summaryrefslogtreecommitdiff
path: root/main/stream.c
diff options
context:
space:
mode:
authorMark Michelson <mmichelson@digium.com>2017-05-05 11:56:34 -0500
committerMark Michelson <mmichelson@digium.com>2017-05-30 10:24:01 -0500
commit2da869408ae5556022526bcd0f526d92fdbb5a5f (patch)
tree808a36331147ecca75186a2d25bc21d3928643bf /main/stream.c
parentdece2eb8929c11bad30616d8f3a236ed449c718c (diff)
Add primitive SFU support to bridge_softmix.
This sets up the "plumbing" in bridge_softmix to be able to accommodate Asterisk asking as an SFU (selective forwarding unit) for conferences. The way this works is that whenever a channel enters or leaves a conference, all participants in the bridge get sent a stream topology change request. The topologies consist of the channels' original topology, along with video destination streams corresponding to each participants' source video streams. So for instance, if Alice, Bob, and Carol are in the conference, and each supplies one video stream, then the topologies for each would look like so: Alice: Audio, Source video(Alice), Destination Video(Bob), Destination video (Carol) Bob: Audio, Source video(Bob) Destination Video(Alice), Destination video (Carol) Carol: Audio, Source video(Carol) Destination Video(Alice), Destination video (Bob) This way, video that arrives from a source video stream can then be copied out to the destination video streams on the other participants' channels. Once the bridge gets told that a topology on a channel has changed, the bridge constructs a map in order to get the video frames routed to the proper destination streams. This is done using the bridge channel's stream_map. This change is bare-bones with regards to SFU support. Some key features are missing at this point: * Stream limits. This commit makes no effort to limit the number of streams on a specific channel. This means that if there were 50 video callers in a conference, bridge_softmix will happily send out topology change requests to every channel in the bridge, requesting 50+ streams. * Configuration. The plumbing has been added to bridge_softmix, but there has been nothing added as of yet to app_confbridge to enable SFU video mode. * Testing. Some functions included here have unit tests. However, the functionality as a whole has only been verified by hand-tracing the code. * Selectivenss. For a "selective" forwarding unit, this does not currently have any means of being selective. * Features. Presumably, someone might wish to only receive video from specific sources. There are no external-facing functions at the moment that allow for users to select who they receive video from. * Efficiency. The current scheme treats all video streams as being unidirectional. We could be re-using a source video stream as a desetnation, too. But to simplify things on this first round, I did it this way. Change-Id: I7c44a829cc63acf8b596a337b2dc3c13898a6c4d
Diffstat (limited to 'main/stream.c')
-rw-r--r--main/stream.c11
1 files changed, 7 insertions, 4 deletions
diff --git a/main/stream.c b/main/stream.c
index 804a0b8ee..fb146931d 100644
--- a/main/stream.c
+++ b/main/stream.c
@@ -95,23 +95,26 @@ struct ast_stream *ast_stream_alloc(const char *name, enum ast_media_type type)
return stream;
}
-struct ast_stream *ast_stream_clone(const struct ast_stream *stream)
+struct ast_stream *ast_stream_clone(const struct ast_stream *stream, const char *name)
{
struct ast_stream *new_stream;
size_t stream_size;
int idx;
+ const char *stream_name;
if (!stream) {
return NULL;
}
- stream_size = sizeof(*stream) + strlen(stream->name) + 1;
+ stream_name = name ?: stream->name;
+ stream_size = sizeof(*stream) + strlen(stream_name) + 1;
new_stream = ast_calloc(1, stream_size);
if (!new_stream) {
return NULL;
}
- memcpy(new_stream, stream, stream_size);
+ memcpy(new_stream, stream, sizeof(*new_stream));
+ strcpy(new_stream->name, stream_name); /* Safe */
if (new_stream->formats) {
ao2_ref(new_stream->formats, +1);
}
@@ -269,7 +272,7 @@ struct ast_stream_topology *ast_stream_topology_clone(
for (i = 0; i < AST_VECTOR_SIZE(&topology->streams); i++) {
struct ast_stream *stream =
- ast_stream_clone(AST_VECTOR_GET(&topology->streams, i));
+ ast_stream_clone(AST_VECTOR_GET(&topology->streams, i), NULL);
if (!stream || AST_VECTOR_APPEND(&new_topology->streams, stream)) {
ast_stream_free(stream);