use of androidx.media3.extractor.metadata.emsg.EventMessage in project media by androidx.
the class EventSampleStreamTest method readDataOutOfBoundReturnEndOfStreamAfterFormatForNonDynamicEventSampleStream.
/**
* Tests that a non-dynamic {@link EventSampleStream} will return a buffer with {@link
* C#BUFFER_FLAG_END_OF_STREAM} when trying to read sample out-of-bound.
*/
@Test
public void readDataOutOfBoundReturnEndOfStreamAfterFormatForNonDynamicEventSampleStream() {
EventStream eventStream = new EventStream(SCHEME_ID, VALUE, TIME_SCALE, new long[0], new EventMessage[0]);
EventSampleStream sampleStream = new EventSampleStream(eventStream, FORMAT, false);
// first read - read format
readData(sampleStream);
int result = readData(sampleStream);
assertThat(result).isEqualTo(C.RESULT_BUFFER_READ);
assertThat(inputBuffer.isEndOfStream()).isTrue();
}
use of androidx.media3.extractor.metadata.emsg.EventMessage in project media by androidx.
the class EventSampleStreamTest method seekToUsThenUpdateStreamContinueToReadFromSeekPosition.
/**
* Tests that {@link EventSampleStream#updateEventStream(EventStream, boolean)} will update the
* underlying event stream, but keep the timestamp the stream has seek to, so the next {@link
* EventSampleStream#readData(FormatHolder, DecoderInputBuffer, int)} call will return sample data
* from the seek position.
*/
@Test
public void seekToUsThenUpdateStreamContinueToReadFromSeekPosition() {
long presentationTimeUs1 = 1000000;
long presentationTimeUs2 = 2000000;
long presentationTimeUs3 = 3000000;
EventMessage eventMessage1 = newEventMessageWithId(1);
EventMessage eventMessage2 = newEventMessageWithId(2);
EventMessage eventMessage3 = newEventMessageWithId(3);
EventStream eventStream1 = new EventStream(SCHEME_ID, VALUE, TIME_SCALE, new long[] { presentationTimeUs1, presentationTimeUs2 }, new EventMessage[] { eventMessage1, eventMessage2 });
EventStream eventStream2 = new EventStream(SCHEME_ID, VALUE, TIME_SCALE, new long[] { presentationTimeUs1, presentationTimeUs2, presentationTimeUs3 }, new EventMessage[] { eventMessage1, eventMessage2, eventMessage3 });
EventSampleStream sampleStream = new EventSampleStream(eventStream1, FORMAT, true);
// first read - read format
readData(sampleStream);
sampleStream.seekToUs(presentationTimeUs2);
sampleStream.updateEventStream(eventStream2, true);
int result = readData(sampleStream);
assertThat(result).isEqualTo(C.RESULT_BUFFER_READ);
assertThat(inputBuffer.data.array()).isEqualTo(getEncodedMessage(eventMessage2));
}
use of androidx.media3.extractor.metadata.emsg.EventMessage in project media by androidx.
the class EventSampleStreamTest method readDataReturnDataAfterFormat.
/**
* Tests that {@link EventSampleStream#readData(FormatHolder, DecoderInputBuffer, int)} will
* return sample data after the first call.
*/
@Test
public void readDataReturnDataAfterFormat() {
long presentationTimeUs = 1000000;
EventMessage eventMessage = newEventMessageWithId(1);
EventStream eventStream = new EventStream(SCHEME_ID, VALUE, TIME_SCALE, new long[] { presentationTimeUs }, new EventMessage[] { eventMessage });
EventSampleStream sampleStream = new EventSampleStream(eventStream, FORMAT, false);
// first read - read format
readData(sampleStream);
int result = readData(sampleStream);
assertThat(result).isEqualTo(C.RESULT_BUFFER_READ);
assertThat(inputBuffer.data.array()).isEqualTo(getEncodedMessage(eventMessage));
}
use of androidx.media3.extractor.metadata.emsg.EventMessage in project media by androidx.
the class EventSampleStreamTest method seekToUsThenReadDataReturnDataFromSeekPosition.
/**
* Tests that {@link EventSampleStream#seekToUs(long)} (long)} will seek to the given position,
* and the next {@link EventSampleStream#readData(FormatHolder, DecoderInputBuffer, int)} call
* will return sample data from that position.
*/
@Test
public void seekToUsThenReadDataReturnDataFromSeekPosition() {
long presentationTimeUs1 = 1000000;
long presentationTimeUs2 = 2000000;
EventMessage eventMessage1 = newEventMessageWithId(1);
EventMessage eventMessage2 = newEventMessageWithId(2);
EventStream eventStream = new EventStream(SCHEME_ID, VALUE, TIME_SCALE, new long[] { presentationTimeUs1, presentationTimeUs2 }, new EventMessage[] { eventMessage1, eventMessage2 });
EventSampleStream sampleStream = new EventSampleStream(eventStream, FORMAT, false);
// first read - read format
readData(sampleStream);
sampleStream.seekToUs(presentationTimeUs2);
int result = readData(sampleStream);
assertThat(result).isEqualTo(C.RESULT_BUFFER_READ);
assertThat(inputBuffer.data.array()).isEqualTo(getEncodedMessage(eventMessage2));
}
use of androidx.media3.extractor.metadata.emsg.EventMessage in project media by androidx.
the class EventSampleStreamTest method skipDataThenUpdateStreamContinueToReadFromSkippedPosition.
/**
* Tests that {@link EventSampleStream#updateEventStream(EventStream, boolean)} will update the
* underlying event stream, but keep the timestamp the stream has skipped to, so the next {@link
* EventSampleStream#readData(FormatHolder, DecoderInputBuffer, int)} call will return sample data
* from the skipped position.
*/
@Test
public void skipDataThenUpdateStreamContinueToReadFromSkippedPosition() {
long presentationTimeUs1 = 1000000;
long presentationTimeUs2 = 2000000;
long presentationTimeUs3 = 3000000;
EventMessage eventMessage1 = newEventMessageWithId(1);
EventMessage eventMessage2 = newEventMessageWithId(2);
EventMessage eventMessage3 = newEventMessageWithId(3);
EventStream eventStream1 = new EventStream(SCHEME_ID, VALUE, TIME_SCALE, new long[] { presentationTimeUs1, presentationTimeUs2 }, new EventMessage[] { eventMessage1, eventMessage2 });
EventStream eventStream2 = new EventStream(SCHEME_ID, VALUE, TIME_SCALE, new long[] { presentationTimeUs1, presentationTimeUs2, presentationTimeUs3 }, new EventMessage[] { eventMessage1, eventMessage2, eventMessage3 });
EventSampleStream sampleStream = new EventSampleStream(eventStream1, FORMAT, true);
// first read - read format
readData(sampleStream);
sampleStream.skipData(presentationTimeUs2 + 1);
sampleStream.updateEventStream(eventStream2, true);
int result = readData(sampleStream);
assertThat(result).isEqualTo(C.RESULT_BUFFER_READ);
assertThat(inputBuffer.data.array()).isEqualTo(getEncodedMessage(eventMessage3));
}
Aggregations