Chromium Code Reviews| Index: content/common/gpu/media/android_video_decode_accelerator.cc |
| diff --git a/content/common/gpu/media/android_video_decode_accelerator.cc b/content/common/gpu/media/android_video_decode_accelerator.cc |
| index dfe0fc52895fcc9d70e0624f5b89132dfe6d6df7..57f84a3d40e80651ca73cf4ef7497c6bab9971a6 100644 |
| --- a/content/common/gpu/media/android_video_decode_accelerator.cc |
| +++ b/content/common/gpu/media/android_video_decode_accelerator.cc |
| @@ -220,11 +220,19 @@ bool AndroidVideoDecodeAccelerator::Initialize(const Config& config, |
| return false; |
| } |
| - strategy_->Initialize(this); |
| + surface_ = strategy_->Initialize(this, config.surface_id); |
| + if (surface_.IsEmpty()) { |
| + LOG(ERROR) << "Failed to initialize the backing strategy. The returned " |
| + "Java surface is empty."; |
| + } |
| - surface_texture_ = strategy_->CreateSurfaceTexture(); |
| - on_frame_available_handler_ = |
| - new OnFrameAvailableHandler(this, surface_texture_); |
| + // TODO(watk,liberato): move this into the strategy. |
| + scoped_refptr<gfx::SurfaceTexture> surface_texture = |
|
liberato (no reviews please)
2016/01/27 16:15:33
i forgot about the onFrameAvailable listener. not
|
| + strategy_->GetSurfaceTexture(); |
| + if (surface_texture) { |
| + on_frame_available_handler_ = |
| + new OnFrameAvailableHandler(this, surface_texture); |
| + } |
| // For encrypted streams we postpone configuration until MediaCrypto is |
| // available. |
| @@ -491,7 +499,7 @@ bool AndroidVideoDecodeAccelerator::DequeueOutput() { |
| case media::MEDIA_CODEC_OK: |
| DCHECK_GE(buf_index, 0); |
| - DVLOG(3) << "AVDA::DequeueOutput: pts:" << presentation_timestamp |
| + DVLOG(3) << __FUNCTION__ << ": pts:" << presentation_timestamp |
| << " buf_index:" << buf_index << " offset:" << offset |
| << " size:" << size << " eos:" << eos; |
| break; |
| @@ -503,7 +511,7 @@ bool AndroidVideoDecodeAccelerator::DequeueOutput() { |
| } while (buf_index < 0); |
| if (eos) { |
| - DVLOG(3) << "AVDA::DequeueOutput: Resetting codec state after EOS"; |
| + DVLOG(3) << __FUNCTION__ << ": Resetting codec state after EOS"; |
| ResetCodecState(); |
| base::MessageLoop::current()->PostTask( |
| @@ -540,7 +548,7 @@ bool AndroidVideoDecodeAccelerator::DequeueOutput() { |
| // correction and provides a non-decreasing timestamp sequence, which might |
| // result in timestamp duplicates. Discard the frame if we cannot get the |
| // corresponding buffer id. |
| - DVLOG(3) << "AVDA::DequeueOutput: Releasing buffer with unexpected PTS: " |
| + DVLOG(3) << __FUNCTION__ << ": Releasing buffer with unexpected PTS: " |
| << presentation_timestamp; |
| media_codec_->ReleaseOutputBuffer(buf_index, false); |
| } |
| @@ -578,11 +586,12 @@ void AndroidVideoDecodeAccelerator::SendDecodedFrameToClient( |
| // mechanism the strategy likes. |
| strategy_->UseCodecBufferForPictureBuffer(codec_buffer_index, i->second); |
| + const bool allow_overlay = strategy_->PicturesAreOverlayable(); |
| base::MessageLoop::current()->PostTask( |
| FROM_HERE, base::Bind(&AndroidVideoDecodeAccelerator::NotifyPictureReady, |
| weak_this_factory_.GetWeakPtr(), |
| media::Picture(picture_buffer_id, bitstream_id, |
| - gfx::Rect(size_), false))); |
| + gfx::Rect(size_), allow_overlay))); |
| } |
| void AndroidVideoDecodeAccelerator::Decode( |
| @@ -678,11 +687,8 @@ void AndroidVideoDecodeAccelerator::Flush() { |
| bool AndroidVideoDecodeAccelerator::ConfigureMediaCodec() { |
| DCHECK(thread_checker_.CalledOnValidThread()); |
| - DCHECK(surface_texture_.get()); |
| TRACE_EVENT0("media", "AVDA::ConfigureMediaCodec"); |
| - gfx::ScopedJavaSurface surface(surface_texture_.get()); |
| - |
| jobject media_crypto = media_crypto_ ? media_crypto_->obj() : nullptr; |
| // |needs_protected_surface_| implies encrypted stream. |
| @@ -692,7 +698,8 @@ bool AndroidVideoDecodeAccelerator::ConfigureMediaCodec() { |
| // when it's known from the bitstream. |
| media_codec_.reset(media::VideoCodecBridge::CreateDecoder( |
| codec_, needs_protected_surface_, gfx::Size(320, 240), |
| - surface.j_surface().obj(), media_crypto)); |
| + surface_.j_surface().obj(), media_crypto)); |
| + |
| strategy_->CodecChanged(media_codec_.get(), output_picture_buffers_); |
| if (!media_codec_) { |
| LOG(ERROR) << "Failed to create MediaCodec instance."; |