qtdemux: cenc aux info parsing from mdat support in PULL mode
authorPhilippe Normand <philn@igalia.com>
Thu, 25 Feb 2016 10:33:13 +0000 (11:33 +0100)
committerSebastian Dröge <sebastian@centricular.com>
Thu, 25 Feb 2016 10:46:27 +0000 (12:46 +0200)
This is already supported for PUSH mode but was failing in PULL mode.
The aux info is sometimes stored in the mdat before the first sample,
so the loop task needs to pull data stored at that location and
perform the aux info cenc parsing.

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

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

gst/isomp4/qtdemux.c

index a8bd06c..5334b6c 100644 (file)
@@ -3458,7 +3458,7 @@ qtdemux_parse_moof (GstQTDemux * qtdemux, const guint8 * buffer, guint length,
         qtdemux->cenc_aux_info_sizes = NULL;
         goto fail;
       }
-      if (base_offset > qtdemux->moof_offset)
+      if (base_offset > -1 && base_offset > qtdemux->moof_offset)
         offset += (guint64) (base_offset - qtdemux->moof_offset);
       if (info_type == FOURCC_cenc && info_type_parameter == 0U) {
         GstByteReader br;
@@ -5220,6 +5220,30 @@ gst_qtdemux_loop_state_movie (GstQTDemux * qtdemux)
         MIN (sample_size - stream->offset_in_sample, stream->max_buffer_size);
   }
 
+  if (qtdemux->cenc_aux_info_offset > 0) {
+    GstMapInfo map;
+    GstByteReader br;
+    GstBuffer* aux_info = NULL;
+
+    /* pull the data stored before the sample */
+    ret = gst_qtdemux_pull_atom (qtdemux, qtdemux->offset, offset + stream->offset_in_sample - qtdemux->offset, &aux_info);
+    if (G_UNLIKELY (ret != GST_FLOW_OK))
+      goto beach;
+    gst_buffer_map(aux_info, &map, GST_MAP_READ);
+    GST_DEBUG_OBJECT (qtdemux, "parsing cenc auxiliary info");
+    gst_byte_reader_init (&br, map.data + 8, map.size);
+    if (!qtdemux_parse_cenc_aux_info (qtdemux, stream, &br,
+                                      qtdemux->cenc_aux_info_sizes, qtdemux->cenc_aux_sample_count)) {
+      GST_ERROR_OBJECT (qtdemux, "failed to parse cenc auxiliary info");
+      gst_buffer_unmap(aux_info, &map);
+      gst_buffer_unref(aux_info);
+      ret = GST_FLOW_ERROR;
+      goto beach;
+    }
+    gst_buffer_unmap(aux_info, &map);
+    gst_buffer_unref(aux_info);
+  }
+
   GST_LOG_OBJECT (qtdemux, "reading %d bytes @ %" G_GUINT64_FORMAT, size,
       offset);