Open source software that extracts RTP / RTCP packets from a pcap file:
From the source code, you can view and understand the methodologies used.
I can receive sip packets, but I cannot distinguish RTP packets from the rest.
If you can decode SIP, you can find (inside the INVITE message) the SDP message. If you decode it, you can find IP and PORT RTP "stream" (and RTCP => port + 1). Using this information, you can uniquely identify RTP and RTCP packets. Keep in mind that there are often packets (with the same IP-PORT) with the STUN protocol, which must be separated from RTP. You must consider where packet capture is located (network context and restrictions), you can consider NAT.
source share