diff --git a/Examples/psi2tsModule/.test.bin b/Examples/psi2tsModule/.test.bin new file mode 100755 index 0000000000000000000000000000000000000000..240e32420756672c51c9bb576b07f7e160e4b31c Binary files /dev/null and b/Examples/psi2tsModule/.test.bin differ diff --git a/Examples/psi2tsModule/.test.stamp b/Examples/psi2tsModule/.test.stamp new file mode 100644 index 0000000000000000000000000000000000000000..e69de29bb2d1d6434b8b29ae775ad8c2e48c5391 diff --git a/Examples/psi2tsModule/SConscript b/Examples/psi2tsModule/SConscript new file mode 100644 index 0000000000000000000000000000000000000000..4aaded30eea918fcaa939c376d14e31025b18379 --- /dev/null +++ b/Examples/psi2tsModule/SConscript @@ -0,0 +1,13 @@ +Import('env') +import SENFSCons, glob + +########################################################################### + +sources = SENFSCons.GlobSources() + +SENFSCons.StandardTargets(env) + +SENFSCons.Object(env, + target = 'psi2ts.o', + sources = sources, + LIBS = ['senf']) diff --git a/Examples/psi2tsModule/main.test.cc b/Examples/psi2tsModule/main.test.cc new file mode 100644 index 0000000000000000000000000000000000000000..2234a332b10f0b98375de665652530b71892efd5 --- /dev/null +++ b/Examples/psi2tsModule/main.test.cc @@ -0,0 +1,49 @@ +// $Id: main.test.cc 206 2007-02-20 14:20:52Z g0dil $ +// +// Copyright (C) 2006 +// Fraunhofer Institute for Open Communication Systems (FOKUS) +// Competence Center NETwork research (NET), St. Augustin, GERMANY +// Thorsten Horstmann <tho@berlios.de> +// +// This program is free software; you can redistribute it and/or modify +// it under the terms of the GNU General Public License as published by +// the Free Software Foundation; either version 2 of the License, or +// (at your option) any later version. +// +// This program is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. +// +// You should have received a copy of the GNU General Public License +// along with this program; if not, write to the +// Free Software Foundation, Inc., +// 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. + +// Definition of non-inline non-template functions + +//#include "test.hh" +//#include "test.ih" + +// Custom includes +#define BOOST_AUTO_TEST_MAIN +#include "../../Utils/auto_unit_test.hh" +#include <boost/test/test_tools.hpp> + +#define prefix_ +///////////////////////////////cc.p//////////////////////////////////////// + + +///////////////////////////////cc.e//////////////////////////////////////// +#undef prefix_ + + +// Local Variables: +// mode: c++ +// fill-column: 100 +// c-file-style: "senf" +// indent-tabs-mode: nil +// ispell-local-dictionary: "american" +// compile-command: "scons -u test" +// comment-column: 40 +// End: diff --git a/Examples/psi2tsModule/psi2ts.cc b/Examples/psi2tsModule/psi2ts.cc new file mode 100644 index 0000000000000000000000000000000000000000..3de7cab11c629877a1f88def26d011b25c783d65 --- /dev/null +++ b/Examples/psi2tsModule/psi2ts.cc @@ -0,0 +1,96 @@ +// $Id: Example.cc 661 2008-02-05 09:53:54Z tho $ +// +// Copyright (C) 2008 +// Fraunhofer Institute for Open Communication Systems (FOKUS) +// Competence Center NETwork research (NET), St. Augustin, GERMANY +// Thorsten Horstmann <tho@berlios.de> +// +// This program is free software; you can redistribute it and/or modify +// it under the terms of the GNU General Public License as published by +// the Free Software Foundation; either version 2 of the License, or +// (at your option) any later version. +// +// This program is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. +// +// You should have received a copy of the GNU General Public License +// along with this program; if not, write to the +// Free Software Foundation, Inc., +// 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. + +/** \file + \brief psi2ts.cc non-inline non-template implementation */ + +#include "psi2ts.hh" +//#include "psi2ts.ih" + +// Custom includes + +//#include "psi2ts.cc.mpp" +#define prefix_ +///////////////////////////////cc.p//////////////////////////////////////// + +namespace { + template <class InputIterator, class Distance> + void advance_max(InputIterator& i, Distance n, InputIterator& i_end) + { + Distance d = std::min( std::distance(i, i_end), n); + std::advance( i, d); + } +} + + +prefix_ Psi2TsModule::Psi2TsModule() +{ + continuity_counter_ = 0; + state_ = IDLE; + route( input, output ); + input.onRequest( &Psi2TsModule::onRequest ); +} + +prefix_ void Psi2TsModule::onRequest() +{ + senf::PacketData & section = input.read().data(); + iterator sec_end = section.end(); + iterator begin = section.begin(); + iterator end = section.begin(); + advance_max( end, 184, sec_end); + + do { + senf::TransportPacket tsPacket (senf::TransportPacket::create()); + tsPacket->continuity_counter() = next_continuity_counter(); + if (state_ == IDLE) { + state_ = PROC; + tsPacket->pusi() = true; + } + senf::DataPacket::createAfter( tsPacket, boost::make_iterator_range(begin, end)); + tsPacket.finalize(); + advance_max( begin, 184, sec_end); + advance_max( end, 184, sec_end); + } while (begin != end); + state_ = IDLE; +} + +prefix_ unsigned Psi2TsModule::next_continuity_counter() +{ + continuity_counter_ = (continuity_counter_ + 1) % 16; + return continuity_counter_; +} + + +///////////////////////////////cc.e//////////////////////////////////////// +#undef prefix_ +//#include "psi2ts.cc.mpp" + + +// Local Variables: +// mode: c++ +// fill-column: 100 +// comment-column: 40 +// c-file-style: "senf" +// indent-tabs-mode: nil +// ispell-local-dictionary: "american" +// compile-command: "scons -u test" +// End: diff --git a/Examples/psi2tsModule/psi2ts.hh b/Examples/psi2tsModule/psi2ts.hh new file mode 100644 index 0000000000000000000000000000000000000000..52ccdd1fee5d6f4d41f4b3bc066723889b97da85 --- /dev/null +++ b/Examples/psi2tsModule/psi2ts.hh @@ -0,0 +1,75 @@ +// $Id: Example.hh 661 2008-02-05 09:53:54Z tho $ +// +// Copyright (C) 2008 +// Fraunhofer Institute for Open Communication Systems (FOKUS) +// Competence Center NETwork research (NET), St. Augustin, GERMANY +// Thorsten Horstmann <tho@berlios.de> +// +// This program is free software; you can redistribute it and/or modify +// it under the terms of the GNU General Public License as published by +// the Free Software Foundation; either version 2 of the License, or +// (at your option) any later version. +// +// This program is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. +// +// You should have received a copy of the GNU General Public License +// along with this program; if not, write to the +// Free Software Foundation, Inc., +// 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. + +/** \file + \brief psi2ts.hh public header */ + +#ifndef HH_psi2ts_ +#define HH_psi2ts_ 1 + +// Custom includes +#include <senf/PPI/PPI.hh> +#include <senf/PPI/Module.hh> +#include <senf/PPI/Connectors.hh> +#include <senf/Packets/PacketData.hh> +#include <senf/Packets/MPEGDVBBundle/TransportPacket.hh> + +//#include "psi2ts.mpp" +///////////////////////////////hh.p//////////////////////////////////////// + +class Psi2TsModule + : public senf::ppi::module::Module +{ + SENF_PPI_MODULE(Psi2TsModule); + +public: + senf::ppi::connector::PassiveInput<> input; + senf::ppi::connector::ActiveOutput<senf::TransportPacket> output; + Psi2TsModule(); + void onRequest(); + +private: + enum state {IDLE, PROC, WAIT}; + typedef senf::PacketData::iterator iterator; + unsigned continuity_counter_; + unsigned next_continuity_counter(); + state state_; + +}; + + +///////////////////////////////hh.e//////////////////////////////////////// +//#include "psi2ts.cci" +//#include "psi2ts.ct" +//#include "psi2ts.cti" +#endif + + +// Local Variables: +// mode: c++ +// fill-column: 100 +// comment-column: 40 +// c-file-style: "senf" +// indent-tabs-mode: nil +// ispell-local-dictionary: "american" +// compile-command: "scons -u test" +// End: diff --git a/Examples/psi2tsModule/psi2ts.test.cc b/Examples/psi2tsModule/psi2ts.test.cc new file mode 100644 index 0000000000000000000000000000000000000000..4bf570ae6cf5482f0a53e368ee9aeebca691df39 --- /dev/null +++ b/Examples/psi2tsModule/psi2ts.test.cc @@ -0,0 +1,51 @@ +// $Id: Example.test.cc 698 2008-02-18 13:41:37Z tho $ +// +// Copyright (C) 2008 +// Fraunhofer Institute for Open Communication Systems (FOKUS) +// Competence Center NETwork research (NET), St. Augustin, GERMANY +// Thorsten Horstmann <tho@berlios.de> +// +// This program is free software; you can redistribute it and/or modify +// it under the terms of the GNU General Public License as published by +// the Free Software Foundation; either version 2 of the License, or +// (at your option) any later version. +// +// This program is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. +// +// You should have received a copy of the GNU General Public License +// along with this program; if not, write to the +// Free Software Foundation, Inc., +// 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. + +/** \file + \brief psi2ts unit tests */ + +// Custom includes +#include "psi2ts.hh" + +#include "../../Utils/auto_unit_test.hh" +#include <boost/test/test_tools.hpp> + +#define prefix_ +///////////////////////////////cc.p//////////////////////////////////////// +BOOST_AUTO_UNIT_TEST(one_section_to_one_transportpacket) +{ + BOOST_CHECK_EQUAL(1, 1+0); +} + +///////////////////////////////cc.e//////////////////////////////////////// +#undef prefix_ + + +// Local Variables: +// mode: c++ +// fill-column: 100 +// comment-column: 40 +// c-file-style: "senf" +// indent-tabs-mode: nil +// ispell-local-dictionary: "american" +// compile-command: "scons -u test" +// End: