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 psi2ts.cc non-inline non-template implementation */
32 //#include "psi2ts.ih"
36 //#include "psi2ts.cc.mpp"
39 //-/////////////////////////////////////////////////////////////////////////////////////////////////
42 template <class InputIterator, class Distance>
43 void advance_max(InputIterator& i, Distance n, InputIterator& i_end)
45 Distance d = std::min( std::distance(i, i_end), n);
51 prefix_ Psi2TsModule::Psi2TsModule(unsigned pid, senf::ClockService::clock_type timeout)
54 continuity_counter_ = 0;
56 route( input, output );
57 input.onRequest( &Psi2TsModule::onRequest );
60 #include <senf/Utils/hexdump.hh>
61 prefix_ void Psi2TsModule::onRequest()
63 senf::PacketData & section = input.read().data();
64 iterator sec_end = section.end();
65 iterator begin = section.begin();
66 iterator end = section.begin();
67 advance_max( end, 183, sec_end);
70 senf::TransportPacket tsPacket (senf::TransportPacket::create(188));
71 tsPacket->continuity_counter() = next_continuity_counter();
72 tsPacket->pid() = pid_;
75 tsPacket->setPUSI(true);
76 tsPacket->pointer_field() = 0;
78 senf::PacketData & payloadData (tsPacket.next().data());
80 std::copy( begin, end, payloadData.begin() ),
86 output.write( tsPacket);
88 advance_max( begin, 184, sec_end);
89 advance_max( end, 184, sec_end);
90 } while (begin != end);
94 prefix_ unsigned Psi2TsModule::next_continuity_counter()
96 continuity_counter_ = (continuity_counter_ + 1) % 16;
97 return continuity_counter_;
101 //-/////////////////////////////////////////////////////////////////////////////////////////////////
103 //#include "psi2ts.cc.mpp"
109 // comment-column: 40
110 // c-file-style: "senf"
111 // indent-tabs-mode: nil
112 // ispell-local-dictionary: "american"
113 // compile-command: "scons -u test"