slomo gst-plugins-bad: gst-plugins-bad/ gst-plugins-bad/gst/mxf/

[email protected] Mon, 8 Dec 2008 07:29:13 -0800 (PST)
Newsgroups gmane.comp.video.gstreamer.cvs
Message-ID <[email protected]>
CVS Root:       /cvs/gstreamer
Module:         gst-plugins-bad
Changes by:     slomo
Date:           Mon Dec 08 2008  15:29:13 UTC

Log message:
* gst/mxf/mxfdemux.c: (gst_mxf_demux_reset_metadata),
(gst_mxf_demux_handle_primer_pack),
(gst_mxf_demux_handle_metadata_preface),
(gst_mxf_demux_handle_header_metadata_resolve_references),
(gst_mxf_demux_choose_package),
(gst_mxf_demux_handle_header_metadata_update_streams),
(gst_mxf_demux_parse_footer_metadata),
(gst_mxf_demux_handle_klv_packet):
* gst/mxf/mxfdemux.h:
* gst/mxf/mxftypes.h:
Remove the concept of "final" metadata, broken files have updated
metadata in following partitions even if the current partition
is closed and complete.
If there's a second primer pack inside a partition ignore the second
one instead of throwing an error.
Store the type of a track (audio, video, timestamp, ...) inside the
track struct.
Post no-more-pads only once for a stream and not a second time
when switching the currently playing package.
When updating all streams make sure that we could select and find
a package instead of dereferencing NULL.
Allow descriptive metadata inside metadata parts of a file when
pulling the footer metadata too.
Only switch the currently playing package if a new one was chosen
and the metadata is in a resolved state. If the latter isn't true
postpone the switch until the metadata is resolved.
Pull the footer metadata directly after parsing the header partition
pack if it's not closed or not complete instead of waiting until
the next KLV packet.

Modified files:
    .               : ChangeLog
    gst/mxf         : mxfdemux.c mxfdemux.h mxftypes.h

Links:
http://freedesktop.org/cgi-bin/viewcvs.cgi/gstreamer/gst-plugins-bad/ChangeLog.diff?r1=1.3800&r2=1.3801
http://freedesktop.org/cgi-bin/viewcvs.cgi/gstreamer/gst-plugins-bad/gst/mxf/mxfdemux.c.diff?r1=1.32&r2=1.33
http://freedesktop.org/cgi-bin/viewcvs.cgi/gstreamer/gst-plugins-bad/gst/mxf/mxfdemux.h.diff?r1=1.8&r2=1.9
http://freedesktop.org/cgi-bin/viewcvs.cgi/gstreamer/gst-plugins-bad/gst/mxf/mxftypes.h.diff?r1=1.6&r2=1.7

====Begin Diffs====
Index: ChangeLog
===================================================================
RCS file: /cvs/gstreamer/gst-plugins-bad/ChangeLog,v
retrieving revision 1.3800
retrieving revision 1.3801
diff -u -d -r1.3800 -r1.3801
--- ChangeLog	8 Dec 2008 13:48:44 -0000	1.3800
+++ ChangeLog	8 Dec 2008 15:28:56 -0000	1.3801
@@ -1,5 +1,44 @@
 2008-12-08  Sebastian Dröge  <[email protected]>
 
+	* gst/mxf/mxfdemux.c: (gst_mxf_demux_reset_metadata),
+	(gst_mxf_demux_handle_primer_pack),
+	(gst_mxf_demux_handle_metadata_preface),
+	(gst_mxf_demux_handle_header_metadata_resolve_references),
+	(gst_mxf_demux_choose_package),
+	(gst_mxf_demux_handle_header_metadata_update_streams),
+	(gst_mxf_demux_parse_footer_metadata),
+	(gst_mxf_demux_handle_klv_packet):
+	* gst/mxf/mxfdemux.h:
+	* gst/mxf/mxftypes.h:
+	Remove the concept of "final" metadata, broken files have updated
+	metadata in following partitions even if the current partition
+	is closed and complete.
+
+	If there's a second primer pack inside a partition ignore the second
+	one instead of throwing an error.
+	Store the type of a track (audio, video, timestamp, ...) inside the
+	track struct.
+	Post no-more-pads only once for a stream and not a second time
+	when switching the currently playing package.
+	When updating all streams make sure that we could select and find
+	a package instead of dereferencing NULL.
+	Allow descriptive metadata inside metadata parts of a file when
+	pulling the footer metadata too.
+	Only switch the currently playing package if a new one was chosen
+	and the metadata is in a resolved state. If the latter isn't true
+	postpone the switch until the metadata is resolved.
+	Pull the footer metadata directly after parsing the header partition
+	pack if it's not closed or not complete instead of waiting until
+	the next KLV packet.
+2008-12-08  Sebastian Dröge  <[email protected]>
 	* gst/mxf/mxfup.c: (mxf_up_handle_essence_element):
 	Don't create a subbuffer, instead just change the buffer metadata
 	of the input buffer.
