Java 类android.media.MediaCrypto 实例源码

项目:transistor    文件: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);
  if (surface == null) {
    Assertions.checkState(shouldUseDummySurface(codecInfo.secure));
    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);
  }
}
项目:android-chromium-view    文件: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;
}
项目: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;
}
项目:chromium_webview    文件: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 = getAudioFormat(channelCount);
            // 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);
            if (mAudioTrack.getState() == AudioTrack.STATE_UNINITIALIZED) {
                mAudioTrack = null;
                return false;
            }
        }
        return true;
    } catch (IllegalStateException e) {
        Log.e(TAG, "Cannot configure the audio codec", e);
    }
    return false;
}
项目:Telegram    文件: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);
  if (surface == null) {
    Assertions.checkState(shouldUseDummySurface(codecInfo.secure));
    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);
  }
}
项目:cordova-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;
}
项目:airgram    文件:StreamingDrmSessionManager.java   
@Override
public final MediaCrypto getMediaCrypto() {
  if (state != STATE_OPENED && state != STATE_OPENED_WITH_KEYS) {
    throw new IllegalStateException();
  }
  return mediaCrypto;
}
项目:Exoplayer2Radio    文件: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;
  }
}
项目:Exoplayer2Radio    文件: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);
  }
}
项目:GLMediaPlayer    文件:TextureVideoTrackRenderer.java   
@Override
protected void configureCodec(MediaCodec codec, String codecName, boolean codecIsAdaptive,
                              android.media.MediaFormat format, MediaCrypto crypto) {
    maybeSetMaxInputSize(format, codecIsAdaptive);
    codec.configure(format, surface, crypto, 0);
    codec.setVideoScalingMode(videoScalingMode);
}
项目:miku    文件:StreamingDrmSessionManager.java   
@Override
public final MediaCrypto getMediaCrypto() {
  if (state != STATE_OPENED && state != STATE_OPENED_WITH_KEYS) {
    throw new IllegalStateException();
  }
  return mediaCrypto;
}
项目: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;
  }
}
项目: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);
  }
}
项目:ExoPlayer-Demo    文件:StreamingDrmSessionManager.java   
@Override
public final MediaCrypto getMediaCrypto() {
  if (state != STATE_OPENED && state != STATE_OPENED_WITH_KEYS) {
    throw new IllegalStateException();
  }
  return mediaCrypto;
}
项目:videoPickPlayer    文件:MediaCodecAudioRenderer.java   
@Override
protected void configureCodec(MediaCodec codec, Format format, MediaCrypto crypto) {
  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;
  }
}
项目:android-exoplayer    文件:StreamingDrmSessionManager.java   
@Override
public MediaCrypto getMediaCrypto() {
  if (state != STATE_OPENED && state != STATE_OPENED_WITH_KEYS) {
    throw new IllegalStateException();
  }
  return mediaCrypto;
}
项目:transistor    文件:DebugRenderersFactory.java   
@Override
protected void configureCodec(MediaCodecInfo codecInfo, MediaCodec codec, Format format,
    MediaCrypto crypto) throws DecoderQueryException {
  // If the codec is being initialized whilst the renderer is started, default behavior is to
  // render the first frame (i.e. the keyframe before the current position), then drop frames up
  // to the current playback position. For test runs that place a maximum limit on the number of
  // dropped frames allowed, this is not desired behavior. Hence we skip (rather than drop)
  // frames up to the current playback position [Internal: b/66494991].
  skipToPositionBeforeRenderingFirstFrame = getState() == Renderer.STATE_STARTED;
  super.configureCodec(codecInfo, codec, format, crypto);
}
项目:transistor    文件: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);
}
项目:transistor    文件: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;
  }
}
项目:Exoplayer_VLC    文件:StreamingDrmSessionManager.java   
@Override
public MediaCrypto getMediaCrypto() {
  if (state != STATE_OPENED && state != STATE_OPENED_WITH_KEYS) {
    throw new IllegalStateException();
  }
  return mediaCrypto;
}
项目:edx-app-android    文件:StreamingDrmSessionManager.java   
@Override
public MediaCrypto getMediaCrypto() {
  if (state != STATE_OPENED && state != STATE_OPENED_WITH_KEYS) {
    throw new IllegalStateException();
  }
  return mediaCrypto;
}
项目:ExoPlayer    文件:StreamingDrmSessionManager.java   
@Override
public final MediaCrypto getMediaCrypto() {
  if (state != STATE_OPENED && state != STATE_OPENED_WITH_KEYS) {
    throw new IllegalStateException();
  }
  return mediaCrypto;
}
项目:android-chromium-view    文件: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;
}
项目: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;
}
项目:chromium_webview    文件: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);
    }
    return false;
}
项目:Telegram    文件:FrameworkMediaDrm.java   
@Override
public FrameworkMediaCrypto createMediaCrypto(UUID uuid, 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);
}
项目:Telegram    文件: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;
  }
}
项目:cordova-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;
}
项目:airgram    文件:MediaCodecVideoTrackRenderer.java   
@Override
protected void configureCodec(MediaCodec codec, boolean codecIsAdaptive,
    android.media.MediaFormat format, MediaCrypto crypto) {
  maybeSetMaxInputSize(format, codecIsAdaptive);
  codec.configure(format, surface, crypto, 0);
}
项目:PlusGram    文件:FrameworkMediaDrm.java   
@Override
public FrameworkMediaCrypto createMediaCrypto(UUID uuid, byte[] initData)
    throws MediaCryptoException {
  return new FrameworkMediaCrypto(new MediaCrypto(uuid, initData));
}
项目:PlusGram    文件:FrameworkMediaCrypto.java   
FrameworkMediaCrypto(MediaCrypto mediaCrypto) {
  this.mediaCrypto = Assertions.checkNotNull(mediaCrypto);
}
项目:PlusGram    文件:FrameworkMediaCrypto.java   
public MediaCrypto getWrappedMediaCrypto() {
  return mediaCrypto;
}
项目:PlusGram    文件:MediaCodecVideoTrackRenderer.java   
@Override
protected void configureCodec(MediaCodec codec, boolean codecIsAdaptive,
    android.media.MediaFormat format, MediaCrypto crypto) {
  maybeSetMaxInputSize(format, codecIsAdaptive);
  codec.configure(format, surface, crypto, 0);
}
项目:Exoplayer2Radio    文件:FrameworkMediaDrm.java   
@Override
public FrameworkMediaCrypto createMediaCrypto(UUID uuid, byte[] initData)
    throws MediaCryptoException {
  return new FrameworkMediaCrypto(new MediaCrypto(uuid, initData));
}
项目:Exoplayer2Radio    文件:FrameworkMediaCrypto.java   
FrameworkMediaCrypto(MediaCrypto mediaCrypto) {
  this.mediaCrypto = Assertions.checkNotNull(mediaCrypto);
}
项目:Exoplayer2Radio    文件:FrameworkMediaCrypto.java   
public MediaCrypto getWrappedMediaCrypto() {
  return mediaCrypto;
}
项目:no-player    文件:FrameworkMediaCryptoFixture.java   
public FrameworkMediaCryptoFixture withMediaCrypto(MediaCrypto mediaCrypto) {
    this.mediaCrypto = mediaCrypto;
    return this;
}
项目:miku    文件:MediaCodecVideoTrackRenderer.java   
@Override
protected void configureCodec(MediaCodec codec, String codecName,
    android.media.MediaFormat format, MediaCrypto crypto) {
  codec.configure(format, surface, crypto, 0);
  codec.setVideoScalingMode(videoScalingMode);
}
项目:K-Sonic    文件:FrameworkMediaDrm.java   
@Override
public FrameworkMediaCrypto createMediaCrypto(UUID uuid, byte[] initData)
    throws MediaCryptoException {
  return new FrameworkMediaCrypto(new MediaCrypto(uuid, initData));
}
项目:K-Sonic    文件:FrameworkMediaCrypto.java   
FrameworkMediaCrypto(MediaCrypto mediaCrypto) {
  this.mediaCrypto = Assertions.checkNotNull(mediaCrypto);
}