Search in sources :

Example 31 with DrmInitData

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

the class FragmentedMp4Extractor method onMoovContainerAtomRead.

private void onMoovContainerAtomRead(ContainerAtom moov) throws ParserException {
    checkState(sideloadedTrack == null, "Unexpected moov box.");
    @Nullable DrmInitData drmInitData = getDrmInitDataFromAtoms(moov.leafChildren);
    // Read declaration of track fragments in the moov box.
    ContainerAtom mvex = checkNotNull(moov.getContainerAtomOfType(Atom.TYPE_mvex));
    SparseArray<DefaultSampleValues> defaultSampleValuesArray = new SparseArray<>();
    long duration = C.TIME_UNSET;
    int mvexChildrenSize = mvex.leafChildren.size();
    for (int i = 0; i < mvexChildrenSize; i++) {
        Atom.LeafAtom atom = mvex.leafChildren.get(i);
        if (atom.type == Atom.TYPE_trex) {
            Pair<Integer, DefaultSampleValues> trexData = parseTrex(atom.data);
            defaultSampleValuesArray.put(trexData.first, trexData.second);
        } else if (atom.type == Atom.TYPE_mehd) {
            duration = parseMehd(atom.data);
        }
    }
    // Construction of tracks and sample tables.
    List<TrackSampleTable> sampleTables = parseTraks(moov, new GaplessInfoHolder(), duration, drmInitData, /* ignoreEditLists= */
    (flags & FLAG_WORKAROUND_IGNORE_EDIT_LISTS) != 0, /* isQuickTime= */
    false, this::modifyTrack);
    int trackCount = sampleTables.size();
    if (trackBundles.size() == 0) {
        // We need to create the track bundles.
        for (int i = 0; i < trackCount; i++) {
            TrackSampleTable sampleTable = sampleTables.get(i);
            Track track = sampleTable.track;
            TrackBundle trackBundle = new TrackBundle(extractorOutput.track(i, track.type), sampleTable, getDefaultSampleValues(defaultSampleValuesArray, track.id));
            trackBundles.put(track.id, trackBundle);
            durationUs = max(durationUs, track.durationUs);
        }
        extractorOutput.endTracks();
    } else {
        checkState(trackBundles.size() == trackCount);
        for (int i = 0; i < trackCount; i++) {
            TrackSampleTable sampleTable = sampleTables.get(i);
            Track track = sampleTable.track;
            trackBundles.get(track.id).reset(sampleTable, getDefaultSampleValues(defaultSampleValuesArray, track.id));
        }
    }
}
Also used : ContainerAtom(com.google.android.exoplayer2.extractor.mp4.Atom.ContainerAtom) LeafAtom(com.google.android.exoplayer2.extractor.mp4.Atom.LeafAtom) ContainerAtom(com.google.android.exoplayer2.extractor.mp4.Atom.ContainerAtom) LeafAtom(com.google.android.exoplayer2.extractor.mp4.Atom.LeafAtom) SparseArray(android.util.SparseArray) DrmInitData(com.google.android.exoplayer2.drm.DrmInitData) GaplessInfoHolder(com.google.android.exoplayer2.extractor.GaplessInfoHolder) Nullable(androidx.annotation.Nullable)

Aggregations

DrmInitData (com.google.android.exoplayer2.drm.DrmInitData)17 Nullable (androidx.annotation.Nullable)16 Format (com.google.android.exoplayer2.Format)10 SchemeData (com.google.android.exoplayer2.drm.DrmInitData.SchemeData)10 ArrayList (java.util.ArrayList)10 Metadata (com.google.android.exoplayer2.metadata.Metadata)5 SuppressLint (android.annotation.SuppressLint)4 Uri (android.net.Uri)4 TrackGroup (com.google.android.exoplayer2.source.TrackGroup)3 ColorInfo (com.google.android.exoplayer2.video.ColorInfo)3 MediaFormat (android.media.MediaFormat)2 Looper (android.os.Looper)2 AndroidJUnit4 (androidx.test.ext.junit.runners.AndroidJUnit4)2 C (com.google.android.exoplayer2.C)2 PlayerId (com.google.android.exoplayer2.analytics.PlayerId)2 DrmSessionReference (com.google.android.exoplayer2.drm.DrmSessionManager.DrmSessionReference)2 AppManagedProvider (com.google.android.exoplayer2.drm.ExoMediaDrm.AppManagedProvider)2 GaplessInfoHolder (com.google.android.exoplayer2.extractor.GaplessInfoHolder)2 SeekPoint (com.google.android.exoplayer2.extractor.SeekPoint)2 ContainerAtom (com.google.android.exoplayer2.extractor.mp4.Atom.ContainerAtom)2