mirror of
https://github.com/samsonjs/media.git
synced 2026-04-23 14:15:48 +00:00
Add internal method for format support
PiperOrigin-RevId: 263312721
This commit is contained in:
parent
b77b9f5c02
commit
81a290f1ee
2 changed files with 24 additions and 14 deletions
|
|
@ -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
|
||||
|
|
@ -526,6 +520,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.
|
||||
*
|
||||
|
|
|
|||
Loading…
Reference in a new issue