mirror of
https://github.com/asterisk/asterisk.git
synced 2025-10-12 15:45:18 +00:00
bridging: Add better support for adding/removing streams.
This change adds support to bridge_softmix to allow the addition and removal of additional video source streams. When such a change occurs each participant is renegotiated as needed to reflect the update. If another video source is added then each participant gets another source. If a video source is removed then it is removed from each participant. This functionality allows you to have both your webcam and screenshare providing video if you desire, or even more streams. Mapping has been changed to use the topology index on the source channel as a unique identifier for outgoing participant streams, this will never change and provides an easy way to establish the mapping. The bridge_simple and bridge_native_rtp modules have also been updated to renegotiate when the stream topology of a party changes allowing the same behavior to occur as added to bridge_softmix. If a screen share is added then the opposite party is renegotiated. If that screen share is removed then the opposite party is renegotiated again. Some additional fixes are also included in here. Stream state is now conveyed in SDP so sendonly/recvonly/inactive streams can be requested. Removed streams now also remove previous state from themselves so consumers don't get confused. ASTERISK-28733 Change-Id: I93f41fb41b85646bef71408111c17ccea30cb0c5
This commit is contained in:
committed by
Joshua Colp
parent
a6de4497e6
commit
5a5be92b79
@@ -952,7 +952,7 @@ static int handle_negotiated_sdp(struct ast_sip_session *session, const pjmedia_
|
||||
{
|
||||
int i;
|
||||
struct ast_stream_topology *topology;
|
||||
unsigned int changed = 0;
|
||||
unsigned int changed = 0; /* 0 = unchanged, 1 = new source, 2 = new topology */
|
||||
|
||||
if (!session->pending_media_state->topology) {
|
||||
if (session->active_media_state->topology) {
|
||||
@@ -1064,6 +1064,14 @@ static int handle_negotiated_sdp(struct ast_sip_session *session, const pjmedia_
|
||||
topology = ast_stream_topology_clone(session->pending_media_state->topology);
|
||||
if (topology) {
|
||||
ast_channel_set_stream_topology(session->channel, topology);
|
||||
/* If this is a remotely done renegotiation that has changed the stream topology notify what is
|
||||
* currently handling this channel.
|
||||
*/
|
||||
if (pjmedia_sdp_neg_was_answer_remote(session->inv_session->neg) == PJ_FALSE &&
|
||||
session->active_media_state && session->active_media_state->topology &&
|
||||
!ast_stream_topology_equal(session->active_media_state->topology, topology)) {
|
||||
changed = 2;
|
||||
}
|
||||
}
|
||||
|
||||
/* Remove all current file descriptors from the channel */
|
||||
@@ -1086,10 +1094,12 @@ static int handle_negotiated_sdp(struct ast_sip_session *session, const pjmedia_
|
||||
|
||||
ast_channel_unlock(session->channel);
|
||||
|
||||
if (changed) {
|
||||
if (changed == 1) {
|
||||
struct ast_frame f = { AST_FRAME_CONTROL, .subclass.integer = AST_CONTROL_STREAM_TOPOLOGY_SOURCE_CHANGED };
|
||||
|
||||
ast_queue_frame(session->channel, &f);
|
||||
} else if (changed == 2) {
|
||||
ast_channel_stream_topology_changed_externally(session->channel);
|
||||
} else {
|
||||
ast_queue_frame(session->channel, &ast_null_frame);
|
||||
}
|
||||
@@ -1926,6 +1936,7 @@ static int sdp_requires_deferral(struct ast_sip_session *session, const pjmedia_
|
||||
enum ast_media_type type;
|
||||
struct ast_sip_session_media *session_media = NULL;
|
||||
enum ast_sip_session_sdp_stream_defer res;
|
||||
pjmedia_sdp_media *remote_stream = sdp->media[i];
|
||||
|
||||
/* We need a null-terminated version of the media string */
|
||||
ast_copy_pj_str(media, &sdp->media[i]->desc.media, sizeof(media));
|
||||
@@ -1954,6 +1965,25 @@ 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)) {
|
||||
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
|
||||
* is.
|
||||
*/
|
||||
ast_stream_set_state(stream, AST_STREAM_STATE_RECVONLY);
|
||||
} else if (pjmedia_sdp_media_find_attr2(remote_stream, "recvonly", NULL)) {
|
||||
ast_stream_set_state(stream, AST_STREAM_STATE_SENDONLY);
|
||||
} else if (pjmedia_sdp_media_find_attr2(remote_stream, "inactive", NULL)) {
|
||||
ast_stream_set_state(stream, AST_STREAM_STATE_INACTIVE);
|
||||
} else {
|
||||
ast_stream_set_state(stream, AST_STREAM_STATE_SENDRECV);
|
||||
}
|
||||
} else {
|
||||
ast_stream_set_state(stream, AST_STREAM_STATE_SENDRECV);
|
||||
}
|
||||
|
||||
if (session_media->handler) {
|
||||
handler = session_media->handler;
|
||||
if (handler->defer_incoming_sdp_stream) {
|
||||
|
Reference in New Issue
Block a user