| 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_FILTERS_DECRYPTING_AUDIO_DECODER_H_ | 5 #ifndef MEDIA_FILTERS_DECRYPTING_AUDIO_DECODER_H_ |
| 6 #define MEDIA_FILTERS_DECRYPTING_AUDIO_DECODER_H_ | 6 #define MEDIA_FILTERS_DECRYPTING_AUDIO_DECODER_H_ |
| 7 | 7 |
| 8 #include "base/callback.h" | 8 #include "base/callback.h" |
| 9 #include "base/memory/ref_counted.h" | 9 #include "base/memory/ref_counted.h" |
| 10 #include "base/memory/scoped_ptr.h" | 10 #include "base/memory/scoped_ptr.h" |
| (...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 42 const SetDecryptorReadyCB& set_decryptor_ready_cb); | 42 const SetDecryptorReadyCB& set_decryptor_ready_cb); |
| 43 virtual ~DecryptingAudioDecoder(); | 43 virtual ~DecryptingAudioDecoder(); |
| 44 | 44 |
| 45 // AudioDecoder implementation. | 45 // AudioDecoder implementation. |
| 46 virtual void Initialize(const AudioDecoderConfig& config, | 46 virtual void Initialize(const AudioDecoderConfig& config, |
| 47 const PipelineStatusCB& status_cb, | 47 const PipelineStatusCB& status_cb, |
| 48 const OutputCB& output_cb) OVERRIDE; | 48 const OutputCB& output_cb) OVERRIDE; |
| 49 virtual void Decode(const scoped_refptr<DecoderBuffer>& buffer, | 49 virtual void Decode(const scoped_refptr<DecoderBuffer>& buffer, |
| 50 const DecodeCB& decode_cb) OVERRIDE; | 50 const DecodeCB& decode_cb) OVERRIDE; |
| 51 virtual void Reset(const base::Closure& closure) OVERRIDE; | 51 virtual void Reset(const base::Closure& closure) OVERRIDE; |
| 52 virtual void Stop() OVERRIDE; | |
| 53 | 52 |
| 54 private: | 53 private: |
| 55 // For a detailed state diagram please see this link: http://goo.gl/8jAok | 54 // For a detailed state diagram please see this link: http://goo.gl/8jAok |
| 56 // TODO(xhwang): Add a ASCII state diagram in this file after this class | 55 // TODO(xhwang): Add a ASCII state diagram in this file after this class |
| 57 // stabilizes. | 56 // stabilizes. |
| 58 // TODO(xhwang): Update this diagram for DecryptingAudioDecoder. | 57 // TODO(xhwang): Update this diagram for DecryptingAudioDecoder. |
| 59 enum State { | 58 enum State { |
| 60 kUninitialized = 0, | 59 kUninitialized = 0, |
| 61 kDecryptorRequested, | 60 kDecryptorRequested, |
| 62 kPendingDecoderInit, | 61 kPendingDecoderInit, |
| 63 kIdle, | 62 kIdle, |
| 64 kPendingDecode, | 63 kPendingDecode, |
| 65 kWaitingForKey, | 64 kWaitingForKey, |
| 66 kDecodeFinished, | 65 kDecodeFinished, |
| 67 kStopped, | 66 kError |
| 68 }; | 67 }; |
| 69 | 68 |
| 70 // Callback for DecryptorHost::RequestDecryptor(). | 69 // Callback for DecryptorHost::RequestDecryptor(). |
| 71 void SetDecryptor(Decryptor* decryptor); | 70 void SetDecryptor(Decryptor* decryptor); |
| 72 | 71 |
| 73 // Initializes the audio decoder on the |decryptor_| with |config_|. | 72 // Initializes the audio decoder on the |decryptor_| with |config_|. |
| 74 void InitializeDecoder(); | 73 void InitializeDecoder(); |
| 75 | 74 |
| 76 // Callback for Decryptor::InitializeAudioDecoder() during initialization. | 75 // Callback for Decryptor::InitializeAudioDecoder() during initialization. |
| 77 void FinishInitialization(bool success); | 76 void FinishInitialization(bool success); |
| (...skipping 16 matching lines...) Expand all Loading... |
| 94 void ProcessDecodedFrames(const Decryptor::AudioBuffers& frames); | 93 void ProcessDecodedFrames(const Decryptor::AudioBuffers& frames); |
| 95 | 94 |
| 96 scoped_refptr<base::SingleThreadTaskRunner> task_runner_; | 95 scoped_refptr<base::SingleThreadTaskRunner> task_runner_; |
| 97 | 96 |
| 98 State state_; | 97 State state_; |
| 99 | 98 |
| 100 PipelineStatusCB init_cb_; | 99 PipelineStatusCB init_cb_; |
| 101 OutputCB output_cb_; | 100 OutputCB output_cb_; |
| 102 DecodeCB decode_cb_; | 101 DecodeCB decode_cb_; |
| 103 base::Closure reset_cb_; | 102 base::Closure reset_cb_; |
| 104 base::Closure stop_cb_; | |
| 105 | 103 |
| 106 // The current decoder configuration. | 104 // The current decoder configuration. |
| 107 AudioDecoderConfig config_; | 105 AudioDecoderConfig config_; |
| 108 | 106 |
| 109 // Callback to request/cancel decryptor creation notification. | 107 // Callback to request/cancel decryptor creation notification. |
| 110 SetDecryptorReadyCB set_decryptor_ready_cb_; | 108 SetDecryptorReadyCB set_decryptor_ready_cb_; |
| 111 | 109 |
| 112 Decryptor* decryptor_; | 110 Decryptor* decryptor_; |
| 113 | 111 |
| 114 // The buffer that needs decrypting/decoding. | 112 // The buffer that needs decrypting/decoding. |
| (...skipping 11 matching lines...) Expand all Loading... |
| 126 // NOTE: Weak pointers must be invalidated before all other member variables. | 124 // NOTE: Weak pointers must be invalidated before all other member variables. |
| 127 base::WeakPtrFactory<DecryptingAudioDecoder> weak_factory_; | 125 base::WeakPtrFactory<DecryptingAudioDecoder> weak_factory_; |
| 128 base::WeakPtr<DecryptingAudioDecoder> weak_this_; | 126 base::WeakPtr<DecryptingAudioDecoder> weak_this_; |
| 129 | 127 |
| 130 DISALLOW_COPY_AND_ASSIGN(DecryptingAudioDecoder); | 128 DISALLOW_COPY_AND_ASSIGN(DecryptingAudioDecoder); |
| 131 }; | 129 }; |
| 132 | 130 |
| 133 } // namespace media | 131 } // namespace media |
| 134 | 132 |
| 135 #endif // MEDIA_FILTERS_DECRYPTING_AUDIO_DECODER_H_ | 133 #endif // MEDIA_FILTERS_DECRYPTING_AUDIO_DECODER_H_ |
| OLD | NEW |