summaryrefslogtreecommitdiff
path: root/main/stream.c
diff options
context:
space:
mode:
authorGeorge Joseph <gjoseph@digium.com>2017-03-02 16:11:06 -0700
committerGeorge Joseph <gjoseph@digium.com>2017-03-14 12:26:32 -0600
commit8470c2bdea89f1ed89d8a773d775de96ededf3fb (patch)
tree82c15910f51fa05dca89ed75d3528b9e063b0805 /main/stream.c
parent018e01543dd7392fd99873090b1781c05362b3cf (diff)
RFC sdp: Initial SDP creation
* Added additional fields to ast_sdp_options. * Re-organized ast_sdp. * Updated field names to correspond to RFC4566 terminology. * Created allocs/frees for SDP children. * Created getters/setters for SDP children where appropriate. * Added ast_sdp_create_from_state. * Refactored res_sdp_translator_pjmedia for changes. Change-Id: Iefbd877af7f5a4d3c74deead1bff8802661b0d48
Diffstat (limited to 'main/stream.c')
-rw-r--r--main/stream.c36
1 files changed, 36 insertions, 0 deletions
diff --git a/main/stream.c b/main/stream.c
index 8bee2fdd0..9d36dbf25 100644
--- a/main/stream.c
+++ b/main/stream.c
@@ -57,6 +57,16 @@ struct ast_stream {
enum ast_stream_state state;
/*!
+ * \brief Opaque stream data
+ */
+ void *data[AST_STREAM_DATA_SLOT_MAX];
+
+ /*!
+ * \brief What to do with data when the stream is freed
+ */
+ ast_stream_data_free_fn data_free_fn[AST_STREAM_DATA_SLOT_MAX];
+
+ /*!
* \brief Name for the stream within the context of the channel it is on
*/
char name[0];
@@ -110,10 +120,18 @@ struct ast_stream *ast_stream_clone(const struct ast_stream *stream)
void ast_stream_free(struct ast_stream *stream)
{
+ int i;
+
if (!stream) {
return;
}
+ for (i = 0; i < AST_STREAM_DATA_SLOT_MAX; i++) {
+ if (stream->data_free_fn[i]) {
+ stream->data_free_fn[i](stream->data[i]);
+ }
+ }
+
ao2_cleanup(stream->formats);
ast_free(stream);
}
@@ -186,6 +204,24 @@ const char *ast_stream_state2str(enum ast_stream_state state)
}
}
+void *ast_stream_get_data(struct ast_stream *stream, enum ast_stream_data_slot slot)
+{
+ ast_assert(stream != NULL);
+
+ return stream->data[slot];
+}
+
+void *ast_stream_set_data(struct ast_stream *stream, enum ast_stream_data_slot slot,
+ void *data, ast_stream_data_free_fn data_free_fn)
+{
+ ast_assert(stream != NULL);
+
+ stream->data[slot] = data;
+ stream->data_free_fn[slot] = data_free_fn;
+
+ return data;
+}
+
int ast_stream_get_position(const struct ast_stream *stream)
{
ast_assert(stream != NULL);