msmith gst-plugins-good: gst-plugins-good/ gst-plugins-good/gst/qtdemux/

[email protected] Thu, 8 Jan 2009 10:17:27 -0800 (PST)
Newsgroups gmane.comp.video.gstreamer.cvs
Message-ID <[email protected]>
CVS Root:       /cvs/gstreamer
Module:         gst-plugins-good
Changes by:     msmith
Date:           Thu Jan 08 2009  18:17:27 UTC

Log message:
    * gst/qtdemux/qtdemux.c:
      In push mode, error out if we get EOS before we've created any srcpads.
      Handle (in pull mode) some files that have a truncated moov atom where
      the final sub-atom is a 'free' atom and the contents of that are not
      present in the file.

Modified files:
    .               : ChangeLog
    gst/qtdemux     : qtdemux.c

Links:
http://freedesktop.org/cgi-bin/viewcvs.cgi/gstreamer/gst-plugins-good/ChangeLog.diff?r1=1.3889&r2=1.3890
http://freedesktop.org/cgi-bin/viewcvs.cgi/gstreamer/gst-plugins-good/gst/qtdemux/qtdemux.c.diff?r1=1.241&r2=1.242

====Begin Diffs====
Index: ChangeLog
===================================================================
RCS file: /cvs/gstreamer/gst-plugins-good/ChangeLog,v
retrieving revision 1.3889
retrieving revision 1.3890
diff -u -d -r1.3889 -r1.3890
--- ChangeLog	8 Jan 2009 15:56:43 -0000	1.3889
+++ ChangeLog	8 Jan 2009 18:17:12 -0000	1.3890
@@ -1,3 +1,11 @@
+2009-01-08  Michael Smith <[email protected]>
+
+	* gst/qtdemux/qtdemux.c:
+	  In push mode, error out if we get EOS before we've created any srcpads.
+	  Handle (in pull mode) some files that have a truncated moov atom where
+	  the final sub-atom is a 'free' atom and the contents of that are not
+	  present in the file.
 2009-01-08  Mark Nauwelaerts  <[email protected]>
 
 	* gst/matroska/matroska-demux.c: (gst_matroska_demux_video_caps):
Index: qtdemux.c
RCS file: /cvs/gstreamer/gst-plugins-good/gst/qtdemux/qtdemux.c,v
retrieving revision 1.241
retrieving revision 1.242
diff -u -d -r1.241 -r1.242
--- qtdemux.c	5 Jan 2009 11:42:09 -0000	1.241
+++ qtdemux.c	8 Jan 2009 18:17:13 -0000	1.242
@@ -985,6 +985,15 @@
       gst_event_unref (event);
       res = TRUE;
       break;
+    case GST_EVENT_EOS:
+      /* If we are in push mode, and get an EOS before we've seen any streams,
+       * then error out - we have nowhere to send the EOS */
+      if (!demux->pullbased && demux->n_streams == 0) {
+        GST_ELEMENT_ERROR (demux, STREAM, DECODE,
+            (_("This file contains no playable streams.")),
+            ("no known streams found"));
+      }
+      /* Fall through */
     default:
       res = gst_pad_event_default (demux->sinkpad, event);
@@ -1128,10 +1137,38 @@
       if (ret != GST_FLOW_OK)
         goto beach;
       if (length != GST_BUFFER_SIZE (moov)) {
+        /* Some files have a 'moov' atom at the end of the file which contains
+         * a terminal 'free' atom where the body of the atom is missing.
+         * Check for, and permit, this special case.
+         */
+        if (GST_BUFFER_SIZE (moov) >= 8) {
+          guint8 *final_data = GST_BUFFER_DATA (moov) +
+              (GST_BUFFER_SIZE (moov) - 8);
+          guint32 final_length = QT_UINT32 (final_data);
+          guint32 final_fourcc = QT_FOURCC (final_data + 4);
+          if (final_fourcc == FOURCC_free &&
+              GST_BUFFER_SIZE (moov) + final_length - 8 == length) {
+            /* Ok, we've found that special case. Allocate a new buffer with
+             * that free atom actually present. */
+            GstBuffer *newmoov = gst_buffer_new_and_alloc (length);
+            gst_buffer_copy_metadata (newmoov, moov,
+                GST_BUFFER_COPY_FLAGS | GST_BUFFER_COPY_TIMESTAMPS |
+                GST_BUFFER_COPY_CAPS);
+            memcpy (GST_BUFFER_DATA (newmoov), GST_BUFFER_DATA (moov),
+                GST_BUFFER_SIZE (moov));
+            memset (GST_BUFFER_DATA (newmoov) + GST_BUFFER_SIZE (moov), 0,
+                final_length - 8);
+            gst_buffer_unref (moov);
+            moov = newmoov;
+          }
+        }
+      if (length != GST_BUFFER_SIZE (moov)) {
         GST_ELEMENT_ERROR (qtdemux, STREAM, DECODE,
             (_("This file is incomplete and cannot be played.")),
-            ("We got less than expected (received %u, wanted %u)",
-                GST_BUFFER_SIZE (moov), (guint) length));
+            ("We got less than expected (received %u, wanted %u, offset %u)",
+                GST_BUFFER_SIZE (moov), (guint) length, cur_offset));
         ret = GST_FLOW_ERROR;
       }

------------------------------------------------------------------------------
Check out the new SourceForge.net Marketplace.
It is the best place to buy or sell services for
just about anything Open Source.
http://p.sf.net/sfu/Xq1LFB