Chromium Code Reviews| Index: media/mojo/services/mojo_cdm.h |
| diff --git a/media/mojo/services/mojo_cdm.h b/media/mojo/services/mojo_cdm.h |
| new file mode 100644 |
| index 0000000000000000000000000000000000000000..dcfdd5fa1092280ad99e375d47fa731a66d6954a |
| --- /dev/null |
| +++ b/media/mojo/services/mojo_cdm.h |
| @@ -0,0 +1,101 @@ |
| +// Copyright 2014 The Chromium Authors. All rights reserved. |
| +// Use of this source code is governed by a BSD-style license that can be |
| +// found in the LICENSE file. |
| + |
| +#ifndef MEDIA_MOJO_SERVICES_MOJO_CDM_H_ |
|
ddorwin
2014/12/08 23:46:49
It seems like this should be in media/ or media/mo
xhwang
2014/12/10 04:59:16
Acked. I am still in the process of discussing nam
|
| +#define MEDIA_MOJO_SERVICES_MOJO_CDM_H_ |
| + |
| +#include "base/macros.h" |
| +#include "base/memory/weak_ptr.h" |
| +#include "media/base/media_keys.h" |
| +#include "media/mojo/interfaces/content_decryption_module.mojom.h" |
| + |
| +namespace mojo { |
| +class ServiceProvider; |
| +} |
| + |
| +namespace media { |
| + |
| +// A MediaKeys that proxies to a mojo::ContentDecryptionModule. That |
| +// mojo::ContentDecryptionModule proxies back to the MojoCdm via the |
| +// mojo::ContentDecryptionModuleClient interface. |
| +class MojoCdm : public MediaKeys, public mojo::ContentDecryptionModuleClient { |
| + public: |
| + // |media_renderer_provider| is a ServiceProvider from a connected |
| + // Application that is hosting a mojo::MediaRenderer. |
| + MojoCdm(mojo::ServiceProvider* media_renderer_provider, |
| + const SessionMessageCB& session_message_cb, |
| + const SessionReadyCB& session_ready_cb, |
| + const SessionClosedCB& session_closed_cb, |
| + const SessionErrorCB& session_error_cb, |
| + const SessionKeysChangeCB& session_keys_change_cb, |
| + const SessionExpirationUpdateCB& session_expiration_update_cb); |
|
xhwang
2014/12/04 02:11:22
ddorwin: This makes me think whether we should als
ddorwin
2014/12/08 23:46:49
SGTM. When we originally implemented this, we were
xhwang
2014/12/10 04:59:16
Acknowledged.
|
| + ~MojoCdm() final; |
| + |
| + // MediaKeys implementation. |
| + void SetServerCertificate(const uint8* certificate_data, |
| + int certificate_data_length, |
| + scoped_ptr<SimpleCdmPromise> promise) final; |
| + void CreateSession(const std::string& init_data_type, |
|
ddorwin
2014/12/08 23:46:49
See the comments about creating sessions in the CD
xhwang
2014/12/10 04:59:16
Acknowledged.
|
| + const uint8* init_data, |
| + int init_data_length, |
| + SessionType session_type, |
| + scoped_ptr<NewSessionCdmPromise> promise) final; |
| + void LoadSession(const std::string& session_id, |
| + scoped_ptr<NewSessionCdmPromise> promise) final; |
| + void UpdateSession(const std::string& session_id, |
|
ddorwin
2014/12/08 23:46:49
We _could_ reconsider whether to have session obje
xhwang
2014/12/10 04:59:16
Agreed that it's worth considering after we drop t
|
| + const uint8* response, |
| + int response_length, |
| + scoped_ptr<SimpleCdmPromise> promise) final; |
| + void CloseSession(const std::string& session_id, |
| + scoped_ptr<SimpleCdmPromise> promise) final; |
| + void RemoveSession(const std::string& session_id, |
| + scoped_ptr<SimpleCdmPromise> promise) final; |
| + void GetUsableKeyIds(const std::string& session_id, |
| + scoped_ptr<KeyIdsPromise> promise) final; |
| + CdmContext* GetCdmContext() final; |
| + |
| + private: |
| + // mojo::ContentDecryptionModuleClient implementation. |
| + void OnSessionMessage(const mojo::String& session_id, |
| + mojo::Array<uint8_t> message, |
| + const mojo::String& destination_url) final; |
|
ddorwin
2014/12/08 23:46:49
This will need CDM_7 updates.
xhwang
2014/12/10 04:59:16
I'll keep working on this until media::MeidaKeys i
|
| + void OnSessionReady(const mojo::String& session_id) final; |
| + void OnSessionClosed(const mojo::String& session_id) final; |
| + void OnSessionError(const mojo::String& session_id, |
| + mojo::CdmException exception_code, |
| + uint32_t system_code, |
| + const mojo::String& error_message) final; |
| + void OnSessionKeysChange(const mojo::String& session_id, |
| + bool has_additional_usable_key) final; |
| + void OnSessionExpirationUpdate(const mojo::String& session_id, |
| + int64_t new_expiry_time_usec) final; |
| + |
| + // Callbacks to handle CDM promises. |
| + void OnResponse(scoped_ptr<SimpleCdmPromise> promise, |
| + mojo::CdmPromiseResultPtr result); |
| + void OnNewSession(scoped_ptr<NewSessionCdmPromise> promise, |
| + mojo::CdmPromiseResultPtr result, |
| + mojo::String session_id); |
| + void OnKeyIds(scoped_ptr<KeyIdsPromise> promise, |
| + mojo::CdmPromiseResultPtr result, |
| + mojo::Array<mojo::Array<uint8_t>> key_ids); |
| + |
| + mojo::ContentDecryptionModulePtr mojo_cdm_ptr_; |
| + |
| + // Callbacks for firing session events. |
| + SessionMessageCB session_message_cb_; |
| + SessionReadyCB session_ready_cb_; |
| + SessionClosedCB session_closed_cb_; |
| + SessionErrorCB session_error_cb_; |
| + SessionKeysChangeCB session_keys_change_cb_; |
| + SessionExpirationUpdateCB session_expiration_update_cb_; |
| + |
| + base::WeakPtrFactory<MojoCdm> weak_factory_; |
| + |
| + DISALLOW_COPY_AND_ASSIGN(MojoCdm); |
| +}; |
| + |
| +} // namespace media |
| + |
| +#endif // MEDIA_MOJO_SERVICES_MOJO_CDM_H_ |