com.google.android.exoplayer2.drm.DrmSession.DrmSessionException Java Examples
The following examples show how to use
com.google.android.exoplayer2.drm.DrmSession.DrmSessionException.
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: OfflineLicenseHelper.java From TelePlus-Android with GNU General Public License v2.0 | 6 votes |
/** * Returns the remaining license and playback durations in seconds, for an offline license. * * @param offlineLicenseKeySetId The key set id of the license. * @return The remaining license and playback durations, in seconds. * @throws DrmSessionException Thrown when a DRM session error occurs. */ public synchronized Pair<Long, Long> getLicenseDurationRemainingSec(byte[] offlineLicenseKeySetId) throws DrmSessionException { Assertions.checkNotNull(offlineLicenseKeySetId); DrmSession<T> drmSession = openBlockingKeyRequest(DefaultDrmSessionManager.MODE_QUERY, offlineLicenseKeySetId, null); DrmSessionException error = drmSession.getError(); Pair<Long, Long> licenseDurationRemainingSec = WidevineUtil.getLicenseDurationRemainingSec(drmSession); drmSessionManager.releaseSession(drmSession); if (error != null) { if (error.getCause() instanceof KeysExpiredException) { return Pair.create(0L, 0L); } throw error; } return licenseDurationRemainingSec; }
Example #2
Source File: OfflineLicenseHelper.java From Telegram with GNU General Public License v2.0 | 6 votes |
/** * Returns the remaining license and playback durations in seconds, for an offline license. * * @param offlineLicenseKeySetId The key set id of the license. * @return The remaining license and playback durations, in seconds. * @throws DrmSessionException Thrown when a DRM session error occurs. */ public synchronized Pair<Long, Long> getLicenseDurationRemainingSec(byte[] offlineLicenseKeySetId) throws DrmSessionException { Assertions.checkNotNull(offlineLicenseKeySetId); DrmSession<T> drmSession = openBlockingKeyRequest( DefaultDrmSessionManager.MODE_QUERY, offlineLicenseKeySetId, DUMMY_DRM_INIT_DATA); DrmSessionException error = drmSession.getError(); Pair<Long, Long> licenseDurationRemainingSec = WidevineUtil.getLicenseDurationRemainingSec(drmSession); drmSessionManager.releaseSession(drmSession); if (error != null) { if (error.getCause() instanceof KeysExpiredException) { return Pair.create(0L, 0L); } throw error; } return Assertions.checkNotNull(licenseDurationRemainingSec); }
Example #3
Source File: OfflineLicenseHelper.java From MediaSDK with Apache License 2.0 | 6 votes |
/** * Returns the remaining license and playback durations in seconds, for an offline license. * * @param offlineLicenseKeySetId The key set id of the license. * @return The remaining license and playback durations, in seconds. * @throws DrmSessionException Thrown when a DRM session error occurs. */ public synchronized Pair<Long, Long> getLicenseDurationRemainingSec(byte[] offlineLicenseKeySetId) throws DrmSessionException { Assertions.checkNotNull(offlineLicenseKeySetId); drmSessionManager.prepare(); DrmSession<T> drmSession = openBlockingKeyRequest( DefaultDrmSessionManager.MODE_QUERY, offlineLicenseKeySetId, DUMMY_DRM_INIT_DATA); DrmSessionException error = drmSession.getError(); Pair<Long, Long> licenseDurationRemainingSec = WidevineUtil.getLicenseDurationRemainingSec(drmSession); drmSession.release(); drmSessionManager.release(); if (error != null) { if (error.getCause() instanceof KeysExpiredException) { return Pair.create(0L, 0L); } throw error; } return Assertions.checkNotNull(licenseDurationRemainingSec); }
Example #4
Source File: OfflineLicenseHelper.java From Telegram-FOSS with GNU General Public License v2.0 | 6 votes |
/** * Returns the remaining license and playback durations in seconds, for an offline license. * * @param offlineLicenseKeySetId The key set id of the license. * @return The remaining license and playback durations, in seconds. * @throws DrmSessionException Thrown when a DRM session error occurs. */ public synchronized Pair<Long, Long> getLicenseDurationRemainingSec(byte[] offlineLicenseKeySetId) throws DrmSessionException { Assertions.checkNotNull(offlineLicenseKeySetId); DrmSession<T> drmSession = openBlockingKeyRequest( DefaultDrmSessionManager.MODE_QUERY, offlineLicenseKeySetId, DUMMY_DRM_INIT_DATA); DrmSessionException error = drmSession.getError(); Pair<Long, Long> licenseDurationRemainingSec = WidevineUtil.getLicenseDurationRemainingSec(drmSession); drmSessionManager.releaseSession(drmSession); if (error != null) { if (error.getCause() instanceof KeysExpiredException) { return Pair.create(0L, 0L); } throw error; } return Assertions.checkNotNull(licenseDurationRemainingSec); }
Example #5
Source File: OfflineLicenseHelper.java From TelePlus-Android with GNU General Public License v2.0 | 6 votes |
/** * Returns the remaining license and playback durations in seconds, for an offline license. * * @param offlineLicenseKeySetId The key set id of the license. * @return The remaining license and playback durations, in seconds. * @throws DrmSessionException Thrown when a DRM session error occurs. */ public synchronized Pair<Long, Long> getLicenseDurationRemainingSec(byte[] offlineLicenseKeySetId) throws DrmSessionException { Assertions.checkNotNull(offlineLicenseKeySetId); DrmSession<T> drmSession = openBlockingKeyRequest(DefaultDrmSessionManager.MODE_QUERY, offlineLicenseKeySetId, null); DrmSessionException error = drmSession.getError(); Pair<Long, Long> licenseDurationRemainingSec = WidevineUtil.getLicenseDurationRemainingSec(drmSession); drmSessionManager.releaseSession(drmSession); if (error != null) { if (error.getCause() instanceof KeysExpiredException) { return Pair.create(0L, 0L); } throw error; } return licenseDurationRemainingSec; }
Example #6
Source File: OfflineLicenseHelper.java From K-Sonic with MIT License | 5 votes |
private void blockingKeyRequest(@Mode int licenseMode, byte[] offlineLicenseKeySetId, DrmInitData drmInitData) throws DrmSessionException { DrmSession<T> session = openBlockingKeyRequest(licenseMode, offlineLicenseKeySetId, drmInitData); DrmSessionException error = session.getError(); if (error != null) { throw error; } drmSessionManager.releaseSession(session); }
Example #7
Source File: OfflineLicenseHelper.java From TelePlus-Android with GNU General Public License v2.0 | 5 votes |
private byte[] blockingKeyRequest(@Mode int licenseMode, byte[] offlineLicenseKeySetId, DrmInitData drmInitData) throws DrmSessionException { DrmSession<T> drmSession = openBlockingKeyRequest(licenseMode, offlineLicenseKeySetId, drmInitData); DrmSessionException error = drmSession.getError(); byte[] keySetId = drmSession.getOfflineLicenseKeySetId(); drmSessionManager.releaseSession(drmSession); if (error != null) { throw error; } return keySetId; }
Example #8
Source File: SimpleDecoderAudioRenderer.java From TelePlus-Android with GNU General Public License v2.0 | 5 votes |
private void maybeInitDecoder() throws ExoPlaybackException { if (decoder != null) { return; } drmSession = pendingDrmSession; ExoMediaCrypto mediaCrypto = null; if (drmSession != null) { 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; } } } 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 #9
Source File: SoftVideoRenderer.java From DanDanPlayForAndroid with MIT License | 5 votes |
private void maybeInitDecoder() throws ExoPlaybackException { if (videoDecoder != null) { return; } drmSession = pendingDrmSession; ExoMediaCrypto mediaCrypto = null; if (drmSession != null) { mediaCrypto = drmSession.getMediaCrypto(); if (mediaCrypto == null) { DrmSessionException drmError = drmSession.getError(); if (drmError != null) { throw ExoPlaybackException.createForRenderer(drmError, getIndex()); } // The drm session isn't open yet. return; } } try { long codecInitializingTimestamp = SystemClock.elapsedRealtime(); TraceUtil.beginSection("createFFmpegDecoder"); videoDecoder = new VideoDecoder(format, NUM_INPUT_BUFFERS, NUM_OUTPUT_BUFFERS, INITIAL_INPUT_BUFFER_SIZE, mediaCrypto); TraceUtil.endSection(); long codecInitializedTimestamp = SystemClock.elapsedRealtime(); eventDispatcher.decoderInitialized(videoDecoder.getName(), codecInitializedTimestamp, codecInitializedTimestamp - codecInitializingTimestamp); decoderCounters.decoderInitCount++; } catch (Exception e) { throw ExoPlaybackException.createForRenderer(e, getIndex()); } }
Example #10
Source File: DefaultDrmSessionManager.java From MediaSDK with Apache License 2.0 | 5 votes |
@Override public DrmSession<T> acquireSession(Looper playbackLooper, DrmInitData drmInitData) { assertExpectedPlaybackLooper(playbackLooper); maybeCreateMediaDrmHandler(playbackLooper); @Nullable List<SchemeData> schemeDatas = null; if (offlineLicenseKeySetId == null) { schemeDatas = getSchemeDatas(drmInitData, uuid, false); if (schemeDatas.isEmpty()) { final MissingSchemeDataException error = new MissingSchemeDataException(uuid); eventDispatcher.dispatch(listener -> listener.onDrmSessionManagerError(error)); return new ErrorStateDrmSession<>(new DrmSessionException(error)); } } @Nullable DefaultDrmSession<T> session; if (!multiSession) { session = noMultiSessionDrmSession; } else { // Only use an existing session if it has matching init data. session = null; for (DefaultDrmSession<T> existingSession : sessions) { if (Util.areEqual(existingSession.schemeDatas, schemeDatas)) { session = existingSession; break; } } } if (session == null) { // Create a new session. session = createNewDefaultSession(schemeDatas, /* isPlaceholderSession= */ false); if (!multiSession) { noMultiSessionDrmSession = session; } sessions.add(session); } session.acquire(); return session; }
Example #11
Source File: DashTest.java From ExoPlayer-Offline with Apache License 2.0 | 5 votes |
public void releaseResources() throws DrmSessionException { if (offlineLicenseKeySetId != null) { releaseLicense(); } if (offlineLicenseHelper != null) { offlineLicenseHelper.releaseResources(); } }
Example #12
Source File: OfflineLicenseHelper.java From K-Sonic with MIT License | 5 votes |
/** * Downloads an offline license. * * @param dataSource The {@link HttpDataSource} to be used for download. * @param dashManifest The {@link DashManifest} of the DASH content. * @return The downloaded offline license key set id. * @throws IOException If an error occurs reading data from the stream. * @throws InterruptedException If the thread has been interrupted. * @throws DrmSessionException Thrown when there is an error during DRM session. */ public byte[] download(HttpDataSource dataSource, DashManifest dashManifest) throws IOException, InterruptedException, DrmSessionException { // Get DrmInitData // Prefer drmInitData obtained from the manifest over drmInitData obtained from the stream, // as per DASH IF Interoperability Recommendations V3.0, 7.5.3. if (dashManifest.getPeriodCount() < 1) { return null; } Period period = dashManifest.getPeriod(0); int adaptationSetIndex = period.getAdaptationSetIndex(C.TRACK_TYPE_VIDEO); if (adaptationSetIndex == C.INDEX_UNSET) { adaptationSetIndex = period.getAdaptationSetIndex(C.TRACK_TYPE_AUDIO); if (adaptationSetIndex == C.INDEX_UNSET) { return null; } } AdaptationSet adaptationSet = period.adaptationSets.get(adaptationSetIndex); if (adaptationSet.representations.isEmpty()) { return null; } Representation representation = adaptationSet.representations.get(0); DrmInitData drmInitData = representation.format.drmInitData; if (drmInitData == null) { Format sampleFormat = DashUtil.loadSampleFormat(dataSource, representation); if (sampleFormat != null) { drmInitData = sampleFormat.drmInitData; } if (drmInitData == null) { return null; } } blockingKeyRequest(DefaultDrmSessionManager.MODE_DOWNLOAD, null, drmInitData); return drmSessionManager.getOfflineLicenseKeySetId(); }
Example #13
Source File: OfflineLicenseHelper.java From K-Sonic with MIT License | 5 votes |
/** * Returns license and playback durations remaining in seconds of the given offline license. * * @param offlineLicenseKeySetId The key set id of the license. */ public Pair<Long, Long> getLicenseDurationRemainingSec(byte[] offlineLicenseKeySetId) throws DrmSessionException { Assertions.checkNotNull(offlineLicenseKeySetId); DrmSession<T> session = openBlockingKeyRequest(DefaultDrmSessionManager.MODE_QUERY, offlineLicenseKeySetId, null); Pair<Long, Long> licenseDurationRemainingSec = WidevineUtil.getLicenseDurationRemainingSec(drmSessionManager); drmSessionManager.releaseSession(session); return licenseDurationRemainingSec; }
Example #14
Source File: DashTest.java From ExoPlayer-Offline with Apache License 2.0 | 5 votes |
public byte[] downloadLicense() throws InterruptedException, DrmSessionException, IOException { assertNull(offlineLicenseKeySetId); offlineLicenseKeySetId = offlineLicenseHelper .download(httpDataSourceFactory.createDataSource(), parameters.manifestUrl); assertNotNull(offlineLicenseKeySetId); assertTrue(offlineLicenseKeySetId.length > 0); return offlineLicenseKeySetId; }
Example #15
Source File: OfflineLicenseHelper.java From Telegram-FOSS with GNU General Public License v2.0 | 5 votes |
/** * Releases an offline license. * * @param offlineLicenseKeySetId The key set id of the license to be released. * @throws DrmSessionException Thrown when a DRM session error occurs. */ public synchronized void releaseLicense(byte[] offlineLicenseKeySetId) throws DrmSessionException { Assertions.checkNotNull(offlineLicenseKeySetId); blockingKeyRequest( DefaultDrmSessionManager.MODE_RELEASE, offlineLicenseKeySetId, DUMMY_DRM_INIT_DATA); }
Example #16
Source File: OfflineLicenseHelper.java From Telegram-FOSS with GNU General Public License v2.0 | 5 votes |
private byte[] blockingKeyRequest( @Mode int licenseMode, @Nullable byte[] offlineLicenseKeySetId, DrmInitData drmInitData) throws DrmSessionException { DrmSession<T> drmSession = openBlockingKeyRequest(licenseMode, offlineLicenseKeySetId, drmInitData); DrmSessionException error = drmSession.getError(); byte[] keySetId = drmSession.getOfflineLicenseKeySetId(); drmSessionManager.releaseSession(drmSession); if (error != null) { throw error; } return Assertions.checkNotNull(keySetId); }
Example #17
Source File: SimpleDecoderAudioRenderer.java From Telegram-FOSS with GNU General Public License v2.0 | 5 votes |
private void maybeInitDecoder() throws ExoPlaybackException { if (decoder != null) { return; } setDecoderDrmSession(sourceDrmSession); ExoMediaCrypto mediaCrypto = null; if (decoderDrmSession != null) { mediaCrypto = decoderDrmSession.getMediaCrypto(); if (mediaCrypto == null) { DrmSessionException drmError = decoderDrmSession.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; } } } 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 #18
Source File: OfflineLicenseHelper.java From Telegram with GNU General Public License v2.0 | 5 votes |
/** * Releases an offline license. * * @param offlineLicenseKeySetId The key set id of the license to be released. * @throws DrmSessionException Thrown when a DRM session error occurs. */ public synchronized void releaseLicense(byte[] offlineLicenseKeySetId) throws DrmSessionException { Assertions.checkNotNull(offlineLicenseKeySetId); blockingKeyRequest( DefaultDrmSessionManager.MODE_RELEASE, offlineLicenseKeySetId, DUMMY_DRM_INIT_DATA); }
Example #19
Source File: OfflineLicenseHelper.java From Telegram with GNU General Public License v2.0 | 5 votes |
private byte[] blockingKeyRequest( @Mode int licenseMode, @Nullable byte[] offlineLicenseKeySetId, DrmInitData drmInitData) throws DrmSessionException { DrmSession<T> drmSession = openBlockingKeyRequest(licenseMode, offlineLicenseKeySetId, drmInitData); DrmSessionException error = drmSession.getError(); byte[] keySetId = drmSession.getOfflineLicenseKeySetId(); drmSessionManager.releaseSession(drmSession); if (error != null) { throw error; } return Assertions.checkNotNull(keySetId); }
Example #20
Source File: SimpleDecoderAudioRenderer.java From Telegram with GNU General Public License v2.0 | 5 votes |
private void maybeInitDecoder() throws ExoPlaybackException { if (decoder != null) { return; } setDecoderDrmSession(sourceDrmSession); ExoMediaCrypto mediaCrypto = null; if (decoderDrmSession != null) { mediaCrypto = decoderDrmSession.getMediaCrypto(); if (mediaCrypto == null) { DrmSessionException drmError = decoderDrmSession.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; } } } 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 #21
Source File: SimpleDecoderVideoRenderer.java From MediaSDK with Apache License 2.0 | 5 votes |
private void maybeInitDecoder() throws ExoPlaybackException { if (decoder != null) { return; } setDecoderDrmSession(sourceDrmSession); ExoMediaCrypto mediaCrypto = null; if (decoderDrmSession != null) { mediaCrypto = decoderDrmSession.getMediaCrypto(); if (mediaCrypto == null) { DrmSessionException drmError = decoderDrmSession.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; } } } try { long decoderInitializingTimestamp = SystemClock.elapsedRealtime(); decoder = createDecoder(inputFormat, mediaCrypto); setDecoderOutputMode(outputMode); long decoderInitializedTimestamp = SystemClock.elapsedRealtime(); onDecoderInitialized( decoder.getName(), decoderInitializedTimestamp, decoderInitializedTimestamp - decoderInitializingTimestamp); decoderCounters.decoderInitCount++; } catch (VideoDecoderException e) { throw createRendererException(e, inputFormat); } }
Example #22
Source File: SimpleDecoderAudioRenderer.java From MediaSDK with Apache License 2.0 | 5 votes |
private void maybeInitDecoder() throws ExoPlaybackException { if (decoder != null) { return; } setDecoderDrmSession(sourceDrmSession); ExoMediaCrypto mediaCrypto = null; if (decoderDrmSession != null) { mediaCrypto = decoderDrmSession.getMediaCrypto(); if (mediaCrypto == null) { DrmSessionException drmError = decoderDrmSession.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; } } } 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 createRendererException(e, inputFormat); } }
Example #23
Source File: SimpleDecoderAudioRenderer.java From TelePlus-Android with GNU General Public License v2.0 | 5 votes |
private void maybeInitDecoder() throws ExoPlaybackException { if (decoder != null) { return; } drmSession = pendingDrmSession; ExoMediaCrypto mediaCrypto = null; if (drmSession != null) { 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; } } } 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 #24
Source File: OfflineLicenseHelper.java From MediaSDK with Apache License 2.0 | 5 votes |
private byte[] blockingKeyRequest( @Mode int licenseMode, @Nullable byte[] offlineLicenseKeySetId, DrmInitData drmInitData) throws DrmSessionException { drmSessionManager.prepare(); DrmSession<T> drmSession = openBlockingKeyRequest(licenseMode, offlineLicenseKeySetId, drmInitData); DrmSessionException error = drmSession.getError(); byte[] keySetId = drmSession.getOfflineLicenseKeySetId(); drmSession.release(); drmSessionManager.release(); if (error != null) { throw error; } return Assertions.checkNotNull(keySetId); }
Example #25
Source File: OfflineLicenseHelper.java From TelePlus-Android with GNU General Public License v2.0 | 5 votes |
private byte[] blockingKeyRequest(@Mode int licenseMode, byte[] offlineLicenseKeySetId, DrmInitData drmInitData) throws DrmSessionException { DrmSession<T> drmSession = openBlockingKeyRequest(licenseMode, offlineLicenseKeySetId, drmInitData); DrmSessionException error = drmSession.getError(); byte[] keySetId = drmSession.getOfflineLicenseKeySetId(); drmSessionManager.releaseSession(drmSession); if (error != null) { throw error; } return keySetId; }
Example #26
Source File: OfflineLicenseHelper.java From MediaSDK with Apache License 2.0 | 5 votes |
/** * Releases an offline license. * * @param offlineLicenseKeySetId The key set id of the license to be released. * @throws DrmSessionException Thrown when a DRM session error occurs. */ public synchronized void releaseLicense(byte[] offlineLicenseKeySetId) throws DrmSessionException { Assertions.checkNotNull(offlineLicenseKeySetId); blockingKeyRequest( DefaultDrmSessionManager.MODE_RELEASE, offlineLicenseKeySetId, DUMMY_DRM_INIT_DATA); }
Example #27
Source File: DefaultDrmSessionManager.java From TelePlus-Android with GNU General Public License v2.0 | 4 votes |
@Override public DrmSession<T> acquireSession(Looper playbackLooper, DrmInitData drmInitData) { Assertions.checkState(this.playbackLooper == null || this.playbackLooper == playbackLooper); if (sessions.isEmpty()) { this.playbackLooper = playbackLooper; if (mediaDrmHandler == null) { mediaDrmHandler = new MediaDrmHandler(playbackLooper); } } SchemeData schemeData = null; if (offlineLicenseKeySetId == null) { schemeData = getSchemeData(drmInitData, uuid, false); if (schemeData == null) { final MissingSchemeDataException error = new MissingSchemeDataException(uuid); eventDispatcher.dispatch(listener -> listener.onDrmSessionManagerError(error)); return new ErrorStateDrmSession<>(new DrmSessionException(error)); } } DefaultDrmSession<T> session; if (!multiSession) { session = sessions.isEmpty() ? null : sessions.get(0); } else { // Only use an existing session if it has matching init data. session = null; byte[] initData = schemeData != null ? schemeData.data : null; for (DefaultDrmSession<T> existingSession : sessions) { if (existingSession.hasInitData(initData)) { session = existingSession; break; } } } if (session == null) { // Create a new session. session = new DefaultDrmSession<>( uuid, mediaDrm, this, schemeData, mode, offlineLicenseKeySetId, optionalKeyRequestParameters, callback, playbackLooper, eventDispatcher, initialDrmRequestRetryCount); sessions.add(session); } session.acquire(); return session; }
Example #28
Source File: DefaultDrmSessionManager.java From Telegram-FOSS with GNU General Public License v2.0 | 4 votes |
@Override public DrmSession<T> acquireSession(Looper playbackLooper, DrmInitData drmInitData) { Assertions.checkState(this.playbackLooper == null || this.playbackLooper == playbackLooper); if (sessions.isEmpty()) { this.playbackLooper = playbackLooper; if (mediaDrmHandler == null) { mediaDrmHandler = new MediaDrmHandler(playbackLooper); } } List<SchemeData> schemeDatas = null; if (offlineLicenseKeySetId == null) { schemeDatas = getSchemeDatas(drmInitData, uuid, false); if (schemeDatas.isEmpty()) { final MissingSchemeDataException error = new MissingSchemeDataException(uuid); eventDispatcher.dispatch(listener -> listener.onDrmSessionManagerError(error)); return new ErrorStateDrmSession<>(new DrmSessionException(error)); } } DefaultDrmSession<T> session; if (!multiSession) { session = sessions.isEmpty() ? null : sessions.get(0); } else { // Only use an existing session if it has matching init data. session = null; for (DefaultDrmSession<T> existingSession : sessions) { if (Util.areEqual(existingSession.schemeDatas, schemeDatas)) { session = existingSession; break; } } } if (session == null) { // Create a new session. session = new DefaultDrmSession<>( uuid, mediaDrm, this, schemeDatas, mode, offlineLicenseKeySetId, optionalKeyRequestParameters, callback, playbackLooper, eventDispatcher, initialDrmRequestRetryCount); sessions.add(session); } session.acquire(); return session; }
Example #29
Source File: DefaultDrmSessionManager.java From Telegram with GNU General Public License v2.0 | 4 votes |
@Override public DrmSession<T> acquireSession(Looper playbackLooper, DrmInitData drmInitData) { Assertions.checkState(this.playbackLooper == null || this.playbackLooper == playbackLooper); if (sessions.isEmpty()) { this.playbackLooper = playbackLooper; if (mediaDrmHandler == null) { mediaDrmHandler = new MediaDrmHandler(playbackLooper); } } List<SchemeData> schemeDatas = null; if (offlineLicenseKeySetId == null) { schemeDatas = getSchemeDatas(drmInitData, uuid, false); if (schemeDatas.isEmpty()) { final MissingSchemeDataException error = new MissingSchemeDataException(uuid); eventDispatcher.dispatch(listener -> listener.onDrmSessionManagerError(error)); return new ErrorStateDrmSession<>(new DrmSessionException(error)); } } DefaultDrmSession<T> session; if (!multiSession) { session = sessions.isEmpty() ? null : sessions.get(0); } else { // Only use an existing session if it has matching init data. session = null; for (DefaultDrmSession<T> existingSession : sessions) { if (Util.areEqual(existingSession.schemeDatas, schemeDatas)) { session = existingSession; break; } } } if (session == null) { // Create a new session. session = new DefaultDrmSession<>( uuid, mediaDrm, this, schemeDatas, mode, offlineLicenseKeySetId, optionalKeyRequestParameters, callback, playbackLooper, eventDispatcher, initialDrmRequestRetryCount); sessions.add(session); } session.acquire(); return session; }
Example #30
Source File: MediaCodecRenderer.java From TelePlus-Android with GNU General Public License v2.0 | 4 votes |
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++; }