android.media.MediaCrypto Java Examples
The following examples show how to use
android.media.MediaCrypto.
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: MediaCodecAudioRenderer.java From MediaSDK with Apache License 2.0 | 6 votes |
@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; } }
Example #2
Source File: MediaCodecBridge.java From android-chromium with BSD 2-Clause "Simplified" License | 6 votes |
@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; }
Example #3
Source File: MediaCodecAudioRenderer.java From TelePlus-Android with GNU General Public License v2.0 | 6 votes |
@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; } }
Example #4
Source File: MediaCodecBridge.java From android-chromium with BSD 2-Clause "Simplified" License | 6 votes |
@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; }
Example #5
Source File: MediaCodecVideoRenderer.java From Telegram with GNU General Public License v2.0 | 6 votes |
@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); } }
Example #6
Source File: MediaCodecAudioRenderer.java From Telegram with GNU General Public License v2.0 | 6 votes |
@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; } }
Example #7
Source File: MediaCodecAudioRenderer.java From Telegram-FOSS with GNU General Public License v2.0 | 6 votes |
@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; } }
Example #8
Source File: MediaCodecAudioRenderer.java From TelePlus-Android with GNU General Public License v2.0 | 6 votes |
@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; } }
Example #9
Source File: MediaCodecVideoRenderer.java From TelePlus-Android with GNU General Public License v2.0 | 5 votes |
@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); } }
Example #10
Source File: MediaCodecAudioRenderer.java From K-Sonic with MIT License | 5 votes |
@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; } }
Example #11
Source File: MediaCodecVideoRenderer.java From K-Sonic with MIT License | 5 votes |
@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); } }
Example #12
Source File: StreamingDrmSessionManager.java From Exoplayer_VLC with Apache License 2.0 | 5 votes |
@Override public MediaCrypto getMediaCrypto() { if (state != STATE_OPENED && state != STATE_OPENED_WITH_KEYS) { throw new IllegalStateException(); } return mediaCrypto; }
Example #13
Source File: MediaCodecVideoRenderer.java From TelePlus-Android with GNU General Public License v2.0 | 5 votes |
@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); } }
Example #14
Source File: MediaCodecRenderer.java From TelePlus-Android with GNU General Public License v2.0 | 5 votes |
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); }
Example #15
Source File: MediaCodecVideoRenderer.java From Telegram-FOSS with GNU General Public License v2.0 | 5 votes |
@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); } }
Example #16
Source File: FrameworkMediaDrm.java From TelePlus-Android with GNU General Public License v2.0 | 5 votes |
@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); }
Example #17
Source File: MediaCodecRenderer.java From TelePlus-Android with GNU General Public License v2.0 | 5 votes |
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); }
Example #18
Source File: MediaCodecBridge.java From android-chromium with BSD 2-Clause "Simplified" License | 5 votes |
@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; }
Example #19
Source File: FrameworkMediaDrm.java From TelePlus-Android with GNU General Public License v2.0 | 5 votes |
@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); }
Example #20
Source File: MediaCodecBridge.java From android-chromium with BSD 2-Clause "Simplified" License | 5 votes |
@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; }
Example #21
Source File: MediaCodecVideoRenderer.java From MediaSDK with Apache License 2.0 | 5 votes |
@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); } }
Example #22
Source File: MediaCodecRenderer.java From Telegram with GNU General Public License v2.0 | 4 votes |
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; 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); }
Example #23
Source File: FrameworkMediaDrm.java From K-Sonic with MIT License | 4 votes |
@Override public FrameworkMediaCrypto createMediaCrypto(UUID uuid, byte[] initData) throws MediaCryptoException { return new FrameworkMediaCrypto(new MediaCrypto(uuid, initData)); }
Example #24
Source File: MediaCodecRenderer.java From Telegram-FOSS with GNU General Public License v2.0 | 4 votes |
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; 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); }
Example #25
Source File: MediaCodecVideoTrackRenderer.java From Exoplayer_VLC with Apache License 2.0 | 4 votes |
@Override protected void configureCodec(MediaCodec codec, android.media.MediaFormat format, MediaCrypto crypto) { codec.configure(format, surface, crypto, 0); codec.setVideoScalingMode(videoScalingMode); }
Example #26
Source File: MediaDrmBridge.java From android-chromium with BSD 2-Clause "Simplified" License | 4 votes |
/** * Return the MediaCrypto object if available. */ @CalledByNative private MediaCrypto getMediaCrypto() { return mMediaCrypto; }
Example #27
Source File: MediaDrmBridge.java From 365browser with Apache License 2.0 | 4 votes |
private native void nativeOnMediaCryptoReady( long nativeMediaDrmBridge, MediaCrypto mediaCrypto);
Example #28
Source File: MediaDrmBridge.java From 365browser with Apache License 2.0 | 4 votes |
private void onMediaCryptoReady(MediaCrypto mediaCrypto) { if (isNativeMediaDrmBridgeValid()) { nativeOnMediaCryptoReady(mNativeMediaDrmBridge, mediaCrypto); } }
Example #29
Source File: MediaDrmBridge.java From android-chromium with BSD 2-Clause "Simplified" License | 4 votes |
/** * Return the MediaCrypto object if available. */ @CalledByNative private MediaCrypto getMediaCrypto() { return mMediaCrypto; }
Example #30
Source File: FrameworkMediaCrypto.java From K-Sonic with MIT License | 4 votes |
public MediaCrypto getWrappedMediaCrypto() { return mediaCrypto; }