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 #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 304 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
315 return; | 315 return; |
316 } | 316 } |
317 | 317 |
318 if (!reset_cb_.is_null()) { | 318 if (!reset_cb_.is_null()) { |
319 base::ResetAndReturn(&read_cb_).Run(kOk, NULL); | 319 base::ResetAndReturn(&read_cb_).Run(kOk, NULL); |
320 DoReset(); | 320 DoReset(); |
321 return; | 321 return; |
322 } | 322 } |
323 | 323 |
324 if (status != DemuxerStream::kOk) { | 324 if (status != DemuxerStream::kOk) { |
325 DecoderStatus decoder_status = | 325 Status decoder_status = |
326 (status == DemuxerStream::kAborted) ? kOk : kDecodeError; | 326 (status == DemuxerStream::kAborted) ? kOk : kDecodeError; |
327 base::ResetAndReturn(&read_cb_).Run(decoder_status, NULL); | 327 base::ResetAndReturn(&read_cb_).Run(decoder_status, NULL); |
328 return; | 328 return; |
329 } | 329 } |
330 | 330 |
331 DCHECK_EQ(status, DemuxerStream::kOk); | 331 DCHECK_EQ(status, DemuxerStream::kOk); |
332 | 332 |
333 if (buffer->GetDecryptConfig() && buffer->GetDataSize()) { | 333 if (buffer->GetDecryptConfig() && buffer->GetDataSize()) { |
334 decryptor_->Decrypt(buffer, | 334 decryptor_->Decrypt(buffer, |
335 base::Bind(&FFmpegVideoDecoder::BufferDecrypted, this)); | 335 base::Bind(&FFmpegVideoDecoder::BufferDecrypted, this)); |
336 return; | 336 return; |
337 } | 337 } |
338 | 338 |
339 DecodeBuffer(buffer); | 339 DecodeBuffer(buffer); |
340 } | 340 } |
341 | 341 |
342 void FFmpegVideoDecoder::BufferDecrypted( | 342 void FFmpegVideoDecoder::BufferDecrypted( |
343 Decryptor::DecryptStatus decrypt_status, | 343 Decryptor::Status decrypt_status, |
344 const scoped_refptr<DecoderBuffer>& buffer) { | 344 const scoped_refptr<DecoderBuffer>& buffer) { |
345 message_loop_->PostTask(FROM_HERE, base::Bind( | 345 message_loop_->PostTask(FROM_HERE, base::Bind( |
346 &FFmpegVideoDecoder::DoBufferDecrypted, this, decrypt_status, buffer)); | 346 &FFmpegVideoDecoder::DoBufferDecrypted, this, decrypt_status, buffer)); |
347 } | 347 } |
348 | 348 |
349 void FFmpegVideoDecoder::DoBufferDecrypted( | 349 void FFmpegVideoDecoder::DoBufferDecrypted( |
350 Decryptor::DecryptStatus decrypt_status, | 350 Decryptor::Status decrypt_status, |
351 const scoped_refptr<DecoderBuffer>& buffer) { | 351 const scoped_refptr<DecoderBuffer>& buffer) { |
352 DCHECK_EQ(MessageLoop::current(), message_loop_); | 352 DCHECK_EQ(MessageLoop::current(), message_loop_); |
353 DCHECK_NE(state_, kUninitialized); | 353 DCHECK_NE(state_, kUninitialized); |
354 DCHECK_NE(state_, kDecodeFinished); | 354 DCHECK_NE(state_, kDecodeFinished); |
355 DCHECK(!read_cb_.is_null()); | 355 DCHECK(!read_cb_.is_null()); |
356 | 356 |
357 if (!reset_cb_.is_null()) { | 357 if (!reset_cb_.is_null()) { |
358 base::ResetAndReturn(&read_cb_).Run(kOk, NULL); | 358 base::ResetAndReturn(&read_cb_).Run(kOk, NULL); |
359 DoReset(); | 359 DoReset(); |
360 return; | 360 return; |
(...skipping 158 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
519 av_free(codec_context_); | 519 av_free(codec_context_); |
520 codec_context_ = NULL; | 520 codec_context_ = NULL; |
521 } | 521 } |
522 if (av_frame_) { | 522 if (av_frame_) { |
523 av_free(av_frame_); | 523 av_free(av_frame_); |
524 av_frame_ = NULL; | 524 av_frame_ = NULL; |
525 } | 525 } |
526 } | 526 } |
527 | 527 |
528 } // namespace media | 528 } // namespace media |
OLD | NEW |