类android.media.MediaCrypto源码实例Demo

下面列出了怎么用android.media.MediaCrypto的API类实例代码及写法,或者点击链接到github查看源代码。

源代码1 项目: MediaSDK   文件: MediaCodecAudioRenderer.java
@Override
protected void configureCodec(
    MediaCodecInfo codecInfo,
    MediaCodec codec,
    Format format,
    @Nullable MediaCrypto crypto,
    float codecOperatingRate) {
  codecMaxInputSize = getCodecMaxInputSize(codecInfo, format, getStreamFormats());
  codecNeedsDiscardChannelsWorkaround = codecNeedsDiscardChannelsWorkaround(codecInfo.name);
  codecNeedsEosBufferTimestampWorkaround = codecNeedsEosBufferTimestampWorkaround(codecInfo.name);
  passthroughEnabled = codecInfo.passthrough;
  String codecMimeType = passthroughEnabled ? MimeTypes.AUDIO_RAW : codecInfo.codecMimeType;
  MediaFormat mediaFormat =
      getMediaFormat(format, codecMimeType, codecMaxInputSize, codecOperatingRate);
  codec.configure(mediaFormat, /* surface= */ null, crypto, /* flags= */ 0);
  if (passthroughEnabled) {
    // Store the input MIME type if we're using the passthrough codec.
    passthroughMediaFormat = mediaFormat;
    passthroughMediaFormat.setString(MediaFormat.KEY_MIME, format.sampleMimeType);
  } else {
    passthroughMediaFormat = null;
  }
}
 
@Override
protected void configureCodec(
    MediaCodecInfo codecInfo,
    MediaCodec codec,
    Format format,
    MediaCrypto crypto,
    float codecOperatingRate) {
  codecMaxInputSize = getCodecMaxInputSize(codecInfo, format, getStreamFormats());
  codecNeedsDiscardChannelsWorkaround = codecNeedsDiscardChannelsWorkaround(codecInfo.name);
  passthroughEnabled = codecInfo.passthrough;
  String codecMimeType = codecInfo.mimeType == null ? MimeTypes.AUDIO_RAW : codecInfo.mimeType;
  MediaFormat mediaFormat =
      getMediaFormat(format, codecMimeType, codecMaxInputSize, codecOperatingRate);
  codec.configure(mediaFormat, /* surface= */ null, crypto, /* flags= */ 0);
  if (passthroughEnabled) {
    // Store the input MIME type if we're using the passthrough codec.
    passthroughMediaFormat = mediaFormat;
    passthroughMediaFormat.setString(MediaFormat.KEY_MIME, format.sampleMimeType);
  } else {
    passthroughMediaFormat = null;
  }
}
 
@Override
protected void configureCodec(
    MediaCodecInfo codecInfo,
    MediaCodec codec,
    Format format,
    MediaCrypto crypto,
    float codecOperatingRate) {
  codecMaxInputSize = getCodecMaxInputSize(codecInfo, format, getStreamFormats());
  codecNeedsDiscardChannelsWorkaround = codecNeedsDiscardChannelsWorkaround(codecInfo.name);
  passthroughEnabled = codecInfo.passthrough;
  String codecMimeType = codecInfo.mimeType == null ? MimeTypes.AUDIO_RAW : codecInfo.mimeType;
  MediaFormat mediaFormat =
      getMediaFormat(format, codecMimeType, codecMaxInputSize, codecOperatingRate);
  codec.configure(mediaFormat, /* surface= */ null, crypto, /* flags= */ 0);
  if (passthroughEnabled) {
    // Store the input MIME type if we're using the passthrough codec.
    passthroughMediaFormat = mediaFormat;
    passthroughMediaFormat.setString(MediaFormat.KEY_MIME, format.sampleMimeType);
  } else {
    passthroughMediaFormat = null;
  }
}
 
