Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(366)

Side by Side Diff: media/filters/decrypting_audio_decoder.h

Issue 11342031: Add DecryptingDemuxerStream. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: rebase Created 8 years, 1 month ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « media/base/decryptor.h ('k') | media/filters/decrypting_audio_decoder.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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 "media/base/audio_decoder.h" 10 #include "media/base/audio_decoder.h"
(...skipping 50 matching lines...) Expand 10 before | Expand all | Expand 10 after
61 virtual int samples_per_second() OVERRIDE; 61 virtual int samples_per_second() OVERRIDE;
62 62
63 protected: 63 protected:
64 virtual ~DecryptingAudioDecoder(); 64 virtual ~DecryptingAudioDecoder();
65 65
66 private: 66 private:
67 // For a detailed state diagram please see this link: http://goo.gl/8jAok 67 // For a detailed state diagram please see this link: http://goo.gl/8jAok
68 // TODO(xhwang): Add a ASCII state diagram in this file after this class 68 // TODO(xhwang): Add a ASCII state diagram in this file after this class
69 // stabilizes. 69 // stabilizes.
70 // TODO(xhwang): Update this diagram for DecryptingAudioDecoder. 70 // TODO(xhwang): Update this diagram for DecryptingAudioDecoder.
71 enum DecoderState { 71 enum State {
72 kUninitialized = 0, 72 kUninitialized = 0,
73 kDecryptorRequested, 73 kDecryptorRequested,
74 kPendingDecoderInit, 74 kPendingDecoderInit,
75 kIdle, 75 kIdle,
76 kPendingDemuxerRead, 76 kPendingDemuxerRead,
77 kPendingDecode, 77 kPendingDecode,
78 kWaitingForKey, 78 kWaitingForKey,
79 kDecodeFinished, 79 kDecodeFinished,
80 }; 80 };
81 81
(...skipping 27 matching lines...) Expand all
109 // Callback for Decryptor::DecryptAndDecodeAudio(). 109 // Callback for Decryptor::DecryptAndDecodeAudio().
110 void DeliverFrame(int buffer_size, 110 void DeliverFrame(int buffer_size,
111 Decryptor::Status status, 111 Decryptor::Status status,
112 const Decryptor::AudioBuffers& frames); 112 const Decryptor::AudioBuffers& frames);
113 113
114 // Carries out the frame delivery operation scheduled by DeliverFrame(). 114 // Carries out the frame delivery operation scheduled by DeliverFrame().
115 void DoDeliverFrame(int buffer_size, 115 void DoDeliverFrame(int buffer_size,
116 Decryptor::Status status, 116 Decryptor::Status status,
117 const Decryptor::AudioBuffers& frames); 117 const Decryptor::AudioBuffers& frames);
118 118
119 // Callback for the |decryptor_| to notify the DecryptingAudioDecoder that 119 // Callback for the |decryptor_| to notify this object that a new key has been
120 // a new key has been added. 120 // added.
121 void OnKeyAdded(); 121 void OnKeyAdded();
122 122
123 // Resets decoder and calls |reset_cb_|. 123 // Resets decoder and calls |reset_cb_|.
124 void DoReset(); 124 void DoReset();
125 125
126 // Sets timestamp and duration for |queued_audio_frames_| to make sure the 126 // Sets timestamp and duration for |queued_audio_frames_| to make sure the
127 // renderer always receives continuous frames without gaps and overlaps. 127 // renderer always receives continuous frames without gaps and overlaps.
128 void EnqueueFrames(const Decryptor::AudioBuffers& frames); 128 void EnqueueFrames(const Decryptor::AudioBuffers& frames);
129 129
130 // Converts number of samples to duration. 130 // Converts number of samples to duration.
131 base::TimeDelta NumberOfSamplesToDuration(int number_of_samples) const; 131 base::TimeDelta NumberOfSamplesToDuration(int number_of_samples) const;
132 132
133 // This is !is_null() iff Initialize() hasn't been called. 133 // This is !is_null() iff Initialize() hasn't been called.
134 MessageLoopFactoryCB message_loop_factory_cb_; 134 MessageLoopFactoryCB message_loop_factory_cb_;
135 135
136 scoped_refptr<base::MessageLoopProxy> message_loop_; 136 scoped_refptr<base::MessageLoopProxy> message_loop_;
137 137
138 // Current state of the DecryptingAudioDecoder. 138 State state_;
139 DecoderState state_;
140 139
141 PipelineStatusCB init_cb_; 140 PipelineStatusCB init_cb_;
142 StatisticsCB statistics_cb_; 141 StatisticsCB statistics_cb_;
143 ReadCB read_cb_; 142 ReadCB read_cb_;
144 base::Closure reset_cb_; 143 base::Closure reset_cb_;
145 144
146 // Pointer to the demuxer stream that will feed us compressed buffers. 145 // Pointer to the demuxer stream that will feed us compressed buffers.
147 scoped_refptr<DemuxerStream> demuxer_stream_; 146 scoped_refptr<DemuxerStream> demuxer_stream_;
148 147
149 // Callback to request/cancel decryptor creation notification. 148 // Callback to request/cancel decryptor creation notification.
150 RequestDecryptorNotificationCB request_decryptor_notification_cb_; 149 RequestDecryptorNotificationCB request_decryptor_notification_cb_;
151 150
152 Decryptor* decryptor_; 151 Decryptor* decryptor_;
153 152
154 // The buffer returned by the demuxer that needs decrypting/decoding. 153 // The buffer returned by the demuxer that needs decrypting/decoding.
155 scoped_refptr<media::DecoderBuffer> pending_buffer_to_decode_; 154 scoped_refptr<media::DecoderBuffer> pending_buffer_to_decode_;
156 155
157 // Indicates the situation where new key is added during pending decode 156 // Indicates the situation where new key is added during pending decode
158 // (in other words, this variable can only be set in state kPendingDecode). 157 // (in other words, this variable can only be set in state kPendingDecode).
159 // If this variable is true and kNoKey is returned then we need to try 158 // If this variable is true and kNoKey is returned then we need to try
160 // decrypting/decoding again in case the newly added key is the correct 159 // decrypting/decoding again in case the newly added key is the correct
161 // decryption key. 160 // decryption key.
162 bool key_added_while_pending_decode_; 161 bool key_added_while_decode_pending_;
163 162
164 Decryptor::AudioBuffers queued_audio_frames_; 163 Decryptor::AudioBuffers queued_audio_frames_;
165 164
166 // Decoded audio format. 165 // Decoded audio format.
167 int bits_per_channel_; 166 int bits_per_channel_;
168 ChannelLayout channel_layout_; 167 ChannelLayout channel_layout_;
169 int samples_per_second_; 168 int samples_per_second_;
170 169
171 int bytes_per_sample_; 170 int bytes_per_sample_;
172 171
173 base::TimeDelta output_timestamp_base_; 172 base::TimeDelta output_timestamp_base_;
174 int total_samples_decoded_; 173 int total_samples_decoded_;
175 174
176 DISALLOW_COPY_AND_ASSIGN(DecryptingAudioDecoder); 175 DISALLOW_COPY_AND_ASSIGN(DecryptingAudioDecoder);
177 }; 176 };
178 177
179 } // namespace media 178 } // namespace media
180 179
181 #endif // MEDIA_FILTERS_DECRYPTING_AUDIO_DECODER_H_ 180 #endif // MEDIA_FILTERS_DECRYPTING_AUDIO_DECODER_H_
OLDNEW
« no previous file with comments | « media/base/decryptor.h ('k') | media/filters/decrypting_audio_decoder.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698