RTP to HLS Disconnect and Reconnect Audio Stream

Hello everyone, I currently have a microphone input which is sending UDP to a server and into a RTP input and finally streaming over HLS. The entire flow is working fine, however, I am trying to handle a scenario where the microphone gets disconnected and when it reconnects and starts sending UDP packets over to the server, I start receiving:
[warning] <0.2197.0>/:rtp/{:stream_receive_bin, 1}/:packet_tracker Dropping packet 39181 with big sequence number difference (-13014)
[warning] <0.2197.0>/:rtp/{:stream_receive_bin, 1}/:packet_tracker Dropping packet 39181 with big sequence number difference (-13014)
Since the sequence numbers are out of sync. I was wondering what is the best scenario to handle this case? Ideally I would like the sequence number to continue from where the microphone got disconnected and this can then continue generating segment files for HLS streaming. The code structure is very similar to https://github.com/membraneframework/membrane_demo/blob/master/rtp_to_hls/rtp_to_hls.exs. Any help would be appreciated!
1 Reply
mat_hek
mat_hek•13mo ago
👋 If you cannot control the sequence numbers on the sender side, I see the following options: - Spawn the RTP part of the pipeline each time the sender reconnects. Use Membrane.Funnel between RTP and HLS to be able to dynamically connect new RTP inputs - Create an element that will parse the RTP packets, change the sequence numbers when needed and serialize them back to RTP. https://hexdocs.pm/membrane_rtp_plugin/Membrane.RTP.Packet.html can help - Instead of using RTP.SessionBin, link elements manually, like the bin does underneath. Then, after the Membrane.RTP.Parser, link an element that will update sequence numbers in Membrane.Buffer.metadata when needed.

Did you find this page helpful?