diff options
author | Mathieu Duponchelle <mathieu@centricular.com> | 2019-04-25 20:23:03 +0200 |
---|---|---|
committer | Mathieu Duponchelle <mduponchelle1@gmail.com> | 2019-05-19 19:40:48 +0000 |
commit | ea011a3266ad0dce040bfa5adb2b830e2be2985f (patch) | |
tree | c52985d7c8d49ba37e75a862c1cc9088002dadc1 /gst/mpegtsmux/tsmux | |
parent | 80bfa16c95c8dff979d6609cfc31274b6d01c78d (diff) | |
download | gstreamer-plugins-bad-ea011a3266ad0dce040bfa5adb2b830e2be2985f.tar.gz |
mpegtsmux: provide API for subclasses to override stream creation
Diffstat (limited to 'gst/mpegtsmux/tsmux')
-rw-r--r-- | gst/mpegtsmux/tsmux/tsmux.c | 26 | ||||
-rw-r--r-- | gst/mpegtsmux/tsmux/tsmux.h | 5 |
2 files changed, 30 insertions, 1 deletions
diff --git a/gst/mpegtsmux/tsmux/tsmux.c b/gst/mpegtsmux/tsmux/tsmux.c index f22ce2406..aa2cc436e 100644 --- a/gst/mpegtsmux/tsmux/tsmux.c +++ b/gst/mpegtsmux/tsmux/tsmux.c @@ -153,6 +153,9 @@ tsmux_new (void) mux->si_sections = g_hash_table_new_full (g_direct_hash, g_direct_equal, NULL, (GDestroyNotify) tsmux_section_free); + mux->new_stream_func = (TsMuxNewStreamFunc) tsmux_stream_new; + mux->new_stream_data = NULL; + return mux; } @@ -194,6 +197,26 @@ tsmux_set_alloc_func (TsMux * mux, TsMuxAllocFunc func, void *user_data) } /** + * tsmux_set_new_stream_func: + * @mux: a #TsMux + * @func: a user callback function + * @user_data: user data passed to @func + * + * Set the callback function and user data to be called when @mux needs + * to create a new stream. + * @user_data will be passed as user data in @func. + */ +void +tsmux_set_new_stream_func (TsMux * mux, TsMuxNewStreamFunc func, + void *user_data) +{ + g_return_if_fail (mux != NULL); + + mux->new_stream_func = func; + mux->new_stream_data = user_data; +} + +/** * tsmux_set_pat_interval: * @mux: a #TsMux * @freq: a new PAT interval @@ -556,6 +579,7 @@ tsmux_create_stream (TsMux * mux, TsMuxStreamType stream_type, guint16 pid, guint16 new_pid; g_return_val_if_fail (mux != NULL, NULL); + g_return_val_if_fail (mux->new_stream_func != NULL, NULL); if (pid == TSMUX_PID_AUTO) { new_pid = tsmux_get_new_pid (mux); @@ -567,7 +591,7 @@ tsmux_create_stream (TsMux * mux, TsMuxStreamType stream_type, guint16 pid, if (tsmux_find_stream (mux, new_pid)) return NULL; - stream = tsmux_stream_new (new_pid, stream_type); + stream = mux->new_stream_func (new_pid, stream_type, mux->new_stream_data); mux->streams = g_list_prepend (mux->streams, stream); mux->nb_streams++; diff --git a/gst/mpegtsmux/tsmux/tsmux.h b/gst/mpegtsmux/tsmux/tsmux.h index a8da29b7f..42b877593 100644 --- a/gst/mpegtsmux/tsmux/tsmux.h +++ b/gst/mpegtsmux/tsmux/tsmux.h @@ -102,6 +102,7 @@ typedef struct TsMux TsMux; typedef gboolean (*TsMuxWriteFunc) (GstBuffer * buf, void *user_data, gint64 new_pcr); typedef void (*TsMuxAllocFunc) (GstBuffer ** buf, void *user_data); +typedef TsMuxStream * (*TsMuxNewStreamFunc) (guint16 new_pid, TsMuxStreamType stream_type, void *user_data); struct TsMuxSection { TsMuxPacketInfo pi; @@ -175,6 +176,9 @@ struct TsMux { /* callback to alloc new packet buffer */ TsMuxAllocFunc alloc_func; void *alloc_func_data; + /* callback to create a new stream */ + TsMuxNewStreamFunc new_stream_func; + void *new_stream_data; /* scratch space for writing ES_info descriptors */ guint8 es_info_buf[TSMUX_MAX_ES_INFO_LENGTH]; @@ -190,6 +194,7 @@ void tsmux_free (TsMux *mux); /* Setting muxing session properties */ void tsmux_set_write_func (TsMux *mux, TsMuxWriteFunc func, void *user_data); void tsmux_set_alloc_func (TsMux *mux, TsMuxAllocFunc func, void *user_data); +void tsmux_set_new_stream_func (TsMux * mux, TsMuxNewStreamFunc func, void *user_data); void tsmux_set_pat_interval (TsMux *mux, guint interval); guint tsmux_get_pat_interval (TsMux *mux); void tsmux_resend_pat (TsMux *mux); |