| OLD | NEW |
| 1 // Copyright 2014 The Chromium Authors. All rights reserved. | 1 // Copyright 2014 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/decoder_stream.h" | 5 #include "media/filters/decoder_stream.h" |
| 6 | 6 |
| 7 #include <utility> | 7 #include <utility> |
| 8 | 8 |
| 9 #include "base/bind.h" | 9 #include "base/bind.h" |
| 10 #include "base/callback_helpers.h" | 10 #include "base/callback_helpers.h" |
| (...skipping 317 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 328 } | 328 } |
| 329 | 329 |
| 330 template <DemuxerStream::Type StreamType> | 330 template <DemuxerStream::Type StreamType> |
| 331 void DecoderStream<StreamType>::FlushDecoder() { | 331 void DecoderStream<StreamType>::FlushDecoder() { |
| 332 Decode(DecoderBuffer::CreateEOSBuffer()); | 332 Decode(DecoderBuffer::CreateEOSBuffer()); |
| 333 } | 333 } |
| 334 | 334 |
| 335 template <DemuxerStream::Type StreamType> | 335 template <DemuxerStream::Type StreamType> |
| 336 void DecoderStream<StreamType>::OnDecodeDone(int buffer_size, | 336 void DecoderStream<StreamType>::OnDecodeDone(int buffer_size, |
| 337 bool end_of_stream, | 337 bool end_of_stream, |
| 338 typename Decoder::Status status) { | 338 DecodeStatus status) { |
| 339 FUNCTION_DVLOG(2) << ": " << status; | 339 FUNCTION_DVLOG(2) << ": " << status; |
| 340 DCHECK(state_ == STATE_NORMAL || state_ == STATE_FLUSHING_DECODER || | 340 DCHECK(state_ == STATE_NORMAL || state_ == STATE_FLUSHING_DECODER || |
| 341 state_ == STATE_PENDING_DEMUXER_READ || state_ == STATE_ERROR) | 341 state_ == STATE_PENDING_DEMUXER_READ || state_ == STATE_ERROR) |
| 342 << state_; | 342 << state_; |
| 343 DCHECK_GT(pending_decode_requests_, 0); | 343 DCHECK_GT(pending_decode_requests_, 0); |
| 344 | 344 |
| 345 --pending_decode_requests_; | 345 --pending_decode_requests_; |
| 346 | 346 |
| 347 TRACE_EVENT_ASYNC_END0("media", GetTraceString<StreamType>(), this); | 347 TRACE_EVENT_ASYNC_END0("media", GetTraceString<StreamType>(), this); |
| 348 | 348 |
| 349 if (end_of_stream) { | 349 if (end_of_stream) { |
| 350 DCHECK(!pending_decode_requests_); | 350 DCHECK(!pending_decode_requests_); |
| 351 decoding_eos_ = false; | 351 decoding_eos_ = false; |
| 352 } | 352 } |
| 353 | 353 |
| 354 if (state_ == STATE_ERROR) { | 354 if (state_ == STATE_ERROR) { |
| 355 DCHECK(read_cb_.is_null()); | 355 DCHECK(read_cb_.is_null()); |
| 356 return; | 356 return; |
| 357 } | 357 } |
| 358 | 358 |
| 359 // Drop decoding result if Reset() was called during decoding. | 359 // Drop decoding result if Reset() was called during decoding. |
| 360 // The resetting process will be handled when the decoder is reset. | 360 // The resetting process will be handled when the decoder is reset. |
| 361 if (!reset_cb_.is_null()) | 361 if (!reset_cb_.is_null()) |
| 362 return; | 362 return; |
| 363 | 363 |
| 364 switch (status) { | 364 switch (status) { |
| 365 case Decoder::kDecodeError: | 365 case DecodeStatus::DECODE_ERROR: |
| 366 state_ = STATE_ERROR; | 366 state_ = STATE_ERROR; |
| 367 MEDIA_LOG(ERROR, media_log_) << GetStreamTypeString() << " decode error"; | 367 MEDIA_LOG(ERROR, media_log_) << GetStreamTypeString() << " decode error"; |
| 368 ready_outputs_.clear(); | 368 ready_outputs_.clear(); |
| 369 if (!read_cb_.is_null()) | 369 if (!read_cb_.is_null()) |
| 370 SatisfyRead(DECODE_ERROR, NULL); | 370 SatisfyRead(DECODE_ERROR, NULL); |
| 371 return; | 371 return; |
| 372 | 372 |
| 373 case Decoder::kAborted: | 373 case DecodeStatus::ABORTED: |
| 374 // Decoder can return kAborted during Reset() or during destruction. | 374 // Decoder can return DecodeStatus::ABORTED during Reset() or during |
| 375 // destruction. |
| 375 return; | 376 return; |
| 376 | 377 |
| 377 case Decoder::kOk: | 378 case DecodeStatus::OK: |
| 378 // Any successful decode counts! | 379 // Any successful decode counts! |
| 379 if (buffer_size > 0) | 380 if (buffer_size > 0) |
| 380 StreamTraits::ReportStatistics(statistics_cb_, buffer_size); | 381 StreamTraits::ReportStatistics(statistics_cb_, buffer_size); |
| 381 | 382 |
| 382 if (state_ == STATE_NORMAL) { | 383 if (state_ == STATE_NORMAL) { |
| 383 if (end_of_stream) { | 384 if (end_of_stream) { |
| 384 state_ = STATE_END_OF_STREAM; | 385 state_ = STATE_END_OF_STREAM; |
| 385 if (ready_outputs_.empty() && !read_cb_.is_null()) | 386 if (ready_outputs_.empty() && !read_cb_.is_null()) |
| 386 SatisfyRead(OK, StreamTraits::CreateEOSOutput()); | 387 SatisfyRead(OK, StreamTraits::CreateEOSOutput()); |
| 387 return; | 388 return; |
| (...skipping 230 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 618 } | 619 } |
| 619 | 620 |
| 620 // The resetting process will be continued in OnDecoderReinitialized(). | 621 // The resetting process will be continued in OnDecoderReinitialized(). |
| 621 ReinitializeDecoder(); | 622 ReinitializeDecoder(); |
| 622 } | 623 } |
| 623 | 624 |
| 624 template class DecoderStream<DemuxerStream::VIDEO>; | 625 template class DecoderStream<DemuxerStream::VIDEO>; |
| 625 template class DecoderStream<DemuxerStream::AUDIO>; | 626 template class DecoderStream<DemuxerStream::AUDIO>; |
| 626 | 627 |
| 627 } // namespace media | 628 } // namespace media |
| OLD | NEW |