removed some useless spaces; not very important, I know :)
[senf.git] / Packets / MPEGDVBBundle / TransportPacket.hh
1 // $Id:TransportPacket.hh 560 2007-12-13 14:39:37Z tho $
2 //
3 // Copyright (C) 2007
4 // Fraunhofer Institute for Open Communication Systems (FOKUS)
5 // Competence Center NETwork research (NET), St. Augustin, GERMANY
6 //     Thorsten Horstmann <tho@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 TransportPacket public header */
25
26 #ifndef HH_TransportPacket_
27 #define HH_TransportPacket_ 1
28
29 // Custom includes
30 #include <algorithm>
31 #include "../../Packets/Packets.hh"
32
33 //#include "TransportPacket.mpp"
34 ///////////////////////////////hh.p////////////////////////////////////////
35
36 namespace senf {
37
38     /** \brief Parse a Transport Stream packet
39
40         Parser implementing the header of a MPEG Transport Stream packet.
41         
42         \see TransportPacketType
43      */
44     struct TransportPacketParser : public PacketParserBase
45     {
46 #       include SENF_FIXED_PARSER()
47
48         SENF_PARSER_FIELD    ( sync_byte,                  UInt8Parser  );
49
50         SENF_PARSER_BITFIELD ( transport_error_indicator,   1, bool     );
51         SENF_PARSER_BITFIELD ( pusi,                        1, bool     );
52         SENF_PARSER_BITFIELD ( transport_priority,          1, bool     );
53         SENF_PARSER_BITFIELD ( pid,                        13, unsigned );
54         SENF_PARSER_BITFIELD ( transport_scrmbl_ctrl,       2, unsigned );
55         SENF_PARSER_BITFIELD ( adaptation_field_ctrl,       2, unsigned );
56         SENF_PARSER_BITFIELD ( continuity_counter,          4, unsigned );
57
58         SENF_PARSER_FINALIZE( TransportPacketParser );
59     
60 //        UInt8Parser payload_pointer() const {
61 //            return parse<UInt8Parser>( TransportPacketParser::fixed_bytes ); 
62 //        }
63     };
64     
65     /** \brief Transport Stream packet
66         
67         <table class="senf">
68           <tr style="text-align:center">
69             <th>Syntax</th><th>No. of bits</th></tr>
70           <tr>
71             <td>transport_packet() {</td> <td></td>
72           </tr>
73           <tr>
74             <td style="padding-left:2em">\ref TransportPacketParser::sync_byte() "sync_byte"</td>
75             <td>8</td></tr>
76           <tr>
77             <td style="padding-left:2em">\ref TransportPacketParser::transport_error_indicator() "transport_error_indicator"</td>
78             <td>1</td></tr>
79           <tr>
80             <td style="padding-left:2em">\ref TransportPacketParser::pusi() "payload_uni_start_indicator"</td>
81             <td>1</td></tr>
82           <tr>
83             <td style="padding-left:2em">\ref TransportPacketParser::transport_priority() "transport_priority"</td>
84             <td>1</td></tr>
85           <tr>
86             <td style="padding-left:2em">\ref TransportPacketParser::pid() "PID"</td>
87             <td>13</td></tr>
88           <tr>
89             <td style="padding-left:2em">\ref TransportPacketParser::transport_scrmbl_ctrl() "transport_scrambling_control"</td>
90             <td>2</td></tr>
91           <tr>
92             <td style="padding-left:2em">\ref TransportPacketParser::adaptation_field_ctrl() "adaptation_field_control"</td>
93             <td>2</td></tr>
94           <tr>
95             <td style="padding-left:2em">\ref TransportPacketParser::continuity_counter() "continuity_counter"</td>
96             <td>4</td></tr>
97           <tr>
98             <td>}</td> <td></td></tr>
99         </table>
100         
101         \par Packet type (typedef):
102             \ref TransportPacket
103
104         \par Fields:
105             \ref TransportPacketParser
106
107         \ingroup protocolbundle_mpegdvb
108      */
109     struct TransportPacketType
110         : public PacketTypeBase,
111           public PacketTypeMixin<TransportPacketType>
112     {
113         typedef PacketTypeMixin<TransportPacketType> mixin;
114         typedef ConcretePacket<TransportPacketType> packet;
115         typedef TransportPacketParser parser;
116     
117         using mixin::nextPacketRange;
118         using mixin::init;
119         using mixin::initSize;
120         
121         static void dump(packet p, std::ostream & os);
122     };
123     
124     /** \brief Transport packet typedef */
125     typedef TransportPacketType::packet TransportPacket;
126     
127     #define TRANSPORT_PACKET_SYNC_BYTE 0x47
128   
129 }
130
131
132 ///////////////////////////////hh.e////////////////////////////////////////
133 //#include "TransportPacket.cci"
134 //#include "TransportPacket.ct"
135 //#include "TransportPacket.cti"
136 #endif
137
138 \f
139 // Local Variables:
140 // mode: c++
141 // fill-column: 100
142 // c-file-style: "senf"
143 // indent-tabs-mode: nil
144 // ispell-local-dictionary: "american"
145 // compile-command: "scons -u test"
146 // comment-column: 40
147 // End: