X-Git-Url: http://g0dil.de/git?a=blobdiff_plain;f=Examples%2FDVBAdapter%2FMPEdec.cc;h=4a33ffde307eca9591497df0b7b9d6d41f472fd3;hb=ac1dca71db955a9f19edc7ad1888bfe5bd126eac;hp=372e7bebf5e9a3e93404fc3314a25801611365c5;hpb=65066c0e037d1de437d6121903e1dd511b41e940;p=senf.git diff --git a/Examples/DVBAdapter/MPEdec.cc b/Examples/DVBAdapter/MPEdec.cc index 372e7be..4a33ffd 100644 --- a/Examples/DVBAdapter/MPEdec.cc +++ b/Examples/DVBAdapter/MPEdec.cc @@ -1,9 +1,9 @@ // $Id$ // -// Copyright (C) 2006 -// Fraunhofer Institut fuer offene Kommunikationssysteme (FOKUS) -// Kompetenzzentrum fuer Satelitenkommunikation (SatCom) -// Stefan Bund +// Copyright (C) 2007 +// 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 @@ -27,70 +27,28 @@ #include #include #include -#include +#include -#include "Scheduler/Scheduler.hh" -#include "Packets/DefaultBundle/EthernetPacket.hh" -#include "Packets/MPEGDVBBundle/DatagramSection.hh" -#include "Utils/membind.hh" -#include "Socket/DVBDemuxHandles.hh" -#include "Packets/ParseInt.hh" -#include "Packets/Packet.hh" -#include "Packets/PacketData.hh" +#include +#include +#include +#include +#include +#include +#include #define PID 500 #define prefix_ -///////////////////////////////cc.p//////////////////////////////////////// - -namespace { - - static const unsigned BLOCK_SIZE = 16; - - template - void hexdump(Iterator i, Iterator const & i_end, std::ostream& stream) - { - unsigned offset (0); - std::string ascii; - for (; i != i_end; ++i, ++offset) { - switch (offset % BLOCK_SIZE) { - case 0: - if (!ascii.empty()) { - stream << " " << ascii << "\n"; - ascii = ""; - } - stream << " " - << std::hex << std::setw(4) << std::setfill('0') - << offset << ' '; - break; - case BLOCK_SIZE/2: - stream << " "; - ascii += ' '; - break; - } - stream << ' ' << std::hex << std::setw(2) << std::setfill('0') - << unsigned(*i); - ascii += (*i >= ' ' && *i < 126) ? *i : '.'; - } - if (!ascii.empty()) { - for (; (offset % BLOCK_SIZE) != 0; ++offset) { - if ((offset % BLOCK_SIZE) == BLOCK_SIZE/2) - stream << " "; - stream << " "; - } - stream << " " << ascii << "\n"; - } - stream << std::dec; - } -} - +//-///////////////////////////////////////////////////////////////////////////////////////////////// class MySniffer { senf::DVBDemuxSectionHandle handle; public: - MySniffer() + MySniffer(unsigned short adapter=0, unsigned short device=0) + : handle( adapter, device ) { struct dmx_sct_filter_params sec_filter; memset(&sec_filter, 0, sizeof (struct dmx_sct_filter_params)); @@ -101,19 +59,19 @@ public: sec_filter.flags |= DMX_CHECK_CRC; handle.protocol().setSectionFilter( &sec_filter ); - + senf::Scheduler::instance().add( handle, senf::membind(&MySniffer::dumpSection, this)); } private: - void dumpSection(senf::FileHandle /* ignored */, senf::Scheduler::EventId event) + void dumpSection(senf::Scheduler::EventId event) { std::string data (handle.read()); - senf::DatagramSection section (senf::DatagramSection::create(data)); + senf::MPESection section (senf::MPESection::create(data)); section.dump(std::cout); - senf::PacketData & datagramData (section.last().data()); - hexdump(datagramData.begin(), datagramData.end(), std::cout); + senf::PacketData & datagramData (section.next().data()); + senf::hexdump(datagramData.begin(), datagramData.end(), std::cout); } }; @@ -130,7 +88,7 @@ int main(int argc, char const * argv[]) } -///////////////////////////////cc.e//////////////////////////////////////// +//-///////////////////////////////////////////////////////////////////////////////////////////////// #undef prefix_ @@ -140,6 +98,6 @@ int main(int argc, char const * argv[]) // c-file-style: "senf" // indent-tabs-mode: nil // ispell-local-dictionary: "american" -// compile-command: "scons -u test" +// compile-command: "scons -u" // comment-column: 40 // End: