Search in sources :

Example 6 with SchemeData

use of com.google.android.exoplayer2.drm.DrmInitData.SchemeData in project ExoPlayer by google.

the class DefaultDrmSessionManager method acquireSession.

// DrmSessionManager implementation.
@Override
public DrmSession<T> acquireSession(Looper playbackLooper, DrmInitData drmInitData) {
    Assertions.checkState(this.playbackLooper == null || this.playbackLooper == playbackLooper);
    if (++openCount != 1) {
        return this;
    }
    if (this.playbackLooper == null) {
        this.playbackLooper = playbackLooper;
        mediaDrmHandler = new MediaDrmHandler(playbackLooper);
        postResponseHandler = new PostResponseHandler(playbackLooper);
    }
    requestHandlerThread = new HandlerThread("DrmRequestHandler");
    requestHandlerThread.start();
    postRequestHandler = new PostRequestHandler(requestHandlerThread.getLooper());
    if (offlineLicenseKeySetId == null) {
        SchemeData schemeData = drmInitData.get(uuid);
        if (schemeData == null) {
            onError(new IllegalStateException("Media does not support uuid: " + uuid));
            return this;
        }
        schemeInitData = schemeData.data;
        schemeMimeType = schemeData.mimeType;
        if (Util.SDK_INT < 21) {
            // Prior to L the Widevine CDM required data to be extracted from the PSSH atom.
            byte[] psshData = PsshAtomUtil.parseSchemeSpecificData(schemeInitData, C.WIDEVINE_UUID);
            if (psshData == null) {
            // Extraction failed. schemeData isn't a Widevine PSSH atom, so leave it unchanged.
            } else {
                schemeInitData = psshData;
            }
        }
        if (Util.SDK_INT < 26 && C.CLEARKEY_UUID.equals(uuid) && (MimeTypes.VIDEO_MP4.equals(schemeMimeType) || MimeTypes.AUDIO_MP4.equals(schemeMimeType))) {
            // Prior to API level 26 the ClearKey CDM only accepted "cenc" as the scheme for MP4.
            schemeMimeType = CENC_SCHEME_MIME_TYPE;
        }
    }
    state = STATE_OPENING;
    openInternal(true);
    return this;
}
Also used : HandlerThread(android.os.HandlerThread) SchemeData(com.google.android.exoplayer2.drm.DrmInitData.SchemeData)

Aggregations

SchemeData (com.google.android.exoplayer2.drm.DrmInitData.SchemeData)6 DrmInitData (com.google.android.exoplayer2.drm.DrmInitData)3 Format (com.google.android.exoplayer2.Format)2 UUID (java.util.UUID)2 HandlerThread (android.os.HandlerThread)1 ParserException (com.google.android.exoplayer2.ParserException)1 LeafAtom (com.google.android.exoplayer2.extractor.mp4.Atom.LeafAtom)1 SegmentTemplate (com.google.android.exoplayer2.source.dash.manifest.SegmentBase.SegmentTemplate)1 SingleSegmentBase (com.google.android.exoplayer2.source.dash.manifest.SegmentBase.SingleSegmentBase)1 ArrayList (java.util.ArrayList)1