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" |
11 #include "base/memory/weak_ptr.h" | 11 #include "base/memory/weak_ptr.h" |
12 #include "base/time/time.h" | 12 #include "base/time/time.h" |
13 #include "media/base/audio_decoder.h" | 13 #include "media/base/audio_decoder.h" |
14 #include "media/base/decryptor.h" | 14 #include "media/base/decryptor.h" |
15 #include "media/base/demuxer_stream.h" | 15 #include "media/base/demuxer_stream.h" |
16 | 16 |
17 namespace base { | 17 namespace base { |
18 class MessageLoopProxy; | 18 class SingleThreadTaskRunner; |
19 } | 19 } |
20 | 20 |
21 namespace media { | 21 namespace media { |
22 | 22 |
23 class AudioTimestampHelper; | 23 class AudioTimestampHelper; |
24 class DecoderBuffer; | 24 class DecoderBuffer; |
25 class Decryptor; | 25 class Decryptor; |
26 | 26 |
27 // Decryptor-based AudioDecoder implementation that can decrypt and decode | 27 // Decryptor-based AudioDecoder implementation that can decrypt and decode |
28 // encrypted audio buffers and return decrypted and decompressed audio frames. | 28 // encrypted audio buffers and return decrypted and decompressed audio frames. |
29 // All public APIs and callbacks are trampolined to the |message_loop_| so | 29 // All public APIs and callbacks are trampolined to the |task_runner_| so |
30 // that no locks are required for thread safety. | 30 // that no locks are required for thread safety. |
31 class MEDIA_EXPORT DecryptingAudioDecoder : public AudioDecoder { | 31 class MEDIA_EXPORT DecryptingAudioDecoder : public AudioDecoder { |
32 public: | 32 public: |
33 // We do not currently have a way to let the Decryptor choose the output | 33 // We do not currently have a way to let the Decryptor choose the output |
34 // audio sample format and notify us of its choice. Therefore, we require all | 34 // audio sample format and notify us of its choice. Therefore, we require all |
35 // Decryptor implementations to decode audio into a fixed integer sample | 35 // Decryptor implementations to decode audio into a fixed integer sample |
36 // format designated by kSupportedBitsPerChannel. | 36 // format designated by kSupportedBitsPerChannel. |
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::MessageLoopProxy>& message_loop, | 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(DemuxerStream* stream, | 46 virtual void Initialize(DemuxerStream* stream, |
47 const PipelineStatusCB& status_cb, | 47 const PipelineStatusCB& status_cb, |
48 const StatisticsCB& statistics_cb) OVERRIDE; | 48 const StatisticsCB& statistics_cb) OVERRIDE; |
49 virtual void Read(const ReadCB& read_cb) OVERRIDE; | 49 virtual void Read(const ReadCB& read_cb) OVERRIDE; |
50 virtual void Reset(const base::Closure& closure) OVERRIDE; | 50 virtual void Reset(const base::Closure& closure) OVERRIDE; |
51 virtual int bits_per_channel() OVERRIDE; | 51 virtual int bits_per_channel() OVERRIDE; |
(...skipping 46 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
98 void DoReset(); | 98 void DoReset(); |
99 | 99 |
100 // Updates audio configs from |demuxer_stream_| and resets | 100 // Updates audio configs from |demuxer_stream_| and resets |
101 // |output_timestamp_base_| and |total_samples_decoded_|. | 101 // |output_timestamp_base_| and |total_samples_decoded_|. |
102 void UpdateDecoderConfig(); | 102 void UpdateDecoderConfig(); |
103 | 103 |
104 // Sets timestamp and duration for |queued_audio_frames_| to make sure the | 104 // Sets timestamp and duration for |queued_audio_frames_| to make sure the |
105 // renderer always receives continuous frames without gaps and overlaps. | 105 // renderer always receives continuous frames without gaps and overlaps. |
106 void EnqueueFrames(const Decryptor::AudioBuffers& frames); | 106 void EnqueueFrames(const Decryptor::AudioBuffers& frames); |
107 | 107 |
108 scoped_refptr<base::MessageLoopProxy> message_loop_; | 108 scoped_refptr<base::SingleThreadTaskRunner> task_runner_; |
109 base::WeakPtrFactory<DecryptingAudioDecoder> weak_factory_; | 109 base::WeakPtrFactory<DecryptingAudioDecoder> weak_factory_; |
110 base::WeakPtr<DecryptingAudioDecoder> weak_this_; | 110 base::WeakPtr<DecryptingAudioDecoder> weak_this_; |
111 | 111 |
112 State state_; | 112 State state_; |
113 | 113 |
114 PipelineStatusCB init_cb_; | 114 PipelineStatusCB init_cb_; |
115 StatisticsCB statistics_cb_; | 115 StatisticsCB statistics_cb_; |
116 ReadCB read_cb_; | 116 ReadCB read_cb_; |
117 base::Closure reset_cb_; | 117 base::Closure reset_cb_; |
118 | 118 |
(...skipping 23 matching lines...) Expand all Loading... |
142 int samples_per_second_; | 142 int samples_per_second_; |
143 | 143 |
144 scoped_ptr<AudioTimestampHelper> timestamp_helper_; | 144 scoped_ptr<AudioTimestampHelper> timestamp_helper_; |
145 | 145 |
146 DISALLOW_COPY_AND_ASSIGN(DecryptingAudioDecoder); | 146 DISALLOW_COPY_AND_ASSIGN(DecryptingAudioDecoder); |
147 }; | 147 }; |
148 | 148 |
149 } // namespace media | 149 } // namespace media |
150 | 150 |
151 #endif // MEDIA_FILTERS_DECRYPTING_AUDIO_DECODER_H_ | 151 #endif // MEDIA_FILTERS_DECRYPTING_AUDIO_DECODER_H_ |
OLD | NEW |