Hooli
Hooli

Reputation: 731

How to handle jitter buffer in pjsip/pjmedia framework?

I have to handle rtp media for incoming and outgoing streams. The incoming stream is from different softphone and outgoing stream is to a diff phone. So its a media relay. For both streams I need to put them in jitter buffer and then play them out at constant bitrate. The framework is confusing me a bit. I am adding code in on_rx_rtp handler. I first break the payload into frames and put each frame in jitterbuffer. Now when and where do I get the frame? In a different thread? or an event or in the same thread after the buffer is full to 70%? Even if I do this, how do I combine the frames into a payload and then send them out? I have to use transport_send_rtp to send packets and not the intrinsic pjmedia stream or port framework? Any help would be appreaciated.

Upvotes: 0

Views: 1881

Answers (1)

TMSZ
TMSZ

Reputation: 687

For media relay you may not need jitter buffer at all. Just send packet to receiver (B) immediately after receiving it from sender (A). You can assume that A is sending packets at correct rate and B has its own jitter buffer and forwarding packets immediately is not adding any significant delays (which is also downside of any buffering).

You may need jitter buffer if you need features like transcoding or being able to modify passed audio but then I would rather use pjmedia streams and conference bridge than handle each packet manually.

Upvotes: 1

Related Questions