Title: [235598] trunk/Source/WebCore
Revision
235598
Author
[email protected]
Date
2018-09-03 04:17:07 -0700 (Mon, 03 Sep 2018)

Log Message

[GStreamer] elements registration clean-ups
https://bugs.webkit.org/show_bug.cgi?id=189192

Reviewed by Xabier Rodriguez-Calvar.

Register all our elements from the base player class. This
simplifies the MSE player by removing duplicated code.

* platform/graphics/gstreamer/MediaPlayerPrivateGStreamer.h:
* platform/graphics/gstreamer/MediaPlayerPrivateGStreamerBase.cpp:
(WebCore::MediaPlayerPrivateGStreamerBase::initializeGStreamerAndRegisterWebKitElements):
(WebCore::registerWebKitGStreamerElements): Deleted.
* platform/graphics/gstreamer/mse/MediaPlayerPrivateGStreamerMSE.cpp:
(WebCore::MediaPlayerPrivateGStreamerMSE::registerMediaEngine):
(WebCore::MediaPlayerPrivateGStreamerMSE::load):
(WebCore::mimeTypeCache):
(WebCore::initializeGStreamerAndRegisterWebKitMSEElement): Deleted.
(WebCore::MediaPlayerPrivateGStreamerMSE::isAvailable): Deleted.
* platform/graphics/gstreamer/mse/MediaPlayerPrivateGStreamerMSE.h:

Modified Paths

Diff

Modified: trunk/Source/WebCore/ChangeLog (235597 => 235598)


--- trunk/Source/WebCore/ChangeLog	2018-09-03 09:06:40 UTC (rev 235597)
+++ trunk/Source/WebCore/ChangeLog	2018-09-03 11:17:07 UTC (rev 235598)
@@ -1,3 +1,25 @@
+2018-09-03  Philippe Normand  <[email protected]>
+
+        [GStreamer] elements registration clean-ups
+        https://bugs.webkit.org/show_bug.cgi?id=189192
+
+        Reviewed by Xabier Rodriguez-Calvar.
+
+        Register all our elements from the base player class. This
+        simplifies the MSE player by removing duplicated code.
+
+        * platform/graphics/gstreamer/MediaPlayerPrivateGStreamer.h:
+        * platform/graphics/gstreamer/MediaPlayerPrivateGStreamerBase.cpp:
+        (WebCore::MediaPlayerPrivateGStreamerBase::initializeGStreamerAndRegisterWebKitElements):
+        (WebCore::registerWebKitGStreamerElements): Deleted.
+        * platform/graphics/gstreamer/mse/MediaPlayerPrivateGStreamerMSE.cpp:
+        (WebCore::MediaPlayerPrivateGStreamerMSE::registerMediaEngine):
+        (WebCore::MediaPlayerPrivateGStreamerMSE::load):
+        (WebCore::mimeTypeCache):
+        (WebCore::initializeGStreamerAndRegisterWebKitMSEElement): Deleted.
+        (WebCore::MediaPlayerPrivateGStreamerMSE::isAvailable): Deleted.
+        * platform/graphics/gstreamer/mse/MediaPlayerPrivateGStreamerMSE.h:
+
 2018-09-02  Zalan Bujtas  <[email protected]>
 
         REGRESSION (r191336): RenderFlexibleBox::adjustChildSizeForMinAndMax crashes in std::optional<>::value()

Modified: trunk/Source/WebCore/platform/graphics/gstreamer/MediaPlayerPrivateGStreamer.h (235597 => 235598)


--- trunk/Source/WebCore/platform/graphics/gstreamer/MediaPlayerPrivateGStreamer.h	2018-09-03 09:06:40 UTC (rev 235597)
+++ trunk/Source/WebCore/platform/graphics/gstreamer/MediaPlayerPrivateGStreamer.h	2018-09-03 11:17:07 UTC (rev 235598)
@@ -66,6 +66,8 @@
     virtual ~MediaPlayerPrivateGStreamer();
 
     static void registerMediaEngine(MediaEngineRegistrar);
+    static bool isAvailable();
+
     void handleMessage(GstMessage*);
     void handlePluginInstallerResult(GstInstallPluginsReturn);
 
