summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorSebastian Dröge <sebastian@centricular.com>2016-05-25 16:01:24 +0300
committerSebastian Dröge <sebastian@centricular.com>2016-07-01 14:11:51 +0200
commit43a2ee8948584a51befe531c6f817493b6e9ae73 (patch)
treefe20fa8f646ad2fc10f192b7f186ff47f4aa7b86
parent91e398ddd6bcf8633e511b73fbd71f1786efec20 (diff)
downloadgstreamer-plugins-bad-43a2ee8948584a51befe531c6f817493b6e9ae73.tar.gz
adaptivedemux: Add custom flow return for allowing subclasses to specify when a fragment is finished
If it is finished before upstream going EOS. https://bugzilla.gnome.org/show_bug.cgi?id=767365
-rw-r--r--gst-libs/gst/adaptivedemux/gstadaptivedemux.c25
-rw-r--r--gst-libs/gst/adaptivedemux/gstadaptivedemux.h2
2 files changed, 21 insertions, 6 deletions
diff --git a/gst-libs/gst/adaptivedemux/gstadaptivedemux.c b/gst-libs/gst/adaptivedemux/gstadaptivedemux.c
index 4e1f2b959..5e967bfb8 100644
--- a/gst-libs/gst/adaptivedemux/gstadaptivedemux.c
+++ b/gst-libs/gst/adaptivedemux/gstadaptivedemux.c
@@ -157,10 +157,8 @@ enum
PROP_LAST
};
-enum GstAdaptiveDemuxFlowReturn
-{
- GST_ADAPTIVE_DEMUX_FLOW_SWITCH = GST_FLOW_CUSTOM_SUCCESS_2 + 1
-};
+/* Internal, so not using GST_FLOW_CUSTOM_SUCCESS_N */
+#define GST_ADAPTIVE_DEMUX_FLOW_SWITCH (GST_FLOW_CUSTOM_SUCCESS_2 + 1)
struct _GstAdaptiveDemuxPrivate
{
@@ -2136,6 +2134,8 @@ _src_chain (GstPad * pad, GstObject * parent, GstBuffer * buffer)
GST_TIME_AS_USECONDS (gst_adaptive_demux_get_monotonic_time (demux));
if (ret != GST_FLOW_OK) {
+ gboolean finished = FALSE;
+
if (ret < GST_FLOW_EOS) {
GST_ELEMENT_ERROR (demux, STREAM, FAILED, (NULL),
("stream stopped, reason %s", gst_flow_get_name (ret)));
@@ -2147,9 +2147,22 @@ _src_chain (GstPad * pad, GstObject * parent, GstBuffer * buffer)
gst_flow_get_name (ret));
}
- gst_adaptive_demux_stream_fragment_download_finish (stream, ret, NULL);
- if (ret == (GstFlowReturn) GST_ADAPTIVE_DEMUX_FLOW_SWITCH)
+ if (ret == (GstFlowReturn) GST_ADAPTIVE_DEMUX_FLOW_SWITCH) {
ret = GST_FLOW_EOS; /* return EOS to make the source stop */
+ } else if (ret == GST_ADAPTIVE_DEMUX_FLOW_END_OF_FRAGMENT) {
+ /* Behaves like an EOS event from upstream */
+ ret = klass->finish_fragment (demux, stream);
+ if (ret == (GstFlowReturn) GST_ADAPTIVE_DEMUX_FLOW_SWITCH) {
+ ret = GST_FLOW_EOS; /* return EOS to make the source stop */
+ } else if (ret != GST_FLOW_OK) {
+ goto error;
+ }
+ finished = TRUE;
+ }
+
+ gst_adaptive_demux_stream_fragment_download_finish (stream, ret, NULL);
+ if (finished)
+ ret = GST_FLOW_EOS;
}
error:
diff --git a/gst-libs/gst/adaptivedemux/gstadaptivedemux.h b/gst-libs/gst/adaptivedemux/gstadaptivedemux.h
index 3db54bb44..c75309f67 100644
--- a/gst-libs/gst/adaptivedemux/gstadaptivedemux.h
+++ b/gst-libs/gst/adaptivedemux/gstadaptivedemux.h
@@ -81,6 +81,8 @@ G_BEGIN_DECLS
g_clear_error (&err); \
} G_STMT_END
+#define GST_ADAPTIVE_DEMUX_FLOW_END_OF_FRAGMENT GST_FLOW_CUSTOM_SUCCESS_1
+
typedef struct _GstAdaptiveDemuxStreamFragment GstAdaptiveDemuxStreamFragment;
typedef struct _GstAdaptiveDemuxStream GstAdaptiveDemuxStream;
typedef struct _GstAdaptiveDemux GstAdaptiveDemux;