Title: [219977] trunk/Source/WebCore
Revision
219977
Author
[email protected]
Date
2017-07-27 01:13:55 -0700 (Thu, 27 Jul 2017)

Log Message

[EME] Allow CDMInstance type traits specialization
https://bugs.webkit.org/show_bug.cgi?id=174886

Reviewed by Xabier Rodriguez-Calvar.

Allow using the trait-based type casting for the CDMInstance class and its
derivatives. ImplementationType enumeration values are to be used and
returned from the new implementationType() virtual method. This method is
leveraged in the type trait specialization that enables using is<>() and
downcast<>() helpers for CDMInstance objects.

This will allow differentiating between CDMInstance implementations once
the media playback pipeline has to retrieve any key information that's
necessary for playback of encrypted content.

MockCDMInstance class overrides the implementationType() method, returning
the ImplementationType::Mock value. Type trait specializations for this
class aren't added since they're not needed anywhere at this point.

* platform/encryptedmedia/CDMInstance.h:
* testing/MockCDMFactory.h:

Modified Paths

Diff

Modified: trunk/Source/WebCore/ChangeLog (219976 => 219977)


--- trunk/Source/WebCore/ChangeLog	2017-07-27 08:13:02 UTC (rev 219976)
+++ trunk/Source/WebCore/ChangeLog	2017-07-27 08:13:55 UTC (rev 219977)
@@ -1,5 +1,29 @@
 2017-07-27  Zan Dobersek  <[email protected]>
 
+        [EME] Allow CDMInstance type traits specialization
+        https://bugs.webkit.org/show_bug.cgi?id=174886
+
+        Reviewed by Xabier Rodriguez-Calvar.
+
+        Allow using the trait-based type casting for the CDMInstance class and its
+        derivatives. ImplementationType enumeration values are to be used and
+        returned from the new implementationType() virtual method. This method is
+        leveraged in the type trait specialization that enables using is<>() and
+        downcast<>() helpers for CDMInstance objects.
+
+        This will allow differentiating between CDMInstance implementations once
+        the media playback pipeline has to retrieve any key information that's
+        necessary for playback of encrypted content.
+
+        MockCDMInstance class overrides the implementationType() method, returning
+        the ImplementationType::Mock value. Type trait specializations for this
+        class aren't added since they're not needed anywhere at this point.
+
+        * platform/encryptedmedia/CDMInstance.h:
+        * testing/MockCDMFactory.h:
+
+2017-07-27  Zan Dobersek  <[email protected]>
+
         [GCrypt] Key serialization support
         https://bugs.webkit.org/show_bug.cgi?id=173883
 

Modified: trunk/Source/WebCore/platform/encryptedmedia/CDMInstance.h (219976 => 219977)


--- trunk/Source/WebCore/platform/encryptedmedia/CDMInstance.h	2017-07-27 08:13:02 UTC (rev 219976)
+++ trunk/Source/WebCore/platform/encryptedmedia/CDMInstance.h	2017-07-27 08:13:55 UTC (rev 219977)
@@ -34,6 +34,7 @@
 #include <wtf/Forward.h>
 #include <wtf/Optional.h>
 #include <wtf/RefCounted.h>
+#include <wtf/TypeCasts.h>
 #include <wtf/Vector.h>
 
 namespace WebCore {
@@ -46,6 +47,12 @@
 public:
     virtual ~CDMInstance() { }
 
+    enum class ImplementationType {
+        Mock,
+    };
+
+    virtual ImplementationType implementationType() const = 0;
+
     enum SuccessValue {
         Failed,
         Succeeded,
@@ -90,4 +97,9 @@
 
 } // namespace WebCore
 
+#define SPECIALIZE_TYPE_TRAITS_CDM_INSTANCE(ToValueTypeName, ImplementationTypeName) \
+SPECIALIZE_TYPE_TRAITS_BEGIN(ToValueTypeName) \
+static bool isType(const WebCore::CDMInstance& instance) { return instance.implementationType() == ImplementationTypeName; } \
+SPECIALIZE_TYPE_TRAITS_END()
+
 #endif

Modified: trunk/Source/WebCore/testing/MockCDMFactory.h (219976 => 219977)


--- trunk/Source/WebCore/testing/MockCDMFactory.h	2017-07-27 08:13:02 UTC (rev 219976)
+++ trunk/Source/WebCore/testing/MockCDMFactory.h	2017-07-27 08:13:55 UTC (rev 219977)
@@ -127,6 +127,7 @@
     MockCDMInstance(WeakPtr<MockCDM>);
 
 private:
+    ImplementationType implementationType() const final { return ImplementationType::Mock; }
     SuccessValue initializeWithConfiguration(const MediaKeySystemConfiguration&) final;
     SuccessValue setDistinctiveIdentifiersAllowed(bool) final;
     SuccessValue setPersistentStateAllowed(bool) final;
_______________________________________________
webkit-changes mailing list
[email protected]
https://lists.webkit.org/mailman/listinfo/webkit-changes

Reply via email to