| OLD | NEW |
| 1 // Copyright (c) 2013 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2013 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 "content/common/gpu/media/android_video_decode_accelerator.h" | 5 #include "content/common/gpu/media/android_video_decode_accelerator.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 "base/message_loop/message_loop.h" | 9 #include "base/message_loop/message_loop.h" |
| 10 #include "base/metrics/histogram.h" | 10 #include "base/metrics/histogram.h" |
| (...skipping 51 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 62 return base::TimeDelta::FromMilliseconds(10); | 62 return base::TimeDelta::FromMilliseconds(10); |
| 63 } | 63 } |
| 64 | 64 |
| 65 static inline const base::TimeDelta NoWaitTimeOut() { | 65 static inline const base::TimeDelta NoWaitTimeOut() { |
| 66 return base::TimeDelta::FromMicroseconds(0); | 66 return base::TimeDelta::FromMicroseconds(0); |
| 67 } | 67 } |
| 68 | 68 |
| 69 AndroidVideoDecodeAccelerator::AndroidVideoDecodeAccelerator( | 69 AndroidVideoDecodeAccelerator::AndroidVideoDecodeAccelerator( |
| 70 const base::WeakPtr<gpu::gles2::GLES2Decoder> decoder, | 70 const base::WeakPtr<gpu::gles2::GLES2Decoder> decoder, |
| 71 const base::Callback<bool(void)>& make_context_current) | 71 const base::Callback<bool(void)>& make_context_current) |
| 72 : client_(NULL), | 72 : client_(nullptr), |
| 73 make_context_current_(make_context_current), | 73 make_context_current_(make_context_current), |
| 74 codec_(media::kCodecH264), | 74 codec_(media::kCodecH264), |
| 75 state_(NO_ERROR), | 75 state_(NO_ERROR), |
| 76 surface_texture_id_(0), | 76 surface_texture_id_(0), |
| 77 picturebuffers_requested_(false), | 77 picturebuffers_requested_(false), |
| 78 gl_decoder_(decoder), | 78 gl_decoder_(decoder), |
| 79 weak_this_factory_(this) {} | 79 weak_this_factory_(this) {} |
| 80 | 80 |
| 81 AndroidVideoDecodeAccelerator::~AndroidVideoDecodeAccelerator() { | 81 AndroidVideoDecodeAccelerator::~AndroidVideoDecodeAccelerator() { |
| 82 DCHECK(thread_checker_.CalledOnValidThread()); | 82 DCHECK(thread_checker_.CalledOnValidThread()); |
| (...skipping 138 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 221 } | 221 } |
| 222 | 222 |
| 223 bool eos = false; | 223 bool eos = false; |
| 224 base::TimeDelta timestamp; | 224 base::TimeDelta timestamp; |
| 225 int32 buf_index = 0; | 225 int32 buf_index = 0; |
| 226 do { | 226 do { |
| 227 size_t offset = 0; | 227 size_t offset = 0; |
| 228 size_t size = 0; | 228 size_t size = 0; |
| 229 | 229 |
| 230 media::MediaCodecStatus status = media_codec_->DequeueOutputBuffer( | 230 media::MediaCodecStatus status = media_codec_->DequeueOutputBuffer( |
| 231 NoWaitTimeOut(), &buf_index, &offset, &size, ×tamp, &eos, NULL); | 231 NoWaitTimeOut(), &buf_index, &offset, &size, ×tamp, &eos, nullptr); |
| 232 switch (status) { | 232 switch (status) { |
| 233 case media::MEDIA_CODEC_DEQUEUE_OUTPUT_AGAIN_LATER: | 233 case media::MEDIA_CODEC_DEQUEUE_OUTPUT_AGAIN_LATER: |
| 234 case media::MEDIA_CODEC_ERROR: | 234 case media::MEDIA_CODEC_ERROR: |
| 235 return; | 235 return; |
| 236 | 236 |
| 237 case media::MEDIA_CODEC_OUTPUT_FORMAT_CHANGED: { | 237 case media::MEDIA_CODEC_OUTPUT_FORMAT_CHANGED: { |
| 238 int32 width, height; | 238 int32 width, height; |
| 239 media_codec_->GetOutputFormat(&width, &height); | 239 media_codec_->GetOutputFormat(&width, &height); |
| 240 | 240 |
| 241 if (!picturebuffers_requested_) { | 241 if (!picturebuffers_requested_) { |
| (...skipping 209 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 451 | 451 |
| 452 bool AndroidVideoDecodeAccelerator::ConfigureMediaCodec() { | 452 bool AndroidVideoDecodeAccelerator::ConfigureMediaCodec() { |
| 453 DCHECK(thread_checker_.CalledOnValidThread()); | 453 DCHECK(thread_checker_.CalledOnValidThread()); |
| 454 DCHECK(surface_texture_.get()); | 454 DCHECK(surface_texture_.get()); |
| 455 | 455 |
| 456 gfx::ScopedJavaSurface surface(surface_texture_.get()); | 456 gfx::ScopedJavaSurface surface(surface_texture_.get()); |
| 457 | 457 |
| 458 // Pass a dummy 320x240 canvas size and let the codec signal the real size | 458 // Pass a dummy 320x240 canvas size and let the codec signal the real size |
| 459 // when it's known from the bitstream. | 459 // when it's known from the bitstream. |
| 460 media_codec_.reset(media::VideoCodecBridge::CreateDecoder( | 460 media_codec_.reset(media::VideoCodecBridge::CreateDecoder( |
| 461 codec_, false, gfx::Size(320, 240), surface.j_surface().obj(), NULL)); | 461 codec_, false, gfx::Size(320, 240), surface.j_surface().obj(), nullptr)); |
| 462 if (!media_codec_) | 462 if (!media_codec_) |
| 463 return false; | 463 return false; |
| 464 | 464 |
| 465 io_timer_.Start(FROM_HERE, | 465 io_timer_.Start(FROM_HERE, |
| 466 DecodePollDelay(), | 466 DecodePollDelay(), |
| 467 this, | 467 this, |
| 468 &AndroidVideoDecodeAccelerator::DoIOTask); | 468 &AndroidVideoDecodeAccelerator::DoIOTask); |
| 469 return true; | 469 return true; |
| 470 } | 470 } |
| 471 | 471 |
| (...skipping 81 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 553 void AndroidVideoDecodeAccelerator::NotifyResetDone() { | 553 void AndroidVideoDecodeAccelerator::NotifyResetDone() { |
| 554 client_->NotifyResetDone(); | 554 client_->NotifyResetDone(); |
| 555 } | 555 } |
| 556 | 556 |
| 557 void AndroidVideoDecodeAccelerator::NotifyError( | 557 void AndroidVideoDecodeAccelerator::NotifyError( |
| 558 media::VideoDecodeAccelerator::Error error) { | 558 media::VideoDecodeAccelerator::Error error) { |
| 559 client_->NotifyError(error); | 559 client_->NotifyError(error); |
| 560 } | 560 } |
| 561 | 561 |
| 562 } // namespace content | 562 } // namespace content |
| OLD | NEW |