Bug 1403849 - p1: introduce IPC method to query tunneled playback support. r=esawin

MozReview-Commit-ID: 3wiKC46ZjvY

--HG--
extra : rebase_source : 8d87656737c5ace1bb47b968e9a1cc958616afa1
This commit is contained in:
John Lin 2017-09-29 18:01:15 +08:00
Родитель a981553464
Коммит 84b53d828f
5 изменённых файлов: 29 добавлений и 1 удалений

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

@ -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 isTunneledPlaybackSupported();
void start();
void stop();
void flush();

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

@ -26,6 +26,7 @@ public interface AsyncCodec {
public abstract void setCallbacks(Callbacks callbacks, Handler handler);
public abstract void configure(MediaFormat format, Surface surface, MediaCrypto crypto, int flags);
public abstract boolean isAdaptivePlaybackSupported(String mimeType);
public abstract boolean isTunneledPlaybackSupported(final String mimeType);
public abstract void start();
public abstract void stop();
public abstract void flush();

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

@ -348,8 +348,9 @@ import org.mozilla.gecko.gfx.GeckoSurface;
private InputProcessor mInputProcessor;
private OutputProcessor mOutputProcessor;
private SamplePool mSamplePool;
// Value will be updated after configure called.
// Values will be updated after configure called.
private volatile boolean mIsAdaptivePlaybackSupported = false;
private boolean mIsTunneledPlaybackSupported = false;
public synchronized void setCallbacks(ICodecCallbacks callbacks) throws RemoteException {
mCallbacks = callbacks;
@ -403,6 +404,9 @@ import org.mozilla.gecko.gfx.GeckoSurface;
final boolean renderToSurface = surface != null;
mOutputProcessor = new OutputProcessor(renderToSurface);
mSamplePool = new SamplePool(name, renderToSurface);
if (renderToSurface) {
mIsTunneledPlaybackSupported = mCodec.isTunneledPlaybackSupported(mime);
}
if (DEBUG) { Log.d(LOGTAG, codec.toString() + " created. Render to surface?" + renderToSurface); }
return true;
}
@ -473,6 +477,11 @@ import org.mozilla.gecko.gfx.GeckoSurface;
return mIsAdaptivePlaybackSupported;
}
@Override
public synchronized boolean isTunneledPlaybackSupported() {
return mIsTunneledPlaybackSupported;
}
@Override
public synchronized void start() throws RemoteException {
if (DEBUG) { Log.d(LOGTAG, "start " + this); }

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

@ -7,6 +7,7 @@ package org.mozilla.gecko.media;
import org.mozilla.gecko.util.HardwareCodecCapabilityUtils;
import android.media.MediaCodec;
import android.media.MediaCodecInfo.CodecCapabilities;
import android.media.MediaCrypto;
import android.media.MediaFormat;
import android.os.Handler;
@ -308,6 +309,14 @@ final class JellyBeanAsyncCodec implements AsyncCodec {
return HardwareCodecCapabilityUtils.checkSupportsAdaptivePlayback(mCodec, mimeType);
}
@Override
public boolean isTunneledPlaybackSupported(final String mimeType) {
return android.os.Build.VERSION.SDK_INT >= android.os.Build.VERSION_CODES.LOLLIPOP
&& mCodec.getCodecInfo()
.getCapabilitiesForType(mimeType)
.isFeatureSupported(CodecCapabilities.FEATURE_TunneledPlayback);
}
private void assertCallbacks() {
if (mCallbackSender == null) {
throw new IllegalStateException(LOGTAG + ": callback must be supplied with setCallbacks().");

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

@ -7,6 +7,7 @@ package org.mozilla.gecko.media;
import org.mozilla.gecko.util.HardwareCodecCapabilityUtils;
import android.media.MediaCodec;
import android.media.MediaCodecInfo.CodecCapabilities;
import android.media.MediaCrypto;
import android.media.MediaFormat;
import android.os.Bundle;
@ -151,6 +152,13 @@ import java.nio.ByteBuffer;
return HardwareCodecCapabilityUtils.checkSupportsAdaptivePlayback(mCodec, mimeType);
}
@Override
public boolean isTunneledPlaybackSupported(final String mimeType) {
return mCodec.getCodecInfo()
.getCapabilitiesForType(mimeType)
.isFeatureSupported(CodecCapabilities.FEATURE_TunneledPlayback);
}
@Override
public void start() {
mCodec.start();