Chromium Code Reviews| 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 215 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 226 const scoped_refptr<DecoderBuffer>& buffer) { | 226 const scoped_refptr<DecoderBuffer>& buffer) { |
| 227 DCHECK(message_loop_->BelongsToCurrentThread()); | 227 DCHECK(message_loop_->BelongsToCurrentThread()); |
| 228 DCHECK_NE(state_, kDecodeFinished); | 228 DCHECK_NE(state_, kDecodeFinished); |
| 229 DCHECK_EQ(status != DemuxerStream::kOk, !buffer) << status; | 229 DCHECK_EQ(status != DemuxerStream::kOk, !buffer) << status; |
| 230 | 230 |
| 231 if (state_ == kUninitialized) | 231 if (state_ == kUninitialized) |
| 232 return; | 232 return; |
| 233 | 233 |
| 234 DCHECK(!read_cb_.is_null()); | 234 DCHECK(!read_cb_.is_null()); |
| 235 | 235 |
| 236 if (status == DemuxerStream::kConfigChanged) { | |
| 237 if (!ConfigureDecoder()) { | |
| 238 base::ResetAndReturn(&read_cb_).Run(kDecodeError, NULL); | |
| 239 state_ = kDecodeFinished; | |
|
acolwell GONE FROM CHROMIUM
2013/01/03 17:53:31
Why is this needed now? The Read() shouldn't be ca
xhwang
2013/01/04 01:28:05
This transition follows the comment on line 298. I
| |
| 240 if (!reset_cb_.is_null()) | |
| 241 base::ResetAndReturn(&reset_cb_).Run(); | |
| 242 return; | |
| 243 } | |
| 244 | |
| 245 if (!reset_cb_.is_null()) { | |
|
acolwell GONE FROM CHROMIUM
2013/01/03 17:53:31
nit: If you flip the condition here you can reuse
xhwang
2013/01/04 01:28:05
Done.
| |
| 246 base::ResetAndReturn(&read_cb_).Run(kOk, NULL); | |
| 247 DoReset(); | |
| 248 return; | |
| 249 } | |
| 250 | |
| 251 ReadFromDemuxerStream(); | |
| 252 return; | |
| 253 } | |
| 254 | |
| 236 if (!reset_cb_.is_null()) { | 255 if (!reset_cb_.is_null()) { |
| 237 base::ResetAndReturn(&read_cb_).Run(kOk, NULL); | 256 base::ResetAndReturn(&read_cb_).Run(kOk, NULL); |
| 238 DoReset(); | 257 DoReset(); |
| 239 return; | 258 return; |
| 240 } | 259 } |
| 241 | 260 |
| 242 if (status == DemuxerStream::kAborted) { | 261 if (status == DemuxerStream::kAborted) { |
| 243 base::ResetAndReturn(&read_cb_).Run(kOk, NULL); | 262 base::ResetAndReturn(&read_cb_).Run(kOk, NULL); |
| 244 return; | 263 return; |
| 245 } | 264 } |
| 246 | 265 |
| 247 if (status == DemuxerStream::kConfigChanged) { | |
| 248 if (!ConfigureDecoder()) { | |
| 249 base::ResetAndReturn(&read_cb_).Run(kDecodeError, NULL); | |
| 250 return; | |
| 251 } | |
| 252 | |
| 253 ReadFromDemuxerStream(); | |
| 254 return; | |
| 255 } | |
| 256 | |
| 257 DCHECK_EQ(status, DemuxerStream::kOk); | 266 DCHECK_EQ(status, DemuxerStream::kOk); |
| 258 DecodeBuffer(buffer); | 267 DecodeBuffer(buffer); |
| 259 } | 268 } |
| 260 | 269 |
| 261 void FFmpegVideoDecoder::DecodeBuffer( | 270 void FFmpegVideoDecoder::DecodeBuffer( |
| 262 const scoped_refptr<DecoderBuffer>& buffer) { | 271 const scoped_refptr<DecoderBuffer>& buffer) { |
| 263 DCHECK(message_loop_->BelongsToCurrentThread()); | 272 DCHECK(message_loop_->BelongsToCurrentThread()); |
| 264 DCHECK_NE(state_, kUninitialized); | 273 DCHECK_NE(state_, kUninitialized); |
| 265 DCHECK_NE(state_, kDecodeFinished); | 274 DCHECK_NE(state_, kDecodeFinished); |
| 266 DCHECK(reset_cb_.is_null()); | 275 DCHECK(reset_cb_.is_null()); |
| (...skipping 175 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 442 if (!codec || avcodec_open2(codec_context_, codec, NULL) < 0) { | 451 if (!codec || avcodec_open2(codec_context_, codec, NULL) < 0) { |
| 443 ReleaseFFmpegResources(); | 452 ReleaseFFmpegResources(); |
| 444 return false; | 453 return false; |
| 445 } | 454 } |
| 446 | 455 |
| 447 av_frame_ = avcodec_alloc_frame(); | 456 av_frame_ = avcodec_alloc_frame(); |
| 448 return true; | 457 return true; |
| 449 } | 458 } |
| 450 | 459 |
| 451 } // namespace media | 460 } // namespace media |
| OLD | NEW |