cd17bc351b60ed239936368dec1635ac9a080c07
[senf.git] / Packets / DefaultBundle / RTPPacket.hh
1 // $Id: main.test.cc 206 2008-08-06 14:20:52Z pug $
2 //
3 // Copyright (C) 2006
4 // Fraunhofer Institute for Open Communication Systems (FOKUS)
5 // Competence Center NETwork research (NET), St. Augustin, GERMANY
6 //     Stefan Bund <g0dil@berlios.de>
7 //
8 // This program is free software; you can redistribute it and/or modify
9 // it under the terms of the GNU General Public License as published by
10 // the Free Software Foundation; either version 2 of the License, or
11 // (at your option) any later version.
12 //
13 // This program is distributed in the hope that it will be useful,
14 // but WITHOUT ANY WARRANTY; without even the implied warranty of
15 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
16 // GNU General Public License for more details.
17 //
18 // You should have received a copy of the GNU General Public License
19 // along with this program; if not, write to the
20 // Free Software Foundation, Inc.,
21 // 59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.
22
23 // Definition of non-inline non-template functions
24
25 // Custom includes
26 #ifndef RTPPACKET_HH_
27 #define RTPPACKET_HH_
28
29 #include "../../Packets/Packets.hh"
30 #include "../../Socket/Protocols/INet/INet6Address.hh"
31 #include "../../Socket/Protocols/INet.hh"
32
33 namespace senf {
34     
35     struct RTPPacketParser : public senf::PacketParserBase
36     {
37     SENF_LOG_CLASS_AREA();
38     #   include SENF_PARSER()
39         SENF_PARSER_BITFIELD  ( version,        2, unsigned     );      //Version (RFC 3550)
40         SENF_PARSER_BITFIELD  ( padding,        1, bool         );      //1 if padding behind payload
41         SENF_PARSER_BITFIELD  ( extension,      1, bool         );
42         SENF_PARSER_BITFIELD_RO  ( csrcCount,      4, unsigned     );   //0-15,define the number of contributing sources
43         SENF_PARSER_BITFIELD  ( marker,         1, bool         );      //Marker M=1, used to signal speech silent compression; further use in combination with PT to be defined
44         SENF_PARSER_BITFIELD  ( payloadType,    7, unsigned     );      //Payload Type; e.g. PCM=8 (RFC 3550)
45         SENF_PARSER_FIELD     ( seqNumber,      senf::UInt16Parser );   //random number to identify initial segment of  a stream, increment by 1 used to resequence segments at receiver
46         SENF_PARSER_FIELD     ( timeStamp,      senf::UInt32Parser );   //signals sampling time of 1st byte of payload; initialised; used to calculate Jitter between segments
47         SENF_PARSER_FIELD     ( synSourceId,    senf::UInt32Parser );   //Synchronisation source identifier; identifier of RFTP stream source (random number) in case of conferencing identifier of mixer
48         SENF_PARSER_VECTOR    (csrcOpt, csrcCount, senf::UInt32Parser );
49         
50         bool valid() const {return version() == 2;}
51         SENF_PARSER_FINALIZE(RTPPacketParser);
52     };
53     
54     struct RTPPacketType 
55         : public senf::PacketTypeBase,
56         public senf::PacketTypeMixin<RTPPacketType>
57     {
58     SENF_LOG_CLASS_AREA();
59         typedef senf::PacketTypeMixin<RTPPacketType> mixin;
60         typedef senf::ConcretePacket<RTPPacketType> packet;
61         typedef RTPPacketParser parser;
62     
63         using mixin::nextPacketRange;
64         using mixin::init;
65         using mixin::initSize;
66     
67         static void dump(packet p, std::ostream &os);
68     };
69     
70     typedef RTPPacketType::packet RTPPacket;
71
72 }
73 #endif