https://bugs.webkit.org/show_bug.cgi?id=175129
Reviewed by Xabier Rodriguez-Calvar.
This is a follow-up to r219678 that moved the majority of CDM abstraction
classes into the platform layer, but missed the CDMFactory class.
The CDMFactory abstraction is now also placed in the platform layer. Only
change to the interface is that the createCDM() method can't accept a CDM
object reference anymore since that class is cemented into the WebCore
layer, and no current implementation used it anyway.
Additionally, the static Vector object of registered factories is moved
under the CDMFactory class, along with the register and unregister
functions. The platformRegisterFactories() function is added to allow for
platform-specific factory registrations to occur when the registered
factories are queried for the first time. Empty implementation for this
function is provided for non-GStreamer platforms, while for GStreamer
the implementation is kept in CDMFactoryGStreamer.cpp. It's still empty
for now, but it will register the ClearKey factory there in the near
future.
No new tests -- none affected, only refactoring.
* CMakeLists.txt:
* Modules/encryptedmedia/CDM.cpp:
(WebCore::createCDMPrivateForKeySystem):
(WebCore::CDM::supportsKeySystem):
(WebCore::CDM::CDM):
(): Deleted.
(WebCore::CDM::registerCDMFactory): Deleted.
(WebCore::CDM::unregisterCDMFactory): Deleted.
* Modules/encryptedmedia/CDM.h:
(WebCore::CDMFactory::~CDMFactory): Deleted.
* PlatformWPE.cmake:
* platform/GStreamer.cmake:
* platform/encryptedmedia/CDMFactory.cpp: Added.
(WebCore::CDMFactory::registerFactory):
(WebCore::CDMFactory::unregisterFactory):
(WebCore::CDMFactory::platformRegisterFactories):
* platform/encryptedmedia/CDMFactory.h: Added.
(WebCore::CDMFactory::~CDMFactory):
* platform/encryptedmedia/clearkey/CDMClearKey.cpp:
(WebCore::CDMFactoryClearKey::createCDM):
* platform/encryptedmedia/clearkey/CDMClearKey.h:
* platform/encryptedmedia/gstreamer/CDMFactoryGStreamer.cpp: Added.
(WebCore::CDMFactory::platformRegisterFactories):
* testing/MockCDMFactory.cpp:
(WebCore::m_weakPtrFactory):
(WebCore::MockCDMFactory::unregister):
(WebCore::MockCDMFactory::createCDM):
* testing/MockCDMFactory.h:
git-svn-id: https://svn.webkit.org/repository/webkit/trunk@220264
268f45cc-cd09-0410-ab3c-
d52691b4dbfc
platform/audio/VectorMath.cpp
platform/audio/ZeroPole.cpp
+ platform/encryptedmedia/CDMFactory.cpp
+
platform/graphics/BitmapImage.cpp
platform/graphics/Color.cpp
platform/graphics/ComplexTextController.cpp
+2017-08-04 Zan Dobersek <zdobersek@igalia.com>
+
+ [EME] Push CDMFactory into the platform layer
+ https://bugs.webkit.org/show_bug.cgi?id=175129
+
+ Reviewed by Xabier Rodriguez-Calvar.
+
+ This is a follow-up to r219678 that moved the majority of CDM abstraction
+ classes into the platform layer, but missed the CDMFactory class.
+
+ The CDMFactory abstraction is now also placed in the platform layer. Only
+ change to the interface is that the createCDM() method can't accept a CDM
+ object reference anymore since that class is cemented into the WebCore
+ layer, and no current implementation used it anyway.
+
+ Additionally, the static Vector object of registered factories is moved
+ under the CDMFactory class, along with the register and unregister
+ functions. The platformRegisterFactories() function is added to allow for
+ platform-specific factory registrations to occur when the registered
+ factories are queried for the first time. Empty implementation for this
+ function is provided for non-GStreamer platforms, while for GStreamer
+ the implementation is kept in CDMFactoryGStreamer.cpp. It's still empty
+ for now, but it will register the ClearKey factory there in the near
+ future.
+
+ No new tests -- none affected, only refactoring.
+
+ * CMakeLists.txt:
+ * Modules/encryptedmedia/CDM.cpp:
+ (WebCore::createCDMPrivateForKeySystem):
+ (WebCore::CDM::supportsKeySystem):
+ (WebCore::CDM::CDM):
+ (): Deleted.
+ (WebCore::CDM::registerCDMFactory): Deleted.
+ (WebCore::CDM::unregisterCDMFactory): Deleted.
+ * Modules/encryptedmedia/CDM.h:
+ (WebCore::CDMFactory::~CDMFactory): Deleted.
+ * PlatformWPE.cmake:
+ * platform/GStreamer.cmake:
+ * platform/encryptedmedia/CDMFactory.cpp: Added.
+ (WebCore::CDMFactory::registerFactory):
+ (WebCore::CDMFactory::unregisterFactory):
+ (WebCore::CDMFactory::platformRegisterFactories):
+ * platform/encryptedmedia/CDMFactory.h: Added.
+ (WebCore::CDMFactory::~CDMFactory):
+ * platform/encryptedmedia/clearkey/CDMClearKey.cpp:
+ (WebCore::CDMFactoryClearKey::createCDM):
+ * platform/encryptedmedia/clearkey/CDMClearKey.h:
+ * platform/encryptedmedia/gstreamer/CDMFactoryGStreamer.cpp: Added.
+ (WebCore::CDMFactory::platformRegisterFactories):
+ * testing/MockCDMFactory.cpp:
+ (WebCore::m_weakPtrFactory):
+ (WebCore::MockCDMFactory::unregister):
+ (WebCore::MockCDMFactory::createCDM):
+ * testing/MockCDMFactory.h:
+
2017-08-04 Frederic Wang <fwang@igalia.com>
ScrollingTreeOverflowScrollingNodeIOS uses the wrong fixed position rectangle
#if ENABLE(ENCRYPTED_MEDIA)
+#include "CDMFactory.h"
#include "CDMPrivate.h"
#include "Document.h"
#include "InitDataRegistry.h"
namespace WebCore {
-static Vector<CDMFactory*>& cdmFactories()
-{
- static NeverDestroyed<Vector<CDMFactory*>> factories;
- return factories;
-}
-
-void CDM::registerCDMFactory(CDMFactory& factory)
-{
- ASSERT(!cdmFactories().contains(&factory));
- cdmFactories().append(&factory);
-}
-
-void CDM::unregisterCDMFactory(CDMFactory& factory)
-{
- ASSERT(cdmFactories().contains(&factory));
- cdmFactories().removeAll(&factory);
-}
-
bool CDM::supportsKeySystem(const String& keySystem)
{
- for (auto* factory : cdmFactories()) {
+ for (auto* factory : CDMFactory::registeredFactories()) {
if (factory->supportsKeySystem(keySystem))
return true;
}
, m_weakPtrFactory(this)
{
ASSERT(supportsKeySystem(keySystem));
- for (auto* factory : cdmFactories()) {
+ for (auto* factory : CDMFactory::registeredFactories()) {
if (factory->supportsKeySystem(keySystem)) {
- m_private = factory->createCDM(*this);
+ m_private = factory->createCDM();
break;
}
}
namespace WebCore {
-class CDM;
+class CDMFactory;
class CDMInstance;
class CDMPrivate;
class Document;
class ScriptExecutionContext;
class SharedBuffer;
-class CDMFactory {
-public:
- virtual ~CDMFactory() { };
- virtual std::unique_ptr<CDMPrivate> createCDM(CDM&) = 0;
- virtual bool supportsKeySystem(const String&) = 0;
-};
-
class CDM : public RefCounted<CDM>, private ContextDestructionObserver {
public:
- WEBCORE_EXPORT static void registerCDMFactory(CDMFactory&);
- WEBCORE_EXPORT static void unregisterCDMFactory(CDMFactory&);
-
static bool supportsKeySystem(const String&);
static bool isPersistentType(MediaKeySessionType);
platform/wpe/WidgetWPE.cpp
)
-if (ENABLE_ENCRYPTED_MEDIA)
- list(APPEND WebCore_INCLUDE_DIRECTORIES
- "${WEBCORE_DIR}/platform/encryptedmedia/clearkey"
- )
- list(APPEND WebCore_SOURCES
- platform/encryptedmedia/clearkey/CDMClearKey.cpp
- )
-endif ()
-
list(APPEND WebCore_USER_AGENT_STYLE_SHEETS
${WEBCORE_DIR}/Modules/mediacontrols/mediaControlsBase.css
)
if (ENABLE_ENCRYPTED_MEDIA)
list(APPEND WebCore_INCLUDE_DIRECTORIES
+ "${WEBCORE_DIR}/platform/encryptedmedia/clearkey"
${LIBGCRYPT_INCLUDE_DIRS}
)
+ list(APPEND WebCore_SOURCES
+ platform/encryptedmedia/clearkey/CDMClearKey.cpp
+
+ platform/graphics/gstreamer/eme/CDMFactoryGStreamer.cpp
+ )
list(APPEND WebCore_LIBRARIES
${LIBGCRYPT_LIBRARIES} -lgpg-error
)
--- /dev/null
+/*
+ * Copyright (C) 2016 Apple Inc. All rights reserved.
+ * Copyright (C) 2017 Metrological Group B.V.
+ * Copyright (C) 2017 Igalia S.L.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY APPLE INC. AND ITS CONTRIBUTORS ``AS IS''
+ * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
+ * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR ITS CONTRIBUTORS
+ * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
+ * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
+ * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
+ * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
+ * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
+ * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF
+ * THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#include "config.h"
+#include "CDMFactory.h"
+
+#if ENABLE(ENCRYPTED_MEDIA)
+
+#include <mutex>
+#include <wtf/NeverDestroyed.h>
+
+namespace WebCore {
+
+Vector<CDMFactory*>& CDMFactory::registeredFactories()
+{
+ static NeverDestroyed<Vector<CDMFactory*>> factories;
+ static std::once_flag once;
+ std::call_once(once, [&] { platformRegisterFactories(factories); });
+
+ return factories;
+}
+
+void CDMFactory::registerFactory(CDMFactory& factory)
+{
+ ASSERT(!registeredFactories().contains(&factory));
+ registeredFactories().append(&factory);
+}
+
+void CDMFactory::unregisterFactory(CDMFactory& factory)
+{
+ ASSERT(registeredFactories().contains(&factory));
+ registeredFactories().removeAll(&factory);
+}
+
+#if !USE(GSTREAMER)
+void CDMFactory::platformRegisterFactories()
+{
+}
+#endif
+
+} // namespace WebCore
+
+#endif // ENABLE(ENCRYPTED_MEDIA)
--- /dev/null
+/*
+ * Copyright (C) 2016 Apple Inc. All rights reserved.
+ * Copyright (C) 2017 Metrological Group B.V.
+ * Copyright (C) 2017 Igalia S.L.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY APPLE INC. AND ITS CONTRIBUTORS ``AS IS''
+ * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
+ * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR ITS CONTRIBUTORS
+ * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
+ * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
+ * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
+ * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
+ * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
+ * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF
+ * THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#pragma once
+
+#if ENABLE(ENCRYPTED_MEDIA)
+
+#include <memory>
+#include <wtf/Forward.h>
+#include <wtf/Vector.h>
+
+namespace WebCore {
+
+class CDMPrivate;
+
+class CDMFactory {
+public:
+ virtual ~CDMFactory() { };
+ virtual std::unique_ptr<CDMPrivate> createCDM() = 0;
+ virtual bool supportsKeySystem(const String&) = 0;
+
+ static Vector<CDMFactory*>& registeredFactories();
+ WEBCORE_EXPORT static void registerFactory(CDMFactory&);
+ WEBCORE_EXPORT static void unregisterFactory(CDMFactory&);
+
+ // Platform-specific function that's called when the list of
+ // registered CDMFactory objects is queried for the first time.
+ static void platformRegisterFactories(Vector<CDMFactory*>&);
+};
+
+} // namespace WebCore
+
+#endif // ENABLE(ENCRYPTED_MEDIA)
#if ENABLE(ENCRYPTED_MEDIA)
+#include "SharedBuffer.h"
+
namespace WebCore {
CDMFactoryClearKey::CDMFactoryClearKey() = default;
CDMFactoryClearKey::~CDMFactoryClearKey() = default;
-std::unique_ptr<CDMPrivate> CDMFactoryClearKey::createCDM(CDM&)
+std::unique_ptr<CDMPrivate> CDMFactoryClearKey::createCDM()
{
return std::unique_ptr<CDMPrivate>(new CDMPrivateClearKey);
}
#if ENABLE(ENCRYPTED_MEDIA)
-#include "CDM.h"
+#include "CDMFactory.h"
#include "CDMInstance.h"
#include "CDMPrivate.h"
CDMFactoryClearKey();
virtual ~CDMFactoryClearKey();
- std::unique_ptr<CDMPrivate> createCDM(CDM&) override;
+ std::unique_ptr<CDMPrivate> createCDM() override;
bool supportsKeySystem(const String&) override;
};
--- /dev/null
+/*
+ * Copyright (C) 2016 Metrological Group B.V.
+ * Copyright (C) 2016 Igalia S.L.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ *
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above
+ * copyright notice, this list of conditions and the following
+ * disclaimer in the documentation and/or other materials provided
+ * with the distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+ * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
+ * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
+ * HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+ * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+ * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+ * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+ * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+ * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#include "config.h"
+#include "CDMFactory.h"
+
+#if ENABLE(ENCRYPTED_MEDIA)
+
+namespace WebCore {
+
+void CDMFactory::platformRegisterFactories(Vector<CDMFactory*>& factories)
+{
+}
+
+} // namespace WebCore
+
+#endif // ENABLE(ENCRYPTED_MEDIA)
: m_supportedSessionTypes({ MediaKeySessionType::Temporary, MediaKeySessionType::PersistentUsageRecord, MediaKeySessionType::PersistentLicense })
, m_weakPtrFactory(this)
{
- CDM::registerCDMFactory(*this);
+ CDMFactory::registerFactory(*this);
}
MockCDMFactory::~MockCDMFactory()
void MockCDMFactory::unregister()
{
if (m_registered) {
- CDM::unregisterCDMFactory(*this);
+ CDMFactory::unregisterFactory(*this);
m_registered = false;
}
}
m_supportedDataTypes.append(type);
}
-std::unique_ptr<CDMPrivate> MockCDMFactory::createCDM(CDM&)
+std::unique_ptr<CDMPrivate> MockCDMFactory::createCDM()
{
return std::make_unique<MockCDM>(m_weakPtrFactory.createWeakPtr());
}
#if ENABLE(ENCRYPTED_MEDIA)
#include "CDM.h"
+#include "CDMFactory.h"
#include "CDMInstance.h"
#include "CDMPrivate.h"
#include "MediaKeysRequirement.h"
private:
MockCDMFactory();
- std::unique_ptr<CDMPrivate> createCDM(CDM&) final;
+ std::unique_ptr<CDMPrivate> createCDM() final;
bool supportsKeySystem(const String&) final;
MediaKeysRequirement m_distinctiveIdentifiersRequirement { MediaKeysRequirement::Optional };