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

Side by Side Diff: media/cdm/cdm_adapter.h

Issue 1915443003: Replace scoped_ptr with std::unique_ptr in //media. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@scopedptr-media-base
Patch Set: scopedptr-media: rebase Created 4 years, 8 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
« no previous file with comments | « media/cdm/aes_decryptor_unittest.cc ('k') | media/cdm/cdm_adapter.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 2015 The Chromium Authors. All rights reserved. 1 // Copyright 2015 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_CDM_CDM_ADAPTER_H_ 5 #ifndef MEDIA_CDM_CDM_ADAPTER_H_
6 #define MEDIA_CDM_CDM_ADAPTER_H_ 6 #define MEDIA_CDM_CDM_ADAPTER_H_
7 7
8 #include <stdint.h> 8 #include <stdint.h>
9 9
10 #include <memory> 10 #include <memory>
11 #include <string> 11 #include <string>
12 #include <vector> 12 #include <vector>
13 13
14 #include "base/callback.h" 14 #include "base/callback.h"
15 #include "base/compiler_specific.h" 15 #include "base/compiler_specific.h"
16 #include "base/files/file_path.h" 16 #include "base/files/file_path.h"
17 #include "base/macros.h" 17 #include "base/macros.h"
18 #include "base/memory/ref_counted.h" 18 #include "base/memory/ref_counted.h"
19 #include "base/memory/scoped_ptr.h"
20 #include "base/memory/weak_ptr.h" 19 #include "base/memory/weak_ptr.h"
21 #include "base/scoped_native_library.h" 20 #include "base/scoped_native_library.h"
22 #include "base/threading/thread.h" 21 #include "base/threading/thread.h"
23 #include "media/base/cdm_config.h" 22 #include "media/base/cdm_config.h"
24 #include "media/base/cdm_context.h" 23 #include "media/base/cdm_context.h"
25 #include "media/base/cdm_factory.h" 24 #include "media/base/cdm_factory.h"
26 #include "media/base/cdm_promise_adapter.h" 25 #include "media/base/cdm_promise_adapter.h"
27 #include "media/base/decryptor.h" 26 #include "media/base/decryptor.h"
28 #include "media/base/media_export.h" 27 #include "media/base/media_export.h"
29 #include "media/base/media_keys.h" 28 #include "media/base/media_keys.h"
(...skipping 24 matching lines...) Expand all
54 // Create the CDM using |cdm_path| and initialize it using |key_system| and 53 // Create the CDM using |cdm_path| and initialize it using |key_system| and
55 // |cdm_config|. |allocator| is to be used whenever the CDM needs memory 54 // |cdm_config|. |allocator| is to be used whenever the CDM needs memory
56 // and to create VideoFrames. |file_io_provider| is to be used whenever the 55 // and to create VideoFrames. |file_io_provider| is to be used whenever the
57 // CDM needs access to the file system. Callbacks will be used for events 56 // CDM needs access to the file system. Callbacks will be used for events
58 // generated by the CDM. |cdm_created_cb| will be called when the CDM is 57 // generated by the CDM. |cdm_created_cb| will be called when the CDM is
59 // loaded and initialized. 58 // loaded and initialized.
60 static void Create( 59 static void Create(
61 const std::string& key_system, 60 const std::string& key_system,
62 const base::FilePath& cdm_path, 61 const base::FilePath& cdm_path,
63 const CdmConfig& cdm_config, 62 const CdmConfig& cdm_config,
64 scoped_ptr<CdmAllocator> allocator, 63 std::unique_ptr<CdmAllocator> allocator,
65 const CreateCdmFileIOCB& create_cdm_file_io_cb, 64 const CreateCdmFileIOCB& create_cdm_file_io_cb,
66 const SessionMessageCB& session_message_cb, 65 const SessionMessageCB& session_message_cb,
67 const SessionClosedCB& session_closed_cb, 66 const SessionClosedCB& session_closed_cb,
68 const LegacySessionErrorCB& legacy_session_error_cb, 67 const LegacySessionErrorCB& legacy_session_error_cb,
69 const SessionKeysChangeCB& session_keys_change_cb, 68 const SessionKeysChangeCB& session_keys_change_cb,
70 const SessionExpirationUpdateCB& session_expiration_update_cb, 69 const SessionExpirationUpdateCB& session_expiration_update_cb,
71 const CdmCreatedCB& cdm_created_cb); 70 const CdmCreatedCB& cdm_created_cb);
72 71
73 // MediaKeys implementation. 72 // MediaKeys implementation.
74 void SetServerCertificate(const std::vector<uint8_t>& certificate, 73 void SetServerCertificate(const std::vector<uint8_t>& certificate,
75 scoped_ptr<SimpleCdmPromise> promise) final; 74 std::unique_ptr<SimpleCdmPromise> promise) final;
76 void CreateSessionAndGenerateRequest( 75 void CreateSessionAndGenerateRequest(
77 SessionType session_type, 76 SessionType session_type,
78 EmeInitDataType init_data_type, 77 EmeInitDataType init_data_type,
79 const std::vector<uint8_t>& init_data, 78 const std::vector<uint8_t>& init_data,
80 scoped_ptr<NewSessionCdmPromise> promise) final; 79 std::unique_ptr<NewSessionCdmPromise> promise) final;
81 void LoadSession(SessionType session_type, 80 void LoadSession(SessionType session_type,
82 const std::string& session_id, 81 const std::string& session_id,
83 scoped_ptr<NewSessionCdmPromise> promise) final; 82 std::unique_ptr<NewSessionCdmPromise> promise) final;
84 void UpdateSession(const std::string& session_id, 83 void UpdateSession(const std::string& session_id,
85 const std::vector<uint8_t>& response, 84 const std::vector<uint8_t>& response,
86 scoped_ptr<SimpleCdmPromise> promise) final; 85 std::unique_ptr<SimpleCdmPromise> promise) final;
87 void CloseSession(const std::string& session_id, 86 void CloseSession(const std::string& session_id,
88 scoped_ptr<SimpleCdmPromise> promise) final; 87 std::unique_ptr<SimpleCdmPromise> promise) final;
89 void RemoveSession(const std::string& session_id, 88 void RemoveSession(const std::string& session_id,
90 scoped_ptr<SimpleCdmPromise> promise) final; 89 std::unique_ptr<SimpleCdmPromise> promise) final;
91 CdmContext* GetCdmContext() final; 90 CdmContext* GetCdmContext() final;
92 91
93 // CdmContext implementation. 92 // CdmContext implementation.
94 Decryptor* GetDecryptor() final; 93 Decryptor* GetDecryptor() final;
95 int GetCdmId() const final; 94 int GetCdmId() const final;
96 95
97 // Decryptor implementation. 96 // Decryptor implementation.
98 void RegisterNewKeyCB(StreamType stream_type, 97 void RegisterNewKeyCB(StreamType stream_type,
99 const NewKeyCB& key_added_cb) final; 98 const NewKeyCB& key_added_cb) final;
100 void Decrypt(StreamType stream_type, 99 void Decrypt(StreamType stream_type,
(...skipping 53 matching lines...) Expand 10 before | Expand all | Expand 10 after
154 uint32_t challenge_size) override; 153 uint32_t challenge_size) override;
155 void EnableOutputProtection(uint32_t desired_protection_mask) override; 154 void EnableOutputProtection(uint32_t desired_protection_mask) override;
156 void QueryOutputProtectionStatus() override; 155 void QueryOutputProtectionStatus() override;
157 void OnDeferredInitializationDone(cdm::StreamType stream_type, 156 void OnDeferredInitializationDone(cdm::StreamType stream_type,
158 cdm::Status decoder_status) override; 157 cdm::Status decoder_status) override;
159 cdm::FileIO* CreateFileIO(cdm::FileIOClient* client) override; 158 cdm::FileIO* CreateFileIO(cdm::FileIOClient* client) override;
160 159
161 private: 160 private:
162 CdmAdapter(const std::string& key_system, 161 CdmAdapter(const std::string& key_system,
163 const CdmConfig& cdm_config, 162 const CdmConfig& cdm_config,
164 scoped_ptr<CdmAllocator> allocator, 163 std::unique_ptr<CdmAllocator> allocator,
165 const CreateCdmFileIOCB& create_cdm_file_io_cb, 164 const CreateCdmFileIOCB& create_cdm_file_io_cb,
166 const SessionMessageCB& session_message_cb, 165 const SessionMessageCB& session_message_cb,
167 const SessionClosedCB& session_closed_cb, 166 const SessionClosedCB& session_closed_cb,
168 const LegacySessionErrorCB& legacy_session_error_cb, 167 const LegacySessionErrorCB& legacy_session_error_cb,
169 const SessionKeysChangeCB& session_keys_change_cb, 168 const SessionKeysChangeCB& session_keys_change_cb,
170 const SessionExpirationUpdateCB& session_expiration_update_cb); 169 const SessionExpirationUpdateCB& session_expiration_update_cb);
171 ~CdmAdapter() final; 170 ~CdmAdapter() final;
172 171
173 // Load the CDM using |cdm_path| and initialize it. |promise| is resolved if 172 // Load the CDM using |cdm_path| and initialize it. |promise| is resolved if
174 // the CDM is successfully loaded and initialized, rejected otherwise. 173 // the CDM is successfully loaded and initialized, rejected otherwise.
175 void Initialize(const base::FilePath& cdm_path, 174 void Initialize(const base::FilePath& cdm_path,
176 scoped_ptr<media::SimpleCdmPromise> promise); 175 std::unique_ptr<media::SimpleCdmPromise> promise);
177 176
178 // Create an instance of the |key_system| CDM contained in |cdm_path|. 177 // Create an instance of the |key_system| CDM contained in |cdm_path|.
179 // Caller owns the returned pointer. On error (unable to load, does not 178 // Caller owns the returned pointer. On error (unable to load, does not
180 // support |key_system|, does not support an supported interface, etc.) 179 // support |key_system|, does not support an supported interface, etc.)
181 // NULL will be returned. 180 // NULL will be returned.
182 CdmWrapper* CreateCdmInstance(const std::string& key_system, 181 CdmWrapper* CreateCdmInstance(const std::string& key_system,
183 const base::FilePath& cdm_path); 182 const base::FilePath& cdm_path);
184 183
185 // Helper for SetTimer(). 184 // Helper for SetTimer().
186 void TimerExpired(void* context); 185 void TimerExpired(void* context);
187 186
188 // Converts audio data stored in |audio_frames| into individual audio 187 // Converts audio data stored in |audio_frames| into individual audio
189 // buffers in |result_frames|. Returns true upon success. 188 // buffers in |result_frames|. Returns true upon success.
190 bool AudioFramesDataToAudioFrames(scoped_ptr<AudioFramesImpl> audio_frames, 189 bool AudioFramesDataToAudioFrames(
191 Decryptor::AudioFrames* result_frames); 190 std::unique_ptr<AudioFramesImpl> audio_frames,
191 Decryptor::AudioFrames* result_frames);
192 192
193 // Keep a reference to the CDM. 193 // Keep a reference to the CDM.
194 base::ScopedNativeLibrary library_; 194 base::ScopedNativeLibrary library_;
195 195
196 // Used to keep track of promises while the CDM is processing the request. 196 // Used to keep track of promises while the CDM is processing the request.
197 CdmPromiseAdapter cdm_promise_adapter_; 197 CdmPromiseAdapter cdm_promise_adapter_;
198 198
199 scoped_ptr<CdmWrapper> cdm_; 199 std::unique_ptr<CdmWrapper> cdm_;
200 std::string key_system_; 200 std::string key_system_;
201 CdmConfig cdm_config_; 201 CdmConfig cdm_config_;
202 202
203 // Callbacks for firing session events. 203 // Callbacks for firing session events.
204 SessionMessageCB session_message_cb_; 204 SessionMessageCB session_message_cb_;
205 SessionClosedCB session_closed_cb_; 205 SessionClosedCB session_closed_cb_;
206 LegacySessionErrorCB legacy_session_error_cb_; 206 LegacySessionErrorCB legacy_session_error_cb_;
207 SessionKeysChangeCB session_keys_change_cb_; 207 SessionKeysChangeCB session_keys_change_cb_;
208 SessionExpirationUpdateCB session_expiration_update_cb_; 208 SessionExpirationUpdateCB session_expiration_update_cb_;
209 209
210 // Callbacks for deferred initialization. 210 // Callbacks for deferred initialization.
211 DecoderInitCB audio_init_cb_; 211 DecoderInitCB audio_init_cb_;
212 DecoderInitCB video_init_cb_; 212 DecoderInitCB video_init_cb_;
213 213
214 // Callbacks for new keys added. 214 // Callbacks for new keys added.
215 NewKeyCB new_audio_key_cb_; 215 NewKeyCB new_audio_key_cb_;
216 NewKeyCB new_video_key_cb_; 216 NewKeyCB new_video_key_cb_;
217 217
218 // Keep track of video frame natural size from the latest configuration 218 // Keep track of video frame natural size from the latest configuration
219 // as the CDM doesn't provide it. 219 // as the CDM doesn't provide it.
220 gfx::Size natural_size_; 220 gfx::Size natural_size_;
221 221
222 // Keep track of audio parameters. 222 // Keep track of audio parameters.
223 int audio_samples_per_second_; 223 int audio_samples_per_second_;
224 ChannelLayout audio_channel_layout_; 224 ChannelLayout audio_channel_layout_;
225 225
226 scoped_ptr<CdmAllocator> allocator_; 226 std::unique_ptr<CdmAllocator> allocator_;
227 CreateCdmFileIOCB create_cdm_file_io_cb_; 227 CreateCdmFileIOCB create_cdm_file_io_cb_;
228 228
229 scoped_refptr<base::SingleThreadTaskRunner> task_runner_; 229 scoped_refptr<base::SingleThreadTaskRunner> task_runner_;
230 230
231 // NOTE: Weak pointers must be invalidated before all other member variables. 231 // NOTE: Weak pointers must be invalidated before all other member variables.
232 base::WeakPtrFactory<CdmAdapter> weak_factory_; 232 base::WeakPtrFactory<CdmAdapter> weak_factory_;
233 233
234 DISALLOW_COPY_AND_ASSIGN(CdmAdapter); 234 DISALLOW_COPY_AND_ASSIGN(CdmAdapter);
235 }; 235 };
236 236
237 } // namespace media 237 } // namespace media
238 238
239 #endif // MEDIA_CDM_CDM_ADAPTER_H_ 239 #endif // MEDIA_CDM_CDM_ADAPTER_H_
OLDNEW
« no previous file with comments | « media/cdm/aes_decryptor_unittest.cc ('k') | media/cdm/cdm_adapter.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698