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 <stdint.h> | 9 #include <stdint.h> |
10 | 10 |
11 #include <memory> | 11 #include <memory> |
12 #include <string> | 12 #include <string> |
13 #include <vector> | 13 #include <vector> |
14 | 14 |
15 #include "base/android/scoped_java_ref.h" | 15 #include "base/android/scoped_java_ref.h" |
16 #include "base/callback.h" | 16 #include "base/callback.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/weak_ptr.h" | 19 #include "base/memory/weak_ptr.h" |
20 #include "media/base/android/media_drm_bridge_cdm_context.h" | 20 #include "media/base/android/media_drm_bridge_cdm_context.h" |
21 #include "media/base/cdm_promise.h" | 21 #include "media/base/cdm_promise.h" |
22 #include "media/base/cdm_promise_adapter.h" | 22 #include "media/base/cdm_promise_adapter.h" |
| 23 #include "media/base/content_decryption_module.h" |
23 #include "media/base/media_export.h" | 24 #include "media/base/media_export.h" |
24 #include "media/base/media_keys.h" | |
25 #include "media/base/player_tracker.h" | 25 #include "media/base/player_tracker.h" |
26 #include "media/base/provision_fetcher.h" | 26 #include "media/base/provision_fetcher.h" |
27 #include "media/cdm/player_tracker_impl.h" | 27 #include "media/cdm/player_tracker_impl.h" |
28 #include "url/gurl.h" | 28 #include "url/gurl.h" |
29 | 29 |
30 namespace base { | 30 namespace base { |
31 class SingleThreadTaskRunner; | 31 class SingleThreadTaskRunner; |
32 } | 32 } |
33 | 33 |
34 namespace media { | 34 namespace media { |
35 | 35 |
36 // Implements a CDM using Android MediaDrm API. | 36 // Implements a CDM using Android MediaDrm API. |
37 // | 37 // |
38 // Thread Safety: | 38 // Thread Safety: |
39 // | 39 // |
40 // This class lives on the thread where it is created. All methods must be | 40 // This class lives on the thread where it is created. All methods must be |
41 // called on the |task_runner_| except for the PlayerTracker methods and | 41 // called on the |task_runner_| except for the PlayerTracker methods and |
42 // SetMediaCryptoReadyCB(), which can be called on any thread. | 42 // SetMediaCryptoReadyCB(), which can be called on any thread. |
43 | 43 |
44 class MEDIA_EXPORT MediaDrmBridge : public MediaKeys, public PlayerTracker { | 44 class MEDIA_EXPORT MediaDrmBridge : public ContentDecryptionModule, |
| 45 public PlayerTracker { |
45 public: | 46 public: |
46 // TODO(ddorwin): These are specific to Widevine. http://crbug.com/459400 | 47 // TODO(ddorwin): These are specific to Widevine. http://crbug.com/459400 |
47 enum SecurityLevel { | 48 enum SecurityLevel { |
48 SECURITY_LEVEL_DEFAULT = 0, | 49 SECURITY_LEVEL_DEFAULT = 0, |
49 SECURITY_LEVEL_1 = 1, | 50 SECURITY_LEVEL_1 = 1, |
50 SECURITY_LEVEL_3 = 3, | 51 SECURITY_LEVEL_3 = 3, |
51 }; | 52 }; |
52 | 53 |
53 using JavaObjectPtr = | 54 using JavaObjectPtr = |
54 std::unique_ptr<base::android::ScopedJavaGlobalRef<jobject>>; | 55 std::unique_ptr<base::android::ScopedJavaGlobalRef<jobject>>; |
(...skipping 39 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
94 const SessionKeysChangeCB& session_keys_change_cb, | 95 const SessionKeysChangeCB& session_keys_change_cb, |
95 const SessionExpirationUpdateCB& session_expiration_update_cb); | 96 const SessionExpirationUpdateCB& session_expiration_update_cb); |
96 | 97 |
97 // Same as Create() except that no session callbacks are provided. This is | 98 // Same as Create() except that no session callbacks are provided. This is |
98 // used when we need to use MediaDrmBridge without creating any sessions. | 99 // used when we need to use MediaDrmBridge without creating any sessions. |
99 static scoped_refptr<MediaDrmBridge> CreateWithoutSessionSupport( | 100 static scoped_refptr<MediaDrmBridge> CreateWithoutSessionSupport( |
100 const std::string& key_system, | 101 const std::string& key_system, |
101 SecurityLevel security_level, | 102 SecurityLevel security_level, |
102 const CreateFetcherCB& create_fetcher_cb); | 103 const CreateFetcherCB& create_fetcher_cb); |
103 | 104 |
104 // MediaKeys implementation. | 105 // ContentDecryptionModule implementation. |
105 void SetServerCertificate( | 106 void SetServerCertificate( |
106 const std::vector<uint8_t>& certificate, | 107 const std::vector<uint8_t>& certificate, |
107 std::unique_ptr<media::SimpleCdmPromise> promise) override; | 108 std::unique_ptr<media::SimpleCdmPromise> promise) override; |
108 void CreateSessionAndGenerateRequest( | 109 void CreateSessionAndGenerateRequest( |
109 SessionType session_type, | 110 SessionType session_type, |
110 media::EmeInitDataType init_data_type, | 111 media::EmeInitDataType init_data_type, |
111 const std::vector<uint8_t>& init_data, | 112 const std::vector<uint8_t>& init_data, |
112 std::unique_ptr<media::NewSessionCdmPromise> promise) override; | 113 std::unique_ptr<media::NewSessionCdmPromise> promise) override; |
113 void LoadSession( | 114 void LoadSession( |
114 SessionType session_type, | 115 SessionType session_type, |
(...skipping 201 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
316 | 317 |
317 // NOTE: Weak pointers must be invalidated before all other member variables. | 318 // NOTE: Weak pointers must be invalidated before all other member variables. |
318 base::WeakPtrFactory<MediaDrmBridge> weak_factory_; | 319 base::WeakPtrFactory<MediaDrmBridge> weak_factory_; |
319 | 320 |
320 DISALLOW_COPY_AND_ASSIGN(MediaDrmBridge); | 321 DISALLOW_COPY_AND_ASSIGN(MediaDrmBridge); |
321 }; | 322 }; |
322 | 323 |
323 } // namespace media | 324 } // namespace media |
324 | 325 |
325 #endif // MEDIA_BASE_ANDROID_MEDIA_DRM_BRIDGE_H_ | 326 #endif // MEDIA_BASE_ANDROID_MEDIA_DRM_BRIDGE_H_ |
OLD | NEW |