Diff
Modified: trunk/Source/WebCore/ChangeLog (250623 => 250624)
--- trunk/Source/WebCore/ChangeLog 2019-10-02 20:07:38 UTC (rev 250623)
+++ trunk/Source/WebCore/ChangeLog 2019-10-02 20:11:09 UTC (rev 250624)
@@ -1,3 +1,17 @@
+2019-10-02 Thibault Saunier <[email protected]>
+
+ [GStreamer] Let playbin handle redirects for us when appropriate
+ https://bugs.webkit.org/show_bug.cgi?id=195326
+
+ A simplified mechanism has been added in GStreamer to handle corner cases.
+
+ Reviewed by Xabier Rodriguez-Calvar.
+
+ Not easily testable at our level
+
+ * platform/graphics/gstreamer/MediaPlayerPrivateGStreamer.cpp:
+ (WebCore::MediaPlayerPrivateGStreamer::loadNextLocation):
+
2019-10-02 Tim Horton <[email protected]>
Another build fix
Modified: trunk/Source/WebCore/platform/graphics/gstreamer/MediaPlayerPrivateGStreamer.cpp (250623 => 250624)
--- trunk/Source/WebCore/platform/graphics/gstreamer/MediaPlayerPrivateGStreamer.cpp 2019-10-02 20:07:38 UTC (rev 250623)
+++ trunk/Source/WebCore/platform/graphics/gstreamer/MediaPlayerPrivateGStreamer.cpp 2019-10-02 20:11:09 UTC (rev 250624)
@@ -2166,6 +2166,19 @@
URL baseUrl = gst_uri_is_valid(newLocation) ? URL() : m_url;
URL newUrl = URL(baseUrl, newLocation);
+ GUniqueOutPtr<gchar> playbinUrlStr;
+ g_object_get(m_pipeline.get(), "current-uri", &playbinUrlStr.outPtr(), nullptr);
+ URL playbinUrl(URL(), playbinUrlStr.get());
+
+ if (playbinUrl == newUrl) {
+ GST_DEBUG_OBJECT(pipeline(), "Playbin already handled redirection.");
+
+ m_url = playbinUrl;
+
+ return true;
+ }
+
+ changePipelineState(GST_STATE_READY);
auto securityOrigin = SecurityOrigin::create(m_url);
if (securityOrigin->canRequest(newUrl)) {
GST_INFO_OBJECT(pipeline(), "New media url: %s", newUrl.string().utf8().data());
@@ -2178,7 +2191,6 @@
// Reset pipeline state.
m_resetPipeline = true;
- changePipelineState(GST_STATE_READY);
GstState state;
gst_element_get_state(m_pipeline.get(), &state, nullptr, 0);
Modified: trunk/Tools/ChangeLog (250623 => 250624)
--- trunk/Tools/ChangeLog 2019-10-02 20:07:38 UTC (rev 250623)
+++ trunk/Tools/ChangeLog 2019-10-02 20:11:09 UTC (rev 250624)
@@ -1,3 +1,15 @@
+2019-10-02 Thibault Saunier <[email protected]>
+
+ [GSTreamer] Let playbin handle redirects for us when appropriate
+ https://bugs.webkit.org/show_bug.cgi?id=195326
+
+ Added required patche in GStreamer
+
+ Reviewed by Xabier Rodriguez-Calvar.
+
+ * gstreamer/patches/base-0001-playbin-Handle-error-message-with-redirection-indica.patch: Added.
+ * gstreamer/patches/good-0001-qtdemux-Specify-REDIRECT-information-in-error-messag.patch: Added.
+
2019-10-01 Aakash Jain <[email protected]>
[ews] Add API endpoint to retry failed builds for a patch
Modified: trunk/Tools/gstreamer/jhbuild.modules (250623 => 250624)
--- trunk/Tools/gstreamer/jhbuild.modules 2019-10-02 20:07:38 UTC (rev 250623)
+++ trunk/Tools/gstreamer/jhbuild.modules 2019-10-02 20:11:09 UTC (rev 250624)
@@ -69,6 +69,7 @@
<dep package="gstreamer"/>
</dependencies>
<branch hash="sha256:4093aa7b51e28fb24dfd603893fead8d1b7782f088b05ed0f22a21ef176fb5ae" module="gst-plugins-base/gst-plugins-base-${version}.tar.xz" repo="gstreamer" version="1.16.0" >
+ <patch file="base-0001-playbin-Handle-error-message-with-redirection-indica.patch" strip="1"/>
</branch>
</meson>
@@ -81,6 +82,7 @@
<branch hash="sha256:654adef33380d604112f702c2927574cfc285e31307b79e584113858838bb0fd" module="gst-plugins-good/gst-plugins-good-${version}.tar.xz" repo="gstreamer" version="1.16.0">
<patch file="gst-plugins-good-scaletempo-Advertise-interleaved-layout-in-caps-temp.patch" strip="1"/> <!-- Merged upstream, should be shipped in 1.16.1 -->
<patch file="gst-plugins-good-glibc-2.30-compat.patch" strip="1"/> <!-- Merged upstream, should be shipped in 1.16.1 -->
+ <patch file="good-0001-qtdemux-Specify-REDIRECT-information-in-error-messag.patch" strip="1"/> <!-- Merged upstream, should be shipped in 1.16.1 -->
</branch>
</meson>
Added: trunk/Tools/gstreamer/patches/base-0001-playbin-Handle-error-message-with-redirection-indica.patch (0 => 250624)
--- trunk/Tools/gstreamer/patches/base-0001-playbin-Handle-error-message-with-redirection-indica.patch (rev 0)
+++ trunk/Tools/gstreamer/patches/base-0001-playbin-Handle-error-message-with-redirection-indica.patch 2019-10-02 20:11:09 UTC (rev 250624)
@@ -0,0 +1,100 @@
+From 6e503b6e34000a18a49d2966df2c01c2ef14bd5c Mon Sep 17 00:00:00 2001
+From: Thibault Saunier <[email protected]>
+Date: Tue, 3 Sep 2019 16:03:49 -0400
+Subject: [PATCH] playbin: Handle error message with redirection indication
+
+There are in the wild (mp4) streams that basically contain no tracks
+but do have a redirect info[0], in which case, qtdemux won't be able
+to expose any pad (there are no tracks) so can't post anything but
+an error on the bus, as:
+ - it can't send EOS downstream, it has no pad,
+ - posting an EOS message will be useless as PAUSED state can't be
+ reached and there is no sink in the pipeline meaning GstBin will
+ simply ignore it
+
+In that case, currently the application could try to handle that but it
+is pretty complex as it will get the REDIRECT message on the bus at
+which point it could set the URL but playbin will ignore it, as
+it will only be for the next EOS, it thus need to set the pipeline to
+NULL (READY won't do as it is already in READY at that point). And it
+needs to figure out the following ERROR message on the bus needs to be
+ignored, which is not really simple.
+
+The approach here is to allow element to add details to the ERROR
+message with a `redirect-location` field which elements like playbin handle
+and use right away.
+
+We could also use the element 'redirect' message in playbin, but the
+issue with that approach is that the element will still emit the ERROR
+message on the bus, leading to wrong behaviour. That can't be avoided
+since in the case the app/parent pipeline is not handling the redirect
+instruction, the ERROR message is necessary (and there is no way to
+detect that the message has been "handled" from the element emitting the
+redirect).
+
+[0]: http://movietrailers.apple.com/movies/paramount/terminator-dark-fate/terminator-dark-fate-trailer-2_480p.mov
+---
+ gst/playback/gstplaybin2.c | 40 ++++++++++++++++++++++++++++++++++++++
+ 1 file changed, 40 insertions(+)
+
+diff --git a/gst/playback/gstplaybin2.c b/gst/playback/gstplaybin2.c
+index c8bfd388e..6997a957c 100644
+--- a/gst/playback/gstplaybin2.c
++++ b/gst/playback/gstplaybin2.c
+@@ -170,6 +170,10 @@
+ * type. The new location may be a relative or an absolute URI. Examples
+ * for such redirects can be found in many quicktime movie trailers.
+ *
++ * NOTE: playbin will internally handle the redirect messages in the case
++ * that the redirecting stream doesn't contain any tracks and thus
++ * needs to report an error message on the bus.
++ *
+ * ## Examples
+ * |[
+ * gst-launch-1.0 -v playbin uri=file:///path/to/somefile.mp4
+@@ -3025,6 +3029,42 @@ gst_play_bin_handle_message (GstBin * bin, GstMessage * msg)
+ no_more_pads_cb (NULL, group);
+ }
+ }
++ } else {
++ const GstStructure *details = NULL;
++
++ gst_message_parse_error_details (msg, &details);
++ if (details && gst_structure_has_field (details, "redirect-location")) {
++ gchar *uri = NULL;
++ const gchar *location =
++ gst_structure_get_string ((GstStructure *) details,
++ "redirect-location");
++
++ if (gst_uri_is_valid (location)) {
++ uri = g_strdup (location);
++ } else {
++ uri = gst_uri_join_strings (group->uri, location);
++ }
++
++ if (g_strcmp0 (uri, group->uri)) {
++ GST_PLAY_BIN_LOCK (playbin);
++ if (playbin->next_group && playbin->next_group->valid) {
++ GST_DEBUG_OBJECT (playbin,
++ "User already setup next uri %s, using it",
++ playbin->next_group->uri);
++ } else {
++ GST_DEBUG_OBJECT (playbin,
++ "Using newly configured redirect URI: %s", uri);
++ gst_play_bin_set_uri (playbin, uri);
++ }
++ GST_PLAY_BIN_UNLOCK (playbin);
++
++ setup_next_source (playbin, GST_STATE_PAUSED);
++ gst_message_unref (msg);
++ msg = NULL;
++ }
++
++ g_free (uri);
++ }
+ }
+ }
+
+--
+2.21.0
+
Added: trunk/Tools/gstreamer/patches/good-0001-qtdemux-Specify-REDIRECT-information-in-error-messag.patch (0 => 250624)
--- trunk/Tools/gstreamer/patches/good-0001-qtdemux-Specify-REDIRECT-information-in-error-messag.patch (rev 0)
+++ trunk/Tools/gstreamer/patches/good-0001-qtdemux-Specify-REDIRECT-information-in-error-messag.patch 2019-10-02 20:11:09 UTC (rev 250624)
@@ -0,0 +1,140 @@
+From a55576d1fd25c7d67661630fc94367908802a496 Mon Sep 17 00:00:00 2001
+From: Thibault Saunier <[email protected]>
+Date: Tue, 3 Sep 2019 16:46:30 -0400
+Subject: [PATCH] qtdemux: Specify REDIRECT information in error message
+
+There are in the wild (mp4) streams that basically contain no tracks
+but do have a redirect info[0], in which case, we won't be able
+to expose any pad (there are no tracks) so we can't post anything but
+an error on the bus, as:
+
+- it can't send EOS downstream, it has no pad,
+- posting an EOS message will be useless as PAUSED state can't be
+ reached and there is no sink in the pipeline meaning GstBin will
+ simply ignore it
+
+The approach here is to to add details to the ERROR message with a
+`redirect-location` field which elements like playbin handle and use right
+away.
+
+[0]: http://movietrailers.apple.com/movies/paramount/terminator-dark-fate/terminator-dark-fate-trailer-2_480p.mov
+---
+ gst/isomp4/qtdemux.c | 32 +++++++++++++++++++++++++-------
+ gst/isomp4/qtdemux.h | 2 +-
+ 2 files changed, 26 insertions(+), 8 deletions(-)
+
+diff --git a/gst/isomp4/qtdemux.c b/gst/isomp4/qtdemux.c
+index ba4d43648..8a6bf08c7 100644
+--- a/gst/isomp4/qtdemux.c
++++ b/gst/isomp4/qtdemux.c
+@@ -526,6 +526,7 @@ GST_STATIC_PAD_TEMPLATE ("subtitle_%u",
+ G_DEFINE_TYPE (GstQTDemux, gst_qtdemux, GST_TYPE_ELEMENT);
+
+ static void gst_qtdemux_dispose (GObject * object);
++static void gst_qtdemux_finalize (GObject * object);
+
+ static guint32
+ gst_qtdemux_find_index_linear (GstQTDemux * qtdemux, QtDemuxStream * str,
+@@ -628,6 +629,7 @@ gst_qtdemux_class_init (GstQTDemuxClass * klass)
+ parent_class = g_type_class_peek_parent (klass);
+
+ gobject_class->dispose = gst_qtdemux_dispose;
++ gobject_class->finalize = gst_qtdemux_finalize;
+
+ gstelement_class->change_state = GST_DEBUG_FUNCPTR (gst_qtdemux_change_state);
+ #if 0
+@@ -683,6 +685,16 @@ gst_qtdemux_init (GstQTDemux * qtdemux)
+ gst_qtdemux_reset (qtdemux, TRUE);
+ }
+
++static void
++gst_qtdemux_finalize (GObject * object)
++{
++ GstQTDemux *qtdemux = GST_QTDEMUX (object);
++
++ g_free (qtdemux->redirect_location);
++
++ G_OBJECT_CLASS (parent_class)->finalize (object);
++}
++
+ static void
+ gst_qtdemux_dispose (GObject * object)
+ {
+@@ -711,10 +723,11 @@ gst_qtdemux_dispose (GObject * object)
+ static void
+ gst_qtdemux_post_no_playable_stream_error (GstQTDemux * qtdemux)
+ {
+- if (qtdemux->posted_redirect) {
+- GST_ELEMENT_ERROR (qtdemux, STREAM, DEMUX,
++ if (qtdemux->redirect_location) {
++ GST_ELEMENT_ERROR_WITH_DETAILS (qtdemux, STREAM, DEMUX,
+ (_("This file contains no playable streams.")),
+- ("no known streams found, a redirect message has been posted"));
++ ("no known streams found, a redirect message has been posted"),
++ ("redirect-location", G_TYPE_STRING, qtdemux->redirect_location, NULL));
+ } else {
+ GST_ELEMENT_ERROR (qtdemux, STREAM, DEMUX,
+ (_("This file contains no playable streams.")),
+@@ -2111,7 +2124,7 @@ gst_qtdemux_reset (GstQTDemux * qtdemux, gboolean hard)
+ qtdemux->neededbytes = 16;
+ qtdemux->todrop = 0;
+ qtdemux->pullbased = FALSE;
+- qtdemux->posted_redirect = FALSE;
++ g_clear_pointer (&qtdemux->redirect_location, g_free);
+ qtdemux->first_mdat = -1;
+ qtdemux->header_size = 0;
+ qtdemux->mdatoffset = -1;
+@@ -6065,11 +6078,12 @@ gst_qtdemux_decorate_and_push_buffer (GstQTDemux * qtdemux,
+ gst_buffer_unmap (buf, &map);
+ if (url != NULL && strlen (url) != 0) {
+ /* we have RTSP redirect now */
++ g_free (qtdemux->redirect_location);
++ qtdemux->redirect_location = g_strdup (url);
+ gst_element_post_message (GST_ELEMENT_CAST (qtdemux),
+ gst_message_new_element (GST_OBJECT_CAST (qtdemux),
+ gst_structure_new ("redirect",
+ "new-location", G_TYPE_STRING, url, NULL)));
+- qtdemux->posted_redirect = TRUE;
+ } else {
+ GST_WARNING_OBJECT (qtdemux, "Redirect URI of stream is empty, not "
+ "posting");
+@@ -12915,7 +12929,9 @@ qtdemux_expose_streams (GstQTDemux * qtdemux)
+ "new-location", G_TYPE_STRING,
+ QTDEMUX_NTH_STREAM (qtdemux, 0)->redirect_uri, NULL));
+ gst_element_post_message (GST_ELEMENT_CAST (qtdemux), m);
+- qtdemux->posted_redirect = TRUE;
++ g_free (qtdemux->redirect_location);
++ qtdemux->redirect_location =
++ g_strdup (QTDEMUX_NTH_STREAM (qtdemux, 0)->redirect_uri);
+ }
+
+ g_ptr_array_foreach (qtdemux->active_streams,
+@@ -13968,9 +13984,11 @@ qtdemux_process_redirects (GstQTDemux * qtdemux, GList * references)
+ g_list_free (references);
+
+ GST_INFO_OBJECT (qtdemux, "posting redirect message: %" GST_PTR_FORMAT, s);
++ g_free (qtdemux->redirect_location);
++ qtdemux->redirect_location =
++ g_strdup (gst_structure_get_string (s, "new-location"));
+ msg = gst_message_new_element (GST_OBJECT_CAST (qtdemux), s);
+ gst_element_post_message (GST_ELEMENT_CAST (qtdemux), msg);
+- qtdemux->posted_redirect = TRUE;
+ }
+
+ /* look for redirect nodes, collect all redirect information and
+diff --git a/gst/isomp4/qtdemux.h b/gst/isomp4/qtdemux.h
+index f9731b2b8..c5e85c721 100644
+--- a/gst/isomp4/qtdemux.h
++++ b/gst/isomp4/qtdemux.h
+@@ -69,7 +69,7 @@ struct _GstQTDemux {
+ /* TRUE if pull-based */
+ gboolean pullbased;
+
+- gboolean posted_redirect;
++ gchar *redirect_location;
+
+ /* Protect pad exposing from flush event */
+ GMutex expose_lock;
+--
+2.21.0
+