- Revision
- 211855
- Author
- [email protected]
- Date
- 2017-02-08 01:34:44 -0800 (Wed, 08 Feb 2017)
Log Message
[EME] Alias CDMInstance enums to the specification-defined enums
https://bugs.webkit.org/show_bug.cgi?id=167896
Reviewed by Sam Weinig.
Simplify the enums in the CDMInstance class by simply aliasing them
to the EME specification-defined enums. CDMInstance::KeyStatus and
CDMInstance::MessageType were already direct copies of the
MediaKeyStatus and MediaKeyMessageType enums, while the
CDMInstance::LicenseType had the members as MediaKeySessionType,
but with slightly different names.
No changes in behavior.
* Modules/encryptedmedia/CDMInstance.h:
* Modules/encryptedmedia/MediaKeySession.cpp:
(WebCore::MediaKeySession::generateRequest):
(WebCore::MediaKeySession::update):
* testing/MockCDMFactory.cpp:
(WebCore::MockCDMInstance::requestLicense):
Modified Paths
Diff
Modified: trunk/Source/WebCore/ChangeLog (211854 => 211855)
--- trunk/Source/WebCore/ChangeLog 2017-02-08 06:54:01 UTC (rev 211854)
+++ trunk/Source/WebCore/ChangeLog 2017-02-08 09:34:44 UTC (rev 211855)
@@ -1,3 +1,26 @@
+2017-02-08 Zan Dobersek <[email protected]>
+
+ [EME] Alias CDMInstance enums to the specification-defined enums
+ https://bugs.webkit.org/show_bug.cgi?id=167896
+
+ Reviewed by Sam Weinig.
+
+ Simplify the enums in the CDMInstance class by simply aliasing them
+ to the EME specification-defined enums. CDMInstance::KeyStatus and
+ CDMInstance::MessageType were already direct copies of the
+ MediaKeyStatus and MediaKeyMessageType enums, while the
+ CDMInstance::LicenseType had the members as MediaKeySessionType,
+ but with slightly different names.
+
+ No changes in behavior.
+
+ * Modules/encryptedmedia/CDMInstance.h:
+ * Modules/encryptedmedia/MediaKeySession.cpp:
+ (WebCore::MediaKeySession::generateRequest):
+ (WebCore::MediaKeySession::update):
+ * testing/MockCDMFactory.cpp:
+ (WebCore::MockCDMInstance::requestLicense):
+
2017-02-07 Carlos Garcia Campos <[email protected]>
REGRESSION(r210740): [GTK] 2.15 broke embedded videos in GNOME's yelp app
Modified: trunk/Source/WebCore/Modules/encryptedmedia/CDMInstance.h (211854 => 211855)
--- trunk/Source/WebCore/Modules/encryptedmedia/CDMInstance.h 2017-02-08 06:54:01 UTC (rev 211854)
+++ trunk/Source/WebCore/Modules/encryptedmedia/CDMInstance.h 2017-02-08 09:34:44 UTC (rev 211855)
@@ -27,6 +27,9 @@
#if ENABLE(ENCRYPTED_MEDIA)
+#include "MediaKeyMessageType.h"
+#include "MediaKeySessionType.h"
+#include "MediaKeyStatus.h"
#include <utility>
#include <wtf/Forward.h>
#include <wtf/Optional.h>
@@ -47,37 +50,18 @@
Succeeded,
};
+ using LicenseType = MediaKeySessionType;
+ using KeyStatus = MediaKeyStatus;
+ using MessageType = MediaKeyMessageType;
+
virtual SuccessValue initializeWithConfiguration(const MediaKeySystemConfiguration&) = 0;
virtual SuccessValue setDistinctiveIdentifiersAllowed(bool) = 0;
virtual SuccessValue setPersistentStateAllowed(bool) = 0;
virtual SuccessValue setServerCertificate(Ref<SharedBuffer>&&) = 0;
- enum class LicenseType {
- Temporary,
- Persistable,
- UsageRecord,
- };
-
using LicenseCallback = Function<void(Ref<SharedBuffer>&& message, const String& sessionId, bool needsIndividualization, SuccessValue succeeded)>;
virtual void requestLicense(LicenseType, const AtomicString& initDataType, Ref<SharedBuffer>&& initData, LicenseCallback) = 0;
- enum class KeyStatus {
- Usable,
- Expired,
- Released,
- OutputRestricted,
- OutputDownscaled,
- StatusPending,
- InternalError,
- };
-
- enum class MessageType {
- LicenseRequest,
- LicenseRenewal,
- LicenseRelease,
- IndividualizationRequest,
- };
-
using KeyStatusVector = Vector<std::pair<Ref<SharedBuffer>, KeyStatus>>;
using Message = std::pair<MessageType, Ref<SharedBuffer>>;
using LicenseUpdateCallback = Function<void(bool sessionWasClosed, std::optional<KeyStatusVector>&& changedKeys, std::optional<double>&& changedExpiration, std::optional<Message>&& message, SuccessValue succeeded)>;
Modified: trunk/Source/WebCore/Modules/encryptedmedia/MediaKeySession.cpp (211854 => 211855)
--- trunk/Source/WebCore/Modules/encryptedmedia/MediaKeySession.cpp 2017-02-08 06:54:01 UTC (rev 211854)
+++ trunk/Source/WebCore/Modules/encryptedmedia/MediaKeySession.cpp 2017-02-08 09:34:44 UTC (rev 211855)
@@ -165,37 +165,25 @@
}
// 10.9.2 Follow the steps for the value of session type from the following list:
- CDMInstance::LicenseType requestedLicenseType;
- switch (m_sessionType) {
- case MediaKeySessionType::Temporary:
- // ↳ "temporary"
- // Let requested license type be a temporary non-persistable license.
- requestedLicenseType = CDMInstance::LicenseType::Temporary;
- break;
- case MediaKeySessionType::PersistentLicense:
- // ↳ "persistent-license"
- // Let requested license type be a persistable license.
- requestedLicenseType = CDMInstance::LicenseType::Persistable;
- break;
- case MediaKeySessionType::PersistentUsageRecord:
- // ↳ "persistent-usage-record"
- // 1. Initialize this object's record of key usage as follows.
- // Set the list of key IDs known to the session to an empty list.
+ // ↳ "temporary"
+ // Let requested license type be a temporary non-persistable license.
+ // ↳ "persistent-license"
+ // Let requested license type be a persistable license.
+ // ↳ "persistent-usage-record"
+ // 1. Initialize this object's record of key usage as follows.
+ // Set the list of key IDs known to the session to an empty list.
+ // Set the first decrypt time to null.
+ // Set the latest decrypt time to null.
+ // 2. Let requested license type be a non-persistable license that will
+ // persist a record of key usage.
+
+ if (m_sessionType == MediaKeySessionType::PersistentUsageRecord) {
m_recordOfKeyUsage.clear();
-
- // Set the first decrypt time to null.
m_firstDecryptTime = 0;
-
- // Set the latest decrypt time to null.
m_latestDecryptTime = 0;
-
- // 2. Let requested license type be a non-persistable license that will
- // persist a record of key usage.
- requestedLicenseType = CDMInstance::LicenseType::UsageRecord;
- break;
}
- m_instance->requestLicense(requestedLicenseType, initDataType, WTFMove(initData), [this, weakThis = m_weakPtrFactory.createWeakPtr(), promise = WTFMove(promise)] (Ref<SharedBuffer>&& message, const String& sessionId, bool needsIndividualization, CDMInstance::SuccessValue succeeded) mutable {
+ m_instance->requestLicense(m_sessionType, initDataType, WTFMove(initData), [this, weakThis = m_weakPtrFactory.createWeakPtr(), promise = WTFMove(promise)] (Ref<SharedBuffer>&& message, const String& sessionId, bool needsIndividualization, CDMInstance::SuccessValue succeeded) mutable {
if (!weakThis)
return;
@@ -277,25 +265,12 @@
return;
}
- CDMInstance::LicenseType licenseType;
- switch (m_sessionType) {
- case MediaKeySessionType::Temporary:
- licenseType = CDMInstance::LicenseType::Temporary;
- break;
- case MediaKeySessionType::PersistentLicense:
- licenseType = CDMInstance::LicenseType::Persistable;
- break;
- case MediaKeySessionType::PersistentUsageRecord:
- licenseType = CDMInstance::LicenseType::UsageRecord;
- break;
- };
-
// 6.3. Let message be null.
// 6.4. Let message type be null.
// 6.5. Let session closed be false.
// 6.6. Let cdm be the CDM instance represented by this object's cdm instance value.
// 6.7. Use the cdm to execute the following steps:
- m_instance->updateLicense(licenseType, *sanitizedResponse, [this, weakThis = m_weakPtrFactory.createWeakPtr(), promise = WTFMove(promise)] (bool sessionWasClosed, std::optional<CDMInstance::KeyStatusVector>&& changedKeys, std::optional<double>&& changedExpiration, std::optional<CDMInstance::Message>&& message, CDMInstance::SuccessValue succeeded) mutable {
+ m_instance->updateLicense(m_sessionType, *sanitizedResponse, [this, weakThis = m_weakPtrFactory.createWeakPtr(), promise = WTFMove(promise)] (bool sessionWasClosed, std::optional<CDMInstance::KeyStatusVector>&& changedKeys, std::optional<double>&& changedExpiration, std::optional<CDMInstance::Message>&& message, CDMInstance::SuccessValue succeeded) mutable {
if (!weakThis)
return;
Modified: trunk/Source/WebCore/testing/MockCDMFactory.cpp (211854 => 211855)
--- trunk/Source/WebCore/testing/MockCDMFactory.cpp 2017-02-08 06:54:01 UTC (rev 211854)
+++ trunk/Source/WebCore/testing/MockCDMFactory.cpp 2017-02-08 09:34:44 UTC (rev 211855)
@@ -249,10 +249,7 @@
return;
}
- if ((licenseType == LicenseType::Temporary && !factory->supportedSessionTypes().contains(MediaKeySessionType::Temporary))
- || (licenseType == LicenseType::Persistable && !factory->supportedSessionTypes().contains(MediaKeySessionType::PersistentLicense))
- || (licenseType == LicenseType::UsageRecord && !factory->supportedSessionTypes().contains(MediaKeySessionType::PersistentUsageRecord))
- || !factory->supportedDataTypes().contains(initDataType)) {
+ if (!factory->supportedSessionTypes().contains(licenseType) || !factory->supportedDataTypes().contains(initDataType)) {
callback(SharedBuffer::create(), emptyString(), false, SuccessValue::Failed);
return;
}