1## This file is part of Scapy
2## See http://www.secdev.org/projects/scapy for more informations
3## Copyright (C) Philippe Biondi <phil@secdev.org>
4## This program is published under a GPLv2 license
5
6"""
7RTP (Real-time Transport Protocol).
8"""
9
10from scapy.packet import *
11from scapy.fields import *
12
13_rtp_payload_types = {
14    # http://www.iana.org/assignments/rtp-parameters
15    0:  'G.711 PCMU',    3:  'GSM',
16    4:  'G723',          5:  'DVI4',
17    6:  'DVI4',          7:  'LPC',
18    8:  'PCMA',          9:  'G722',
19    10: 'L16',           11: 'L16',
20    12: 'QCELP',         13: 'CN',
21    14: 'MPA',           15: 'G728',
22    16: 'DVI4',          17: 'DVI4',
23    18: 'G729',          25: 'CelB',
24    26: 'JPEG',          28: 'nv',
25    31: 'H261',          32: 'MPV',
26    33: 'MP2T',          34: 'H263' }
27
28class RTP(Packet):
29    name="RTP"
30    fields_desc = [ BitField('version', 2, 2),
31                    BitField('padding', 0, 1),
32                    BitField('extension', 0, 1),
33                    BitFieldLenField('numsync', None, 4, count_of='sync'),
34                    BitField('marker', 0, 1),
35                    BitEnumField('payload', 0, 7, _rtp_payload_types),
36                    ShortField('sequence', 0),
37                    IntField('timestamp', 0),
38                    IntField('sourcesync', 0),
39                    FieldListField('sync', [], IntField("id",0), count_from=lambda pkt:pkt.numsync) ]
40
41