Chromium Code Reviews| OLD | NEW |
|---|---|
| (Empty) | |
| 1 // Copyright 2014 The Chromium Authors. All rights reserved. | |
| 2 // Use of this source code is governed by a BSD-style license that can be | |
| 3 // found in the LICENSE file. | |
| 4 | |
| 5 #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
| |
| 6 #define MEDIA_MOJO_SERVICES_MOJO_CDM_H_ | |
| 7 | |
| 8 #include "base/macros.h" | |
| 9 #include "base/memory/weak_ptr.h" | |
| 10 #include "media/base/media_keys.h" | |
| 11 #include "media/mojo/interfaces/content_decryption_module.mojom.h" | |
| 12 | |
| 13 namespace mojo { | |
| 14 class ServiceProvider; | |
| 15 } | |
| 16 | |
| 17 namespace media { | |
| 18 | |
| 19 // A MediaKeys that proxies to a mojo::ContentDecryptionModule. That | |
| 20 // mojo::ContentDecryptionModule proxies back to the MojoCdm via the | |
| 21 // mojo::ContentDecryptionModuleClient interface. | |
| 22 class MojoCdm : public MediaKeys, public mojo::ContentDecryptionModuleClient { | |
| 23 public: | |
| 24 // |media_renderer_provider| is a ServiceProvider from a connected | |
| 25 // Application that is hosting a mojo::MediaRenderer. | |
| 26 MojoCdm(mojo::ServiceProvider* media_renderer_provider, | |
| 27 const SessionMessageCB& session_message_cb, | |
| 28 const SessionReadyCB& session_ready_cb, | |
| 29 const SessionClosedCB& session_closed_cb, | |
| 30 const SessionErrorCB& session_error_cb, | |
| 31 const SessionKeysChangeCB& session_keys_change_cb, | |
| 32 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.
| |
| 33 ~MojoCdm() final; | |
| 34 | |
| 35 // MediaKeys implementation. | |
| 36 void SetServerCertificate(const uint8* certificate_data, | |
| 37 int certificate_data_length, | |
| 38 scoped_ptr<SimpleCdmPromise> promise) final; | |
| 39 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.
| |
| 40 const uint8* init_data, | |
| 41 int init_data_length, | |
| 42 SessionType session_type, | |
| 43 scoped_ptr<NewSessionCdmPromise> promise) final; | |
| 44 void LoadSession(const std::string& session_id, | |
| 45 scoped_ptr<NewSessionCdmPromise> promise) final; | |
| 46 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
| |
| 47 const uint8* response, | |
| 48 int response_length, | |
| 49 scoped_ptr<SimpleCdmPromise> promise) final; | |
| 50 void CloseSession(const std::string& session_id, | |
| 51 scoped_ptr<SimpleCdmPromise> promise) final; | |
| 52 void RemoveSession(const std::string& session_id, | |
| 53 scoped_ptr<SimpleCdmPromise> promise) final; | |
| 54 void GetUsableKeyIds(const std::string& session_id, | |
| 55 scoped_ptr<KeyIdsPromise> promise) final; | |
| 56 CdmContext* GetCdmContext() final; | |
| 57 | |
| 58 private: | |
| 59 // mojo::ContentDecryptionModuleClient implementation. | |
| 60 void OnSessionMessage(const mojo::String& session_id, | |
| 61 mojo::Array<uint8_t> message, | |
| 62 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
| |
| 63 void OnSessionReady(const mojo::String& session_id) final; | |
| 64 void OnSessionClosed(const mojo::String& session_id) final; | |
| 65 void OnSessionError(const mojo::String& session_id, | |
| 66 mojo::CdmException exception_code, | |
| 67 uint32_t system_code, | |
| 68 const mojo::String& error_message) final; | |
| 69 void OnSessionKeysChange(const mojo::String& session_id, | |
| 70 bool has_additional_usable_key) final; | |
| 71 void OnSessionExpirationUpdate(const mojo::String& session_id, | |
| 72 int64_t new_expiry_time_usec) final; | |
| 73 | |
| 74 // Callbacks to handle CDM promises. | |
| 75 void OnResponse(scoped_ptr<SimpleCdmPromise> promise, | |
| 76 mojo::CdmPromiseResultPtr result); | |
| 77 void OnNewSession(scoped_ptr<NewSessionCdmPromise> promise, | |
| 78 mojo::CdmPromiseResultPtr result, | |
| 79 mojo::String session_id); | |
| 80 void OnKeyIds(scoped_ptr<KeyIdsPromise> promise, | |
| 81 mojo::CdmPromiseResultPtr result, | |
| 82 mojo::Array<mojo::Array<uint8_t>> key_ids); | |
| 83 | |
| 84 mojo::ContentDecryptionModulePtr mojo_cdm_ptr_; | |
| 85 | |
| 86 // Callbacks for firing session events. | |
| 87 SessionMessageCB session_message_cb_; | |
| 88 SessionReadyCB session_ready_cb_; | |
| 89 SessionClosedCB session_closed_cb_; | |
| 90 SessionErrorCB session_error_cb_; | |
| 91 SessionKeysChangeCB session_keys_change_cb_; | |
| 92 SessionExpirationUpdateCB session_expiration_update_cb_; | |
| 93 | |
| 94 base::WeakPtrFactory<MojoCdm> weak_factory_; | |
| 95 | |
| 96 DISALLOW_COPY_AND_ASSIGN(MojoCdm); | |
| 97 }; | |
| 98 | |
| 99 } // namespace media | |
| 100 | |
| 101 #endif // MEDIA_MOJO_SERVICES_MOJO_CDM_H_ | |
| OLD | NEW |