Search in sources :

Example 16 with Builder

use of com.google.android.exoplayer2.DefaultLoadControl.Builder in project ExoPlayer by google.

the class CssParserTest method testGetNextToken.

public void testGetNextToken() {
    String stringInput = " lorem:ipsum\n{dolor}#sit,amet;lorem:ipsum\r\t\f\ndolor(())\n";
    ParsableByteArray input = new ParsableByteArray(Util.getUtf8Bytes(stringInput));
    StringBuilder builder = new StringBuilder();
    assertEquals(CssParser.parseNextToken(input, builder), "lorem");
    assertEquals(CssParser.parseNextToken(input, builder), ":");
    assertEquals(CssParser.parseNextToken(input, builder), "ipsum");
    assertEquals(CssParser.parseNextToken(input, builder), "{");
    assertEquals(CssParser.parseNextToken(input, builder), "dolor");
    assertEquals(CssParser.parseNextToken(input, builder), "}");
    assertEquals(CssParser.parseNextToken(input, builder), "#sit");
    assertEquals(CssParser.parseNextToken(input, builder), ",");
    assertEquals(CssParser.parseNextToken(input, builder), "amet");
    assertEquals(CssParser.parseNextToken(input, builder), ";");
    assertEquals(CssParser.parseNextToken(input, builder), "lorem");
    assertEquals(CssParser.parseNextToken(input, builder), ":");
    assertEquals(CssParser.parseNextToken(input, builder), "ipsum");
    assertEquals(CssParser.parseNextToken(input, builder), "dolor");
    assertEquals(CssParser.parseNextToken(input, builder), "(");
    assertEquals(CssParser.parseNextToken(input, builder), "(");
    assertEquals(CssParser.parseNextToken(input, builder), ")");
    assertEquals(CssParser.parseNextToken(input, builder), ")");
    assertEquals(CssParser.parseNextToken(input, builder), null);
}
Also used : ParsableByteArray(com.google.android.exoplayer2.util.ParsableByteArray)

Example 17 with Builder

use of com.google.android.exoplayer2.DefaultLoadControl.Builder in project ExoPlayer by google.

the class MediaCodecAudioRenderer method getDecoderInfos.

/**
 * Returns a list of decoders that can decode media in the specified format, in the priority order
 * specified by the {@link MediaCodecSelector}. Note that since the {@link MediaCodecSelector}
 * only has access to {@link Format#sampleMimeType}, the list is not ordered to account for
 * whether each decoder supports the details of the format (e.g., taking into account the format's
 * profile, level, channel count and so on). {@link
 * MediaCodecUtil#getDecoderInfosSortedByFormatSupport} can be used to further sort the list into
 * an order where decoders that fully support the format come first.
 *
 * @param mediaCodecSelector The decoder selector.
 * @param format The {@link Format} for which a decoder is required.
 * @param requiresSecureDecoder Whether a secure decoder is required.
 * @param audioSink The {@link AudioSink} to which audio will be output.
 * @return A list of {@link MediaCodecInfo}s corresponding to decoders. May be empty.
 * @throws DecoderQueryException Thrown if there was an error querying decoders.
 */
private static List<MediaCodecInfo> getDecoderInfos(MediaCodecSelector mediaCodecSelector, Format format, boolean requiresSecureDecoder, AudioSink audioSink) throws DecoderQueryException {
    @Nullable String mimeType = format.sampleMimeType;
    if (mimeType == null) {
        return ImmutableList.of();
    }
    if (audioSink.supportsFormat(format)) {
        // The format is supported directly, so a codec is only needed for decryption.
        @Nullable MediaCodecInfo codecInfo = MediaCodecUtil.getDecryptOnlyDecoderInfo();
        if (codecInfo != null) {
            return ImmutableList.of(codecInfo);
        }
    }
    List<MediaCodecInfo> decoderInfos = mediaCodecSelector.getDecoderInfos(mimeType, requiresSecureDecoder, /* requiresTunnelingDecoder= */
    false);
    @Nullable String alternativeMimeType = MediaCodecUtil.getAlternativeCodecMimeType(format);
    if (alternativeMimeType == null) {
        return ImmutableList.copyOf(decoderInfos);
    }
    List<MediaCodecInfo> alternativeDecoderInfos = mediaCodecSelector.getDecoderInfos(alternativeMimeType, requiresSecureDecoder, /* requiresTunnelingDecoder= */
    false);
    return ImmutableList.<MediaCodecInfo>builder().addAll(decoderInfos).addAll(alternativeDecoderInfos).build();
}
Also used : MediaCodecInfo(com.google.android.exoplayer2.mediacodec.MediaCodecInfo) Nullable(androidx.annotation.Nullable)

Example 18 with Builder

use of com.google.android.exoplayer2.DefaultLoadControl.Builder in project ExoPlayer by google.

the class WebvttCssParserTest method getNextToken.

