I am setting up kind of media player. And I want to get RTP data in TCP packet for media play.
For getting data, i should remove header parts. And i found 2 ways.
way [1] TCP packet
[$ - 1byte][Transport Channel - 1byte][RTP data length - 2bytes][RTP data]
way [2] TCP packet
in rfc4571 standard (https://www.rfc-editor.org/rfc/rfc4571#page-3)
0 1 2 3
0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1
---------------------------------------------------------------
| LENGTH | RTP or RTCP packet ... |
---------------------------------------------------------------
I found two tcp packet structure. So if i follow way [1], i should remove 4bytes(1+1+2), but way [2], i should remove 2bytes only.
Actually, i implements my program like way [1], but in gst-plugins-good, rtpstreamdepay plugin implements it follows way [2] and Android also.
So does removing 2bytes are rignt? or is it old & new standard ?
If I remember correctly you are looking at two different things here.
Way 1: Means RTSP interleaving. So all RTP/RTCP channels are transmitted over the RTSP control connection. Since you are dealing with a single connection in this case you need additional information which communication channel the data you are sending belongs to.
Way 2: Is simply TCP framing for UDP data. Since TCP is a continuous stream you are missing out implicit length information that UDP datagrams provide. Since the protocol itself does not have such information by itself it is hereby provided by a 16 bit length field before the actual payload.