@@ -137,7 +139,6 @@
     static void getSupportedTypes(HashSet<String, ASCIICaseInsensitiveHash>&);
     static MediaPlayer::SupportsType supportsType(const MediaEngineSupportParameters&);
 
-    static bool isAvailable();
 
     GstElement* createAudioSink() override;
 

Modified: trunk/Source/WebCore/platform/graphics/gstreamer/MediaPlayerPrivateGStreamerBase.cpp (235597 => 235598)


--- trunk/Source/WebCore/platform/graphics/gstreamer/MediaPlayerPrivateGStreamerBase.cpp	2018-09-03 09:06:40 UTC (rev 235597)
+++ trunk/Source/WebCore/platform/graphics/gstreamer/MediaPlayerPrivateGStreamerBase.cpp	2018-09-03 11:17:07 UTC (rev 235598)
@@ -54,6 +54,10 @@
 #include "WebKitClearKeyDecryptorGStreamer.h"
 #endif
 
+#if ENABLE(MEDIA_SOURCE)
+#include "WebKitMediaSourceGStreamer.h"
+#endif
+
 #if ENABLE(MEDIA_STREAM) && GST_CHECK_VERSION(1, 10, 0)
 #include "GStreamerMediaStreamSource.h"
 #endif
@@ -138,34 +142,30 @@
 namespace WebCore {
 using namespace std;
 
-void registerWebKitGStreamerElements()
+bool MediaPlayerPrivateGStreamerBase::initializeGStreamerAndRegisterWebKitElements()
 {
+    if (!initializeGStreamer())
+        return false;
+
+    static std::once_flag onceFlag;
+    std::call_once(onceFlag, [] {
+        GST_DEBUG_CATEGORY_INIT(webkit_media_player_debug, "webkitmediaplayer", 0, "WebKit media player");
 #if ENABLE(ENCRYPTED_MEDIA)
-    if (!webkitGstCheckVersion(1, 6, 1))
-        return;
+        if (webkitGstCheckVersion(1, 6, 1))
+            gst_element_register(nullptr, "webkitclearkey", GST_RANK_PRIMARY + 100, WEBKIT_TYPE_MEDIA_CK_DECRYPT);
+#endif
 
-    GRefPtr<GstElementFactory> clearKeyDecryptorFactory = adoptGRef(gst_element_factory_find("webkitclearkey"));
-    if (!clearKeyDecryptorFactory)
-        gst_element_register(nullptr, "webkitclearkey", GST_RANK_PRIMARY + 100, WEBKIT_TYPE_MEDIA_CK_DECRYPT);
+#if ENABLE(MEDIA_STREAM) && GST_CHECK_VERSION(1, 10, 0)
+        if (webkitGstCheckVersion(1, 10, 0))
+            gst_element_register(nullptr, "mediastreamsrc", GST_RANK_PRIMARY, WEBKIT_TYPE_MEDIA_STREAM_SRC);
 #endif
-#if ENABLE(MEDIA_STREAM) && GST_CHECK_VERSION(1,10,0)
-    gst_element_register(nullptr, "mediastreamsrc", GST_RANK_PRIMARY, WEBKIT_TYPE_MEDIA_STREAM_SRC);
+
+#if ENABLE(MEDIA_SOURCE)
+        gst_element_register(nullptr, "webkitmediasrc", GST_RANK_PRIMARY + 100, WEBKIT_TYPE_MEDIA_SRC);
 #endif
-}
 
-bool MediaPlayerPrivateGStreamerBase::initializeGStreamerAndRegisterWebKitElements()
-{
-    if (!initializeGStreamer())
-        return false;
-
-    registerWebKitGStreamerElements();
-
-    GRefPtr<GstElementFactory> srcFactory = adoptGRef(gst_element_factory_find("webkitwebsrc"));
-    if (!srcFactory) {
-        GST_DEBUG_CATEGORY_INIT(webkit_media_player_debug, "webkitmediaplayer", 0, "WebKit media player");
         gst_element_register(0, "webkitwebsrc", GST_RANK_PRIMARY + 100, WEBKIT_TYPE_WEB_SRC);
-    }
-
+    });
     return true;
 }
 

Modified: trunk/Source/WebCore/platform/graphics/gstreamer/mse/MediaPlayerPrivateGStreamerMSE.cpp (235597 => 235598)


--- trunk/Source/WebCore/platform/graphics/gstreamer/mse/MediaPlayerPrivateGStreamerMSE.cpp	2018-09-03 09:06:40 UTC (rev 235597)
+++ trunk/Source/WebCore/platform/graphics/gstreamer/mse/MediaPlayerPrivateGStreamerMSE.cpp	2018-09-03 11:17:07 UTC (rev 235598)
@@ -79,6 +79,7 @@
 
 void MediaPlayerPrivateGStreamerMSE::registerMediaEngine(MediaEngineRegistrar registrar)
 {
+    GST_DEBUG_CATEGORY_INIT(webkit_mse_debug, "webkitmse", 0, "WebKit MSE media player");
     if (isAvailable()) {
         registrar([](MediaPlayer* player) { return std::make_unique<MediaPlayerPrivateGStreamerMSE>(player); },
             getSupportedTypes, supportsType, nullptr, nullptr, nullptr, supportsKeySystem);
@@ -85,27 +86,6 @@
     }
 }
 
-bool initializeGStreamerAndRegisterWebKitMSEElement()
-{
-    registerWebKitGStreamerElements();
-
-    GST_DEBUG_CATEGORY_INIT(webkit_mse_debug, "webkitmse", 0, "WebKit MSE media player");
-
-    GRefPtr<GstElementFactory> WebKitMediaSrcFactory = adoptGRef(gst_element_factory_find("webkitmediasrc"));
-    if (UNLIKELY(!WebKitMediaSrcFactory))
-        gst_element_register(nullptr, "webkitmediasrc", GST_RANK_PRIMARY + 100, WEBKIT_TYPE_MEDIA_SRC);
-    return true;
-}
-
-bool MediaPlayerPrivateGStreamerMSE::isAvailable()
-{
-    if (UNLIKELY(!initializeGStreamerAndRegisterWebKitMSEElement()))
-        return false;
-
-    GRefPtr<GstElementFactory> factory = adoptGRef(gst_element_factory_find("playbin"));
-    return factory;
-}
-
 MediaPlayerPrivateGStreamerMSE::MediaPlayerPrivateGStreamerMSE(MediaPlayer* player)
     : MediaPlayerPrivateGStreamer(player)
 {
@@ -137,7 +117,8 @@
         return;
     }
 
-    if (UNLIKELY(!initializeGStreamerAndRegisterWebKitMSEElement()))
+
+    if (UNLIKELY(!MediaPlayerPrivateGStreamerBase::initializeGStreamerAndRegisterWebKitElements()))
         return;
 
     if (!m_playbackPipeline)
@@ -708,7 +689,7 @@
 {
     static NeverDestroyed<HashSet<String, ASCIICaseInsensitiveHash>> cache = []()
     {
-        initializeGStreamerAndRegisterWebKitMSEElement();
+        MediaPlayerPrivateGStreamerBase::initializeGStreamerAndRegisterWebKitElements();
         HashSet<String, ASCIICaseInsensitiveHash> set;
         const char* mimeTypes[] = {
             "video/mp4",

Modified: trunk/Source/WebCore/platform/graphics/gstreamer/mse/MediaPlayerPrivateGStreamerMSE.h (235597 => 235598)


--- trunk/Source/WebCore/platform/graphics/gstreamer/mse/MediaPlayerPrivateGStreamerMSE.h	2018-09-03 09:06:40 UTC (rev 235597)
+++ trunk/Source/WebCore/platform/graphics/gstreamer/mse/MediaPlayerPrivateGStreamerMSE.h	2018-09-03 11:17:07 UTC (rev 235598)
@@ -93,8 +93,6 @@
     static void getSupportedTypes(HashSet<String, ASCIICaseInsensitiveHash>&);
     static MediaPlayer::SupportsType supportsType(const MediaEngineSupportParameters&);
 
-    static bool isAvailable();
-
     // FIXME: Reduce code duplication.
     void updateStates() override;
 
_______________________________________________
webkit-changes mailing list
[email protected]
https://lists.webkit.org/mailman/listinfo/webkit-changes

Reply via email to