From: Joshua C. Colp Date: Thu, 19 Mar 2020 13:48:39 +0000 (-0300) Subject: res_pjsip_session: Don't restrict non-audio default streams to sendrecv. X-Git-Tag: 18.0.0-rc1~183 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=9620ecbf80fa8a3b93f22798489e3d0bb469dfab;p=thirdparty%2Fasterisk.git res_pjsip_session: Don't restrict non-audio default streams to sendrecv. The state of the default audio stream is used for hold/unhold so we restrict it to sendrecv as the core does not handle when it changes as a result of hold/unhold. This restriction does not apply to other media types though so we now only restrict it to audio. This allows the other default streams to store their state at all values, and not just sendrecv and removed. ASTERISK-28783 Change-Id: I139740f38cea7f7d92a876ec2631ef50681f6625 --- diff --git a/res/res_pjsip_session.c b/res/res_pjsip_session.c index 0c752b80f2..11abe81f4c 100644 --- a/res/res_pjsip_session.c +++ b/res/res_pjsip_session.c @@ -769,8 +769,8 @@ static int handle_incoming_sdp(struct ast_sip_session *session, const pjmedia_sd ast_stream_free(stream); return -1; } - /* For backwards compatibility with the core default streams are always sendrecv */ - if (!ast_sip_session_is_pending_stream_default(session, stream)) { + /* For backwards compatibility with the core the default audio stream is always sendrecv */ + if (!ast_sip_session_is_pending_stream_default(session, stream) || strcmp(media, "audio")) { if (pjmedia_sdp_media_find_attr2(remote_stream, "sendonly", NULL)) { /* Stream state reflects our state of a stream, so in the case of * sendonly and recvonly we store the opposite since that is what ours @@ -880,12 +880,16 @@ static int handle_negotiated_sdp_session_media(struct ast_sip_session_media *ses RAII_VAR(struct sdp_handler_list *, handler_list, NULL, ao2_cleanup); int res; + /* We need a null-terminated version of the media string */ + ast_copy_pj_str(media, &local->media[index]->desc.media, sizeof(media)); + /* For backwards compatibility we only reflect the stream state correctly on - * the non-default streams. This is because the stream state is also used for - * signaling that someone has placed us on hold. This situation is not handled - * currently and can result in the remote side being sort of placed on hold too. + * the non-default streams and any non-audio streams. This is because the stream + * state of the default audio stream is also used for signaling that someone has + * placed us on hold. This situation is not handled currently and can result in + * the remote side being sorted of placed on hold too. */ - if (!ast_sip_session_is_pending_stream_default(session, asterisk_stream)) { + if (!ast_sip_session_is_pending_stream_default(session, asterisk_stream) || strcmp(media, "audio")) { /* Determine the state of the stream based on our local SDP */ if (pjmedia_sdp_media_find_attr2(local_stream, "sendonly", NULL)) { ast_stream_set_state(asterisk_stream, AST_STREAM_STATE_SENDONLY); @@ -900,9 +904,6 @@ static int handle_negotiated_sdp_session_media(struct ast_sip_session_media *ses ast_stream_set_state(asterisk_stream, AST_STREAM_STATE_SENDRECV); } - /* We need a null-terminated version of the media string */ - ast_copy_pj_str(media, &local->media[index]->desc.media, sizeof(media)); - set_mid_and_bundle_group(session, session_media, remote, remote->media[index]); set_remote_mslabel_and_stream_group(session, session_media, remote, remote->media[index], asterisk_stream); @@ -1974,8 +1975,8 @@ static int sdp_requires_deferral(struct ast_sip_session *session, const pjmedia_ return -1; } - /* For backwards compatibility with the core default streams are always sendrecv */ - if (!ast_sip_session_is_pending_stream_default(session, stream)) { + /* For backwards compatibility with the core the default audio stream is always sendrecv */ + if (!ast_sip_session_is_pending_stream_default(session, stream) || strcmp(media, "audio")) { if (pjmedia_sdp_media_find_attr2(remote_stream, "sendonly", NULL)) { /* Stream state reflects our state of a stream, so in the case of * sendonly and recvonly we store the opposite since that is what ours