freeswitch icon indicating copy to clipboard operation
freeswitch copied to clipboard

RTP Media Timeout is broken for calls on hold

Open shaunjstokes opened this issue 2 years ago • 6 comments

If both 'media_hold_timeout_audio' and 'media_timeout_audio' are set, and 'media_timeout_audio' has a value less than 'media_hold_timeout_audio', then 'media_timeout_audio' is used instead of 'media_hold_timeout_audio' while the call is on hold.

This is a bug that's been introduced in 1.10.8 (and master), as a result of the following changes. src/switch_core_media.c

		if (engine->type == SWITCH_MEDIA_TYPE_AUDIO) {
			/* the values are in milliseconds, not in seconds as the deprecated rtp_timeout_sec */
			engine->max_missed_packets = (engine->read_impl.samples_per_second * engine->media_timeout / 1000) / engine->read_impl.samples_per_packet;

			switch_rtp_set_max_missed_packets(engine->rtp_session, engine->max_missed_packets);
			if (!engine->media_hold_timeout) {
				engine->media_hold_timeout = engine->media_timeout * 10;
			}

			engine->max_missed_hold_packets = (engine->read_impl.samples_per_second * engine->media_hold_timeout / 1000) / engine->read_impl.samples_per_packet;
		}

In this commit: https://github.com/signalwire/freeswitch/commit/beffab1d680104f2c469d0947a2a8b0e09d9c343

Reversing the above changes resolves the issue.

@dragos-oancea @andywolk can you please comment on the above, would you like me to create a pull request to roll this back?

shaunjstokes avatar Jan 31 '23 11:01 shaunjstokes