Search in sources :

Example 21 with MetadataInputBuffer

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();
}
Also used : TestUtil.createMetadataInputBuffer(androidx.media3.test.utils.TestUtil.createMetadataInputBuffer) MetadataInputBuffer(androidx.media3.extractor.metadata.MetadataInputBuffer) Metadata(androidx.media3.common.Metadata) Test(org.junit.Test)

Example 22 with MetadataInputBuffer

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));
}
Also used : TestUtil.createMetadataInputBuffer(androidx.media3.test.utils.TestUtil.createMetadataInputBuffer) MetadataInputBuffer(androidx.media3.extractor.metadata.MetadataInputBuffer) Test(org.junit.Test)

Example 23 with MetadataInputBuffer

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));
}
Also used : TestUtil.createMetadataInputBuffer(androidx.media3.test.utils.TestUtil.createMetadataInputBuffer) MetadataInputBuffer(androidx.media3.extractor.metadata.MetadataInputBuffer) Test(org.junit.Test)

Example 24 with MetadataInputBuffer

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));
}
Also used : TestUtil.createMetadataInputBuffer(androidx.media3.test.utils.TestUtil.createMetadataInputBuffer) MetadataInputBuffer(androidx.media3.extractor.metadata.MetadataInputBuffer) Test(org.junit.Test)

Example 25 with MetadataInputBuffer

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();
}
Also used : TestUtil.createMetadataInputBuffer(androidx.media3.test.utils.TestUtil.createMetadataInputBuffer) MetadataInputBuffer(androidx.media3.extractor.metadata.MetadataInputBuffer) Before(org.junit.Before)

Aggregations

MetadataInputBuffer (androidx.media3.extractor.metadata.MetadataInputBuffer)23 Test (org.junit.Test)17 TestUtil.createMetadataInputBuffer (androidx.media3.test.utils.TestUtil.createMetadataInputBuffer)11 Metadata (androidx.media3.common.Metadata)4 Nullable (androidx.annotation.Nullable)2 Before (org.junit.Before)2 TimestampAdjuster (androidx.media3.common.util.TimestampAdjuster)1 FormatHolder (androidx.media3.exoplayer.FormatHolder)1 EventMessageEncoder (androidx.media3.extractor.metadata.emsg.EventMessageEncoder)1 Matcher (java.util.regex.Matcher)1