Membrane RTSP source

Ok, that’s an interleaving I haven’t heard about yet - not only audio and video are interleaved, but also RTSP packets. I’ve done short research and it seems I finally understand your first post :stuck_out_tongue: So basing on RFC 7826 it looks like we have the following types of packets:

  • RTP packets (prepended with this four-byte header)
  • RTSP packets (plain text)
  • possibly RTCP packets (prepended by the same header as RTP, but with the channel id incremented by one, as far as I understood)

So I think the parsing should be something like:

def dissect(<<36, rtp_channel::integer-8, length::integer-16, chunk::binary-size(length), rest::binary>>, rtp_channel) do
  # chunk is an RTP packet, forward to RTP parser
end

def dissect(<<36, rtcp_channel::integer-8, length::integer-16, chunk::binary-size(length), rest::binary>>, rtp_channel) when rtcp_channel == rtp_channel+1 do
  # chunk is an RTCP packet - not yet supported in Membrane - ignore or extract some information if needed
end

def dissect(<<36, _::binary>>, _rtp_channel) do
  # request more data
end

def dissect(rtsp_packet, _rtp_channel) do
  # got RTSP packet - even if not needed, has to be parsed to identify the beginning of the next packet,
  # that may be RTP. https://github.com/membraneframework/membrane-protocol-rtsp/blob/master/lib/rtsp/response.ex
  # may be helpful. You can also try skipping until the next 36 byte, but not sure it will work.
end

This should be done before the RTP parser (or before the RTP receiver bin). I don’t know RTSP that thoroughly, but hopefully this will finally be helpful.