matroskamux: Support "webm" DocType
authorPhilip Jägenstedt <philip@foolip.org>
Sun, 9 May 2010 10:09:57 +0000 (12:09 +0200)
committerSebastian Dröge <sebastian.droege@collabora.co.uk>
Wed, 19 May 2010 18:28:42 +0000 (20:28 +0200)
gst/matroska/matroska-ids.c
gst/matroska/matroska-ids.h
gst/matroska/matroska-mux.c
gst/matroska/matroska-mux.h

index 0ee39d3..b7153ba 100644 (file)
 
 #include "matroska-ids.h"
 
+GType
+gst_matroska_doctype_get_type (void)
+{
+  static GType doctype_type = 0;
+
+  static const GEnumValue doctype_types[] = {
+    {GST_MATROSKA_DOCTYPE_MATROSKA, "Matroska", "matroska"},
+    {GST_MATROSKA_DOCTYPE_WEBM, "WebM", "webm"},
+    {0, NULL, NULL}
+  };
+
+  if (!doctype_type) {
+    doctype_type = g_enum_register_static ("GstMatroskaDoctype", doctype_types);
+  }
+  return doctype_type;
+}
+
 gboolean
 gst_matroska_track_init_video_context (GstMatroskaTrackContext ** p_context)
 {
index a2bf198..c6bc433 100644 (file)
 #include "ebml-ids.h"
 
 /*
+ * EBML DocType. enum.
+ */
+
+#define GST_MATROSKA_DOCTYPE_MATROSKA              0
+#define GST_MATROSKA_DOCTYPE_WEBM                  1
+
+#define GST_TYPE_MATROSKA_DOCTYPE                  (gst_matroska_doctype_get_type())
+extern GType gst_matroska_doctype_get_type (void);
+
+/*
  * Matroska element IDs. max. 32-bit.
  */
 
index 5829b61..447e654 100644 (file)
@@ -61,10 +61,12 @@ enum
 {
   ARG_0,
   ARG_WRITING_APP,
+  ARG_DOCTYPE,
   ARG_MATROSKA_VERSION,
   ARG_MIN_INDEX_INTERVAL
 };
 
+#define  DEFAULT_DOCTYPE                 GST_MATROSKA_DOCTYPE_MATROSKA
 #define  DEFAULT_MATROSKA_VERSION        1
 #define  DEFAULT_WRITING_APP             "GStreamer Matroska muxer"
 #define  DEFAULT_MIN_INDEX_INTERVAL      0
@@ -297,6 +299,10 @@ gst_matroska_mux_class_init (GstMatroskaMuxClass * klass)
       g_param_spec_string ("writing-app", "Writing application.",
           "The name the application that creates the matroska file.",
           NULL, G_PARAM_READWRITE));
+  g_object_class_install_property (gobject_class, ARG_DOCTYPE,
+      g_param_spec_enum ("doctype", "DocType.",
+          "The type of document.", GST_TYPE_MATROSKA_DOCTYPE,
+          DEFAULT_DOCTYPE, G_PARAM_READWRITE));
   g_object_class_install_property (gobject_class, ARG_MATROSKA_VERSION,
       g_param_spec_int ("version", "Matroska version",
           "This parameter determines what matroska features can be used.",
@@ -337,6 +343,7 @@ gst_matroska_mux_init (GstMatroskaMux * mux, GstMatroskaMuxClass * g_class)
   mux->ebml_write = gst_ebml_write_new (mux->srcpad);
 
   /* property defaults */
+  mux->doctype = DEFAULT_DOCTYPE;
   mux->matroska_version = DEFAULT_MATROSKA_VERSION;
   mux->writing_app = g_strdup (DEFAULT_WRITING_APP);
   mux->min_index_interval = DEFAULT_MIN_INDEX_INTERVAL;
@@ -1980,6 +1987,9 @@ static void
 gst_matroska_mux_start (GstMatroskaMux * mux)
 {
   GstEbmlWrite *ebml = mux->ebml_write;
+  GEnumClass *doctype_class;
+  GEnumValue *doctype_value;
+  const gchar *doctype;
   guint32 seekhead_id[] = { GST_MATROSKA_ID_SEGMENTINFO,
     GST_MATROSKA_ID_TRACKS,
     GST_MATROSKA_ID_CUES,
@@ -1995,7 +2005,13 @@ gst_matroska_mux_start (GstMatroskaMux * mux)
   GTimeVal time = { 0, 0 };
 
   /* we start with a EBML header */
-  gst_ebml_write_header (ebml, "matroska", mux->matroska_version);
+  doctype_class = g_type_class_ref (GST_TYPE_MATROSKA_DOCTYPE);
+  doctype_value = g_enum_get_value (doctype_class, mux->doctype);
+  doctype = doctype_value->value_nick;
+  g_type_class_unref (doctype_class);
+  GST_INFO_OBJECT (ebml, "DocType: %s, Version: %d",
+      doctype, mux->matroska_version);
+  gst_ebml_write_header (ebml, doctype, mux->matroska_version);
 
   /* start a segment */
   mux->segment_pos =
@@ -2768,6 +2784,9 @@ gst_matroska_mux_set_property (GObject * object,
       g_free (mux->writing_app);
       mux->writing_app = g_value_dup_string (value);
       break;
+    case ARG_DOCTYPE:
+      mux->doctype = g_value_get_enum (value);
+      break;
     case ARG_MATROSKA_VERSION:
       mux->matroska_version = g_value_get_int (value);
       break;
@@ -2793,6 +2812,9 @@ gst_matroska_mux_get_property (GObject * object,
     case ARG_WRITING_APP:
       g_value_set_string (value, mux->writing_app);
       break;
+    case ARG_DOCTYPE:
+      g_value_set_enum (value, mux->doctype);
+      break;
     case ARG_MATROSKA_VERSION:
       g_value_set_int (value, mux->matroska_version);
       break;
index 08b07ba..600a750 100644 (file)
@@ -85,6 +85,9 @@ typedef struct _GstMatroskaMux {
   /* Application name (for the writing application header element) */
   gchar          *writing_app;
 
+  /* EBML DocType. */
+  gint           doctype;
+
   /* Matroska version. */
   guint          matroska_version;