Search in sources :

Example 6 with MetadataInputBuffer

use of androidx.media3.extractor.metadata.MetadataInputBuffer in project media by androidx.

the class AppInfoTableDecoderTest method decode_failsIfArrayOffsetNonZero.

@Test
public void decode_failsIfArrayOffsetNonZero() {
    AppInfoTableDecoder decoder = new AppInfoTableDecoder();
    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 7 with MetadataInputBuffer

use of androidx.media3.extractor.metadata.MetadataInputBuffer in project media by androidx.

the class EventMessageDecoderTest method createMetadataInputBuffer.

/**
 * Create a new {@link MetadataInputBuffer} and copy {@code data} into the backing {@link
 * ByteBuffer}.
 */
// TODO(internal b/161804035): Use TestUtils when it's available in a dependency we can use here.
private static MetadataInputBuffer createMetadataInputBuffer(byte[] data) {
    MetadataInputBuffer buffer = new MetadataInputBuffer();
    buffer.data = ByteBuffer.allocate(data.length).put(data);
    buffer.data.flip();
    return buffer;
}
Also used : MetadataInputBuffer(androidx.media3.extractor.metadata.MetadataInputBuffer)

Example 8 with MetadataInputBuffer

use of androidx.media3.extractor.metadata.MetadataInputBuffer in project media by androidx.

the class IcyDecoderTest method decode_failsIfBufferHasNoArray.

@Test
public void decode_failsIfBufferHasNoArray() {
    MetadataInputBuffer buffer = createMetadataInputBuffer(createByteArray(1, 2, 3));
    buffer.data = buffer.data.asReadOnlyBuffer();
    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 9 with MetadataInputBuffer

use of androidx.media3.extractor.metadata.MetadataInputBuffer in project media by androidx.

the class SpliceInfoDecoderTest method decodeFailsIfBufferHasNoArray.

@Test
public void decodeFailsIfBufferHasNoArray() {
    MetadataInputBuffer buffer = createMetadataInputBuffer(createByteArray(1, 2, 3));
    buffer.data = buffer.data.asReadOnlyBuffer();
    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 10 with MetadataInputBuffer

use of androidx.media3.extractor.metadata.MetadataInputBuffer in project media by androidx.

the class TestUtil method createMetadataInputBuffer.

/**
 * Create a new {@link MetadataInputBuffer} and copy {@code data} into the backing {@link
 * ByteBuffer}.
 */
public static MetadataInputBuffer createMetadataInputBuffer(byte[] data) {
    MetadataInputBuffer buffer = new MetadataInputBuffer();
    buffer.data = ByteBuffer.allocate(data.length).put(data);
    buffer.data.flip();
    return buffer;
}
Also used : MetadataInputBuffer(androidx.media3.extractor.metadata.MetadataInputBuffer)

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