Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(197)

Side by Side Diff: media/mojo/services/mojo_cdm.h

Issue 840473002: media: Support creation and SetCdm() for mojo based CDM. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 5 years, 11 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
1 // Copyright 2014 The Chromium Authors. All rights reserved. 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 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #ifndef MEDIA_MOJO_SERVICES_MOJO_CDM_H_ 5 #ifndef MEDIA_MOJO_SERVICES_MOJO_CDM_H_
6 #define MEDIA_MOJO_SERVICES_MOJO_CDM_H_ 6 #define MEDIA_MOJO_SERVICES_MOJO_CDM_H_
7 7
8 #include "base/macros.h" 8 #include "base/macros.h"
9 #include "base/memory/weak_ptr.h" 9 #include "base/memory/weak_ptr.h"
10 #include "media/base/cdm_context.h"
10 #include "media/base/media_keys.h" 11 #include "media/base/media_keys.h"
11 #include "media/mojo/interfaces/content_decryption_module.mojom.h" 12 #include "media/mojo/interfaces/content_decryption_module.mojom.h"
12 #include "media/mojo/services/mojo_type_trait.h" 13 #include "media/mojo/services/mojo_type_trait.h"
13 14
14 namespace mojo { 15 namespace mojo {
15 class ServiceProvider; 16 class ServiceProvider;
16 } 17 }
17 18
18 namespace media { 19 namespace media {
19 20
20 // A MediaKeys that proxies to a mojo::ContentDecryptionModule. That 21 // A MediaKeys that proxies to a mojo::ContentDecryptionModule. That
21 // mojo::ContentDecryptionModule proxies back to the MojoCdm via the 22 // mojo::ContentDecryptionModule proxies back to the MojoCdm via the
22 // mojo::ContentDecryptionModuleClient interface. 23 // mojo::ContentDecryptionModuleClient interface.
23 class MojoCdm : public MediaKeys, public mojo::ContentDecryptionModuleClient { 24 class MojoCdm : public MediaKeys,
25 public CdmContext,
26 public mojo::ContentDecryptionModuleClient {
24 public: 27 public:
25 // |media_renderer_provider| is a ServiceProvider from a connected 28 // |media_renderer_provider| is a ServiceProvider from a connected
26 // Application that is hosting a mojo::MediaRenderer. 29 // Application that is hosting a mojo::MediaRenderer.
27 MojoCdm(mojo::ContentDecryptionModulePtr remote_cdm, 30 MojoCdm(mojo::ContentDecryptionModulePtr remote_cdm,
31 int32_t cdm_id,
28 const SessionMessageCB& session_message_cb, 32 const SessionMessageCB& session_message_cb,
29 const SessionClosedCB& session_closed_cb, 33 const SessionClosedCB& session_closed_cb,
30 const SessionErrorCB& session_error_cb, 34 const SessionErrorCB& session_error_cb,
31 const SessionKeysChangeCB& session_keys_change_cb, 35 const SessionKeysChangeCB& session_keys_change_cb,
32 const SessionExpirationUpdateCB& session_expiration_update_cb); 36 const SessionExpirationUpdateCB& session_expiration_update_cb);
33 ~MojoCdm() final; 37 ~MojoCdm() final;
34 38
35 // MediaKeys implementation. 39 // MediaKeys implementation.
36 void SetServerCertificate(const uint8_t* certificate_data, 40 void SetServerCertificate(const uint8_t* certificate_data,
37 int certificate_data_length, 41 int certificate_data_length,
38 scoped_ptr<SimpleCdmPromise> promise) final; 42 scoped_ptr<SimpleCdmPromise> promise) final;
39 void CreateSession(const std::string& init_data_type, 43 void CreateSession(const std::string& init_data_type,
40 const uint8_t* init_data, 44 const uint8_t* init_data,
41 int init_data_length, 45 int init_data_length,
42 SessionType session_type, 46 SessionType session_type,
43 scoped_ptr<NewSessionCdmPromise> promise) final; 47 scoped_ptr<NewSessionCdmPromise> promise) final;
44 void LoadSession(const std::string& session_id, 48 void LoadSession(const std::string& session_id,
45 scoped_ptr<NewSessionCdmPromise> promise) final; 49 scoped_ptr<NewSessionCdmPromise> promise) final;
46 void UpdateSession(const std::string& session_id, 50 void UpdateSession(const std::string& session_id,
47 const uint8_t* response, 51 const uint8_t* response,
48 int response_length, 52 int response_length,
49 scoped_ptr<SimpleCdmPromise> promise) final; 53 scoped_ptr<SimpleCdmPromise> promise) final;
50 void CloseSession(const std::string& session_id, 54 void CloseSession(const std::string& session_id,
51 scoped_ptr<SimpleCdmPromise> promise) final; 55 scoped_ptr<SimpleCdmPromise> promise) final;
52 void RemoveSession(const std::string& session_id, 56 void RemoveSession(const std::string& session_id,
53 scoped_ptr<SimpleCdmPromise> promise) final; 57 scoped_ptr<SimpleCdmPromise> promise) final;
54 CdmContext* GetCdmContext() final; 58 CdmContext* GetCdmContext() final;
55 59
60 // CdmContext implementation.
61 media::Decryptor* GetDecryptor() final;
62 int GetCdmId() const final;
63
56 private: 64 private:
57 // mojo::ContentDecryptionModuleClient implementation. 65 // mojo::ContentDecryptionModuleClient implementation.
58 void OnSessionMessage(const mojo::String& session_id, 66 void OnSessionMessage(const mojo::String& session_id,
59 mojo::Array<uint8_t> message, 67 mojo::Array<uint8_t> message,
60 const mojo::String& destination_url) final; 68 const mojo::String& destination_url) final;
61 void OnSessionClosed(const mojo::String& session_id) final; 69 void OnSessionClosed(const mojo::String& session_id) final;
62 void OnSessionError(const mojo::String& session_id, 70 void OnSessionError(const mojo::String& session_id,
63 mojo::CdmException exception, 71 mojo::CdmException exception,
64 uint32_t system_code, 72 uint32_t system_code,
65 const mojo::String& error_message) final; 73 const mojo::String& error_message) final;
66 void OnSessionKeysChange(const mojo::String& session_id, 74 void OnSessionKeysChange(const mojo::String& session_id,
67 bool has_additional_usable_key) final; 75 bool has_additional_usable_key) final;
68 void OnSessionExpirationUpdate(const mojo::String& session_id, 76 void OnSessionExpirationUpdate(const mojo::String& session_id,
69 int64_t new_expiry_time_usec) final; 77 int64_t new_expiry_time_usec) final;
70 78
71 // Callbacks to handle CDM promises. 79 // Callbacks to handle CDM promises.
72 template <typename... T> 80 template <typename... T>
73 void OnPromiseResult(scoped_ptr<CdmPromiseTemplate<T...>> promise, 81 void OnPromiseResult(scoped_ptr<CdmPromiseTemplate<T...>> promise,
74 mojo::CdmPromiseResultPtr result, 82 mojo::CdmPromiseResultPtr result,
75 typename MojoTypeTrait<T>::MojoType... args); 83 typename MojoTypeTrait<T>::MojoType... args);
76 84
77 mojo::ContentDecryptionModulePtr remote_cdm_; 85 mojo::ContentDecryptionModulePtr remote_cdm_;
78 86
87 const int32_t cdm_id_;
88
79 // Callbacks for firing session events. 89 // Callbacks for firing session events.
80 SessionMessageCB session_message_cb_; 90 SessionMessageCB session_message_cb_;
81 SessionClosedCB session_closed_cb_; 91 SessionClosedCB session_closed_cb_;
82 SessionErrorCB session_error_cb_; 92 SessionErrorCB session_error_cb_;
83 SessionKeysChangeCB session_keys_change_cb_; 93 SessionKeysChangeCB session_keys_change_cb_;
84 SessionExpirationUpdateCB session_expiration_update_cb_; 94 SessionExpirationUpdateCB session_expiration_update_cb_;
85 95
86 base::WeakPtrFactory<MojoCdm> weak_factory_; 96 base::WeakPtrFactory<MojoCdm> weak_factory_;
87 97
88 DISALLOW_COPY_AND_ASSIGN(MojoCdm); 98 DISALLOW_COPY_AND_ASSIGN(MojoCdm);
89 }; 99 };
90 100
91 } // namespace media 101 } // namespace media
92 102
93 #endif // MEDIA_MOJO_SERVICES_MOJO_CDM_H_ 103 #endif // MEDIA_MOJO_SERVICES_MOJO_CDM_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698