| 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 69e7af1a66354ef9ee217f190e2ca4218d30183c..8b784f19fd843fc708ca53760bd0d39226910fa6 100644
|
| --- a/content/common/gpu/media/android_video_decode_accelerator.cc
|
| +++ b/content/common/gpu/media/android_video_decode_accelerator.cc
|
| @@ -168,9 +168,9 @@ AndroidVideoDecodeAccelerator::AndroidVideoDecodeAccelerator(
|
| defer_errors_(false),
|
| weak_this_factory_(this) {
|
| if (UseDeferredRenderingStrategy())
|
| - strategy_.reset(new AndroidDeferredRenderingBackingStrategy());
|
| + strategy_.reset(new AndroidDeferredRenderingBackingStrategy(this));
|
| else
|
| - strategy_.reset(new AndroidCopyingBackingStrategy());
|
| + strategy_.reset(new AndroidCopyingBackingStrategy(this));
|
| }
|
|
|
| AndroidVideoDecodeAccelerator::~AndroidVideoDecodeAccelerator() {
|
| @@ -230,11 +230,19 @@ bool AndroidVideoDecodeAccelerator::Initialize(const Config& config,
|
| return false;
|
| }
|
|
|
| - strategy_->Initialize(this);
|
| + surface_ = strategy_->Initialize(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 =
|
| + strategy_->GetSurfaceTexture();
|
| + if (surface_texture) {
|
| + on_frame_available_handler_ =
|
| + new OnFrameAvailableHandler(this, surface_texture);
|
| + }
|
|
|
| // For encrypted streams we postpone configuration until MediaCrypto is
|
| // available.
|
| @@ -503,7 +511,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;
|
| @@ -515,7 +523,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(
|
| @@ -552,7 +560,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);
|
| }
|
| @@ -590,11 +598,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(
|
| @@ -690,11 +699,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.
|
| @@ -704,7 +710,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.";
|
|
|