Please see the comments in the following codes, at the moment, A & B both have one audio & video stream separately and B is starting to add an extra sharing video:
static int sdp_requires_deferral(struct ast_sip_session *session, const pjmedia_sdp_session *sdp) { int i; if (!session->pending_media_state->topology) { session->pending_media_state->topology = ast_stream_topology_alloc(); if (!session->pending_media_state->topology) { return -1; } } for (i = 0; i < sdp->media_count; ++i) { /* See if there are registered handlers for this media stream type */ char media[20]; struct ast_sip_session_sdp_handler *handler; RAII_VAR(struct sdp_handler_list *, handler_list, NULL, ao2_cleanup); struct ast_stream *existing_stream = NULL; struct ast_stream *stream; enum ast_media_type type; struct ast_sip_session_media *session_media = NULL; enum ast_sip_session_sdp_stream_defer res; /* We need a null-terminated version of the media string */ ast_copy_pj_str(media, &sdp->media[i]->desc.media, sizeof(media)); /* The stream count of B's active_media_state->topology is 3, one B's audio, one B's video, one A's video with name softbridge_dest_PJSIP... The sdp->media_count is 3, one for audio, one for camera video, one for sharing video Here B's sharing video is map to A's video with name softbridge_dest_PJSIP... */ if (session->active_media_state->topology && (i < ast_stream_topology_get_count(session->active_media_state->topology))) { existing_stream = ast_stream_topology_get_stream(session->active_media_state->topology, i); } type = ast_media_type_from_str(media); stream = ast_stream_alloc(existing_stream ? ast_stream_get_name(existing_stream) : ast_codec_media_type2str(type), type); if (!stream) { return -1; } /* As this is only called on an incoming SDP offer before processing it is not possible * for streams and their media sessions to exist. */ if (ast_stream_topology_set_stream(session->pending_media_state->topology, i, stream)) { ast_stream_free(stream); return -1; } session_media = ast_sip_session_media_state_add(session, session->pending_media_state, ast_media_type_from_str(media), i); if (!session_media) { return -1; } /* If the code of B's new sharing video stream executes here, does it need to call set_mid_and_bundle_group() & set_remote_mslabel_and_stream_group() & handler->negotiate_incoming_sdp_stream for the new stream setup instead of the handler->defer_incoming_sdp_stream()? */ if (session_media->handler) { handler = session_media->handler; if (handler->defer_incoming_sdp_stream) { res = handler->defer_incoming_sdp_stream(session, session_media, sdp, sdp->media[i]); switch (res) { case AST_SIP_SESSION_SDP_DEFER_NOT_HANDLED: break; case AST_SIP_SESSION_SDP_DEFER_ERROR: return 0; case AST_SIP_SESSION_SDP_DEFER_NOT_NEEDED: break; case AST_SIP_SESSION_SDP_DEFER_NEEDED: return 1; } } /* Handled by this handler. Move to the next stream */ continue; } handler_list = ao2_find(sdp_handlers, media, OBJ_KEY); if (!handler_list) { ast_debug(1, "No registered SDP handlers for media type '%s'\n", media); continue; } AST_LIST_TRAVERSE(&handler_list->list, handler, next) { if (handler == session_media->handler) { continue; } if (!handler->defer_incoming_sdp_stream) { continue; } res = handler->defer_incoming_sdp_stream(session, session_media, sdp, sdp->media[i]); switch (res) { case AST_SIP_SESSION_SDP_DEFER_NOT_HANDLED: continue; case AST_SIP_SESSION_SDP_DEFER_ERROR: session_media_set_handler(session_media, handler); return 0; case AST_SIP_SESSION_SDP_DEFER_NOT_NEEDED: /* Handled by this handler. */ session_media_set_handler(session_media, handler); break; case AST_SIP_SESSION_SDP_DEFER_NEEDED: /* Handled by this handler. */ session_media_set_handler(session_media, handler); return 1; } /* Move to the next stream */ break; } } return 0; } Joshua C. Colp <jc...@digium.com> 于2019年5月8日周三 下午5:14写道: > On Wed, May 8, 2019, at 12:07 AM, Xiemin Chen wrote: > > Hi there, > > > > *Problem* > > > > In a WebRTC conference, participant A & B join with only one video > > track, then B add another video track with the SDP renegotiate, A > > cannot see B's two video tracks. > > > > *Root Cause* > > * > > * > > After work through the source code, the problem may caused by the > > sdp_requires_deferral() in res_pjsip_session.c: > > It does not take of the situation of the new creation of the video > > track. > > > > *Solution* > > > > Can I use the handle_incoming_sdp() to replace the > > sdp_requires_deferal() ? handle_incoming_sdp() function is called > > during the init of the session, it does the track initial progress. > > The sdp_requires_deferral function and its functionality has to continue > to exist, or T.38 fax will be non-functional. The sdp_requires_deferral > function would need to be examined based on your scenario and adjusted > accordingly however it makes sense. Looking at the function I'm also not > sure why it would cause any problems with your scenario, as it should just > result in some things being set up and that's pretty much it but I have not > looked into it deeply or reproduced the problem. > > -- > Joshua C. Colp > Digium - A Sangoma Company | Senior Software Developer > 445 Jan Davis Drive NW - Huntsville, AL 35806 - US > Check us out at: www.digium.com & www.asterisk.org > > -- > _____________________________________________________________________ > -- Bandwidth and Colocation Provided by http://www.api-digital.com -- > > asterisk-dev mailing list > To UNSUBSCRIBE or update options visit: > http://lists.digium.com/mailman/listinfo/asterisk-dev
-- _____________________________________________________________________ -- Bandwidth and Colocation Provided by http://www.api-digital.com -- asterisk-dev mailing list To UNSUBSCRIBE or update options visit: http://lists.digium.com/mailman/listinfo/asterisk-dev