diff --git a/Examples/psi2tsModule/psi2ts.cc b/Examples/psi2tsModule/psi2ts.cc index a41acbe8903c1a8520382366fe32269e4daebc17..2ff2538ba0f31818e66d255bc8805fdd3810374b 100644 --- a/Examples/psi2tsModule/psi2ts.cc +++ b/Examples/psi2tsModule/psi2ts.cc @@ -29,6 +29,7 @@ // Custom includes //#include "psi2ts.cc.mpp" + #define prefix_ ///////////////////////////////cc.p//////////////////////////////////////// @@ -59,14 +60,18 @@ prefix_ void Psi2TsModule::onRequest() advance_max( end, 184, sec_end); do { - senf::TransportPacket tsPacket (senf::TransportPacket::create()); + senf::TransportPacket tsPacket (senf::TransportPacket::create(188)); tsPacket->continuity_counter() = next_continuity_counter(); if (state_ == IDLE) { state_ = PROC; tsPacket->pusi() = true; } - senf::DataPacket::createAfter( tsPacket, boost::make_iterator_range(begin, end)); + senf::PacketData & payloadData (tsPacket.next().data()); + std::copy( begin, end, payloadData.begin() ); tsPacket.finalize(); + + output.write( tsPacket); + advance_max( begin, 184, sec_end); advance_max( end, 184, sec_end); } while (begin != end); diff --git a/Examples/psi2tsModule/psi2ts.test.cc b/Examples/psi2tsModule/psi2ts.test.cc index b57e39c262ae5c08cb7ba8ebb265a0dc2d47bc99..e34aa91befc6e499a21636467472a10b5dee22d9 100644 --- a/Examples/psi2tsModule/psi2ts.test.cc +++ b/Examples/psi2tsModule/psi2ts.test.cc @@ -24,16 +24,61 @@ \brief psi2ts unit tests */ // Custom includes +#include "senf/PPI/DebugModules.hh" +#include "senf/PPI/Setup.hh" +#include <senf/Packets/MPEGDVBBundle/MPESection.hh> +#include <senf/Packets/MPEGDVBBundle/TransportPacket.hh> #include "psi2ts.hh" #include "../../Utils/auto_unit_test.hh" #include <boost/test/test_tools.hpp> +#include <boost/lambda/lambda.hpp> #define prefix_ ///////////////////////////////cc.p//////////////////////////////////////// + +void check_transportpacket_header(senf::TransportPacket tsPacket, bool pusi, unsigned pid, unsigned counter) +{ + BOOST_CHECK_EQUAL( tsPacket->sync_byte(), senf::TransportPacketType::SYNC_BYTE+0 ); + BOOST_CHECK_EQUAL( tsPacket->transport_error_indicator(), false ); + BOOST_CHECK_EQUAL( tsPacket->pusi(), pusi ); + BOOST_CHECK_EQUAL( tsPacket->transport_priority(), false ); + BOOST_CHECK_EQUAL( tsPacket->transport_scrmbl_ctrl(), 0x0u ); + BOOST_CHECK_EQUAL( tsPacket->adaptation_field_ctrl(), 0x1u ); + BOOST_CHECK_EQUAL( tsPacket->continuity_counter(), counter ); + +} + BOOST_AUTO_UNIT_TEST(one_section_to_one_transportpacket) { - BOOST_CHECK_EQUAL(1, 1+0); + senf::ppi::module::debug::ActiveSource source; + senf::ppi::module::debug::PassiveSink sink; + Psi2TsModule psi2ts; + + senf::ppi::connect(source, psi2ts); + senf::ppi::connect(psi2ts, sink); + senf::ppi::init(); + + std::string payload_data ( "psi2ts_test: one_section_to_one_transportpacket"); + senf::Packet payload (senf::DataPacket::create(payload_data)); + payload.finalize(); + + source.submit(payload); + BOOST_CHECK_EQUAL( sink.size(), 1u); + + senf::TransportPacket tsPacket = sink.pop_front().as<senf::TransportPacket>(); + check_transportpacket_header( tsPacket, true, 0, 1); + senf::PacketData & ts_data = tsPacket.next().data(); + BOOST_CHECK_EQUAL_COLLECTIONS( + ts_data.begin(), + boost::next( ts_data.begin(), payload_data.size()), + payload_data.begin(), + payload_data.end()); +// BOOST_CHECK( std::find_if( +// boost::next( ts_data.begin(), payload_data.size()), +// ts_data.end(), +// boost::lambda::_1 != 0xffu) == ts_data.end() ); + } ///////////////////////////////cc.e////////////////////////////////////////