diff options
author | Edward Hervey <edward@centricular.com> | 2016-10-11 11:11:16 +0200 |
---|---|---|
committer | Edward Hervey <bilboed@bilboed.com> | 2016-10-12 15:07:46 +0200 |
commit | 6622e2dacf3d61d880ac7bcccf5680f62ccac7a0 (patch) | |
tree | d17910638b406b42241514fbafec148d87e2fb89 /gst/mpegtsdemux/tsdemux.c | |
parent | ddacbb7793cd1614b4c7d8681af60e12364dba14 (diff) | |
download | gstreamer-plugins-bad-6622e2dacf3d61d880ac7bcccf5680f62ccac7a0.tar.gz |
mpegtsdemux: Implement efficient program updates
If the parent bin can handle it, only add/remove the new/gone stream
instead of re-adding/re-moving everything
https://bugzilla.gnome.org/show_bug.cgi?id=772742
Diffstat (limited to 'gst/mpegtsdemux/tsdemux.c')
-rw-r--r-- | gst/mpegtsdemux/tsdemux.c | 31 |
1 files changed, 31 insertions, 0 deletions
diff --git a/gst/mpegtsdemux/tsdemux.c b/gst/mpegtsdemux/tsdemux.c index b08fd3404..fe0c3a6d3 100644 --- a/gst/mpegtsdemux/tsdemux.c +++ b/gst/mpegtsdemux/tsdemux.c @@ -281,6 +281,8 @@ enum /* mpegtsbase methods */ static void +gst_ts_demux_update_program (MpegTSBase * base, MpegTSBaseProgram * program); +static void gst_ts_demux_program_started (MpegTSBase * base, MpegTSBaseProgram * program); static void gst_ts_demux_program_stopped (MpegTSBase * base, MpegTSBaseProgram * program); @@ -385,6 +387,7 @@ gst_ts_demux_class_init (GstTSDemuxClass * klass) ts_class->push_event = GST_DEBUG_FUNCPTR (push_event); ts_class->program_started = GST_DEBUG_FUNCPTR (gst_ts_demux_program_started); ts_class->program_stopped = GST_DEBUG_FUNCPTR (gst_ts_demux_program_stopped); + ts_class->update_program = GST_DEBUG_FUNCPTR (gst_ts_demux_update_program); ts_class->can_remove_program = gst_ts_demux_can_remove_program; ts_class->stream_added = gst_ts_demux_stream_added; ts_class->stream_removed = gst_ts_demux_stream_removed; @@ -1826,6 +1829,34 @@ gst_ts_demux_can_remove_program (MpegTSBase * base, MpegTSBaseProgram * program) return TRUE; } +static void +gst_ts_demux_update_program (MpegTSBase * base, MpegTSBaseProgram * program) +{ + GstTSDemux *demux = GST_TS_DEMUX (base); + GList *tmp; + + GST_DEBUG ("Updating program %d", program->program_number); + /* Emit collection message */ + gst_element_post_message ((GstElement *) base, + gst_message_new_stream_collection ((GstObject *) base, + program->collection)); + + /* Add all streams, then fire no-more-pads */ + for (tmp = program->stream_list; tmp; tmp = tmp->next) { + TSDemuxStream *stream = (TSDemuxStream *) tmp->data; + if (!stream->pad) { + activate_pad_for_stream (demux, stream); + if (stream->sparse) { + /* force sending of pending sticky events which have been stored on the + * pad already and which otherwise would only be sent on the first buffer + * or serialized event (which means very late in case of subtitle streams), + * and playsink waits for stream-start or another serialized event */ + GST_DEBUG_OBJECT (stream->pad, "sparse stream, pushing GAP event"); + gst_pad_push_event (stream->pad, gst_event_new_gap (0, 0)); + } + } + } +} static void gst_ts_demux_program_started (MpegTSBase * base, MpegTSBaseProgram * program) |