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

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

Issue 1888603002: Add CdmFileIOProvider interface for use by cdm_adapter (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: callback 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
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 <string> 11 #include <string>
11 #include <vector> 12 #include <vector>
12 13
14 #include "base/callback.h"
13 #include "base/compiler_specific.h" 15 #include "base/compiler_specific.h"
14 #include "base/files/file_path.h" 16 #include "base/files/file_path.h"
15 #include "base/macros.h" 17 #include "base/macros.h"
16 #include "base/memory/ref_counted.h" 18 #include "base/memory/ref_counted.h"
17 #include "base/memory/scoped_ptr.h" 19 #include "base/memory/scoped_ptr.h"
18 #include "base/memory/weak_ptr.h" 20 #include "base/memory/weak_ptr.h"
19 #include "base/scoped_native_library.h" 21 #include "base/scoped_native_library.h"
20 #include "base/threading/thread.h" 22 #include "base/threading/thread.h"
21 #include "media/base/cdm_config.h" 23 #include "media/base/cdm_config.h"
22 #include "media/base/cdm_context.h" 24 #include "media/base/cdm_context.h"
23 #include "media/base/cdm_factory.h" 25 #include "media/base/cdm_factory.h"
24 #include "media/base/cdm_promise_adapter.h" 26 #include "media/base/cdm_promise_adapter.h"
25 #include "media/base/decryptor.h" 27 #include "media/base/decryptor.h"
26 #include "media/base/media_export.h" 28 #include "media/base/media_export.h"
27 #include "media/base/media_keys.h" 29 #include "media/base/media_keys.h"
28 #include "media/cdm/api/content_decryption_module.h" 30 #include "media/cdm/api/content_decryption_module.h"
29 #include "ui/gfx/geometry/size.h" 31 #include "ui/gfx/geometry/size.h"
30 32
31 namespace media { 33 namespace media {
32 34
33 class AudioFramesImpl; 35 class AudioFramesImpl;
34 class CdmAllocator; 36 class CdmAllocator;
37 class CdmFileIO;
35 class CdmWrapper; 38 class CdmWrapper;
36 39
40 // Called when the CDM needs a FileIO object from the host to do file IO
41 // operations. Returns NULL if a FileIO object cannot be obtained. Once a
42 // valid FileIO object is returned, |client| must be valid until
43 // FileIO::Close() is called. The CDM can call this method multiple times
44 // to operate on different files.
45 using CdmFileIOProviderCB =
xhwang 2016/04/18 21:09:22 The naming is a bit odd since the callback does cr
jrummell 2016/04/19 23:59:29 Done.
46 base::Callback<std::unique_ptr<CdmFileIO>(cdm::FileIOClient* client)>;
47
37 class MEDIA_EXPORT CdmAdapter : public MediaKeys, 48 class MEDIA_EXPORT CdmAdapter : public MediaKeys,
38 public CdmContext, 49 public CdmContext,
39 public Decryptor, 50 public Decryptor,
40 NON_EXPORTED_BASE(public cdm::Host_7), 51 NON_EXPORTED_BASE(public cdm::Host_7),
41 NON_EXPORTED_BASE(public cdm::Host_8) { 52 NON_EXPORTED_BASE(public cdm::Host_8) {
42 public: 53 public:
43 // Create the CDM using |cdm_path| and initialize it using |key_system| and 54 // Create the CDM using |cdm_path| and initialize it using |key_system| and
44 // |cdm_config|. |allocator| is to be used whenever the CDM needs memory 55 // |cdm_config|. |allocator| is to be used whenever the CDM needs memory
45 // and to create VideoFrames. Callbacks will be used for events generated 56 // and to create VideoFrames. |file_io_provider| is to be used whenever the
46 // by the CDM. |cdm_created_cb| will be called when the CDM is loaded and 57 // CDM needs access to the file system. Callbacks will be used for events
47 // initialized. 58 // generated by the CDM. |cdm_created_cb| will be called when the CDM is
59 // loaded and initialized.
48 static void Create( 60 static void Create(
49 const std::string& key_system, 61 const std::string& key_system,
50 const base::FilePath& cdm_path, 62 const base::FilePath& cdm_path,
51 const CdmConfig& cdm_config, 63 const CdmConfig& cdm_config,
52 scoped_ptr<CdmAllocator> allocator, 64 scoped_ptr<CdmAllocator> allocator,
65 const CdmFileIOProviderCB& file_io_provider_cb,
53 const SessionMessageCB& session_message_cb, 66 const SessionMessageCB& session_message_cb,
54 const SessionClosedCB& session_closed_cb, 67 const SessionClosedCB& session_closed_cb,
55 const LegacySessionErrorCB& legacy_session_error_cb, 68 const LegacySessionErrorCB& legacy_session_error_cb,
56 const SessionKeysChangeCB& session_keys_change_cb, 69 const SessionKeysChangeCB& session_keys_change_cb,
57 const SessionExpirationUpdateCB& session_expiration_update_cb, 70 const SessionExpirationUpdateCB& session_expiration_update_cb,
58 const CdmCreatedCB& cdm_created_cb); 71 const CdmCreatedCB& cdm_created_cb);
59 72
60 // MediaKeys implementation. 73 // MediaKeys implementation.
61 void SetServerCertificate(const std::vector<uint8_t>& certificate, 74 void SetServerCertificate(const std::vector<uint8_t>& certificate,
62 scoped_ptr<SimpleCdmPromise> promise) final; 75 scoped_ptr<SimpleCdmPromise> promise) final;
(...skipping 79 matching lines...) Expand 10 before | Expand all | Expand 10 after
142 void EnableOutputProtection(uint32_t desired_protection_mask) override; 155 void EnableOutputProtection(uint32_t desired_protection_mask) override;
143 void QueryOutputProtectionStatus() override; 156 void QueryOutputProtectionStatus() override;
144 void OnDeferredInitializationDone(cdm::StreamType stream_type, 157 void OnDeferredInitializationDone(cdm::StreamType stream_type,
145 cdm::Status decoder_status) override; 158 cdm::Status decoder_status) override;
146 cdm::FileIO* CreateFileIO(cdm::FileIOClient* client) override; 159 cdm::FileIO* CreateFileIO(cdm::FileIOClient* client) override;
147 160
148 private: 161 private:
149 CdmAdapter(const std::string& key_system, 162 CdmAdapter(const std::string& key_system,
150 const CdmConfig& cdm_config, 163 const CdmConfig& cdm_config,
151 scoped_ptr<CdmAllocator> allocator, 164 scoped_ptr<CdmAllocator> allocator,
165 const CdmFileIOProviderCB& file_io_provider_cb,
152 const SessionMessageCB& session_message_cb, 166 const SessionMessageCB& session_message_cb,
153 const SessionClosedCB& session_closed_cb, 167 const SessionClosedCB& session_closed_cb,
154 const LegacySessionErrorCB& legacy_session_error_cb, 168 const LegacySessionErrorCB& legacy_session_error_cb,
155 const SessionKeysChangeCB& session_keys_change_cb, 169 const SessionKeysChangeCB& session_keys_change_cb,
156 const SessionExpirationUpdateCB& session_expiration_update_cb); 170 const SessionExpirationUpdateCB& session_expiration_update_cb);
157 ~CdmAdapter() final; 171 ~CdmAdapter() final;
158 172
159 // Load the CDM using |cdm_path| and initialize it. |promise| is resolved if 173 // Load the CDM using |cdm_path| and initialize it. |promise| is resolved if
160 // the CDM is successfully loaded and initialized, rejected otherwise. 174 // the CDM is successfully loaded and initialized, rejected otherwise.
161 void Initialize(const base::FilePath& cdm_path, 175 void Initialize(const base::FilePath& cdm_path,
(...skipping 41 matching lines...) Expand 10 before | Expand all | Expand 10 after
203 217
204 // Keep track of video frame natural size from the latest configuration 218 // Keep track of video frame natural size from the latest configuration
205 // as the CDM doesn't provide it. 219 // as the CDM doesn't provide it.
206 gfx::Size natural_size_; 220 gfx::Size natural_size_;
207 221
208 // Keep track of audio parameters. 222 // Keep track of audio parameters.
209 int audio_samples_per_second_; 223 int audio_samples_per_second_;
210 ChannelLayout audio_channel_layout_; 224 ChannelLayout audio_channel_layout_;
211 225
212 scoped_ptr<CdmAllocator> allocator_; 226 scoped_ptr<CdmAllocator> allocator_;
227 CdmFileIOProviderCB file_io_provider_cb_;
213 228
214 scoped_refptr<base::SingleThreadTaskRunner> task_runner_; 229 scoped_refptr<base::SingleThreadTaskRunner> task_runner_;
215 230
216 // NOTE: Weak pointers must be invalidated before all other member variables. 231 // NOTE: Weak pointers must be invalidated before all other member variables.
217 base::WeakPtrFactory<CdmAdapter> weak_factory_; 232 base::WeakPtrFactory<CdmAdapter> weak_factory_;
218 233
219 DISALLOW_COPY_AND_ASSIGN(CdmAdapter); 234 DISALLOW_COPY_AND_ASSIGN(CdmAdapter);
220 }; 235 };
221 236
222 } // namespace media 237 } // namespace media
223 238
224 #endif // MEDIA_CDM_CDM_ADAPTER_H_ 239 #endif // MEDIA_CDM_CDM_ADAPTER_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698