From 025417f12436170fe77d469d614933304b0b046f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Tim-Philipp=20M=C3=BCller?= Date: Wed, 13 Apr 2011 15:18:11 +0100 Subject: [PATCH] qtmux: add variant-less video/quicktime to source pad template caps This is needed for automatic transcoding using encodebin. Our typefinder does not always add a variant to the found caps, and encodebin needs an *exact* match to the caps on the source pad template, so we need to add the variant-less video/quicktime caps to the template as well for encodebin to be able to find it. Add unit test for this as well. https://bugzilla.gnome.org/show_bug.cgi?id=642879 --- gst/quicktime/gstqtmux.c | 3 ++ gst/quicktime/gstqtmuxmap.c | 3 +- tests/check/Makefile.am | 6 ++- tests/check/elements/qtmux.c | 90 +++++++++++++++++++++++++++++------- 4 files changed, 83 insertions(+), 19 deletions(-) diff --git a/gst/quicktime/gstqtmux.c b/gst/quicktime/gstqtmux.c index 39110d846b..56e4525090 100644 --- a/gst/quicktime/gstqtmux.c +++ b/gst/quicktime/gstqtmux.c @@ -1591,6 +1591,9 @@ gst_qt_mux_start_file (GstQTMux * qtmux) GST_DEBUG_OBJECT (qtmux, "starting file"); caps = gst_caps_copy (gst_pad_get_pad_template_caps (qtmux->srcpad)); + /* qtmux has structure with and without variant, remove all but the first */ + while (gst_caps_get_size (caps) > 1) + gst_caps_remove_structure (caps, 1); gst_pad_set_caps (qtmux->srcpad, caps); gst_caps_unref (caps); diff --git a/gst/quicktime/gstqtmuxmap.c b/gst/quicktime/gstqtmuxmap.c index b8859b46ba..efcae465f4 100644 --- a/gst/quicktime/gstqtmuxmap.c +++ b/gst/quicktime/gstqtmuxmap.c @@ -149,7 +149,8 @@ GstQTMuxFormatProp gst_qt_mux_format_list[] = { "qtmux", "QuickTime", "GstQTMux", - GST_STATIC_CAPS ("video/quicktime, variant = (string) apple"), + GST_STATIC_CAPS ("video/quicktime, variant = (string) apple; " + "video/quicktime"), GST_STATIC_CAPS ("video/x-raw-rgb, " COMMON_VIDEO_CAPS "; " "video/x-raw-yuv, " diff --git a/tests/check/Makefile.am b/tests/check/Makefile.am index aed720065d..9fe0e35242 100644 --- a/tests/check/Makefile.am +++ b/tests/check/Makefile.am @@ -235,11 +235,15 @@ elements_level_LDADD = $(LDADD) $(LIBM) elements_matroskamux_LDADD = $(GST_BASE_LIBS) $(LDADD) $(LIBM) +elements_qtmux_CFLAGS = $(GST_PLUGINS_BASE_CFLAGS) $(GST_CFLAGS) $(AM_CFLAGS) +elements_qtmux_LDADD = $(GST_PLUGINS_BASE_LIBS) -lgstpbutils-@GST_MAJORMINOR@ \ + $(GST_BASE_LIBS) $(GST_LIBS) $(GST_CHECK_LIBS) + elements_rtpbin_buffer_list_CFLAGS = $(GST_PLUGINS_BASE_CFLAGS) $(GST_CFLAGS) \ $(WARNING_CFLAGS) $(ERROR_CFLAGS) $(GST_CHECK_CFLAGS) $(AM_CFLAGS) elements_rtpbin_buffer_list_LDADD = $(GST_PLUGINS_BASE_LIBS) \ -lgstnetbuffer-@GST_MAJORMINOR@ -lgstrtp-@GST_MAJORMINOR@ \ - $(GST_BASE_LIBS) $(GST_LIBS_LIBS) $(GST_CHECK_LIBS) + $(GST_BASE_LIBS) $(GST_LIBS) $(GST_CHECK_LIBS) elements_rtpbin_buffer_list_SOURCES = elements/rtpbin_buffer_list.c elements_souphttpsrc_CFLAGS = $(SOUP_CFLAGS) $(AM_CFLAGS) diff --git a/tests/check/elements/qtmux.c b/tests/check/elements/qtmux.c index 1db618cec9..51ecf1d39f 100644 --- a/tests/check/elements/qtmux.c +++ b/tests/check/elements/qtmux.c @@ -20,9 +20,16 @@ * Boston, MA 02111-1307, USA. */ +#ifdef HAVE_CONFIG_H +#include +#endif + +#ifdef HAVE_UNISTD_H #include +#endif #include +#include /* For ease of programming we use globals to keep refs for our floating * src and sink pads we create; otherwise we always have to do get_pad, @@ -385,6 +392,70 @@ GST_START_TEST (test_reuse) GST_END_TEST; +static GstEncodingContainerProfile * +create_qtmux_profile (const gchar * variant) +{ + GstEncodingContainerProfile *cprof; + GstCaps *caps; + + if (variant == NULL) { + caps = gst_caps_new_simple ("video/quicktime", NULL); + } else { + caps = gst_caps_new_simple ("video/quicktime", + "variant", G_TYPE_STRING, variant, NULL); + } + + cprof = gst_encoding_container_profile_new ("Name", "blah", caps, NULL); + gst_caps_unref (caps); + + caps = gst_caps_new_simple ("audio/x-raw-int", "width", G_TYPE_INT, 16, + "depth", G_TYPE_INT, 16, "endianness", G_TYPE_INT, 4321, + "channels", G_TYPE_INT, 2, "rate", G_TYPE_INT, 44100, + "signed", G_TYPE_BOOLEAN, TRUE, NULL); + gst_encoding_container_profile_add_profile (cprof, + GST_ENCODING_PROFILE (gst_encoding_audio_profile_new (caps, NULL, NULL, + 1))); + gst_caps_unref (caps); + + return cprof; +} + +GST_START_TEST (test_encodebin) +{ + GstEncodingContainerProfile *cprof; + GstElement *enc; + GstPad *pad; + + enc = gst_element_factory_make ("encodebin", NULL); + if (enc == NULL) + return; + + /* Make sure encodebin finds a muxer for a profile with a variant field .. */ + cprof = create_qtmux_profile ("apple"); + g_object_set (enc, "profile", cprof, NULL); + gst_encoding_profile_unref (cprof); + + /* should have created a pad after setting the profile */ + pad = gst_element_get_static_pad (enc, "audio_0"); + fail_unless (pad != NULL); + gst_object_unref (pad); + gst_object_unref (enc); + + /* ... and for a profile without a variant field */ + enc = gst_element_factory_make ("encodebin", NULL); + cprof = create_qtmux_profile (NULL); + g_object_set (enc, "profile", cprof, NULL); + gst_encoding_profile_unref (cprof); + + /* should have created a pad after setting the profile */ + pad = gst_element_get_static_pad (enc, "audio_0"); + fail_unless (pad != NULL); + gst_object_unref (pad); + gst_object_unref (enc); +} + +GST_END_TEST; + static Suite * qtmux_suite (void) { @@ -398,25 +469,10 @@ qtmux_suite (void) tcase_add_test (tc_chain, test_audio_pad_frag); tcase_add_test (tc_chain, test_video_pad_frag_streamable); tcase_add_test (tc_chain, test_audio_pad_frag_streamable); - tcase_add_test (tc_chain, test_reuse); + tcase_add_test (tc_chain, test_encodebin); return s; } -int -main (int argc, char **argv) -{ - int nf; - - Suite *s = qtmux_suite (); - SRunner *sr = srunner_create (s); - - gst_check_init (&argc, &argv); - - srunner_run_all (sr, CK_NORMAL); - nf = srunner_ntests_failed (sr); - srunner_free (sr); - - return nf; -} +GST_CHECK_MAIN (qtmux)