Search in sources :

Example 1 with PMTStream

use of org.jcodec.containers.mps.psi.PMTSection.PMTStream in project ddf by codice.

the class MpegTransportStreamMetadataExtractor method getProgramMapTable.

private void getProgramMapTable(final MTSPacket packet) {
    final ByteBuffer payload = packet.getPayload();
    final int pointer = payload.get() & 0xff;
    payload.position(payload.position() + pointer);
    final int packetId = packet.getPid();
    final PMTSection pmt = PMTSection.parsePMT(payload);
    programMapTables.put(packetId, pmt);
    for (final PMTStream stream : pmt.getStreams()) {
        programElementaryStreams.put(stream.getPid(), stream);
    }
}
Also used : PMTStream(org.jcodec.containers.mps.psi.PMTSection.PMTStream) ByteBuffer(java.nio.ByteBuffer) PMTSection(org.jcodec.containers.mps.psi.PMTSection)

Example 2 with PMTStream

use of org.jcodec.containers.mps.psi.PMTSection.PMTStream in project ddf by codice.

the class MpegTransportStreamMetadataExtractor method handleElementaryStreamPacket.

private void handleElementaryStreamPacket(final MTSPacket packet, final int packetId, final BiConsumer<Integer, byte[]> callback) {
    if (programElementaryStreams.containsKey(packetId)) {
        final PMTStream stream = programElementaryStreams.get(packetId);
        if (isMetadataStream(stream)) {
            final byte[] currentMetadataPacketBytes = currentMetadataPacketBytesByStream.get(packetId);
            final boolean startingNewMetadataPacket = packet.isPayloadUnitStartIndicator();
            final boolean currentMetadataPacketToHandle = currentMetadataPacketBytes != null;
            final boolean reachedEndOfCurrentMetadataPacket = startingNewMetadataPacket && currentMetadataPacketToHandle;
            final byte[] payloadBytes = getByteBufferAsBytes(packet.getPayload());
            if (reachedEndOfCurrentMetadataPacket) {
                callback.accept(packetId, currentMetadataPacketBytes);
                startNewMetadataPacketBytes(packetId, payloadBytes);
            } else if (startingNewMetadataPacket) {
                startNewMetadataPacketBytes(packetId, payloadBytes);
            } else if (currentMetadataPacketToHandle) {
                final byte[] concatenatedMetadataPacket = ArrayUtils.addAll(currentMetadataPacketBytes, payloadBytes);
                currentMetadataPacketBytesByStream.put(packetId, concatenatedMetadataPacket);
            }
        }
    }
}
Also used : PMTStream(org.jcodec.containers.mps.psi.PMTSection.PMTStream)

Aggregations

PMTStream (org.jcodec.containers.mps.psi.PMTSection.PMTStream)2 ByteBuffer (java.nio.ByteBuffer)1 PMTSection (org.jcodec.containers.mps.psi.PMTSection)1