| 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 | 9 |
| 10 #include "base/basictypes.h" | 10 #include "base/basictypes.h" |
| 11 #include "base/callback.h" | 11 #include "base/callback.h" |
| 12 #include "base/memory/scoped_ptr.h" | 12 #include "base/memory/scoped_ptr.h" |
| 13 #include "media/base/media_export.h" | 13 #include "media/base/media_export.h" |
| 14 | 14 |
| 15 namespace media { | 15 namespace media { |
| 16 | 16 |
| 17 class Decryptor; |
| 18 |
| 17 // Performs media key operations. | 19 // Performs media key operations. |
| 18 // | 20 // |
| 19 // All key operations are called on the renderer thread. Therefore, these calls | 21 // All key operations are called on the renderer thread. Therefore, these calls |
| 20 // should be fast and nonblocking; key events should be fired asynchronously. | 22 // should be fast and nonblocking; key events should be fired asynchronously. |
| 21 class MEDIA_EXPORT MediaKeys { | 23 class MEDIA_EXPORT MediaKeys { |
| 22 public: | 24 public: |
| 23 // Reported to UMA, so never reuse a value! | 25 // Reported to UMA, so never reuse a value! |
| 24 // Must be kept in sync with WebKit::WebMediaPlayerClient::MediaKeyErrorCode | 26 // Must be kept in sync with WebKit::WebMediaPlayerClient::MediaKeyErrorCode |
| 25 // (enforced in webmediaplayer_impl.cc). | 27 // (enforced in webmediaplayer_impl.cc). |
| 26 enum KeyError { | 28 enum KeyError { |
| (...skipping 22 matching lines...) Expand all Loading... |
| 49 // key. It can be any data that the key system accepts, such as a license. | 51 // key. It can be any data that the key system accepts, such as a license. |
| 50 // If multiple calls of this function set different keys for the same | 52 // If multiple calls of this function set different keys for the same |
| 51 // key ID, the older key will be replaced by the newer key. | 53 // key ID, the older key will be replaced by the newer key. |
| 52 virtual void AddKey(const uint8* key, int key_length, | 54 virtual void AddKey(const uint8* key, int key_length, |
| 53 const uint8* init_data, int init_data_length, | 55 const uint8* init_data, int init_data_length, |
| 54 const std::string& session_id) = 0; | 56 const std::string& session_id) = 0; |
| 55 | 57 |
| 56 // Cancels the key request specified by |session_id|. | 58 // Cancels the key request specified by |session_id|. |
| 57 virtual void CancelKeyRequest(const std::string& session_id) = 0; | 59 virtual void CancelKeyRequest(const std::string& session_id) = 0; |
| 58 | 60 |
| 61 // Gets the Decryptor object associated with the MediaKeys. Returns NULL if |
| 62 // no Decryptor object is associated. The returned object is only guaranteed |
| 63 // to be valid during the MediaKeys' lifetime. |
| 64 virtual Decryptor* GetDecryptor(); |
| 65 |
| 59 private: | 66 private: |
| 60 DISALLOW_COPY_AND_ASSIGN(MediaKeys); | 67 DISALLOW_COPY_AND_ASSIGN(MediaKeys); |
| 61 }; | 68 }; |
| 62 | 69 |
| 63 // Key event callbacks. See the spec for details: | 70 // Key event callbacks. See the spec for details: |
| 64 // http://dvcs.w3.org/hg/html-media/raw-file/eme-v0.1b/encrypted-media/encrypted
-media.html#event-summary | 71 // http://dvcs.w3.org/hg/html-media/raw-file/eme-v0.1b/encrypted-media/encrypted
-media.html#event-summary |
| 65 typedef base::Callback<void(const std::string& session_id)> KeyAddedCB; | 72 typedef base::Callback<void(const std::string& session_id)> KeyAddedCB; |
| 66 | 73 |
| 67 typedef base::Callback<void(const std::string& session_id, | 74 typedef base::Callback<void(const std::string& session_id, |
| 68 media::MediaKeys::KeyError error_code, | 75 media::MediaKeys::KeyError error_code, |
| 69 int system_code)> KeyErrorCB; | 76 int system_code)> KeyErrorCB; |
| 70 | 77 |
| 71 typedef base::Callback<void(const std::string& session_id, | 78 typedef base::Callback<void(const std::string& session_id, |
| 72 const std::string& message, | 79 const std::string& message, |
| 73 const std::string& default_url)> KeyMessageCB; | 80 const std::string& default_url)> KeyMessageCB; |
| 74 | 81 |
| 75 typedef base::Callback<void(const std::string& session_id, | 82 typedef base::Callback<void(const std::string& session_id, |
| 76 const std::string& type, | 83 const std::string& type, |
| 77 scoped_ptr<uint8[]> init_data, | 84 scoped_ptr<uint8[]> init_data, |
| 78 int init_data_size)> NeedKeyCB; | 85 int init_data_size)> NeedKeyCB; |
| 79 | 86 |
| 80 } // namespace media | 87 } // namespace media |
| 81 | 88 |
| 82 #endif // MEDIA_BASE_MEDIA_KEYS_H_ | 89 #endif // MEDIA_BASE_MEDIA_KEYS_H_ |
| OLD | NEW |