Commit 972c6c2f by aquilescanta Committed by Oliver Woodman

Avoid acquiring DrmSessions using the dummy DrmSessionManager

This is a temporary workaround until we have migrated all MediaSources uses.
This change avoids having to migrate all uses of MediaSources immediately.

PiperOrigin-RevId: 257459138
parent 6606a4ff
...@@ -131,7 +131,8 @@ public final class DecryptableSampleQueueReader { ...@@ -131,7 +131,8 @@ public final class DecryptableSampleQueueReader {
if (currentFormat == null || formatRequired) { if (currentFormat == null || formatRequired) {
readFlagFormatRequired = true; readFlagFormatRequired = true;
} else if (currentFormat.drmInitData != null } else if (sessionManager != DrmSessionManager.DUMMY
&& currentFormat.drmInitData != null
&& Assertions.checkNotNull(currentSession).getState() && Assertions.checkNotNull(currentSession).getState()
!= DrmSession.STATE_OPENED_WITH_KEYS) { != DrmSession.STATE_OPENED_WITH_KEYS) {
if (playClearSamplesWithoutKeys) { if (playClearSamplesWithoutKeys) {
...@@ -158,12 +159,7 @@ public final class DecryptableSampleQueueReader { ...@@ -158,12 +159,7 @@ public final class DecryptableSampleQueueReader {
if (onlyPropagateFormatChanges && currentFormat == formatHolder.format) { if (onlyPropagateFormatChanges && currentFormat == formatHolder.format) {
return C.RESULT_NOTHING_READ; return C.RESULT_NOTHING_READ;
} }
onFormat(Assertions.checkNotNull(formatHolder.format)); onFormat(Assertions.checkNotNull(formatHolder.format), outputFormatHolder);
// TODO: Remove once all Renderers and MediaSources have migrated to the new DRM model
// [Internal ref: b/129764794].
outputFormatHolder.includesDrmSession = true;
outputFormatHolder.format = formatHolder.format;
outputFormatHolder.drmSession = currentSession;
} }
return result; return result;
} }
...@@ -172,10 +168,21 @@ public final class DecryptableSampleQueueReader { ...@@ -172,10 +168,21 @@ public final class DecryptableSampleQueueReader {
* Updates the current format and manages any necessary DRM resources. * Updates the current format and manages any necessary DRM resources.
* *
* @param format The format read from upstream. * @param format The format read from upstream.
* @param outputFormatHolder The output {@link FormatHolder}.
*/ */
private void onFormat(Format format) { private void onFormat(Format format, FormatHolder outputFormatHolder) {
DrmInitData oldDrmInitData = currentFormat != null ? currentFormat.drmInitData : null; outputFormatHolder.format = format;
currentFormat = format; currentFormat = format;
if (sessionManager == 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;
}
outputFormatHolder.includesDrmSession = true;
outputFormatHolder.drmSession = currentSession;
DrmInitData oldDrmInitData = currentFormat != null ? currentFormat.drmInitData : null;
if (Util.areEqual(oldDrmInitData, format.drmInitData)) { if (Util.areEqual(oldDrmInitData, format.drmInitData)) {
// Nothing to do. // Nothing to do.
return; return;
...@@ -195,6 +202,7 @@ public final class DecryptableSampleQueueReader { ...@@ -195,6 +202,7 @@ public final class DecryptableSampleQueueReader {
} else { } else {
currentSession = null; currentSession = null;
} }
outputFormatHolder.drmSession = currentSession;
if (previousSession != null) { if (previousSession != null) {
previousSession.releaseReference(); previousSession.releaseReference();
...@@ -211,7 +219,8 @@ public final class DecryptableSampleQueueReader { ...@@ -211,7 +219,8 @@ public final class DecryptableSampleQueueReader {
} else if (nextInQueue == SampleQueue.PEEK_RESULT_BUFFER_CLEAR) { } else if (nextInQueue == SampleQueue.PEEK_RESULT_BUFFER_CLEAR) {
return currentSession == null || playClearSamplesWithoutKeys; return currentSession == null || playClearSamplesWithoutKeys;
} else if (nextInQueue == SampleQueue.PEEK_RESULT_BUFFER_ENCRYPTED) { } else if (nextInQueue == SampleQueue.PEEK_RESULT_BUFFER_ENCRYPTED) {
return Assertions.checkNotNull(currentSession).getState() return sessionManager == DrmSessionManager.DUMMY
|| Assertions.checkNotNull(currentSession).getState()
== DrmSession.STATE_OPENED_WITH_KEYS; == DrmSession.STATE_OPENED_WITH_KEYS;
} else { } else {
throw new IllegalStateException(); throw new IllegalStateException();
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or sign in to comment