Search in sources :

Example 1 with EventMessageEncoder

use of androidx.media3.extractor.metadata.emsg.EventMessageEncoder 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 EventMessageEncoder

use of androidx.media3.extractor.metadata.emsg.EventMessageEncoder in project media by androidx.

the class EventMessageEncoderTest method encodeDecodeEventStream.

@Test
public void encodeDecodeEventStream() throws IOException {
    byte[] encodedByteArray = new EventMessageEncoder().encode(DECODED_MESSAGE);
    MetadataInputBuffer buffer = createMetadataInputBuffer(encodedByteArray);
    EventMessageDecoder decoder = new EventMessageDecoder();
    Metadata metadata = decoder.decode(buffer);
    assertThat(metadata.length()).isEqualTo(1);
    assertThat(metadata.get(0)).isEqualTo(DECODED_MESSAGE);
}
Also used : MetadataInputBuffer(androidx.media3.extractor.metadata.MetadataInputBuffer) Metadata(androidx.media3.common.Metadata) Test(org.junit.Test)

Example 3 with EventMessageEncoder

use of androidx.media3.extractor.metadata.emsg.EventMessageEncoder in project media by androidx.

the class EventMessageEncoderTest method encodeDecodeEventMessage_durationNotSet.

// https://github.com/google/ExoPlayer/issues/9123
@Test
public void encodeDecodeEventMessage_durationNotSet() {
    EventMessage originalMessage = new EventMessage("urn:test", "456", C.TIME_UNSET, 99, new byte[] { 7, 8, 9 });
    byte[] encodedMessage = new EventMessageEncoder().encode(originalMessage);
    EventMessage decodedMessage = new EventMessageDecoder().decode(new ParsableByteArray(encodedMessage));
    assertThat(decodedMessage).isEqualTo(originalMessage);
}
Also used : ParsableByteArray(androidx.media3.common.util.ParsableByteArray) Test(org.junit.Test)

Aggregations

MetadataInputBuffer (androidx.media3.extractor.metadata.MetadataInputBuffer)2 Test (org.junit.Test)2 Metadata (androidx.media3.common.Metadata)1 ParsableByteArray (androidx.media3.common.util.ParsableByteArray)1 FormatHolder (androidx.media3.exoplayer.FormatHolder)1 EventMessageEncoder (androidx.media3.extractor.metadata.emsg.EventMessageEncoder)1 Before (org.junit.Before)1