Parser for TLVPacket is working now, thanx to Stefan for the hint.
[senf.git] / Packets / MPEGDVBBundle / TransportPacket.hh
1 // $Id:DatagramSection.hh 327 2007-07-20 10:03:44Z tho $
2 //
3 // Copyright (C) 2007
4 // Fraunhofer Institut fuer offene Kommunikationssysteme (FOKUS)
5 // Kompetenzzentrum fuer Satelitenkommunikation (SatCom)
6 //     Thorsten Horstmann <thorsten.horstmann@fokus.fraunhofer.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/PacketType.hh"
32 #include "../../Packets/ParseInt.hh"
33 #include "../../Packets/PacketParser.hh"
34
35 //#include "TransportPacket.mpp"
36 ///////////////////////////////hh.p////////////////////////////////////////
37
38 namespace senf {
39
40     /** \brief Parse a Transport Stream packet
41
42         Parser implementing the header of a MPEG Transport Stream packet.
43         
44         \see TransportPacketType
45      */
46     struct Parse_TransportPacket : public PacketParserBase
47     {
48         typedef Parse_Flag      <     0 > Parse_tei; // transport_error_indicator
49         typedef Parse_Flag      <     1 > Parse_pusi; // payload_unit_start_indicator
50         typedef Parse_Flag      <     2 > Parse_transportPrio;  // transport_priority
51         typedef Parse_UIntField < 2, 16 > Parse_pid;
52         typedef Parse_UIntField < 0,  2 > Parse_tsc; // transport_scrambling_control
53         typedef Parse_UIntField < 2,  4 > Parse_adaptCtrl; // adaptation_field_control
54         typedef Parse_UIntField < 4,  8 > Parse_contCounter; // continuity_counter
55     
56 #       ifndef DOXYGEN
57         
58         SENF_PACKET_PARSER_INIT(Parse_TransportPacket);
59         
60         SENF_PACKET_PARSER_DEFINE_FIXED_FIELDS(
61             ((Field       ) ( sync_byte,                 Parse_UInt8         )) 
62             ((OverlayField) ( transport_error_indicator, Parse_tei           ))
63             ((OverlayField) ( pusi,                      Parse_pusi          ))
64             ((OverlayField) ( transport_priority,        Parse_transportPrio ))
65             ((Field       ) ( pid,                       Parse_pid           ))
66             ((OverlayField) ( transport_scrmbl_ctrl,     Parse_tsc           ))
67             ((OverlayField) ( adaptation_field_ctrl,     Parse_adaptCtrl     ))
68             ((Field       ) ( continuity_counter,        Parse_contCounter   ))      
69         );
70         
71 #       else
72         
73         Parse_UInt8         sync_byte() const;
74         Parse_tei           transport_error_indicator() const;
75         Parse_pusi          pusi() const;
76         Parse_transportPrio transport_priority() const;
77         Parse_pid           pid() const;
78         Parse_tsc           transport_scrmbl_ctrl() const;
79         Parse_adaptCtrl     adaptation_field_ctrl() const;
80         Parse_contCounter   continuity_counter() const;
81
82 #       endif
83         
84 //        Parse_UInt8 payload_pointer() const {
85 //            return parse<Parse_UInt8>( Parse_TransportPacket::fixed_bytes ); 
86 //        }
87     };
88     
89     /** \brief Transport Stream packet
90         
91         <table class="senf">
92           <tr style="text-align:center">
93             <th>Syntax</th><th>No. of bits</th></tr>
94           <tr>
95             <td>transport_packet() {</td> <td></td>
96           </tr>
97           <tr>
98             <td style="padding-left:2em">\ref Parse_TransportPacket::sync_byte() "sync_byte"</td>
99             <td>8</td></tr>
100           <tr>
101             <td style="padding-left:2em">\ref Parse_TransportPacket::transport_error_indicator() "transport_error_indicator"</td>
102             <td>1</td></tr>
103           <tr>
104             <td style="padding-left:2em">\ref Parse_TransportPacket::pusi() "payload_uni_start_indicator"</td>
105             <td>1</td></tr>
106           <tr>
107             <td style="padding-left:2em">\ref Parse_TransportPacket::transport_priority() "transport_priority"</td>
108             <td>1</td></tr>
109           <tr>
110             <td style="padding-left:2em">\ref Parse_TransportPacket::pid() "PID"</td>
111             <td>13</td></tr>
112           <tr>
113             <td style="padding-left:2em">\ref Parse_TransportPacket::transport_scrmbl_ctrl() "transport_scrambling_control"</td>
114             <td>2</td></tr>
115           <tr>
116             <td style="padding-left:2em">\ref Parse_TransportPacket::adaptation_field_ctrl() "adaptation_field_control"</td>
117             <td>2</td></tr>
118           <tr>
119             <td style="padding-left:2em">\ref Parse_TransportPacket::continuity_counter() "continuity_counter"</td>
120             <td>4</td></tr>
121           <tr>
122             <td>}</td> <td></td></tr>
123         </table>
124         
125         \par Packet type (typedef):
126             \ref TransportPacket
127
128         \par Fields:
129             \ref Parse_TransportPacket
130
131         \ingroup protocolbundle_mpegdvb
132      */
133     struct TransportPacketType
134         : public PacketTypeBase,
135           public PacketTypeMixin<TransportPacketType>
136     {
137         typedef PacketTypeMixin<TransportPacketType> mixin;
138         typedef ConcretePacket<TransportPacketType> packet;
139         typedef Parse_TransportPacket parser;
140     
141         using mixin::nextPacketRange;
142         using mixin::init;
143         using mixin::initSize;
144         
145         static void dump(packet p, std::ostream & os);
146     };
147     
148     /** \brief Transport packet typedef */
149     typedef TransportPacketType::packet TransportPacket;
150     
151     #define TRANSPORT_PACKET_SYNC_BYTE 0x47
152   
153 }
154
155
156 ///////////////////////////////hh.e////////////////////////////////////////
157 //#include "TransportPacket.cci"
158 //#include "TransportPacket.ct"
159 //#include "TransportPacket.cti"
160 #endif
161
162 \f
163 // Local Variables:
164 // mode: c++
165 // fill-column: 100
166 // c-file-style: "senf"
167 // indent-tabs-mode: nil
168 // ispell-local-dictionary: "american"
169 // compile-command: "scons -u test"
170 // comment-column: 40
171 // End: