| 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/media_export.h" | 15 #include "media/base/media_export.h" |
| 16 #include "media/base/media_keys.h" | 16 #include "media/base/media_keys.h" |
| 17 #include "url/gurl.h" | 17 #include "url/gurl.h" |
| 18 | 18 |
| 19 class GURL; | 19 class GURL; |
| 20 | 20 |
| 21 namespace media { | 21 namespace media { |
| 22 | 22 |
| 23 class MediaPlayerManager; | 23 class MediaPlayerManager; |
| 24 | 24 |
| 25 // This class provides DRM services for android EME implementation. | 25 // This class provides DRM services for android EME implementation. |
| 26 // TODO(qinmin): implement all the functions in this class. | 26 // TODO(qinmin): implement all the functions in this class. |
| 27 class MEDIA_EXPORT MediaDrmBridge : public MediaKeys { | 27 class MEDIA_EXPORT MediaDrmBridge { |
| 28 public: | 28 public: |
| 29 enum SecurityLevel { | 29 enum SecurityLevel { |
| 30 SECURITY_LEVEL_NONE = 0, | 30 SECURITY_LEVEL_NONE = 0, |
| 31 SECURITY_LEVEL_1 = 1, | 31 SECURITY_LEVEL_1 = 1, |
| 32 SECURITY_LEVEL_3 = 3, | 32 SECURITY_LEVEL_3 = 3, |
| 33 }; | 33 }; |
| 34 | 34 |
| 35 typedef base::Callback<void(bool)> ResetCredentialsCB; | 35 typedef base::Callback<void(bool)> ResetCredentialsCB; |
| 36 | 36 |
| 37 virtual ~MediaDrmBridge(); | 37 virtual ~MediaDrmBridge(); |
| (...skipping 43 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 81 | 81 |
| 82 // Returns true if |security_level| is successfully set, or false otherwise. | 82 // Returns true if |security_level| is successfully set, or false otherwise. |
| 83 // Call this function right after Create() and before any other calls. | 83 // Call this function right after Create() and before any other calls. |
| 84 // Note: | 84 // Note: |
| 85 // - If this function is not called, the default security level of the device | 85 // - If this function is not called, the default security level of the device |
| 86 // will be used. | 86 // will be used. |
| 87 // - It's recommended to call this function only once on a MediaDrmBridge | 87 // - It's recommended to call this function only once on a MediaDrmBridge |
| 88 // object. Calling this function multiples times may cause errors. | 88 // object. Calling this function multiples times may cause errors. |
| 89 bool SetSecurityLevel(SecurityLevel security_level); | 89 bool SetSecurityLevel(SecurityLevel security_level); |
| 90 | 90 |
| 91 // MediaKeys implementations. | 91 // Media key operations. |
| 92 virtual bool CreateSession(uint32 session_id, | 92 bool CreateSession(uint32 session_id, |
| 93 const std::string& content_type, | 93 const std::string& content_type, |
| 94 const uint8* init_data, | 94 const uint8* init_data, |
| 95 int init_data_length) OVERRIDE; | 95 int init_data_length); |
| 96 virtual void LoadSession(uint32 session_id, | 96 void LoadSession(uint32 session_id, const std::string& web_session_id); |
| 97 const std::string& web_session_id) OVERRIDE; | 97 void UpdateSession(uint32 session_id, |
| 98 virtual void UpdateSession(uint32 session_id, | 98 const uint8* response, |
| 99 const uint8* response, | 99 int response_length); |
| 100 int response_length) OVERRIDE; | 100 void ReleaseSession(uint32 session_id); |
| 101 virtual void ReleaseSession(uint32 session_id) OVERRIDE; | |
| 102 | 101 |
| 103 // Returns a MediaCrypto object if it's already created. Returns a null object | 102 // Returns a MediaCrypto object if it's already created. Returns a null object |
| 104 // otherwise. | 103 // otherwise. |
| 105 base::android::ScopedJavaLocalRef<jobject> GetMediaCrypto(); | 104 base::android::ScopedJavaLocalRef<jobject> GetMediaCrypto(); |
| 106 | 105 |
| 107 // Sets callback which will be called when MediaCrypto is ready. | 106 // Sets callback which will be called when MediaCrypto is ready. |
| 108 // If |closure| is null, previously set callback will be cleared. | 107 // If |closure| is null, previously set callback will be cleared. |
| 109 void SetMediaCryptoReadyCB(const base::Closure& closure); | 108 void SetMediaCryptoReadyCB(const base::Closure& closure); |
| 110 | 109 |
| 111 // Called after a MediaCrypto object is created. | 110 // Called after a MediaCrypto object is created. |
| (...skipping 50 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 162 base::Closure media_crypto_ready_cb_; | 161 base::Closure media_crypto_ready_cb_; |
| 163 | 162 |
| 164 ResetCredentialsCB reset_credentials_cb_; | 163 ResetCredentialsCB reset_credentials_cb_; |
| 165 | 164 |
| 166 DISALLOW_COPY_AND_ASSIGN(MediaDrmBridge); | 165 DISALLOW_COPY_AND_ASSIGN(MediaDrmBridge); |
| 167 }; | 166 }; |
| 168 | 167 |
| 169 } // namespace media | 168 } // namespace media |
| 170 | 169 |
| 171 #endif // MEDIA_BASE_ANDROID_MEDIA_DRM_BRIDGE_H_ | 170 #endif // MEDIA_BASE_ANDROID_MEDIA_DRM_BRIDGE_H_ |
| OLD | NEW |