| 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 217 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 228 reset_cb_.Reset(); | 228 reset_cb_.Reset(); |
| 229 } | 229 } |
| 230 | 230 |
| 231 void FFmpegVideoDecoder::Stop(const base::Closure& closure) { | 231 void FFmpegVideoDecoder::Stop(const base::Closure& closure) { |
| 232 if (MessageLoop::current() != message_loop_) { | 232 if (MessageLoop::current() != message_loop_) { |
| 233 message_loop_->PostTask(FROM_HERE, base::Bind( | 233 message_loop_->PostTask(FROM_HERE, base::Bind( |
| 234 &FFmpegVideoDecoder::Stop, this, closure)); | 234 &FFmpegVideoDecoder::Stop, this, closure)); |
| 235 return; | 235 return; |
| 236 } | 236 } |
| 237 | 237 |
| 238 if (decryptor_) |
| 239 decryptor_->Stop(); |
| 240 |
| 238 stop_cb_ = closure; | 241 stop_cb_ = closure; |
| 239 | 242 |
| 240 // Defer stopping if a read is pending. | 243 // Defer stopping if a read is pending. |
| 241 if (!read_cb_.is_null()) | 244 if (!read_cb_.is_null()) |
| 242 return; | 245 return; |
| 243 | 246 |
| 244 DoStop(); | 247 DoStop(); |
| 245 } | 248 } |
| 246 | 249 |
| 247 void FFmpegVideoDecoder::DoStop() { | 250 void FFmpegVideoDecoder::DoStop() { |
| (...skipping 103 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 351 DCHECK_NE(state_, kUninitialized); | 354 DCHECK_NE(state_, kUninitialized); |
| 352 DCHECK_NE(state_, kDecodeFinished); | 355 DCHECK_NE(state_, kDecodeFinished); |
| 353 DCHECK(!read_cb_.is_null()); | 356 DCHECK(!read_cb_.is_null()); |
| 354 | 357 |
| 355 if (!reset_cb_.is_null()) { | 358 if (!reset_cb_.is_null()) { |
| 356 base::ResetAndReturn(&read_cb_).Run(kOk, NULL); | 359 base::ResetAndReturn(&read_cb_).Run(kOk, NULL); |
| 357 DoReset(); | 360 DoReset(); |
| 358 return; | 361 return; |
| 359 } | 362 } |
| 360 | 363 |
| 361 if (decrypt_status == Decryptor::kError) { | 364 if (decrypt_status == Decryptor::kNoKey || |
| 365 decrypt_status == Decryptor::kError) { |
| 362 state_ = kDecodeFinished; | 366 state_ = kDecodeFinished; |
| 363 base::ResetAndReturn(&read_cb_).Run(kDecryptError, NULL); | 367 base::ResetAndReturn(&read_cb_).Run(kDecryptError, NULL); |
| 364 return; | 368 return; |
| 365 } | 369 } |
| 366 | 370 |
| 367 DCHECK_EQ(Decryptor::kSuccess, decrypt_status); | 371 DCHECK_EQ(Decryptor::kSuccess, decrypt_status); |
| 368 DCHECK(buffer); | 372 DCHECK(buffer); |
| 369 DCHECK(buffer->GetDataSize()); | 373 DCHECK(buffer->GetDataSize()); |
| 370 DCHECK(!buffer->GetDecryptConfig()); | 374 DCHECK(!buffer->GetDecryptConfig()); |
| 371 DecodeBuffer(buffer); | 375 DecodeBuffer(buffer); |
| (...skipping 144 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 516 av_free(codec_context_); | 520 av_free(codec_context_); |
| 517 codec_context_ = NULL; | 521 codec_context_ = NULL; |
| 518 } | 522 } |
| 519 if (av_frame_) { | 523 if (av_frame_) { |
| 520 av_free(av_frame_); | 524 av_free(av_frame_); |
| 521 av_frame_ = NULL; | 525 av_frame_ = NULL; |
| 522 } | 526 } |
| 523 } | 527 } |
| 524 | 528 |
| 525 } // namespace media | 529 } // namespace media |
| OLD | NEW |