| 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/buffers.h" | 10 #include "media/base/buffers.h" |
| (...skipping 195 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 206 } | 206 } |
| 207 | 207 |
| 208 void MediaCodecVideoDecoder::Render(int buffer_index, | 208 void MediaCodecVideoDecoder::Render(int buffer_index, |
| 209 size_t offset, | 209 size_t offset, |
| 210 size_t size, | 210 size_t size, |
| 211 RenderMode render_mode, | 211 RenderMode render_mode, |
| 212 base::TimeDelta pts, | 212 base::TimeDelta pts, |
| 213 bool eos_encountered) { | 213 bool eos_encountered) { |
| 214 DCHECK(decoder_thread_.task_runner()->BelongsToCurrentThread()); | 214 DCHECK(decoder_thread_.task_runner()->BelongsToCurrentThread()); |
| 215 | 215 |
| 216 DVLOG(2) << class_name() << "::" << __FUNCTION__ << " pts:" << pts | 216 // http://crbug.com/526755 |
| 217 << " index:" << buffer_index << " size:" << size | 217 if (verbose_) { |
| 218 << (eos_encountered ? " EOS " : " ") << AsString(render_mode); | 218 DVLOG(0) << class_name() << "::" << __FUNCTION__ << " pts:" << pts |
| 219 << (eos_encountered ? " EOS " : " ") << AsString(render_mode); |
| 220 } else { |
| 221 DVLOG(2) << class_name() << "::" << __FUNCTION__ << " pts:" << pts |
| 222 << " index:" << buffer_index << " size:" << size |
| 223 << (eos_encountered ? " EOS " : " ") << AsString(render_mode); |
| 224 } |
| 219 | 225 |
| 220 // Normally EOS comes as a separate access unit that does not have data, | 226 // Normally EOS comes as a separate access unit that does not have data, |
| 221 // the corresponding |size| will be 0. | 227 // the corresponding |size| will be 0. |
| 222 if (!size && eos_encountered) { | 228 if (!size && eos_encountered) { |
| 223 // Stand-alone EOS | 229 // Stand-alone EOS |
| 224 // Discard the PTS that comes with it and ensure it is released last. | 230 // Discard the PTS that comes with it and ensure it is released last. |
| 225 pts = last_seen_pts_ + | 231 pts = last_seen_pts_ + |
| 226 base::TimeDelta::FromMilliseconds(kDelayForStandAloneEOS); | 232 base::TimeDelta::FromMilliseconds(kDelayForStandAloneEOS); |
| 227 } else { | 233 } else { |
| 228 // Keep track of last seen PTS | 234 // Keep track of last seen PTS |
| (...skipping 71 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 300 } | 306 } |
| 301 #endif | 307 #endif |
| 302 | 308 |
| 303 void MediaCodecVideoDecoder::ReleaseOutputBuffer(int buffer_index, | 309 void MediaCodecVideoDecoder::ReleaseOutputBuffer(int buffer_index, |
| 304 base::TimeDelta pts, | 310 base::TimeDelta pts, |
| 305 bool render, | 311 bool render, |
| 306 bool update_time, | 312 bool update_time, |
| 307 bool eos_encountered) { | 313 bool eos_encountered) { |
| 308 DCHECK(decoder_thread_.task_runner()->BelongsToCurrentThread()); | 314 DCHECK(decoder_thread_.task_runner()->BelongsToCurrentThread()); |
| 309 | 315 |
| 310 DVLOG(2) << class_name() << "::" << __FUNCTION__ << " pts:" << pts; | 316 // http://crbug.com/526755 |
| 317 if (verbose_) { |
| 318 DVLOG(0) << class_name() << "::" << __FUNCTION__ << " pts:" << pts |
| 319 << " eos_encountered:" << eos_encountered; |
| 320 } else { |
| 321 DVLOG(2) << class_name() << "::" << __FUNCTION__ << " pts:" << pts; |
| 322 } |
| 311 | 323 |
| 312 // Do not render if we are in emergency stop, there might be no surface. | 324 // Do not render if we are in emergency stop, there might be no surface. |
| 313 if (InEmergencyStop()) | 325 if (InEmergencyStop()) |
| 314 render = false; | 326 render = false; |
| 315 | 327 |
| 316 media_codec_bridge_->ReleaseOutputBuffer(buffer_index, render); | 328 media_codec_bridge_->ReleaseOutputBuffer(buffer_index, render); |
| 317 | 329 |
| 318 delayed_buffers_.erase(buffer_index); | 330 delayed_buffers_.erase(buffer_index); |
| 319 | 331 |
| 320 CheckLastFrame(eos_encountered, !delayed_buffers_.empty()); | 332 CheckLastFrame(eos_encountered, !delayed_buffers_.empty()); |
| 321 | 333 |
| 322 // |update_current_time_cb_| might be null if there is audio stream. | 334 // |update_current_time_cb_| might be null if there is audio stream. |
| 323 // Do not update current time for stand-alone EOS frames. | 335 // Do not update current time for stand-alone EOS frames. |
| 324 if (!update_current_time_cb_.is_null() && update_time) { | 336 if (!update_current_time_cb_.is_null() && update_time) { |
| 325 media_task_runner_->PostTask( | 337 media_task_runner_->PostTask( |
| 326 FROM_HERE, base::Bind(update_current_time_cb_, pts, pts, false)); | 338 FROM_HERE, base::Bind(update_current_time_cb_, pts, pts, false)); |
| 327 } | 339 } |
| 328 } | 340 } |
| 329 | 341 |
| 330 } // namespace media | 342 } // namespace media |
| OLD | NEW |