OLD | NEW |
---|---|
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 "media/base/browser_cdm.h" | 15 #include "media/base/browser_cdm.h" |
16 #include "media/base/cdm_promise_adapter.h" | 16 #include "media/base/cdm_promise_adapter.h" |
17 #include "media/base/media_export.h" | 17 #include "media/base/media_export.h" |
18 #include "media/cdm/player_tracker_impl.h" | 18 #include "media/cdm/player_tracker_impl.h" |
19 #include "url/gurl.h" | 19 #include "url/gurl.h" |
20 | 20 |
21 class GURL; | 21 class GURL; |
22 | 22 |
23 namespace media { | 23 namespace media { |
24 | 24 |
25 class MediaPlayerManager; | 25 class MediaPlayerManager; |
26 | 26 |
27 // This class provides DRM services for android EME implementation. | 27 // This class provides DRM services for android EME implementation. |
28 class MEDIA_EXPORT MediaDrmBridge : public BrowserCdm { | 28 class MEDIA_EXPORT MediaDrmBridge : public BrowserCdm { |
29 public: | 29 public: |
30 class Delegate { | |
xhwang
2015/03/23 04:59:47
Add comment please.
gunsch
2015/04/09 01:36:39
Done.
| |
31 public: | |
32 void OnCreateSession( | |
xhwang
2015/03/23 04:59:47
How about SanitizeInitData()? (Search for "sanitiz
xhwang
2015/03/23 04:59:47
virtual?
gunsch
2015/04/09 01:36:39
1) I feel like isn't, strictly speaking, "sanitiza
gunsch
2015/04/09 01:36:39
Done.
| |
33 const std::string& init_data_type, | |
34 const uint8* init_data, | |
35 int init_data_length, | |
36 std::vector<uint8>& init_data_out, | |
37 std::vector<std::string>& additional_data_out) {} | |
38 | |
39 private: | |
40 virtual ~Delegate() {} | |
41 | |
42 DISALLOW_COPY_AND_ASSIGN(Delegate); | |
43 }; | |
44 | |
30 // TODO(ddorwin): These are specific to Widevine. http://crbug.com/459400 | 45 // TODO(ddorwin): These are specific to Widevine. http://crbug.com/459400 |
31 enum SecurityLevel { | 46 enum SecurityLevel { |
32 SECURITY_LEVEL_NONE = 0, | 47 SECURITY_LEVEL_NONE = 0, |
33 SECURITY_LEVEL_1 = 1, | 48 SECURITY_LEVEL_1 = 1, |
34 SECURITY_LEVEL_3 = 3, | 49 SECURITY_LEVEL_3 = 3, |
35 }; | 50 }; |
36 | 51 |
37 typedef base::Callback<void(bool)> ResetCredentialsCB; | 52 typedef base::Callback<void(bool)> ResetCredentialsCB; |
38 | 53 |
39 ~MediaDrmBridge() override; | 54 ~MediaDrmBridge() override; |
40 | 55 |
41 // Checks whether MediaDRM is available. | 56 // Checks whether MediaDRM is available. |
42 // All other static methods check IsAvailable() internally. There's no need | 57 // All other static methods check IsAvailable() internally. There's no need |
43 // to check IsAvailable() explicitly before calling them. | 58 // to check IsAvailable() explicitly before calling them. |
44 static bool IsAvailable(); | 59 static bool IsAvailable(); |
45 | 60 |
46 // Checks whether |key_system| is supported. | 61 // Checks whether |key_system| is supported. |
47 static bool IsKeySystemSupported(const std::string& key_system); | 62 static bool IsKeySystemSupported(const std::string& key_system); |
48 | 63 |
49 // Returns the list of the platform-supported key system names that | 64 // Returns the list of the platform-supported key system names that |
50 // are not handled by Chrome explicitly. | 65 // are not handled by Chrome explicitly. |
51 static std::vector<std::string> GetPlatformKeySystemNames(); | 66 static std::vector<std::string> GetPlatformKeySystemNames(); |
52 | 67 |
53 // Checks whether |key_system| is supported with |container_mime_type|. | 68 // Checks whether |key_system| is supported with |container_mime_type|. |
54 // |container_mime_type| must not be empty. | 69 // |container_mime_type| must not be empty. |
55 static bool IsKeySystemSupportedWithType( | 70 static bool IsKeySystemSupportedWithType( |
56 const std::string& key_system, | 71 const std::string& key_system, |
57 const std::string& container_mime_type); | 72 const std::string& container_mime_type); |
58 | 73 |
74 // Registers a delegate to handle requests with a given UUID. | |
75 static void RegisterDelegate( | |
76 const std::string& key_system, | |
77 Delegate* delegate); | |
78 | |
59 static bool RegisterMediaDrmBridge(JNIEnv* env); | 79 static bool RegisterMediaDrmBridge(JNIEnv* env); |
60 | 80 |
61 // Returns a MediaDrmBridge instance if |key_system| is supported, or a NULL | 81 // Returns a MediaDrmBridge instance if |key_system| is supported, or a NULL |
62 // pointer otherwise. | 82 // pointer otherwise. |
63 // TODO(xhwang): Is it okay not to update session expiration info? | 83 // TODO(xhwang): Is it okay not to update session expiration info? |
64 static scoped_ptr<MediaDrmBridge> Create( | 84 static scoped_ptr<MediaDrmBridge> Create( |
65 const std::string& key_system, | 85 const std::string& key_system, |
66 const SessionMessageCB& session_message_cb, | 86 const SessionMessageCB& session_message_cb, |
67 const SessionClosedCB& session_closed_cb, | 87 const SessionClosedCB& session_closed_cb, |
68 const SessionErrorCB& session_error_cb, | 88 const SessionErrorCB& session_error_cb, |
(...skipping 109 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
178 | 198 |
179 // Helper function to determine whether a protected surface is needed for the | 199 // Helper function to determine whether a protected surface is needed for the |
180 // video playback. | 200 // video playback. |
181 bool IsProtectedSurfaceRequired(); | 201 bool IsProtectedSurfaceRequired(); |
182 | 202 |
183 private: | 203 private: |
184 MediaDrmBridge(const std::vector<uint8>& scheme_uuid, | 204 MediaDrmBridge(const std::vector<uint8>& scheme_uuid, |
185 const SessionMessageCB& session_message_cb, | 205 const SessionMessageCB& session_message_cb, |
186 const SessionClosedCB& session_closed_cb, | 206 const SessionClosedCB& session_closed_cb, |
187 const SessionErrorCB& session_error_cb, | 207 const SessionErrorCB& session_error_cb, |
188 const SessionKeysChangeCB& session_keys_change_cb); | 208 const SessionKeysChangeCB& session_keys_change_cb, |
209 Delegate* delegate); | |
189 | 210 |
190 static bool IsSecureDecoderRequired(SecurityLevel security_level); | 211 static bool IsSecureDecoderRequired(SecurityLevel security_level); |
191 | 212 |
192 // Get the security level of the media. | 213 // Get the security level of the media. |
193 SecurityLevel GetSecurityLevel(); | 214 SecurityLevel GetSecurityLevel(); |
194 | 215 |
195 // UUID of the key system. | 216 // UUID of the key system. |
196 std::vector<uint8> scheme_uuid_; | 217 std::vector<uint8> scheme_uuid_; |
197 | 218 |
198 // Java MediaDrm instance. | 219 // Java MediaDrm instance. |
199 base::android::ScopedJavaGlobalRef<jobject> j_media_drm_; | 220 base::android::ScopedJavaGlobalRef<jobject> j_media_drm_; |
200 | 221 |
222 Delegate* const delegate_; | |
223 | |
201 // Callbacks for firing session events. | 224 // Callbacks for firing session events. |
202 SessionMessageCB session_message_cb_; | 225 SessionMessageCB session_message_cb_; |
203 SessionClosedCB session_closed_cb_; | 226 SessionClosedCB session_closed_cb_; |
204 SessionErrorCB session_error_cb_; | 227 SessionErrorCB session_error_cb_; |
205 SessionKeysChangeCB session_keys_change_cb_; | 228 SessionKeysChangeCB session_keys_change_cb_; |
206 | 229 |
207 base::Closure media_crypto_ready_cb_; | 230 base::Closure media_crypto_ready_cb_; |
208 | 231 |
209 ResetCredentialsCB reset_credentials_cb_; | 232 ResetCredentialsCB reset_credentials_cb_; |
210 | 233 |
211 PlayerTrackerImpl player_tracker_; | 234 PlayerTrackerImpl player_tracker_; |
212 | 235 |
213 CdmPromiseAdapter cdm_promise_adapter_; | 236 CdmPromiseAdapter cdm_promise_adapter_; |
214 | 237 |
215 DISALLOW_COPY_AND_ASSIGN(MediaDrmBridge); | 238 DISALLOW_COPY_AND_ASSIGN(MediaDrmBridge); |
216 }; | 239 }; |
217 | 240 |
218 } // namespace media | 241 } // namespace media |
219 | 242 |
220 #endif // MEDIA_BASE_ANDROID_MEDIA_DRM_BRIDGE_H_ | 243 #endif // MEDIA_BASE_ANDROID_MEDIA_DRM_BRIDGE_H_ |
OLD | NEW |