Bug 1322650 - Make video decoding work with new SurfaceTexture API r=jolin

This commit is contained in:
James Willcox 2017-03-03 15:16:28 -06:00
Родитель 77f7d855c8
Коммит b69402b0ba
7 изменённых файлов: 29 добавлений и 24 удалений

Просмотреть файл

@ -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<layers::Image> img = new SurfaceTextureImage(
mDecoder->mSurfaceTexture.get(), inputInfo.mImageSize,
mDecoder->mSurfaceHandle, inputInfo.mImageSize,
gl::OriginPos::BottomLeft);
RefPtr<VideoData> v = VideoData::CreateFromImage(
@ -177,18 +176,12 @@ public:
RefPtr<InitPromise> 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__);
GeckoSurface::LocalRef surf = GeckoSurface::LocalRef(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 = surf->GetHandle();
// Register native methods.
JavaCallbacksSupport::Init();
@ -199,7 +192,7 @@ public:
mJavaDecoder = CodecProxy::Create(false, // false indicates to create a decoder and true denotes encoder
mFormat,
mSurfaceTexture->JavaSurface(),
surf,
mJavaCallbacks,
mDrmStubId);
if (mJavaDecoder == nullptr) {
@ -239,7 +232,7 @@ public:
private:
layers::ImageContainer* mImageContainer;
const VideoInfo mConfig;
RefPtr<AndroidSurfaceTexture> mSurfaceTexture;
AndroidSurfaceTextureHandle mSurfaceHandle;
SimpleMap<InputInfo> mInputInfos;
bool mIsCodecSupportAdaptivePlayback = false;
};
@ -411,7 +404,6 @@ RemoteDataDecoder::CreateVideoDecoder(const CreateDecoderParams& aParams,
const nsString& aDrmStubId,
CDMProxy* aProxy)
{
const VideoInfo& config = aParams.VideoConfig();
MediaFormat::LocalRef format;
NS_ENSURE_SUCCESS(

Просмотреть файл

@ -38,6 +38,14 @@
<application>
<!-- New child services must also be added to the Fennec AndroidManifest.xml.in -->
<service
android:name="org.mozilla.gecko.media.MediaManager"
android:enabled="true"
android:exported="false"
android:process=":media"
android:isolatedProcess="false">
</service>
<service
android:name="org.mozilla.gecko.process.GeckoServiceChildProcess$geckomediaplugin"
android:enabled="true"

Просмотреть файл

@ -6,14 +6,14 @@ package org.mozilla.gecko.media;
// Non-default types used in interface.
import android.os.Bundle;
import android.view.Surface;
import org.mozilla.gecko.gfx.GeckoSurface;
import org.mozilla.gecko.media.FormatParam;
import org.mozilla.gecko.media.ICodecCallbacks;
import org.mozilla.gecko.media.Sample;
interface ICodec {
void setCallbacks(in ICodecCallbacks callbacks);
boolean configure(in FormatParam format, inout Surface surface, int flags, in String drmStubId);
boolean configure(in FormatParam format, in GeckoSurface surface, in int flags, in String drmStubId);
boolean isAdaptivePlaybackSupported();
void start();
void stop();

Просмотреть файл

@ -20,6 +20,8 @@ import java.util.LinkedList;
import java.util.Queue;
import java.util.concurrent.ConcurrentLinkedQueue;
import org.mozilla.gecko.gfx.GeckoSurface;
/* package */ final class Codec extends ICodec.Stub implements IBinder.DeathRecipient {
private static final String LOGTAG = "GeckoRemoteCodec";
private static final boolean DEBUG = false;
@ -348,7 +350,7 @@ import java.util.concurrent.ConcurrentLinkedQueue;
@Override
public synchronized boolean configure(FormatParam format,
Surface surface,
GeckoSurface surface,
int flags,
String drmStubId) throws RemoteException {
if (mCallbacks == null) {

Просмотреть файл

@ -14,6 +14,7 @@ import android.util.Log;
import android.view.Surface;
import org.mozilla.gecko.annotation.WrapForJNI;
import org.mozilla.gecko.gfx.GeckoSurface;
import org.mozilla.gecko.mozglue.JNIObject;
import java.io.IOException;
@ -29,7 +30,7 @@ public final class CodecProxy {
private ICodec mRemote;
private boolean mIsEncoder;
private FormatParam mFormat;
private Surface mOutputSurface;
private GeckoSurface mOutputSurface;
private CallbacksForwarder mCallbacks;
private String mRemoteDrmStubId;
private Queue<Sample> mSurfaceOutputs = new ConcurrentLinkedQueue<>();
@ -125,7 +126,7 @@ public final class CodecProxy {
@WrapForJNI
public static CodecProxy create(boolean isEncoder,
MediaFormat format,
Surface surface,
GeckoSurface surface,
Callbacks callbacks,
String drmStubId) {
return RemoteManager.getInstance().createCodec(isEncoder, format, surface, callbacks, drmStubId);
@ -133,13 +134,13 @@ public final class CodecProxy {
public static CodecProxy createCodecProxy(boolean isEncoder,
MediaFormat format,
Surface surface,
GeckoSurface surface,
Callbacks callbacks,
String drmStubId) {
return new CodecProxy(isEncoder, format, surface, callbacks, drmStubId);
}
private CodecProxy(boolean isEncoder, MediaFormat format, Surface surface, Callbacks callbacks, String drmStubId) {
private CodecProxy(boolean isEncoder, MediaFormat format, GeckoSurface surface, Callbacks callbacks, String drmStubId) {
mIsEncoder = isEncoder;
mFormat = new FormatParam(format);
mOutputSurface = surface;

Просмотреть файл

@ -20,6 +20,8 @@ import android.util.Log;
import java.util.LinkedList;
import java.util.List;
import org.mozilla.gecko.gfx.GeckoSurface;
public final class RemoteManager implements IBinder.DeathRecipient {
private static final String LOGTAG = "GeckoRemoteManager";
private static final boolean DEBUG = false;
@ -111,7 +113,7 @@ public final class RemoteManager implements IBinder.DeathRecipient {
public synchronized CodecProxy createCodec(boolean isEncoder,
MediaFormat format,
Surface surface,
GeckoSurface surface,
CodecProxy.Callbacks callbacks,
String drmStubId) {
if (mRemote == null) {

Просмотреть файл

@ -4944,7 +4944,7 @@ public:
mozilla::jni::String::Param> Args;
static constexpr char name[] = "create";
static constexpr char signature[] =
"(ZLandroid/media/MediaFormat;Landroid/view/Surface;Lorg/mozilla/gecko/media/CodecProxy$Callbacks;Ljava/lang/String;)Lorg/mozilla/gecko/media/CodecProxy;";
"(ZLandroid/media/MediaFormat;Lorg/mozilla/gecko/gfx/GeckoSurface;Lorg/mozilla/gecko/media/CodecProxy$Callbacks;Ljava/lang/String;)Lorg/mozilla/gecko/media/CodecProxy;";
static const bool isStatic = true;
static const mozilla::jni::ExceptionMode exceptionMode =
mozilla::jni::ExceptionMode::ABORT;