ae1f540b88fce197c025826856622382d23d5314
[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_SENF_Packets_MPEGDVBBundle_TransportPacket_
27 #define HH_SENF_Packets_MPEGDVBBundle_TransportPacket_ 1
28
29 // Custom includes
30 #include "../../Packets/Packets.hh"
31
32 //#include "TransportPacket.mpp"
33 ///////////////////////////////hh.p////////////////////////////////////////
34
35 namespace senf {
36
37 //    struct PSIPayloadPacketParser : public PacketParserBase
38 //    {
39 //        static const size_type fixed_bytes = 184;
40 //
41 //    };
42
43
44     /** \brief Parse a Transport Stream packet
45
46         Parser implementing the header of a MPEG Transport Stream packet.
47         
48         \see TransportPacketType
49      */
50     struct TransportPacketParser : public PacketParserBase
51     {
52 #       include SENF_PARSER()
53
54         SENF_PARSER_FIELD       ( sync_byte,                  UInt8Parser );
55
56         SENF_PARSER_BITFIELD    ( transport_error_indicator,  1, bool     );
57         SENF_PARSER_BITFIELD_RO ( pusi,                       1, bool     );
58         SENF_PARSER_BITFIELD    ( transport_priority,         1, bool     );
59         SENF_PARSER_BITFIELD    ( pid,                       13, unsigned );
60         SENF_PARSER_BITFIELD    ( transport_scrmbl_ctrl,      2, unsigned );
61         SENF_PARSER_BITFIELD    ( adaptation_field_ctrl,      2, unsigned );
62         SENF_PARSER_BITFIELD    ( continuity_counter,         4, unsigned );
63
64         SENF_PARSER_PRIVATE_VARIANT ( pointer_field_, pusi,
65                 (senf::VoidPacketParser) (UInt8Parser) );
66         
67         SENF_PARSER_FINALIZE( TransportPacketParser );
68         
69         UInt8Parser pointer_field() const;
70         void init_fields() const;
71         void setPUSI(bool pusi) const;
72
73         SENF_PARSER_INIT() {
74             defaultInit();
75             init_fields();
76         }
77     };
78     
79     /** \brief Transport Stream packet
80         
81         <table class="senf">
82           <tr style="text-align:center">
83             <th>Syntax</th><th>No. of bits</th></tr>
84           <tr>
85             <td>transport_packet() {</td> <td></td>
86           </tr>
87           <tr>
88             <td style="padding-left:2em">\ref TransportPacketParser::sync_byte() "sync_byte"</td>
89             <td>8</td></tr>
90           <tr>
91             <td style="padding-left:2em">\ref TransportPacketParser::transport_error_indicator() "transport_error_indicator"</td>
92             <td>1</td></tr>
93           <tr>
94             <td style="padding-left:2em">\ref TransportPacketParser::pusi() "payload_uni_start_indicator"</td>
95             <td>1</td></tr>
96           <tr>
97             <td style="padding-left:2em">\ref TransportPacketParser::transport_priority() "transport_priority"</td>
98             <td>1</td></tr>
99           <tr>
100             <td style="padding-left:2em">\ref TransportPacketParser::pid() "PID"</td>
101             <td>13</td></tr>
102           <tr>
103             <td style="padding-left:2em">\ref TransportPacketParser::transport_scrmbl_ctrl() "transport_scrambling_control"</td>
104             <td>2</td></tr>
105           <tr>
106             <td style="padding-left:2em">\ref TransportPacketParser::adaptation_field_ctrl() "adaptation_field_control"</td>
107             <td>2</td></tr>
108           <tr>
109             <td style="padding-left:2em">\ref TransportPacketParser::continuity_counter() "continuity_counter"</td>
110             <td>4</td></tr>
111           <tr>
112             <td>}</td> <td></td></tr>
113         </table>
114         
115         \par Packet type (typedef):
116             \ref TransportPacket
117
118         \par Fields:
119             \ref TransportPacketParser
120
121         \ingroup protocolbundle_mpegdvb
122      */
123     struct TransportPacketType
124         : public PacketTypeBase,
125           public PacketTypeMixin<TransportPacketType>
126     {
127         typedef PacketTypeMixin<TransportPacketType> mixin;
128         typedef ConcretePacket<TransportPacketType> packet;
129         typedef TransportPacketParser parser;
130     
131         using mixin::nextPacketRange;
132         using mixin::init;
133         using mixin::initSize;
134         
135         static void dump(packet p, std::ostream & os);
136         static const byte SYNC_BYTE = 0x47;
137     };
138     
139     /** \brief Transport packet typedef */
140     typedef ConcretePacket<TransportPacketType> TransportPacket;
141 }
142
143
144 ///////////////////////////////hh.e////////////////////////////////////////
145 //#include "TransportPacket.cci"
146 //#include "TransportPacket.ct"
147 //#include "TransportPacket.cti"
148 #endif
149
150 \f
151 // Local Variables:
152 // mode: c++
153 // fill-column: 100
154 // c-file-style: "senf"
155 // indent-tabs-mode: nil
156 // ispell-local-dictionary: "american"
157 // compile-command: "scons -u test"
158 // comment-column: 40
159 // End: