diff --git a/dom/media/platforms/android/RemoteDataDecoder.cpp b/dom/media/platforms/android/RemoteDataDecoder.cpp index 87604370bf6f..918c6c78cee5 100644 --- a/dom/media/platforms/android/RemoteDataDecoder.cpp +++ b/dom/media/platforms/android/RemoteDataDecoder.cpp @@ -208,6 +208,8 @@ public: } mIsCodecSupportAdaptivePlayback = mJavaDecoder->IsAdaptivePlaybackSupported(); + mIsHardwareAccelerated = + mJavaDecoder->IsHardwareAccelerated(); return InitPromise::CreateAndResolve(TrackInfo::kVideoTrack, __func__); } @@ -272,12 +274,19 @@ public: return true; } + bool IsHardwareAccelerated(nsACString& aFailureReason) const override + { + return mIsHardwareAccelerated; + } + private: const VideoInfo mConfig; GeckoSurface::GlobalRef mSurface; AndroidSurfaceTextureHandle mSurfaceHandle; // Only accessed on reader's task queue. bool mIsCodecSupportAdaptivePlayback = false; + // Can be accessed on any thread, but only written on during init. + bool mIsHardwareAccelerated = false; // Accessed on mTaskQueue, reader's TaskQueue and Java callback tread. // SimpleMap however is thread-safe, so it's okay to do so. SimpleMap mInputInfos; diff --git a/mobile/android/geckoview/src/main/aidl/org/mozilla/gecko/media/ICodec.aidl b/mobile/android/geckoview/src/main/aidl/org/mozilla/gecko/media/ICodec.aidl index d48eb47d0a57..3433542efa9b 100644 --- a/mobile/android/geckoview/src/main/aidl/org/mozilla/gecko/media/ICodec.aidl +++ b/mobile/android/geckoview/src/main/aidl/org/mozilla/gecko/media/ICodec.aidl @@ -15,6 +15,7 @@ interface ICodec { void setCallbacks(in ICodecCallbacks callbacks); boolean configure(in FormatParam format, in GeckoSurface surface, in int flags, in String drmStubId); boolean isAdaptivePlaybackSupported(); + boolean isHardwareAccelerated(); boolean isTunneledPlaybackSupported(); void start(); void stop(); diff --git a/mobile/android/geckoview/src/main/java/org/mozilla/gecko/media/Codec.java b/mobile/android/geckoview/src/main/java/org/mozilla/gecko/media/Codec.java index 92b1164f7935..8e9d551e7896 100644 --- a/mobile/android/geckoview/src/main/java/org/mozilla/gecko/media/Codec.java +++ b/mobile/android/geckoview/src/main/java/org/mozilla/gecko/media/Codec.java @@ -350,6 +350,7 @@ import org.mozilla.gecko.gfx.GeckoSurface; private SamplePool mSamplePool; // Values will be updated after configure called. private volatile boolean mIsAdaptivePlaybackSupported = false; + private volatile boolean mIsHardwareAccelerated = false; private boolean mIsTunneledPlaybackSupported = false; public synchronized void setCallbacks(ICodecCallbacks callbacks) throws RemoteException { @@ -399,6 +400,7 @@ import org.mozilla.gecko.gfx.GeckoSurface; Log.w(LOGTAG, "unable to configure " + name + ". Try next."); continue; } + mIsHardwareAccelerated = !name.startsWith("OMX.google."); mCodec = codec; mInputProcessor = new InputProcessor(); final boolean renderToSurface = surface != null; @@ -477,6 +479,11 @@ import org.mozilla.gecko.gfx.GeckoSurface; return mIsAdaptivePlaybackSupported; } + @Override + public synchronized boolean isHardwareAccelerated() { + return mIsHardwareAccelerated; + } + @Override public synchronized boolean isTunneledPlaybackSupported() { return mIsTunneledPlaybackSupported; diff --git a/mobile/android/geckoview/src/main/java/org/mozilla/gecko/media/CodecProxy.java b/mobile/android/geckoview/src/main/java/org/mozilla/gecko/media/CodecProxy.java index f5be498c8149..173862fee3ed 100644 --- a/mobile/android/geckoview/src/main/java/org/mozilla/gecko/media/CodecProxy.java +++ b/mobile/android/geckoview/src/main/java/org/mozilla/gecko/media/CodecProxy.java @@ -191,6 +191,21 @@ public final class CodecProxy { } } + @WrapForJNI + public synchronized boolean isHardwareAccelerated() + { + if (mRemote == null) { + Log.e(LOGTAG, "cannot check isHardwareAccelerated with an ended codec"); + return false; + } + try { + return mRemote.isHardwareAccelerated(); + } catch (RemoteException e) { + e.printStackTrace(); + return false; + } + } + @WrapForJNI public synchronized boolean isTunneledPlaybackSupported() {