Search in sources :

Example 96 with Format

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

the class DecoderVideoRendererTest method setUp.

@Before
public void setUp() {
    surface = new Surface(new SurfaceTexture(/* texName= */
    0));
    renderer = new DecoderVideoRenderer(/* allowedJoiningTimeMs= */
    0, new Handler(), eventListener, /* maxDroppedFramesToNotify= */
    -1) {

        private final Phaser inputBuffersInCodecPhaser = new Phaser();

        @C.VideoOutputMode
        private int outputMode;

        @Override
        public String getName() {
            return "TestVideoRenderer";
        }

        @Override
        @Capabilities
        public int supportsFormat(Format format) {
            return RendererCapabilities.create(C.FORMAT_HANDLED);
        }

        @Override
        protected void setDecoderOutputMode(@C.VideoOutputMode int outputMode) {
            this.outputMode = outputMode;
        }

        @Override
        protected void renderOutputBufferToSurface(VideoDecoderOutputBuffer outputBuffer, Surface surface) {
        // Do nothing.
        }

        @Override
        protected void onQueueInputBuffer(DecoderInputBuffer buffer) {
            // Decoding is done on a background thread we have no control about from the test.
            // Ensure the background calls are predictably serialized by waiting for them to finish:
            // 1. Register queued input buffers here.
            // 2. Deregister the input buffer when it's cleared. If an input buffer is cleared it
            // will have been fully handled by the decoder.
            // 3. Send a message on the test thread to wait for all currently pending input buffers
            // to be cleared.
            // 4. The tests need to call ShadowLooper.idleMainThread() to execute the wait message
            // sent in step (3).
            int currentPhase = inputBuffersInCodecPhaser.register();
            new Handler().post(() -> inputBuffersInCodecPhaser.awaitAdvance(currentPhase));
            super.onQueueInputBuffer(buffer);
        }

        @Override
        protected SimpleDecoder<DecoderInputBuffer, ? extends VideoDecoderOutputBuffer, ? extends DecoderException> createDecoder(Format format, @Nullable CryptoConfig cryptoConfig) {
            return new SimpleDecoder<DecoderInputBuffer, VideoDecoderOutputBuffer, DecoderException>(new DecoderInputBuffer[10], new VideoDecoderOutputBuffer[10]) {

                @Override
                protected DecoderInputBuffer createInputBuffer() {
                    return new DecoderInputBuffer(DecoderInputBuffer.BUFFER_REPLACEMENT_MODE_DIRECT) {

                        @Override
                        public void clear() {
                            super.clear();
                            inputBuffersInCodecPhaser.arriveAndDeregister();
                        }
                    };
                }

                @Override
                protected VideoDecoderOutputBuffer createOutputBuffer() {
                    return new VideoDecoderOutputBuffer(this::releaseOutputBuffer);
                }

                @Override
                protected DecoderException createUnexpectedDecodeException(Throwable error) {
                    return new DecoderException("error", error);
                }

                @Nullable
                @Override
                protected DecoderException decode(DecoderInputBuffer inputBuffer, VideoDecoderOutputBuffer outputBuffer, boolean reset) {
                    outputBuffer.init(inputBuffer.timeUs, outputMode, /* supplementalData= */
                    null);
                    return null;
                }

                @Override
                public String getName() {
                    return "TestDecoder";
                }
            };
        }
    };
    renderer.setOutput(surface);
}
Also used : SimpleDecoder(com.google.android.exoplayer2.decoder.SimpleDecoder) Handler(android.os.Handler) Surface(android.view.Surface) VideoDecoderOutputBuffer(com.google.android.exoplayer2.decoder.VideoDecoderOutputBuffer) DecoderException(com.google.android.exoplayer2.decoder.DecoderException) SurfaceTexture(android.graphics.SurfaceTexture) Format(com.google.android.exoplayer2.Format) DecoderInputBuffer(com.google.android.exoplayer2.decoder.DecoderInputBuffer) RendererCapabilities(com.google.android.exoplayer2.RendererCapabilities) Phaser(java.util.concurrent.Phaser) CryptoConfig(com.google.android.exoplayer2.decoder.CryptoConfig) Nullable(androidx.annotation.Nullable) Before(org.junit.Before)

Example 97 with Format

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

the class DashUtilTest method loadDrmInitDataFromManifest.

@Test
public void loadDrmInitDataFromManifest() throws Exception {
    Period period = newPeriod(newAdaptationSet(newRepresentation(newDrmInitData())));
    Format format = DashUtil.loadFormatWithDrmInitData(DummyDataSource.INSTANCE, period);
    assertThat(format.drmInitData).isEqualTo(newDrmInitData());
}
Also used : Format(com.google.android.exoplayer2.Format) Period(com.google.android.exoplayer2.source.dash.manifest.Period) Test(org.junit.Test)

Example 98 with Format

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

the class DashUtilTest method loadDrmInitDataNoRepresentations.

@Test
public void loadDrmInitDataNoRepresentations() throws Exception {
    Period period = newPeriod(newAdaptationSet());
    Format format = DashUtil.loadFormatWithDrmInitData(DummyDataSource.INSTANCE, period);
    assertThat(format).isNull();
}
Also used : Format(com.google.android.exoplayer2.Format) Period(com.google.android.exoplayer2.source.dash.manifest.Period) Test(org.junit.Test)

Example 99 with Format

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

the class DashUtilTest method loadDrmInitDataMissing.

@Test
public void loadDrmInitDataMissing() throws Exception {
    Period period = newPeriod(newAdaptationSet(newRepresentation(null)));
    Format format = DashUtil.loadFormatWithDrmInitData(DummyDataSource.INSTANCE, period);
    assertThat(format.drmInitData).isNull();
}
Also used : Format(com.google.android.exoplayer2.Format) Period(com.google.android.exoplayer2.source.dash.manifest.Period) Test(org.junit.Test)

Example 100 with Format

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

the class DashUtilTest method loadDrmInitDataNoAdaptationSets.

@Test
public void loadDrmInitDataNoAdaptationSets() throws Exception {
    Period period = newPeriod();
    Format format = DashUtil.loadFormatWithDrmInitData(DummyDataSource.INSTANCE, period);
    assertThat(format).isNull();
}
Also used : Format(com.google.android.exoplayer2.Format) Period(com.google.android.exoplayer2.source.dash.manifest.Period) 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