{
GstElement *provided_sink = NULL;
- g_return_val_if_fail (splitmux->active_sink == NULL, TRUE);
+ if (splitmux->active_sink == NULL) {
- GST_OBJECT_LOCK (splitmux);
- if (splitmux->provided_sink != NULL)
- provided_sink = gst_object_ref (splitmux->provided_sink);
- GST_OBJECT_UNLOCK (splitmux);
+ GST_OBJECT_LOCK (splitmux);
+ if (splitmux->provided_sink != NULL)
+ provided_sink = gst_object_ref (splitmux->provided_sink);
+ GST_OBJECT_UNLOCK (splitmux);
- if (provided_sink == NULL) {
- if ((splitmux->sink =
- create_element (splitmux, DEFAULT_SINK, "sink")) == NULL)
- goto fail;
- splitmux->active_sink = splitmux->sink;
- } else {
- if (!gst_bin_add (GST_BIN (splitmux), provided_sink)) {
- g_warning ("Could not add sink elements - splitmuxsink will not work");
- gst_object_unref (provided_sink);
- goto fail;
- }
+ if (provided_sink == NULL) {
+ if ((splitmux->sink =
+ create_element (splitmux, DEFAULT_SINK, "sink")) == NULL)
+ goto fail;
+ splitmux->active_sink = splitmux->sink;
+ } else {
+ if (!gst_bin_add (GST_BIN (splitmux), provided_sink)) {
+ g_warning ("Could not add sink elements - splitmuxsink will not work");
+ gst_object_unref (provided_sink);
+ goto fail;
+ }
- splitmux->active_sink = provided_sink;
+ splitmux->active_sink = provided_sink;
- /* The bin holds a ref now, we can drop our tmp ref */
- gst_object_unref (provided_sink);
+ /* The bin holds a ref now, we can drop our tmp ref */
+ gst_object_unref (provided_sink);
- /* Find the sink element */
- splitmux->sink = find_sink (splitmux->active_sink);
- if (splitmux->sink == NULL) {
- g_warning
- ("Could not locate sink element in provided sink - splitmuxsink will not work");
- goto fail;
+ /* Find the sink element */
+ splitmux->sink = find_sink (splitmux->active_sink);
+ if (splitmux->sink == NULL) {
+ g_warning
+ ("Could not locate sink element in provided sink - splitmuxsink will not work");
+ goto fail;
+ }
}
- }
- if (!gst_element_link (splitmux->muxer, splitmux->active_sink)) {
- g_warning ("Failed to link muxer and sink- splitmuxsink will not work");
- goto fail;
+ if (!gst_element_link (splitmux->muxer, splitmux->active_sink)) {
+ g_warning ("Failed to link muxer and sink- splitmuxsink will not work");
+ goto fail;
+ }
}
return TRUE;
GST_END_TEST;
+/* For verifying bug https://bugzilla.gnome.org/show_bug.cgi?id=762893 */
+GST_START_TEST (test_splitmuxsink_reuse_simple)
+{
+ GstElement *sink;
+ GstPad *pad;
+
+ sink = gst_element_factory_make ("splitmuxsink", NULL);
+ pad = gst_element_get_request_pad (sink, "video");
+ fail_unless (pad != NULL);
+ g_object_set (sink, "location", "/dev/null", NULL);
+
+ fail_unless (gst_element_set_state (sink,
+ GST_STATE_PLAYING) == GST_STATE_CHANGE_ASYNC);
+ fail_unless (gst_element_set_state (sink,
+ GST_STATE_NULL) == GST_STATE_CHANGE_SUCCESS);
+ fail_unless (gst_element_set_state (sink,
+ GST_STATE_PLAYING) == GST_STATE_CHANGE_ASYNC);
+ fail_unless (gst_element_set_state (sink,
+ GST_STATE_NULL) == GST_STATE_CHANGE_SUCCESS);
+
+ gst_element_release_request_pad (sink, pad);
+ gst_object_unref (pad);
+ gst_object_unref (sink);
+}
+
+GST_END_TEST;
+
static Suite *
splitmux_suite (void)
{
Suite *s = suite_create ("splitmux");
TCase *tc_chain = tcase_create ("general");
+ TCase *tc_chain_basic = tcase_create ("basic");
suite_add_tcase (s, tc_chain);
+ suite_add_tcase (s, tc_chain_basic);
- tcase_add_checked_fixture (tc_chain, tempdir_setup, tempdir_cleanup);
+ tcase_add_test (tc_chain_basic, test_splitmuxsink_reuse_simple);
+ tcase_add_checked_fixture (tc_chain, tempdir_setup, tempdir_cleanup);
tcase_add_test (tc_chain, test_splitmuxsrc);
tcase_add_test (tc_chain, test_splitmuxsink);