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

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

Issue 265993002: Add Promises for EME (Chromium side) (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Android changes Created 6 years, 6 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 "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 typedef base::Callback<
38 void(uint32 session_id, const std::string& web_session_id)>
39 SessionCreatedCB;
40
41 typedef base::Callback<void(uint32 session_id,
42 const std::vector<uint8>& message,
43 const GURL& destination_url)> SessionMessageCB;
44
45 typedef base::Callback<void(uint32 session_id)> SessionReadyCB;
46
47 typedef base::Callback<void(uint32 session_id)> SessionClosedCB;
48
49 typedef base::Callback<void(uint32 session_id,
50 media::MediaKeys::KeyError error_code,
51 uint32 system_code)> SessionErrorCB;
52
37 virtual ~MediaDrmBridge(); 53 virtual ~MediaDrmBridge();
38 54
39 // Checks whether MediaDRM is available. 55 // Checks whether MediaDRM is available.
40 // All other static methods check IsAvailable() internally. There's no need 56 // All other static methods check IsAvailable() internally. There's no need
41 // to check IsAvailable() explicitly before calling them. 57 // to check IsAvailable() explicitly before calling them.
42 static bool IsAvailable(); 58 static bool IsAvailable();
43 59
44 static bool IsSecurityLevelSupported(const std::string& key_system, 60 static bool IsSecurityLevelSupported(const std::string& key_system,
45 SecurityLevel security_level); 61 SecurityLevel security_level);
46 62
(...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after
81 97
82 // Returns true if |security_level| is successfully set, or false otherwise. 98 // Returns true if |security_level| is successfully set, or false otherwise.
83 // Call this function right after Create() and before any other calls. 99 // Call this function right after Create() and before any other calls.
84 // Note: 100 // Note:
85 // - If this function is not called, the default security level of the device 101 // - If this function is not called, the default security level of the device
86 // will be used. 102 // will be used.
87 // - It's recommended to call this function only once on a MediaDrmBridge 103 // - It's recommended to call this function only once on a MediaDrmBridge
88 // object. Calling this function multiples times may cause errors. 104 // object. Calling this function multiples times may cause errors.
89 bool SetSecurityLevel(SecurityLevel security_level); 105 bool SetSecurityLevel(SecurityLevel security_level);
90 106
91 // MediaKeys implementations. 107 // Media key operations.
92 virtual bool CreateSession(uint32 session_id, 108 bool CreateSession(uint32 session_id,
93 const std::string& content_type, 109 const std::string& content_type,
94 const uint8* init_data, 110 const uint8* init_data,
95 int init_data_length) OVERRIDE; 111 int init_data_length);
96 virtual void LoadSession(uint32 session_id, 112 void LoadSession(uint32 session_id, const std::string& web_session_id);
97 const std::string& web_session_id) OVERRIDE; 113 void UpdateSession(uint32 session_id,
98 virtual void UpdateSession(uint32 session_id, 114 const uint8* response,
99 const uint8* response, 115 int response_length);
100 int response_length) OVERRIDE; 116 void ReleaseSession(uint32 session_id);
101 virtual void ReleaseSession(uint32 session_id) OVERRIDE;
102 117
103 // Returns a MediaCrypto object if it's already created. Returns a null object 118 // Returns a MediaCrypto object if it's already created. Returns a null object
104 // otherwise. 119 // otherwise.
105 base::android::ScopedJavaLocalRef<jobject> GetMediaCrypto(); 120 base::android::ScopedJavaLocalRef<jobject> GetMediaCrypto();
106 121
107 // Sets callback which will be called when MediaCrypto is ready. 122 // Sets callback which will be called when MediaCrypto is ready.
108 // If |closure| is null, previously set callback will be cleared. 123 // If |closure| is null, previously set callback will be cleared.
109 void SetMediaCryptoReadyCB(const base::Closure& closure); 124 void SetMediaCryptoReadyCB(const base::Closure& closure);
110 125
111 // Called after a MediaCrypto object is created. 126 // Called after a MediaCrypto object is created.
(...skipping 50 matching lines...) Expand 10 before | Expand all | Expand 10 after
162 base::Closure media_crypto_ready_cb_; 177 base::Closure media_crypto_ready_cb_;
163 178
164 ResetCredentialsCB reset_credentials_cb_; 179 ResetCredentialsCB reset_credentials_cb_;
165 180
166 DISALLOW_COPY_AND_ASSIGN(MediaDrmBridge); 181 DISALLOW_COPY_AND_ASSIGN(MediaDrmBridge);
167 }; 182 };
168 183
169 } // namespace media 184 } // namespace media
170 185
171 #endif // MEDIA_BASE_ANDROID_MEDIA_DRM_BRIDGE_H_ 186 #endif // MEDIA_BASE_ANDROID_MEDIA_DRM_BRIDGE_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698