From: tho Date: Mon, 10 Mar 2008 14:21:25 +0000 (+0000) Subject: very fist alpha version of PSI-Section-to-TransportPacket encoder X-Git-Url: http://g0dil.de/git?p=senf.git;a=commitdiff_plain;h=3f0cb3ca7b09eb7733289c2a0576d36a3403a908 very fist alpha version of PSI-Section-to-TransportPacket encoder git-svn-id: https://svn.berlios.de/svnroot/repos/senf/trunk@738 270642c3-0616-0410-b53a-bc976706d245 --- diff --git a/Examples/psi2tsModule/.test.bin b/Examples/psi2tsModule/.test.bin new file mode 100755 index 0000000..240e324 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 0000000..e69de29 diff --git a/Examples/psi2tsModule/SConscript b/Examples/psi2tsModule/SConscript new file mode 100644 index 0000000..4aaded3 --- /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 0000000..2234a33 --- /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 +// +// 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 + +#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 0000000..3de7cab --- /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 +// +// 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 + 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 0000000..52ccdd1 --- /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 +// +// 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 +#include +#include +#include +#include + +//#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 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 0000000..4bf570a --- /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 +// +// 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 + +#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: