summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorThiago Santos <thiagoss@osg.samsung.com>2016-02-29 23:40:03 -0300
committerTim-Philipp Müller <tim@centricular.com>2016-04-06 13:15:42 +0100
commit602c287823594274db903d2355a8724010a0cc56 (patch)
tree04b03c41d552df892506139f7610c843a395d17a
parente47b013db4e4605272ab43b603dff513d35dd7d7 (diff)
downloadgstreamer-plugins-good-602c287823594274db903d2355a8724010a0cc56.tar.gz
splitmuxsink: only try to create internal sink if it doesn't exist
This allows splitmuxsink to be reused after being put to NULL. Test included https://bugzilla.gnome.org/show_bug.cgi?id=762893
-rw-r--r--gst/multifile/gstsplitmuxsink.c59
-rw-r--r--tests/check/elements/splitmux.c32
2 files changed, 61 insertions, 30 deletions
diff --git a/gst/multifile/gstsplitmuxsink.c b/gst/multifile/gstsplitmuxsink.c
index aef9e64a3..a925d55b2 100644
--- a/gst/multifile/gstsplitmuxsink.c
+++ b/gst/multifile/gstsplitmuxsink.c
@@ -1439,42 +1439,43 @@ create_sink (GstSplitMuxSink * splitmux)
{
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;
diff --git a/tests/check/elements/splitmux.c b/tests/check/elements/splitmux.c
index 31b421c65..bf906946b 100644
--- a/tests/check/elements/splitmux.c
+++ b/tests/check/elements/splitmux.c
@@ -216,16 +216,46 @@ GST_START_TEST (test_splitmuxsink)
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);