[GStreamer] Use of playbin3 when USE_PLAYBIN3 environment variable is set
authorcommit-queue@webkit.org <commit-queue@webkit.org@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Wed, 11 Apr 2018 18:33:39 +0000 (18:33 +0000)
committercommit-queue@webkit.org <commit-queue@webkit.org@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Wed, 11 Apr 2018 18:33:39 +0000 (18:33 +0000)
https://bugs.webkit.org/show_bug.cgi?id=184498

Patch by Thibault Saunier <tsaunier@igalia.com> on 2018-04-11
Reviewed by Philippe Normand.

.:

This is the same behaviour as with playbin itself.

Make sure to keep using "playbin" for MediaSource.

* Source/cmake/GStreamerDefinitions.cmake:

Source/WebCore:

[GStreamer] Use of playbin3 when USE_PLAYBIN3 environment variable is set

This is the same behaviour as with playbin itself.

Make sure to keep using "playbin" for MediaSource.

No test added as this is basically a small rework of the way we expose a feature.

* platform/graphics/gstreamer/AudioTrackPrivateGStreamer.cpp:
* platform/graphics/gstreamer/AudioTrackPrivateGStreamer.h:
* platform/graphics/gstreamer/GRefPtrGStreamer.cpp:
* platform/graphics/gstreamer/GRefPtrGStreamer.h:
* platform/graphics/gstreamer/InbandTextTrackPrivateGStreamer.cpp:
* platform/graphics/gstreamer/InbandTextTrackPrivateGStreamer.h:
* platform/graphics/gstreamer/MediaPlayerPrivateGStreamer.cpp:
(WebCore::MediaPlayerPrivateGStreamer::load):
(WebCore::MediaPlayerPrivateGStreamer::enableTrack):
(WebCore::MediaPlayerPrivateGStreamer::handleMessage):
(WebCore::MediaPlayerPrivateGStreamer::createGSTPlayBin):
* platform/graphics/gstreamer/MediaPlayerPrivateGStreamer.h:
* platform/graphics/gstreamer/MediaPlayerPrivateGStreamerBase.h:
* platform/graphics/gstreamer/TrackPrivateBaseGStreamer.cpp:
(WebCore::TrackPrivateBaseGStreamer::disconnect):
(WebCore::TrackPrivateBaseGStreamer::tagsChanged):
* platform/graphics/gstreamer/TrackPrivateBaseGStreamer.h:
* platform/graphics/gstreamer/VideoTrackPrivateGStreamer.cpp:
* platform/graphics/gstreamer/VideoTrackPrivateGStreamer.h:

git-svn-id: https://svn.webkit.org/repository/webkit/trunk@230540 268f45cc-cd09-0410-ab3c-d52691b4dbfc

16 files changed:
ChangeLog
Source/WebCore/ChangeLog
Source/WebCore/platform/graphics/gstreamer/AudioTrackPrivateGStreamer.cpp
Source/WebCore/platform/graphics/gstreamer/AudioTrackPrivateGStreamer.h
Source/WebCore/platform/graphics/gstreamer/GRefPtrGStreamer.cpp
Source/WebCore/platform/graphics/gstreamer/GRefPtrGStreamer.h
Source/WebCore/platform/graphics/gstreamer/InbandTextTrackPrivateGStreamer.cpp
Source/WebCore/platform/graphics/gstreamer/InbandTextTrackPrivateGStreamer.h
Source/WebCore/platform/graphics/gstreamer/MediaPlayerPrivateGStreamer.cpp
Source/WebCore/platform/graphics/gstreamer/MediaPlayerPrivateGStreamer.h
Source/WebCore/platform/graphics/gstreamer/MediaPlayerPrivateGStreamerBase.h
Source/WebCore/platform/graphics/gstreamer/TrackPrivateBaseGStreamer.cpp
Source/WebCore/platform/graphics/gstreamer/TrackPrivateBaseGStreamer.h
Source/WebCore/platform/graphics/gstreamer/VideoTrackPrivateGStreamer.cpp
Source/WebCore/platform/graphics/gstreamer/VideoTrackPrivateGStreamer.h
Source/cmake/GStreamerDefinitions.cmake

