When receiving a RTP stream, will pion correct misordered packets? #2249
-
I'm trying to use this library for building a RTP Server to recieve multiple RTP streams. I want to ensure that out of order packets are reordered before they are consumed, does pion handle this internally or could anyone point me to a sample? Much appreciated, thanks |
Beta Was this translation helpful? Give feedback.
Replies: 3 comments 4 replies
-
@birla |
Beta Was this translation helpful? Give feedback.
-
Hi @birla @alexpokotilo is correct :) By default Pion doesn't delay or de-jitter packets. Pion does provide the SampleBuilder. You can run your RTP packets through it and it will re-order them + delay a configured amount of time for late packets. |
Beta Was this translation helpful? Give feedback.
-
Is there a way to use the sample builder together with Atm I'm just initializing the oggwriter and passing the RTP packets into it like this: writer, _ := oggwriter.New("recording.ogg", 48000, 2)
buf := make([]byte, 1600)
for {
n, _, _ := conn.ReadFrom(buf)
rtpPacket := &rtp.Packet{}
_ = rtpPacket.Unmarshal(buf[:n])
_ = m.writer.WriteRTP(rtpPacket)
}
writer.Close() If I use the samplebuilder: builder := samplebuilder.New(10, &codecs.OpusPacket{}, 48000) // how do I set the num of channels?
buf := make([]byte, 1600)
for {
n, _, _ := conn.ReadFrom(buf)
rtpPacket := &rtp.Packet{}
_ = rtpPacket.Unmarshal(buf[:n])
builder.Push(rtpPacket)
sample := builder.Pop()
if sample != nil {
// how to I write this sample to a file?
}
}
// how do I flush the last remaining packets out? |
Beta Was this translation helpful? Give feedback.
@birla
what do you find during your tests ? As far as I see ReadRTP will give you packets in order they received and hence sorting reorderings(if you really need this) is your responsibility. If I am wrong, would be cool to be corrected