c65360e3cb2b4757731587a5f79684fbbb888777
[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 HH_SENF_Packets_DefaultBundle_RTPPacket_
27 #define HH_SENF_Packets_DefaultBundle_RTPPacket_
28
29 #include "../../Packets/Packets.hh"
30 #include "../../Socket/Protocols/INet/INet6Address.hh"
31 #include "../../Socket/Protocols/INet.hh"
32 #include "../../Utils/Logger/SenfLog.hh"
33
34 namespace senf {
35     
36     struct RTPPacketParser : public senf::PacketParserBase
37     {
38         SENF_LOG_CLASS_AREA();
39 #       include SENF_PARSER()
40         SENF_PARSER_BITFIELD  ( version,        2, unsigned     );      //Version (RFC 3550)
41         SENF_PARSER_BITFIELD  ( padding,        1, bool         );      //1 if padding behind payload
42         SENF_PARSER_BITFIELD  ( extension,      1, bool         );
43         SENF_PARSER_BITFIELD_RO  ( csrcCount,      4, unsigned     );   //0-15,define the number of contributing sources
44         SENF_PARSER_BITFIELD  ( marker,         1, bool         );      //Marker M=1, used to signal speech silent compression; further use in combination with PT to be defined
45         SENF_PARSER_BITFIELD  ( payloadType,    7, unsigned     );      //Payload Type; e.g. PCM=8 (RFC 3550)
46         SENF_PARSER_FIELD     ( seqNumber,      senf::UInt16Parser );   //random number to identify initial segment of  a stream, increment by 1 used to resequence segments at receiver
47         SENF_PARSER_FIELD     ( timeStamp,      senf::UInt32Parser );   //signals sampling time of 1st byte of payload; initialised; used to calculate Jitter between segments
48         SENF_PARSER_FIELD     ( synSourceId,    senf::UInt32Parser );   //Synchronisation source identifier; identifier of RFTP stream source (random number) in case of conferencing identifier of mixer
49         SENF_PARSER_VECTOR    (csrcOpt, csrcCount, senf::UInt32Parser );
50         
51         bool valid() const {return version() == 2;}
52         SENF_PARSER_FINALIZE(RTPPacketParser);
53     };
54     
55     struct RTPPacketType 
56         : public senf::PacketTypeBase,
57           public senf::PacketTypeMixin<RTPPacketType>
58     {
59         SENF_LOG_CLASS_AREA();
60         typedef senf::PacketTypeMixin<RTPPacketType> mixin;
61         typedef senf::ConcretePacket<RTPPacketType> packet;
62         typedef RTPPacketParser parser;
63     
64         using mixin::nextPacketRange;
65         using mixin::init;
66         using mixin::initSize;
67     
68         static void dump(packet p, std::ostream &os);
69     };
70     
71     typedef RTPPacketType::packet RTPPacket;
72
73 }
74 #endif