diff options
author | jrummell <jrummell@chromium.org> | 2015-01-08 10:43:07 -0800 |
---|---|---|
committer | Commit bot <commit-bot@chromium.org> | 2015-01-08 18:44:21 +0000 |
commit | 3d50dc21e899735f9c99596fc182552c6871c318 (patch) | |
tree | f0cfbaf1b818e03b2774f29e9318328de77921e6 /media/mojo | |
parent | 0934df74b30f1b6eb5036dbc2a01b4bf4b668c28 (diff) | |
download | chromium_src-3d50dc21e899735f9c99596fc182552c6871c318.zip chromium_src-3d50dc21e899735f9c99596fc182552c6871c318.tar.gz chromium_src-3d50dc21e899735f9c99596fc182552c6871c318.tar.bz2 |
Pass key_information on SessionKeysChange message
The event now includes a list of key ids and their associated
status.
BUG=428384
TEST=existing EME tests pass
Review URL: https://codereview.chromium.org/833963003
Cr-Commit-Position: refs/heads/master@{#310543}
Diffstat (limited to 'media/mojo')
-rw-r--r-- | media/mojo/interfaces/content_decryption_module.mojom | 22 | ||||
-rw-r--r-- | media/mojo/services/media_type_converters.cc | 36 | ||||
-rw-r--r-- | media/mojo/services/media_type_converters.h | 13 | ||||
-rw-r--r-- | media/mojo/services/mojo_cdm.cc | 17 | ||||
-rw-r--r-- | media/mojo/services/mojo_cdm.h | 6 | ||||
-rw-r--r-- | media/mojo/services/mojo_cdm_service.cc | 12 | ||||
-rw-r--r-- | media/mojo/services/mojo_cdm_service.h | 3 |
7 files changed, 99 insertions, 10 deletions
diff --git a/media/mojo/interfaces/content_decryption_module.mojom b/media/mojo/interfaces/content_decryption_module.mojom index e462f7a..dac6d12 100644 --- a/media/mojo/interfaces/content_decryption_module.mojom +++ b/media/mojo/interfaces/content_decryption_module.mojom @@ -19,6 +19,16 @@ enum CdmException { OUTPUT_ERROR }; +// Transport layer of media::CdmKeyInformation::KeyStatus (see +// media/base/cdm_key_information.h). This is used for indicating the status +// of a specific key ID. +enum CdmKeyStatus { + USABLE, + INTERNAL_ERROR, + EXPIRED, + OUTPUT_NOT_ALLOWED +}; + // Transport layer of media::CdmPromise (see media/base/cdm_promise.h). // - When |success| is true, the promise is resolved and all other fields should // be ignored. @@ -31,6 +41,15 @@ struct CdmPromiseResult { string error_message; }; +// Transport layer of media::CdmKeyInformation (see +// media/base/cdm_key_information.h). It is used to specify a key_id and it's +// associated status. +struct CdmKeyInformation { + array<uint8> key_id; + CdmKeyStatus status; + uint32 system_code; +}; + // An interface that represents a CDM in the Encrypted Media Extensions (EME) // spec (https://w3c.github.io/encrypted-media/). See media/base/media_keys.h. [Client=ContentDecryptionModuleClient] @@ -98,7 +117,8 @@ interface ContentDecryptionModuleClient { OnSessionError(string session_id, CdmException exception, uint32 system_code, string error_message); - OnSessionKeysChange(string session_id, bool has_additional_usable_key); + OnSessionKeysChange(string session_id, bool has_additional_usable_key, + array<CdmKeyInformation> key_information); OnSessionExpirationUpdate(string session_id, int64 new_expiry_time_usec); }; diff --git a/media/mojo/services/media_type_converters.cc b/media/mojo/services/media_type_converters.cc index b037f98..077645e 100644 --- a/media/mojo/services/media_type_converters.cc +++ b/media/mojo/services/media_type_converters.cc @@ -6,6 +6,7 @@ #include "media/base/audio_decoder_config.h" #include "media/base/buffering_state.h" +#include "media/base/cdm_key_information.h" #include "media/base/decoder_buffer.h" #include "media/base/decrypt_config.h" #include "media/base/demuxer_stream.h" @@ -233,6 +234,17 @@ ASSERT_CDM_EXCEPTION(OUTPUT_ERROR); ASSERT_CDM_SESSION_TYPE(TEMPORARY_SESSION); ASSERT_CDM_SESSION_TYPE(PERSISTENT_SESSION); +// CDM Key Status +#define ASSERT_CDM_KEY_STATUS(value) \ + static_assert(media::CdmKeyInformation::value == \ + static_cast<media::CdmKeyInformation::KeyStatus>( \ + CDM_KEY_STATUS_##value), \ + "Mismatched CDM Key Status") +ASSERT_CDM_KEY_STATUS(USABLE); +ASSERT_CDM_KEY_STATUS(INTERNAL_ERROR); +ASSERT_CDM_KEY_STATUS(EXPIRED); +ASSERT_CDM_KEY_STATUS(OUTPUT_NOT_ALLOWED); + // static SubsampleEntryPtr TypeConverter<SubsampleEntryPtr, media::SubsampleEntry>::Convert( @@ -426,4 +438,28 @@ TypeConverter<media::VideoDecoderConfig, VideoDecoderConfigPtr>::Convert( return config; } +// static +CdmKeyInformationPtr +TypeConverter<CdmKeyInformationPtr, media::CdmKeyInformation>::Convert( + const media::CdmKeyInformation& input) { + CdmKeyInformationPtr info(CdmKeyInformation::New()); + std::vector<uint8_t> key_id_copy(input.key_id); + info->key_id.Swap(&key_id_copy); + info->status = static_cast<CdmKeyStatus>(input.status); + info->system_code = input.system_code; + return info.Pass(); +} + +// static +scoped_ptr<media::CdmKeyInformation> TypeConverter< + scoped_ptr<media::CdmKeyInformation>, + CdmKeyInformationPtr>::Convert(const CdmKeyInformationPtr& input) { + scoped_ptr<media::CdmKeyInformation> info(new media::CdmKeyInformation); + info->key_id = input->key_id.storage(); + info->status = + static_cast<media::CdmKeyInformation::KeyStatus>(input->status); + info->system_code = input->system_code; + return info.Pass(); +} + } // namespace mojo diff --git a/media/mojo/services/media_type_converters.h b/media/mojo/services/media_type_converters.h index 7332bf9..14a4562 100644 --- a/media/mojo/services/media_type_converters.h +++ b/media/mojo/services/media_type_converters.h @@ -7,6 +7,7 @@ #include "base/memory/ref_counted.h" #include "base/memory/scoped_ptr.h" +#include "media/mojo/interfaces/content_decryption_module.mojom.h" #include "media/mojo/interfaces/media_types.mojom.h" namespace media { @@ -15,6 +16,7 @@ class VideoDecoderConfig; class DecoderBuffer; class DecryptConfig; struct SubsampleEntry; +struct CdmKeyInformation; } namespace mojo { @@ -69,6 +71,17 @@ struct TypeConverter<media::VideoDecoderConfig, VideoDecoderConfigPtr> { static media::VideoDecoderConfig Convert(const VideoDecoderConfigPtr& input); }; +template <> +struct TypeConverter<CdmKeyInformationPtr, media::CdmKeyInformation> { + static CdmKeyInformationPtr Convert(const media::CdmKeyInformation& input); +}; +template <> +struct TypeConverter<scoped_ptr<media::CdmKeyInformation>, + CdmKeyInformationPtr> { + static scoped_ptr<media::CdmKeyInformation> Convert( + const CdmKeyInformationPtr& input); +}; + } // namespace mojo #endif // MEDIA_MOJO_SERVICES_MEDIA_TYPE_CONVERTERS_H_ diff --git a/media/mojo/services/mojo_cdm.cc b/media/mojo/services/mojo_cdm.cc index a857afe2..e0a8652 100644 --- a/media/mojo/services/mojo_cdm.cc +++ b/media/mojo/services/mojo_cdm.cc @@ -6,7 +6,9 @@ #include "base/bind.h" #include "base/bind_helpers.h" +#include "media/base/cdm_key_information.h" #include "media/base/cdm_promise.h" +#include "media/mojo/services/media_type_converters.h" #include "mojo/public/cpp/application/connect.h" #include "mojo/public/cpp/bindings/interface_impl.h" #include "mojo/public/interfaces/application/service_provider.mojom.h" @@ -142,9 +144,18 @@ void MojoCdm::OnSessionError(const mojo::String& session_id, system_code, error_message); } -void MojoCdm::OnSessionKeysChange(const mojo::String& session_id, - bool has_additional_usable_key) { - session_keys_change_cb_.Run(session_id, has_additional_usable_key); +void MojoCdm::OnSessionKeysChange( + const mojo::String& session_id, + bool has_additional_usable_key, + mojo::Array<mojo::CdmKeyInformationPtr> keys_info) { + media::CdmKeysInfo key_data; + key_data.reserve(keys_info.size()); + for (size_t i = 0; i < keys_info.size(); ++i) { + key_data.push_back( + keys_info[i].To<scoped_ptr<media::CdmKeyInformation>>().release()); + } + session_keys_change_cb_.Run(session_id, has_additional_usable_key, + key_data.Pass()); } void MojoCdm::OnSessionExpirationUpdate(const mojo::String& session_id, diff --git a/media/mojo/services/mojo_cdm.h b/media/mojo/services/mojo_cdm.h index b644dd9..8e9744c 100644 --- a/media/mojo/services/mojo_cdm.h +++ b/media/mojo/services/mojo_cdm.h @@ -64,8 +64,10 @@ class MojoCdm : public MediaKeys, public mojo::ContentDecryptionModuleClient { mojo::CdmException exception, uint32_t system_code, const mojo::String& error_message) final; - void OnSessionKeysChange(const mojo::String& session_id, - bool has_additional_usable_key) final; + void OnSessionKeysChange( + const mojo::String& session_id, + bool has_additional_usable_key, + mojo::Array<mojo::CdmKeyInformationPtr> keys_info) final; void OnSessionExpirationUpdate(const mojo::String& session_id, int64_t new_expiry_time_usec) final; diff --git a/media/mojo/services/mojo_cdm_service.cc b/media/mojo/services/mojo_cdm_service.cc index 3f83c39..bdf0621 100644 --- a/media/mojo/services/mojo_cdm_service.cc +++ b/media/mojo/services/mojo_cdm_service.cc @@ -5,8 +5,10 @@ #include "media/mojo/services/mojo_cdm_service.h" #include "base/bind.h" +#include "media/base/cdm_key_information.h" #include "media/base/key_systems.h" #include "media/cdm/aes_decryptor.h" +#include "media/mojo/services/media_type_converters.h" #include "media/mojo/services/mojo_cdm_promise.h" #include "mojo/common/common_type_converters.h" @@ -14,7 +16,6 @@ namespace media { typedef MojoCdmPromise<> SimpleMojoCdmPromise; typedef MojoCdmPromise<std::string> NewSessionMojoCdmPromise; -typedef MojoCdmPromise<std::vector<std::vector<uint8_t>>> KeyIdsMojoCdmPromise; MojoCdmService::MojoCdmService(const mojo::String& key_system) : weak_factory_(this) { @@ -111,8 +112,13 @@ void MojoCdmService::OnSessionMessage(const std::string& session_id, } void MojoCdmService::OnSessionKeysChange(const std::string& session_id, - bool has_additional_usable_key) { - client()->OnSessionKeysChange(session_id, has_additional_usable_key); + bool has_additional_usable_key, + CdmKeysInfo keys_info) { + mojo::Array<mojo::CdmKeyInformationPtr> keys_data; + for (const auto& key : keys_info) + keys_data.push_back(mojo::CdmKeyInformation::From(*key)); + client()->OnSessionKeysChange(session_id, has_additional_usable_key, + keys_data.Pass()); } void MojoCdmService::OnSessionExpirationUpdate( diff --git a/media/mojo/services/mojo_cdm_service.h b/media/mojo/services/mojo_cdm_service.h index 17356c9..69bdb5b 100644 --- a/media/mojo/services/mojo_cdm_service.h +++ b/media/mojo/services/mojo_cdm_service.h @@ -54,7 +54,8 @@ class MojoCdmService const std::vector<uint8_t>& message, const GURL& destination_url); void OnSessionKeysChange(const std::string& session_id, - bool has_additional_usable_key); + bool has_additional_usable_key, + CdmKeysInfo keys_info); void OnSessionExpirationUpdate(const std::string& session_id, const base::Time& new_expiry_time); void OnSessionClosed(const std::string& session_id); |