Java Code Examples for com.google.android.exoplayer2.drm.DrmInitData#get()

The following examples show how to use com.google.android.exoplayer2.drm.DrmInitData#get() . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: MediaCodecVideoRenderer.java    From K-Sonic with MIT License 5 votes vote down vote up
@Override
protected int supportsFormat(MediaCodecSelector mediaCodecSelector, Format format)
    throws DecoderQueryException {
  String mimeType = format.sampleMimeType;
  if (!MimeTypes.isVideo(mimeType)) {
    return FORMAT_UNSUPPORTED_TYPE;
  }
  boolean requiresSecureDecryption = false;
  DrmInitData drmInitData = format.drmInitData;
  if (drmInitData != null) {
    for (int i = 0; i < drmInitData.schemeDataCount; i++) {
      requiresSecureDecryption |= drmInitData.get(i).requiresSecureDecryption;
    }
  }
  MediaCodecInfo decoderInfo = mediaCodecSelector.getDecoderInfo(mimeType,
      requiresSecureDecryption);
  if (decoderInfo == null) {
    return FORMAT_UNSUPPORTED_SUBTYPE;
  }

  boolean decoderCapable = decoderInfo.isCodecSupported(format.codecs);
  if (decoderCapable && format.width > 0 && format.height > 0) {
    if (Util.SDK_INT >= 21) {
      decoderCapable = decoderInfo.isVideoSizeAndRateSupportedV21(format.width, format.height,
          format.frameRate);
    } else {
      decoderCapable = format.width * format.height <= MediaCodecUtil.maxH264DecodableFrameSize();
      if (!decoderCapable) {
        Log.d(TAG, "FalseCheck [legacyFrameSize, " + format.width + "x" + format.height + "] ["
            + Util.DEVICE_DEBUG_INFO + "]");
      }
    }
  }

  int adaptiveSupport = decoderInfo.adaptive ? ADAPTIVE_SEAMLESS : ADAPTIVE_NOT_SEAMLESS;
  int tunnelingSupport = decoderInfo.tunneling ? TUNNELING_SUPPORTED : TUNNELING_NOT_SUPPORTED;
  int formatSupport = decoderCapable ? FORMAT_HANDLED : FORMAT_EXCEEDS_CAPABILITIES;
  return adaptiveSupport | tunnelingSupport | formatSupport;
}
 
Example 2
Source File: MediaCodecVideoRenderer.java    From TelePlus-Android with GNU General Public License v2.0 4 votes vote down vote up
@Override
protected int supportsFormat(MediaCodecSelector mediaCodecSelector,
    DrmSessionManager<FrameworkMediaCrypto> drmSessionManager, Format format)
    throws DecoderQueryException {
  String mimeType = format.sampleMimeType;
  if (!MimeTypes.isVideo(mimeType)) {
    return FORMAT_UNSUPPORTED_TYPE;
  }
  boolean requiresSecureDecryption = false;
  DrmInitData drmInitData = format.drmInitData;
  if (drmInitData != null) {
    for (int i = 0; i < drmInitData.schemeDataCount; i++) {
      requiresSecureDecryption |= drmInitData.get(i).requiresSecureDecryption;
    }
  }
  List<MediaCodecInfo> decoderInfos =
      mediaCodecSelector.getDecoderInfos(format, requiresSecureDecryption);
  if (decoderInfos.isEmpty()) {
    return requiresSecureDecryption
            && !mediaCodecSelector
                .getDecoderInfos(format, /* requiresSecureDecoder= */ false)
                .isEmpty()
        ? FORMAT_UNSUPPORTED_DRM
        : FORMAT_UNSUPPORTED_SUBTYPE;
  }
  if (!supportsFormatDrm(drmSessionManager, drmInitData)) {
    return FORMAT_UNSUPPORTED_DRM;
  }
  // Check capabilities for the first decoder in the list, which takes priority.
  MediaCodecInfo decoderInfo = decoderInfos.get(0);
  boolean decoderCapable = decoderInfo.isCodecSupported(format.codecs);
  if (decoderCapable && format.width > 0 && format.height > 0) {
    if (Util.SDK_INT >= 21) {
      decoderCapable = decoderInfo.isVideoSizeAndRateSupportedV21(format.width, format.height,
          format.frameRate);
    } else {
      decoderCapable = format.width * format.height <= MediaCodecUtil.maxH264DecodableFrameSize();
      if (!decoderCapable) {
        Log.d(TAG, "FalseCheck [legacyFrameSize, " + format.width + "x" + format.height + "] ["
            + Util.DEVICE_DEBUG_INFO + "]");
      }
    }
  }

  int adaptiveSupport = decoderInfo.adaptive ? ADAPTIVE_SEAMLESS : ADAPTIVE_NOT_SEAMLESS;
  int tunnelingSupport = decoderInfo.tunneling ? TUNNELING_SUPPORTED : TUNNELING_NOT_SUPPORTED;
  int formatSupport = decoderCapable ? FORMAT_HANDLED : FORMAT_EXCEEDS_CAPABILITIES;
  return adaptiveSupport | tunnelingSupport | formatSupport;
}
 
