mirror of
https://gitlab.freedesktop.org/gstreamer/gstreamer.git
synced 2025-03-27 11:32:51 +00:00
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
This commit is contained in:
parent
c163250f0d
commit
d738fa0787
2 changed files with 61 additions and 30 deletions
|
@ -1437,44 +1437,45 @@ 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");
|
||||
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;
|
||||
|
||||
/* The bin holds a ref now, we can drop our tmp ref */
|
||||
gst_object_unref (provided_sink);
|
||||
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;
|
||||
}
|
||||
}
|
||||
|
||||
splitmux->active_sink = 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");
|
||||
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;
|
||||
fail:
|
||||
return FALSE;
|
||||
|
|
|
@ -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_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);
|
||||
|
||||
|
|
Loading…
Reference in a new issue