xref: /aosp_15_r20/external/webrtc/pc/g3doc/rtp.md (revision d9f758449e529ab9291ac668be2861e7a55c2422)
1*d9f75844SAndroid Build Coastguard Worker<?% config.freshness.reviewed = '2021-06-03' %?>
2*d9f75844SAndroid Build Coastguard Worker<?% config.freshness.owner = 'hta' %?>
3*d9f75844SAndroid Build Coastguard Worker
4*d9f75844SAndroid Build Coastguard Worker# RTP in WebRTC
5*d9f75844SAndroid Build Coastguard Worker
6*d9f75844SAndroid Build Coastguard WorkerWebRTC uses the RTP protocol described in
7*d9f75844SAndroid Build Coastguard Worker[RFC3550](https://datatracker.ietf.org/doc/html/rfc3550) for transporting audio
8*d9f75844SAndroid Build Coastguard Workerand video. Media is encrypted using [SRTP](./srtp.md).
9*d9f75844SAndroid Build Coastguard Worker
10*d9f75844SAndroid Build Coastguard Worker## Allocation of payload types
11*d9f75844SAndroid Build Coastguard Worker
12*d9f75844SAndroid Build Coastguard WorkerRTP packets have a payload type field that describes which media codec can be
13*d9f75844SAndroid Build Coastguard Workerused to handle a packet. For some (older) codecs like PCMU the payload type is
14*d9f75844SAndroid Build Coastguard Workerassigned statically as described in
15*d9f75844SAndroid Build Coastguard Worker[RFC3551](https://datatracker.ietf.org/doc/html/rfc3551). For others, it is
16*d9f75844SAndroid Build Coastguard Workerassigned dynamically through the SDP. **Note:** there are no guarantees on the
17*d9f75844SAndroid Build Coastguard Workerstability of a payload type assignment.
18*d9f75844SAndroid Build Coastguard Worker
19*d9f75844SAndroid Build Coastguard WorkerFor this allocation, the range from 96 to 127 is used. When this range is
20*d9f75844SAndroid Build Coastguard Workerexhausted, the allocation falls back to the range from 35 to 63 as permitted by
21*d9f75844SAndroid Build Coastguard Worker[section 5.1 of RFC3550][1]. Note that older versions of WebRTC failed to
22*d9f75844SAndroid Build Coastguard Workerrecognize payload types in the lower range. Newer codecs (such as flexfec-03 and
23*d9f75844SAndroid Build Coastguard WorkerAV1) will by default be allocated in that range.
24*d9f75844SAndroid Build Coastguard Worker
25*d9f75844SAndroid Build Coastguard WorkerPayload types in the range 64 to 95 are not used to avoid confusion with RTCP as
26*d9f75844SAndroid Build Coastguard Workerdescribed in [RFC5761](https://datatracker.ietf.org/doc/html/rfc5761).
27*d9f75844SAndroid Build Coastguard Worker
28*d9f75844SAndroid Build Coastguard Worker## Allocation of audio payload types
29*d9f75844SAndroid Build Coastguard Worker
30*d9f75844SAndroid Build Coastguard WorkerAudio payload types are assigned from a table by the [PayloadTypeMapper][2]
31*d9f75844SAndroid Build Coastguard Workerclass. New audio codecs should be allocated in the lower dynamic range [35,63],
32*d9f75844SAndroid Build Coastguard Workerstarting at 63, to reduce collisions with payload types
33*d9f75844SAndroid Build Coastguard Worker
34*d9f75844SAndroid Build Coastguard Worker## Allocation of video payload types
35*d9f75844SAndroid Build Coastguard Worker
36*d9f75844SAndroid Build Coastguard WorkerVideo payload types are allocated by the
37*d9f75844SAndroid Build Coastguard Worker[GetPayloadTypesAndDefaultCodecs method][3]. The set of codecs depends on the
38*d9f75844SAndroid Build Coastguard Workerplatform, in particular for H264 codecs and their different profiles. Payload
39*d9f75844SAndroid Build Coastguard Workernumbers are assigned ascending from 96 for video codecs and their
40*d9f75844SAndroid Build Coastguard Worker[associated retransmission format](https://datatracker.ietf.org/doc/html/rfc4588).
41*d9f75844SAndroid Build Coastguard WorkerSome codecs like flexfec-03 and AV1 are assigned to the lower range [35,63] for
42*d9f75844SAndroid Build Coastguard Workerreasons explained above. When the upper range [96,127] is exhausted, payload
43*d9f75844SAndroid Build Coastguard Workertypes are assigned to the lower range [35,63], starting at 35.
44*d9f75844SAndroid Build Coastguard Worker
45*d9f75844SAndroid Build Coastguard Worker## Handling of payload type collisions
46*d9f75844SAndroid Build Coastguard Worker
47*d9f75844SAndroid Build Coastguard WorkerDue to the requirement that payload types must be uniquely identifiable when
48*d9f75844SAndroid Build Coastguard Workerusing [BUNDLE](https://datatracker.ietf.org/doc/html/rfc8829) collisions between
49*d9f75844SAndroid Build Coastguard Workerthe assignments of the audio and video payload types may arise. These are
50*d9f75844SAndroid Build Coastguard Workerresolved by the [UsedPayloadTypes][4] class which will reassign payload type
51*d9f75844SAndroid Build Coastguard Workernumbers descending from 127.
52*d9f75844SAndroid Build Coastguard Worker
53*d9f75844SAndroid Build Coastguard Worker[1]: https://datatracker.ietf.org/doc/html/rfc3550#section-5.1
54*d9f75844SAndroid Build Coastguard Worker[2]: https://source.chromium.org/chromium/chromium/src/+/main:third_party/webrtc/media/engine/payload_type_mapper.cc;l=25;drc=4f26a3c7e8e20e0e0ca4ca67a6ebdf3f5543dc3f
55*d9f75844SAndroid Build Coastguard Worker[3]: https://source.chromium.org/chromium/chromium/src/+/main:third_party/webrtc/media/engine/webrtc_video_engine.cc;l=119;drc=b412efdb780c86e6530493afa403783d14985347
56*d9f75844SAndroid Build Coastguard Worker[4]: https://source.chromium.org/chromium/chromium/src/+/main:third_party/webrtc/pc/used_ids.h;l=94;drc=b412efdb780c86e6530493afa403783d14985347
57