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

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

Issue 2426813002: EME: Close existing sessions on CDM failure (Closed)
Patch Set: rename result (+rebase) Created 4 years, 1 month 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
« no previous file with comments | « media/base/cdm_session_tracker.cc ('k') | media/mojo/clients/mojo_cdm.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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_CLIENTS_MOJO_CDM_H_ 5 #ifndef MEDIA_MOJO_CLIENTS_MOJO_CDM_H_
6 #define MEDIA_MOJO_CLIENTS_MOJO_CDM_H_ 6 #define MEDIA_MOJO_CLIENTS_MOJO_CDM_H_
7 7
8 #include <stdint.h> 8 #include <stdint.h>
9 9
10 #include <memory> 10 #include <memory>
11 #include <utility> 11 #include <utility>
12 #include <vector> 12 #include <vector>
13 13
14 #include "base/macros.h" 14 #include "base/macros.h"
15 #include "base/memory/weak_ptr.h" 15 #include "base/memory/weak_ptr.h"
16 #include "base/synchronization/lock.h" 16 #include "base/synchronization/lock.h"
17 #include "base/threading/thread_checker.h" 17 #include "base/threading/thread_checker.h"
18 #include "media/base/cdm_context.h" 18 #include "media/base/cdm_context.h"
19 #include "media/base/cdm_initialized_promise.h" 19 #include "media/base/cdm_initialized_promise.h"
20 #include "media/base/cdm_session_tracker.h"
20 #include "media/base/media_keys.h" 21 #include "media/base/media_keys.h"
21 #include "media/mojo/interfaces/content_decryption_module.mojom.h" 22 #include "media/mojo/interfaces/content_decryption_module.mojom.h"
22 #include "mojo/public/cpp/bindings/binding.h" 23 #include "mojo/public/cpp/bindings/binding.h"
23 24
24 namespace base { 25 namespace base {
25 class SingleThreadTaskRunner; 26 class SingleThreadTaskRunner;
26 } 27 }
27 28
28 namespace media { 29 namespace media {
29 30
30 class MojoDecryptor; 31 class MojoDecryptor;
31 32
32 // A MediaKeys that proxies to a mojom::ContentDecryptionModule. That 33 // A MediaKeys that proxies to a mojom::ContentDecryptionModule. That
33 // mojom::ContentDecryptionModule proxies back to the MojoCdm via the 34 // mojom::ContentDecryptionModule proxies back to the MojoCdm via the
34 // mojom::ContentDecryptionModuleClient interface. 35 // mojom::ContentDecryptionModuleClient interface.
35 class MojoCdm : public MediaKeys, 36 class MojoCdm : public MediaKeys,
36 public CdmContext, 37 public CdmContext,
37 public mojom::ContentDecryptionModuleClient { 38 public mojom::ContentDecryptionModuleClient {
38 public: 39 public:
39 using MessageType = MediaKeys::MessageType; 40 using MessageType = MediaKeys::MessageType;
40 41
41 static void Create( 42 static void Create(
42 const std::string& key_system, 43 const std::string& key_system,
43 const GURL& security_origin, 44 const GURL& security_origin,
44 const media::CdmConfig& cdm_config, 45 const CdmConfig& cdm_config,
45 mojom::ContentDecryptionModulePtr remote_cdm, 46 mojom::ContentDecryptionModulePtr remote_cdm,
46 const media::SessionMessageCB& session_message_cb, 47 const SessionMessageCB& session_message_cb,
47 const media::SessionClosedCB& session_closed_cb, 48 const SessionClosedCB& session_closed_cb,
48 const media::SessionKeysChangeCB& session_keys_change_cb, 49 const SessionKeysChangeCB& session_keys_change_cb,
49 const media::SessionExpirationUpdateCB& session_expiration_update_cb, 50 const SessionExpirationUpdateCB& session_expiration_update_cb,
50 const media::CdmCreatedCB& cdm_created_cb); 51 const CdmCreatedCB& cdm_created_cb);
51 52
52 // MediaKeys implementation. 53 // MediaKeys implementation.
53 void SetServerCertificate(const std::vector<uint8_t>& certificate, 54 void SetServerCertificate(const std::vector<uint8_t>& certificate,
54 std::unique_ptr<SimpleCdmPromise> promise) final; 55 std::unique_ptr<SimpleCdmPromise> promise) final;
55 void CreateSessionAndGenerateRequest( 56 void CreateSessionAndGenerateRequest(
56 SessionType session_type, 57 SessionType session_type,
57 EmeInitDataType init_data_type, 58 EmeInitDataType init_data_type,
58 const std::vector<uint8_t>& init_data, 59 const std::vector<uint8_t>& init_data,
59 std::unique_ptr<NewSessionCdmPromise> promise) final; 60 std::unique_ptr<NewSessionCdmPromise> promise) final;
60 void LoadSession(SessionType session_type, 61 void LoadSession(SessionType session_type,
61 const std::string& session_id, 62 const std::string& session_id,
62 std::unique_ptr<NewSessionCdmPromise> promise) final; 63 std::unique_ptr<NewSessionCdmPromise> promise) final;
63 void UpdateSession(const std::string& session_id, 64 void UpdateSession(const std::string& session_id,
64 const std::vector<uint8_t>& response, 65 const std::vector<uint8_t>& response,
65 std::unique_ptr<SimpleCdmPromise> promise) final; 66 std::unique_ptr<SimpleCdmPromise> promise) final;
66 void CloseSession(const std::string& session_id, 67 void CloseSession(const std::string& session_id,
67 std::unique_ptr<SimpleCdmPromise> promise) final; 68 std::unique_ptr<SimpleCdmPromise> promise) final;
68 void RemoveSession(const std::string& session_id, 69 void RemoveSession(const std::string& session_id,
69 std::unique_ptr<SimpleCdmPromise> promise) final; 70 std::unique_ptr<SimpleCdmPromise> promise) final;
70 CdmContext* GetCdmContext() final; 71 CdmContext* GetCdmContext() final;
71 72
72 // CdmContext implementation. Can be called on a different thread. 73 // CdmContext implementation. Can be called on a different thread.
73 // All GetDecryptor() calls must be made on the same thread. 74 // All GetDecryptor() calls must be made on the same thread.
74 media::Decryptor* GetDecryptor() final; 75 Decryptor* GetDecryptor() final;
75 int GetCdmId() const final; 76 int GetCdmId() const final;
76 77
77 private: 78 private:
78 MojoCdm(mojom::ContentDecryptionModulePtr remote_cdm, 79 MojoCdm(mojom::ContentDecryptionModulePtr remote_cdm,
79 const SessionMessageCB& session_message_cb, 80 const SessionMessageCB& session_message_cb,
80 const SessionClosedCB& session_closed_cb, 81 const SessionClosedCB& session_closed_cb,
81 const SessionKeysChangeCB& session_keys_change_cb, 82 const SessionKeysChangeCB& session_keys_change_cb,
82 const SessionExpirationUpdateCB& session_expiration_update_cb); 83 const SessionExpirationUpdateCB& session_expiration_update_cb);
83 84
84 ~MojoCdm() final; 85 ~MojoCdm() final;
85 86
86 void InitializeCdm(const std::string& key_system, 87 void InitializeCdm(const std::string& key_system,
87 const GURL& security_origin, 88 const GURL& security_origin,
88 const media::CdmConfig& cdm_config, 89 const CdmConfig& cdm_config,
89 std::unique_ptr<CdmInitializedPromise> promise); 90 std::unique_ptr<CdmInitializedPromise> promise);
90 91
91 void OnConnectionError(); 92 void OnConnectionError();
92 93
93 // mojom::ContentDecryptionModuleClient implementation. 94 // mojom::ContentDecryptionModuleClient implementation.
94 void OnSessionMessage(const std::string& session_id, 95 void OnSessionMessage(const std::string& session_id,
95 MessageType message_type, 96 MessageType message_type,
96 const std::vector<uint8_t>& message) final; 97 const std::vector<uint8_t>& message) final;
97 void OnSessionClosed(const std::string& session_id) final; 98 void OnSessionClosed(const std::string& session_id) final;
98 void OnSessionKeysChange( 99 void OnSessionKeysChange(
(...skipping 46 matching lines...) Expand 10 before | Expand all | Expand 10 after
145 146
146 // Callbacks for firing session events. 147 // Callbacks for firing session events.
147 SessionMessageCB session_message_cb_; 148 SessionMessageCB session_message_cb_;
148 SessionClosedCB session_closed_cb_; 149 SessionClosedCB session_closed_cb_;
149 SessionKeysChangeCB session_keys_change_cb_; 150 SessionKeysChangeCB session_keys_change_cb_;
150 SessionExpirationUpdateCB session_expiration_update_cb_; 151 SessionExpirationUpdateCB session_expiration_update_cb_;
151 152
152 // Pending promise for InitializeCdm(). 153 // Pending promise for InitializeCdm().
153 std::unique_ptr<CdmInitializedPromise> pending_init_promise_; 154 std::unique_ptr<CdmInitializedPromise> pending_init_promise_;
154 155
156 // Keep track of current sessions.
157 CdmSessionTracker cdm_session_tracker_;
158
155 // This must be the last member. 159 // This must be the last member.
156 base::WeakPtrFactory<MojoCdm> weak_factory_; 160 base::WeakPtrFactory<MojoCdm> weak_factory_;
157 161
158 DISALLOW_COPY_AND_ASSIGN(MojoCdm); 162 DISALLOW_COPY_AND_ASSIGN(MojoCdm);
159 }; 163 };
160 164
161 } // namespace media 165 } // namespace media
162 166
163 #endif // MEDIA_MOJO_CLIENTS_MOJO_CDM_H_ 167 #endif // MEDIA_MOJO_CLIENTS_MOJO_CDM_H_
OLDNEW
« no previous file with comments | « media/base/cdm_session_tracker.cc ('k') | media/mojo/clients/mojo_cdm.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698