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:22:34 +0000
commit672ab8fb5b653b5b64d8d596b5a5c24819d2ed32 (patch)
tree5003c1d277b9abec311fc99c71f13e533774ec32
parent64cdbb77a92f0008c5399f49fe10cbc444436846 (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 e47e85773..050aac0e6 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 c69839240..27dc2f7ea 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;
}