minor steps for the psi2ts module
tho [Thu, 20 Mar 2008 16:25:43 +0000 (16:25 +0000)]
git-svn-id: https://svn.berlios.de/svnroot/repos/senf/trunk@752 270642c3-0616-0410-b53a-bc976706d245

Examples/psi2tsModule/psi2ts.cc
Examples/psi2tsModule/psi2ts.test.cc

index a41acbe..2ff2538 100644 (file)
@@ -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);
index b57e39c..e34aa91 100644 (file)
     \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////////////////////////////////////////