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 unit tests */
31 //#include "TransportPacket.test.hh"
32 //#include "TransportPacket.test.ih"
35 #include "TransportPacket.hh"
37 #include <senf/Utils/auto_unit_test.hh>
38 #include <boost/test/test_tools.hpp>
41 //-/////////////////////////////////////////////////////////////////////////////////////////////////
45 SENF_AUTO_UNIT_TEST(transportPacket_parse)
47 // TransportStream-Packet containing a ULE encoded IPv6 ping packet,
48 // captured with dvbsnoop
49 unsigned char data[] = {
50 // Transport Packet Header
51 0x47, 0x41, 0x0f, 0x1e,
55 0x80, 0x4c, 0x86, 0xdd,
57 0x60, 0x00, 0x00, 0x00, 0x00, 0x20, 0x11, 0x40,
58 0xfe, 0x80, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
59 0x48, 0x7c, 0x7e, 0xff, 0xfe, 0x23, 0x68, 0xaf,
60 0xff, 0x02, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
61 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0x00, 0x04,
62 0x02, 0x8c, 0x02, 0x8c, 0x00, 0x20, 0x58, 0xe1,
63 0x11, 0x05, 0x12, 0x67, 0x06, 0x2f, 0x01, 0x00,
64 0x20, 0x01, 0x06, 0x38, 0x04, 0x09, 0x10, 0x00,
65 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x11, 0x00,
66 // SNDU footer (crc-32)
67 0x1d, 0xc4, 0xe8, 0xc1,
68 // Transport Packet stuffing
69 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
70 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
71 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
72 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
73 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
74 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
75 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
76 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
77 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
78 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
79 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
80 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
81 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff
84 TransportPacket p (TransportPacket::create(data));
86 BOOST_CHECK_EQUAL( p->sync_byte(), TransportPacketType::SYNC_BYTE+0 );
87 BOOST_CHECK( ! p->transport_error_indicator() );
88 BOOST_CHECK( p->pusi() );
89 BOOST_CHECK( ! p->transport_priority() );
90 BOOST_CHECK_EQUAL( p->pid(), 0x010fu );
91 BOOST_CHECK_EQUAL( p->transport_scrmbl_ctrl(), 0x0u );
92 BOOST_CHECK_EQUAL( p->adaptation_field_ctrl(), 0x1u );
93 BOOST_CHECK_EQUAL( p->continuity_counter(), 0x0eu );
94 BOOST_CHECK_EQUAL( p->pointer_field(), 0x0u );
96 std::ostringstream oss (std::ostringstream::out);
97 SENF_CHECK_NO_THROW( p.dump( oss));
101 SENF_AUTO_UNIT_TEST(transportPacket_create_with_pusi)
103 TransportPacket ts_packet (TransportPacket::create());
104 ts_packet->setPUSI(true);
105 ts_packet->pid() = 0x010fu;
106 ts_packet->continuity_counter() = 0x0eu;
108 unsigned char payload_data[] = { // see test above
110 0x80, 0x4c, 0x86, 0xdd,
112 0x60, 0x00, 0x00, 0x00, 0x00, 0x20, 0x11, 0x40,
113 0xfe, 0x80, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
114 0x48, 0x7c, 0x7e, 0xff, 0xfe, 0x23, 0x68, 0xaf,
115 0xff, 0x02, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
116 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0x00, 0x04,
117 0x02, 0x8c, 0x02, 0x8c, 0x00, 0x20, 0x58, 0xe1,
118 0x11, 0x05, 0x12, 0x67, 0x06, 0x2f, 0x01, 0x00,
119 0x20, 0x01, 0x06, 0x38, 0x04, 0x09, 0x10, 0x00,
120 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x11, 0x00,
121 // SNDU footer (crc-32)
122 0x1d, 0xc4, 0xe8, 0xc1
124 senf::DataPacket payload (senf::DataPacket::createAfter( ts_packet, payload_data));
126 // TODO: add method for stuffing
130 //-/////////////////////////////////////////////////////////////////////////////////////////////////
137 // c-file-style: "senf"
138 // indent-tabs-mode: nil
139 // ispell-local-dictionary: "american"
140 // compile-command: "scons -u test"
141 // comment-column: 40