源代码4 项目: Telegram-FOSS   文件: MediaCodecAudioRenderer.java
@Override
protected void configureCodec(
    MediaCodecInfo codecInfo,
    MediaCodec codec,
    Format format,
    MediaCrypto crypto,
    float codecOperatingRate) {
  codecMaxInputSize = getCodecMaxInputSize(codecInfo, format, getStreamFormats());
  codecNeedsDiscardChannelsWorkaround = codecNeedsDiscardChannelsWorkaround(codecInfo.name);
  codecNeedsEosBufferTimestampWorkaround = codecNeedsEosBufferTimestampWorkaround(codecInfo.name);
  passthroughEnabled = codecInfo.passthrough;
  String codecMimeType = passthroughEnabled ? MimeTypes.AUDIO_RAW : codecInfo.codecMimeType;
  MediaFormat mediaFormat =
      getMediaFormat(format, codecMimeType, codecMaxInputSize, codecOperatingRate);
  codec.configure(mediaFormat, /* surface= */ null, crypto, /* flags= */ 0);
  if (passthroughEnabled) {
    // Store the input MIME type if we're using the passthrough codec.
    passthroughMediaFormat = mediaFormat;
    passthroughMediaFormat.setString(MediaFormat.KEY_MIME, format.sampleMimeType);
  } else {
    passthroughMediaFormat = null;
  }
}
 
源代码5 项目: Telegram   文件: MediaCodecAudioRenderer.java
@Override
protected void configureCodec(
    MediaCodecInfo codecInfo,
    MediaCodec codec,
    Format format,
    MediaCrypto crypto,
    float codecOperatingRate) {
  codecMaxInputSize = getCodecMaxInputSize(codecInfo, format, getStreamFormats());
  codecNeedsDiscardChannelsWorkaround = codecNeedsDiscardChannelsWorkaround(codecInfo.name);
  codecNeedsEosBufferTimestampWorkaround = codecNeedsEosBufferTimestampWorkaround(codecInfo.name);
  passthroughEnabled = codecInfo.passthrough;
  String codecMimeType = passthroughEnabled ? MimeTypes.AUDIO_RAW : codecInfo.codecMimeType;
  MediaFormat mediaFormat =
      getMediaFormat(format, codecMimeType, codecMaxInputSize, codecOperatingRate);
  codec.configure(mediaFormat, /* surface= */ null, crypto, /* flags= */ 0);
  if (passthroughEnabled) {
    // Store the input MIME type if we're using the passthrough codec.
    passthroughMediaFormat = mediaFormat;
    passthroughMediaFormat.setString(MediaFormat.KEY_MIME, format.sampleMimeType);
  } else {
    passthroughMediaFormat = null;
  }
}
 
源代码6 项目: android-chromium   文件: MediaCodecBridge.java
@CalledByNative
private boolean configureAudio(MediaFormat format, MediaCrypto crypto, int flags,
        boolean playAudio) {
    try {
        mMediaCodec.configure(format, null, crypto, flags);
        if (playAudio) {
            int sampleRate = format.getInteger(MediaFormat.KEY_SAMPLE_RATE);
            int channelCount = format.getInteger(MediaFormat.KEY_CHANNEL_COUNT);
            int channelConfig = (channelCount == 1) ? AudioFormat.CHANNEL_OUT_MONO :
                    AudioFormat.CHANNEL_OUT_STEREO;
            // Using 16bit PCM for output. Keep this value in sync with
            // kBytesPerAudioOutputSample in media_codec_bridge.cc.
            int minBufferSize = AudioTrack.getMinBufferSize(sampleRate, channelConfig,
                    AudioFormat.ENCODING_PCM_16BIT);
            mAudioTrack = new AudioTrack(AudioManager.STREAM_MUSIC, sampleRate, channelConfig,
                    AudioFormat.ENCODING_PCM_16BIT, minBufferSize, AudioTrack.MODE_STREAM);
        }
        return true;
    } catch (IllegalStateException e) {
        Log.e(TAG, "Cannot configure the audio codec " + e.toString());
    }
    return false;
}
 