@Test
public void getNextToken() {
    String stringInput = " lorem:ipsum\n{dolor}#sit,amet;lorem:ipsum\r\t\f\ndolor(())\n";
    ParsableByteArray input = new ParsableByteArray(Util.getUtf8Bytes(stringInput));
    StringBuilder builder = new StringBuilder();
    assertThat(parseNextToken(input, builder)).isEqualTo("lorem");
    assertThat(parseNextToken(input, builder)).isEqualTo(":");
    assertThat(parseNextToken(input, builder)).isEqualTo("ipsum");
    assertThat(parseNextToken(input, builder)).isEqualTo("{");
    assertThat(parseNextToken(input, builder)).isEqualTo("dolor");
    assertThat(parseNextToken(input, builder)).isEqualTo("}");
    assertThat(parseNextToken(input, builder)).isEqualTo("#sit");
    assertThat(parseNextToken(input, builder)).isEqualTo(",");
    assertThat(parseNextToken(input, builder)).isEqualTo("amet");
    assertThat(parseNextToken(input, builder)).isEqualTo(";");
    assertThat(parseNextToken(input, builder)).isEqualTo("lorem");
    assertThat(parseNextToken(input, builder)).isEqualTo(":");
    assertThat(parseNextToken(input, builder)).isEqualTo("ipsum");
    assertThat(parseNextToken(input, builder)).isEqualTo("dolor");
    assertThat(parseNextToken(input, builder)).isEqualTo("(");
    assertThat(parseNextToken(input, builder)).isEqualTo("(");
    assertThat(parseNextToken(input, builder)).isEqualTo(")");
    assertThat(parseNextToken(input, builder)).isEqualTo(")");
    assertThat(parseNextToken(input, builder)).isNull();
}
Also used : ParsableByteArray(com.google.android.exoplayer2.util.ParsableByteArray) Test(org.junit.Test)

Example 19 with Builder

use of com.google.android.exoplayer2.DefaultLoadControl.Builder in project ExoPlayer by google.

the class DefaultLoadControlTest method setUp.

@Before
public void setUp() throws Exception {
    builder = new Builder();
    allocator = new DefaultAllocator(true, C.DEFAULT_BUFFER_SEGMENT_SIZE);
}
Also used : Builder(com.google.android.exoplayer2.DefaultLoadControl.Builder) DefaultAllocator(com.google.android.exoplayer2.upstream.DefaultAllocator) Before(org.junit.Before)

Example 20 with Builder

use of com.google.android.exoplayer2.DefaultLoadControl.Builder in project ExoPlayer by google.

the class PictureFrameTest method populateMediaMetadata_setsBuilderValues.

@Test
public void populateMediaMetadata_setsBuilderValues() {
    byte[] pictureData = new byte[] { -12, 52, 33, 85, 34, 22, 1, -55 };
    Metadata.Entry entry = new PictureFrame(/* pictureType= */
    MediaMetadata.PICTURE_TYPE_FRONT_COVER, /* mimeType= */
    MimeTypes.IMAGE_JPEG, /* description= */
    "an image", /* width= */
    4, /* height= */
    2, /* depth= */
    1, /* colors= */
    1, pictureData);
    MediaMetadata.Builder builder = MediaMetadata.EMPTY.buildUpon();
    entry.populateMediaMetadata(builder);
    MediaMetadata mediaMetadata = builder.build();
    assertThat(mediaMetadata.artworkData).isEqualTo(pictureData);
    assertThat(mediaMetadata.artworkDataType).isEqualTo(MediaMetadata.PICTURE_TYPE_FRONT_COVER);
}
Also used : MediaMetadata(com.google.android.exoplayer2.MediaMetadata) Metadata(com.google.android.exoplayer2.metadata.Metadata) MediaMetadata(com.google.android.exoplayer2.MediaMetadata) Test(org.junit.Test)

Aggregations

Test (org.junit.Test)12 Nullable (androidx.annotation.Nullable)7 MediaItem (com.google.android.exoplayer2.MediaItem)6 MediaMetadata (com.google.android.exoplayer2.MediaMetadata)5 Metadata (com.google.android.exoplayer2.metadata.Metadata)4 TrackGroupArray (com.google.android.exoplayer2.source.TrackGroupArray)3 ParametersBuilder (com.google.android.exoplayer2.trackselection.DefaultTrackSelector.ParametersBuilder)3 ImmutableList (com.google.common.collect.ImmutableList)3 Bundle (android.os.Bundle)2 FakeDataSource (com.google.android.exoplayer2.testutil.FakeDataSource)2 DefaultTrackSelector (com.google.android.exoplayer2.trackselection.DefaultTrackSelector)2 ParsableByteArray (com.google.android.exoplayer2.util.ParsableByteArray)2 MediaQueueItem (com.google.android.gms.cast.MediaQueueItem)2 SurfaceTexture (android.graphics.SurfaceTexture)1 PlaybackStateCompat (android.support.v4.media.session.PlaybackStateCompat)1 AbsoluteSizeSpan (android.text.style.AbsoluteSizeSpan)1 BackgroundColorSpan (android.text.style.BackgroundColorSpan)1 ForegroundColorSpan (android.text.style.ForegroundColorSpan)1 RelativeSizeSpan (android.text.style.RelativeSizeSpan)1 StrikethroughSpan (android.text.style.StrikethroughSpan)1