summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorTim-Philipp Müller <tim.muller@collabora.co.uk>2012-11-30 17:20:18 +0000
committerTim-Philipp Müller <tim.muller@collabora.co.uk>2012-11-30 17:43:02 +0000
commit10cd251f6001f86a6e6717d3be1103ab945632fb (patch)
treec1013e58134f8f312ae9d257b077df30a8810a96
parent7fe34e4f1c11270464baa01e8bb7c10890155c0d (diff)
webmux: fix linking with shout2send element
Shout2send only accepts webm format, not matroska, but due to a bug in matroskamux, webmmux's source pad is also created with the matroska source pad template as pad template, which makes the link function think it can't link webmmux to shout2send. Also add unit test. https://bugzilla.gnome.org/show_bug.cgi?id=689336
-rw-r--r--gst/matroska/matroska-mux.c53
-rw-r--r--tests/check/elements/matroskamux.c26
2 files changed, 65 insertions, 14 deletions
diff --git a/gst/matroska/matroska-mux.c b/gst/matroska/matroska-mux.c
index dddfc1c4c..380f72de6 100644
--- a/gst/matroska/matroska-mux.c
+++ b/gst/matroska/matroska-mux.c
@@ -196,13 +196,11 @@ static GstStaticPadTemplate subtitlesink_templ =
static GArray *used_uids;
G_LOCK_DEFINE_STATIC (used_uids);
-#define parent_class gst_matroska_mux_parent_class
-G_DEFINE_TYPE_WITH_CODE (GstMatroskaMux, gst_matroska_mux, GST_TYPE_ELEMENT,
- G_IMPLEMENT_INTERFACE (GST_TYPE_TAG_SETTER, NULL)
- G_IMPLEMENT_INTERFACE (GST_TYPE_TOC_SETTER, NULL)
- );
+static gpointer parent_class; /* NULL */
/* Matroska muxer destructor */
+static void gst_matroska_mux_class_init (GstMatroskaMuxClass * klass);
+static void gst_matroska_mux_init (GstMatroskaMux * mux, gpointer g_class);
static void gst_matroska_mux_finalize (GObject * object);
/* Pads collected callback */
@@ -248,6 +246,38 @@ static void
gst_matroska_mux_write_simple_tag (const GstTagList * list, const gchar * tag,
gpointer data);
+/* Cannot use boilerplate macros here because we need the full init function
+ * signature with the additional class argument, so we use the right template
+ * for the sink caps */
+GType
+gst_matroska_mux_get_type (void)
+{
+ static GType object_type; /* 0 */
+
+ if (object_type == 0) {
+ static const GTypeInfo object_info = {
+ sizeof (GstMatroskaMuxClass),
+ NULL, /* base_init */
+ NULL, /* base_finalize */
+ (GClassInitFunc) gst_matroska_mux_class_init,
+ NULL, /* class_finalize */
+ NULL, /* class_data */
+ sizeof (GstMatroskaMux),
+ 0, /* n_preallocs */
+ (GInstanceInitFunc) gst_matroska_mux_init
+ };
+ const GInterfaceInfo iface_info = { NULL };
+
+ object_type = g_type_register_static (GST_TYPE_ELEMENT,
+ "GstMatroskaMux", &object_info, (GTypeFlags) 0);
+
+ g_type_add_interface_static (object_type, GST_TYPE_TAG_SETTER, &iface_info);
+ g_type_add_interface_static (object_type, GST_TYPE_TOC_SETTER, &iface_info);
+ }
+
+ return object_type;
+}
+
static void
gst_matroska_mux_class_init (GstMatroskaMuxClass * klass)
{
@@ -305,6 +335,8 @@ gst_matroska_mux_class_init (GstMatroskaMuxClass * klass)
GST_DEBUG_FUNCPTR (gst_matroska_mux_request_new_pad);
gstelement_class->release_pad =
GST_DEBUG_FUNCPTR (gst_matroska_mux_release_pad);
+
+ parent_class = g_type_class_peek_parent (klass);
}
/**
@@ -405,20 +437,13 @@ gst_matroskamux_pad_init (GstMatroskamuxPad * pad)
* End of pad option handler code
**/
-/**
- * gst_matroska_mux_init:
- * @mux: #GstMatroskaMux that should be initialized.
- * @g_class: Class of the muxer.
- *
- * Matroska muxer constructor.
- */
static void
-gst_matroska_mux_init (GstMatroskaMux * mux)
+gst_matroska_mux_init (GstMatroskaMux * mux, gpointer g_class)
{
GstPadTemplate *templ;
templ =
- gst_element_class_get_pad_template (GST_ELEMENT_GET_CLASS (mux), "src");
+ gst_element_class_get_pad_template (GST_ELEMENT_CLASS (g_class), "src");
mux->srcpad = gst_pad_new_from_template (templ, "src");
gst_pad_set_event_function (mux->srcpad, gst_matroska_mux_handle_src_event);
diff --git a/tests/check/elements/matroskamux.c b/tests/check/elements/matroskamux.c
index 8f27857ee..26ed7f0f1 100644
--- a/tests/check/elements/matroskamux.c
+++ b/tests/check/elements/matroskamux.c
@@ -437,6 +437,31 @@ GST_START_TEST (test_reset)
GST_END_TEST;
+GST_START_TEST (test_link_webmmux_webm_sink)
+{
+ static GstStaticPadTemplate webm_sinktemplate =
+ GST_STATIC_PAD_TEMPLATE ("sink",
+ GST_PAD_SINK,
+ GST_PAD_ALWAYS,
+ GST_STATIC_CAPS ("video/webm; audio/webm"));
+ GstElement *mux;
+
+ mux = gst_check_setup_element ("webmmux");
+ mysinkpad = setup_sink_pad (mux, &webm_sinktemplate, NULL);
+ fail_unless (mysinkpad != NULL);
+
+ fail_unless (gst_element_set_state (mux,
+ GST_STATE_PLAYING) == GST_STATE_CHANGE_SUCCESS,
+ "could not set to playing");
+
+ gst_element_set_state (mux, GST_STATE_NULL);
+
+ teardown_sink_pad (mux);
+ gst_check_teardown_element (mux);
+}
+
+GST_END_TEST;
+
static Suite *
matroskamux_suite (void)
{
@@ -448,6 +473,7 @@ matroskamux_suite (void)
tcase_add_test (tc_chain, test_vorbis_header);
tcase_add_test (tc_chain, test_block_group);
tcase_add_test (tc_chain, test_reset);
+ tcase_add_test (tc_chain, test_link_webmmux_webm_sink);
return s;
}