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 14 matching lines...) Expand all Loading... | |
25 const int kNextFrameDelay = 1; | 25 const int kNextFrameDelay = 1; |
26 | 26 |
27 // Timeout for dequeuing an input buffer from MediaCodec in milliseconds. | 27 // Timeout for dequeuing an input buffer from MediaCodec in milliseconds. |
28 const int kInputBufferTimeout = 20; | 28 const int kInputBufferTimeout = 20; |
29 | 29 |
30 // Timeout for dequeuing an output buffer from MediaCodec in milliseconds. | 30 // Timeout for dequeuing an output buffer from MediaCodec in milliseconds. |
31 const int kOutputBufferTimeout = 20; | 31 const int kOutputBufferTimeout = 20; |
32 } | 32 } |
33 | 33 |
34 MediaCodecDecoder::MediaCodecDecoder( | 34 MediaCodecDecoder::MediaCodecDecoder( |
35 const char* decoder_thread_name, | |
35 const scoped_refptr<base::SingleThreadTaskRunner>& media_task_runner, | 36 const scoped_refptr<base::SingleThreadTaskRunner>& media_task_runner, |
37 FrameStatistics* frame_statistics, | |
36 const base::Closure& external_request_data_cb, | 38 const base::Closure& external_request_data_cb, |
37 const base::Closure& starvation_cb, | 39 const base::Closure& starvation_cb, |
38 const base::Closure& decoder_drained_cb, | 40 const base::Closure& decoder_drained_cb, |
39 const base::Closure& stop_done_cb, | 41 const base::Closure& stop_done_cb, |
40 const base::Closure& waiting_for_decryption_key_cb, | 42 const base::Closure& waiting_for_decryption_key_cb, |
41 const base::Closure& error_cb, | 43 const base::Closure& error_cb) |
42 const char* decoder_thread_name) | 44 : decoder_thread_(decoder_thread_name), |
43 : media_task_runner_(media_task_runner), | 45 media_task_runner_(media_task_runner), |
44 decoder_thread_(decoder_thread_name), | 46 frame_statistics_(frame_statistics), |
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 waiting_for_decryption_key_cb_(waiting_for_decryption_key_cb), | 54 waiting_for_decryption_key_cb_(waiting_for_decryption_key_cb), |
53 error_cb_(error_cb), | 55 error_cb_(error_cb), |
54 state_(kStopped), | 56 state_(kStopped), |
(...skipping 455 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
510 void MediaCodecDecoder::CheckLastFrame(bool eos_encountered, | 512 void 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; |
xhwang
2015/10/01 21:58:57
The naming of this member variable still can be im
Tima Vaisburd
2015/10/02 00:44:32
Acknowledged.
| |
521 } | 523 } |
522 } | 524 } |
523 | 525 |
524 void MediaCodecDecoder::OnCodecError() { | 526 void MediaCodecDecoder::OnCodecError() { |
525 DCHECK(media_task_runner_->BelongsToCurrentThread()); | 527 DCHECK(media_task_runner_->BelongsToCurrentThread()); |
526 | 528 |
527 // Ignore codec errors from the moment surface is changed till the | 529 // Ignore codec errors from the moment surface is changed till the |
528 // |media_codec_bridge_| is deleted. | 530 // |media_codec_bridge_| is deleted. |
529 if (needs_reconfigure_) { | 531 if (needs_reconfigure_) { |
530 DVLOG(1) << class_name() << "::" << __FUNCTION__ | 532 DVLOG(1) << class_name() << "::" << __FUNCTION__ |
(...skipping 416 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
947 RETURN_STRING(kStopping); | 949 RETURN_STRING(kStopping); |
948 RETURN_STRING(kInEmergencyStop); | 950 RETURN_STRING(kInEmergencyStop); |
949 RETURN_STRING(kError); | 951 RETURN_STRING(kError); |
950 } | 952 } |
951 return nullptr; // crash early | 953 return nullptr; // crash early |
952 } | 954 } |
953 | 955 |
954 #undef RETURN_STRING | 956 #undef RETURN_STRING |
955 | 957 |
956 } // namespace media | 958 } // namespace media |
OLD | NEW |