Search in sources :

Example 16 with Format

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

the class TrackGroupArrayTest method roundTripViaBundle_ofTrackGroupArray_yieldsEqualInstance.

@Test
public void roundTripViaBundle_ofTrackGroupArray_yieldsEqualInstance() {
    Format.Builder formatBuilder = new Format.Builder();
    Format format1 = formatBuilder.setSampleMimeType(MimeTypes.VIDEO_H264).build();
    Format format2 = formatBuilder.setSampleMimeType(MimeTypes.AUDIO_AAC).build();
    Format format3 = formatBuilder.setSampleMimeType(MimeTypes.VIDEO_H264).build();
    TrackGroup trackGroup1 = new TrackGroup(format1, format2);
    TrackGroup trackGroup2 = new TrackGroup(format3);
    TrackGroupArray trackGroupArrayToBundle = new TrackGroupArray(trackGroup1, trackGroup2);
    TrackGroupArray trackGroupArrayFromBundle = TrackGroupArray.CREATOR.fromBundle(trackGroupArrayToBundle.toBundle());
    assertThat(trackGroupArrayFromBundle).isEqualTo(trackGroupArrayToBundle);
}
Also used : Format(com.google.android.exoplayer2.Format) Test(org.junit.Test)

Example 17 with Format

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

the class MediaMetricsListener method onVideoSizeChanged.

@Override
public void onVideoSizeChanged(EventTime eventTime, VideoSize videoSize) {
    @Nullable PendingFormatUpdate pendingVideoFormat = this.pendingVideoFormat;
    if (pendingVideoFormat != null && pendingVideoFormat.format.height == Format.NO_VALUE) {
        Format formatWithHeightAndWidth = pendingVideoFormat.format.buildUpon().setWidth(videoSize.width).setHeight(videoSize.height).build();
        this.pendingVideoFormat = new PendingFormatUpdate(formatWithHeightAndWidth, pendingVideoFormat.selectionReason, pendingVideoFormat.sessionId);
    }
}
Also used : Format(com.google.android.exoplayer2.Format) Nullable(androidx.annotation.Nullable)

Example 18 with Format

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

the class DecoderAudioRenderer method onInputFormatChanged.

private void onInputFormatChanged(FormatHolder formatHolder) throws ExoPlaybackException {
    Format newFormat = Assertions.checkNotNull(formatHolder.format);
    setSourceDrmSession(formatHolder.drmSession);
    Format oldFormat = inputFormat;
    inputFormat = newFormat;
    encoderDelay = newFormat.encoderDelay;
    encoderPadding = newFormat.encoderPadding;
    if (decoder == null) {
        maybeInitDecoder();
        eventDispatcher.inputFormatChanged(inputFormat, /* decoderReuseEvaluation= */
        null);
        return;
    }
    DecoderReuseEvaluation evaluation;
    if (sourceDrmSession != decoderDrmSession) {
        evaluation = new DecoderReuseEvaluation(decoder.getName(), oldFormat, newFormat, REUSE_RESULT_NO, DISCARD_REASON_DRM_SESSION_CHANGED);
    } else {
        evaluation = canReuseDecoder(decoder.getName(), oldFormat, newFormat);
    }
    if (evaluation.result == REUSE_RESULT_NO) {
        if (decoderReceivedBuffers) {
            // Signal end of stream and wait for any final output buffers before re-initialization.
            decoderReinitializationState = REINITIALIZATION_STATE_SIGNAL_END_OF_STREAM;
        } else {
            // There aren't any final output buffers, so release the decoder immediately.
            releaseDecoder();
            maybeInitDecoder();
            audioTrackNeedsConfigure = true;
        }
    }
    eventDispatcher.inputFormatChanged(inputFormat, evaluation);
}
Also used : Format(com.google.android.exoplayer2.Format) DecoderReuseEvaluation(com.google.android.exoplayer2.decoder.DecoderReuseEvaluation)