源代码7 项目: android-chromium   文件: MediaCodecBridge.java
@CalledByNative
private boolean configureAudio(MediaFormat format, MediaCrypto crypto, int flags,
        boolean playAudio) {
    try {
        mMediaCodec.configure(format, null, crypto, flags);
        if (playAudio) {
            int sampleRate = format.getInteger(MediaFormat.KEY_SAMPLE_RATE);
            int channelCount = format.getInteger(MediaFormat.KEY_CHANNEL_COUNT);
            int channelConfig = (channelCount == 1) ? AudioFormat.CHANNEL_OUT_MONO :
                    AudioFormat.CHANNEL_OUT_STEREO;
            // Using 16bit PCM for output. Keep this value in sync with
            // kBytesPerAudioOutputSample in media_codec_bridge.cc.
            int minBufferSize = AudioTrack.getMinBufferSize(sampleRate, channelConfig,
                    AudioFormat.ENCODING_PCM_16BIT);
            mAudioTrack = new AudioTrack(AudioManager.STREAM_MUSIC, sampleRate, channelConfig,
                    AudioFormat.ENCODING_PCM_16BIT, minBufferSize, AudioTrack.MODE_STREAM);
        }
        return true;
    } catch (IllegalStateException e) {
        Log.e(TAG, "Cannot configure the audio codec " + e.toString());
    }
    return false;
}
 
源代码8 项目: MediaSDK   文件: MediaCodecVideoRenderer.java
@Override
protected void configureCodec(
    MediaCodecInfo codecInfo,
    MediaCodec codec,
    Format format,
    @Nullable MediaCrypto crypto,
    float codecOperatingRate) {
  String codecMimeType = codecInfo.codecMimeType;
  codecMaxValues = getCodecMaxValues(codecInfo, format, getStreamFormats());
  MediaFormat mediaFormat =
      getMediaFormat(
          format,
          codecMimeType,
          codecMaxValues,
          codecOperatingRate,
          deviceNeedsNoPostProcessWorkaround,
          tunnelingAudioSessionId);
  if (surface == null) {
    Assertions.checkState(shouldUseDummySurface(codecInfo));
    if (dummySurface == null) {
      dummySurface = DummySurface.newInstanceV17(context, codecInfo.secure);
    }
    surface = dummySurface;
  }
  codec.configure(mediaFormat, surface, crypto, 0);
  if (Util.SDK_INT >= 23 && tunneling) {
    tunnelingOnFrameRenderedListener = new OnFrameRenderedListenerV23(codec);
  }
}
 
源代码9 项目: TelePlus-Android   文件: FrameworkMediaDrm.java
@Override
public FrameworkMediaCrypto createMediaCrypto(byte[] initData) throws MediaCryptoException {
  // Work around a bug prior to Lollipop where L1 Widevine forced into L3 mode would still
  // indicate that it required secure video decoders [Internal ref: b/11428937].
  boolean forceAllowInsecureDecoderComponents = Util.SDK_INT < 21
      && C.WIDEVINE_UUID.equals(uuid) && "L3".equals(getPropertyString("securityLevel"));
  return new FrameworkMediaCrypto(new MediaCrypto(uuid, initData),
      forceAllowInsecureDecoderComponents);
}
 
源代码10 项目: TelePlus-Android   文件: MediaCodecRenderer.java
private void initCodec(MediaCodecInfo codecInfo, MediaCrypto crypto) throws Exception {
  long codecInitializingTimestamp;
  long codecInitializedTimestamp;
  MediaCodec codec = null;
  String name = codecInfo.name;
  updateCodecOperatingRate();
  boolean configureWithOperatingRate = codecOperatingRate > assumedMinimumCodecOperatingRate;
  try {
    codecInitializingTimestamp = SystemClock.elapsedRealtime();
    TraceUtil.beginSection("createCodec:" + name);
    codec = MediaCodec.createByCodecName(name);
    TraceUtil.endSection();
    TraceUtil.beginSection("configureCodec");
    configureCodec(
        codecInfo,
        codec,
        format,
        crypto,
        configureWithOperatingRate ? codecOperatingRate : CODEC_OPERATING_RATE_UNSET);
    codecConfiguredWithOperatingRate = configureWithOperatingRate;
    TraceUtil.endSection();
    TraceUtil.beginSection("startCodec");
    codec.start();
    TraceUtil.endSection();
    codecInitializedTimestamp = SystemClock.elapsedRealtime();
    getCodecBuffers(codec);
  } catch (Exception e) {
    if (codec != null) {
      resetCodecBuffers();
      codec.release();
    }
    throw e;
  }
  this.codec = codec;
  this.codecInfo = codecInfo;
  long elapsed = codecInitializedTimestamp - codecInitializingTimestamp;
  onCodecInitialized(name, codecInitializedTimestamp, elapsed);
}
 
