From e92f96eef9f1c1bf59e778b47ebfda8a00d8d2c3 Mon Sep 17 00:00:00 2001 From: James Willcox Date: Fri, 3 Mar 2017 15:16:28 -0600 Subject: [PATCH] Bug 1322650 - Make video decoding work with new SurfaceTexture API r=jolin MozReview-Commit-ID: EXQ5YDSMMGL --- .../platforms/android/RemoteDataDecoder.cpp | 23 +++++++------------ .../geckoview/src/main/AndroidManifest.xml | 8 +++++++ 2 files changed, 16 insertions(+), 15 deletions(-) diff --git a/dom/media/platforms/android/RemoteDataDecoder.cpp b/dom/media/platforms/android/RemoteDataDecoder.cpp index 0149e2262f98..4fb2731b4cc4 100644 --- a/dom/media/platforms/android/RemoteDataDecoder.cpp +++ b/dom/media/platforms/android/RemoteDataDecoder.cpp @@ -4,7 +4,6 @@ #include "AndroidBridge.h" #include "AndroidDecoderModule.h" -#include "AndroidSurfaceTexture.h" #include "JavaCallbacksSupport.h" #include "SimpleMap.h" #include "GLImages.h" @@ -134,7 +133,7 @@ public: if (size > 0) { RefPtr img = new SurfaceTextureImage( - mDecoder->mSurfaceTexture.get(), inputInfo.mImageSize, + mDecoder->mSurfaceHandle, inputInfo.mImageSize, gl::OriginPos::BottomLeft); RefPtr v = VideoData::CreateFromImage( @@ -177,18 +176,12 @@ public: RefPtr Init() override { - mSurfaceTexture = AndroidSurfaceTexture::Create(); - if (!mSurfaceTexture) { - NS_WARNING("Failed to create SurfaceTexture for video decode\n"); - return InitPromise::CreateAndReject(NS_ERROR_DOM_MEDIA_FATAL_ERR, - __func__); + jni::Object::LocalRef surf = SurfaceAllocator::AcquireSurface(mConfig.mImage.width, mConfig.mImage.height, false); + if (!surf) { + return InitPromise::CreateAndReject(NS_ERROR_DOM_MEDIA_FATAL_ERR, __func__); } - if (!jni::IsFennec()) { - NS_WARNING("Remote decoding not supported in non-Fennec environment\n"); - return InitPromise::CreateAndReject(NS_ERROR_DOM_MEDIA_FATAL_ERR, - __func__); - } + mSurfaceHandle = GeckoSurface::LocalRef(GeckoSurface::Ref::From(surf))->GetHandle(); // Register native methods. JavaCallbacksSupport::Init(); @@ -197,9 +190,10 @@ public: JavaCallbacksSupport::AttachNative( mJavaCallbacks, mozilla::MakeUnique(this)); + auto surfRef = Surface::LocalRef(Surface::Ref::From(surf)); mJavaDecoder = CodecProxy::Create(false, // false indicates to create a decoder and true denotes encoder mFormat, - mSurfaceTexture->JavaSurface(), + surfRef, mJavaCallbacks, mDrmStubId); if (mJavaDecoder == nullptr) { @@ -239,7 +233,7 @@ public: private: layers::ImageContainer* mImageContainer; const VideoInfo mConfig; - RefPtr mSurfaceTexture; + AndroidSurfaceTextureHandle mSurfaceHandle; SimpleMap mInputInfos; bool mIsCodecSupportAdaptivePlayback = false; }; @@ -411,7 +405,6 @@ RemoteDataDecoder::CreateVideoDecoder(const CreateDecoderParams& aParams, const nsString& aDrmStubId, CDMProxy* aProxy) { - const VideoInfo& config = aParams.VideoConfig(); MediaFormat::LocalRef format; NS_ENSURE_SUCCESS( diff --git a/mobile/android/geckoview/src/main/AndroidManifest.xml b/mobile/android/geckoview/src/main/AndroidManifest.xml index 1f508da4437f..62137f765614 100644 --- a/mobile/android/geckoview/src/main/AndroidManifest.xml +++ b/mobile/android/geckoview/src/main/AndroidManifest.xml @@ -38,6 +38,14 @@ + + +