matroska-demux: assume matroska if no doctype is specified
authorTim-Philipp Müller <tim.muller@collabora.co.uk>
Wed, 29 Dec 2010 23:09:04 +0000 (23:09 +0000)
committerTim-Philipp Müller <tim.muller@collabora.co.uk>
Wed, 29 Dec 2010 23:09:04 +0000 (23:09 +0000)
https://bugzilla.gnome.org/show_bug.cgi?id=638019

gst/matroska/matroska-demux.c

index 47f0ed3..96c9a15 100644 (file)
@@ -3099,26 +3099,30 @@ gst_matroska_demux_parse_header (GstMatroskaDemux * demux, GstEbmlRead * ebml)
   }
 
 exit:
-  ret = GST_FLOW_ERROR;
-  if (doctype) {
-    if (g_str_equal (doctype, GST_MATROSKA_DOCTYPE_MATROSKA) ||
-        g_str_equal (doctype, GST_MATROSKA_DOCTYPE_WEBM)) {
-      if (version <= 2) {
+
+  if ((doctype != NULL && !strcmp (doctype, GST_MATROSKA_DOCTYPE_MATROSKA)) ||
+      (doctype != NULL && !strcmp (doctype, GST_MATROSKA_DOCTYPE_WEBM)) ||
+      (doctype == NULL)) {
+    if (version <= 2) {
+      if (doctype) {
         GST_INFO_OBJECT (demux, "Input is %s version %d", doctype, version);
-        ret = GST_FLOW_OK;
       } else {
-        GST_ELEMENT_ERROR (demux, STREAM, DEMUX, (NULL),
-            ("Demuxer version (2) is too old to read %s version %d",
-                doctype, version));
+        GST_WARNING_OBJECT (demux, "Input is EBML without doctype, assuming "
+            "matroska (version %d)", version);
       }
+      ret = GST_FLOW_OK;
     } else {
-      GST_ELEMENT_ERROR (demux, STREAM, WRONG_TYPE, (NULL),
-          ("Input is not a matroska stream (doctype=%s)", doctype));
+      GST_ELEMENT_ERROR (demux, STREAM, DEMUX, (NULL),
+          ("Demuxer version (2) is too old to read %s version %d",
+              GST_STR_NULL (doctype), version));
+      ret = GST_FLOW_ERROR;
     }
     g_free (doctype);
   } else {
     GST_ELEMENT_ERROR (demux, STREAM, WRONG_TYPE, (NULL),
-        ("Input is not a matroska stream"));
+        ("Input is not a matroska stream (doctype=%s)", doctype));
+    ret = GST_FLOW_ERROR;
+    g_free (doctype);
   }
 
   return ret;