matroskamux: Support "webm" DocType

This commit is contained in:
Philip Jägenstedt 2010-05-09 12:09:57 +02:00 committed by Sebastian Dröge
parent e847957790
commit 27069088db
4 changed files with 53 additions and 1 deletions

View file

@ -26,6 +26,23 @@
#include "matroska-ids.h" #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 gboolean
gst_matroska_track_init_video_context (GstMatroskaTrackContext ** p_context) gst_matroska_track_init_video_context (GstMatroskaTrackContext ** p_context)
{ {

View file

@ -26,6 +26,16 @@
#include "ebml-ids.h" #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. * Matroska element IDs. max. 32-bit.
*/ */

View file

@ -61,10 +61,12 @@ enum
{ {
ARG_0, ARG_0,
ARG_WRITING_APP, ARG_WRITING_APP,
ARG_DOCTYPE,
ARG_MATROSKA_VERSION, ARG_MATROSKA_VERSION,
ARG_MIN_INDEX_INTERVAL ARG_MIN_INDEX_INTERVAL
}; };
#define DEFAULT_DOCTYPE GST_MATROSKA_DOCTYPE_MATROSKA
#define DEFAULT_MATROSKA_VERSION 1 #define DEFAULT_MATROSKA_VERSION 1
#define DEFAULT_WRITING_APP "GStreamer Matroska muxer" #define DEFAULT_WRITING_APP "GStreamer Matroska muxer"
#define DEFAULT_MIN_INDEX_INTERVAL 0 #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.", g_param_spec_string ("writing-app", "Writing application.",
"The name the application that creates the matroska file.", "The name the application that creates the matroska file.",
NULL, G_PARAM_READWRITE)); 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_object_class_install_property (gobject_class, ARG_MATROSKA_VERSION,
g_param_spec_int ("version", "Matroska version", g_param_spec_int ("version", "Matroska version",
"This parameter determines what matroska features can be used.", "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); mux->ebml_write = gst_ebml_write_new (mux->srcpad);
/* property defaults */ /* property defaults */
mux->doctype = DEFAULT_DOCTYPE;
mux->matroska_version = DEFAULT_MATROSKA_VERSION; mux->matroska_version = DEFAULT_MATROSKA_VERSION;
mux->writing_app = g_strdup (DEFAULT_WRITING_APP); mux->writing_app = g_strdup (DEFAULT_WRITING_APP);
mux->min_index_interval = DEFAULT_MIN_INDEX_INTERVAL; mux->min_index_interval = DEFAULT_MIN_INDEX_INTERVAL;
@ -1980,6 +1987,9 @@ static void
gst_matroska_mux_start (GstMatroskaMux * mux) gst_matroska_mux_start (GstMatroskaMux * mux)
{ {
GstEbmlWrite *ebml = mux->ebml_write; GstEbmlWrite *ebml = mux->ebml_write;
GEnumClass *doctype_class;
GEnumValue *doctype_value;
const gchar *doctype;
guint32 seekhead_id[] = { GST_MATROSKA_ID_SEGMENTINFO, guint32 seekhead_id[] = { GST_MATROSKA_ID_SEGMENTINFO,
GST_MATROSKA_ID_TRACKS, GST_MATROSKA_ID_TRACKS,
GST_MATROSKA_ID_CUES, GST_MATROSKA_ID_CUES,
@ -1995,7 +2005,13 @@ gst_matroska_mux_start (GstMatroskaMux * mux)
GTimeVal time = { 0, 0 }; GTimeVal time = { 0, 0 };
/* we start with a EBML header */ /* 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 */ /* start a segment */
mux->segment_pos = mux->segment_pos =
@ -2768,6 +2784,9 @@ gst_matroska_mux_set_property (GObject * object,
g_free (mux->writing_app); g_free (mux->writing_app);
mux->writing_app = g_value_dup_string (value); mux->writing_app = g_value_dup_string (value);
break; break;
case ARG_DOCTYPE:
mux->doctype = g_value_get_enum (value);
break;
case ARG_MATROSKA_VERSION: case ARG_MATROSKA_VERSION:
mux->matroska_version = g_value_get_int (value); mux->matroska_version = g_value_get_int (value);
break; break;
@ -2793,6 +2812,9 @@ gst_matroska_mux_get_property (GObject * object,
case ARG_WRITING_APP: case ARG_WRITING_APP:
g_value_set_string (value, mux->writing_app); g_value_set_string (value, mux->writing_app);
break; break;
case ARG_DOCTYPE:
g_value_set_enum (value, mux->doctype);
break;
case ARG_MATROSKA_VERSION: case ARG_MATROSKA_VERSION:
g_value_set_int (value, mux->matroska_version); g_value_set_int (value, mux->matroska_version);
break; break;

View file

@ -85,6 +85,9 @@ typedef struct _GstMatroskaMux {
/* Application name (for the writing application header element) */ /* Application name (for the writing application header element) */
gchar *writing_app; gchar *writing_app;
/* EBML DocType. */
gint doctype;
/* Matroska version. */ /* Matroska version. */
guint matroska_version; guint matroska_version;