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);
}
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();
}
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();
}
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);
}
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);
}
Aggregations