源代码11 项目: TelePlus-Android   文件: MediaCodecVideoRenderer.java
@Override
protected void configureCodec(
    MediaCodecInfo codecInfo,
    MediaCodec codec,
    Format format,
    MediaCrypto crypto,
    float codecOperatingRate)
    throws DecoderQueryException {
  codecMaxValues = getCodecMaxValues(codecInfo, format, getStreamFormats());
  MediaFormat mediaFormat =
      getMediaFormat(
          format,
          codecMaxValues,
          codecOperatingRate,
          deviceNeedsAutoFrcWorkaround,
          tunnelingAudioSessionId);
  if (surface == null) {
    Assertions.checkState(shouldUseDummySurface(codecInfo));
    if (dummySurface == null) {
      dummySurface = DummySurface.newInstanceV17(context, codecInfo.secure);
    }
    surface = dummySurface;
  }
  codec.configure(mediaFormat, surface, crypto, 0);
  if (Util.SDK_INT >= 23 && tunneling) {
    tunnelingOnFrameRenderedListener = new OnFrameRenderedListenerV23(codec);
  }
}
 
源代码12 项目: TelePlus-Android   文件: FrameworkMediaDrm.java
@Override
public FrameworkMediaCrypto createMediaCrypto(byte[] initData) throws MediaCryptoException {
  // Work around a bug prior to Lollipop where L1 Widevine forced into L3 mode would still
  // indicate that it required secure video decoders [Internal ref: b/11428937].
  boolean forceAllowInsecureDecoderComponents = Util.SDK_INT < 21
      && C.WIDEVINE_UUID.equals(uuid) && "L3".equals(getPropertyString("securityLevel"));
  return new FrameworkMediaCrypto(new MediaCrypto(uuid, initData),
      forceAllowInsecureDecoderComponents);
}
 
源代码13 项目: TelePlus-Android   文件: MediaCodecRenderer.java
private void initCodec(MediaCodecInfo codecInfo, MediaCrypto crypto) throws Exception {
  long codecInitializingTimestamp;
  long codecInitializedTimestamp;
  MediaCodec codec = null;
  String name = codecInfo.name;
  updateCodecOperatingRate();
  boolean configureWithOperatingRate = codecOperatingRate > assumedMinimumCodecOperatingRate;
  try {
    codecInitializingTimestamp = SystemClock.elapsedRealtime();
    TraceUtil.beginSection("createCodec:" + name);
    codec = MediaCodec.createByCodecName(name);
    TraceUtil.endSection();
    TraceUtil.beginSection("configureCodec");
    configureCodec(
        codecInfo,
        codec,
        format,
        crypto,
        configureWithOperatingRate ? codecOperatingRate : CODEC_OPERATING_RATE_UNSET);
    codecConfiguredWithOperatingRate = configureWithOperatingRate;
    TraceUtil.endSection();
    TraceUtil.beginSection("startCodec");
    codec.start();
    TraceUtil.endSection();
    codecInitializedTimestamp = SystemClock.elapsedRealtime();
    getCodecBuffers(codec);
  } catch (Exception e) {
    if (codec != null) {
      resetCodecBuffers();
      codec.release();
    }
    throw e;
  }
  this.codec = codec;
  this.codecInfo = codecInfo;
  long elapsed = codecInitializedTimestamp - codecInitializingTimestamp;
  onCodecInitialized(name, codecInitializedTimestamp, elapsed);
}
 
源代码14 项目: TelePlus-Android   文件: MediaCodecVideoRenderer.java
@Override
protected void configureCodec(
    MediaCodecInfo codecInfo,
    MediaCodec codec,
    Format format,
    MediaCrypto crypto,
    float codecOperatingRate)
    throws DecoderQueryException {
  codecMaxValues = getCodecMaxValues(codecInfo, format, getStreamFormats());
  MediaFormat mediaFormat =
      getMediaFormat(
          format,
          codecMaxValues,
          codecOperatingRate,
          deviceNeedsAutoFrcWorkaround,
          tunnelingAudioSessionId);
  if (surface == null) {
    Assertions.checkState(shouldUseDummySurface(codecInfo));
    if (dummySurface == null) {
      dummySurface = DummySurface.newInstanceV17(context, codecInfo.secure);
    }
    surface = dummySurface;
  }
  codec.configure(mediaFormat, surface, crypto, 0);
  if (Util.SDK_INT >= 23 && tunneling) {
    tunnelingOnFrameRenderedListener = new OnFrameRenderedListenerV23(codec);
  }
}
 
