4 // Fraunhofer Institute for Open Communication Systems (FOKUS)
5 // Competence Center NETwork research (NET), St. Augustin, GERMANY
6 // Thorsten Horstmann <tho@berlios.de>
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.
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.
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.
24 \brief psi2ts.cc non-inline non-template implementation */
27 //#include "psi2ts.ih"
31 //#include "psi2ts.cc.mpp"
34 ///////////////////////////////cc.p////////////////////////////////////////
37 template <class InputIterator, class Distance>
38 void advance_max(InputIterator& i, Distance n, InputIterator& i_end)
40 Distance d = std::min( std::distance(i, i_end), n);
46 prefix_ Psi2TsModule::Psi2TsModule(unsigned pid, senf::ClockService::clock_type timeout)
49 continuity_counter_ = 0;
51 route( input, output );
52 input.onRequest( &Psi2TsModule::onRequest );
55 #include <senf/Utils/hexdump.hh>
56 prefix_ void Psi2TsModule::onRequest()
58 senf::PacketData & section = input.read().data();
59 iterator sec_end = section.end();
60 iterator begin = section.begin();
61 iterator end = section.begin();
62 advance_max( end, 183, sec_end);
65 senf::TransportPacket tsPacket (senf::TransportPacket::create(188));
66 tsPacket->continuity_counter() = next_continuity_counter();
67 tsPacket->pid() = pid_;
70 tsPacket->setPUSI(true);
71 tsPacket->pointer_field() = 0;
73 senf::PacketData & payloadData (tsPacket.next().data());
75 std::copy( begin, end, payloadData.begin() ),
81 output.write( tsPacket);
83 advance_max( begin, 184, sec_end);
84 advance_max( end, 184, sec_end);
85 } while (begin != end);
89 prefix_ unsigned Psi2TsModule::next_continuity_counter()
91 continuity_counter_ = (continuity_counter_ + 1) % 16;
92 return continuity_counter_;
96 ///////////////////////////////cc.e////////////////////////////////////////
98 //#include "psi2ts.cc.mpp"
104 // comment-column: 40
105 // c-file-style: "senf"
106 // indent-tabs-mode: nil
107 // ispell-local-dictionary: "american"
108 // compile-command: "scons -u test"