Packets: extended description of bad_cast exception in Packet.as()
[senf.git] / senf / Packets / DefaultBundle / RTPPacket.hh
1 // $Id$
2 //
3 // Copyright (C) 2006
4 // Fraunhofer Institute for Open Communication Systems (FOKUS)
5 // Competence Center NETwork research (NET), St. Augustin, GERMANY
6 //     Philipp Batroff <pug@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 /** \file
24     \brief RTPPacket public header */
25
26 #ifndef HH_SENF_Packets_DefaultBundle_RTPPacket_
27 #define HH_SENF_Packets_DefaultBundle_RTPPacket_ 1
28
29 // Custom includes
30 #include <senf/Packets/Packets.hh>
31
32 //-/////////////////////////////////////////////////////////////////////////////////////////////////
33 namespace senf {
34
35     struct RTPPacketParser : public PacketParserBase
36     {
37 #       include SENF_PARSER()
38         SENF_PARSER_BITFIELD  ( version,        2, unsigned     );      //Version (RFC 3550)
39         SENF_PARSER_BITFIELD  ( padding,        1, bool         );      //1 if padding behind payload
40         SENF_PARSER_BITFIELD  ( extension,      1, bool         );
41         SENF_PARSER_BITFIELD_RO  ( csrcCount,      4, unsigned     );   //0-15,define the number of contributing sources
42         SENF_PARSER_BITFIELD  ( marker,         1, bool         );      //Marker M=1, used to signal speech silent compression; further use in combination with PT to be defined
43         SENF_PARSER_BITFIELD  ( payloadType,    7, unsigned     );      //Payload Type; e.g. PCM=8 (RFC 3550)
44         SENF_PARSER_FIELD     ( seqNumber,      UInt16Parser );   //random number to identify initial segment of  a stream, increment by 1 used to resequence segments at receiver
45         SENF_PARSER_FIELD     ( timeStamp,      UInt32Parser );   //signals sampling time of 1st byte of payload; initialized; used to calculate Jitter between segments
46         SENF_PARSER_FIELD     ( synSourceId,    UInt32Parser );   //Synchronization source identifier; identifier of RFTP stream source (random number) in case of conferencing identifier of mixer
47         SENF_PARSER_VECTOR    (csrcOpt, csrcCount, UInt32Parser );
48
49         SENF_PARSER_FINALIZE(RTPPacketParser);
50
51         bool valid() const { return version() == 2; }
52     };
53
54     struct RTPPacketType
55         : public PacketTypeBase,
56           public PacketTypeMixin<RTPPacketType>
57     {
58         typedef PacketTypeMixin<RTPPacketType> mixin;
59         typedef ConcretePacket<RTPPacketType> packet;
60         typedef RTPPacketParser parser;
61
62         using mixin::nextPacketRange;
63         using mixin::init;
64         using mixin::initSize;
65
66         static void dump(packet p, std::ostream & os);
67     };
68
69     typedef RTPPacketType::packet RTPPacket;
70
71 }
72
73 //-/////////////////////////////////////////////////////////////////////////////////////////////////
74 #endif