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

Side by Side Diff: media/filters/ffmpeg_video_decoder.cc

Issue 11144036: Update Decryptor interface to support audio decoding. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: simplify AudioBuffers Created 8 years, 2 months 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
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 #include "media/filters/ffmpeg_video_decoder.h" 5 #include "media/filters/ffmpeg_video_decoder.h"
6 6
7 #include <algorithm> 7 #include <algorithm>
8 #include <string> 8 #include <string>
9 9
10 #include "base/bind.h" 10 #include "base/bind.h"
(...skipping 165 matching lines...) Expand 10 before | Expand all | Expand 10 after
176 if (!message_loop_->BelongsToCurrentThread()) { 176 if (!message_loop_->BelongsToCurrentThread()) {
177 message_loop_->PostTask(FROM_HERE, base::Bind( 177 message_loop_->PostTask(FROM_HERE, base::Bind(
178 &FFmpegVideoDecoder::Reset, this, closure)); 178 &FFmpegVideoDecoder::Reset, this, closure));
179 return; 179 return;
180 } 180 }
181 181
182 DCHECK(reset_cb_.is_null()); 182 DCHECK(reset_cb_.is_null());
183 reset_cb_ = closure; 183 reset_cb_ = closure;
184 184
185 if (decryptor_) 185 if (decryptor_)
186 decryptor_->CancelDecrypt(); 186 decryptor_->CancelDecrypt(Decryptor::kVideo);
187 187
188 // Defer the reset if a read is pending. 188 // Defer the reset if a read is pending.
189 if (!read_cb_.is_null()) 189 if (!read_cb_.is_null())
190 return; 190 return;
191 191
192 DoReset(); 192 DoReset();
193 } 193 }
194 194
195 void FFmpegVideoDecoder::DoReset() { 195 void FFmpegVideoDecoder::DoReset() {
196 DCHECK(read_cb_.is_null()); 196 DCHECK(read_cb_.is_null());
(...skipping 14 matching lines...) Expand all
211 DCHECK(stop_cb_.is_null()); 211 DCHECK(stop_cb_.is_null());
212 212
213 if (state_ == kUninitialized) { 213 if (state_ == kUninitialized) {
214 closure.Run(); 214 closure.Run();
215 return; 215 return;
216 } 216 }
217 217
218 stop_cb_ = closure; 218 stop_cb_ = closure;
219 219
220 if (decryptor_) 220 if (decryptor_)
221 decryptor_->CancelDecrypt(); 221 decryptor_->CancelDecrypt(Decryptor::kVideo);
222 222
223 // Defer stopping if a read is pending. 223 // Defer stopping if a read is pending.
224 if (!read_cb_.is_null()) 224 if (!read_cb_.is_null())
225 return; 225 return;
226 226
227 DoStop(); 227 DoStop();
228 } 228 }
229 229
230 void FFmpegVideoDecoder::DoStop() { 230 void FFmpegVideoDecoder::DoStop() {
231 ReleaseFFmpegResources(); 231 ReleaseFFmpegResources();
(...skipping 73 matching lines...) Expand 10 before | Expand all | Expand 10 after
305 return; 305 return;
306 } 306 }
307 307
308 ReadFromDemuxerStream(); 308 ReadFromDemuxerStream();
309 return; 309 return;
310 } 310 }
311 311
312 DCHECK_EQ(status, DemuxerStream::kOk); 312 DCHECK_EQ(status, DemuxerStream::kOk);
313 313
314 if (buffer->GetDecryptConfig() && buffer->GetDataSize()) { 314 if (buffer->GetDecryptConfig() && buffer->GetDataSize()) {
315 decryptor_->Decrypt(buffer, 315 decryptor_->Decrypt(Decryptor::kVideo,
316 buffer,
316 base::Bind(&FFmpegVideoDecoder::BufferDecrypted, this)); 317 base::Bind(&FFmpegVideoDecoder::BufferDecrypted, this));
317 return; 318 return;
318 } 319 }
319 320
320 DecodeBuffer(buffer); 321 DecodeBuffer(buffer);
321 } 322 }
322 323
323 void FFmpegVideoDecoder::BufferDecrypted( 324 void FFmpegVideoDecoder::BufferDecrypted(
324 Decryptor::Status decrypt_status, 325 Decryptor::Status decrypt_status,
325 const scoped_refptr<DecoderBuffer>& buffer) { 326 const scoped_refptr<DecoderBuffer>& buffer) {
(...skipping 215 matching lines...) Expand 10 before | Expand all | Expand 10 after
541 if (!codec || avcodec_open2(codec_context_, codec, NULL) < 0) { 542 if (!codec || avcodec_open2(codec_context_, codec, NULL) < 0) {
542 ReleaseFFmpegResources(); 543 ReleaseFFmpegResources();
543 return false; 544 return false;
544 } 545 }
545 546
546 av_frame_ = avcodec_alloc_frame(); 547 av_frame_ = avcodec_alloc_frame();
547 return true; 548 return true;
548 } 549 }
549 550
550 } // namespace media 551 } // namespace media
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698