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_video_decoder.h" | 5 #include "media/base/android/media_codec_video_decoder.h" |
6 | 6 |
7 #include "base/bind.h" | 7 #include "base/bind.h" |
8 #include "base/logging.h" | 8 #include "base/logging.h" |
9 #include "media/base/android/media_codec_bridge.h" | 9 #include "media/base/android/media_codec_bridge.h" |
10 #include "media/base/demuxer_stream.h" | 10 #include "media/base/demuxer_stream.h" |
11 #include "media/base/timestamp_constants.h" | 11 #include "media/base/timestamp_constants.h" |
12 | 12 |
13 namespace media { | 13 namespace media { |
14 | 14 |
15 namespace { | 15 namespace { |
16 const int kDelayForStandAloneEOS = 2; // milliseconds | 16 const int kDelayForStandAloneEOS = 2; // milliseconds |
17 } | 17 } |
18 | 18 |
19 MediaCodecVideoDecoder::MediaCodecVideoDecoder( | 19 MediaCodecVideoDecoder::MediaCodecVideoDecoder( |
20 const scoped_refptr<base::SingleThreadTaskRunner>& media_task_runner, | 20 const scoped_refptr<base::SingleThreadTaskRunner>& media_task_runner, |
21 const base::Closure& request_data_cb, | 21 const base::Closure& request_data_cb, |
22 const base::Closure& starvation_cb, | 22 const base::Closure& starvation_cb, |
23 const base::Closure& decoder_drained_cb, | 23 const base::Closure& decoder_drained_cb, |
24 const base::Closure& stop_done_cb, | 24 const base::Closure& stop_done_cb, |
25 const base::Closure& error_cb, | 25 const base::Closure& error_cb, |
26 const SetTimeCallback& update_current_time_cb, | 26 const SetTimeCallback& update_current_time_cb, |
27 const VideoSizeChangedCallback& video_size_changed_cb, | 27 const VideoSizeChangedCallback& video_size_changed_cb) |
28 const base::Closure& codec_created_cb) | |
29 : MediaCodecDecoder(media_task_runner, | 28 : MediaCodecDecoder(media_task_runner, |
30 request_data_cb, | 29 request_data_cb, |
31 starvation_cb, | 30 starvation_cb, |
32 decoder_drained_cb, | 31 decoder_drained_cb, |
33 stop_done_cb, | 32 stop_done_cb, |
34 error_cb, | 33 error_cb, |
35 "VideoDecoder"), | 34 "VideoDecoder"), |
36 update_current_time_cb_(update_current_time_cb), | 35 update_current_time_cb_(update_current_time_cb), |
37 video_size_changed_cb_(video_size_changed_cb), | 36 video_size_changed_cb_(video_size_changed_cb) { |
38 codec_created_cb_(codec_created_cb) { | |
39 } | 37 } |
40 | 38 |
41 MediaCodecVideoDecoder::~MediaCodecVideoDecoder() { | 39 MediaCodecVideoDecoder::~MediaCodecVideoDecoder() { |
42 DCHECK(media_task_runner_->BelongsToCurrentThread()); | 40 DCHECK(media_task_runner_->BelongsToCurrentThread()); |
43 DVLOG(1) << "VideoDecoder::~VideoDecoder()"; | 41 DVLOG(1) << "VideoDecoder::~VideoDecoder()"; |
44 ReleaseDecoderResources(); | 42 ReleaseDecoderResources(); |
45 } | 43 } |
46 | 44 |
47 const char* MediaCodecVideoDecoder::class_name() const { | 45 const char* MediaCodecVideoDecoder::class_name() const { |
48 return "VideoDecoder"; | 46 return "VideoDecoder"; |
(...skipping 110 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
159 GetMediaCrypto().obj())); | 157 GetMediaCrypto().obj())); |
160 | 158 |
161 if (!media_codec_bridge_) { | 159 if (!media_codec_bridge_) { |
162 DVLOG(0) << class_name() << "::" << __FUNCTION__ | 160 DVLOG(0) << class_name() << "::" << __FUNCTION__ |
163 << " failed: cannot create video codec"; | 161 << " failed: cannot create video codec"; |
164 return kConfigFailure; | 162 return kConfigFailure; |
165 } | 163 } |
166 | 164 |
167 DVLOG(0) << class_name() << "::" << __FUNCTION__ << " succeeded"; | 165 DVLOG(0) << class_name() << "::" << __FUNCTION__ << " succeeded"; |
168 | 166 |
169 media_task_runner_->PostTask(FROM_HERE, codec_created_cb_); | |
170 | |
171 if (!codec_created_for_tests_cb_.is_null()) | 167 if (!codec_created_for_tests_cb_.is_null()) |
172 media_task_runner_->PostTask(FROM_HERE, codec_created_for_tests_cb_); | 168 media_task_runner_->PostTask(FROM_HERE, codec_created_for_tests_cb_); |
173 | 169 |
174 return kConfigOk; | 170 return kConfigOk; |
175 } | 171 } |
176 | 172 |
177 void MediaCodecVideoDecoder::AssociateCurrentTimeWithPTS(base::TimeDelta pts) { | 173 void MediaCodecVideoDecoder::AssociateCurrentTimeWithPTS(base::TimeDelta pts) { |
178 DCHECK(media_task_runner_->BelongsToCurrentThread()); | 174 DCHECK(media_task_runner_->BelongsToCurrentThread()); |
179 | 175 |
180 DVLOG(1) << class_name() << "::" << __FUNCTION__ << " pts:" << pts; | 176 DVLOG(1) << class_name() << "::" << __FUNCTION__ << " pts:" << pts; |
(...skipping 139 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
320 | 316 |
321 // |update_current_time_cb_| might be null if there is audio stream. | 317 // |update_current_time_cb_| might be null if there is audio stream. |
322 // Do not update current time for stand-alone EOS frames. | 318 // Do not update current time for stand-alone EOS frames. |
323 if (!update_current_time_cb_.is_null() && update_time) { | 319 if (!update_current_time_cb_.is_null() && update_time) { |
324 media_task_runner_->PostTask( | 320 media_task_runner_->PostTask( |
325 FROM_HERE, base::Bind(update_current_time_cb_, pts, pts, false)); | 321 FROM_HERE, base::Bind(update_current_time_cb_, pts, pts, false)); |
326 } | 322 } |
327 } | 323 } |
328 | 324 |
329 } // namespace media | 325 } // namespace media |
OLD | NEW |