Index: mxfdemux.c
RCS file: /cvs/gstreamer/gst-plugins-bad/gst/mxf/mxfdemux.c,v
retrieving revision 1.32
retrieving revision 1.33
diff -u -d -r1.32 -r1.33
--- mxfdemux.c	7 Dec 2008 20:12:33 -0000	1.32
+++ mxfdemux.c	8 Dec 2008 15:28:58 -0000	1.33
@@ -190,7 +190,7 @@
   GST_DEBUG_OBJECT (demux, "Resetting metadata");
   demux->update_metadata = TRUE;
-  demux->final_metadata = FALSE;
+  demux->metadata_resolved = FALSE;
   demux->current_package = NULL;
@@ -556,7 +556,7 @@
   if (G_UNLIKELY (demux->primer.valid)) {
     GST_ERROR_OBJECT (demux, "Primer pack already exists");
-    return GST_FLOW_ERROR;
+    return GST_FLOW_OK;
   }
   if (!mxf_primer_pack_parse (key, &demux->primer,
@@ -578,11 +578,6 @@
       "Handling metadata preface of size %u"
       " at offset %" G_GUINT64_FORMAT, GST_BUFFER_SIZE (buffer), demux->offset);
-  if (demux->final_metadata) {
-    GST_DEBUG_OBJECT (demux, "Metadata is already final, skipping");
-    return GST_FLOW_OK;
-  }
-
   if (!mxf_metadata_preface_parse (key, &preface, &demux->primer,
           GST_BUFFER_DATA (buffer), GST_BUFFER_SIZE (buffer))) {
     GST_ERROR_OBJECT (demux, "Parsing metadata preface failed");
@@ -597,6 +592,8 @@
         "Timestamp of new preface is newer than old, updating metadata");
     gst_mxf_demux_reset_metadata (demux);
     memcpy (&demux->preface, &preface, sizeof (MXFMetadataPreface));
+  } else {
+    GST_DEBUG_OBJECT (demux, "Preface is older than already parsed preface");
   return GST_FLOW_OK;
@@ -1138,8 +1135,6 @@
 }
 static GstFlowReturn
 gst_mxf_demux_handle_metadata_locator (GstMXFDemux * demux,
     const MXFUL * key, guint16 type, GstBuffer * buffer)
@@ -1173,8 +1168,6 @@
   GST_DEBUG_OBJECT (demux, "Resolve metadata references");
   demux->update_metadata = FALSE;
-  if (demux->partition.closed && demux->partition.complete)
-    demux->final_metadata = TRUE;
   /* Fill in demux->descriptor */
   demux->descriptor = g_ptr_array_new ();
