Commit 81a290f1 by sofijajvc Committed by Andrew Lewis

Add internal method for format support

PiperOrigin-RevId: 263312721
parent b77b9f5c
......@@ -204,15 +204,20 @@ public class LibvpxVideoRenderer extends SimpleDecoderVideoRenderer {
}
@Override
public int supportsFormat(Format format) {
protected int supportsFormatInternal(
@Nullable DrmSessionManager<ExoMediaCrypto> drmSessionManager, Format format) {
if (!VpxLibrary.isAvailable() || !MimeTypes.VIDEO_VP9.equalsIgnoreCase(format.sampleMimeType)) {
return FORMAT_UNSUPPORTED_TYPE;
}
if (format.drmInitData == null
|| VpxLibrary.matchesExpectedExoMediaCryptoType(format.exoMediaCryptoType)) {
return FORMAT_HANDLED | ADAPTIVE_SEAMLESS;
boolean drmIsSupported =
format.drmInitData == null
|| VpxLibrary.matchesExpectedExoMediaCryptoType(format.exoMediaCryptoType)
|| (format.exoMediaCryptoType == null
&& supportsFormatDrm(drmSessionManager, format.drmInitData));
if (!drmIsSupported) {
return FORMAT_UNSUPPORTED_DRM;
}
return super.supportsFormat(format);
return FORMAT_HANDLED | ADAPTIVE_SEAMLESS;
}
@Override
......
......@@ -27,6 +27,7 @@ import com.google.android.exoplayer2.C;
import com.google.android.exoplayer2.ExoPlaybackException;
import com.google.android.exoplayer2.Format;
import com.google.android.exoplayer2.FormatHolder;
import com.google.android.exoplayer2.RendererCapabilities;
import com.google.android.exoplayer2.decoder.DecoderCounters;
import com.google.android.exoplayer2.decoder.DecoderInputBuffer;
import com.google.android.exoplayer2.decoder.SimpleDecoder;
......@@ -155,15 +156,8 @@ public abstract class SimpleDecoderVideoRenderer extends BaseRenderer {
// BaseRenderer implementation.
@Override
public int supportsFormat(Format format) {
boolean drmIsSupported =
format.drmInitData == null
|| (format.exoMediaCryptoType == null
&& supportsFormatDrm(drmSessionManager, format.drmInitData));
if (!drmIsSupported) {
return FORMAT_UNSUPPORTED_DRM;
}
return FORMAT_HANDLED | ADAPTIVE_SEAMLESS;
public final int supportsFormat(Format format) {
return supportsFormatInternal(drmSessionManager, format);
}
@Override
......@@ -527,6 +521,17 @@ public abstract class SimpleDecoderVideoRenderer extends BaseRenderer {
}
/**
* Returns the extent to which the subclass supports a given format.
*
* @param drmSessionManager The renderer's {@link DrmSessionManager}.
* @param format The format, which has a video {@link Format#sampleMimeType}.
* @return The extent to which the subclass supports the format itself.
* @see RendererCapabilities#supportsFormat(Format)
*/
protected abstract int supportsFormatInternal(
@Nullable DrmSessionManager<ExoMediaCrypto> drmSessionManager, Format format);
/**
* Creates a decoder for the given format.
*
* @param format The format for which a decoder is required.
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or sign in to comment