Better behavior if media doesn't support DRM scheme
We don't expect this case to occur, since track selection is normally expected to check canAcquireSession before selecting a track. Nevertheless, if an attempt is made to acquire a session when the media doesn't support the manager's UUID, we should fail in a more graceful way. ------------- Created by MOE: https://github.com/google/moe MOE_MIGRATED_REVID=173124170
This commit is contained in:
parent
3289e3e9cb
commit
c4f3cad586
@ -26,6 +26,7 @@ import android.text.TextUtils;
|
||||
import com.google.android.exoplayer2.C;
|
||||
import com.google.android.exoplayer2.drm.DefaultDrmSession.ProvisioningManager;
|
||||
import com.google.android.exoplayer2.drm.DrmInitData.SchemeData;
|
||||
import com.google.android.exoplayer2.drm.DrmSession.DrmSessionException;
|
||||
import com.google.android.exoplayer2.drm.ExoMediaDrm.OnEventListener;
|
||||
import com.google.android.exoplayer2.extractor.mp4.PsshAtomUtil;
|
||||
import com.google.android.exoplayer2.util.Assertions;
|
||||
@ -372,19 +373,20 @@ public class DefaultDrmSessionManager<T extends ExoMediaCrypto> implements DrmSe
|
||||
if (offlineLicenseKeySetId == null) {
|
||||
SchemeData data = getSchemeData(drmInitData, uuid);
|
||||
if (data == null) {
|
||||
final IllegalStateException error = new IllegalStateException(
|
||||
"Media does not support uuid: " + uuid);
|
||||
if (eventHandler != null && eventListener != null) {
|
||||
eventHandler.post(new Runnable() {
|
||||
@Override
|
||||
public void run() {
|
||||
eventListener.onDrmSessionManagerError(new IllegalStateException(
|
||||
"Media does not support uuid: " + uuid));
|
||||
eventListener.onDrmSessionManagerError(error);
|
||||
}
|
||||
});
|
||||
}
|
||||
} else {
|
||||
initData = getSchemeInitData(data, uuid);
|
||||
mimeType = getSchemeMimeType(data, uuid);
|
||||
return new ErrorStateDrmSession<>(new DrmSessionException(error));
|
||||
}
|
||||
initData = getSchemeInitData(data, uuid);
|
||||
mimeType = getSchemeMimeType(data, uuid);
|
||||
}
|
||||
|
||||
DefaultDrmSession<T> session;
|
||||
@ -414,6 +416,11 @@ public class DefaultDrmSessionManager<T extends ExoMediaCrypto> implements DrmSe
|
||||
|
||||
@Override
|
||||
public void releaseSession(DrmSession<T> session) {
|
||||
if (session instanceof ErrorStateDrmSession) {
|
||||
// Do nothing.
|
||||
return;
|
||||
}
|
||||
|
||||
DefaultDrmSession<T> drmSession = (DefaultDrmSession<T>) session;
|
||||
if (drmSession.release()) {
|
||||
sessions.remove(drmSession);
|
||||
|
@ -0,0 +1,57 @@
|
||||
/*
|
||||
* Copyright (C) 2017 The Android Open Source Project
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
package com.google.android.exoplayer2.drm;
|
||||
|
||||
import com.google.android.exoplayer2.util.Assertions;
|
||||
import java.util.Map;
|
||||
|
||||
/**
|
||||
* A {@link DrmSession} that's in a terminal error state.
|
||||
*/
|
||||
/* package */ final class ErrorStateDrmSession<T extends ExoMediaCrypto> implements DrmSession<T> {
|
||||
|
||||
private final DrmSessionException error;
|
||||
|
||||
public ErrorStateDrmSession(DrmSessionException error) {
|
||||
this.error = Assertions.checkNotNull(error);
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getState() {
|
||||
return STATE_ERROR;
|
||||
}
|
||||
|
||||
@Override
|
||||
public DrmSessionException getError() {
|
||||
return error;
|
||||
}
|
||||
|
||||
@Override
|
||||
public T getMediaCrypto() {
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Map<String, String> queryKeyStatus() {
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public byte[] getOfflineLicenseKeySetId() {
|
||||
return null;
|
||||
}
|
||||
|
||||
}
|
Loading…
x
Reference in New Issue
Block a user