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 30 matching lines...) Expand all Loading... |
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(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 void Stop(const base::Closure& closure) OVERRIDE; | |
52 virtual int bits_per_channel() OVERRIDE; | 51 virtual int bits_per_channel() OVERRIDE; |
53 virtual ChannelLayout channel_layout() OVERRIDE; | 52 virtual ChannelLayout channel_layout() OVERRIDE; |
54 virtual int samples_per_second() OVERRIDE; | 53 virtual int samples_per_second() OVERRIDE; |
55 | 54 |
56 private: | 55 private: |
57 // For a detailed state diagram please see this link: http://goo.gl/8jAok | 56 // For a detailed state diagram please see this link: http://goo.gl/8jAok |
58 // TODO(xhwang): Add a ASCII state diagram in this file after this class | 57 // TODO(xhwang): Add a ASCII state diagram in this file after this class |
59 // stabilizes. | 58 // stabilizes. |
60 // TODO(xhwang): Update this diagram for DecryptingAudioDecoder. | 59 // TODO(xhwang): Update this diagram for DecryptingAudioDecoder. |
61 enum State { | 60 enum State { |
62 kUninitialized = 0, | 61 kUninitialized = 0, |
63 kDecryptorRequested, | 62 kDecryptorRequested, |
64 kPendingDecoderInit, | 63 kPendingDecoderInit, |
65 kIdle, | 64 kIdle, |
66 kPendingConfigChange, | 65 kPendingConfigChange, |
67 kPendingDemuxerRead, | 66 kPendingDemuxerRead, |
68 kPendingDecode, | 67 kPendingDecode, |
69 kWaitingForKey, | 68 kWaitingForKey, |
70 kDecodeFinished, | 69 kDecodeFinished, |
71 kStopped, | |
72 }; | 70 }; |
73 | 71 |
74 // Callback for DecryptorHost::RequestDecryptor(). | 72 // Callback for DecryptorHost::RequestDecryptor(). |
75 void SetDecryptor(Decryptor* decryptor); | 73 void SetDecryptor(Decryptor* decryptor); |
76 | 74 |
77 // Callback for Decryptor::InitializeAudioDecoder() during initialization. | 75 // Callback for Decryptor::InitializeAudioDecoder() during initialization. |
78 void FinishInitialization(bool success); | 76 void FinishInitialization(bool success); |
79 | 77 |
80 // Callback for Decryptor::InitializeAudioDecoder() during config change. | 78 // Callback for Decryptor::InitializeAudioDecoder() during config change. |
81 void FinishConfigChange(bool success); | 79 void FinishConfigChange(bool success); |
(...skipping 28 matching lines...) Expand all Loading... |
110 scoped_refptr<base::SingleThreadTaskRunner> task_runner_; | 108 scoped_refptr<base::SingleThreadTaskRunner> task_runner_; |
111 base::WeakPtrFactory<DecryptingAudioDecoder> weak_factory_; | 109 base::WeakPtrFactory<DecryptingAudioDecoder> weak_factory_; |
112 base::WeakPtr<DecryptingAudioDecoder> weak_this_; | 110 base::WeakPtr<DecryptingAudioDecoder> weak_this_; |
113 | 111 |
114 State state_; | 112 State state_; |
115 | 113 |
116 PipelineStatusCB init_cb_; | 114 PipelineStatusCB init_cb_; |
117 StatisticsCB statistics_cb_; | 115 StatisticsCB statistics_cb_; |
118 ReadCB read_cb_; | 116 ReadCB read_cb_; |
119 base::Closure reset_cb_; | 117 base::Closure reset_cb_; |
120 base::Closure stop_cb_; | |
121 | 118 |
122 // Pointer to the demuxer stream that will feed us compressed buffers. | 119 // Pointer to the demuxer stream that will feed us compressed buffers. |
123 DemuxerStream* demuxer_stream_; | 120 DemuxerStream* demuxer_stream_; |
124 | 121 |
125 // Callback to request/cancel decryptor creation notification. | 122 // Callback to request/cancel decryptor creation notification. |
126 SetDecryptorReadyCB set_decryptor_ready_cb_; | 123 SetDecryptorReadyCB set_decryptor_ready_cb_; |
127 | 124 |
128 Decryptor* decryptor_; | 125 Decryptor* decryptor_; |
129 | 126 |
130 // The buffer returned by the demuxer that needs decrypting/decoding. | 127 // The buffer returned by the demuxer that needs decrypting/decoding. |
(...skipping 14 matching lines...) Expand all Loading... |
145 int samples_per_second_; | 142 int samples_per_second_; |
146 | 143 |
147 scoped_ptr<AudioTimestampHelper> timestamp_helper_; | 144 scoped_ptr<AudioTimestampHelper> timestamp_helper_; |
148 | 145 |
149 DISALLOW_COPY_AND_ASSIGN(DecryptingAudioDecoder); | 146 DISALLOW_COPY_AND_ASSIGN(DecryptingAudioDecoder); |
150 }; | 147 }; |
151 | 148 |
152 } // namespace media | 149 } // namespace media |
153 | 150 |
154 #endif // MEDIA_FILTERS_DECRYPTING_AUDIO_DECODER_H_ | 151 #endif // MEDIA_FILTERS_DECRYPTING_AUDIO_DECODER_H_ |
OLD | NEW |