Diff
Modified: trunk/Source/WebCore/ChangeLog (237793 => 237794)
--- trunk/Source/WebCore/ChangeLog 2018-11-05 09:34:01 UTC (rev 237793)
+++ trunk/Source/WebCore/ChangeLog 2018-11-05 10:00:19 UTC (rev 237794)
@@ -1,3 +1,30 @@
+2018-11-05 Philippe Normand <[email protected]>
+
+ [GStreamer] Move elements registration to GStreamerCommon
+ https://bugs.webkit.org/show_bug.cgi?id=191189
+
+ Reviewed by Xabier Rodriguez-Calvar.
+
+ It was a bit odd to have this in the base player class and to have
+ sub-classes calling a static function of the super-class.
+
+ Covered by existing tests.
+
+ * platform/graphics/gstreamer/GStreamerCommon.cpp:
+ (WebCore::initializeGStreamerAndRegisterWebKitElements):
+ * platform/graphics/gstreamer/GStreamerCommon.h:
+ * platform/graphics/gstreamer/MediaPlayerPrivateGStreamer.cpp:
+ (WebCore::MediaPlayerPrivateGStreamer::isAvailable):
+ (WebCore::MediaPlayerPrivateGStreamer::loadFull):
+ (WebCore::MediaPlayerPrivateGStreamer::getSupportedTypes):
+ * platform/graphics/gstreamer/MediaPlayerPrivateGStreamerBase.cpp:
+ * platform/graphics/gstreamer/MediaPlayerPrivateGStreamerBase.h:
+ * platform/graphics/gstreamer/mse/MediaPlayerPrivateGStreamerMSE.cpp:
+ (WebCore::MediaPlayerPrivateGStreamerMSE::registerMediaEngine):
+ (WebCore::MediaPlayerPrivateGStreamerMSE::load):
+ (WebCore::MediaPlayerPrivateGStreamerMSE::trackDetected):
+ (WebCore::MediaPlayerPrivateGStreamerMSE::supportsType):
+
2018-11-04 Rob Buis <[email protected]>
Remove ENABLE_OPENCL fully
Modified: trunk/Source/WebCore/platform/graphics/gstreamer/GStreamerCommon.cpp (237793 => 237794)
--- trunk/Source/WebCore/platform/graphics/gstreamer/GStreamerCommon.cpp 2018-11-05 09:34:01 UTC (rev 237793)
+++ trunk/Source/WebCore/platform/graphics/gstreamer/GStreamerCommon.cpp 2018-11-05 10:00:19 UTC (rev 237794)
@@ -38,6 +38,22 @@
#undef GST_USE_UNSTABLE_API
#endif
+#if ENABLE(MEDIA_SOURCE)
+#include "WebKitMediaSourceGStreamer.h"
+#endif
+
+#if ENABLE(MEDIA_STREAM) && GST_CHECK_VERSION(1, 10, 0)
+#include "GStreamerMediaStreamSource.h"
+#endif
+
+#if ENABLE(ENCRYPTED_MEDIA)
+#include "WebKitClearKeyDecryptorGStreamer.h"
+#endif
+
+#if ENABLE(VIDEO)
+#include "WebKitWebSourceGStreamer.h"
+#endif
+
namespace WebCore {
GstPad* webkitGstGhostPadFromStaticTemplate(GstStaticPadTemplate* staticPadTemplate, const gchar* name, GstPad* target)
@@ -234,6 +250,34 @@
return isGStreamerInitialized;
}
+bool initializeGStreamerAndRegisterWebKitElements()
+{
+ if (!initializeGStreamer())
+ return false;
+
+ static std::once_flag onceFlag;
+ std::call_once(onceFlag, [] {
+#if ENABLE(ENCRYPTED_MEDIA)
+ if (webkitGstCheckVersion(1, 6, 1))
+ gst_element_register(nullptr, "webkitclearkey", GST_RANK_PRIMARY + 100, WEBKIT_TYPE_MEDIA_CK_DECRYPT);
+#endif
+
+#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_SOURCE)
+ gst_element_register(nullptr, "webkitmediasrc", GST_RANK_PRIMARY + 100, WEBKIT_TYPE_MEDIA_SRC);
+#endif
+
+#if ENABLE(VIDEO)
+ gst_element_register(0, "webkitwebsrc", GST_RANK_PRIMARY + 100, WEBKIT_TYPE_WEB_SRC);
+#endif
+ });
+ return true;
+}
+
unsigned getGstPlayFlag(const char* nick)
{
static GFlagsClass* flagsClass = static_cast<GFlagsClass*>(g_type_class_ref(g_type_from_name("GstPlayFlags")));
Modified: trunk/Source/WebCore/platform/graphics/gstreamer/GStreamerCommon.h (237793 => 237794)
--- trunk/Source/WebCore/platform/graphics/gstreamer/GStreamerCommon.h 2018-11-05 09:34:01 UTC (rev 237793)
+++ trunk/Source/WebCore/platform/graphics/gstreamer/GStreamerCommon.h 2018-11-05 10:00:19 UTC (rev 237794)
@@ -68,6 +68,7 @@
bool areEncryptedCaps(const GstCaps*);
Vector<String> extractGStreamerOptionsFromCommandLine();
bool initializeGStreamer(std::optional<Vector<String>>&& = std::nullopt);
+bool initializeGStreamerAndRegisterWebKitElements();
unsigned getGstPlayFlag(const char* nick);
uint64_t toGstUnsigned64Time(const MediaTime&);
Modified: trunk/Source/WebCore/platform/graphics/gstreamer/MediaPlayerPrivateGStreamer.cpp (237793 => 237794)
--- trunk/Source/WebCore/platform/graphics/gstreamer/MediaPlayerPrivateGStreamer.cpp 2018-11-05 09:34:01 UTC (rev 237793)
+++ trunk/Source/WebCore/platform/graphics/gstreamer/MediaPlayerPrivateGStreamer.cpp 2018-11-05 10:00:19 UTC (rev 237794)
@@ -113,6 +113,7 @@
void MediaPlayerPrivateGStreamer::registerMediaEngine(MediaEngineRegistrar registrar)
{
+ MediaPlayerPrivateGStreamerBase::initializeDebugCategory();
if (isAvailable()) {
registrar([](MediaPlayer* player) { return std::make_unique<MediaPlayerPrivateGStreamer>(player); },
getSupportedTypes, supportsType, nullptr, nullptr, nullptr, supportsKeySystem);
@@ -121,7 +122,7 @@
bool MediaPlayerPrivateGStreamer::isAvailable()
{
- if (!MediaPlayerPrivateGStreamerBase::initializeGStreamerAndRegisterWebKitElements())
+ if (!initializeGStreamerAndRegisterWebKitElements())
return false;
GRefPtr<GstElementFactory> factory = adoptGRef(gst_element_factory_find("playbin"));
@@ -258,9 +259,6 @@
return;
}
- if (!MediaPlayerPrivateGStreamerBase::initializeGStreamerAndRegisterWebKitElements())
- return;
-
URL url(URL(), urlString);
if (url.protocolIsAbout())
return;
@@ -2214,7 +2212,7 @@
{
static NeverDestroyed<HashSet<String, ASCIICaseInsensitiveHash>> mimeTypes = []()
{
- MediaPlayerPrivateGStreamerBase::initializeGStreamerAndRegisterWebKitElements();
+ initializeGStreamerAndRegisterWebKitElements();
HashSet<String, ASCIICaseInsensitiveHash> set;
GList* audioDecoderFactories = gst_element_factory_list_get_elements(GST_ELEMENT_FACTORY_TYPE_DECODER | GST_ELEMENT_FACTORY_TYPE_MEDIA_AUDIO, GST_RANK_MARGINAL);
Modified: trunk/Source/WebCore/platform/graphics/gstreamer/MediaPlayerPrivateGStreamerBase.cpp (237793 => 237794)
--- trunk/Source/WebCore/platform/graphics/gstreamer/MediaPlayerPrivateGStreamerBase.cpp 2018-11-05 09:34:01 UTC (rev 237793)
+++ trunk/Source/WebCore/platform/graphics/gstreamer/MediaPlayerPrivateGStreamerBase.cpp 2018-11-05 10:00:19 UTC (rev 237794)
@@ -37,7 +37,6 @@
#include "MediaPlayer.h"
#include "NotImplemented.h"
#include "VideoSinkGStreamer.h"
-#include "WebKitWebSourceGStreamer.h"
#include <wtf/glib/GUniquePtr.h>
#include <wtf/text/AtomicString.h>
#include <wtf/text/CString.h>
@@ -51,17 +50,8 @@
#include "CDMInstance.h"
#include "GStreamerEMEUtilities.h"
#include "SharedBuffer.h"
-#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
-
#if USE(GSTREAMER_GL)
#if G_BYTE_ORDER == G_LITTLE_ENDIAN
#define GST_GL_CAPS_FORMAT "{ BGRx, BGRA }"
@@ -142,33 +132,6 @@
namespace WebCore {
using namespace std;
-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))
- gst_element_register(nullptr, "webkitclearkey", GST_RANK_PRIMARY + 100, WEBKIT_TYPE_MEDIA_CK_DECRYPT);
-#endif
-
-#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_SOURCE)
- gst_element_register(nullptr, "webkitmediasrc", GST_RANK_PRIMARY + 100, WEBKIT_TYPE_MEDIA_SRC);
-#endif
-
- gst_element_register(0, "webkitwebsrc", GST_RANK_PRIMARY + 100, WEBKIT_TYPE_WEB_SRC);
- });
- return true;
-}
-
static int greatestCommonDivisor(int a, int b)
{
while (b) {
@@ -277,6 +240,11 @@
};
#endif
+void MediaPlayerPrivateGStreamerBase::initializeDebugCategory()
+{
+ GST_DEBUG_CATEGORY_INIT(webkit_media_player_debug, "webkitmediaplayer", 0, "WebKit media player");
+}
+
MediaPlayerPrivateGStreamerBase::MediaPlayerPrivateGStreamerBase(MediaPlayer* player)
: m_notifier(MainThreadNotifier<MainThreadNotification>::create())
, m_player(player)
Modified: trunk/Source/WebCore/platform/graphics/gstreamer/MediaPlayerPrivateGStreamerBase.h (237793 => 237794)
--- trunk/Source/WebCore/platform/graphics/gstreamer/MediaPlayerPrivateGStreamerBase.h 2018-11-05 09:34:01 UTC (rev 237793)
+++ trunk/Source/WebCore/platform/graphics/gstreamer/MediaPlayerPrivateGStreamerBase.h 2018-11-05 10:00:19 UTC (rev 237794)
@@ -76,6 +76,8 @@
{
public:
+ static void initializeDebugCategory();
+
virtual ~MediaPlayerPrivateGStreamerBase();
FloatSize naturalSize() const override;
@@ -87,7 +89,6 @@
bool ensureGstGLContext();
GstContext* requestGLContext(const char* contextType);
#endif
- static bool initializeGStreamerAndRegisterWebKitElements();
bool supportsMuting() const override { return true; }
void setMuted(bool) override;
bool muted() const;
Modified: trunk/Source/WebCore/platform/graphics/gstreamer/mse/MediaPlayerPrivateGStreamerMSE.cpp (237793 => 237794)
--- trunk/Source/WebCore/platform/graphics/gstreamer/mse/MediaPlayerPrivateGStreamerMSE.cpp 2018-11-05 09:34:01 UTC (rev 237793)
+++ trunk/Source/WebCore/platform/graphics/gstreamer/mse/MediaPlayerPrivateGStreamerMSE.cpp 2018-11-05 10:00:19 UTC (rev 237794)
@@ -79,6 +79,7 @@
void MediaPlayerPrivateGStreamerMSE::registerMediaEngine(MediaEngineRegistrar registrar)
{
+ initializeGStreamerAndRegisterWebKitElements();
GST_DEBUG_CATEGORY_INIT(webkit_mse_debug, "webkitmse", 0, "WebKit MSE media player");
if (isAvailable()) {
registrar([](MediaPlayer* player) { return std::make_unique<MediaPlayerPrivateGStreamerMSE>(player); },
@@ -117,10 +118,6 @@
return;
}
-
- if (UNLIKELY(!MediaPlayerPrivateGStreamerBase::initializeGStreamerAndRegisterWebKitElements()))
- return;
-
if (!m_playbackPipeline)
m_playbackPipeline = PlaybackPipeline::create();
@@ -689,7 +686,7 @@
{
static NeverDestroyed<HashSet<String, ASCIICaseInsensitiveHash>> cache = []()
{
- MediaPlayerPrivateGStreamerBase::initializeGStreamerAndRegisterWebKitElements();
+ initializeGStreamerAndRegisterWebKitElements();
HashSet<String, ASCIICaseInsensitiveHash> set;
const char* mimeTypes[] = {
"video/mp4",
@@ -733,7 +730,7 @@
{
static NeverDestroyed<HashSet<AtomicString>> codecTypes = []()
{
- MediaPlayerPrivateGStreamerBase::initializeGStreamerAndRegisterWebKitElements();
+ initializeGStreamerAndRegisterWebKitElements();
HashSet<AtomicString> set;
GList* audioDecoderFactories = gst_element_factory_list_get_elements(GST_ELEMENT_FACTORY_TYPE_DECODER | GST_ELEMENT_FACTORY_TYPE_MEDIA_AUDIO, GST_RANK_MARGINAL);