1 // $Id:TransportPacket.hh 560 2007-12-13 14:39:37Z tho $
4 // Fraunhofer Institute for Open Communication Systems (FOKUS)
6 // The contents of this file are subject to the Fraunhofer FOKUS Public License
7 // Version 1.0 (the "License"); you may not use this file except in compliance
8 // with the License. You may obtain a copy of the License at
9 // http://senf.berlios.de/license.html
11 // The Fraunhofer FOKUS Public License Version 1.0 is based on,
12 // but modifies the Mozilla Public License Version 1.1.
13 // See the full license text for the amendments.
15 // Software distributed under the License is distributed on an "AS IS" basis,
16 // WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
17 // for the specific language governing rights and limitations under the License.
19 // The Original Code is Fraunhofer FOKUS code.
21 // The Initial Developer of the Original Code is Fraunhofer-Gesellschaft e.V.
22 // (registered association), Hansastraße 27 c, 80686 Munich, Germany.
23 // All Rights Reserved.
26 // Thorsten Horstmann <tho@berlios.de>
29 \brief TransportPacket public header */
31 #ifndef HH_SENF_Packets_MPEGDVBBundle_TransportPacket_
32 #define HH_SENF_Packets_MPEGDVBBundle_TransportPacket_ 1
35 #include <senf/Packets/Packets.hh>
37 //#include "TransportPacket.mpp"
38 //-/////////////////////////////////////////////////////////////////////////////////////////////////
42 /** \brief Parse a Transport Stream packet
44 Parser implementing the header of a MPEG Transport Stream packet.
45 \image html TransportPacket.png
47 \see TransportPacketType
49 struct TransportPacketParser : public PacketParserBase
51 # include SENF_PARSER()
53 SENF_PARSER_FIELD ( sync_byte, UInt8Parser );
55 SENF_PARSER_BITFIELD ( transport_error_indicator, 1, bool );
56 SENF_PARSER_BITFIELD_RO ( pusi, 1, bool );
57 SENF_PARSER_BITFIELD ( transport_priority, 1, bool );
58 SENF_PARSER_BITFIELD ( pid, 13, unsigned );
59 SENF_PARSER_BITFIELD ( transport_scrmbl_ctrl, 2, unsigned );
60 SENF_PARSER_BITFIELD ( adaptation_field_ctrl, 2, unsigned );
61 SENF_PARSER_BITFIELD ( continuity_counter, 4, unsigned );
63 SENF_PARSER_PRIVATE_VARIANT ( pointer_field_, pusi,
64 (senf::VoidPacketParser) (UInt8Parser) );
66 SENF_PARSER_FINALIZE( TransportPacketParser );
68 UInt8Parser pointer_field() const;
69 void init_fields() const;
70 void setPUSI(bool pusi) const;
78 /** \brief Transport Stream packet
81 <tr style="text-align:center">
82 <th>Syntax</th><th>No. of bits</th></tr>
84 <td>transport_packet() {</td> <td></td>
87 <td style="padding-left:2em">\ref TransportPacketParser::sync_byte() "sync_byte"</td>
90 <td style="padding-left:2em">\ref TransportPacketParser::transport_error_indicator() "transport_error_indicator"</td>
93 <td style="padding-left:2em">\ref TransportPacketParser::pusi() "payload_uni_start_indicator"</td>
96 <td style="padding-left:2em">\ref TransportPacketParser::transport_priority() "transport_priority"</td>
99 <td style="padding-left:2em">\ref TransportPacketParser::pid() "PID"</td>
102 <td style="padding-left:2em">\ref TransportPacketParser::transport_scrmbl_ctrl() "transport_scrambling_control"</td>
105 <td style="padding-left:2em">\ref TransportPacketParser::adaptation_field_ctrl() "adaptation_field_control"</td>
108 <td style="padding-left:2em">\ref TransportPacketParser::continuity_counter() "continuity_counter"</td>
111 <td>}</td> <td></td></tr>
114 \par Packet type (typedef):
118 \ref TransportPacketParser
120 \ingroup protocolbundle_mpegdvb
122 struct TransportPacketType
123 : public PacketTypeBase,
124 public PacketTypeMixin<TransportPacketType>
127 typedef PacketTypeMixin<TransportPacketType> mixin;
129 typedef ConcretePacket<TransportPacketType> packet; ///< Transport packet typedef
130 typedef TransportPacketParser parser; ///< typedef to the parser of Transport packet
132 using mixin::nextPacketRange;
134 using mixin::initSize;
136 /** \brief Dump given Transport packet in readable form to given output stream */
137 static void dump(packet p, std::ostream & os);
138 static const byte SYNC_BYTE = 0x47;
141 /** \brief Transport packet typedef */
142 typedef ConcretePacket<TransportPacketType> TransportPacket;
146 //-/////////////////////////////////////////////////////////////////////////////////////////////////
147 //#include "TransportPacket.cci"
148 //#include "TransportPacket.ct"
149 //#include "TransportPacket.cti"
156 // c-file-style: "senf"
157 // indent-tabs-mode: nil
158 // ispell-local-dictionary: "american"
159 // compile-command: "scons -u test"
160 // comment-column: 40