index e3c16b9..cb1ec06 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,16 @@
+2018-04-11  Thibault Saunier  <tsaunier@igalia.com>
+
+        [GStreamer] Use of playbin3 when USE_PLAYBIN3 environment variable is set
+        https://bugs.webkit.org/show_bug.cgi?id=184498
+
+        Reviewed by Philippe Normand.
+
+        This is the same behaviour as with playbin itself.
+
+        Make sure to keep using "playbin" for MediaSource.
+
+        * Source/cmake/GStreamerDefinitions.cmake:
+
 2018-04-09  Michael Catanzaro  <mcatanzaro@igalia.com>
 
         [WPE] Use GNU install directories
index 8b7a449..9b6b96c 100644 (file)
@@ -1,3 +1,38 @@
+2018-04-11  Thibault Saunier  <tsaunier@igalia.com>
+
+        [GStreamer] Use of playbin3 when USE_PLAYBIN3 environment variable is set
+        https://bugs.webkit.org/show_bug.cgi?id=184498
+
+        Reviewed by Philippe Normand.
+
+        [GStreamer] Use of playbin3 when USE_PLAYBIN3 environment variable is set
+
+        This is the same behaviour as with playbin itself.
+
+        Make sure to keep using "playbin" for MediaSource.
+
+        No test added as this is basically a small rework of the way we expose a feature.
+
+        * platform/graphics/gstreamer/AudioTrackPrivateGStreamer.cpp:
+        * platform/graphics/gstreamer/AudioTrackPrivateGStreamer.h:
+        * platform/graphics/gstreamer/GRefPtrGStreamer.cpp:
+        * platform/graphics/gstreamer/GRefPtrGStreamer.h:
+        * platform/graphics/gstreamer/InbandTextTrackPrivateGStreamer.cpp:
+        * platform/graphics/gstreamer/InbandTextTrackPrivateGStreamer.h:
+        * platform/graphics/gstreamer/MediaPlayerPrivateGStreamer.cpp:
+        (WebCore::MediaPlayerPrivateGStreamer::load):
+        (WebCore::MediaPlayerPrivateGStreamer::enableTrack):
+        (WebCore::MediaPlayerPrivateGStreamer::handleMessage):
+        (WebCore::MediaPlayerPrivateGStreamer::createGSTPlayBin):
+        * platform/graphics/gstreamer/MediaPlayerPrivateGStreamer.h:
+        * platform/graphics/gstreamer/MediaPlayerPrivateGStreamerBase.h:
+        * platform/graphics/gstreamer/TrackPrivateBaseGStreamer.cpp:
+        (WebCore::TrackPrivateBaseGStreamer::disconnect):
+        (WebCore::TrackPrivateBaseGStreamer::tagsChanged):
+        * platform/graphics/gstreamer/TrackPrivateBaseGStreamer.h:
+        * platform/graphics/gstreamer/VideoTrackPrivateGStreamer.cpp:
+        * platform/graphics/gstreamer/VideoTrackPrivateGStreamer.h:
+
 2018-04-10  Alex Christensen  <achristensen@webkit.org>
 
         IDN spoofing with Hebrew combining characters
index a5a0d68..2e54b3b 100644 (file)
@@ -43,7 +43,7 @@ AudioTrackPrivateGStreamer::AudioTrackPrivateGStreamer(WeakPtr<MediaPlayerPrivat
     notifyTrackOfActiveChanged();
 }
 
-#if USE(GSTREAMER_PLAYBIN3)
+#if GST_CHECK_VERSION(1, 10, 0)
 AudioTrackPrivateGStreamer::AudioTrackPrivateGStreamer(WeakPtr<MediaPlayerPrivateGStreamer> player, gint index, GRefPtr<GstStream> stream)
     : TrackPrivateBaseGStreamer(this, index, stream)
     , m_player(player)
index 3fdd6e6..34e1990 100644 (file)
@@ -43,7 +43,7 @@ public:
         return adoptRef(*new AudioTrackPrivateGStreamer(player, index, pad));
     }
 
-#if USE(GSTREAMER_PLAYBIN3)
+#if GST_CHECK_VERSION(1, 10, 0)
     static RefPtr<AudioTrackPrivateGStreamer> create(WeakPtr<MediaPlayerPrivateGStreamer> player, gint index, GRefPtr<GstStream> stream)
     {
         return adoptRef(*new AudioTrackPrivateGStreamer(player, index, stream));
@@ -64,7 +64,7 @@ public:
 
 private:
     AudioTrackPrivateGStreamer(WeakPtr<MediaPlayerPrivateGStreamer>, gint index, GRefPtr<GstPad>);
-#if USE(GSTREAMER_PLAYBIN3)
+#if GST_CHECK_VERSION(1, 10, 0)
     AudioTrackPrivateGStreamer(WeakPtr<MediaPlayerPrivateGStreamer>, gint index, GRefPtr<GstStream>);
 #endif
 
index eeaed8f..f1cbad7 100644 (file)
@@ -353,7 +353,7 @@ template <> void derefGPtr<GstQuery>(GstQuery* ptr)
         gst_query_unref(ptr);
 }
 
-#if USE(GSTREAMER_PLAYBIN3)
+#if GST_CHECK_VERSION(1, 10, 0)
 template <> GRefPtr<GstStream> adoptGRef(GstStream* ptr)
 {
     ASSERT(!ptr || !g_object_is_floating(ptr));
index 83bfdec..b2dee47 100644 (file)
 
 #if USE(GSTREAMER)
 
+#include <gst/gst.h>
 #include <wtf/glib/GRefPtr.h>
 
-typedef struct _GstElement GstElement;
-typedef struct _GstPad GstPad;
-typedef struct _GstPadTemplate GstPadTemplate;
-typedef struct _GstCaps GstCaps;
-typedef struct _GstContext GstContext;
-typedef struct _GstTask GstTask;
-typedef struct _GstBus GstBus;
-typedef struct _GstElementFactory GstElementFactory;
-typedef struct _GstBuffer GstBuffer;
-typedef struct _GstBufferList GstBufferList;
-typedef struct _GstBufferPool GstBufferPool;
-typedef struct _GstSample GstSample;
-typedef struct _GstTagList GstTagList;
-typedef struct _GstEvent GstEvent;
-typedef struct _GstToc GstToc;
-typedef struct _GstMessage GstMessage;
-typedef struct _GstQuery GstQuery;
 typedef struct _WebKitVideoSink WebKitVideoSink;
 typedef struct _WebKitWebSrc WebKitWebSrc;
 
-#if USE(GSTREAMER_PLAYBIN3)
-typedef struct _GstStream GstStream;
-typedef struct _GstStreamCollection GstStreamCollection;
-#endif
-
 #if USE(GSTREAMER_GL)
 typedef struct _GstGLDisplay GstGLDisplay;
 typedef struct _GstGLContext GstGLContext;
@@ -132,7 +111,7 @@ GRefPtr<WebKitWebSrc> ensureGRef(WebKitWebSrc* ptr);
 template<> WebKitWebSrc* refGPtr<WebKitWebSrc>(WebKitWebSrc* ptr);
 template<> void derefGPtr<WebKitWebSrc>(WebKitWebSrc* ptr);
 
-#if USE(GSTREAMER_PLAYBIN3)
+#if GST_CHECK_VERSION(1, 10, 0)
 template<> GRefPtr<GstStream> adoptGRef(GstStream*);
 template<> GstStream* refGPtr<GstStream>(GstStream*);
 template<> void derefGPtr<GstStream>(GstStream*);
index 34ce830..ad28452 100644 (file)
@@ -58,7 +58,7 @@ InbandTextTrackPrivateGStreamer::InbandTextTrackPrivateGStreamer(gint index, GRe
     notifyTrackOfStreamChanged();
 }
 
-#if USE(GSTREAMER_PLAYBIN3)
+#if GST_CHECK_VERSION(1, 10, 0)
 InbandTextTrackPrivateGStreamer::InbandTextTrackPrivateGStreamer(gint index, GRefPtr<GstStream> stream)
     : InbandTextTrackPrivate(WebVTT)
     , TrackPrivateBaseGStreamer(this, index, stream)
index 324a270..af7aa63 100644 (file)
@@ -44,7 +44,7 @@ public:
         return adoptRef(*new InbandTextTrackPrivateGStreamer(index, pad));
     }
 
