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 32 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
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) OVERRIDE; |
48 virtual void Decode(const scoped_refptr<DecoderBuffer>& buffer, | 48 virtual void Decode(const scoped_refptr<DecoderBuffer>& buffer, |
49 const DecodeCB& decode_cb) OVERRIDE; | 49 const DecodeCB& decode_cb) OVERRIDE; |
50 virtual scoped_refptr<AudioBuffer> GetDecodeOutput() 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(const base::Closure& closure) OVERRIDE; | 52 virtual void Stop(const base::Closure& closure) OVERRIDE; |
53 virtual int bits_per_channel() OVERRIDE; | |
54 virtual ChannelLayout channel_layout() OVERRIDE; | |
55 virtual int samples_per_second() OVERRIDE; | |
56 | 53 |
57 private: | 54 private: |
58 // 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 |
59 // 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 |
60 // stabilizes. | 57 // stabilizes. |
61 // TODO(xhwang): Update this diagram for DecryptingAudioDecoder. | 58 // TODO(xhwang): Update this diagram for DecryptingAudioDecoder. |
62 enum State { | 59 enum State { |
63 kUninitialized = 0, | 60 kUninitialized = 0, |
64 kDecryptorRequested, | 61 kDecryptorRequested, |
65 kPendingDecoderInit, | 62 kPendingDecoderInit, |
(...skipping 20 matching lines...) Expand all Loading... |
86 Decryptor::Status status, | 83 Decryptor::Status status, |
87 const Decryptor::AudioBuffers& frames); | 84 const Decryptor::AudioBuffers& frames); |
88 | 85 |
89 // 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 |
90 // added. | 87 // added. |
91 void OnKeyAdded(); | 88 void OnKeyAdded(); |
92 | 89 |
93 // Resets decoder and calls |reset_cb_|. | 90 // Resets decoder and calls |reset_cb_|. |
94 void DoReset(); | 91 void DoReset(); |
95 | 92 |
96 // Updates audio configs from |demuxer_stream_| and resets | |
97 // |output_timestamp_base_| and |total_samples_decoded_|. | |
98 void UpdateDecoderConfig(); | |
99 | |
100 // 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 |
101 // renderer always receives continuous frames without gaps and overlaps. | 94 // renderer always receives continuous frames without gaps and overlaps. |
102 void EnqueueFrames(const Decryptor::AudioBuffers& frames); | 95 void EnqueueFrames(const Decryptor::AudioBuffers& frames); |
103 | 96 |
104 scoped_refptr<base::SingleThreadTaskRunner> task_runner_; | 97 scoped_refptr<base::SingleThreadTaskRunner> task_runner_; |
105 | 98 |
106 State state_; | 99 State state_; |
107 | 100 |
108 PipelineStatusCB init_cb_; | 101 PipelineStatusCB init_cb_; |
109 DecodeCB decode_cb_; | 102 DecodeCB decode_cb_; |
(...skipping 13 matching lines...) Expand all Loading... |
123 | 116 |
124 // Indicates the situation where new key is added during pending decode | 117 // Indicates the situation where new key is added during pending decode |
125 // (in other words, this variable can only be set in state kPendingDecode). | 118 // (in other words, this variable can only be set in state kPendingDecode). |
126 // If this variable is true and kNoKey is returned then we need to try | 119 // If this variable is true and kNoKey is returned then we need to try |
127 // decrypting/decoding again in case the newly added key is the correct | 120 // decrypting/decoding again in case the newly added key is the correct |
128 // decryption key. | 121 // decryption key. |
129 bool key_added_while_decode_pending_; | 122 bool key_added_while_decode_pending_; |
130 | 123 |
131 Decryptor::AudioBuffers queued_audio_frames_; | 124 Decryptor::AudioBuffers queued_audio_frames_; |
132 | 125 |
133 // Decoded audio format. | |
134 int bits_per_channel_; | |
135 ChannelLayout channel_layout_; | |
136 int samples_per_second_; | |
137 | |
138 scoped_ptr<AudioTimestampHelper> timestamp_helper_; | 126 scoped_ptr<AudioTimestampHelper> timestamp_helper_; |
139 | 127 |
140 // NOTE: Weak pointers must be invalidated before all other member variables. | 128 // NOTE: Weak pointers must be invalidated before all other member variables. |
141 base::WeakPtrFactory<DecryptingAudioDecoder> weak_factory_; | 129 base::WeakPtrFactory<DecryptingAudioDecoder> weak_factory_; |
142 base::WeakPtr<DecryptingAudioDecoder> weak_this_; | 130 base::WeakPtr<DecryptingAudioDecoder> weak_this_; |
143 | 131 |
144 DISALLOW_COPY_AND_ASSIGN(DecryptingAudioDecoder); | 132 DISALLOW_COPY_AND_ASSIGN(DecryptingAudioDecoder); |
145 }; | 133 }; |
146 | 134 |
147 } // namespace media | 135 } // namespace media |
148 | 136 |
149 #endif // MEDIA_FILTERS_DECRYPTING_AUDIO_DECODER_H_ | 137 #endif // MEDIA_FILTERS_DECRYPTING_AUDIO_DECODER_H_ |
OLD | NEW |