dashdemux: don't meddle with the class struct from an instance
authorTim-Philipp Müller <tim@centricular.com>
Fri, 21 Aug 2015 15:13:43 +0000 (16:13 +0100)
committerTim-Philipp Müller <tim@centricular.com>
Wed, 26 Aug 2015 23:35:02 +0000 (00:35 +0100)
Fix some very dubious code. The class methods should always
be set, and the instance-specific check should then be done
inside the method. For data_received that's there already, for
finish_fragment we need to add it.

https://bugzilla.gnome.org/show_bug.cgi?id=753937

ext/dash/gstdashdemux.c

index 5a1e1a513ab9ed41a709a547d6ff812f0678fa0b..48ad520fad2effd327270b9b61a2c6a728395862 100644 (file)
@@ -411,6 +411,10 @@ gst_dash_demux_class_init (GstDashDemuxClass * klass)
       gst_dash_demux_get_live_seek_range;
   gstadaptivedemux_class->get_presentation_offset =
       gst_dash_demux_get_presentation_offset;
+
+  gstadaptivedemux_class->finish_fragment =
+      gst_dash_demux_stream_fragment_finished;
+  gstadaptivedemux_class->data_received = gst_dash_demux_data_received;
 }
 
 static void
@@ -702,7 +706,6 @@ done:
 static gboolean
 gst_dash_demux_process_manifest (GstAdaptiveDemux * demux, GstBuffer * buf)
 {
-  GstAdaptiveDemuxClass *klass;
   GstDashDemux *dashdemux = GST_DASH_DEMUX_CAST (demux);
   gboolean ret = FALSE;
   gchar *manifest;
@@ -722,13 +725,6 @@ gst_dash_demux_process_manifest (GstAdaptiveDemux * demux, GstBuffer * buf)
   if (gst_buffer_map (buf, &mapinfo, GST_MAP_READ)) {
     manifest = (gchar *) mapinfo.data;
     if (gst_mpd_parse (dashdemux->client, manifest, mapinfo.size)) {
-      if (gst_mpd_client_has_isoff_ondemand_profile (dashdemux->client)) {
-        klass = GST_ADAPTIVE_DEMUX_GET_CLASS (dashdemux);
-
-        klass->data_received = gst_dash_demux_data_received;
-        klass->finish_fragment = gst_dash_demux_stream_fragment_finished;
-      }
-
       if (gst_mpd_client_setup_media_presentation (dashdemux->client)) {
         ret = TRUE;
       } else {
@@ -1434,6 +1430,7 @@ gst_dash_demux_stream_fragment_finished (GstAdaptiveDemux * demux,
       dashstream->sidx_parser.status == GST_ISOFF_SIDX_PARSER_FINISHED)
     /* fragment is advanced on data_received when byte limits are reached */
     return GST_FLOW_OK;
+
   if (G_UNLIKELY (stream->downloading_header || stream->downloading_index))
     return GST_FLOW_OK;
 
@@ -1446,10 +1443,15 @@ gst_dash_demux_data_received (GstAdaptiveDemux * demux,
     GstAdaptiveDemuxStream * stream)
 {
   GstDashDemuxStream *dash_stream = (GstDashDemuxStream *) stream;
+  GstDashDemux *dashdemux = GST_DASH_DEMUX_CAST (demux);
   GstFlowReturn ret = GST_FLOW_OK;
   GstBuffer *buffer;
   gsize available;
 
+  if (!gst_mpd_client_has_isoff_ondemand_profile (dashdemux->client))
+    return GST_ADAPTIVE_DEMUX_CLASS (parent_class)->data_received (demux,
+        stream);
+
   if (stream->downloading_index) {
     GstIsoffParserResult res;
     guint consumed;