From e3337c6868321855331b955d21319ca718e9daa4 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Sebastian=20Dr=C3=B6ge?= <slomo@circular-chaos.org>
Date: Thu, 27 Nov 2008 08:49:08 +0000
Subject: gst/mxf/mxfdemux.*: Only try to pull the footer metadata once and not
 on every KLV packet if it failed before.

Original commit message from CVS:
* gst/mxf/mxfdemux.c: (gst_mxf_demux_reset),
(gst_mxf_demux_handle_klv_packet):
* gst/mxf/mxfdemux.h:
Only try to pull the footer metadata once and not on every KLV packet
if it failed before.
---
 gst/mxf/mxfdemux.c | 11 ++++++++---
 gst/mxf/mxfdemux.h |  1 +
 2 files changed, 9 insertions(+), 3 deletions(-)

(limited to 'gst')

diff --git a/gst/mxf/mxfdemux.c b/gst/mxf/mxfdemux.c
index 198aa284..11bd6dec 100644
--- a/gst/mxf/mxfdemux.c
+++ b/gst/mxf/mxfdemux.c
@@ -363,6 +363,8 @@ gst_mxf_demux_reset (GstMXFDemux * demux)
   demux->footer_partition_pack_offset = 0;
   demux->offset = 0;
 
+  demux->pull_footer_metadata = TRUE;
+
   demux->run_in = -1;
 
   memset (&demux->current_package_uid, 0, sizeof (MXFUMID));
@@ -1272,8 +1274,9 @@ gst_mxf_demux_handle_header_metadata_resolve_references (GstMXFDemux * demux)
           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;
         }
@@ -2369,13 +2372,15 @@ gst_mxf_demux_handle_klv_packet (GstMXFDemux * demux, const MXFUL * key,
   GstFlowReturn ret = GST_FLOW_OK;
 
   /* In pull mode try to get the last metadata */
-  if (!demux->final_metadata && demux->random_access && demux->partition.valid
+  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?
diff --git a/gst/mxf/mxfdemux.h b/gst/mxf/mxfdemux.h
index 0452f808..83426d67 100644
--- a/gst/mxf/mxfdemux.h
+++ b/gst/mxf/mxfdemux.h
@@ -70,6 +70,7 @@ struct _GstMXFDemux
   /* Structural metadata */
   gboolean update_metadata;
   gboolean final_metadata;
+  gboolean pull_footer_metadata;
   MXFMetadataPreface preface;
   GArray *identification;
   MXFMetadataContentStorage content_storage;
-- 
cgit v1.2.1