-#if USE(GSTREAMER_PLAYBIN3)
+#if GST_CHECK_VERSION(1, 10, 0)
     static Ref<InbandTextTrackPrivateGStreamer> create(gint index, GRefPtr<GstStream> stream)
     {
         return adoptRef(*new InbandTextTrackPrivateGStreamer(index, stream));
@@ -63,7 +63,7 @@ public:
 
 private:
     InbandTextTrackPrivateGStreamer(gint index, GRefPtr<GstPad>);
-#if USE(GSTREAMER_PLAYBIN3)
+#if GST_CHECK_VERSION(1, 10, 0)
     InbandTextTrackPrivateGStreamer(gint index, GRefPtr<GstStream>);
 #endif
 
index 1acb28b..3415543 100644 (file)
@@ -252,7 +252,7 @@ void MediaPlayerPrivateGStreamer::load(const String& urlString)
         return;
 
     if (!m_pipeline)
-        createGSTPlayBin();
+        createGSTPlayBin(isMediaSource() ? "playbin" : nullptr);
 
     if (m_fillTimer.isActive())
         m_fillTimer.stop();
@@ -621,7 +621,7 @@ bool MediaPlayerPrivateGStreamer::seeking() const
     return m_seeking;
 }
 
-#if USE(GSTREAMER_PLAYBIN3)
+#if GST_CHECK_VERSION(1, 10, 0)
 void MediaPlayerPrivateGStreamer::updateTracks()
 {
     ASSERT(!m_isLegacyPlaybin);
@@ -755,7 +755,7 @@ void MediaPlayerPrivateGStreamer::enableTrack(TrackPrivateBaseGStreamer::TrackTy
         GstElement* element = isMediaSource() ? m_source.get() : m_pipeline.get();
         g_object_set(element, propertyName, index, nullptr);
     }
-#if USE(GSTREAMER_PLAYBIN3)
+#if GST_CHECK_VERSION(1, 10, 0)
     else {
         GstStream* stream = gst_stream_collection_get_stream(m_streamCollection.get(), index);
         if (stream) {
@@ -1280,7 +1280,7 @@ void MediaPlayerPrivateGStreamer::handleMessage(GstMessage* message)
         gst_tag_list_unref(tags);
         break;
     }
-#if USE(GSTREAMER_PLAYBIN3)
+#if GST_CHECK_VERSION(1, 10, 0)
     case GST_MESSAGE_STREAM_COLLECTION: {
         GRefPtr<GstStreamCollection> collection;
         gst_message_parse_stream_collection(message, &collection.outPtr());
@@ -2399,19 +2399,39 @@ AudioSourceProvider* MediaPlayerPrivateGStreamer::audioSourceProvider()
 }
 #endif
 
-void MediaPlayerPrivateGStreamer::createGSTPlayBin()
+void MediaPlayerPrivateGStreamer::createGSTPlayBin(const gchar* playbinName)
 {
+    if (m_pipeline) {
+        if (!playbinName) {
+            GST_INFO_OBJECT(pipeline(), "Keeping same playbin as nothing forced");
+            return;
+        }
+
+        if (!g_strcmp0(GST_OBJECT_NAME(gst_element_get_factory(m_pipeline.get())), playbinName)) {
+            GST_INFO_OBJECT(pipeline(), "Already using %s", playbinName);
+            return;
+        }
+
+        GST_INFO_OBJECT(pipeline(), "Tearing down as we need to use %s now.",
+            playbinName);
+        changePipelineState(GST_STATE_NULL);
+        m_pipeline = nullptr;
+    }
+
     ASSERT(!m_pipeline);
 
+#if GST_CHECK_VERSION(1, 10, 0)
+    m_isLegacyPlaybin = !g_getenv("USE_PLAYBIN3");
+    if (!m_isLegacyPlaybin)
+        playbinName = "playbin3";
+#endif
+
+    if (!playbinName)
+        playbinName = "playbin";
+
     // gst_element_factory_make() returns a floating reference so
     // we should not adopt.
-#if USE(GSTREAMER_PLAYBIN3)
-    m_isLegacyPlaybin = false;
-    setPipeline(gst_element_factory_make("playbin3", "play"));
-#else
-    m_isLegacyPlaybin = true;
-    setPipeline(gst_element_factory_make("playbin", "play"));
-#endif
+    setPipeline(gst_element_factory_make(playbinName, "play"));
     setStreamVolumeElement(GST_STREAM_VOLUME(m_pipeline.get()));
 
     GST_INFO("Using legacy playbin element: %s", boolForPrinting(m_isLegacyPlaybin));
index 3687048..b79d43c 100644 (file)
@@ -146,7 +146,7 @@ private:
     virtual void updateStates();
     virtual void asyncStateChangeDone();
 
-    void createGSTPlayBin();
+    void createGSTPlayBin(const gchar* playbinName);
 
     bool loadNextLocation();
     void mediaLocationChanged(GstMessage*);
@@ -178,7 +178,7 @@ private:
 
     void setPlaybinURL(const URL& urlString);
 
-#if USE(GSTREAMER_PLAYBIN3)
+#if GST_CHECK_VERSION(1, 10, 0)
     void updateTracks();
 #endif
 
@@ -257,7 +257,7 @@ private:
     URL m_url;
     bool m_preservesPitch;
     bool m_isLegacyPlaybin;
-#if USE(GSTREAMER_PLAYBIN3)
+#if GST_CHECK_VERSION(1, 10, 0)
     GRefPtr<GstStreamCollection> m_streamCollection;
 #endif
     String m_currentAudioStreamId;
index fe65e93..a799f0f 100644 (file)
@@ -211,7 +211,7 @@ protected:
         TextChanged = 1 << 5,
 #endif
         SizeChanged = 1 << 6,
-#if USE(GSTREAMER_PLAYBIN3)
+#if GST_CHECK_VERSION(1, 10, 0)
         StreamCollectionChanged = 1 << 7
 #endif
     };
index ff4eb96..5f5159f 100644 (file)
@@ -58,7 +58,7 @@ TrackPrivateBaseGStreamer::TrackPrivateBaseGStreamer(TrackPrivateBase* owner, gi
     tagsChanged();
 }
 
-#if USE(GSTREAMER_PLAYBIN3)
+#if GST_CHECK_VERSION(1, 10, 0)
 TrackPrivateBaseGStreamer::TrackPrivateBaseGStreamer(TrackPrivateBase* owner, gint index, GRefPtr<GstStream> stream)
     : m_notifier(MainThreadNotifier<MainThreadNotification>::create())
     , m_index(index)
@@ -82,7 +82,7 @@ void TrackPrivateBaseGStreamer::disconnect()
 {
     m_tags.clear();
 
-#if USE(GSTREAMER_PLAYBIN3)
+#if GST_CHECK_VERSION(1, 10, 0)
     if (m_stream)
         m_stream.clear();
 #endif
@@ -115,7 +115,7 @@ void TrackPrivateBaseGStreamer::tagsChanged()
         else
             tags = adoptGRef(gst_tag_list_new_empty());
     }
-#if USE(GSTREAMER_PLAYBIN3)
+#if GST_CHECK_VERSION(1, 10, 0)
     else if (m_stream)
         tags = adoptGRef(gst_stream_get_tags(m_stream.get()));
 #endif
index d548472..f1215c1 100644 (file)
@@ -58,7 +58,7 @@ public:
 
 protected:
     TrackPrivateBaseGStreamer(TrackPrivateBase* owner, gint index, GRefPtr<GstPad>);
-#if USE(GSTREAMER_PLAYBIN3)
+#if GST_CHECK_VERSION(1, 10, 0)
     TrackPrivateBaseGStreamer(TrackPrivateBase* owner, gint index, GRefPtr<GstStream>);
 #endif
     void notifyTrackOfActiveChanged();
@@ -76,7 +76,7 @@ protected:
     AtomicString m_label;
     AtomicString m_language;
     GRefPtr<GstPad> m_pad;
-#if USE(GSTREAMER_PLAYBIN3)
+#if GST_CHECK_VERSION(1, 10, 0)
     GRefPtr<GstStream> m_stream;
 #endif
 
index 71a1490..741524e 100644 (file)
@@ -43,7 +43,7 @@ VideoTrackPrivateGStreamer::VideoTrackPrivateGStreamer(WeakPtr<MediaPlayerPrivat
     notifyTrackOfActiveChanged();
 }
 
-#if USE(GSTREAMER_PLAYBIN3)
+#if GST_CHECK_VERSION(1, 10, 0)
 VideoTrackPrivateGStreamer::VideoTrackPrivateGStreamer(WeakPtr<MediaPlayerPrivateGStreamer> player, gint index, GRefPtr<GstStream> stream)
     : TrackPrivateBaseGStreamer(this, index, stream)
     , m_player(player)
index bb19d31..274e569 100644 (file)
@@ -43,7 +43,7 @@ public:
     {
         return adoptRef(*new VideoTrackPrivateGStreamer(player, index, pad));
     }
-#if USE(GSTREAMER_PLAYBIN3)
+#if GST_CHECK_VERSION(1, 10, 0)
     static Ref<VideoTrackPrivateGStreamer> create(WeakPtr<MediaPlayerPrivateGStreamer> player, gint index, GRefPtr<GstStream> stream)
     {
         return adoptRef(*new VideoTrackPrivateGStreamer(player, index, stream));
@@ -64,7 +64,7 @@ public:
 
 private:
     VideoTrackPrivateGStreamer(WeakPtr<MediaPlayerPrivateGStreamer>, gint index, GRefPtr<GstPad>);
-#if USE(GSTREAMER_PLAYBIN3)
+#if GST_CHECK_VERSION(1, 10, 0)
     VideoTrackPrivateGStreamer(WeakPtr<MediaPlayerPrivateGStreamer>, gint index, GRefPtr<GstStream>);
 #endif
     AtomicString m_id;
index 62a69d8..03938c8 100644 (file)
@@ -5,4 +5,3 @@ WEBKIT_OPTION_DEFAULT_PORT_VALUE(ENABLE_MEDIA_SOURCE PRIVATE ON)
 
 WEBKIT_OPTION_DEFINE(USE_GSTREAMER_GL "Whether to enable support for GStreamer GL" PRIVATE ON)
 WEBKIT_OPTION_DEFINE(USE_GSTREAMER_MPEGTS "Whether to enable support for MPEG-TS" PRIVATE OFF)
-WEBKIT_OPTION_DEFINE(USE_GSTREAMER_PLAYBIN3 "Whether to enable support for GStreamer's playbin3 element" PRIVATE OFF)