Search in sources :

Example 11 with Format

use of org.geotoolkit.wps.xml.v200.Format in project ExoPlayer by google.

the class DashManifestParser method buildRepresentation.

protected Representation buildRepresentation(RepresentationInfo representationInfo, String contentId, ArrayList<SchemeData> extraDrmSchemeDatas, ArrayList<SchemeValuePair> extraInbandEventStreams) {
    Format format = representationInfo.format;
    ArrayList<SchemeData> drmSchemeDatas = representationInfo.drmSchemeDatas;
    drmSchemeDatas.addAll(extraDrmSchemeDatas);
    if (!drmSchemeDatas.isEmpty()) {
        format = format.copyWithDrmInitData(new DrmInitData(drmSchemeDatas));
    }
    ArrayList<SchemeValuePair> inbandEventStremas = representationInfo.inbandEventStreams;
    inbandEventStremas.addAll(extraInbandEventStreams);
    return Representation.newInstance(contentId, Representation.REVISION_ID_DEFAULT, format, representationInfo.baseUrl, representationInfo.segmentBase, inbandEventStremas);
}
Also used : Format(com.google.android.exoplayer2.Format) DrmInitData(com.google.android.exoplayer2.drm.DrmInitData) SchemeData(com.google.android.exoplayer2.drm.DrmInitData.SchemeData)

Example 12 with Format

use of org.geotoolkit.wps.xml.v200.Format in project ExoPlayer by google.

the class DashMediaPeriod method buildTrackGroups.

// Internal methods.
private static Pair<TrackGroupArray, EmbeddedTrackInfo[]> buildTrackGroups(List<AdaptationSet> adaptationSets) {
    int adaptationSetCount = adaptationSets.size();
    int embeddedTrackCount = getEmbeddedTrackCount(adaptationSets);
    TrackGroup[] trackGroupArray = new TrackGroup[adaptationSetCount + embeddedTrackCount];
    EmbeddedTrackInfo[] embeddedTrackInfos = new EmbeddedTrackInfo[embeddedTrackCount];
    int embeddedTrackIndex = 0;
    for (int i = 0; i < adaptationSetCount; i++) {
        AdaptationSet adaptationSet = adaptationSets.get(i);
        List<Representation> representations = adaptationSet.representations;
        Format[] formats = new Format[representations.size()];
        for (int j = 0; j < formats.length; j++) {
            formats[j] = representations.get(j).format;
        }
        trackGroupArray[i] = new TrackGroup(formats);
        if (hasEventMessageTrack(adaptationSet)) {
            Format format = Format.createSampleFormat(adaptationSet.id + ":emsg", MimeTypes.APPLICATION_EMSG, null, Format.NO_VALUE, null);
            trackGroupArray[adaptationSetCount + embeddedTrackIndex] = new TrackGroup(format);
            embeddedTrackInfos[embeddedTrackIndex++] = new EmbeddedTrackInfo(i, C.TRACK_TYPE_METADATA);
        }
        if (hasCea608Track(adaptationSet)) {
            Format format = Format.createTextSampleFormat(adaptationSet.id + ":cea608", MimeTypes.APPLICATION_CEA608, null, Format.NO_VALUE, 0, null, null);
            trackGroupArray[adaptationSetCount + embeddedTrackIndex] = new TrackGroup(format);
            embeddedTrackInfos[embeddedTrackIndex++] = new EmbeddedTrackInfo(i, C.TRACK_TYPE_TEXT);
        }
    }
    return Pair.create(new TrackGroupArray(trackGroupArray), embeddedTrackInfos);
}
Also used : Format(com.google.android.exoplayer2.Format) TrackGroup(com.google.android.exoplayer2.source.TrackGroup) TrackGroupArray(com.google.android.exoplayer2.source.TrackGroupArray) AdaptationSet(com.google.android.exoplayer2.source.dash.manifest.AdaptationSet) Representation(com.google.android.exoplayer2.source.dash.manifest.Representation)

Example 13 with Format

use of org.geotoolkit.wps.xml.v200.Format in project AntennaPod by AntennaPod.

the class ExoPlayerWrapper method getAudioTracks.

@Override
public List<String> getAudioTracks() {
    List<String> trackNames = new ArrayList<>();
    TrackNameProvider trackNameProvider = new DefaultTrackNameProvider(context.getResources());
    for (Format format : getFormats()) {
        trackNames.add(trackNameProvider.getTrackName(format));
    }
    return trackNames;
}
Also used : DefaultTrackNameProvider(com.google.android.exoplayer2.ui.DefaultTrackNameProvider) Format(com.google.android.exoplayer2.Format) ArrayList(java.util.ArrayList) DefaultTrackNameProvider(com.google.android.exoplayer2.ui.DefaultTrackNameProvider) TrackNameProvider(com.google.android.exoplayer2.ui.TrackNameProvider)