源代码15 项目: K-Sonic   文件: MediaCodecAudioRenderer.java
@Override
protected void configureCodec(MediaCodecInfo codecInfo, MediaCodec codec, Format format,
    MediaCrypto crypto) {
  codecNeedsDiscardChannelsWorkaround = codecNeedsDiscardChannelsWorkaround(codecInfo.name);
  if (passthroughEnabled) {
    // Override the MIME type used to configure the codec if we are using a passthrough decoder.
    passthroughMediaFormat = format.getFrameworkMediaFormatV16();
    passthroughMediaFormat.setString(MediaFormat.KEY_MIME, MimeTypes.AUDIO_RAW);
    codec.configure(passthroughMediaFormat, null, crypto, 0);
    passthroughMediaFormat.setString(MediaFormat.KEY_MIME, format.sampleMimeType);
  } else {
    codec.configure(format.getFrameworkMediaFormatV16(), null, crypto, 0);
    passthroughMediaFormat = null;
  }
}
 
源代码16 项目: K-Sonic   文件: MediaCodecVideoRenderer.java
@Override
protected void configureCodec(MediaCodecInfo codecInfo, MediaCodec codec, Format format,
    MediaCrypto crypto) throws DecoderQueryException {
  codecMaxValues = getCodecMaxValues(codecInfo, format, streamFormats);
  MediaFormat mediaFormat = getMediaFormat(format, codecMaxValues, deviceNeedsAutoFrcWorkaround,
      tunnelingAudioSessionId);
  codec.configure(mediaFormat, surface, crypto, 0);
  if (Util.SDK_INT >= 23 && tunneling) {
    tunnelingOnFrameRenderedListener = new OnFrameRenderedListenerV23(codec);
  }
}
 
源代码17 项目: Exoplayer_VLC   文件: StreamingDrmSessionManager.java
@Override
public MediaCrypto getMediaCrypto() {
  if (state != STATE_OPENED && state != STATE_OPENED_WITH_KEYS) {
    throw new IllegalStateException();
  }
  return mediaCrypto;
}
 
源代码18 项目: Telegram-FOSS   文件: MediaCodecVideoRenderer.java
@Override
protected void configureCodec(
    MediaCodecInfo codecInfo,
    MediaCodec codec,
    Format format,
    MediaCrypto crypto,
    float codecOperatingRate) {
  String codecMimeType = codecInfo.codecMimeType;
  codecMaxValues = getCodecMaxValues(codecInfo, format, getStreamFormats());
  MediaFormat mediaFormat =
      getMediaFormat(
          format,
          codecMimeType,
          codecMaxValues,
          codecOperatingRate,
          deviceNeedsNoPostProcessWorkaround,
          tunnelingAudioSessionId);
  if (surface == null) {
    Assertions.checkState(shouldUseDummySurface(codecInfo));
    if (dummySurface == null) {
      dummySurface = DummySurface.newInstanceV17(context, codecInfo.secure);
    }
    surface = dummySurface;
  }
  codec.configure(mediaFormat, surface, crypto, 0);
  if (Util.SDK_INT >= 23 && tunneling) {
    tunnelingOnFrameRenderedListener = new OnFrameRenderedListenerV23(codec);
  }
}
 
源代码19 项目: Telegram   文件: MediaCodecVideoRenderer.java
@Override
protected void configureCodec(
    MediaCodecInfo codecInfo,
    MediaCodec codec,
    Format format,
    MediaCrypto crypto,
    float codecOperatingRate) {
  String codecMimeType = codecInfo.codecMimeType;
  codecMaxValues = getCodecMaxValues(codecInfo, format, getStreamFormats());
  MediaFormat mediaFormat =
      getMediaFormat(
          format,
          codecMimeType,
          codecMaxValues,
          codecOperatingRate,
          deviceNeedsNoPostProcessWorkaround,
          tunnelingAudioSessionId);
  if (surface == null) {
    Assertions.checkState(shouldUseDummySurface(codecInfo));
    if (dummySurface == null) {
      dummySurface = DummySurface.newInstanceV17(context, codecInfo.secure);
    }
    surface = dummySurface;
  }
  codec.configure(mediaFormat, surface, crypto, 0);
  if (Util.SDK_INT >= 23 && tunneling) {
    tunnelingOnFrameRenderedListener = new OnFrameRenderedListenerV23(codec);
  }
}
 