Example 3
Source File: MediaCodecVideoRenderer.java    From TelePlus-Android with GNU General Public License v2.0 4 votes vote down vote up
@Override
protected int supportsFormat(MediaCodecSelector mediaCodecSelector,
    DrmSessionManager<FrameworkMediaCrypto> drmSessionManager, Format format)
    throws DecoderQueryException {
  String mimeType = format.sampleMimeType;
  if (!MimeTypes.isVideo(mimeType)) {
    return FORMAT_UNSUPPORTED_TYPE;
  }
  boolean requiresSecureDecryption = false;
  DrmInitData drmInitData = format.drmInitData;
  if (drmInitData != null) {
    for (int i = 0; i < drmInitData.schemeDataCount; i++) {
      requiresSecureDecryption |= drmInitData.get(i).requiresSecureDecryption;
    }
  }
  List<MediaCodecInfo> decoderInfos =
      mediaCodecSelector.getDecoderInfos(format, requiresSecureDecryption);
  if (decoderInfos.isEmpty()) {
    return requiresSecureDecryption
            && !mediaCodecSelector
                .getDecoderInfos(format, /* requiresSecureDecoder= */ false)
                .isEmpty()
        ? FORMAT_UNSUPPORTED_DRM
        : FORMAT_UNSUPPORTED_SUBTYPE;
  }
  if (!supportsFormatDrm(drmSessionManager, drmInitData)) {
    return FORMAT_UNSUPPORTED_DRM;
  }
  // Check capabilities for the first decoder in the list, which takes priority.
  MediaCodecInfo decoderInfo = decoderInfos.get(0);
  boolean decoderCapable = decoderInfo.isCodecSupported(format.codecs);
  if (decoderCapable && format.width > 0 && format.height > 0) {
    if (Util.SDK_INT >= 21) {
      decoderCapable = decoderInfo.isVideoSizeAndRateSupportedV21(format.width, format.height,
          format.frameRate);
    } else {
      decoderCapable = format.width * format.height <= MediaCodecUtil.maxH264DecodableFrameSize();
      if (!decoderCapable) {
        Log.d(TAG, "FalseCheck [legacyFrameSize, " + format.width + "x" + format.height + "] ["
            + Util.DEVICE_DEBUG_INFO + "]");
      }
    }
  }

  int adaptiveSupport = decoderInfo.adaptive ? ADAPTIVE_SEAMLESS : ADAPTIVE_NOT_SEAMLESS;
  int tunnelingSupport = decoderInfo.tunneling ? TUNNELING_SUPPORTED : TUNNELING_NOT_SUPPORTED;
  int formatSupport = decoderCapable ? FORMAT_HANDLED : FORMAT_EXCEEDS_CAPABILITIES;
  return adaptiveSupport | tunnelingSupport | formatSupport;
}
 
Example 4
Source File: LocalDrmSessionManager.java    From no-player with Apache License 2.0 4 votes vote down vote up
@Override
public boolean canAcquireSession(DrmInitData drmInitData) {
    DrmInitData.SchemeData schemeData = drmInitData.get(drmScheme);
    return schemeData != null;
}
 
