com.google.android.exoplayer2.drm.DrmSession Java Examples
The following examples show how to use
com.google.android.exoplayer2.drm.DrmSession.
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: LocalDrmSessionManager.java From no-player with Apache License 2.0 | 6 votes |
@SuppressWarnings("PMD.AvoidCatchingGenericException") // We are forced to catch Exception as ResourceBusyException is minSdk 19 @TargetApi(Build.VERSION_CODES.JELLY_BEAN_MR2) @Override public DrmSession<FrameworkMediaCrypto> acquireSession(Looper playbackLooper, DrmInitData drmInitData) { DrmSession<FrameworkMediaCrypto> drmSession; try { SessionId sessionId = SessionId.of(mediaDrm.openSession()); FrameworkMediaCrypto mediaCrypto = mediaDrm.createMediaCrypto(sessionId.asBytes()); mediaDrm.restoreKeys(sessionId.asBytes(), keySetIdToRestore.asBytes()); drmSession = new LocalDrmSession(mediaCrypto, keySetIdToRestore, sessionId); } catch (Exception exception) { drmSession = new InvalidDrmSession(new DrmSession.DrmSessionException(exception)); notifyErrorListener(drmSession); } return drmSession; }
Example #2
Source File: LocalDrmSessionManagerTest.java From no-player with Apache License 2.0 | 5 votes |
@Test public void givenAcquiredSession_whenReleasingSession_thenClosesCurrentSession() { DrmSession<FrameworkMediaCrypto> drmSession = new LocalDrmSession(frameworkMediaCrypto, KEY_SET_ID_TO_RESTORE, SESSION_ID); localDrmSessionManager.releaseSession(drmSession); verify(mediaDrm).closeSession(SESSION_ID.asBytes()); }
Example #3
Source File: MediaCodecRenderer.java From TelePlus-Android with GNU General Public License v2.0 | 5 votes |
private boolean shouldWaitForKeys(boolean bufferEncrypted) throws ExoPlaybackException { if (drmSession == null || (!bufferEncrypted && playClearSamplesWithoutKeys)) { return false; } @DrmSession.State int drmSessionState = drmSession.getState(); if (drmSessionState == DrmSession.STATE_ERROR) { throw ExoPlaybackException.createForRenderer(drmSession.getError(), getIndex()); } return drmSessionState != DrmSession.STATE_OPENED_WITH_KEYS; }
Example #4
Source File: SimpleDecoderAudioRenderer.java From TelePlus-Android with GNU General Public License v2.0 | 5 votes |
private boolean shouldWaitForKeys(boolean bufferEncrypted) throws ExoPlaybackException { if (drmSession == null || (!bufferEncrypted && playClearSamplesWithoutKeys)) { return false; } @DrmSession.State int drmSessionState = drmSession.getState(); if (drmSessionState == DrmSession.STATE_ERROR) { throw ExoPlaybackException.createForRenderer(drmSession.getError(), getIndex()); } return drmSessionState != DrmSession.STATE_OPENED_WITH_KEYS; }
Example #5
Source File: SoftVideoRenderer.java From DanDanPlayForAndroid with MIT License | 5 votes |
private boolean shouldWaitForKeys(boolean bufferEncrypted) throws ExoPlaybackException { if (drmSession == null || (!bufferEncrypted && playClearSamplesWithoutKeys)) { return false; } @DrmSession.State int drmSessionState = drmSession.getState(); if (drmSessionState == DrmSession.STATE_ERROR) { throw ExoPlaybackException.createForRenderer(drmSession.getError(), getIndex()); } return drmSessionState != DrmSession.STATE_OPENED_WITH_KEYS; }
Example #6
Source File: LocalDrmSessionManager.java From no-player with Apache License 2.0 | 5 votes |
private void notifyErrorListener(DrmSession<FrameworkMediaCrypto> drmSession) { final DrmSession.DrmSessionException error = drmSession.getError(); handler.post(new Runnable() { @Override public void run() { eventListener.onDrmSessionManagerError(error); } }); }
Example #7
Source File: BaseRenderer.java From MediaSDK with Apache License 2.0 | 5 votes |
/** Returns a {@link DrmSession} ready for assignment, handling resource management. */ @Nullable protected final <T extends ExoMediaCrypto> DrmSession<T> getUpdatedSourceDrmSession( @Nullable Format oldFormat, Format newFormat, @Nullable DrmSessionManager<T> drmSessionManager, @Nullable DrmSession<T> existingSourceSession) throws ExoPlaybackException { boolean drmInitDataChanged = !Util.areEqual(newFormat.drmInitData, oldFormat == null ? null : oldFormat.drmInitData); if (!drmInitDataChanged) { return existingSourceSession; } @Nullable DrmSession<T> newSourceDrmSession = null; if (newFormat.drmInitData != null) { if (drmSessionManager == null) { throw createRendererException( new IllegalStateException("Media requires a DrmSessionManager"), newFormat); } newSourceDrmSession = drmSessionManager.acquireSession( Assertions.checkNotNull(Looper.myLooper()), newFormat.drmInitData); } if (existingSourceSession != null) { existingSourceSession.release(); } return newSourceDrmSession; }
Example #8
Source File: LocalDrmSessionManagerTest.java From no-player with Apache License 2.0 | 5 votes |
@Test public void givenValidMediaDrm_whenAcquiringSession_thenReturnsLocalDrmSession() throws MediaCryptoException { given(mediaDrm.createMediaCrypto(SESSION_ID.asBytes())).willReturn(frameworkMediaCrypto); DrmSession<FrameworkMediaCrypto> drmSession = localDrmSessionManager.acquireSession(IGNORED_LOOPER, IGNORED_DRM_DATA); LocalDrmSession localDrmSession = new LocalDrmSession(frameworkMediaCrypto, KEY_SET_ID_TO_RESTORE, SESSION_ID); assertThat(drmSession).isEqualTo(localDrmSession); }
Example #9
Source File: LocalDrmSessionManagerTest.java From no-player with Apache License 2.0 | 5 votes |
@RequiresApi(api = Build.VERSION_CODES.KITKAT) @Test public void givenOpeningSessionError_whenAcquiringSession_thenNotifiesErrorEventListenerOnHandler() throws MediaDrmException { given(mediaDrm.openSession()).willThrow(new ResourceBusyException("resource is busy")); localDrmSessionManager.acquireSession(IGNORED_LOOPER, IGNORED_DRM_DATA); ArgumentCaptor<Runnable> argumentCaptor = ArgumentCaptor.forClass(Runnable.class); verify(handler).post(argumentCaptor.capture()); argumentCaptor.getValue().run(); verify(eventListener).onDrmSessionManagerError(any(DrmSession.DrmSessionException.class)); }
Example #10
Source File: LocalDrmSessionManagerTest.java From no-player with Apache License 2.0 | 5 votes |
@RequiresApi(api = Build.VERSION_CODES.KITKAT) @Test public void givenOpeningSessionError_whenAcquiringSession_thenReturnsInvalidDrmSession() throws MediaDrmException { ResourceBusyException resourceBusyException = new ResourceBusyException("resource is busy"); given(mediaDrm.openSession()).willThrow(resourceBusyException); DrmSession<FrameworkMediaCrypto> drmSession = localDrmSessionManager.acquireSession(IGNORED_LOOPER, IGNORED_DRM_DATA); assertThat(drmSession).isInstanceOf(InvalidDrmSession.class); assertThat(drmSession.getError().getCause()).isEqualTo(resourceBusyException); }
Example #11
Source File: RendererErrorMapper.java From no-player with Apache License 2.0 | 5 votes |
@SuppressWarnings({"PMD.StdCyclomaticComplexity", "PMD.CyclomaticComplexity", "PMD.ModifiedCyclomaticComplexity", "PMD.NPathComplexity"}) static NoPlayer.PlayerError map(Exception rendererException, String message) { if (rendererException instanceof AudioSink.ConfigurationException) { return new NoPlayerError(PlayerErrorType.RENDERER_DECODER, DetailErrorType.AUDIO_SINK_CONFIGURATION_ERROR, message); } if (rendererException instanceof AudioSink.InitializationException) { return new NoPlayerError(PlayerErrorType.RENDERER_DECODER, DetailErrorType.AUDIO_SINK_INITIALISATION_ERROR, message); } if (rendererException instanceof AudioSink.WriteException) { return new NoPlayerError(PlayerErrorType.RENDERER_DECODER, DetailErrorType.AUDIO_SINK_WRITE_ERROR, message); } if (rendererException instanceof AudioProcessor.UnhandledFormatException) { return new NoPlayerError(PlayerErrorType.RENDERER_DECODER, DetailErrorType.AUDIO_UNHANDLED_FORMAT_ERROR, message); } if (rendererException instanceof AudioDecoderException) { return new NoPlayerError(PlayerErrorType.RENDERER_DECODER, DetailErrorType.AUDIO_DECODER_ERROR, message); } if (rendererException instanceof MediaCodecRenderer.DecoderInitializationException) { MediaCodecRenderer.DecoderInitializationException decoderInitializationException = (MediaCodecRenderer.DecoderInitializationException) rendererException; String fullMessage = "decoder-name:" + decoderInitializationException.decoderName + ", " + "mimetype:" + decoderInitializationException.mimeType + ", " + "secureCodeRequired:" + decoderInitializationException.secureDecoderRequired + ", " + "diagnosticInfo:" + decoderInitializationException.diagnosticInfo + ", " + "exceptionMessage:" + message; return new NoPlayerError(PlayerErrorType.RENDERER_DECODER, DetailErrorType.INITIALISATION_ERROR, fullMessage); } if (rendererException instanceof MediaCodecUtil.DecoderQueryException) { return new NoPlayerError(PlayerErrorType.DEVICE_MEDIA_CAPABILITIES, DetailErrorType.UNKNOWN, message); } if (rendererException instanceof SubtitleDecoderException) { return new NoPlayerError(PlayerErrorType.RENDERER_DECODER, DetailErrorType.DECODING_SUBTITLE_ERROR, message); } if (rendererException instanceof UnsupportedDrmException) { return mapUnsupportedDrmException((UnsupportedDrmException) rendererException, message); } if (rendererException instanceof DefaultDrmSessionManager.MissingSchemeDataException) { return new NoPlayerError(PlayerErrorType.DRM, DetailErrorType.CANNOT_ACQUIRE_DRM_SESSION_MISSING_SCHEME_FOR_REQUIRED_UUID_ERROR, message); } if (rendererException instanceof DrmSession.DrmSessionException) { return new NoPlayerError(PlayerErrorType.DRM, DetailErrorType.DRM_SESSION_ERROR, message); } if (rendererException instanceof KeysExpiredException) { return new NoPlayerError(PlayerErrorType.DRM, DetailErrorType.DRM_KEYS_EXPIRED_ERROR, message); } if (rendererException instanceof DecryptionException) { return new NoPlayerError(PlayerErrorType.CONTENT_DECRYPTION, DetailErrorType.FAIL_DECRYPT_DATA_DUE_NON_PLATFORM_COMPONENT_ERROR, message); } if (rendererException instanceof MediaCodec.CryptoException) { return mapCryptoException((MediaCodec.CryptoException) rendererException, message); } if (rendererException instanceof IllegalStateException) { return new NoPlayerError(PlayerErrorType.DRM, DetailErrorType.MEDIA_REQUIRES_DRM_SESSION_MANAGER_ERROR, message); } return new NoPlayerError(PlayerErrorType.UNKNOWN, DetailErrorType.UNKNOWN, message); }
Example #12
Source File: MediaCodecRenderer.java From K-Sonic with MIT License | 5 votes |
private boolean shouldWaitForKeys(boolean bufferEncrypted) throws ExoPlaybackException { if (drmSession == null) { return false; } @DrmSession.State int drmSessionState = drmSession.getState(); if (drmSessionState == DrmSession.STATE_ERROR) { throw ExoPlaybackException.createForRenderer(drmSession.getError(), getIndex()); } return drmSessionState != DrmSession.STATE_OPENED_WITH_KEYS && (bufferEncrypted || !playClearSamplesWithoutKeys); }
Example #13
Source File: SimpleDecoderAudioRenderer.java From K-Sonic with MIT License | 5 votes |
private boolean shouldWaitForKeys(boolean bufferEncrypted) throws ExoPlaybackException { if (drmSession == null) { return false; } @DrmSession.State int drmSessionState = drmSession.getState(); if (drmSessionState == DrmSession.STATE_ERROR) { throw ExoPlaybackException.createForRenderer(drmSession.getError(), getIndex()); } return drmSessionState != DrmSession.STATE_OPENED_WITH_KEYS && (bufferEncrypted || !playClearSamplesWithoutKeys); }
Example #14
Source File: SimpleDecoderAudioRenderer.java From K-Sonic with MIT License | 5 votes |
private void maybeInitDecoder() throws ExoPlaybackException { if (decoder != null) { return; } drmSession = pendingDrmSession; ExoMediaCrypto mediaCrypto = null; if (drmSession != null) { @DrmSession.State int drmSessionState = drmSession.getState(); if (drmSessionState == DrmSession.STATE_ERROR) { throw ExoPlaybackException.createForRenderer(drmSession.getError(), getIndex()); } else if (drmSessionState == DrmSession.STATE_OPENED || drmSessionState == DrmSession.STATE_OPENED_WITH_KEYS) { mediaCrypto = drmSession.getMediaCrypto(); } else { // The drm session isn't open yet. return; } } try { long codecInitializingTimestamp = SystemClock.elapsedRealtime(); TraceUtil.beginSection("createAudioDecoder"); decoder = createDecoder(inputFormat, mediaCrypto); TraceUtil.endSection(); long codecInitializedTimestamp = SystemClock.elapsedRealtime(); eventDispatcher.decoderInitialized(decoder.getName(), codecInitializedTimestamp, codecInitializedTimestamp - codecInitializingTimestamp); decoderCounters.decoderInitCount++; } catch (AudioDecoderException e) { throw ExoPlaybackException.createForRenderer(e, getIndex()); } }
Example #15
Source File: MediaCodecRenderer.java From Telegram-FOSS with GNU General Public License v2.0 | 5 votes |
private boolean shouldWaitForKeys(boolean bufferEncrypted) throws ExoPlaybackException { if (codecDrmSession == null || (!bufferEncrypted && playClearSamplesWithoutKeys)) { return false; } @DrmSession.State int drmSessionState = codecDrmSession.getState(); if (drmSessionState == DrmSession.STATE_ERROR) { throw ExoPlaybackException.createForRenderer(codecDrmSession.getError(), getIndex()); } return drmSessionState != DrmSession.STATE_OPENED_WITH_KEYS; }
Example #16
Source File: SimpleDecoderAudioRenderer.java From Telegram-FOSS with GNU General Public License v2.0 | 5 votes |
private boolean shouldWaitForKeys(boolean bufferEncrypted) throws ExoPlaybackException { if (decoderDrmSession == null || (!bufferEncrypted && playClearSamplesWithoutKeys)) { return false; } @DrmSession.State int drmSessionState = decoderDrmSession.getState(); if (drmSessionState == DrmSession.STATE_ERROR) { throw ExoPlaybackException.createForRenderer(decoderDrmSession.getError(), getIndex()); } return drmSessionState != DrmSession.STATE_OPENED_WITH_KEYS; }
Example #17
Source File: SimpleDecoderAudioRenderer.java From Telegram-FOSS with GNU General Public License v2.0 | 5 votes |
private void onInputFormatChanged(Format newFormat) throws ExoPlaybackException { Format oldFormat = inputFormat; inputFormat = newFormat; boolean drmInitDataChanged = !Util.areEqual(inputFormat.drmInitData, oldFormat == null ? null : oldFormat.drmInitData); if (drmInitDataChanged) { if (inputFormat.drmInitData != null) { if (drmSessionManager == null) { throw ExoPlaybackException.createForRenderer( new IllegalStateException("Media requires a DrmSessionManager"), getIndex()); } DrmSession<ExoMediaCrypto> session = drmSessionManager.acquireSession(Looper.myLooper(), newFormat.drmInitData); if (session == decoderDrmSession || session == sourceDrmSession) { // We already had this session. The manager must be reference counting, so release it once // to get the count attributed to this renderer back down to 1. drmSessionManager.releaseSession(session); } setSourceDrmSession(session); } else { setSourceDrmSession(null); } } if (decoderReceivedBuffers) { // Signal end of stream and wait for any final output buffers before re-initialization. decoderReinitializationState = REINITIALIZATION_STATE_SIGNAL_END_OF_STREAM; } else { // There aren't any final output buffers, so release the decoder immediately. releaseDecoder(); maybeInitDecoder(); audioTrackNeedsConfigure = true; } encoderDelay = newFormat.encoderDelay; encoderPadding = newFormat.encoderPadding; eventDispatcher.inputFormatChanged(newFormat); }
Example #18
Source File: MediaCodecRenderer.java From Telegram with GNU General Public License v2.0 | 5 votes |
private boolean shouldWaitForKeys(boolean bufferEncrypted) throws ExoPlaybackException { if (codecDrmSession == null || (!bufferEncrypted && playClearSamplesWithoutKeys)) { return false; } @DrmSession.State int drmSessionState = codecDrmSession.getState(); if (drmSessionState == DrmSession.STATE_ERROR) { throw ExoPlaybackException.createForRenderer(codecDrmSession.getError(), getIndex()); } return drmSessionState != DrmSession.STATE_OPENED_WITH_KEYS; }
Example #19
Source File: SimpleDecoderAudioRenderer.java From Telegram with GNU General Public License v2.0 | 5 votes |
private boolean shouldWaitForKeys(boolean bufferEncrypted) throws ExoPlaybackException { if (decoderDrmSession == null || (!bufferEncrypted && playClearSamplesWithoutKeys)) { return false; } @DrmSession.State int drmSessionState = decoderDrmSession.getState(); if (drmSessionState == DrmSession.STATE_ERROR) { throw ExoPlaybackException.createForRenderer(decoderDrmSession.getError(), getIndex()); } return drmSessionState != DrmSession.STATE_OPENED_WITH_KEYS; }
Example #20
Source File: SimpleDecoderAudioRenderer.java From Telegram with GNU General Public License v2.0 | 5 votes |
private void onInputFormatChanged(Format newFormat) throws ExoPlaybackException { Format oldFormat = inputFormat; inputFormat = newFormat; boolean drmInitDataChanged = !Util.areEqual(inputFormat.drmInitData, oldFormat == null ? null : oldFormat.drmInitData); if (drmInitDataChanged) { if (inputFormat.drmInitData != null) { if (drmSessionManager == null) { throw ExoPlaybackException.createForRenderer( new IllegalStateException("Media requires a DrmSessionManager"), getIndex()); } DrmSession<ExoMediaCrypto> session = drmSessionManager.acquireSession(Looper.myLooper(), newFormat.drmInitData); if (session == decoderDrmSession || session == sourceDrmSession) { // We already had this session. The manager must be reference counting, so release it once // to get the count attributed to this renderer back down to 1. drmSessionManager.releaseSession(session); } setSourceDrmSession(session); } else { setSourceDrmSession(null); } } if (decoderReceivedBuffers) { // Signal end of stream and wait for any final output buffers before re-initialization. decoderReinitializationState = REINITIALIZATION_STATE_SIGNAL_END_OF_STREAM; } else { // There aren't any final output buffers, so release the decoder immediately. releaseDecoder(); maybeInitDecoder(); audioTrackNeedsConfigure = true; } encoderDelay = newFormat.encoderDelay; encoderPadding = newFormat.encoderPadding; eventDispatcher.inputFormatChanged(newFormat); }
Example #21
Source File: SimpleDecoderAudioRenderer.java From TelePlus-Android with GNU General Public License v2.0 | 5 votes |
private boolean shouldWaitForKeys(boolean bufferEncrypted) throws ExoPlaybackException { if (drmSession == null || (!bufferEncrypted && playClearSamplesWithoutKeys)) { return false; } @DrmSession.State int drmSessionState = drmSession.getState(); if (drmSessionState == DrmSession.STATE_ERROR) { throw ExoPlaybackException.createForRenderer(drmSession.getError(), getIndex()); } return drmSessionState != DrmSession.STATE_OPENED_WITH_KEYS; }
Example #22
Source File: SampleMetadataQueue.java From MediaSDK with Apache License 2.0 | 5 votes |
/** * Throws an error that's preventing data from being read. Does nothing if no such error exists. * * @throws IOException The underlying error. */ public void maybeThrowError() throws IOException { // TODO: Avoid throwing if the DRM error is not preventing a read operation. if (currentDrmSession != null && currentDrmSession.getState() == DrmSession.STATE_ERROR) { throw Assertions.checkNotNull(currentDrmSession.getError()); } }
Example #23
Source File: SampleMetadataQueue.java From MediaSDK with Apache License 2.0 | 5 votes |
/** * Sets the downstream format, performs DRM resource management, and populates the {@code * outputFormatHolder}. * * @param newFormat The new downstream format. * @param outputFormatHolder The output {@link FormatHolder}. */ private void onFormatResult(Format newFormat, FormatHolder outputFormatHolder) { outputFormatHolder.format = newFormat; boolean isFirstFormat = downstreamFormat == null; DrmInitData oldDrmInitData = isFirstFormat ? null : downstreamFormat.drmInitData; downstreamFormat = newFormat; if (drmSessionManager == DrmSessionManager.DUMMY) { // Avoid attempting to acquire a session using the dummy DRM session manager. It's likely that // the media source creation has not yet been migrated and the renderer can acquire the // session for the read DRM init data. // TODO: Remove once renderers are migrated [Internal ref: b/122519809]. return; } DrmInitData newDrmInitData = newFormat.drmInitData; outputFormatHolder.includesDrmSession = true; outputFormatHolder.drmSession = currentDrmSession; if (!isFirstFormat && Util.areEqual(oldDrmInitData, newDrmInitData)) { // Nothing to do. return; } // Ensure we acquire the new session before releasing the previous one in case the same session // is being used for both DrmInitData. DrmSession<?> previousSession = currentDrmSession; Looper playbackLooper = Assertions.checkNotNull(Looper.myLooper()); currentDrmSession = newDrmInitData != null ? drmSessionManager.acquireSession(playbackLooper, newDrmInitData) : drmSessionManager.acquirePlaceholderSession( playbackLooper, MimeTypes.getTrackType(newFormat.sampleMimeType)); outputFormatHolder.drmSession = currentDrmSession; if (previousSession != null) { previousSession.release(); } }
Example #24
Source File: SampleMetadataQueue.java From MediaSDK with Apache License 2.0 | 5 votes |
/** * Returns whether it's possible to read the next sample. * * @param relativeReadIndex The relative read index of the next sample. * @return Whether it's possible to read the next sample. */ private boolean mayReadSample(int relativeReadIndex) { if (drmSessionManager == DrmSessionManager.DUMMY) { // TODO: Remove once renderers are migrated [Internal ref: b/122519809]. // For protected content it's likely that the DrmSessionManager is still being injected into // the renderers. We assume that the renderers will be able to acquire a DrmSession if needed. return true; } return currentDrmSession == null || currentDrmSession.getState() == DrmSession.STATE_OPENED_WITH_KEYS || ((flags[relativeReadIndex] & C.BUFFER_FLAG_ENCRYPTED) == 0 && currentDrmSession.playClearSamplesWithoutKeys()); }
Example #25
Source File: MediaCodecRenderer.java From MediaSDK with Apache License 2.0 | 5 votes |
private boolean shouldWaitForKeys(boolean bufferEncrypted) throws ExoPlaybackException { if (codecDrmSession == null || (!bufferEncrypted && (playClearSamplesWithoutKeys || codecDrmSession.playClearSamplesWithoutKeys()))) { return false; } @DrmSession.State int drmSessionState = codecDrmSession.getState(); if (drmSessionState == DrmSession.STATE_ERROR) { throw createRendererException(codecDrmSession.getError(), inputFormat); } return drmSessionState != DrmSession.STATE_OPENED_WITH_KEYS; }
Example #26
Source File: SimpleDecoderAudioRenderer.java From MediaSDK with Apache License 2.0 | 5 votes |
private boolean shouldWaitForKeys(boolean bufferEncrypted) throws ExoPlaybackException { if (decoderDrmSession == null || (!bufferEncrypted && (playClearSamplesWithoutKeys || decoderDrmSession.playClearSamplesWithoutKeys()))) { return false; } @DrmSession.State int drmSessionState = decoderDrmSession.getState(); if (drmSessionState == DrmSession.STATE_ERROR) { throw createRendererException(decoderDrmSession.getError(), inputFormat); } return drmSessionState != DrmSession.STATE_OPENED_WITH_KEYS; }
Example #27
Source File: SimpleDecoderAudioRenderer.java From MediaSDK with Apache License 2.0 | 5 votes |
@SuppressWarnings("unchecked") private void onInputFormatChanged(FormatHolder formatHolder) throws ExoPlaybackException { Format newFormat = Assertions.checkNotNull(formatHolder.format); if (formatHolder.includesDrmSession) { setSourceDrmSession((DrmSession<ExoMediaCrypto>) formatHolder.drmSession); } else { sourceDrmSession = getUpdatedSourceDrmSession(inputFormat, newFormat, drmSessionManager, sourceDrmSession); } Format oldFormat = inputFormat; inputFormat = newFormat; if (!canKeepCodec(oldFormat, inputFormat)) { if (decoderReceivedBuffers) { // Signal end of stream and wait for any final output buffers before re-initialization. decoderReinitializationState = REINITIALIZATION_STATE_SIGNAL_END_OF_STREAM; } else { // There aren't any final output buffers, so release the decoder immediately. releaseDecoder(); maybeInitDecoder(); audioTrackNeedsConfigure = true; } } encoderDelay = inputFormat.encoderDelay; encoderPadding = inputFormat.encoderPadding; eventDispatcher.inputFormatChanged(inputFormat); }
Example #28
Source File: SimpleDecoderVideoRenderer.java From MediaSDK with Apache License 2.0 | 5 votes |
/** * Called when a new format is read from the upstream source. * * @param formatHolder A {@link FormatHolder} that holds the new {@link Format}. * @throws ExoPlaybackException If an error occurs (re-)initializing the decoder. */ @CallSuper @SuppressWarnings("unchecked") protected void onInputFormatChanged(FormatHolder formatHolder) throws ExoPlaybackException { waitingForFirstSampleInFormat = true; Format newFormat = Assertions.checkNotNull(formatHolder.format); if (formatHolder.includesDrmSession) { setSourceDrmSession((DrmSession<ExoMediaCrypto>) formatHolder.drmSession); } else { sourceDrmSession = getUpdatedSourceDrmSession(inputFormat, newFormat, drmSessionManager, sourceDrmSession); } inputFormat = newFormat; if (sourceDrmSession != decoderDrmSession) { if (decoderReceivedBuffers) { // Signal end of stream and wait for any final output buffers before re-initialization. decoderReinitializationState = REINITIALIZATION_STATE_SIGNAL_END_OF_STREAM; } else { // There aren't any final output buffers, so release the decoder immediately. releaseDecoder(); maybeInitDecoder(); } } eventDispatcher.inputFormatChanged(inputFormat); }
Example #29
Source File: MediaCodecRenderer.java From TelePlus-Android with GNU General Public License v2.0 | 5 votes |
private boolean shouldWaitForKeys(boolean bufferEncrypted) throws ExoPlaybackException { if (drmSession == null || (!bufferEncrypted && playClearSamplesWithoutKeys)) { return false; } @DrmSession.State int drmSessionState = drmSession.getState(); if (drmSessionState == DrmSession.STATE_ERROR) { throw ExoPlaybackException.createForRenderer(drmSession.getError(), getIndex()); } return drmSessionState != DrmSession.STATE_OPENED_WITH_KEYS; }
Example #30
Source File: SimpleDecoderVideoRenderer.java From MediaSDK with Apache License 2.0 | 5 votes |
private boolean shouldWaitForKeys(boolean bufferEncrypted) throws ExoPlaybackException { if (decoderDrmSession == null || (!bufferEncrypted && (playClearSamplesWithoutKeys || decoderDrmSession.playClearSamplesWithoutKeys()))) { return false; } @DrmSession.State int drmSessionState = decoderDrmSession.getState(); if (drmSessionState == DrmSession.STATE_ERROR) { throw createRendererException(decoderDrmSession.getError(), inputFormat); } return drmSessionState != DrmSession.STATE_OPENED_WITH_KEYS; }