源代码20 项目: android-chromium   文件: MediaCodecBridge.java
@CalledByNative
private boolean configureVideo(MediaFormat format, Surface surface, MediaCrypto crypto,
        int flags) {
    try {
        mMediaCodec.configure(format, surface, crypto, flags);
        return true;
    } catch (IllegalStateException e) {
        Log.e(TAG, "Cannot configure the video codec " + e.toString());
    }
    return false;
}
 
源代码21 项目: android-chromium   文件: MediaCodecBridge.java
@CalledByNative
private boolean configureVideo(MediaFormat format, Surface surface, MediaCrypto crypto,
        int flags) {
    try {
        mMediaCodec.configure(format, surface, crypto, flags);
        return true;
    } catch (IllegalStateException e) {
        Log.e(TAG, "Cannot configure the video codec " + e.toString());
    }
    return false;
}
 
源代码22 项目: MediaSDK   文件: MediaCodecRenderer.java
private void initCodec(MediaCodecInfo codecInfo, MediaCrypto crypto) throws Exception {
  long codecInitializingTimestamp;
  long codecInitializedTimestamp;
  MediaCodec codec = null;
  String codecName = codecInfo.name;

  float codecOperatingRate =
      Util.SDK_INT < 23
          ? CODEC_OPERATING_RATE_UNSET
          : getCodecOperatingRateV23(rendererOperatingRate, inputFormat, getStreamFormats());
  if (codecOperatingRate <= assumedMinimumCodecOperatingRate) {
    codecOperatingRate = CODEC_OPERATING_RATE_UNSET;
  }
  try {
    codecInitializingTimestamp = SystemClock.elapsedRealtime();
    TraceUtil.beginSection("createCodec:" + codecName);
    codec = MediaCodec.createByCodecName(codecName);
    TraceUtil.endSection();
    TraceUtil.beginSection("configureCodec");
    configureCodec(codecInfo, codec, inputFormat, crypto, codecOperatingRate);
    TraceUtil.endSection();
    TraceUtil.beginSection("startCodec");
    codec.start();
    TraceUtil.endSection();
    codecInitializedTimestamp = SystemClock.elapsedRealtime();
    getCodecBuffers(codec);
  } catch (Exception e) {
    if (codec != null) {
      resetCodecBuffers();
      codec.release();
    }
    throw e;
  }

  this.codec = codec;
  this.codecInfo = codecInfo;
  this.codecOperatingRate = codecOperatingRate;
  codecFormat = inputFormat;
  codecAdaptationWorkaroundMode = codecAdaptationWorkaroundMode(codecName);
  codecNeedsReconfigureWorkaround = codecNeedsReconfigureWorkaround(codecName);
  codecNeedsDiscardToSpsWorkaround = codecNeedsDiscardToSpsWorkaround(codecName, codecFormat);
  codecNeedsFlushWorkaround = codecNeedsFlushWorkaround(codecName);
  codecNeedsEosFlushWorkaround = codecNeedsEosFlushWorkaround(codecName);
  codecNeedsEosOutputExceptionWorkaround = codecNeedsEosOutputExceptionWorkaround(codecName);
  codecNeedsMonoChannelCountWorkaround =
      codecNeedsMonoChannelCountWorkaround(codecName, codecFormat);
  codecNeedsEosPropagation =
      codecNeedsEosPropagationWorkaround(codecInfo) || getCodecNeedsEosPropagation();

  resetInputBuffer();
  resetOutputBuffer();
  codecHotswapDeadlineMs =
      getState() == STATE_STARTED
          ? (SystemClock.elapsedRealtime() + MAX_CODEC_HOTSWAP_TIME_MS)
          : C.TIME_UNSET;
  codecReconfigured = false;
  codecReconfigurationState = RECONFIGURATION_STATE_NONE;
  codecReceivedEos = false;
  codecReceivedBuffers = false;
  largestQueuedPresentationTimeUs = C.TIME_UNSET;
  lastBufferInStreamPresentationTimeUs = C.TIME_UNSET;
  codecDrainState = DRAIN_STATE_NONE;
  codecDrainAction = DRAIN_ACTION_NONE;
  codecNeedsAdaptationWorkaroundBuffer = false;
  shouldSkipAdaptationWorkaroundOutputBuffer = false;
  isDecodeOnlyOutputBuffer = false;
  isLastOutputBuffer = false;
  waitingForFirstSyncSample = true;

  decoderCounters.decoderInitCount++;
  long elapsed = codecInitializedTimestamp - codecInitializingTimestamp;
  onCodecInitialized(codecName, codecInitializedTimestamp, elapsed);
}
 
