From c198d8000c1cfdc1dce77ebf5a604385c7eaf638 Mon Sep 17 00:00:00 2001 From: Wim Taymans Date: Thu, 28 Jun 2007 09:46:11 +0000 Subject: [PATCH] gst/playback/gstdecodebin2.c: When creating the groups, allow for a 5 second, unlimited buffers preroll phase after w... Original commit message from CVS: * gst/playback/gstdecodebin2.c: (gst_decode_group_new), (gst_decode_group_expose), (gst_decode_group_free), (add_fakesink): When creating the groups, allow for a 5 second, unlimited buffers preroll phase after which we expose the group. When the group is exposed, use a small number of buffers up to a 2 second limit. Also disconnect the overrun signal from multiqueue when we exposed the group because it is not needed anymore. --- ChangeLog | 10 ++++++++++ gst/playback/gstdecodebin2.c | 32 +++++++++++++++++++++++++++++--- 2 files changed, 39 insertions(+), 3 deletions(-) diff --git a/ChangeLog b/ChangeLog index 6160f9d903..d5940ab4d1 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,13 @@ +2007-06-28 Wim Taymans + + * gst/playback/gstdecodebin2.c: (gst_decode_group_new), + (gst_decode_group_expose), (gst_decode_group_free), (add_fakesink): + When creating the groups, allow for a 5 second, unlimited buffers + preroll phase after which we expose the group. + When the group is exposed, use a small number of buffers up to a 2 + second limit. Also disconnect the overrun signal from multiqueue when we + exposed the group because it is not needed anymore. + 2007-06-27 Tim-Philipp Müller * gst-libs/gst/tag/tags.c: (gst_tag_freeform_string_to_utf8): diff --git a/gst/playback/gstdecodebin2.c b/gst/playback/gstdecodebin2.c index 1f17cd34c0..5f05e8d1a7 100644 --- a/gst/playback/gstdecodebin2.c +++ b/gst/playback/gstdecodebin2.c @@ -1457,11 +1457,18 @@ gst_decode_group_new (GstDecodeBin * dbin, gboolean use_queue) group->endpads = NULL; if (mq) { + /* we first configure the mulitqueue to buffer an unlimited number of + * buffers up to 5 seconds or, when no timestamps are present, up to 2 MB of + * memory. When this queue overruns, we assume the group is complete and can + * be exposed. */ g_object_set (G_OBJECT (mq), "max-size-bytes", 2 * 1024 * 1024, "max-size-time", 5 * GST_SECOND, "max-size-buffers", 0, NULL); + /* will expose the group */ group->overrunsig = g_signal_connect (G_OBJECT (mq), "overrun", G_CALLBACK (multi_queue_overrun_cb), group); + /* will hide the group again, this is usually called when the multiqueue is + * drained because of EOS. */ group->underrunsig = g_signal_connect (G_OBJECT (mq), "underrun", G_CALLBACK (multi_queue_underrun_cb), group); @@ -1740,7 +1747,6 @@ sort_end_pads (GstDecodePad * da, GstDecodePad * db) * * Not MT safe, please take the group lock */ - static gboolean gst_decode_group_expose (GstDecodeGroup * group) { @@ -1771,6 +1777,21 @@ gst_decode_group_expose (GstDecodeGroup * group) GST_LOG ("Exposing group %p", group); + if (group->multiqueue) { + /* update runtime limits. At runtime, we try to keep the amount of buffers + * in the queues as low as possible (but at least 5 buffers). */ + g_object_set (G_OBJECT (group->multiqueue), + "max-size-bytes", 2 * 1024 * 1024, + "max-size-time", 2 * GST_SECOND, "max-size-buffers", 5, NULL); + /* we can now disconnect any overrun signal, which is used to expose the + * group. */ + if (group->overrunsig) { + GST_LOG ("Disconnecting overrun"); + g_signal_handler_disconnect (group->multiqueue, group->overrunsig); + group->overrunsig = 0; + } + } + /* re-order pads : video, then audio, then others */ group->endpads = g_list_sort (group->endpads, (GCompareFunc) sort_end_pads); @@ -1938,8 +1959,10 @@ gst_decode_group_free (GstDecodeGroup * group) /* disconnect signal handlers on multiqueue */ if (group->multiqueue) { - g_signal_handler_disconnect (group->multiqueue, group->underrunsig); - g_signal_handler_disconnect (group->multiqueue, group->overrunsig); + if (group->underrunsig) + g_signal_handler_disconnect (group->multiqueue, group->underrunsig); + if (group->overrunsig) + g_signal_handler_disconnect (group->multiqueue, group->overrunsig); deactivate_free_recursive (group, group->multiqueue); } @@ -2065,6 +2088,9 @@ add_fakesink (GstDecodeBin * decode_bin) if (!decode_bin->fakesink) goto no_fakesink; + /* enable sync so that we force ASYNC preroll */ + g_object_set (G_OBJECT (decode_bin->fakesink), "sync", TRUE, NULL); + /* hacky, remove sink flag, we don't want our decodebin to become a sink * just because we add a fakesink element to make us ASYNC */ GST_OBJECT_FLAG_UNSET (decode_bin->fakesink, GST_ELEMENT_IS_SINK);