Search in sources :

Example 1 with MetadataInputBuffer

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

the class EventSampleStreamTest method setUp.

@Before
public void setUp() {
    formatHolder = new FormatHolder();
    inputBuffer = new MetadataInputBuffer();
    eventMessageEncoder = new EventMessageEncoder();
}
Also used : MetadataInputBuffer(androidx.media3.extractor.metadata.MetadataInputBuffer) FormatHolder(androidx.media3.exoplayer.FormatHolder) EventMessageEncoder(androidx.media3.extractor.metadata.emsg.EventMessageEncoder) Before(org.junit.Before)

Example 2 with MetadataInputBuffer

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

the class Id3DecoderTest 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 3 with MetadataInputBuffer

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

the class Id3DecoderTest method decodeFailsIfBufferHasNoArray.

@Test
public void decodeFailsIfBufferHasNoArray() {
    Id3Decoder decoder = new Id3Decoder();
    MetadataInputBuffer buffer = createMetadataInputBuffer(createByteArray(1, 2, 3));
    buffer.data = buffer.data.asReadOnlyBuffer();
    assertThrows(IllegalArgumentException.class, () -> decoder.decode(buffer));
}
Also used : MetadataInputBuffer(androidx.media3.extractor.metadata.MetadataInputBuffer) Test(org.junit.Test)

Example 4 with MetadataInputBuffer

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

the class Id3DecoderTest method decodeFailsIfArrayOffsetNonZero.

@Test
public void decodeFailsIfArrayOffsetNonZero() {
    Id3Decoder decoder = new Id3Decoder();
    MetadataInputBuffer buffer = createMetadataInputBuffer(createByteArray(1, 2, 3));
    buffer.data.position(1);
    buffer.data = buffer.data.slice();
    assertThrows(IllegalArgumentException.class, () -> decoder.decode(buffer));
}
Also used : MetadataInputBuffer(androidx.media3.extractor.metadata.MetadataInputBuffer) Test(org.junit.Test)

Example 5 with MetadataInputBuffer

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

the class Id3DecoderTest method decodeFailsIfPositionNonZero.

@Test
public void decodeFailsIfPositionNonZero() {
    Id3Decoder decoder = new Id3Decoder();
    MetadataInputBuffer buffer = createMetadataInputBuffer(createByteArray(1, 2, 3));
    buffer.data.position(1);
    assertThrows(IllegalArgumentException.class, () -> decoder.decode(buffer));
}
Also used : MetadataInputBuffer(androidx.media3.extractor.metadata.MetadataInputBuffer) Test(org.junit.Test)

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