Search in sources :

Example 6 with MTSPacket

use of org.taktik.mpegts.MTSPacket in project alliance by codice.

the class H262Test method testIDRFrameCount.

@Test
public void testIDRFrameCount() throws Exception {
    EmbeddedChannel channel = new EmbeddedChannel(new MTSPacketToPESPacketDecoder(), new PESPacketToApplicationDataDecoder(), new DecodedStreamDataHandler(packetBuffer));
    InputStream inputStream = getInputStream("/Closed_Caption_EIA_MPEG2.ts");
    byte[] buffer = new byte[TS_SIZE];
    int c;
    while ((c = inputStream.read(buffer)) != -1) {
        if (c == TS_SIZE) {
            ResettableMTSSource src = MTSSources.from(ByteSource.wrap(buffer));
            MTSPacket packet = null;
            try {
                packet = src.nextPacket();
            } catch (IOException e) {
                LOGGER.debug("unable to parse mpegst packet", e);
            }
            if (packet != null) {
                channel.writeInbound(packet);
            }
        }
    }
    verify(packetBuffer, times(37)).frameComplete(PacketBuffer.FrameType.IDR);
}
Also used : MTSPacket(org.taktik.mpegts.MTSPacket) InputStream(java.io.InputStream) EmbeddedChannel(io.netty.channel.embedded.EmbeddedChannel) IOException(java.io.IOException) ResettableMTSSource(org.taktik.mpegts.sources.ResettableMTSSource) Test(org.junit.Test)

Example 7 with MTSPacket

use of org.taktik.mpegts.MTSPacket in project alliance by codice.

the class MTSPacketToPESPacketDecoderTest method testDecode.

/**
 * This test sends MTSPackets to the decoder so that the decoder outputs one video pes packet.
 *
 * @throws Exception
 */
@Test
public void testDecode() throws Exception {
    MpegTsDecoder mpegTsDecoder = mock(MpegTsDecoder.class);
    MTSPacketToPESPacketDecoder decoder = new MTSPacketToPESPacketDecoder(mpegTsDecoder);
    MTSPacket mtsPacket = mock(MTSPacket.class);
    EmbeddedChannel channel = new EmbeddedChannel(decoder);
    channel.writeInbound(mtsPacket);
    NettyUtility.read(channel);
    verify(mpegTsDecoder).read(eq(mtsPacket), anyObject());
}
Also used : MTSPacket(org.taktik.mpegts.MTSPacket) EmbeddedChannel(io.netty.channel.embedded.EmbeddedChannel) MpegTsDecoder(org.codice.alliance.libs.mpegts.MpegTsDecoder) Test(org.junit.Test)

Aggregations

MTSPacket (org.taktik.mpegts.MTSPacket)7 Test (org.junit.Test)4 ResettableMTSSource (org.taktik.mpegts.sources.ResettableMTSSource)4 EmbeddedChannel (io.netty.channel.embedded.EmbeddedChannel)3 IOException (java.io.IOException)3 SecurityServiceException (ddf.security.service.SecurityServiceException)1 DatagramPacket (io.netty.channel.socket.DatagramPacket)1 InputStream (java.io.InputStream)1 LinkedList (java.util.LinkedList)1 MpegTsDecoder (org.codice.alliance.libs.mpegts.MpegTsDecoder)1 MTSUtils (org.jcodec.containers.mps.MTSUtils)1 PMTSection (org.jcodec.containers.mps.psi.PMTSection)1 PATSection (org.taktik.mpegts.PATSection)1