Testing a jitter buffer by presenting packet captures through a DatagramSocket interface

I've been working on the jitter buffer code in the FMJ project which is used by the Jitsi softclient. To know that the code is good, it's been handy to be able to try it out under real world conditions. To make this repeatable I wanted to be able to play packet captures through the jitter buffer and hear the results so I could then tweak the code and hear whether it improved things.

The easiest way to achieve this was to use the excellent libjitsi library from the Jitsi team. This just allows me to call LibJitsi.start() then I can use the MediaService to create a MediaDevice to play the audio and use a MediaStream connected to this device for dealing with the RTP. See here for the code.

The MediaStream is then connected to a new class I wrote which implements the StreamConnector interface. This class PCapStreamConnector, is a small class which has most of the interesting logic in another new class I wrote - PCapDatagramSocket. This presents a packet capture file through a DatagramSocket interface! It's fairly crude, and assumes the media file is written in the exact format that Jitsi uses for writing packet capture files, but that's all I need so no point doing any more.

It's a bit rough and ready at the moment. The fact that it doesn't actually use the RTP timings makes this borderline useless (!), but I will be adding that feature soon. At the same time, I'll be cleaning up the interface to allow the payload type to be passed in, or even better just try to detect it from the capture file. With a little more work, this could be a handy generic tool for playing media from RTP streams in any format that libjitsi supports - at least g711, SILK, Opus, g722, g723, iLBC and speex.

To really make this feature useful, I also enhanced the error reporting module so that users would have the chance to report a few minutes of media if they've experienced bad voice quality on a call.