Search in sources :

Example 1 with MetadataRenderer

use of androidx.media3.exoplayer.metadata.MetadataRenderer in project media by androidx.

the class MetadataRendererTest method runRenderer.

private static List<Metadata> runRenderer(byte[] input) throws ExoPlaybackException {
    List<Metadata> metadata = new ArrayList<>();
    MetadataRenderer renderer = new MetadataRenderer(metadata::add, /* outputLooper= */
    null);
    FakeSampleStream fakeSampleStream = new FakeSampleStream(new DefaultAllocator(/* trimOnReset= */
    true, /* individualAllocationSize= */
    1024), /* mediaSourceEventDispatcher= */
    null, DrmSessionManager.DRM_UNSUPPORTED, new DrmSessionEventListener.EventDispatcher(), EMSG_FORMAT, ImmutableList.of(sample(/* timeUs= */
    0, C.BUFFER_FLAG_KEY_FRAME, input), END_OF_STREAM_ITEM));
    fakeSampleStream.writeData(/* startPositionUs= */
    0);
    renderer.replaceStream(new Format[] { EMSG_FORMAT }, fakeSampleStream, /* startPositionUs= */
    0L, /* offsetUs= */
    0L);
    // Read the format
    renderer.render(/* positionUs= */
    0, /* elapsedRealtimeUs= */
    0);
    // Read the data
    renderer.render(/* positionUs= */
    0, /* elapsedRealtimeUs= */
    0);
    return Collections.unmodifiableList(metadata);
}
Also used : FakeSampleStream(androidx.media3.test.utils.FakeSampleStream) Metadata(androidx.media3.common.Metadata) ArrayList(java.util.ArrayList) DefaultAllocator(androidx.media3.exoplayer.upstream.DefaultAllocator) DrmSessionEventListener(androidx.media3.exoplayer.drm.DrmSessionEventListener)

Aggregations

Metadata (androidx.media3.common.Metadata)1 DrmSessionEventListener (androidx.media3.exoplayer.drm.DrmSessionEventListener)1 DefaultAllocator (androidx.media3.exoplayer.upstream.DefaultAllocator)1 FakeSampleStream (androidx.media3.test.utils.FakeSampleStream)1 ArrayList (java.util.ArrayList)1