use of androidx.media3.extractor.metadata.MetadataInputBuffer in project media by androidx.
the class IcyDecoderTest method decode_respectsLimit.
@Test
public // Check the decoder is reading MetadataInputBuffer.data.limit() correctly.
void decode_respectsLimit() {
byte[] icyTitle = "StreamTitle='test title';".getBytes(UTF_8);
byte[] icyUrl = "StreamURL='test_url';".getBytes(UTF_8);
byte[] paddedRawBytes = Bytes.concat(icyTitle, icyUrl);
MetadataInputBuffer metadataBuffer = createMetadataInputBuffer(paddedRawBytes);
// Stop before the stream URL.
metadataBuffer.data.limit(icyTitle.length);
Metadata metadata = decoder.decode(metadataBuffer);
assertThat(metadata.length()).isEqualTo(1);
IcyInfo streamInfo = (IcyInfo) metadata.get(0);
assertThat(streamInfo.rawMetadata).isEqualTo(icyTitle);
assertThat(streamInfo.title).isEqualTo("test title");
assertThat(streamInfo.url).isNull();
}
use of androidx.media3.extractor.metadata.MetadataInputBuffer in project media by androidx.
the class IcyDecoderTest method decode_failsIfArrayOffsetNonZero.
@Test
public void decode_failsIfArrayOffsetNonZero() {
MetadataInputBuffer buffer = createMetadataInputBuffer(createByteArray(1, 2, 3));
buffer.data.position(1);
buffer.data = buffer.data.slice();
assertThrows(IllegalArgumentException.class, () -> decoder.decode(buffer));
}
use of androidx.media3.extractor.metadata.MetadataInputBuffer in project media by androidx.
the class SpliceInfoDecoderTest method decodeFailsIfArrayOffsetNonZero.
@Test
public void decodeFailsIfArrayOffsetNonZero() {
MetadataInputBuffer buffer = createMetadataInputBuffer(createByteArray(1, 2, 3));
buffer.data.position(1);
buffer.data = buffer.data.slice();
assertThrows(IllegalArgumentException.class, () -> decoder.decode(buffer));
}
use of androidx.media3.extractor.metadata.MetadataInputBuffer in project media by androidx.
the class SpliceInfoDecoderTest method decodeFailsIfPositionNonZero.
@Test
public void decodeFailsIfPositionNonZero() {
MetadataInputBuffer buffer = createMetadataInputBuffer(createByteArray(1, 2, 3));
buffer.data.position(1);
assertThrows(IllegalArgumentException.class, () -> decoder.decode(buffer));
}
use of androidx.media3.extractor.metadata.MetadataInputBuffer in project media by androidx.
the class SpliceInfoDecoderTest method setUp.
@Before
public void setUp() {
decoder = new SpliceInfoDecoder();
inputBuffer = new MetadataInputBuffer();
}
Aggregations