Chromium Code Reviews| OLD | NEW |
|---|---|
| 1 // Copyright 2013 The Chromium Authors. All rights reserved. | 1 // Copyright 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_MEDIA_KEYS_H_ | 5 #ifndef MEDIA_BASE_MEDIA_KEYS_H_ |
| 6 #define MEDIA_BASE_MEDIA_KEYS_H_ | 6 #define MEDIA_BASE_MEDIA_KEYS_H_ |
| 7 | 7 |
| 8 #include <string> | 8 #include <string> |
| 9 #include <vector> | 9 #include <vector> |
| 10 | 10 |
| 11 #include "base/basictypes.h" | 11 #include "base/basictypes.h" |
| 12 #include "base/callback.h" | 12 #include "base/callback.h" |
| 13 #include "base/memory/scoped_ptr.h" | 13 #include "base/memory/scoped_ptr.h" |
| 14 #include "media/base/media_export.h" | 14 #include "media/base/media_export.h" |
| 15 | 15 |
| 16 namespace media { | 16 namespace media { |
| 17 | 17 |
| 18 class Decryptor; | 18 class Decryptor; |
| 19 | 19 |
| 20 template <typename T> | |
| 21 class CdmPromise; | |
| 22 | |
| 23 typedef CdmPromise<std::string> NewSessionCdmPromise; | |
| 24 typedef CdmPromise<void> SimpleCdmPromise; | |
| 25 | |
| 20 // Performs media key operations. | 26 // Performs media key operations. |
| 21 // | 27 // |
| 22 // All key operations are called on the renderer thread. Therefore, these calls | 28 // All key operations are called on the renderer thread. Therefore, these calls |
| 23 // should be fast and nonblocking; key events should be fired asynchronously. | 29 // should be fast and nonblocking; key events should be fired asynchronously. |
| 24 class MEDIA_EXPORT MediaKeys { | 30 class MEDIA_EXPORT MediaKeys { |
| 25 public: | 31 public: |
| 26 // Reported to UMA, so never reuse a value! | 32 // Reported to UMA, so never reuse a value! |
| 27 // Must be kept in sync with blink::WebMediaPlayerClient::MediaKeyErrorCode | 33 // Must be kept in sync with blink::WebMediaPlayerClient::MediaKeyErrorCode |
| 28 // (enforced in webmediaplayer_impl.cc). | 34 // (enforced in webmediaplayer_impl.cc). |
| 29 enum KeyError { | 35 enum KeyError { |
|
ddorwin
2014/05/23 16:41:09
This is no longer used in this header, so it proba
jrummell
2014/05/29 00:54:40
And in android/proxy_media_keys (which might get f
| |
| 30 kUnknownError = 1, | 36 kUnknownError = 1, |
| 31 kClientError, | 37 kClientError, |
| 32 // The commented v0.1b values below have never been used. | 38 // The commented v0.1b values below have never been used. |
| 33 // kServiceError, | 39 // kServiceError, |
| 34 kOutputError = 4, | 40 kOutputError = 4, |
| 35 // kHardwareChangeError, | 41 // kHardwareChangeError, |
| 36 // kDomainError, | 42 // kDomainError, |
| 37 kMaxKeyError // Must be last and greater than any legit value. | 43 kMaxKeyError // Must be last and greater than any legit value. |
| 38 }; | 44 }; |
| 39 | 45 |
| 46 // Must be a superset of cdm::MediaKeyException. | |
| 47 enum Exception { | |
| 48 EXCEPTION_NO_MODIFICATION_ALLOWED_ERROR, | |
| 49 EXCEPTION_NOT_FOUND_ERROR, | |
| 50 EXCEPTION_NOT_SUPPORTED_ERROR, | |
| 51 EXCEPTION_INVALID_STATE_ERROR, | |
| 52 EXCEPTION_INVALID_MODIFICATION_ERROR, | |
| 53 EXCEPTION_INVALID_ACCESS_ERROR, | |
| 54 EXCEPTION_SECURITY_ERROR, | |
| 55 EXCEPTION_ABORT_ERROR, | |
| 56 EXCEPTION_QUOTA_EXCEEDED_ERROR, | |
| 57 EXCEPTION_TIMEOUT_ERROR, | |
| 58 EXCEPTION_UNKNOWN_ERROR, | |
| 59 EXCEPTION_DATA_ERROR, | |
| 60 EXCEPTION_VERSION_ERROR, | |
| 61 EXCEPTION_NOT_READABLE_ERROR, | |
| 62 EXCEPTION_OPERATION_ERROR, | |
| 63 EXCEPTION_CLIENT_ERROR, | |
| 64 EXCEPTION_OUTPUT_ERROR | |
|
xhwang
2014/05/23 06:01:23
Hmm, DOM "exceptions" are all "error"s... Generall
ddorwin
2014/05/23 16:41:09
I don't think there is a general *requirement* for
xhwang
2014/05/23 16:47:36
I have no strong opinion on this one :)
jrummell
2014/05/29 00:54:40
Done.
jrummell
2014/05/29 00:54:40
Done.
| |
| 65 }; | |
| 66 | |
| 67 // Type of license required when creating/loading a session. | |
| 68 // Must be consistent with the values specified in the spec: | |
| 69 // https://dvcs.w3.org/hg/html-media/raw-file/default/encrypted-media/encrypte d-media.html#extensions | |
| 70 enum SessionType { | |
| 71 SESSION_TYPE_TEMPORARY, | |
| 72 SESSION_TYPE_PERSISTENT | |
| 73 }; | |
| 74 | |
| 40 const static uint32 kInvalidSessionId = 0; | 75 const static uint32 kInvalidSessionId = 0; |
| 41 | 76 |
| 42 MediaKeys(); | 77 MediaKeys(); |
| 43 virtual ~MediaKeys(); | 78 virtual ~MediaKeys(); |
| 44 | 79 |
| 45 // Creates a session with the |content_type| and |init_data| provided. | 80 // Creates a session with the |init_data_type|, |init_data| and |session_type| |
| 46 // Returns true if a session is successfully created, false otherwise. | 81 // provided. |
| 47 // Note: UpdateSession() and ReleaseSession() should only be called after | 82 // Note: UpdateSession() and ReleaseSession() should only be called after |
| 48 // SessionCreatedCB is fired. | 83 // |promise| is resolved. |
| 49 // TODO(jrummell): Remove return value when prefixed API is removed. | 84 virtual void CreateSession(const std::string& init_data_type, |
| 50 // See http://crbug.com/342510 | |
| 51 virtual bool CreateSession(uint32 session_id, | |
| 52 const std::string& content_type, | |
| 53 const uint8* init_data, | 85 const uint8* init_data, |
| 54 int init_data_length) = 0; | 86 int init_data_length, |
| 87 SessionType session_type, | |
| 88 scoped_ptr<NewSessionCdmPromise> promise) = 0; | |
| 55 | 89 |
| 56 // Loads a session with the |web_session_id| provided. | 90 // Loads a session with the |web_session_id| provided. |
| 57 // Note: UpdateSession() and ReleaseSession() should only be called after | 91 // Note: UpdateSession() and ReleaseSession() should only be called after |
| 58 // SessionCreatedCB is fired. | 92 // |promise| is resolved. |
| 59 virtual void LoadSession(uint32 session_id, | 93 virtual void LoadSession(const std::string& web_session_id, |
| 60 const std::string& web_session_id) = 0; | 94 scoped_ptr<NewSessionCdmPromise> promise) = 0; |
| 61 | 95 |
| 62 // Updates a session specified by |session_id| with |response|. | 96 // Updates a session specified by |web_session_id| with |response|. |
| 63 virtual void UpdateSession(uint32 session_id, | 97 virtual void UpdateSession(const std::string& web_session_id, |
| 64 const uint8* response, | 98 const uint8* response, |
| 65 int response_length) = 0; | 99 int response_length, |
| 100 scoped_ptr<SimpleCdmPromise> promise) = 0; | |
| 66 | 101 |
| 67 // Releases the session specified by |session_id|. | 102 // Releases the session specified by |web_session_id|. |
| 68 virtual void ReleaseSession(uint32 session_id) = 0; | 103 virtual void ReleaseSession(const std::string& web_session_id, |
| 104 scoped_ptr<SimpleCdmPromise> promise) = 0; | |
| 69 | 105 |
| 70 // Gets the Decryptor object associated with the MediaKeys. Returns NULL if | 106 // Gets the Decryptor object associated with the MediaKeys. Returns NULL if |
| 71 // no Decryptor object is associated. The returned object is only guaranteed | 107 // no Decryptor object is associated. The returned object is only guaranteed |
| 72 // to be valid during the MediaKeys' lifetime. | 108 // to be valid during the MediaKeys' lifetime. |
| 73 virtual Decryptor* GetDecryptor(); | 109 virtual Decryptor* GetDecryptor(); |
| 74 | 110 |
| 75 private: | 111 private: |
| 76 DISALLOW_COPY_AND_ASSIGN(MediaKeys); | 112 DISALLOW_COPY_AND_ASSIGN(MediaKeys); |
| 77 }; | 113 }; |
| 78 | 114 |
| 79 // Key event callbacks. See the spec for details: | 115 // Key event callbacks. See the spec for details: |
| 80 // https://dvcs.w3.org/hg/html-media/raw-file/default/encrypted-media/encrypted- media.html#event-summary | 116 // https://dvcs.w3.org/hg/html-media/raw-file/default/encrypted-media/encrypted- media.html#event-summary |
| 81 typedef base::Callback< | |
| 82 void(uint32 session_id, const std::string& web_session_id)> | |
| 83 SessionCreatedCB; | |
| 84 | |
| 85 // TODO(xhwang): Use GURL for |destination_url|. See http://crbug.com/372877 | 117 // TODO(xhwang): Use GURL for |destination_url|. See http://crbug.com/372877 |
| 86 typedef base::Callback<void(uint32 session_id, | 118 typedef base::Callback<void(const std::string& web_session_id, |
| 87 const std::vector<uint8>& message, | 119 const std::vector<uint8>& message, |
| 88 const std::string& destination_url)> | 120 const std::string& destination_url)> |
| 89 SessionMessageCB; | 121 SessionMessageCB; |
| 90 | 122 |
| 91 typedef base::Callback<void(uint32 session_id)> SessionReadyCB; | 123 typedef base::Callback<void(const std::string& web_session_id)> SessionReadyCB; |
| 92 | 124 |
| 93 typedef base::Callback<void(uint32 session_id)> SessionClosedCB; | 125 typedef base::Callback<void(const std::string& web_session_id)> SessionClosedCB; |
| 94 | 126 |
| 95 typedef base::Callback<void(uint32 session_id, | 127 typedef base::Callback<void(const std::string& web_session_id, |
| 96 media::MediaKeys::KeyError error_code, | 128 MediaKeys::Exception exception_code, |
| 97 uint32 system_code)> SessionErrorCB; | 129 uint32 system_code, |
| 130 const std::string& error_message)> SessionErrorCB; | |
| 98 | 131 |
| 99 } // namespace media | 132 } // namespace media |
| 100 | 133 |
| 101 #endif // MEDIA_BASE_MEDIA_KEYS_H_ | 134 #endif // MEDIA_BASE_MEDIA_KEYS_H_ |
| OLD | NEW |