Example 19 with Format

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

the class MediaCodecAudioRenderer method onOutputFormatChanged.

@Override
protected void onOutputFormatChanged(Format format, @Nullable MediaFormat mediaFormat) throws ExoPlaybackException {
    Format audioSinkInputFormat;
    @Nullable int[] channelMap = null;
    if (decryptOnlyCodecFormat != null) {
        // Direct playback with a codec for decryption.
        audioSinkInputFormat = decryptOnlyCodecFormat;
    } else if (getCodec() == null) {
        // Direct playback with codec bypass.
        audioSinkInputFormat = format;
    } else {
        @C.PcmEncoding int pcmEncoding;
        if (MimeTypes.AUDIO_RAW.equals(format.sampleMimeType)) {
            // For PCM streams, the encoder passes through int samples despite set to float mode.
            pcmEncoding = format.pcmEncoding;
        } else if (Util.SDK_INT >= 24 && mediaFormat.containsKey(MediaFormat.KEY_PCM_ENCODING)) {
            pcmEncoding = mediaFormat.getInteger(MediaFormat.KEY_PCM_ENCODING);
        } else if (mediaFormat.containsKey(VIVO_BITS_PER_SAMPLE_KEY)) {
            pcmEncoding = Util.getPcmEncoding(mediaFormat.getInteger(VIVO_BITS_PER_SAMPLE_KEY));
        } else {
            // If the format is anything other than PCM then we assume that the audio decoder will
            // output 16-bit PCM.
            pcmEncoding = C.ENCODING_PCM_16BIT;
        }
        audioSinkInputFormat = new Format.Builder().setSampleMimeType(MimeTypes.AUDIO_RAW).setPcmEncoding(pcmEncoding).setEncoderDelay(format.encoderDelay).setEncoderPadding(format.encoderPadding).setChannelCount(mediaFormat.getInteger(MediaFormat.KEY_CHANNEL_COUNT)).setSampleRate(mediaFormat.getInteger(MediaFormat.KEY_SAMPLE_RATE)).build();
        if (codecNeedsDiscardChannelsWorkaround && audioSinkInputFormat.channelCount == 6 && format.channelCount < 6) {
            channelMap = new int[format.channelCount];
            for (int i = 0; i < format.channelCount; i++) {
                channelMap[i] = i;
            }
        }
    }
    try {
        audioSink.configure(audioSinkInputFormat, /* specifiedBufferSize= */
        0, channelMap);
    } catch (AudioSink.ConfigurationException e) {
        throw createRendererException(e, e.format, PlaybackException.ERROR_CODE_AUDIO_TRACK_INIT_FAILED);
    }
}
Also used : MediaFormat(android.media.MediaFormat) AudioFormat(android.media.AudioFormat) Format(com.google.android.exoplayer2.Format) Nullable(androidx.annotation.Nullable)

Example 20 with Format

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

the class MediaFormatUtilTest method createMediaFormatFromFormat_withPcmEncoding_setsCustomPcmEncodingEntry.

@Test
public void createMediaFormatFromFormat_withPcmEncoding_setsCustomPcmEncodingEntry() {
    Format format = new Format.Builder().setPcmEncoding(C.ENCODING_PCM_16BIT_BIG_ENDIAN).build();
    MediaFormat mediaFormat = MediaFormatUtil.createMediaFormatFromFormat(format);
    assertThat(mediaFormat.getInteger(MediaFormatUtil.KEY_PCM_ENCODING_EXTENDED)).isEqualTo(C.ENCODING_PCM_16BIT_BIG_ENDIAN);
    assertThat(mediaFormat.containsKey(MediaFormat.KEY_PCM_ENCODING)).isFalse();
}
Also used : MediaFormat(android.media.MediaFormat) Format(com.google.android.exoplayer2.Format) MediaFormat(android.media.MediaFormat) Test(org.junit.Test)

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