Chromium Code Reviews| OLD | NEW |
|---|---|
| 1 // Copyright 2015 The Chromium Authors. All rights reserved. | 1 // Copyright 2015 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/base/android/media_codec_decoder.h" | 5 #include "media/base/android/media_codec_decoder.h" |
| 6 | 6 |
| 7 #include "base/bind.h" | 7 #include "base/bind.h" |
| 8 #include "base/bind_helpers.h" | 8 #include "base/bind_helpers.h" |
| 9 #include "base/callback_helpers.h" | 9 #include "base/callback_helpers.h" |
| 10 #include "base/logging.h" | 10 #include "base/logging.h" |
| (...skipping 21 matching lines...) Expand all Loading... | |
| 32 } | 32 } |
| 33 | 33 |
| 34 MediaCodecDecoder::MediaCodecDecoder( | 34 MediaCodecDecoder::MediaCodecDecoder( |
| 35 const scoped_refptr<base::SingleThreadTaskRunner>& media_task_runner, | 35 const scoped_refptr<base::SingleThreadTaskRunner>& media_task_runner, |
| 36 const base::Closure& external_request_data_cb, | 36 const base::Closure& external_request_data_cb, |
| 37 const base::Closure& starvation_cb, | 37 const base::Closure& starvation_cb, |
| 38 const base::Closure& decoder_drained_cb, | 38 const base::Closure& decoder_drained_cb, |
| 39 const base::Closure& stop_done_cb, | 39 const base::Closure& stop_done_cb, |
| 40 const base::Closure& key_required_cb, | 40 const base::Closure& key_required_cb, |
| 41 const base::Closure& error_cb, | 41 const base::Closure& error_cb, |
| 42 const char* decoder_thread_name) | 42 const char* decoder_thread_name, |
| 43 FrameStatistics* frame_statistics) | |
| 43 : media_task_runner_(media_task_runner), | 44 : media_task_runner_(media_task_runner), |
| 44 decoder_thread_(decoder_thread_name), | 45 decoder_thread_(decoder_thread_name), |
| 46 frame_statistics_(frame_statistics), | |
|
xhwang
2015/09/30 21:02:57
nit: Make the initialization order consistent with
Tima Vaisburd
2015/10/01 20:05:15
Done.
| |
| 45 needs_reconfigure_(false), | 47 needs_reconfigure_(false), |
| 46 drain_decoder_(false), | 48 drain_decoder_(false), |
| 47 always_reconfigure_for_tests_(false), | 49 always_reconfigure_for_tests_(false), |
| 48 external_request_data_cb_(external_request_data_cb), | 50 external_request_data_cb_(external_request_data_cb), |
| 49 starvation_cb_(starvation_cb), | 51 starvation_cb_(starvation_cb), |
| 50 decoder_drained_cb_(decoder_drained_cb), | 52 decoder_drained_cb_(decoder_drained_cb), |
| 51 stop_done_cb_(stop_done_cb), | 53 stop_done_cb_(stop_done_cb), |
| 52 key_required_cb_(key_required_cb), | 54 key_required_cb_(key_required_cb), |
| 53 error_cb_(error_cb), | 55 error_cb_(error_cb), |
| 54 state_(kStopped), | 56 state_(kStopped), |
| (...skipping 445 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 500 // Set [kInEmergencyStop| state to block already posted ProcessNextFrame(). | 502 // Set [kInEmergencyStop| state to block already posted ProcessNextFrame(). |
| 501 SetState(kInEmergencyStop); | 503 SetState(kInEmergencyStop); |
| 502 | 504 |
| 503 decoder_thread_.Stop(); // synchronous | 505 decoder_thread_.Stop(); // synchronous |
| 504 | 506 |
| 505 SetState(kStopped); | 507 SetState(kStopped); |
| 506 | 508 |
| 507 key_request_posted_ = false; | 509 key_request_posted_ = false; |
| 508 } | 510 } |
| 509 | 511 |
| 510 void MediaCodecDecoder::CheckLastFrame(bool eos_encountered, | 512 bool MediaCodecDecoder::CheckLastFrame(bool eos_encountered, |
| 511 bool has_delayed_tasks) { | 513 bool has_delayed_tasks) { |
| 512 DCHECK(decoder_thread_.task_runner()->BelongsToCurrentThread()); | 514 DCHECK(decoder_thread_.task_runner()->BelongsToCurrentThread()); |
| 513 | 515 |
| 514 bool last_frame_when_stopping = GetState() == kStopping && !has_delayed_tasks; | 516 bool last_frame_when_stopping = GetState() == kStopping && !has_delayed_tasks; |
| 515 | 517 |
| 516 if (last_frame_when_stopping || eos_encountered) { | 518 if (last_frame_when_stopping || eos_encountered) { |
| 517 media_task_runner_->PostTask( | 519 media_task_runner_->PostTask( |
| 518 FROM_HERE, base::Bind(&MediaCodecDecoder::OnLastFrameRendered, | 520 FROM_HERE, base::Bind(&MediaCodecDecoder::OnLastFrameRendered, |
| 519 weak_factory_.GetWeakPtr(), eos_encountered)); | 521 weak_factory_.GetWeakPtr(), eos_encountered)); |
| 520 last_frame_posted_ = true; | 522 last_frame_posted_ = true; |
| 521 } | 523 } |
| 524 return last_frame_posted_; | |
| 522 } | 525 } |
| 523 | 526 |
| 524 void MediaCodecDecoder::OnCodecError() { | 527 void MediaCodecDecoder::OnCodecError() { |
| 525 DCHECK(media_task_runner_->BelongsToCurrentThread()); | 528 DCHECK(media_task_runner_->BelongsToCurrentThread()); |
| 526 | 529 |
| 527 // Ignore codec errors from the moment surface is changed till the | 530 // Ignore codec errors from the moment surface is changed till the |
| 528 // |media_codec_bridge_| is deleted. | 531 // |media_codec_bridge_| is deleted. |
| 529 if (needs_reconfigure_) { | 532 if (needs_reconfigure_) { |
| 530 DVLOG(1) << class_name() << "::" << __FUNCTION__ | 533 DVLOG(1) << class_name() << "::" << __FUNCTION__ |
| 531 << ": needs reconfigure, ignoring"; | 534 << ": needs reconfigure, ignoring"; |
| (...skipping 414 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 946 RETURN_STRING(kStopping); | 949 RETURN_STRING(kStopping); |
| 947 RETURN_STRING(kInEmergencyStop); | 950 RETURN_STRING(kInEmergencyStop); |
| 948 RETURN_STRING(kError); | 951 RETURN_STRING(kError); |
| 949 } | 952 } |
| 950 return nullptr; // crash early | 953 return nullptr; // crash early |
| 951 } | 954 } |
| 952 | 955 |
| 953 #undef RETURN_STRING | 956 #undef RETURN_STRING |
| 954 | 957 |
| 955 } // namespace media | 958 } // namespace media |
| OLD | NEW |