Example 14 with Format

use of org.geotoolkit.wps.xml.v200.Format in project AntennaPod by AntennaPod.

the class ExoPlayerWrapper method getFormats.

private List<Format> getFormats() {
    List<Format> formats = new ArrayList<>();
    MappingTrackSelector.MappedTrackInfo trackInfo = trackSelector.getCurrentMappedTrackInfo();
    if (trackInfo == null) {
        return Collections.emptyList();
    }
    TrackGroupArray trackGroups = trackInfo.getTrackGroups(getAudioRendererIndex());
    for (int i = 0; i < trackGroups.length; i++) {
        formats.add(trackGroups.get(i).getFormat(0));
    }
    return formats;
}
Also used : Format(com.google.android.exoplayer2.Format) MappingTrackSelector(com.google.android.exoplayer2.trackselection.MappingTrackSelector) ArrayList(java.util.ArrayList) TrackGroupArray(com.google.android.exoplayer2.source.TrackGroupArray)

Example 15 with Format

use of org.geotoolkit.wps.xml.v200.Format in project ExoPlayer by google.

the class MetadataRenderer method decodeWrappedMetadata.

/**
 * Iterates through {@code metadata.entries} and checks each one to see if contains wrapped
 * metadata. If it does, then we recursively decode the wrapped metadata. If it doesn't (recursion
 * base-case), we add the {@link Metadata.Entry} to {@code decodedEntries} (output parameter).
 */
private void decodeWrappedMetadata(Metadata metadata, List<Metadata.Entry> decodedEntries) {
    for (int i = 0; i < metadata.length(); i++) {
        @Nullable Format wrappedMetadataFormat = metadata.get(i).getWrappedMetadataFormat();
        if (wrappedMetadataFormat != null && decoderFactory.supportsFormat(wrappedMetadataFormat)) {
            MetadataDecoder wrappedMetadataDecoder = decoderFactory.createDecoder(wrappedMetadataFormat);
            // wrappedMetadataFormat != null so wrappedMetadataBytes must be non-null too.
            byte[] wrappedMetadataBytes = Assertions.checkNotNull(metadata.get(i).getWrappedMetadataBytes());
            buffer.clear();
            buffer.ensureSpaceForWrite(wrappedMetadataBytes.length);
            castNonNull(buffer.data).put(wrappedMetadataBytes);
            buffer.flip();
            @Nullable Metadata innerMetadata = wrappedMetadataDecoder.decode(buffer);
            if (innerMetadata != null) {
                // The decoding succeeded, so we'll try another level of unwrapping.
                decodeWrappedMetadata(innerMetadata, decodedEntries);
            }
        } else {
            // Entry doesn't contain any wrapped metadata, so output it directly.
            decodedEntries.add(metadata.get(i));
        }
    }
}
Also used : Format(com.google.android.exoplayer2.Format) Nullable(androidx.annotation.Nullable)

Aggregations

Format (com.google.android.exoplayer2.Format)313 Test (org.junit.Test)132 TrackGroup (com.google.android.exoplayer2.source.TrackGroup)66 TrackGroupArray (com.google.android.exoplayer2.source.TrackGroupArray)60 Nullable (androidx.annotation.Nullable)47 RendererCapabilities (com.google.android.exoplayer2.RendererCapabilities)37 ArrayList (java.util.ArrayList)31 MediaFormat (android.media.MediaFormat)24 Data (org.geotoolkit.wps.xml.v200.Data)19 HashMap (java.util.HashMap)16 Format (org.geotoolkit.wps.xml.v200.Format)16 SuppressLint (android.annotation.SuppressLint)15 Point (android.graphics.Point)15 Capabilities (com.google.android.exoplayer2.RendererCapabilities.Capabilities)12 UnconvertibleObjectException (org.apache.sis.util.UnconvertibleObjectException)12 DecoderReuseEvaluation (com.google.android.exoplayer2.decoder.DecoderReuseEvaluation)11 Metadata (com.google.android.exoplayer2.metadata.Metadata)11 ImmutableList (com.google.common.collect.ImmutableList)11 ComplexData (org.geotoolkit.wps.xml.v200.ComplexData)9 C (com.google.android.exoplayer2.C)8