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

Side by Side Diff: media/base/android/media_drm_bridge.h

Issue 1341883003: Prepare MediaDrmBridge to work with MediaCodecPlayer (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@bug526755
Patch Set: Addressed Min's comments Created 5 years, 3 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 (c) 2013 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2013 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_BASE_ANDROID_MEDIA_DRM_BRIDGE_H_ 5 #ifndef MEDIA_BASE_ANDROID_MEDIA_DRM_BRIDGE_H_
6 #define MEDIA_BASE_ANDROID_MEDIA_DRM_BRIDGE_H_ 6 #define MEDIA_BASE_ANDROID_MEDIA_DRM_BRIDGE_H_
7 7
8 #include <jni.h> 8 #include <jni.h>
9 #include <string> 9 #include <string>
10 #include <vector> 10 #include <vector>
11 11
12 #include "base/android/scoped_java_ref.h" 12 #include "base/android/scoped_java_ref.h"
13 #include "base/callback.h" 13 #include "base/callback.h"
14 #include "base/memory/scoped_ptr.h" 14 #include "base/memory/scoped_ptr.h"
15 #include "base/memory/weak_ptr.h"
15 #include "media/base/browser_cdm.h" 16 #include "media/base/browser_cdm.h"
16 #include "media/base/cdm_promise_adapter.h" 17 #include "media/base/cdm_promise_adapter.h"
17 #include "media/base/media_export.h" 18 #include "media/base/media_export.h"
18 #include "media/cdm/player_tracker_impl.h" 19 #include "media/cdm/player_tracker_impl.h"
19 #include "url/gurl.h" 20 #include "url/gurl.h"
20 21
21 class GURL; 22 class GURL;
22 23
23 namespace media { 24 namespace media {
24 25
(...skipping 11 matching lines...) Expand all
36 37
37 typedef base::Callback<void(bool)> ResetCredentialsCB; 38 typedef base::Callback<void(bool)> ResetCredentialsCB;
38 39
39 ~MediaDrmBridge() override; 40 ~MediaDrmBridge() override;
40 41
41 // Checks whether MediaDRM is available. 42 // Checks whether MediaDRM is available.
42 // All other static methods check IsAvailable() internally. There's no need 43 // All other static methods check IsAvailable() internally. There's no need
43 // to check IsAvailable() explicitly before calling them. 44 // to check IsAvailable() explicitly before calling them.
44 static bool IsAvailable(); 45 static bool IsAvailable();
45 46
47 // Checks whether we can create the DRM for key system and security level.
48 static bool CanCreate(const std::string& key_system,
49 SecurityLevel widevine_security_level);
50
46 // Checks whether |key_system| is supported. 51 // Checks whether |key_system| is supported.
47 static bool IsKeySystemSupported(const std::string& key_system); 52 static bool IsKeySystemSupported(const std::string& key_system);
48 53
49 // Returns the list of the platform-supported key system names that 54 // Returns the list of the platform-supported key system names that
50 // are not handled by Chrome explicitly. 55 // are not handled by Chrome explicitly.
51 static std::vector<std::string> GetPlatformKeySystemNames(); 56 static std::vector<std::string> GetPlatformKeySystemNames();
52 57
53 // Checks whether |key_system| is supported with |container_mime_type|. 58 // Checks whether |key_system| is supported with |container_mime_type|.
54 // |container_mime_type| must not be empty. 59 // |container_mime_type| must not be empty.
55 static bool IsKeySystemSupportedWithType( 60 static bool IsKeySystemSupportedWithType(
56 const std::string& key_system, 61 const std::string& key_system,
57 const std::string& container_mime_type); 62 const std::string& container_mime_type);
58 63
59 static bool RegisterMediaDrmBridge(JNIEnv* env); 64 static bool RegisterMediaDrmBridge(JNIEnv* env);
60 65
61 // Returns a MediaDrmBridge instance if |key_system| is supported, or a NULL 66 // Returns a MediaDrmBridge instance if |key_system| is supported, or a NULL
62 // pointer otherwise. 67 // pointer otherwise.
63 // TODO(xhwang): Is it okay not to update session expiration info? 68 // TODO(xhwang): Is it okay not to update session expiration info?
64 static scoped_ptr<MediaDrmBridge> Create( 69 static scoped_ptr<MediaDrmBridge, BrowserCdmDeleter> Create(
65 const std::string& key_system, 70 const std::string& key_system,
71 SecurityLevel widevine_security_level,
66 const SessionMessageCB& session_message_cb, 72 const SessionMessageCB& session_message_cb,
67 const SessionClosedCB& session_closed_cb, 73 const SessionClosedCB& session_closed_cb,
68 const LegacySessionErrorCB& legacy_session_error_cb, 74 const LegacySessionErrorCB& legacy_session_error_cb,
69 const SessionKeysChangeCB& session_keys_change_cb, 75 const SessionKeysChangeCB& session_keys_change_cb,
70 const SessionExpirationUpdateCB& session_expiration_update_cb); 76 const SessionExpirationUpdateCB& session_expiration_update_cb);
71 77
72 // Returns a MediaDrmBridge instance if |key_system| is supported, or a NULL 78 // Returns a MediaDrmBridge instance if |key_system| is supported, or a NULL
73 // otherwise. No session callbacks are provided. This is used when we need to 79 // otherwise. No session callbacks are provided. This is used when we need to
74 // use MediaDrmBridge without creating any sessions. 80 // use MediaDrmBridge without creating any sessions.
75 static scoped_ptr<MediaDrmBridge> CreateWithoutSessionSupport( 81 static scoped_ptr<MediaDrmBridge, BrowserCdmDeleter>
76 const std::string& key_system); 82 CreateWithoutSessionSupport(const std::string& key_system);
77 83
78 // Returns true if |security_level| is successfully set, or false otherwise. 84 // Returns true if |security_level| is successfully set, or false otherwise.
79 // Call this function right after Create() and before any other calls. 85 // Call this function right after Create() and before any other calls.
80 // Note: 86 // Note:
81 // - If this function is not called, the default security level of the device 87 // - If this function is not called, the default security level of the device
82 // will be used. 88 // will be used.
83 // - It's recommended to call this function only once on a MediaDrmBridge 89 // - It's recommended to call this function only once on a MediaDrmBridge
84 // object. Calling this function multiples times may cause errors. 90 // object. Calling this function multiples times may cause errors.
85 bool SetSecurityLevel(SecurityLevel security_level); 91 bool SetSecurityLevel(SecurityLevel security_level);
86 92
(...skipping 105 matching lines...) Expand 10 before | Expand all | Expand 10 after
192 const SessionClosedCB& session_closed_cb, 198 const SessionClosedCB& session_closed_cb,
193 const LegacySessionErrorCB& legacy_session_error_cb, 199 const LegacySessionErrorCB& legacy_session_error_cb,
194 const SessionKeysChangeCB& session_keys_change_cb, 200 const SessionKeysChangeCB& session_keys_change_cb,
195 const SessionExpirationUpdateCB& session_expiration_update_cb); 201 const SessionExpirationUpdateCB& session_expiration_update_cb);
196 202
197 static bool IsSecureDecoderRequired(SecurityLevel security_level); 203 static bool IsSecureDecoderRequired(SecurityLevel security_level);
198 204
199 // Get the security level of the media. 205 // Get the security level of the media.
200 SecurityLevel GetSecurityLevel(); 206 SecurityLevel GetSecurityLevel();
201 207
208 void InternalKeysAdded(bool has_additional_usable_key);
209
210 void InternalPromiseResolved(uint32_t promise_id);
211 void InternalPromiseResolvedWithSession(uint32_t promise_id,
212 const std::string& session_id);
213 void InternalPromiseRejected(uint32_t promise_id,
214 const std::string& error_message);
215
202 // UUID of the key system. 216 // UUID of the key system.
203 std::vector<uint8> scheme_uuid_; 217 std::vector<uint8> scheme_uuid_;
204 218
205 // Java MediaDrm instance. 219 // Java MediaDrm instance.
206 base::android::ScopedJavaGlobalRef<jobject> j_media_drm_; 220 base::android::ScopedJavaGlobalRef<jobject> j_media_drm_;
207 221
208 // Callbacks for firing session events. 222 // Callbacks for firing session events.
209 SessionMessageCB session_message_cb_; 223 SessionMessageCB session_message_cb_;
210 SessionClosedCB session_closed_cb_; 224 SessionClosedCB session_closed_cb_;
211 LegacySessionErrorCB legacy_session_error_cb_; 225 LegacySessionErrorCB legacy_session_error_cb_;
212 SessionKeysChangeCB session_keys_change_cb_; 226 SessionKeysChangeCB session_keys_change_cb_;
213 SessionExpirationUpdateCB session_expiration_update_cb_; 227 SessionExpirationUpdateCB session_expiration_update_cb_;
214 228
215 base::Closure media_crypto_ready_cb_; 229 base::Closure media_crypto_ready_cb_;
216 230
217 ResetCredentialsCB reset_credentials_cb_; 231 ResetCredentialsCB reset_credentials_cb_;
218 232
219 PlayerTrackerImpl player_tracker_; 233 PlayerTrackerImpl player_tracker_;
220 234
221 CdmPromiseAdapter cdm_promise_adapter_; 235 CdmPromiseAdapter cdm_promise_adapter_;
222 236
237 // Callback for posting Java notifications to Media thread.
238 typedef base::Callback<void(bool)> KeysAddedCallback;
239 KeysAddedCallback internal_keys_added_cb_;
240
241 typedef base::Callback<void(uint32_t)> PromiseCallback;
242 typedef base::Callback<void(uint32_t, const std::string&)> PromiseWSCallback;
243 PromiseCallback internal_promise_resolved_cb_;
244 PromiseWSCallback internal_promise_resolved_with_session_cb_;
245 PromiseWSCallback internal_promise_rejected_cb_;
246
247 bool run_on_media_thread_;
248
249 // NOTE: Weak pointers must be invalidated before all other member variables.
250 base::WeakPtrFactory<MediaDrmBridge> weak_factory_;
251
223 DISALLOW_COPY_AND_ASSIGN(MediaDrmBridge); 252 DISALLOW_COPY_AND_ASSIGN(MediaDrmBridge);
224 }; 253 };
225 254
226 } // namespace media 255 } // namespace media
227 256
228 #endif // MEDIA_BASE_ANDROID_MEDIA_DRM_BRIDGE_H_ 257 #endif // MEDIA_BASE_ANDROID_MEDIA_DRM_BRIDGE_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698