@Override
public void configure(MediaFormat format, Surface surface, MediaCrypto crypto, int flags) {
  mediaCodec.configure(format, surface, crypto, flags);
}
 
源代码24 项目: TelePlus-Android   文件: FrameworkMediaCrypto.java
/**
 * @param mediaCrypto The {@link MediaCrypto} to wrap.
 */
public FrameworkMediaCrypto(MediaCrypto mediaCrypto) {
  this(mediaCrypto, false);
}
 
源代码25 项目: TelePlus-Android   文件: FrameworkMediaCrypto.java
/**
 * Returns the wrapped {@link MediaCrypto}.
 */
public MediaCrypto getWrappedMediaCrypto() {
  return mediaCrypto;
}
 
源代码26 项目: TelePlus-Android   文件: MediaCodecRenderer.java
protected final void maybeInitCodec() throws ExoPlaybackException {
  if (codec != null || format == null) {
    // We have a codec already, or we don't have a format with which to instantiate one.
    return;
  }

  drmSession = pendingDrmSession;
  String mimeType = format.sampleMimeType;
  MediaCrypto wrappedMediaCrypto = null;
  boolean drmSessionRequiresSecureDecoder = false;
  if (drmSession != null) {
    FrameworkMediaCrypto mediaCrypto = drmSession.getMediaCrypto();
    if (mediaCrypto == null) {
      DrmSessionException drmError = drmSession.getError();
      if (drmError != null) {
        // Continue for now. We may be able to avoid failure if the session recovers, or if a new
        // input format causes the session to be replaced before it's used.
      } else {
        // The drm session isn't open yet.
        return;
      }
    } else {
      wrappedMediaCrypto = mediaCrypto.getWrappedMediaCrypto();
      drmSessionRequiresSecureDecoder = mediaCrypto.requiresSecureDecoderComponent(mimeType);
    }
    if (deviceNeedsDrmKeysToConfigureCodecWorkaround()) {
      @DrmSession.State int drmSessionState = drmSession.getState();
      if (drmSessionState == DrmSession.STATE_ERROR) {
        throw ExoPlaybackException.createForRenderer(drmSession.getError(), getIndex());
      } else if (drmSessionState != DrmSession.STATE_OPENED_WITH_KEYS) {
        // Wait for keys.
        return;
      }
    }
  }

  try {
    if (!initCodecWithFallback(wrappedMediaCrypto, drmSessionRequiresSecureDecoder)) {
      // We can't initialize a codec yet.
      return;
    }
  } catch (DecoderInitializationException e) {
    throw ExoPlaybackException.createForRenderer(e, getIndex());
  }

  String codecName = codecInfo.name;
  codecAdaptationWorkaroundMode = codecAdaptationWorkaroundMode(codecName);
  codecNeedsDiscardToSpsWorkaround = codecNeedsDiscardToSpsWorkaround(codecName, format);
  codecNeedsFlushWorkaround = codecNeedsFlushWorkaround(codecName);
  codecNeedsEosPropagationWorkaround = codecNeedsEosPropagationWorkaround(codecInfo);
  codecNeedsEosFlushWorkaround = codecNeedsEosFlushWorkaround(codecName);
  codecNeedsEosOutputExceptionWorkaround = codecNeedsEosOutputExceptionWorkaround(codecName);
  codecNeedsMonoChannelCountWorkaround = codecNeedsMonoChannelCountWorkaround(codecName, format);
  codecHotswapDeadlineMs =
      getState() == STATE_STARTED
          ? (SystemClock.elapsedRealtime() + MAX_CODEC_HOTSWAP_TIME_MS)
          : C.TIME_UNSET;
  resetInputBuffer();
  resetOutputBuffer();
  waitingForFirstSyncFrame = true;
  decoderCounters.decoderInitCount++;
}
 
