@Test public void testDecodeEventMessage() { byte[] rawEmsgBody = new byte[] { 117, 114, 110, 58, 116, 101, 115, 116, 0, // scheme_id_uri = "urn:test" 49, 50, 51, 0, // value = "123" 0, 0, -69, -128, // timescale = 48000 0, 0, 0, 0, // presentation_time_delta (ignored) = 0 0, 2, 50, -128, // event_duration = 144000 0, 15, 67, -45, // id = 1000403 0, 1, 2, 3, 4}; // message_data = {0, 1, 2, 3, 4} EventMessageDecoder decoder = new EventMessageDecoder(); MetadataInputBuffer buffer = new MetadataInputBuffer(); buffer.data = ByteBuffer.allocate(rawEmsgBody.length).put(rawEmsgBody); Metadata metadata = decoder.decode(buffer); assertThat(metadata.length()).isEqualTo(1); EventMessage eventMessage = (EventMessage) metadata.get(0); assertThat(eventMessage.schemeIdUri).isEqualTo("urn:test"); assertThat(eventMessage.value).isEqualTo("123"); assertThat(eventMessage.durationMs).isEqualTo(3000); assertThat(eventMessage.id).isEqualTo(1000403); assertThat(eventMessage.messageData).isEqualTo(new byte[]{0, 1, 2, 3, 4}); }
@Override public Metadata decode(MetadataInputBuffer inputBuffer) { ByteBuffer buffer = inputBuffer.data; return decode(buffer.array(), buffer.limit()); }
@Before public void setUp() { decoder = new SpliceInfoDecoder(); inputBuffer = new MetadataInputBuffer(); }