Question

I am using a combination of wireshark's tshark and jnetpcap to decode offline captures and extract the rtp audio payload from files for foward and reverse directions.

In the first steps I isolate only the rtp files and save them to an extra file.

Then I simply loop with jnetpcap through that file and save the rtp payload to a file.

In case I need both channels the produced file can be played, but sampling etc. does not work correctly. It sounds bit too fast (too high). So something must be done differently..

anybody got a hint how to save it into 2 channels so it works as stereo instead of mono?

final StringBuilder errbuf = new StringBuilder();

    Pcap pcap = Pcap.openOffline(filename, errbuf);

    if(pcap == null) {
        System.err.printf("Error while opening device for capture: " 
                + errbuf.toString());

        return false;
    }

    PcapPacketHandler<String> handler = new PcapPacketHandler<String>() {
        public void nextPacket(PcapPacket packet, String user) {
            System.out.println("size of packet is=" + packet.size());
            Rtp rtp = new Rtp();

            if(packet.hasHeader(rtp)) {
                System.out.println("rtp.headerLength = "+rtp.getHeaderLength()+ "rtp.payloadLength = "+rtp.getPayloadLength());

                try {
                    dos.write(rtp.getPayload());
                } catch (IOException e) {
                    // TODO Auto-generated catch block
                    e.printStackTrace();
                }
            }


        }
    };

    int ret = pcap.dispatch(-1, handler, "I rock");
    System.out.println("Ret = "+ret);
    try {
        dos.close();
    } catch (IOException e) {
        // TODO Auto-generated catch block
        e.printStackTrace();
    }
Was it helpful?

Solution

The solution to the question is to build a RingBuffer as jitterbuffer and synchronize packages and do proper silence generation.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top