Commit 7e187283 by aquilescanta Committed by Oliver Woodman

Add MediaSource-provided-DRM support to Renderer implementations

PiperOrigin-RevId: 250719155
parent 090f3598
...@@ -489,6 +489,7 @@ public class LibvpxVideoRenderer extends BaseRenderer { ...@@ -489,6 +489,7 @@ public class LibvpxVideoRenderer extends BaseRenderer {
* @throws ExoPlaybackException If an error occurs (re-)initializing the decoder. * @throws ExoPlaybackException If an error occurs (re-)initializing the decoder.
*/ */
@CallSuper @CallSuper
@SuppressWarnings("unchecked")
protected void onInputFormatChanged(Format newFormat) throws ExoPlaybackException { protected void onInputFormatChanged(Format newFormat) throws ExoPlaybackException {
Format oldFormat = format; Format oldFormat = format;
format = newFormat; format = newFormat;
...@@ -502,12 +503,16 @@ public class LibvpxVideoRenderer extends BaseRenderer { ...@@ -502,12 +503,16 @@ public class LibvpxVideoRenderer extends BaseRenderer {
throw ExoPlaybackException.createForRenderer( throw ExoPlaybackException.createForRenderer(
new IllegalStateException("Media requires a DrmSessionManager"), getIndex()); new IllegalStateException("Media requires a DrmSessionManager"), getIndex());
} }
DrmSession<ExoMediaCrypto> session = if (formatHolder.decryptionResourceIsProvided) {
drmSessionManager.acquireSession(Looper.myLooper(), newFormat.drmInitData); setSourceDrmSession((DrmSession<ExoMediaCrypto>) formatHolder.drmSession);
if (sourceDrmSession != null) { } else {
sourceDrmSession.releaseReference(); DrmSession<ExoMediaCrypto> session =
drmSessionManager.acquireSession(Looper.myLooper(), newFormat.drmInitData);
if (sourceDrmSession != null) {
sourceDrmSession.releaseReference();
}
sourceDrmSession = session;
} }
sourceDrmSession = session;
} else { } else {
setSourceDrmSession(null); setSourceDrmSession(null);
} }
......
...@@ -655,6 +655,7 @@ public abstract class SimpleDecoderAudioRenderer extends BaseRenderer implements ...@@ -655,6 +655,7 @@ public abstract class SimpleDecoderAudioRenderer extends BaseRenderer implements
decoderDrmSession = session; decoderDrmSession = session;
} }
@SuppressWarnings("unchecked")
private void onInputFormatChanged(Format newFormat) throws ExoPlaybackException { private void onInputFormatChanged(Format newFormat) throws ExoPlaybackException {
Format oldFormat = inputFormat; Format oldFormat = inputFormat;
inputFormat = newFormat; inputFormat = newFormat;
...@@ -667,12 +668,16 @@ public abstract class SimpleDecoderAudioRenderer extends BaseRenderer implements ...@@ -667,12 +668,16 @@ public abstract class SimpleDecoderAudioRenderer extends BaseRenderer implements
throw ExoPlaybackException.createForRenderer( throw ExoPlaybackException.createForRenderer(
new IllegalStateException("Media requires a DrmSessionManager"), getIndex()); new IllegalStateException("Media requires a DrmSessionManager"), getIndex());
} }
DrmSession<ExoMediaCrypto> session = if (formatHolder.decryptionResourceIsProvided) {
drmSessionManager.acquireSession(Looper.myLooper(), newFormat.drmInitData); setSourceDrmSession((DrmSession<ExoMediaCrypto>) formatHolder.drmSession);
if (sourceDrmSession != null) { } else {
sourceDrmSession.releaseReference(); DrmSession<ExoMediaCrypto> session =
drmSessionManager.acquireSession(Looper.myLooper(), newFormat.drmInitData);
if (sourceDrmSession != null) {
sourceDrmSession.releaseReference();
}
sourceDrmSession = session;
} }
sourceDrmSession = session;
} else { } else {
setSourceDrmSession(null); setSourceDrmSession(null);
} }
......
...@@ -1135,6 +1135,7 @@ public abstract class MediaCodecRenderer extends BaseRenderer { ...@@ -1135,6 +1135,7 @@ public abstract class MediaCodecRenderer extends BaseRenderer {
* @param formatHolder A {@link FormatHolder} that holds the new {@link Format}. * @param formatHolder A {@link FormatHolder} that holds the new {@link Format}.
* @throws ExoPlaybackException If an error occurs re-initializing the {@link MediaCodec}. * @throws ExoPlaybackException If an error occurs re-initializing the {@link MediaCodec}.
*/ */
@SuppressWarnings("unchecked")
protected void onInputFormatChanged(FormatHolder formatHolder) throws ExoPlaybackException { protected void onInputFormatChanged(FormatHolder formatHolder) throws ExoPlaybackException {
Format oldFormat = inputFormat; Format oldFormat = inputFormat;
Format newFormat = formatHolder.format; Format newFormat = formatHolder.format;
...@@ -1149,12 +1150,16 @@ public abstract class MediaCodecRenderer extends BaseRenderer { ...@@ -1149,12 +1150,16 @@ public abstract class MediaCodecRenderer extends BaseRenderer {
throw ExoPlaybackException.createForRenderer( throw ExoPlaybackException.createForRenderer(
new IllegalStateException("Media requires a DrmSessionManager"), getIndex()); new IllegalStateException("Media requires a DrmSessionManager"), getIndex());
} }
DrmSession<FrameworkMediaCrypto> session = if (formatHolder.decryptionResourceIsProvided) {
drmSessionManager.acquireSession(Looper.myLooper(), newFormat.drmInitData); setSourceDrmSession((DrmSession<FrameworkMediaCrypto>) formatHolder.drmSession);
if (sourceDrmSession != null) { } else {
sourceDrmSession.releaseReference(); DrmSession<FrameworkMediaCrypto> session =
drmSessionManager.acquireSession(Looper.myLooper(), newFormat.drmInitData);
if (sourceDrmSession != null) {
sourceDrmSession.releaseReference();
}
sourceDrmSession = session;
} }
sourceDrmSession = session;
} else { } else {
setSourceDrmSession(null); setSourceDrmSession(null);
} }
......
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