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 "media/base/media_export.h" | 13 #include "media/base/media_export.h" |
14 #include "media/base/media_keys.h" | 14 #include "media/base/media_keys.h" |
15 | 15 |
16 namespace media { | 16 namespace media { |
17 | 17 |
18 // This class provides DRM services for android EME implementation. | 18 // This class provides DRM services for android EME implementation. |
19 // TODO(qinmin): implement all the functions in this class. | 19 // TODO(qinmin): implement all the functions in this class. |
20 class MEDIA_EXPORT MediaDrmBridge : public MediaKeys { | 20 class MEDIA_EXPORT MediaDrmBridge : public MediaKeys { |
21 public: | 21 public: |
22 // TODO(xhwang): Pass in |key_system|. | |
23 MediaDrmBridge(int media_keys_id, const std::vector<uint8>& uuid); | |
24 virtual ~MediaDrmBridge(); | 22 virtual ~MediaDrmBridge(); |
25 | 23 |
| 24 // Returns a MediaDrmBridge instance if |uuid| is supported, or a NULL |
| 25 // pointer otherwise. |
| 26 static MediaDrmBridge* Create(int media_keys_id, |
| 27 const std::vector<uint8>& uuid); |
| 28 |
26 // Checks whether DRM is available. | 29 // Checks whether DRM is available. |
27 static bool IsAvailable(); | 30 static bool IsAvailable(); |
28 | 31 |
29 // MediaKeys implementations. | 32 // MediaKeys implementations. |
30 virtual bool GenerateKeyRequest(const std::string& type, | 33 virtual bool GenerateKeyRequest(const std::string& type, |
31 const uint8* init_data, | 34 const uint8* init_data, |
32 int init_data_length) OVERRIDE; | 35 int init_data_length) OVERRIDE; |
33 virtual void AddKey(const uint8* key, int key_length, | 36 virtual void AddKey(const uint8* key, int key_length, |
34 const uint8* init_data, int init_data_length, | 37 const uint8* init_data, int init_data_length, |
35 const std::string& session_id) OVERRIDE; | 38 const std::string& session_id) OVERRIDE; |
36 virtual void CancelKeyRequest(const std::string& session_id) OVERRIDE; | 39 virtual void CancelKeyRequest(const std::string& session_id) OVERRIDE; |
37 | 40 |
38 // Drm related message was received. | 41 // Drm related message was received. |
39 void OnDrmEvent(JNIEnv* env, jobject, jstring session_id, | 42 void OnDrmEvent(JNIEnv* env, jobject, jstring session_id, |
40 jint event, jint extra, jstring data); | 43 jint event, jint extra, jstring data); |
41 | 44 |
42 // Called after we got the response for GenerateKeyRequest(). | 45 // Called after we got the response for GenerateKeyRequest(). |
43 void OnKeyMessage(JNIEnv* env, jobject, jstring session_id, | 46 void OnKeyMessage(JNIEnv* env, jobject, jstring session_id, |
44 jbyteArray message, jstring destination_url); | 47 jbyteArray message, jstring destination_url); |
45 | 48 |
46 // Methods to create and release a MediaCrypto object. | 49 // Methods to create and release a MediaCrypto object. |
47 base::android::ScopedJavaLocalRef<jobject> CreateMediaCrypto( | 50 base::android::ScopedJavaLocalRef<jobject> CreateMediaCrypto( |
48 const std::string& session_id); | 51 const std::string& session_id); |
49 void ReleaseMediaCrypto(const std::string& session_id); | 52 void ReleaseMediaCrypto(const std::string& session_id); |
50 | 53 |
51 int media_keys_id() const { return media_keys_id_; } | 54 int media_keys_id() const { return media_keys_id_; } |
52 | 55 |
53 private: | 56 private: |
| 57 MediaDrmBridge(int media_keys_id, const std::vector<uint8>& uuid); |
| 58 |
54 // Id of the MediaKeys object. | 59 // Id of the MediaKeys object. |
55 int media_keys_id_; | 60 int media_keys_id_; |
56 | 61 |
| 62 // UUID of the key system. |
| 63 std::vector<uint8> uuid_; |
| 64 |
57 DISALLOW_COPY_AND_ASSIGN(MediaDrmBridge); | 65 DISALLOW_COPY_AND_ASSIGN(MediaDrmBridge); |
58 }; | 66 }; |
59 | 67 |
60 } // namespace media | 68 } // namespace media |
61 | 69 |
62 #endif // MEDIA_BASE_ANDROID_MEDIA_DRM_BRIDGE_H_ | 70 #endif // MEDIA_BASE_ANDROID_MEDIA_DRM_BRIDGE_H_ |
OLD | NEW |