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

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

Issue 2426813002: EME: Close existing sessions on CDM failure (Closed)
Patch Set: Created 4 years, 2 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_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 static void Create( 40 static void Create(
40 const std::string& key_system, 41 const std::string& key_system,
41 const GURL& security_origin, 42 const GURL& security_origin,
42 const media::CdmConfig& cdm_config, 43 const CdmConfig& cdm_config,
43 mojom::ContentDecryptionModulePtr remote_cdm, 44 mojom::ContentDecryptionModulePtr remote_cdm,
44 const media::SessionMessageCB& session_message_cb, 45 const SessionMessageCB& session_message_cb,
45 const media::SessionClosedCB& session_closed_cb, 46 const SessionClosedCB& session_closed_cb,
46 const media::SessionKeysChangeCB& session_keys_change_cb, 47 const SessionKeysChangeCB& session_keys_change_cb,
47 const media::SessionExpirationUpdateCB& session_expiration_update_cb, 48 const SessionExpirationUpdateCB& session_expiration_update_cb,
48 const media::CdmCreatedCB& cdm_created_cb); 49 const CdmCreatedCB& cdm_created_cb);
49 50
50 // MediaKeys implementation. 51 // MediaKeys implementation.
51 void SetServerCertificate(const std::vector<uint8_t>& certificate, 52 void SetServerCertificate(const std::vector<uint8_t>& certificate,
52 std::unique_ptr<SimpleCdmPromise> promise) final; 53 std::unique_ptr<SimpleCdmPromise> promise) final;
53 void CreateSessionAndGenerateRequest( 54 void CreateSessionAndGenerateRequest(
54 SessionType session_type, 55 SessionType session_type,
55 EmeInitDataType init_data_type, 56 EmeInitDataType init_data_type,
56 const std::vector<uint8_t>& init_data, 57 const std::vector<uint8_t>& init_data,
57 std::unique_ptr<NewSessionCdmPromise> promise) final; 58 std::unique_ptr<NewSessionCdmPromise> promise) final;
58 void LoadSession(SessionType session_type, 59 void LoadSession(SessionType session_type,
59 const std::string& session_id, 60 const std::string& session_id,
60 std::unique_ptr<NewSessionCdmPromise> promise) final; 61 std::unique_ptr<NewSessionCdmPromise> promise) final;
61 void UpdateSession(const std::string& session_id, 62 void UpdateSession(const std::string& session_id,
62 const std::vector<uint8_t>& response, 63 const std::vector<uint8_t>& response,
63 std::unique_ptr<SimpleCdmPromise> promise) final; 64 std::unique_ptr<SimpleCdmPromise> promise) final;
64 void CloseSession(const std::string& session_id, 65 void CloseSession(const std::string& session_id,
65 std::unique_ptr<SimpleCdmPromise> promise) final; 66 std::unique_ptr<SimpleCdmPromise> promise) final;
66 void RemoveSession(const std::string& session_id, 67 void RemoveSession(const std::string& session_id,
67 std::unique_ptr<SimpleCdmPromise> promise) final; 68 std::unique_ptr<SimpleCdmPromise> promise) final;
68 CdmContext* GetCdmContext() final; 69 CdmContext* GetCdmContext() final;
69 70
70 // CdmContext implementation. Can be called on a different thread. 71 // CdmContext implementation. Can be called on a different thread.
71 // All GetDecryptor() calls must be made on the same thread. 72 // All GetDecryptor() calls must be made on the same thread.
72 media::Decryptor* GetDecryptor() final; 73 Decryptor* GetDecryptor() final;
73 int GetCdmId() const final; 74 int GetCdmId() const final;
74 75
75 private: 76 private:
76 MojoCdm(mojom::ContentDecryptionModulePtr remote_cdm, 77 MojoCdm(mojom::ContentDecryptionModulePtr remote_cdm,
77 const SessionMessageCB& session_message_cb, 78 const SessionMessageCB& session_message_cb,
78 const SessionClosedCB& session_closed_cb, 79 const SessionClosedCB& session_closed_cb,
79 const SessionKeysChangeCB& session_keys_change_cb, 80 const SessionKeysChangeCB& session_keys_change_cb,
80 const SessionExpirationUpdateCB& session_expiration_update_cb); 81 const SessionExpirationUpdateCB& session_expiration_update_cb);
81 82
82 ~MojoCdm() final; 83 ~MojoCdm() final;
83 84
84 void InitializeCdm(const std::string& key_system, 85 void InitializeCdm(const std::string& key_system,
85 const GURL& security_origin, 86 const GURL& security_origin,
86 const media::CdmConfig& cdm_config, 87 const CdmConfig& cdm_config,
87 std::unique_ptr<CdmInitializedPromise> promise); 88 std::unique_ptr<CdmInitializedPromise> promise);
88 89
89 void OnConnectionError(); 90 void OnConnectionError();
90 91
91 // mojom::ContentDecryptionModuleClient implementation. 92 // mojom::ContentDecryptionModuleClient implementation.
92 void OnSessionMessage(const std::string& session_id, 93 void OnSessionMessage(const std::string& session_id,
93 mojom::CdmMessageType message_type, 94 mojom::CdmMessageType message_type,
94 const std::vector<uint8_t>& message) final; 95 const std::vector<uint8_t>& message) final;
95 void OnSessionClosed(const std::string& session_id) final; 96 void OnSessionClosed(const std::string& session_id) final;
96 void OnSessionKeysChange( 97 void OnSessionKeysChange(
(...skipping 46 matching lines...) Expand 10 before | Expand all | Expand 10 after
143 144
144 // Callbacks for firing session events. 145 // Callbacks for firing session events.
145 SessionMessageCB session_message_cb_; 146 SessionMessageCB session_message_cb_;
146 SessionClosedCB session_closed_cb_; 147 SessionClosedCB session_closed_cb_;
147 SessionKeysChangeCB session_keys_change_cb_; 148 SessionKeysChangeCB session_keys_change_cb_;
148 SessionExpirationUpdateCB session_expiration_update_cb_; 149 SessionExpirationUpdateCB session_expiration_update_cb_;
149 150
150 // Pending promise for InitializeCdm(). 151 // Pending promise for InitializeCdm().
151 std::unique_ptr<CdmInitializedPromise> pending_init_promise_; 152 std::unique_ptr<CdmInitializedPromise> pending_init_promise_;
152 153
154 // Keep track of current sessions.
155 CdmSessionTracker cdm_session_tracker_;
156
153 // This must be the last member. 157 // This must be the last member.
154 base::WeakPtrFactory<MojoCdm> weak_factory_; 158 base::WeakPtrFactory<MojoCdm> weak_factory_;
155 159
156 DISALLOW_COPY_AND_ASSIGN(MojoCdm); 160 DISALLOW_COPY_AND_ASSIGN(MojoCdm);
157 }; 161 };
158 162
159 } // namespace media 163 } // namespace media
160 164
161 #endif // MEDIA_MOJO_CLIENTS_MOJO_CDM_H_ 165 #endif // MEDIA_MOJO_CLIENTS_MOJO_CDM_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698