#endif
#include <gst/pbutils/encoding-profile.h>
+#include <gst/pbutils/missing-plugins.h>
#include <gst/check/gstcheck.h>
/* Helper functions to create profiles */
static GstEncodingProfile *
+create_ogg_profile ()
+{
+ GstEncodingContainerProfile *prof;
+ GstCaps *ogg;
+
+ ogg = gst_caps_new_empty_simple ("application/ogg");
+ prof = gst_encoding_container_profile_new ((gchar *) "myprofile", NULL, ogg,
+ NULL);
+ gst_caps_unref (ogg);
+ return (GstEncodingProfile *) prof;
+}
+
+static GstEncodingProfile *
create_ogg_vorbis_profile (guint presence, gchar * preset)
{
GstEncodingContainerProfile *cprof;
return prof;
}
+static GstEncodingProfile *
+create_unsupported_profile (void)
+{
+ GstEncodingProfile *prof;
+ GstCaps *caps;
+
+ caps = gst_caps_new_empty_simple ("audio/x-bogus");
+ prof =
+ (GstEncodingProfile *) gst_encoding_audio_profile_new (caps, NULL, NULL,
+ 0);
+ gst_caps_unref (caps);
+
+ return prof;
+}
+
static void
_caps_match (GstPad * sinkpad, const gchar * capsname)
{
gst_caps_unref (caps);
}
-GST_START_TEST (test_encodebin_states)
+static void
+set_profile (GstElement * ebin, GstEncodingProfile * prof)
+{
+ g_object_set (ebin, "profile", prof, NULL);
+ gst_encoding_profile_unref (prof);
+}
+
+/* Tests */
+
+GST_START_TEST (test_encodebin_set_profile)
{
GstElement *ebin;
GstEncodingProfile *prof, *prof2;
- GstCaps *ogg;
+
+ /* Create an encodebin and check that it correctly changes states
+ * according to whether a profile is set or not */
+
+ ebin = gst_element_factory_make ("encodebin", NULL);
+
+ /* Set a profile on encodebin... */
+ prof = create_ogg_profile ();
+ g_object_set (ebin, "profile", prof, NULL);
+
+ /* ... and check the profile has been properly set */
+ g_object_get (ebin, "profile", &prof2, NULL);
+
+ fail_unless (gst_encoding_profile_is_equal (prof, prof2));
+
+ gst_encoding_profile_unref (prof);
+ gst_encoding_profile_unref (prof2);
+
+ gst_object_unref (ebin);
+};
+
+GST_END_TEST;
+
+
+GST_START_TEST (test_encodebin_can_go_to_ready_without_profile)
+{
+ GstElement *ebin;
GstPad *srcpad;
GstPad *target;
fail_unless_equals_int (gst_element_set_state (ebin, GST_STATE_PAUSED),
GST_STATE_CHANGE_FAILURE);
- /* Set a profile on encodebin... */
- ogg = gst_caps_new_empty_simple ("application/ogg");
- prof = (GstEncodingProfile *) gst_encoding_container_profile_new ((gchar *)
- "myprofile", NULL, ogg, NULL);
- gst_caps_unref (ogg);
+ /* Set back to NULL */
+ fail_unless_equals_int (gst_element_set_state (ebin, GST_STATE_NULL),
+ GST_STATE_CHANGE_SUCCESS);
- g_object_set (ebin, "profile", prof, NULL);
+ gst_object_unref (ebin);
+};
- /* ... and check the profile has been properly set */
- g_object_get (ebin, "profile", &prof2, NULL);
+GST_END_TEST;
- fail_unless (gst_encoding_profile_is_equal (prof, prof2));
+GST_START_TEST (test_encodebin_can_go_to_paused_with_profile)
+{
+ GstElement *ebin;
+ GstPad *srcpad;
+ GstPad *target;
- gst_encoding_profile_unref (prof);
- gst_encoding_profile_unref (prof2);
+ /* Create an encodebin and check that it correctly changes states
+ * according to whether a profile is set or not */
+
+ ebin = gst_element_factory_make ("encodebin", NULL);
+
+ /* Set a profile on encodebin... */
+ set_profile (ebin, create_ogg_profile ());
/* Make sure we can go to PAUSED */
fail_unless_equals_int (gst_element_set_state (ebin, GST_STATE_PAUSED),
GST_END_TEST;
+
GST_START_TEST (test_encodebin_sink_pads_static)
{
GstElement *ebin;
- GstEncodingProfile *prof;
GstPad *srcpad, *sinkpad;
/* Create an encodebin and check that it properly creates the sink pads
ebin = gst_element_factory_make ("encodebin", NULL);
/* streamprofile that has a forced presence of 1 */
- prof = create_ogg_vorbis_profile (1, NULL);
-
- g_object_set (ebin, "profile", prof, NULL);
-
- gst_encoding_profile_unref (prof);
+ set_profile (ebin, create_ogg_vorbis_profile (1, NULL));
fail_unless_equals_int (gst_element_set_state (ebin, GST_STATE_PAUSED),
GST_STATE_CHANGE_SUCCESS);
GST_START_TEST (test_encodebin_preset)
{
GstElement *ebin;
+ GstEncodingProfile *prof;
guint64 max_delay = 0;
GstPreset *oggmuxpreset;
- GstEncodingProfile *prof;
/* Create an encodebin with a bogus preset and check it fails switching states */
ebin = gst_element_factory_make ("encodebin", NULL);
oggmuxpreset = GST_PRESET (gst_element_factory_make ("oggmux", NULL));
- /* streamprofile that has a forced presence of 1 */
- prof = create_ogg_vorbis_profile (1, NULL);
/* We also set the name as the load_preset call will reset the element name to
* what is described in the preset... which might not be very smart tbh */
g_object_set (oggmuxpreset, "max-delay", (guint64) 12, "name",
/* Give a name someone should never use outside of that test */
gst_preset_save_preset (oggmuxpreset, "test_encodebin_preset");
+ /* streamprofile that has a forced presence of 1 */
+ prof = create_ogg_vorbis_profile (1, NULL);
+
gst_encoding_profile_set_preset (prof, "test_encodebin_preset");
gst_encoding_profile_set_preset_name (prof, "oggmux");
- g_object_set (ebin, "profile", prof, NULL);
-
- gst_encoding_profile_unref (prof);
+ set_profile (ebin, prof);
/* It will go to READY... */
fail_unless_equals_int (gst_element_set_state (ebin, GST_STATE_READY),
GST_START_TEST (test_encodebin_sink_pads_nopreset_static)
{
GstElement *ebin;
- GstEncodingProfile *prof;
/* Create an encodebin with a bogus preset and check it fails switching states */
ebin = gst_element_factory_make ("encodebin", NULL);
/* streamprofile that has a forced presence of 1 */
- prof = create_ogg_vorbis_profile (1, (gchar *) "nowaythispresetexists");
-
- g_object_set (ebin, "profile", prof, NULL);
-
- gst_encoding_profile_unref (prof);
+ set_profile (ebin,
+ create_ogg_vorbis_profile (1, (gchar *) "nowaythispresetexists"));
/* It will go to READY... */
fail_unless_equals_int (gst_element_set_state (ebin, GST_STATE_READY),
GST_START_TEST (test_encodebin_sink_pads_dynamic)
{
GstElement *ebin;
- GstEncodingProfile *prof;
GstPad *srcpad, *sinkpad;
GstCaps *sinkcaps;
ebin = gst_element_factory_make ("encodebin", NULL);
/* streamprofile that has non-forced presence */
- prof = create_ogg_vorbis_profile (0, NULL);
-
- g_object_set (ebin, "profile", prof, NULL);
-
- gst_encoding_profile_unref (prof);
+ set_profile (ebin, create_ogg_vorbis_profile (0, NULL));
/* Check if the source pad was properly created */
srcpad = gst_element_get_static_pad (ebin, "src");
GST_START_TEST (test_encodebin_sink_pads_multiple_static)
{
GstElement *ebin;
- GstEncodingProfile *prof;
GstPad *srcpad, *sinkpadvorbis, *sinkpadtheora;
/* Create an encodebin and check that it properly creates the sink pads */
ebin = gst_element_factory_make ("encodebin", NULL);
/* First try is with a streamprofile that has a forced presence of 1 */
- prof = create_ogg_theora_vorbis_profile (1, 1);
-
- g_object_set (ebin, "profile", prof, NULL);
-
- gst_encoding_profile_unref (prof);
+ set_profile (ebin, create_ogg_theora_vorbis_profile (1, 1));
fail_unless_equals_int (gst_element_set_state (ebin, GST_STATE_PAUSED),
GST_STATE_CHANGE_SUCCESS);
GST_START_TEST (test_encodebin_sink_pads_multiple_dynamic)
{
GstElement *ebin;
- GstEncodingProfile *prof;
GstPad *srcpad, *sinkpadvorbis, *sinkpadtheora;
/* Create an encodebin and check that it properly creates the sink pads
ebin = gst_element_factory_make ("encodebin", NULL);
/* multi-stream profile that has non-forced presence */
- prof = create_ogg_theora_vorbis_profile (0, 0);
-
- g_object_set (ebin, "profile", prof, NULL);
-
- gst_encoding_profile_unref (prof);
+ set_profile (ebin, create_ogg_theora_vorbis_profile (0, 0));
/* Check if the source pad was properly created */
srcpad = gst_element_get_static_pad (ebin, "src");
GST_START_TEST (test_encodebin_sink_pads_dynamic_encoder)
{
GstElement *ebin;
- GstEncodingProfile *prof;
GstPad *srcpad, *sinkpad = NULL;
GstCaps *vorbiscaps;
ebin = gst_element_factory_make ("encodebin", NULL);
/* streamprofile that has non-forced presence */
- prof = create_ogg_vorbis_profile (0, NULL);
-
- g_object_set (ebin, "profile", prof, NULL);
-
- gst_encoding_profile_unref (prof);
+ set_profile (ebin, create_ogg_vorbis_profile (0, NULL));
/* Check if the source pad was properly created */
srcpad = gst_element_get_static_pad (ebin, "src");
GST_START_TEST (test_encodebin_render_audio_static)
{
GstElement *ebin, *pipeline, *audiotestsrc, *fakesink;
- GstEncodingProfile *prof;
GstBus *bus;
gboolean done = FALSE;
fakesink = gst_element_factory_make ("fakesink", NULL);
ebin = gst_element_factory_make ("encodebin", NULL);
-
- prof = create_ogg_vorbis_profile (1, NULL);
- g_object_set (ebin, "profile", prof, NULL);
- gst_encoding_profile_unref (prof);
+ set_profile (ebin, create_ogg_vorbis_profile (1, NULL));
gst_bin_add_many ((GstBin *) pipeline, audiotestsrc, ebin, fakesink, NULL);
GST_START_TEST (test_encodebin_render_audio_only_static)
{
GstElement *ebin, *pipeline, *audiotestsrc, *fakesink;
- GstEncodingProfile *prof;
GstBus *bus;
gboolean done = FALSE;
GstPad *sinkpad;
fakesink = gst_element_factory_make ("fakesink", NULL);
ebin = gst_element_factory_make ("encodebin", NULL);
-
- prof = create_vorbis_only_profile ();
- g_object_set (ebin, "profile", prof, NULL);
- gst_encoding_profile_unref (prof);
+ set_profile (ebin, create_vorbis_only_profile ());
gst_bin_add_many (GST_BIN (pipeline), audiotestsrc, ebin, fakesink, NULL);
GST_START_TEST (test_encodebin_render_audio_dynamic)
{
GstElement *ebin, *pipeline, *audiotestsrc, *fakesink;
- GstEncodingProfile *prof;
GstBus *bus;
GstPad *sinkpad, *srcpad;
gboolean done = FALSE;
fakesink = gst_element_factory_make ("fakesink", NULL);
ebin = gst_element_factory_make ("encodebin", NULL);
-
- prof = create_ogg_vorbis_profile (0, NULL);
- g_object_set (ebin, "profile", prof, NULL);
- gst_encoding_profile_unref (prof);
+ set_profile (ebin, create_ogg_vorbis_profile (0, NULL));
gst_bin_add_many ((GstBin *) pipeline, audiotestsrc, ebin, fakesink, NULL);
GST_START_TEST (test_encodebin_render_audio_video_static)
{
GstElement *ebin, *pipeline, *audiotestsrc, *videotestsrc, *fakesink;
- GstEncodingProfile *prof;
GstBus *bus;
gboolean done = FALSE;
fakesink = gst_element_factory_make ("fakesink", NULL);
ebin = gst_element_factory_make ("encodebin", NULL);
-
- prof = create_ogg_theora_vorbis_profile (1, 1);
- g_object_set (ebin, "profile", prof, NULL);
- gst_encoding_profile_unref (prof);
+ set_profile (ebin, create_ogg_theora_vorbis_profile (1, 1));
gst_bin_add_many ((GstBin *) pipeline, audiotestsrc, videotestsrc, ebin,
fakesink, NULL);
GST_START_TEST (test_encodebin_render_audio_video_dynamic)
{
GstElement *ebin, *pipeline, *audiotestsrc, *videotestsrc, *fakesink;
- GstEncodingProfile *prof;
GstBus *bus;
gboolean done = FALSE;
GstPad *sinkpad1, *sinkpad2, *srcpad;
fakesink = gst_element_factory_make ("fakesink", NULL);
ebin = gst_element_factory_make ("encodebin", NULL);
-
- prof = create_ogg_theora_vorbis_profile (0, 0);
- g_object_set (ebin, "profile", prof, NULL);
- gst_encoding_profile_unref (prof);
+ set_profile (ebin, create_ogg_theora_vorbis_profile (0, 0));
gst_bin_add_many ((GstBin *) pipeline, audiotestsrc, videotestsrc, ebin,
fakesink, NULL);
GST_END_TEST;
+GST_START_TEST (test_encodebin_missing_plugin_messages)
+{
+ GstElement *pipeline = gst_pipeline_new ("test");
+ GstBus *bus = gst_pipeline_get_bus ((GstPipeline *) pipeline);
+ GstElement *ebin = gst_element_factory_make ("encodebin", NULL);
+ GstMessage *message;
+
+ /* first add to bin, then set profile */
+ gst_bin_add ((GstBin *) pipeline, ebin);
+ set_profile (ebin, create_unsupported_profile ());
+
+ gst_element_set_state (pipeline, GST_STATE_READY);
+
+ message = gst_bus_pop_filtered (bus, GST_MESSAGE_ELEMENT);
+ fail_if (message == NULL);
+ fail_if (!gst_is_missing_plugin_message (message));
+ gst_message_unref (message);
+
+ gst_element_set_state (pipeline, GST_STATE_NULL);
+ gst_object_unref (bus);
+ gst_object_unref (pipeline);
+}
+
+GST_END_TEST;
+
static Suite *
encodebin_suite (void)
{
TCase *tc_chain = tcase_create ("general");
suite_add_tcase (s, tc_chain);
- tcase_add_test (tc_chain, test_encodebin_states);
+ tcase_add_test (tc_chain, test_encodebin_set_profile);
+ tcase_add_test (tc_chain, test_encodebin_can_go_to_ready_without_profile);
+ tcase_add_test (tc_chain, test_encodebin_can_go_to_paused_with_profile);
tcase_add_test (tc_chain, test_encodebin_sink_pads_static);
tcase_add_test (tc_chain, test_encodebin_sink_pads_nopreset_static);
tcase_add_test (tc_chain, test_encodebin_preset);
tcase_add_test (tc_chain, test_encodebin_impossible_element_combination);
tcase_add_test (tc_chain, test_encodebin_reuse);
tcase_add_test (tc_chain, test_encodebin_named_requests);
+ tcase_add_test (tc_chain, test_encodebin_missing_plugin_messages);
return s;
}