源代码27 项目: TelePlus-Android   文件: FrameworkMediaCrypto.java
/**
 * @param mediaCrypto The {@link MediaCrypto} to wrap.
 */
public FrameworkMediaCrypto(MediaCrypto mediaCrypto) {
  this(mediaCrypto, false);
}
 
源代码28 项目: TelePlus-Android   文件: FrameworkMediaCrypto.java
/**
 * Returns the wrapped {@link MediaCrypto}.
 */
public MediaCrypto getWrappedMediaCrypto() {
  return mediaCrypto;
}
 
源代码29 项目: TelePlus-Android   文件: MediaCodecRenderer.java
protected final void maybeInitCodec() throws ExoPlaybackException {
  if (codec != null || format == null) {
    // We have a codec already, or we don't have a format with which to instantiate one.
    return;
  }

  drmSession = pendingDrmSession;
  String mimeType = format.sampleMimeType;
  MediaCrypto wrappedMediaCrypto = null;
  boolean drmSessionRequiresSecureDecoder = false;
  if (drmSession != null) {
    FrameworkMediaCrypto mediaCrypto = drmSession.getMediaCrypto();
    if (mediaCrypto == null) {
      DrmSessionException drmError = drmSession.getError();
      if (drmError != null) {
        // Continue for now. We may be able to avoid failure if the session recovers, or if a new
        // input format causes the session to be replaced before it's used.
      } else {
        // The drm session isn't open yet.
        return;
      }
    } else {
      wrappedMediaCrypto = mediaCrypto.getWrappedMediaCrypto();
      drmSessionRequiresSecureDecoder = mediaCrypto.requiresSecureDecoderComponent(mimeType);
    }
    if (deviceNeedsDrmKeysToConfigureCodecWorkaround()) {
      @DrmSession.State int drmSessionState = drmSession.getState();
      if (drmSessionState == DrmSession.STATE_ERROR) {
        throw ExoPlaybackException.createForRenderer(drmSession.getError(), getIndex());
      } else if (drmSessionState != DrmSession.STATE_OPENED_WITH_KEYS) {
        // Wait for keys.
        return;
      }
    }
  }

  try {
    if (!initCodecWithFallback(wrappedMediaCrypto, drmSessionRequiresSecureDecoder)) {
      // We can't initialize a codec yet.
      return;
    }
  } catch (DecoderInitializationException e) {
    throw ExoPlaybackException.createForRenderer(e, getIndex());
  }

  String codecName = codecInfo.name;
  codecAdaptationWorkaroundMode = codecAdaptationWorkaroundMode(codecName);
  codecNeedsDiscardToSpsWorkaround = codecNeedsDiscardToSpsWorkaround(codecName, format);
  codecNeedsFlushWorkaround = codecNeedsFlushWorkaround(codecName);
  codecNeedsEosPropagationWorkaround = codecNeedsEosPropagationWorkaround(codecInfo);
  codecNeedsEosFlushWorkaround = codecNeedsEosFlushWorkaround(codecName);
  codecNeedsEosOutputExceptionWorkaround = codecNeedsEosOutputExceptionWorkaround(codecName);
  codecNeedsMonoChannelCountWorkaround = codecNeedsMonoChannelCountWorkaround(codecName, format);
  codecHotswapDeadlineMs =
      getState() == STATE_STARTED
          ? (SystemClock.elapsedRealtime() + MAX_CODEC_HOTSWAP_TIME_MS)
          : C.TIME_UNSET;
  resetInputBuffer();
  resetOutputBuffer();
  waitingForFirstSyncFrame = true;
  decoderCounters.decoderInitCount++;
}
 
源代码30 项目: no-player   文件: FrameworkMediaCryptoFixture.java
public FrameworkMediaCryptoFixture withMediaCrypto(MediaCrypto mediaCrypto) {
    this.mediaCrypto = mediaCrypto;
    return this;
}
 
 类所在包
 同包方法