Skip to content

Commit

Permalink
media: Remove cdm::ContentDecryptionModule_8 support
Browse files Browse the repository at this point in the history
CDM_9 support has been shipped in Chomium for multiple releases. All new CDMs
should use CDM_9 and above. Hence removing support for CDM_8.

only cover CDM_9 and CDM_10.

Bug: 737296
Test: Removing support of old interface support. Currently our tests
Change-Id: I22facd6dc6e18933a295d3aece7ba2de1369cb79
Reviewed-on: https://chromium-review.googlesource.com/1015640
Reviewed-by: Frank Liberato <liberato@chromium.org>
Commit-Queue: Xiaohan Wang <xhwang@chromium.org>
Cr-Commit-Position: refs/heads/master@{#551494}
  • Loading branch information
xhwang-chromium authored and Commit Bot committed Apr 17, 2018
1 parent 92423d6 commit 778e8cf
Show file tree
Hide file tree
Showing 4 changed files with 3 additions and 179 deletions.
62 changes: 1 addition & 61 deletions media/cdm/cdm_adapter.cc
Original file line number Diff line number Diff line change
Expand Up @@ -122,29 +122,6 @@ CdmPromise::Exception ToMediaExceptionType(cdm::Exception exception) {
return CdmPromise::Exception::INVALID_STATE_ERROR;
}

cdm::Exception ToCdmExceptionType(cdm::Error error) {
switch (error) {
case cdm::kNotSupportedError:
return cdm::kExceptionNotSupportedError;
case cdm::kInvalidStateError:
return cdm::kExceptionInvalidStateError;
case cdm::kInvalidAccessError:
return cdm::kExceptionTypeError;
case cdm::kQuotaExceededError:
return cdm::kExceptionQuotaExceededError;

// TODO(jrummell): Remove these once CDM_8 is no longer supported.
// https://crbug.com/737296.
case cdm::kUnknownError:
case cdm::kClientError:
case cdm::kOutputError:
return cdm::kExceptionNotSupportedError;
}

NOTREACHED() << "Unexpected cdm::Error " << error;
return cdm::kExceptionInvalidStateError;
}

CdmMessageType ToMediaMessageType(cdm::MessageType message_type) {
switch (message_type) {
case cdm::kLicenseRequest:
Expand Down Expand Up @@ -429,7 +406,7 @@ void* GetCdmHost(int host_interface_version, void* user_data) {
// IsSupportedCdmHostVersion.

// TODO(xhwang): Static assert these at compile time.
const int kMinVersion = cdm::ContentDecryptionModule_8::kVersion;
const int kMinVersion = cdm::ContentDecryptionModule_9::kVersion;
const int kMaxVersion = cdm::ContentDecryptionModule_10::kVersion;
DCHECK(!IsSupportedCdmInterfaceVersion(kMinVersion - 1));
for (int version = kMinVersion; version <= kMaxVersion; ++version)
Expand All @@ -440,8 +417,6 @@ void* GetCdmHost(int host_interface_version, void* user_data) {
CdmAdapter* cdm_adapter = static_cast<CdmAdapter*>(user_data);
DVLOG(1) << "Create CDM Host with version " << host_interface_version;
switch (host_interface_version) {
case cdm::Host_8::kVersion:
return static_cast<cdm::Host_8*>(cdm_adapter);
case cdm::Host_9::kVersion:
return static_cast<cdm::Host_9*>(cdm_adapter);
case cdm::Host_10::kVersion:
Expand Down Expand Up @@ -979,17 +954,6 @@ void CdmAdapter::OnRejectPromise(uint32_t promise_id,
std::string(error_message, error_message_size));
}

void CdmAdapter::OnRejectPromise(uint32_t promise_id,
cdm::Error error,
uint32_t system_code,
const char* error_message,
uint32_t error_message_size) {
// cdm::Host_8 version. Remove when CDM_8 no longer supported.
// https://crbug.com/737296.
OnRejectPromise(promise_id, ToCdmExceptionType(error), system_code,
error_message, error_message_size);
}

void CdmAdapter::OnSessionMessage(const char* session_id,
uint32_t session_id_size,
cdm::MessageType message_type,
Expand All @@ -1003,19 +967,6 @@ void CdmAdapter::OnSessionMessage(const char* session_id,
std::vector<uint8_t>(message_ptr, message_ptr + message_size));
}

void CdmAdapter::OnSessionMessage(const char* session_id,
uint32_t session_id_size,
cdm::MessageType message_type,
const char* message,
uint32_t message_size,
const char* /* legacy_destination_url */,
uint32_t /* legacy_destination_url_size */) {
// cdm::Host_8 version. Remove when CDM_8 no longer supported.
// https://crbug.com/737296.
OnSessionMessage(session_id, session_id_size, message_type, message,
message_size);
}

void CdmAdapter::OnSessionKeysChange(const char* session_id,
uint32_t session_id_size,
bool has_additional_usable_key,
Expand Down Expand Up @@ -1061,17 +1012,6 @@ void CdmAdapter::OnSessionClosed(const char* session_id,
session_closed_cb_.Run(std::string(session_id, session_id_size));
}

void CdmAdapter::OnLegacySessionError(const char* session_id,
uint32_t session_id_size,
cdm::Error error,
uint32_t system_code,
const char* error_message,
uint32_t error_message_size) {
// cdm::Host_8 version. Remove when CDM_8 no longer supported.
// https://crbug.com/737296.
DCHECK(task_runner_->BelongsToCurrentThread());
}

void CdmAdapter::SendPlatformChallenge(const char* service_id,
uint32_t service_id_size,
const char* challenge,
Expand Down
21 changes: 0 additions & 21 deletions media/cdm/cdm_adapter.h
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,6 @@ class CdmWrapper;
class MEDIA_EXPORT CdmAdapter : public ContentDecryptionModule,
public CdmContext,
public Decryptor,
public cdm::Host_8,
public cdm::Host_9,
public cdm::Host_10 {
public:
Expand Down Expand Up @@ -154,26 +153,6 @@ class MEDIA_EXPORT CdmAdapter : public ContentDecryptionModule,
void OnInitialized(bool success) override;
cdm::CdmProxy* RequestCdmProxy(cdm::CdmProxyClient* client) override;

// cdm::Host_8 specific implementation.
void OnRejectPromise(uint32_t promise_id,
cdm::Error error,
uint32_t system_code,
const char* error_message,
uint32_t error_message_size) override;
void OnSessionMessage(const char* session_id,
uint32_t session_id_size,
cdm::MessageType message_type,
const char* message,
uint32_t message_size,
const char* legacy_destination_url,
uint32_t legacy_destination_url_size) override;
void OnLegacySessionError(const char* session_id,
uint32_t session_id_size,
cdm::Error error,
uint32_t system_code,
const char* error_message,
uint32_t error_message_size) override;

private:
CdmAdapter(const std::string& key_system,
const url::Origin& security_origin,
Expand Down
97 changes: 2 additions & 95 deletions media/cdm/cdm_wrapper.h
Original file line number Diff line number Diff line change
Expand Up @@ -389,92 +389,7 @@ CdmWrapperImpl<cdm::ContentDecryptionModule_9>::DecryptAndDecodeSamples(
audio_frames);
}

// Specialization for cdm::ContentDecryptionModule_8 methods.
// TODO(crbug.com/737296): Remove when CDM_8 no longer supported.

template <>
bool CdmWrapperImpl<cdm::ContentDecryptionModule_8>::Initialize(
bool allow_distinctive_identifier,
bool allow_persistent_state,
bool /* use_hw_secure_codecs*/) {
cdm_->Initialize(allow_distinctive_identifier, allow_persistent_state);
return false;
}

template <>
bool CdmWrapperImpl<cdm::ContentDecryptionModule_8>::GetStatusForPolicy(
uint32_t /* promise_id */,
cdm::HdcpVersion /* min_hdcp_version */) {
return false;
}

template <>
void CdmWrapperImpl<cdm::ContentDecryptionModule_8>::OnStorageId(
uint32_t version,
const uint8_t* storage_id,
uint32_t storage_id_size) {}

template <>
cdm::Status
CdmWrapperImpl<cdm::ContentDecryptionModule_8>::InitializeAudioDecoder(
const cdm::AudioDecoderConfig_2& audio_decoder_config) {
if (!IsEncryptionSchemeSupportedByLegacyCdms(
audio_decoder_config.encryption_scheme))
return cdm::kInitializationError;

return cdm_->InitializeAudioDecoder(
ToAudioDecoderConfig_1(audio_decoder_config));
}

template <>
cdm::Status
CdmWrapperImpl<cdm::ContentDecryptionModule_8>::InitializeVideoDecoder(
const cdm::VideoDecoderConfig_2& video_decoder_config) {
if (!IsEncryptionSchemeSupportedByLegacyCdms(
video_decoder_config.encryption_scheme))
return cdm::kInitializationError;

return cdm_->InitializeVideoDecoder(
ToVideoDecoderConfig_1(video_decoder_config));
}

template <>
cdm::Status CdmWrapperImpl<cdm::ContentDecryptionModule_8>::Decrypt(
const cdm::InputBuffer_2& encrypted_buffer,
cdm::DecryptedBlock* decrypted_buffer) {
if (!IsEncryptionSchemeSupportedByLegacyCdms(
encrypted_buffer.encryption_scheme))
return cdm::kDecryptError;

return cdm_->Decrypt(ToInputBuffer_1(encrypted_buffer), decrypted_buffer);
}

template <>
cdm::Status
CdmWrapperImpl<cdm::ContentDecryptionModule_8>::DecryptAndDecodeFrame(
const cdm::InputBuffer_2& encrypted_buffer,
cdm::VideoFrame* video_frame) {
if (!IsEncryptionSchemeSupportedByLegacyCdms(
encrypted_buffer.encryption_scheme))
return cdm::kDecryptError;

return cdm_->DecryptAndDecodeFrame(ToInputBuffer_1(encrypted_buffer),
video_frame);
}

template <>
cdm::Status
CdmWrapperImpl<cdm::ContentDecryptionModule_8>::DecryptAndDecodeSamples(
const cdm::InputBuffer_2& encrypted_buffer,
cdm::AudioFrames* audio_frames) {
if (!IsEncryptionSchemeSupportedByLegacyCdms(
encrypted_buffer.encryption_scheme))
return cdm::kDecryptError;

return cdm_->DecryptAndDecodeSamples(ToInputBuffer_1(encrypted_buffer),
audio_frames);
}

// static
CdmWrapper* CdmWrapper::Create(CreateCdmFunc create_cdm_func,
const char* key_system,
uint32_t key_system_size,
Expand All @@ -490,7 +405,7 @@ CdmWrapper* CdmWrapper::Create(CreateCdmFunc create_cdm_func,
// If this check fails, update this function and DCHECK or update
// IsSupportedCdmInterfaceVersion().
// TODO(xhwang): Static assert these at compile time.
const int kMinVersion = cdm::ContentDecryptionModule_8::kVersion;
const int kMinVersion = cdm::ContentDecryptionModule_9::kVersion;
const int kMaxVersion = cdm::ContentDecryptionModule_10::kVersion;
DCHECK(!IsSupportedCdmInterfaceVersion(kMinVersion - 1));
for (int version = kMinVersion; version <= kMaxVersion; ++version)
Expand All @@ -516,14 +431,6 @@ CdmWrapper* CdmWrapper::Create(CreateCdmFunc create_cdm_func,
user_data);
}

// If |cdm_wrapper| is NULL, try to create the CDM using older supported
// versions of the CDM interface here.
if (!cdm_wrapper) {
cdm_wrapper = CdmWrapperImpl<cdm::ContentDecryptionModule_8>::Create(
create_cdm_func, key_system, key_system_size, get_cdm_host_func,
user_data);
}

return cdm_wrapper;
}

Expand Down
2 changes: 0 additions & 2 deletions media/cdm/supported_cdm_versions.cc
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,6 @@ bool IsSupportedCdmInterfaceVersion(int version) {
// Supported versions in decreasing order.
case cdm::ContentDecryptionModule_10::kVersion:
case cdm::ContentDecryptionModule_9::kVersion:
case cdm::ContentDecryptionModule_8::kVersion:
return true;
default:
return false;
Expand All @@ -41,7 +40,6 @@ bool IsSupportedCdmHostVersion(int version) {
// Supported versions in decreasing order.
case cdm::Host_10::kVersion:
case cdm::Host_9::kVersion:
case cdm::Host_8::kVersion:
return true;
default:
return false;
Expand Down

0 comments on commit 778e8cf

Please sign in to comment.