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 26 matching lines...) Expand all Loading... | |
37 // TODO(xhwang): Remove this restriction after http://crbug.com/169105 fixed. | 37 // TODO(xhwang): Remove this restriction after http://crbug.com/169105 fixed. |
38 static const int kSupportedBitsPerChannel; | 38 static const int kSupportedBitsPerChannel; |
39 | 39 |
40 DecryptingAudioDecoder( | 40 DecryptingAudioDecoder( |
41 const scoped_refptr<base::SingleThreadTaskRunner>& task_runner, | 41 const scoped_refptr<base::SingleThreadTaskRunner>& task_runner, |
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) OVERRIDE; | 47 const PipelineStatusCB& status_cb, |
48 const OutputCB& output_cb) OVERRIDE; | |
48 virtual void Decode(const scoped_refptr<DecoderBuffer>& buffer, | 49 virtual void Decode(const scoped_refptr<DecoderBuffer>& buffer, |
49 const DecodeCB& decode_cb) OVERRIDE; | 50 const DecodeCB& decode_cb) OVERRIDE; |
50 virtual scoped_refptr<AudioBuffer> GetDecodeOutput() OVERRIDE; | |
51 virtual void Reset(const base::Closure& closure) OVERRIDE; | 51 virtual void Reset(const base::Closure& closure) OVERRIDE; |
52 virtual void Stop() OVERRIDE; | 52 virtual void Stop() OVERRIDE; |
53 | 53 |
54 private: | 54 private: |
55 // For a detailed state diagram please see this link: http://goo.gl/8jAok | 55 // 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 | 56 // TODO(xhwang): Add a ASCII state diagram in this file after this class |
57 // stabilizes. | 57 // stabilizes. |
58 // TODO(xhwang): Update this diagram for DecryptingAudioDecoder. | 58 // TODO(xhwang): Update this diagram for DecryptingAudioDecoder. |
59 enum State { | 59 enum State { |
60 kUninitialized = 0, | 60 kUninitialized = 0, |
(...skipping 24 matching lines...) Expand all Loading... | |
85 | 85 |
86 // Callback for the |decryptor_| to notify this object that a new key has been | 86 // Callback for the |decryptor_| to notify this object that a new key has been |
87 // added. | 87 // added. |
88 void OnKeyAdded(); | 88 void OnKeyAdded(); |
89 | 89 |
90 // Resets decoder and calls |reset_cb_|. | 90 // Resets decoder and calls |reset_cb_|. |
91 void DoReset(); | 91 void DoReset(); |
92 | 92 |
93 // Sets timestamp and duration for |queued_audio_frames_| to make sure the | 93 // Sets timestamp and duration for |queued_audio_frames_| to make sure the |
94 // renderer always receives continuous frames without gaps and overlaps. | 94 // renderer always receives continuous frames without gaps and overlaps. |
95 void EnqueueFrames(const Decryptor::AudioBuffers& frames); | 95 void EnqueueFrames(const Decryptor::AudioBuffers& frames); |
xhwang
2014/05/29 22:15:14
This comment needs to be updated, and the method s
Sergey Ulanov
2014/06/03 00:08:11
Done.
| |
96 | 96 |
97 scoped_refptr<base::SingleThreadTaskRunner> task_runner_; | 97 scoped_refptr<base::SingleThreadTaskRunner> task_runner_; |
98 | 98 |
99 State state_; | 99 State state_; |
100 | 100 |
101 PipelineStatusCB init_cb_; | 101 PipelineStatusCB init_cb_; |
102 OutputCB output_cb_; | |
102 DecodeCB decode_cb_; | 103 DecodeCB decode_cb_; |
103 base::Closure reset_cb_; | 104 base::Closure reset_cb_; |
104 base::Closure stop_cb_; | 105 base::Closure stop_cb_; |
105 | 106 |
106 // The current decoder configuration. | 107 // The current decoder configuration. |
107 AudioDecoderConfig config_; | 108 AudioDecoderConfig config_; |
108 | 109 |
109 // Callback to request/cancel decryptor creation notification. | 110 // Callback to request/cancel decryptor creation notification. |
110 SetDecryptorReadyCB set_decryptor_ready_cb_; | 111 SetDecryptorReadyCB set_decryptor_ready_cb_; |
111 | 112 |
112 Decryptor* decryptor_; | 113 Decryptor* decryptor_; |
113 | 114 |
114 // The buffer that needs decrypting/decoding. | 115 // The buffer that needs decrypting/decoding. |
115 scoped_refptr<media::DecoderBuffer> pending_buffer_to_decode_; | 116 scoped_refptr<media::DecoderBuffer> pending_buffer_to_decode_; |
116 | 117 |
117 // Indicates the situation where new key is added during pending decode | 118 // Indicates the situation where new key is added during pending decode |
118 // (in other words, this variable can only be set in state kPendingDecode). | 119 // (in other words, this variable can only be set in state kPendingDecode). |
119 // If this variable is true and kNoKey is returned then we need to try | 120 // If this variable is true and kNoKey is returned then we need to try |
120 // decrypting/decoding again in case the newly added key is the correct | 121 // decrypting/decoding again in case the newly added key is the correct |
121 // decryption key. | 122 // decryption key. |
122 bool key_added_while_decode_pending_; | 123 bool key_added_while_decode_pending_; |
123 | 124 |
124 Decryptor::AudioBuffers queued_audio_frames_; | 125 Decryptor::AudioBuffers queued_audio_frames_; |
xhwang
2014/05/29 22:15:14
remove?
Sergey Ulanov
2014/06/03 00:08:11
Done.
| |
125 | 126 |
126 scoped_ptr<AudioTimestampHelper> timestamp_helper_; | 127 scoped_ptr<AudioTimestampHelper> timestamp_helper_; |
127 | 128 |
128 // NOTE: Weak pointers must be invalidated before all other member variables. | 129 // NOTE: Weak pointers must be invalidated before all other member variables. |
129 base::WeakPtrFactory<DecryptingAudioDecoder> weak_factory_; | 130 base::WeakPtrFactory<DecryptingAudioDecoder> weak_factory_; |
130 base::WeakPtr<DecryptingAudioDecoder> weak_this_; | 131 base::WeakPtr<DecryptingAudioDecoder> weak_this_; |
131 | 132 |
132 DISALLOW_COPY_AND_ASSIGN(DecryptingAudioDecoder); | 133 DISALLOW_COPY_AND_ASSIGN(DecryptingAudioDecoder); |
133 }; | 134 }; |
134 | 135 |
135 } // namespace media | 136 } // namespace media |
136 | 137 |
137 #endif // MEDIA_FILTERS_DECRYPTING_AUDIO_DECODER_H_ | 138 #endif // MEDIA_FILTERS_DECRYPTING_AUDIO_DECODER_H_ |
OLD | NEW |