mirror of
https://github.com/samsonjs/media.git
synced 2026-04-02 10:45:51 +00:00
Add MediaSource-provided-DRM support to Renderer implementations
PiperOrigin-RevId: 250719155
This commit is contained in:
parent
090f359895
commit
7e187283cd
3 changed files with 30 additions and 15 deletions
|
|
@ -489,6 +489,7 @@ public class LibvpxVideoRenderer extends BaseRenderer {
|
|||
* @throws ExoPlaybackException If an error occurs (re-)initializing the decoder.
|
||||
*/
|
||||
@CallSuper
|
||||
@SuppressWarnings("unchecked")
|
||||
protected void onInputFormatChanged(Format newFormat) throws ExoPlaybackException {
|
||||
Format oldFormat = format;
|
||||
format = newFormat;
|
||||
|
|
@ -502,12 +503,16 @@ public class LibvpxVideoRenderer extends BaseRenderer {
|
|||
throw ExoPlaybackException.createForRenderer(
|
||||
new IllegalStateException("Media requires a DrmSessionManager"), getIndex());
|
||||
}
|
||||
DrmSession<ExoMediaCrypto> session =
|
||||
drmSessionManager.acquireSession(Looper.myLooper(), newFormat.drmInitData);
|
||||
if (sourceDrmSession != null) {
|
||||
sourceDrmSession.releaseReference();
|
||||
if (formatHolder.decryptionResourceIsProvided) {
|
||||
setSourceDrmSession((DrmSession<ExoMediaCrypto>) formatHolder.drmSession);
|
||||
} else {
|
||||
DrmSession<ExoMediaCrypto> session =
|
||||
drmSessionManager.acquireSession(Looper.myLooper(), newFormat.drmInitData);
|
||||
if (sourceDrmSession != null) {
|
||||
sourceDrmSession.releaseReference();
|
||||
}
|
||||
sourceDrmSession = session;
|
||||
}
|
||||
sourceDrmSession = session;
|
||||
} else {
|
||||
setSourceDrmSession(null);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -655,6 +655,7 @@ public abstract class SimpleDecoderAudioRenderer extends BaseRenderer implements
|
|||
decoderDrmSession = session;
|
||||
}
|
||||
|
||||
@SuppressWarnings("unchecked")
|
||||
private void onInputFormatChanged(Format newFormat) throws ExoPlaybackException {
|
||||
Format oldFormat = inputFormat;
|
||||
inputFormat = newFormat;
|
||||
|
|
@ -667,12 +668,16 @@ public abstract class SimpleDecoderAudioRenderer extends BaseRenderer implements
|
|||
throw ExoPlaybackException.createForRenderer(
|
||||
new IllegalStateException("Media requires a DrmSessionManager"), getIndex());
|
||||
}
|
||||
DrmSession<ExoMediaCrypto> session =
|
||||
drmSessionManager.acquireSession(Looper.myLooper(), newFormat.drmInitData);
|
||||
if (sourceDrmSession != null) {
|
||||
sourceDrmSession.releaseReference();
|
||||
if (formatHolder.decryptionResourceIsProvided) {
|
||||
setSourceDrmSession((DrmSession<ExoMediaCrypto>) formatHolder.drmSession);
|
||||
} else {
|
||||
DrmSession<ExoMediaCrypto> session =
|
||||
drmSessionManager.acquireSession(Looper.myLooper(), newFormat.drmInitData);
|
||||
if (sourceDrmSession != null) {
|
||||
sourceDrmSession.releaseReference();
|
||||
}
|
||||
sourceDrmSession = session;
|
||||
}
|
||||
sourceDrmSession = session;
|
||||
} else {
|
||||
setSourceDrmSession(null);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1135,6 +1135,7 @@ public abstract class MediaCodecRenderer extends BaseRenderer {
|
|||
* @param formatHolder A {@link FormatHolder} that holds the new {@link Format}.
|
||||
* @throws ExoPlaybackException If an error occurs re-initializing the {@link MediaCodec}.
|
||||
*/
|
||||
@SuppressWarnings("unchecked")
|
||||
protected void onInputFormatChanged(FormatHolder formatHolder) throws ExoPlaybackException {
|
||||
Format oldFormat = inputFormat;
|
||||
Format newFormat = formatHolder.format;
|
||||
|
|
@ -1149,12 +1150,16 @@ public abstract class MediaCodecRenderer extends BaseRenderer {
|
|||
throw ExoPlaybackException.createForRenderer(
|
||||
new IllegalStateException("Media requires a DrmSessionManager"), getIndex());
|
||||
}
|
||||
DrmSession<FrameworkMediaCrypto> session =
|
||||
drmSessionManager.acquireSession(Looper.myLooper(), newFormat.drmInitData);
|
||||
if (sourceDrmSession != null) {
|
||||
sourceDrmSession.releaseReference();
|
||||
if (formatHolder.decryptionResourceIsProvided) {
|
||||
setSourceDrmSession((DrmSession<FrameworkMediaCrypto>) formatHolder.drmSession);
|
||||
} else {
|
||||
DrmSession<FrameworkMediaCrypto> session =
|
||||
drmSessionManager.acquireSession(Looper.myLooper(), newFormat.drmInitData);
|
||||
if (sourceDrmSession != null) {
|
||||
sourceDrmSession.releaseReference();
|
||||
}
|
||||
sourceDrmSession = session;
|
||||
}
|
||||
sourceDrmSession = session;
|
||||
} else {
|
||||
setSourceDrmSession(null);
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in a new issue