Commit 3467f088 authored by jrummell's avatar jrummell Committed by Commit bot

Remove CDM_5 Support

As we never shipped a CDM based on CDM_5, we can remove the code.
CDM_4 will be removed later, once all clients are upgraded to CDM_6.

BUG=401815
TEST=existing EME tests still pass

Review URL: https://codereview.chromium.org/518353002

Cr-Commit-Position: refs/heads/master@{#292754}
parent 3c2889b0
......@@ -387,7 +387,7 @@ void CdmAdapter::CloseSession(uint32_t promise_id,
const std::string& web_session_id) {
if (!cdm_->CloseSession(
promise_id, web_session_id.data(), web_session_id.length())) {
// CDM_4 and CDM_5 don't support this method, so reject the promise.
// CDM_4 doesn't support this method, so reject the promise.
RejectPromise(promise_id, cdm::kNotSupportedError, 0, "Not implemented.");
}
}
......@@ -402,7 +402,7 @@ void CdmAdapter::GetUsableKeyIds(uint32_t promise_id,
const std::string& web_session_id) {
if (!cdm_->GetUsableKeyIds(
promise_id, web_session_id.data(), web_session_id.length())) {
// CDM_4 and CDM_5 don't support this method, so reject the promise.
// CDM_4 doesn't support this method, so reject the promise.
RejectPromise(promise_id, cdm::kNotSupportedError, 0, "Not implemented.");
}
}
......@@ -604,7 +604,7 @@ void CdmAdapter::TimerExpired(int32_t result, void* context) {
// cdm::Host_4 methods
double CdmAdapter::GetCurrentWallTimeInSeconds() {
return GetCurrentTime();
return GetCurrentWallTime();
}
void CdmAdapter::OnSessionCreated(uint32_t session_id,
......@@ -635,7 +635,8 @@ void CdmAdapter::OnSessionReady(uint32_t session_id) {
OnResolvePromise(promise_id);
} else {
std::string web_session_id = cdm_->LookupWebSessionId(session_id);
OnSessionReady(web_session_id.data(), web_session_id.length());
PostOnMain(callback_factory_.NewCallback(
&CdmAdapter::SendSessionReadyInternal, web_session_id));
}
}
......@@ -685,27 +686,12 @@ void CdmAdapter::OnSessionError(uint32_t session_id,
}
}
// cdm::Host_5 and cdm::Host_6 methods
cdm::Time CdmAdapter::GetCurrentTime() {
return GetCurrentWallTime();
}
// cdm::Host_6 methods
cdm::Time CdmAdapter::GetCurrentWallTime() {
return pp::Module::Get()->core()->GetTime();
}
void CdmAdapter::OnResolvePromise(uint32_t promise_id) {
PostOnMain(callback_factory_.NewCallback(
&CdmAdapter::SendPromiseResolvedInternal, promise_id));
// CDM_5 doesn't support OnSessionKeysChange(), so simulate one if requested.
// Passing "true" which may result in false positives for retrying.
std::string session_id;
if (cdm_->SessionUsableKeysEventNeeded(promise_id, &session_id))
OnSessionKeysChange(session_id.data(), session_id.length(), true);
}
void CdmAdapter::OnResolveNewSessionPromise(uint32_t promise_id,
const char* web_session_id,
uint32_t web_session_id_length) {
......@@ -713,12 +699,11 @@ void CdmAdapter::OnResolveNewSessionPromise(uint32_t promise_id,
&CdmAdapter::SendPromiseResolvedWithSessionInternal,
promise_id,
std::string(web_session_id, web_session_id_length)));
}
// CDM_5 doesn't support OnSessionKeysChange(), so simulate one if requested.
// Passing "true" which may result in false positives for retrying.
std::string session_id;
if (cdm_->SessionUsableKeysEventNeeded(promise_id, &session_id))
OnSessionKeysChange(web_session_id, web_session_id_length, true);
void CdmAdapter::OnResolvePromise(uint32_t promise_id) {
PostOnMain(callback_factory_.NewCallback(
&CdmAdapter::SendPromiseResolvedInternal, promise_id));
}
void CdmAdapter::OnResolveKeyIdsPromise(uint32_t promise_id,
......@@ -770,13 +755,6 @@ void CdmAdapter::OnSessionMessage(const char* web_session_id,
std::string(destination_url, destination_url_length)));
}
void CdmAdapter::OnSessionKeysChange(const char* web_session_id,
uint32_t web_session_id_length,
bool has_additional_usable_key) {
OnSessionUsableKeysChange(
web_session_id, web_session_id_length, has_additional_usable_key);
}
void CdmAdapter::OnSessionUsableKeysChange(const char* web_session_id,
uint32_t web_session_id_length,
bool has_additional_usable_key) {
......@@ -795,13 +773,6 @@ void CdmAdapter::OnExpirationChange(const char* web_session_id,
new_expiry_time));
}
void CdmAdapter::OnSessionReady(const char* web_session_id,
uint32_t web_session_id_length) {
PostOnMain(callback_factory_.NewCallback(
&CdmAdapter::SendSessionReadyInternal,
std::string(web_session_id, web_session_id_length)));
}
void CdmAdapter::OnSessionClosed(const char* web_session_id,
uint32_t web_session_id_length) {
PostOnMain(callback_factory_.NewCallback(
......@@ -1312,7 +1283,7 @@ void* GetCdmHost(int host_interface_version, void* user_data) {
// Current version is supported.
IsSupportedCdmHostVersion(cdm::Host_6::kVersion) &&
// Include all previous supported versions (if any) here.
IsSupportedCdmHostVersion(cdm::Host_5::kVersion) &&
// Host_5 is not supported.
IsSupportedCdmHostVersion(cdm::Host_4::kVersion) &&
// One older than the oldest supported version is not supported.
!IsSupportedCdmHostVersion(cdm::Host_4::kVersion - 1));
......@@ -1323,8 +1294,6 @@ void* GetCdmHost(int host_interface_version, void* user_data) {
switch (host_interface_version) {
case cdm::Host_4::kVersion:
return static_cast<cdm::Host_4*>(cdm_adapter);
case cdm::Host_5::kVersion:
return static_cast<cdm::Host_5*>(cdm_adapter);
case cdm::Host_6::kVersion:
return static_cast<cdm::Host_6*>(cdm_adapter);
default:
......
......@@ -28,11 +28,6 @@
#include "ppapi/cpp/private/platform_verification.h"
#endif
#if defined(GetCurrentTime)
// winbase.h defines this which messes up calls to Host_5::GetCurrentTime.
#undef GetCurrentTime
#endif
namespace media {
// GetCdmHostFunc implementation.
......@@ -43,7 +38,6 @@ void* GetCdmHost(int host_interface_version, void* user_data);
class CdmAdapter : public pp::Instance,
public pp::ContentDecryptor_Private,
public cdm::Host_4,
public cdm::Host_5,
public cdm::Host_6 {
public:
CdmAdapter(PP_Instance instance, pp::Module* module);
......@@ -94,7 +88,7 @@ class CdmAdapter : public pp::Instance,
pp::Buffer_Dev encrypted_buffer,
const PP_EncryptedBlockInfo& encrypted_block_info) OVERRIDE;
// cdm::Host_4, cdm::Host_5 and cdm::Host_6 implementation.
// cdm::Host_4 and cdm::Host_6 implementation.
virtual cdm::Buffer* Allocate(uint32_t capacity) OVERRIDE;
virtual void SetTimer(int64_t delay_ms, void* context) OVERRIDE;
......@@ -114,13 +108,16 @@ class CdmAdapter : public pp::Instance,
cdm::MediaKeyError error_code,
uint32_t system_code) OVERRIDE;
// cdm::Host_5 implementation.
virtual cdm::Time GetCurrentTime() OVERRIDE;
// cdm::Host_6 implementation.
virtual cdm::Time GetCurrentWallTime() OVERRIDE;
virtual void OnResolveNewSessionPromise(
uint32_t promise_id,
const char* web_session_id,
uint32_t web_session_id_length) OVERRIDE;
virtual void OnResolvePromise(uint32_t promise_id) OVERRIDE;
virtual void OnResolveKeyIdsPromise(uint32_t promise_id,
const cdm::BinaryData* usable_key_ids,
uint32_t usable_key_ids_length) OVERRIDE;
virtual void OnRejectPromise(uint32_t promise_id,
cdm::Error error,
uint32_t system_code,
......@@ -132,14 +129,13 @@ class CdmAdapter : public pp::Instance,
uint32_t message_length,
const char* destination_url,
uint32_t destination_url_length) OVERRIDE;
virtual void OnSessionKeysChange(const char* web_session_id,
virtual void OnSessionUsableKeysChange(
const char* web_session_id,
uint32_t web_session_id_length,
bool has_additional_usable_key) OVERRIDE;
virtual void OnExpirationChange(const char* web_session_id,
uint32_t web_session_id_length,
cdm::Time new_expiry_time) OVERRIDE;
virtual void OnSessionReady(const char* web_session_id,
uint32_t web_session_id_length) OVERRIDE;
virtual void OnSessionClosed(const char* web_session_id,
uint32_t web_session_id_length) OVERRIDE;
virtual void OnSessionError(const char* web_session_id,
......@@ -149,17 +145,7 @@ class CdmAdapter : public pp::Instance,
const char* error_message,
uint32_t error_message_length) OVERRIDE;
// cdm::Host_6 implementation.
virtual cdm::Time GetCurrentWallTime() OVERRIDE;
virtual void OnResolveKeyIdsPromise(uint32_t promise_id,
const cdm::BinaryData* usable_key_ids,
uint32_t usable_key_ids_length) OVERRIDE;
virtual void OnSessionUsableKeysChange(
const char* web_session_id,
uint32_t web_session_id_length,
bool has_additional_usable_key) OVERRIDE;
// cdm::Host_4, cdm::Host_5 and cdm::Host_6 implementation.
// cdm::Host_4 and cdm::Host_6 implementation.
virtual void SendPlatformChallenge(const char* service_id,
uint32_t service_id_length,
const char* challenge,
......
......@@ -103,11 +103,11 @@ class CdmWrapper {
virtual std::string LookupWebSessionId(uint32_t session_id) = 0;
virtual void DropWebSessionId(std::string web_session_id) = 0;
// Helper functions for the cdm::Host_4 and cdm::Host_5 methods.
// Helper functions for the cdm::Host_4 methods.
// CDMs using cdm::Host_6 will call OnSessionUsableKeys() as necessary when
// resolving LoadSession() and UpdateSession(). This needs to be simulated
// for the older CDMs. These must not be called for cdm::Host_6 and later.
// TODO(jrummell): Remove these once Host_4 and Host_5 interfaces are removed.
// TODO(jrummell): Remove these once Host_4 interface is removed.
// Query whether a SessionUsableKeys event is necessary for the specified
// |promise_id|. Returns true if needed and |web_session_id| is updated,
......@@ -122,16 +122,16 @@ class CdmWrapper {
const char* web_session_id,
uint32_t web_session_id_size) = 0;
// cdm::Host_6 introduces InputBuffer_2 (aka InputBuffer). cdm::Host_4 and
// cdm::Host_5 methods still use InputBuffer_1, so this helper function
// cdm::Host_6 introduces InputBuffer_2 (aka InputBuffer). cdm::Host_4
// methods still use InputBuffer_1, so this helper function
// converts InputBuffer_2 to InputBuffer_1.
// TODO(jrummell): Remove these once Host_4 and Host_5 interfaces are removed.
// TODO(jrummell): Remove these once Host_4 interfaces is removed.
virtual void ConvertInputBuffer(const cdm::InputBuffer& v2,
cdm::InputBuffer_1* v1) = 0;
// Prior to CDM_6, |init_data_type| was a content type. This helper convererts
// an |init_data_type| to a content type.
// TODO(sandersd): Remove once Host_4 and Host_5 interfaces are removed.
// TODO(sandersd): Remove once Host_4 interface is removed.
virtual std::string ConvertInitDataTypeToContentType(
const std::string& init_data_type) const = 0;
......@@ -511,121 +511,6 @@ CdmWrapperImpl<cdm::ContentDecryptionModule_4>::DecryptAndDecodeSamples(
return cdm_->DecryptAndDecodeSamples(buffer, audio_frames);
}
// Overrides for the cdm::Host_5 methods.
// TODO(jrummell): Remove these once Host_5 interface is removed.
template <>
void CdmWrapperImpl<cdm::ContentDecryptionModule_5>::CreateSession(
uint32_t promise_id,
const char* init_data_type,
uint32_t init_data_type_size,
const uint8_t* init_data,
uint32_t init_data_size,
cdm::SessionType session_type) {
std::string converted_init_data_type = ConvertInitDataTypeToContentType(
std::string(init_data_type, init_data_type_size));
// TODO(jrummell): Remove this code once |session_type| is passed through
// Pepper. When removing, add the header back in for CDM4.
PP_DCHECK(session_type == cdm::kTemporary);
const char kPersistentSessionHeader[] = "PERSISTENT|";
if (HasHeader(init_data, init_data_size, kPersistentSessionHeader)) {
cdm_->CreateSession(promise_id,
converted_init_data_type.data(),
converted_init_data_type.length(),
init_data + strlen(kPersistentSessionHeader),
init_data_size - strlen(kPersistentSessionHeader),
cdm::kPersistent);
return;
}
cdm_->CreateSession(promise_id,
converted_init_data_type.data(),
converted_init_data_type.length(),
init_data,
init_data_size,
session_type);
}
template <>
void CdmWrapperImpl<cdm::ContentDecryptionModule_5>::LoadSession(
uint32_t promise_id,
const char* web_session_id,
uint32_t web_session_id_size) {
// As CDM_5 doesn't support OnSessionUsableKeysChange(), make sure to generate
// one when the promise is resolved. This may be overly aggressive.
SetSessionUsableKeysEventNeeded(
promise_id, web_session_id, web_session_id_size);
cdm_->LoadSession(promise_id, web_session_id, web_session_id_size);
}
template <>
void CdmWrapperImpl<cdm::ContentDecryptionModule_5>::UpdateSession(
uint32_t promise_id,
const char* web_session_id,
uint32_t web_session_id_size,
const uint8_t* response,
uint32_t response_size) {
// As CDM_5 doesn't support OnSessionUsableKeysChange(), make sure to generate
// one when the promise is resolved. This may be overly aggressive.
SetSessionUsableKeysEventNeeded(
promise_id, web_session_id, web_session_id_size);
cdm_->UpdateSession(
promise_id, web_session_id, web_session_id_size, response, response_size);
}
template <>
bool CdmWrapperImpl<cdm::ContentDecryptionModule_5>::CloseSession(
uint32_t promise_id,
const char* web_session_id,
uint32_t web_session_id_size) {
return false;
}
template <>
void CdmWrapperImpl<cdm::ContentDecryptionModule_5>::RemoveSession(
uint32_t promise_id,
const char* web_session_id,
uint32_t web_session_id_size) {
cdm_->ReleaseSession(promise_id, web_session_id, web_session_id_size);
}
template <>
bool CdmWrapperImpl<cdm::ContentDecryptionModule_5>::GetUsableKeyIds(
uint32_t promise_id,
const char* web_session_id,
uint32_t web_session_id_size) {
return false;
}
template <>
cdm::Status CdmWrapperImpl<cdm::ContentDecryptionModule_5>::Decrypt(
const cdm::InputBuffer& encrypted_buffer,
cdm::DecryptedBlock* decrypted_buffer) {
cdm::InputBuffer_1 buffer;
ConvertInputBuffer(encrypted_buffer, &buffer);
return cdm_->Decrypt(buffer, decrypted_buffer);
}
template <>
cdm::Status
CdmWrapperImpl<cdm::ContentDecryptionModule_5>::DecryptAndDecodeFrame(
const cdm::InputBuffer& encrypted_buffer,
cdm::VideoFrame* video_frame) {
cdm::InputBuffer_1 buffer;
ConvertInputBuffer(encrypted_buffer, &buffer);
return cdm_->DecryptAndDecodeFrame(buffer, video_frame);
}
template <>
cdm::Status
CdmWrapperImpl<cdm::ContentDecryptionModule_5>::DecryptAndDecodeSamples(
const cdm::InputBuffer& encrypted_buffer,
cdm::AudioFrames* audio_frames) {
cdm::InputBuffer_1 buffer;
ConvertInputBuffer(encrypted_buffer, &buffer);
return cdm_->DecryptAndDecodeSamples(buffer, audio_frames);
}
CdmWrapper* CdmWrapper::Create(const char* key_system,
uint32_t key_system_size,
GetCdmHostFunc get_cdm_host_func,
......@@ -656,11 +541,6 @@ CdmWrapper* CdmWrapper::Create(const char* key_system,
// If |cdm_wrapper| is NULL, try to create the CDM using older supported
// versions of the CDM interface.
cdm_wrapper = CdmWrapperImpl<cdm::ContentDecryptionModule_5>::Create(
key_system, key_system_size, get_cdm_host_func, user_data);
if (cdm_wrapper)
return cdm_wrapper;
cdm_wrapper = CdmWrapperImpl<cdm::ContentDecryptionModule_4>::Create(
key_system, key_system_size, get_cdm_host_func, user_data);
return cdm_wrapper;
......
......@@ -26,7 +26,6 @@ bool IsSupportedCdmInterfaceVersion(int version) {
switch(version) {
// Supported versions in decreasing order.
case cdm::ContentDecryptionModule_6::kVersion:
case cdm::ContentDecryptionModule_5::kVersion:
case cdm::ContentDecryptionModule_4::kVersion:
return true;
default:
......@@ -41,7 +40,6 @@ bool IsSupportedCdmHostVersion(int version) {
switch(version) {
// Supported versions in decreasing order.
case cdm::Host_6::kVersion:
case cdm::Host_5::kVersion:
case cdm::Host_4::kVersion:
return true;
default:
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment