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

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

Issue 763883006: Add Mojo CDM Service. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: More updates. Created 6 years 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
(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_
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 #include "media/mojo/services/mojo_type_trait.h"
13
14 namespace mojo {
15 class ServiceProvider;
16 }
17
18 namespace media {
19
20 // A MediaKeys that proxies to a mojo::ContentDecryptionModule. That
21 // mojo::ContentDecryptionModule proxies back to the MojoCdm via the
22 // mojo::ContentDecryptionModuleClient interface.
23 class MojoCdm : public MediaKeys, public mojo::ContentDecryptionModuleClient {
24 public:
25 // |media_renderer_provider| is a ServiceProvider from a connected
26 // Application that is hosting a mojo::MediaRenderer.
27 MojoCdm(mojo::ContentDecryptionModulePtr remote_cdm,
28 const SessionMessageCB& session_message_cb,
29 const SessionReadyCB& session_ready_cb,
30 const SessionClosedCB& session_closed_cb,
31 const SessionErrorCB& session_error_cb,
32 const SessionKeysChangeCB& session_keys_change_cb,
33 const SessionExpirationUpdateCB& session_expiration_update_cb);
34 ~MojoCdm() final;
35
36 // MediaKeys implementation.
37 void SetServerCertificate(const uint8* certificate_data,
38 int certificate_data_length,
39 scoped_ptr<SimpleCdmPromise> promise) final;
40 void CreateSession(const std::string& init_data_type,
41 const uint8* init_data,
42 int init_data_length,
43 SessionType session_type,
44 scoped_ptr<NewSessionCdmPromise> promise) final;
45 void LoadSession(const std::string& session_id,
46 scoped_ptr<NewSessionCdmPromise> promise) final;
47 void UpdateSession(const std::string& session_id,
48 const uint8* response,
49 int response_length,
50 scoped_ptr<SimpleCdmPromise> promise) final;
51 void CloseSession(const std::string& session_id,
52 scoped_ptr<SimpleCdmPromise> promise) final;
53 void RemoveSession(const std::string& session_id,
54 scoped_ptr<SimpleCdmPromise> promise) final;
55 void GetUsableKeyIds(const std::string& session_id,
56 scoped_ptr<KeyIdsPromise> promise) final;
57 CdmContext* GetCdmContext() final;
58
59 private:
60 // mojo::ContentDecryptionModuleClient implementation.
61 void OnSessionMessage(const mojo::String& session_id,
62 mojo::Array<uint8_t> message,
63 const mojo::String& destination_url) final;
64 void OnSessionReady(const mojo::String& session_id) final;
65 void OnSessionClosed(const mojo::String& session_id) final;
66 void OnSessionError(const mojo::String& session_id,
67 mojo::CdmException exception,
68 uint32_t system_code,
69 const mojo::String& error_message) final;
70 void OnSessionKeysChange(const mojo::String& session_id,
71 bool has_additional_usable_key) final;
72 void OnSessionExpirationUpdate(const mojo::String& session_id,
73 int64_t new_expiry_time_usec) final;
74
75 // Callbacks to handle CDM promises.
76 template <typename... T>
77 void OnResponse(scoped_ptr<CdmPromiseTemplate<T...>> promise,
ddorwin 2014/12/12 19:25:13 "Response" could be misleading since this handles
xhwang 2014/12/12 23:15:44 Done.
78 mojo::CdmPromiseResultPtr result,
79 typename MojoTypeTrait<T>::MojoType... args);
80
81 mojo::ContentDecryptionModulePtr remote_cdm_;
82
83 // Callbacks for firing session events.
84 SessionMessageCB session_message_cb_;
85 SessionReadyCB session_ready_cb_;
86 SessionClosedCB session_closed_cb_;
87 SessionErrorCB session_error_cb_;
88 SessionKeysChangeCB session_keys_change_cb_;
89 SessionExpirationUpdateCB session_expiration_update_cb_;
90
91 base::WeakPtrFactory<MojoCdm> weak_factory_;
92
93 DISALLOW_COPY_AND_ASSIGN(MojoCdm);
94 };
95
96 } // namespace media
97
98 #endif // MEDIA_MOJO_SERVICES_MOJO_CDM_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698