@@ -1324,9 +1317,8 @@
           MXFMetadataEssenceContainerData, i);
       for (j = 0; j < demux->content_storage.n_essence_container_data; j++) {
-        if (mxf_ul_is_equal (&demux->
-                content_storage.essence_container_data_uids[j],
-                &data->instance_uid)) {
+        if (mxf_ul_is_equal (&demux->content_storage.
+                essence_container_data_uids[j], &data->instance_uid)) {
           demux->content_storage.essence_container_data[j] = data;
           break;
         }
@@ -1585,7 +1577,8 @@
     }
-  /* Store, for every package, the number of timestamp, metadata, essence and other tracks */
+  /* Store, for every package, the number of timestamp, metadata, essence and other tracks 
+   * and also store for every track the type */
   if (demux->package) {
     for (i = 0; i < demux->package->len; i++) {
       MXFMetadataGenericPackage *package =
@@ -1622,6 +1615,8 @@
               mxf_metadata_track_identifier_parse (&sequence->data_definition);
+        track->type = type;
         if (type == MXF_METADATA_TRACK_UNKNOWN)
           continue;
         else if ((type & 0xf0) == 0x10)
@@ -1636,9 +1631,13 @@
+  demux->metadata_resolved = TRUE;
   return ret;
 error:
@@ -1674,8 +1673,6 @@
       GST_ERROR_OBJECT (demux, "Invalid requested package");
     } else {
       if (memcmp (&umid, &demux->current_package_uid, 32) != 0) {
-        if (demux->src)
-          gst_element_no_more_pads (GST_ELEMENT_CAST (demux));
         gst_mxf_demux_remove_pads (demux);
         memcpy (&demux->current_package_uid, &umid, 32);
       }
@@ -1730,7 +1727,10 @@
   current_package = gst_mxf_demux_choose_package (demux);
-  if (!current_package->tracks) {
+  if (!current_package) {
+    GST_ERROR_OBJECT (demux, "Unable to find current package");
+    return GST_FLOW_ERROR;
+  } else if (!current_package->tracks) {
     GST_ERROR_OBJECT (demux, "Current package has no (resolved) tracks");
     return GST_FLOW_ERROR;
   } else if (!current_package->n_essence_tracks) {
@@ -2565,7 +2565,7 @@
             demux->partition.this_partition - demux->partition.prev_partition;
         goto next_try;
-    } else if (mxf_is_fill (&key)) {
+    } else if (mxf_is_descriptive_metadata (&key) || mxf_is_fill (&key)) {
       offset += read;
       gst_buffer_unref (buffer);
       buffer = NULL;
@@ -2586,8 +2586,6 @@
     goto next_try;
-  demux->final_metadata = TRUE;
 out:
   if (buffer)
     gst_buffer_unref (buffer);
@@ -2607,24 +2605,6 @@
   gchar key_str[48];
   GstFlowReturn ret = GST_FLOW_OK;
-  /* In pull mode try to get the last metadata */
-  if (demux->pull_footer_metadata && !demux->final_metadata
-      && demux->random_access && demux->partition.valid
-      && demux->partition.type == MXF_PARTITION_PACK_HEADER
-      && (!demux->partition.closed || !demux->partition.complete)
-      && demux->footer_partition_pack_offset != 0) {
-    GST_DEBUG_OBJECT (demux,
-        "Open or incomplete header partition, trying to get final metadata from the last partitions");
-    gst_mxf_demux_parse_footer_metadata (demux);
-    demux->pull_footer_metadata = FALSE;
-  /* TODO: - Pull random index pack from footer partition?
-   *       - Pull all partitions for parsing all index segments and having a complete index
-   *         as first thing. This also will make it possible to use the latest header
-   *         metadata if it's not in the footer partition
-   */
   if (demux->update_metadata
       && !mxf_timestamp_is_unknown (&demux->preface.last_modified_date)
       && !mxf_is_metadata (key) && !mxf_is_descriptive_metadata (key)
@@ -2637,7 +2617,7 @@
             gst_mxf_demux_handle_header_metadata_update_streams (demux)) !=
         GST_FLOW_OK)
       goto beach;
-  } else if (!demux->update_metadata && demux->requested_package_string) {
+  } else if (demux->metadata_resolved && demux->requested_package_string) {
     if ((ret =
@@ -2677,6 +2657,19 @@
         mxf_ul_to_string (key, key_str));
+  /* In pull mode try to get the last metadata */
+  if (mxf_is_partition_pack (key) && ret == GST_FLOW_OK
+      && demux->pull_footer_metadata
+      && demux->random_access && demux->partition.valid
+      && demux->partition.type == MXF_PARTITION_PACK_HEADER
+      && (!demux->partition.closed || !demux->partition.complete)
+      && demux->footer_partition_pack_offset != 0) {
+    GST_DEBUG_OBJECT (demux,
+        "Open or incomplete header partition, trying to get final metadata from the last partitions");
+    gst_mxf_demux_parse_footer_metadata (demux);
+    demux->pull_footer_metadata = FALSE;
+  }
 beach:
Index: mxfdemux.h
RCS file: /cvs/gstreamer/gst-plugins-bad/gst/mxf/mxfdemux.h,v
retrieving revision 1.8
retrieving revision 1.9
diff -u -d -r1.8 -r1.9
--- mxfdemux.h	5 Dec 2008 12:26:02 -0000	1.8
+++ mxfdemux.h	8 Dec 2008 15:28:58 -0000	1.9
@@ -72,8 +72,9 @@
   /* Structural metadata */
   gboolean update_metadata;
-  gboolean final_metadata;
   gboolean pull_footer_metadata;
+  gboolean metadata_resolved;
   MXFMetadataPreface preface;
   GArray *identification;
   MXFMetadataContentStorage content_storage;
Index: mxftypes.h
RCS file: /cvs/gstreamer/gst-plugins-bad/gst/mxf/mxftypes.h,v
retrieving revision 1.6
retrieving revision 1.7
diff -u -d -r1.6 -r1.7
--- mxftypes.h	7 Dec 2008 17:16:28 -0000	1.6
+++ mxftypes.h	8 Dec 2008 15:28:58 -0000	1.7
@@ -334,6 +334,8 @@
   guint32 track_id;
   guint32 track_number;
+  MXFMetadataTrackType type;
   gchar *track_name;
   MXFFraction edit_rate;

------------------------------------------------------------------------------
SF.Net email is Sponsored by MIX09, March 18-20, 2009 in Las Vegas, Nevada.
The future of the web can't happen without you.  Join us at MIX09 to help
pave the way to the Next Web now. Learn more and register at
http://ad.doubleclick.net/clk;208669438;13503038;i?http://2009.visitmix.com/

_______________________________________________
gstreamer-cvs-verbose mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/gstreamer-cvs-verbose