From 16ed0a6961fb0e2b6d9505764a8ff568b2c9999b Mon Sep 17 00:00:00 2001 From: =?utf8?q?Sebastian=20Dr=C3=B6ge?= Date: Fri, 1 Apr 2022 10:25:23 +0300 Subject: [PATCH] playbin/playbin3: Allow setting a NULL URI The URI is already initialized to NULL at the beginning and GstPlayer was assuming that it is possible to set to NULL at a later time too. Fixes https://gitlab.freedesktop.org/gstreamer/gstreamer/-/issues/1124 Part-of: --- .../gst-plugins-base/gst/playback/gstplaybin2.c | 18 +++++++++--------- .../gst-plugins-base/gst/playback/gstplaybin3.c | 18 +++++++++--------- 2 files changed, 18 insertions(+), 18 deletions(-) diff --git a/subprojects/gst-plugins-base/gst/playback/gstplaybin2.c b/subprojects/gst-plugins-base/gst/playback/gstplaybin2.c index 56ca76f..1dc2b45 100644 --- a/subprojects/gst-plugins-base/gst/playback/gstplaybin2.c +++ b/subprojects/gst-plugins-base/gst/playback/gstplaybin2.c @@ -1670,12 +1670,7 @@ gst_play_bin_set_uri (GstPlayBin * playbin, const gchar * uri) { GstSourceGroup *group; - if (uri == NULL) { - g_warning ("cannot set NULL uri"); - return; - } - - if (!gst_playbin_uri_is_valid (playbin, uri)) { + if (uri && !gst_playbin_uri_is_valid (playbin, uri)) { if (g_str_has_prefix (uri, "file:")) { GST_WARNING_OBJECT (playbin, "not entirely correct file URI '%s' - make " "sure to escape spaces and non-ASCII characters properly and specify " @@ -1692,11 +1687,16 @@ gst_play_bin_set_uri (GstPlayBin * playbin, const gchar * uri) GST_SOURCE_GROUP_LOCK (group); /* store the uri in the next group we will play */ g_free (group->uri); - group->uri = g_strdup (uri); - group->valid = TRUE; + if (uri) { + group->uri = g_strdup (uri); + group->valid = TRUE; + } else { + group->uri = NULL; + group->valid = FALSE; + } GST_SOURCE_GROUP_UNLOCK (group); - GST_DEBUG ("set new uri to %s", uri); + GST_DEBUG ("set new uri to %s", GST_STR_NULL (uri)); GST_PLAY_BIN_UNLOCK (playbin); } diff --git a/subprojects/gst-plugins-base/gst/playback/gstplaybin3.c b/subprojects/gst-plugins-base/gst/playback/gstplaybin3.c index 6cfabba..7946c6a 100644 --- a/subprojects/gst-plugins-base/gst/playback/gstplaybin3.c +++ b/subprojects/gst-plugins-base/gst/playback/gstplaybin3.c @@ -1476,12 +1476,7 @@ gst_play_bin3_set_uri (GstPlayBin3 * playbin, const gchar * uri) { GstSourceGroup *group; - if (uri == NULL) { - g_warning ("cannot set NULL uri"); - return; - } - - if (!gst_playbin_uri_is_valid (playbin, uri)) { + if (uri && !gst_playbin_uri_is_valid (playbin, uri)) { if (g_str_has_prefix (uri, "file:")) { GST_WARNING_OBJECT (playbin, "not entirely correct file URI '%s' - make " "sure to escape spaces and non-ASCII characters properly and specify " @@ -1498,11 +1493,16 @@ gst_play_bin3_set_uri (GstPlayBin3 * playbin, const gchar * uri) GST_SOURCE_GROUP_LOCK (group); /* store the uri in the next group we will play */ g_free (group->uri); - group->uri = g_strdup (uri); - group->valid = TRUE; + if (uri) { + group->uri = g_strdup (uri); + group->valid = TRUE; + } else { + group->uri = NULL; + group->valid = FALSE; + } GST_SOURCE_GROUP_UNLOCK (group); - GST_DEBUG ("set new uri to %s", uri); + GST_DEBUG ("set new uri to %s", GST_STR_NULL (uri)); GST_PLAY_BIN3_UNLOCK (playbin); } -- 2.7.4