Example 5
Source File: MediaCodecVideoRenderer.java    From Telegram-FOSS with GNU General Public License v2.0 4 votes vote down vote up
@Override
protected int supportsFormat(MediaCodecSelector mediaCodecSelector,
    DrmSessionManager<FrameworkMediaCrypto> drmSessionManager, Format format)
    throws DecoderQueryException {
  String mimeType = format.sampleMimeType;
  if (!MimeTypes.isVideo(mimeType)) {
    return FORMAT_UNSUPPORTED_TYPE;
  }
  boolean requiresSecureDecryption = false;
  DrmInitData drmInitData = format.drmInitData;
  if (drmInitData != null) {
    for (int i = 0; i < drmInitData.schemeDataCount; i++) {
      requiresSecureDecryption |= drmInitData.get(i).requiresSecureDecryption;
    }
  }
  List<MediaCodecInfo> decoderInfos =
      getDecoderInfos(mediaCodecSelector, format, requiresSecureDecryption);
  if (decoderInfos.isEmpty()) {
    return requiresSecureDecryption
            && !mediaCodecSelector
                .getDecoderInfos(
                    format.sampleMimeType,
                    /* requiresSecureDecoder= */ false,
                    /* requiresTunnelingDecoder= */ false)
                .isEmpty()
        ? FORMAT_UNSUPPORTED_DRM
        : FORMAT_UNSUPPORTED_SUBTYPE;
  }
  if (!supportsFormatDrm(drmSessionManager, drmInitData)) {
    return FORMAT_UNSUPPORTED_DRM;
  }
  // Check capabilities for the first decoder in the list, which takes priority.
  MediaCodecInfo decoderInfo = decoderInfos.get(0);
  boolean isFormatSupported = decoderInfo.isFormatSupported(format);
  int adaptiveSupport =
      decoderInfo.isSeamlessAdaptationSupported(format)
          ? ADAPTIVE_SEAMLESS
          : ADAPTIVE_NOT_SEAMLESS;
  int tunnelingSupport = TUNNELING_NOT_SUPPORTED;
  if (isFormatSupported) {
    List<MediaCodecInfo> tunnelingDecoderInfos =
        mediaCodecSelector.getDecoderInfos(
            format.sampleMimeType,
            requiresSecureDecryption,
            /* requiresTunnelingDecoder= */ true);
    if (!tunnelingDecoderInfos.isEmpty()) {
      MediaCodecInfo tunnelingDecoderInfo = tunnelingDecoderInfos.get(0);
      if (tunnelingDecoderInfo.isFormatSupported(format)
          && tunnelingDecoderInfo.isSeamlessAdaptationSupported(format)) {
        tunnelingSupport = TUNNELING_SUPPORTED;
      }
    }
  }
  int formatSupport = isFormatSupported ? FORMAT_HANDLED : FORMAT_EXCEEDS_CAPABILITIES;
  return adaptiveSupport | tunnelingSupport | formatSupport;
}
 
Example 6
Source File: MediaCodecVideoRenderer.java    From Telegram with GNU General Public License v2.0 4 votes vote down vote up
@Override
protected int supportsFormat(MediaCodecSelector mediaCodecSelector,
    DrmSessionManager<FrameworkMediaCrypto> drmSessionManager, Format format)
    throws DecoderQueryException {
  String mimeType = format.sampleMimeType;
  if (!MimeTypes.isVideo(mimeType)) {
    return FORMAT_UNSUPPORTED_TYPE;
  }
  boolean requiresSecureDecryption = false;
  DrmInitData drmInitData = format.drmInitData;
  if (drmInitData != null) {
    for (int i = 0; i < drmInitData.schemeDataCount; i++) {
      requiresSecureDecryption |= drmInitData.get(i).requiresSecureDecryption;
    }
  }
  List<MediaCodecInfo> decoderInfos =
      getDecoderInfos(mediaCodecSelector, format, requiresSecureDecryption);
  if (decoderInfos.isEmpty()) {
    return requiresSecureDecryption
            && !mediaCodecSelector
                .getDecoderInfos(
                    format.sampleMimeType,
                    /* requiresSecureDecoder= */ false,
                    /* requiresTunnelingDecoder= */ false)
                .isEmpty()
        ? FORMAT_UNSUPPORTED_DRM
        : FORMAT_UNSUPPORTED_SUBTYPE;
  }
  if (!supportsFormatDrm(drmSessionManager, drmInitData)) {
    return FORMAT_UNSUPPORTED_DRM;
  }
  // Check capabilities for the first decoder in the list, which takes priority.
  MediaCodecInfo decoderInfo = decoderInfos.get(0);
  boolean isFormatSupported = decoderInfo.isFormatSupported(format);
  int adaptiveSupport =
      decoderInfo.isSeamlessAdaptationSupported(format)
          ? ADAPTIVE_SEAMLESS
          : ADAPTIVE_NOT_SEAMLESS;
  int tunnelingSupport = TUNNELING_NOT_SUPPORTED;
  if (isFormatSupported) {
    List<MediaCodecInfo> tunnelingDecoderInfos =
        mediaCodecSelector.getDecoderInfos(
            format.sampleMimeType,
            requiresSecureDecryption,
            /* requiresTunnelingDecoder= */ true);
    if (!tunnelingDecoderInfos.isEmpty()) {
      MediaCodecInfo tunnelingDecoderInfo = tunnelingDecoderInfos.get(0);
      if (tunnelingDecoderInfo.isFormatSupported(format)
          && tunnelingDecoderInfo.isSeamlessAdaptationSupported(format)) {
        tunnelingSupport = TUNNELING_SUPPORTED;
      }
    }
  }
  int formatSupport = isFormatSupported ? FORMAT_HANDLED : FORMAT_EXCEEDS_CAPABILITIES;
  return adaptiveSupport | tunnelingSupport | formatSupport;
}