diff options
author | Joshua Colp <jcolp@digium.com> | 2017-10-25 22:31:33 +0000 |
---|---|---|
committer | Joshua Colp <jcolp@digium.com> | 2017-10-30 17:10:03 -0500 |
commit | 4c535f5c30f7271f89d236f98fdfba101d73ff34 (patch) | |
tree | 6d867aa49526eadf221b08bb4d1542b4c22a1f4e /main/stream.c | |
parent | be5b7b2076a577c2a994e752b152c5242fb29ce7 (diff) |
core / pjsip: Add support for grouping streams together.
In WebRTC streams (or media tracks in their world) can be grouped
together using the mslabel. This informs the browser that each
should be synchronized with each other.
This change extends the stream API so this information can
be stored with streams. The PJSIP support has been extended
to use the mslabel to determine grouped streams and store
this association on the streams. Finally when creating the
SDP the group information is used to cause each media stream
to use the same mslabel.
ASTERISK-27379
Change-Id: Id6299aa031efe46254edbdc7973c534d54d641ad
Diffstat (limited to 'main/stream.c')
-rw-r--r-- | main/stream.c | 27 |
1 files changed, 25 insertions, 2 deletions
diff --git a/main/stream.c b/main/stream.c index 89ed0dc53..c233b2f34 100644 --- a/main/stream.c +++ b/main/stream.c @@ -67,6 +67,11 @@ struct ast_stream { ast_stream_data_free_fn data_free_fn[AST_STREAM_DATA_SLOT_MAX]; /*! + * \brief The group that the stream is part of + */ + int group; + + /*! * \brief Name for the stream within the context of the channel it is on */ char name[0]; @@ -90,6 +95,7 @@ struct ast_stream *ast_stream_alloc(const char *name, enum ast_media_type type) stream->type = type; stream->state = AST_STREAM_STATE_INACTIVE; + stream->group = -1; strcpy(stream->name, S_OR(name, "")); /* Safe */ return stream; @@ -115,6 +121,7 @@ struct ast_stream *ast_stream_clone(const struct ast_stream *stream, const char memcpy(new_stream, stream, sizeof(*new_stream)); strcpy(new_stream->name, stream_name); /* Safe */ + new_stream->group = -1; if (new_stream->formats) { ao2_ref(new_stream->formats, +1); } @@ -288,14 +295,16 @@ 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), NULL); + struct ast_stream *existing = AST_VECTOR_GET(&topology->streams, i); + struct ast_stream *stream = ast_stream_clone(existing, NULL); if (!stream || AST_VECTOR_APPEND(&new_topology->streams, stream)) { ast_stream_free(stream); ast_stream_topology_free(new_topology); return NULL; } + + ast_stream_set_group(stream, ast_stream_get_group(existing)); } return new_topology; @@ -580,3 +589,17 @@ void ast_stream_topology_map(const struct ast_stream_topology *topology, AST_VECTOR_REPLACE(v1, index, i); } } + +int ast_stream_get_group(const struct ast_stream *stream) +{ + ast_assert(stream != NULL); + + return stream->group; +} + +void ast_stream_set_group(struct ast_stream *stream, int group) +{ + ast_assert(stream != NULL); + + stream->group = group; +} |