| OLD | NEW |
| 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 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_DECRYPTOR_H_ | 5 #ifndef MEDIA_BASE_DECRYPTOR_H_ |
| 6 #define MEDIA_BASE_DECRYPTOR_H_ | 6 #define MEDIA_BASE_DECRYPTOR_H_ |
| 7 | 7 |
| 8 #include <list> | 8 #include <list> |
| 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/ref_counted.h" | 12 #include "base/memory/ref_counted.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 AudioDecoderConfig; | 17 class AudioDecoderConfig; |
| 18 class DataBuffer; | 18 class DataBuffer; |
| 19 class DecoderBuffer; | 19 class DecoderBuffer; |
| 20 class MediaKeys; | |
| 21 class VideoDecoderConfig; | 20 class VideoDecoderConfig; |
| 22 class VideoFrame; | 21 class VideoFrame; |
| 23 | 22 |
| 24 // Decrypts (and decodes) encrypted buffer. | 23 // Decrypts (and decodes) encrypted buffer. |
| 25 // | 24 // |
| 26 // All methods are called on the (video/audio) decoder thread. Decryptor | 25 // All methods are called on the (video/audio) decoder thread. Decryptor |
| 27 // implementations must be thread safe when methods are called this way. | 26 // implementations must be thread safe when methods are called this way. |
| 28 // Depending on the implementation callbacks may be fired synchronously or | 27 // Depending on the implementation callbacks may be fired synchronously or |
| 29 // asynchronously. | 28 // asynchronously. |
| 30 class MEDIA_EXPORT Decryptor { | 29 class MEDIA_EXPORT Decryptor { |
| 31 public: | 30 public: |
| 32 // TODO(xhwang): Replace kError with kDecryptError and kDecodeError. | 31 // TODO(xhwang): Replace kError with kDecryptError and kDecodeError. |
| 33 // TODO(xhwang): Replace kNeedMoreData with kNotEnoughData. | 32 // TODO(xhwang): Replace kNeedMoreData with kNotEnoughData. |
| 34 enum Status { | 33 enum Status { |
| 35 kSuccess, // Decryption successfully completed. Decrypted buffer ready. | 34 kSuccess, // Decryption successfully completed. Decrypted buffer ready. |
| 36 kNoKey, // No key is available to decrypt. | 35 kNoKey, // No key is available to decrypt. |
| 37 kNeedMoreData, // Decoder needs more data to produce a frame. | 36 kNeedMoreData, // Decoder needs more data to produce a frame. |
| 38 kError // Key is available but an error occurred during decryption. | 37 kError // Key is available but an error occurred during decryption. |
| 39 }; | 38 }; |
| 40 | 39 |
| 41 // TODO(xhwang): Unify this with DemuxerStream::Type. | 40 // TODO(xhwang): Unify this with DemuxerStream::Type. |
| 42 enum StreamType { | 41 enum StreamType { |
| 43 kAudio, | 42 kAudio, |
| 44 kVideo | 43 kVideo |
| 45 }; | 44 }; |
| 46 | 45 |
| 47 Decryptor(); | 46 Decryptor(); |
| 48 virtual ~Decryptor(); | 47 virtual ~Decryptor(); |
| 49 | 48 |
| 50 // Gets the MediaKey object associated with the Decryptor. Returns NULL if | |
| 51 // no MediaKey object is associated. The returned object is only guaranteed | |
| 52 // to be valid during the Decryptor's lifetime. | |
| 53 virtual MediaKeys* GetMediaKeys() = 0; | |
| 54 | |
| 55 // Indicates that a new key has been added to the MediaKeys object associated | 49 // Indicates that a new key has been added to the MediaKeys object associated |
| 56 // with the Decryptor. | 50 // with the Decryptor. |
| 57 typedef base::Callback<void()> NewKeyCB; | 51 typedef base::Callback<void()> NewKeyCB; |
| 58 | 52 |
| 59 // Registers a NewKeyCB which should be called when a new key is added to the | 53 // Registers a NewKeyCB which should be called when a new key is added to the |
| 60 // decryptor. Only one NewKeyCB can be registered for one |stream_type|. | 54 // decryptor. Only one NewKeyCB can be registered for one |stream_type|. |
| 61 // If this function is called multiple times for the same |stream_type|, the | 55 // If this function is called multiple times for the same |stream_type|, the |
| 62 // previously registered callback will be replaced. In other words, | 56 // previously registered callback will be replaced. In other words, |
| 63 // registering a null callback cancels the originally registered callback. | 57 // registering a null callback cancels the originally registered callback. |
| 64 virtual void RegisterNewKeyCB(StreamType stream_type, | 58 virtual void RegisterNewKeyCB(StreamType stream_type, |
| (...skipping 110 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 175 // notification. When the decryptor is ready, notification will be sent | 169 // notification. When the decryptor is ready, notification will be sent |
| 176 // through the provided callback. | 170 // through the provided callback. |
| 177 // Calling this callback with a null callback cancels previously registered | 171 // Calling this callback with a null callback cancels previously registered |
| 178 // decryptor ready notification. Any previously provided callback will be | 172 // decryptor ready notification. Any previously provided callback will be |
| 179 // fired immediately with NULL. | 173 // fired immediately with NULL. |
| 180 typedef base::Callback<void(const DecryptorReadyCB&)> SetDecryptorReadyCB; | 174 typedef base::Callback<void(const DecryptorReadyCB&)> SetDecryptorReadyCB; |
| 181 | 175 |
| 182 } // namespace media | 176 } // namespace media |
| 183 | 177 |
| 184 #endif // MEDIA_BASE_DECRYPTOR_H_ | 178 #endif // MEDIA_BASE_DECRYPTOR_H_ |
| OLD | NEW |