Add a track type argument to DrmSessionManager.acquirePlaceholderSession
Issue:#4867 PiperOrigin-RevId: 279928345
This commit is contained in:
parent
b84a9bed2c
commit
abe0330f39
@ -458,12 +458,15 @@ public class DefaultDrmSessionManager<T extends ExoMediaCrypto> implements DrmSe
|
||||
|
||||
@Override
|
||||
@Nullable
|
||||
public DrmSession<T> acquirePlaceholderSession(Looper playbackLooper) {
|
||||
public DrmSession<T> acquirePlaceholderSession(Looper playbackLooper, int trackType) {
|
||||
assertExpectedPlaybackLooper(playbackLooper);
|
||||
Assertions.checkNotNull(exoMediaDrm);
|
||||
boolean avoidPlaceholderDrmSessions =
|
||||
FrameworkMediaCrypto.class.equals(exoMediaDrm.getExoMediaCryptoType())
|
||||
&& FrameworkMediaCrypto.WORKAROUND_DEVICE_NEEDS_KEYS_TO_CONFIGURE_CODEC;
|
||||
// Avoid attaching a session to sparse formats.
|
||||
avoidPlaceholderDrmSessions |=
|
||||
trackType != C.TRACK_TYPE_VIDEO && trackType != C.TRACK_TYPE_AUDIO;
|
||||
if (avoidPlaceholderDrmSessions
|
||||
|| !preferSecureDecoders
|
||||
|| exoMediaDrm.getExoMediaCryptoType() == null) {
|
||||
|
@ -18,6 +18,7 @@ package com.google.android.exoplayer2.drm;
|
||||
import android.os.Looper;
|
||||
import androidx.annotation.IntDef;
|
||||
import androidx.annotation.Nullable;
|
||||
import com.google.android.exoplayer2.C;
|
||||
import com.google.android.exoplayer2.drm.DrmInitData.SchemeData;
|
||||
import java.lang.annotation.Documented;
|
||||
import java.lang.annotation.Retention;
|
||||
@ -112,11 +113,13 @@ public interface DrmSessionManager<T extends ExoMediaCrypto> {
|
||||
* content periods.
|
||||
*
|
||||
* @param playbackLooper The looper associated with the media playback thread.
|
||||
* @param trackType The type of the track to acquire a placeholder session for. Must be one of the
|
||||
* {@link C}{@code .TRACK_TYPE_*} constants.
|
||||
* @return The placeholder DRM session, or null if this DRM session manager does not support
|
||||
* placeholder sessions.
|
||||
*/
|
||||
@Nullable
|
||||
default DrmSession<T> acquirePlaceholderSession(Looper playbackLooper) {
|
||||
default DrmSession<T> acquirePlaceholderSession(Looper playbackLooper, int trackType) {
|
||||
return null;
|
||||
}
|
||||
|
||||
|
@ -26,6 +26,7 @@ import com.google.android.exoplayer2.drm.DrmSession;
|
||||
import com.google.android.exoplayer2.drm.DrmSessionManager;
|
||||
import com.google.android.exoplayer2.extractor.TrackOutput.CryptoData;
|
||||
import com.google.android.exoplayer2.util.Assertions;
|
||||
import com.google.android.exoplayer2.util.MimeTypes;
|
||||
import com.google.android.exoplayer2.util.Util;
|
||||
import java.io.IOException;
|
||||
|
||||
@ -623,7 +624,8 @@ import java.io.IOException;
|
||||
currentDrmSession =
|
||||
newDrmInitData != null
|
||||
? drmSessionManager.acquireSession(playbackLooper, newDrmInitData)
|
||||
: drmSessionManager.acquirePlaceholderSession(playbackLooper);
|
||||
: drmSessionManager.acquirePlaceholderSession(
|
||||
playbackLooper, MimeTypes.getTrackType(newFormat.sampleMimeType));
|
||||
outputFormatHolder.drmSession = currentDrmSession;
|
||||
|
||||
if (previousSession != null) {
|
||||
|
@ -396,7 +396,8 @@ public final class SampleQueueTest {
|
||||
DrmSession<ExoMediaCrypto> mockPlaceholderDrmSession =
|
||||
(DrmSession<ExoMediaCrypto>) Mockito.mock(DrmSession.class);
|
||||
when(mockPlaceholderDrmSession.getState()).thenReturn(DrmSession.STATE_OPENED_WITH_KEYS);
|
||||
when(mockDrmSessionManager.acquirePlaceholderSession(ArgumentMatchers.any()))
|
||||
when(mockDrmSessionManager.acquirePlaceholderSession(
|
||||
ArgumentMatchers.any(), ArgumentMatchers.anyInt()))
|
||||
.thenReturn(mockPlaceholderDrmSession);
|
||||
writeTestDataWithEncryptedSections();
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user