From: tho Date: Fri, 10 Aug 2007 08:04:31 +0000 (+0000) Subject: minor improvements X-Git-Url: http://g0dil.de/git?a=commitdiff_plain;h=4a597684a4c3fbab2c946f48fe85680716dbb3a6;p=senf.git minor improvements git-svn-id: https://svn.berlios.de/svnroot/repos/senf/trunk@388 270642c3-0616-0410-b53a-bc976706d245 --- diff --git a/Examples/DVBAdapter/MPEdec.cc b/Examples/DVBAdapter/MPEdec.cc index 3a95687..a0b6a3a 100644 --- a/Examples/DVBAdapter/MPEdec.cc +++ b/Examples/DVBAdapter/MPEdec.cc @@ -72,7 +72,7 @@ private: std::string data (handle.read()); senf::DatagramSection section (senf::DatagramSection::create(data)); section.dump(std::cout); - senf::PacketData & datagramData (section.last().data()); + senf::PacketData & datagramData (section.next().data()); senf::hexdump(datagramData.begin(), datagramData.end(), std::cout); } }; diff --git a/Examples/DVBAdapter/ULEdec.cc b/Examples/DVBAdapter/ULEdec.cc index edce523..695037f 100644 --- a/Examples/DVBAdapter/ULEdec.cc +++ b/Examples/DVBAdapter/ULEdec.cc @@ -25,11 +25,16 @@ #include "ULEdec.hh" #include +#include #include "Packets/PacketData.hh" #include "Utils/hexdump.hh" #include "Utils/membind.hh" #define PID 271 +#define TRANSPORT_PACKET_SIZE 188 +// max. payload_pointer = ts packet payload size ( = ts packet size - ts header - payload_pointer) +// - 2 bytes min. sndu header +#define MAX_PAYLOAD_POINTER ( TRANSPORT_PACKET_SIZE - 4 - 1 - 2 ) #define prefix_ ///////////////////////////////cc.p//////////////////////////////////////// @@ -108,7 +113,7 @@ void ULEdec::handleTSPacket(senf::TransportPacket ts_packet) return; default: if ( (*payload_iter++ << 8 | *payload_iter++) != ULE_END_INDICATOR ) - std::cerr << "delimiting error 1\n"; + std::cerr << "delimiting error\n"; } else { BOOST_ASSERT( std::distance( payload_iter, payload_end ) == 0 ); } @@ -118,8 +123,9 @@ void ULEdec::handleTSPacket(senf::TransportPacket ts_packet) case 1: { // a PUSI value of 1 indicates the presence of a Payload Pointer. unsigned char payload_pointer = *payload_iter++; - if (payload_pointer > 181) { - std::cerr << "invalid payload_pointer\n"; + if (payload_pointer > MAX_PAYLOAD_POINTER) { + std::cerr << str( boost::format( + "invalid payload_pointer (%d)\n") % unsigned(payload_pointer) ) ; this->receiver_state = Idle; return; } @@ -131,7 +137,9 @@ void ULEdec::handleTSPacket(senf::TransportPacket ts_packet) // Reassembly Payload Pointer Checking if (snduPacketBytesLeft() != payload_pointer) { // delimiting error - std::cerr << "delimiting error 2\n"; + std::cerr << str( boost::format( + "delimiting error: bytes left in SNDU packet != payload_pointer (" + "(%d != %d)\n") % snduPacketBytesLeft() % payload_pointer ); std::advance(payload_iter, payload_pointer); } else { payload_iter = readContSNDUPacket( payload_iter, payload_end ); @@ -185,7 +193,8 @@ ULEdec::iterator ULEdec::readNewSNDUPacket(iterator i, iterator const i_end) dbit = true; } if (sndu_length < 5 || sndu_length == 0xffff) { - throw ULEdecException("SNDU length error"); + throw ULEdecException( str( boost::format( + "SNDU length error. length=%d") % sndu_length) ); } this->snduPacket = senf::SNDUPacket::create(sndu_length+4); this->snduPacket->d_bit() = dbit; @@ -227,7 +236,9 @@ void ULEdec::handleSNDUPacket() this->snduPacket.dump(std::cout); std::cout << "----------------------------------------------------------------------------\n\n"; if (this->snduPacket->crc() != this->snduPacket->calcCrc()) { - throw ULEdecException("CRC Error"); + throw ULEdecException( str( boost::format( + "CRC Error. received crc:%d calculated crc:%d") + % this->snduPacket->crc() % this->snduPacket->calcCrc() ) ); } // senf::Packet nextPacket = this->snduPacket.next(); // senf::hexdump( diff --git a/Examples/DVBAdapter/ULEdec.hh b/Examples/DVBAdapter/ULEdec.hh index 7dcf9f8..03ab0fc 100644 --- a/Examples/DVBAdapter/ULEdec.hh +++ b/Examples/DVBAdapter/ULEdec.hh @@ -68,6 +68,7 @@ private: struct ULEdecException : public std::exception { ULEdecException(char const * what) : what_(what) {}; + ULEdecException(std::string const what) : what_(what) {}; virtual char const * what() const throw() { return what_.c_str(); } virtual ~ULEdecException() throw() {}; std::string what_; diff --git a/Packets/MPEGDVBBundle/SNDUPacket.cc b/Packets/MPEGDVBBundle/SNDUPacket.cc index 900b3db..39784e9 100644 --- a/Packets/MPEGDVBBundle/SNDUPacket.cc +++ b/Packets/MPEGDVBBundle/SNDUPacket.cc @@ -77,7 +77,7 @@ prefix_ senf::PacketInterpreterBase::factory_t senf::SNDUPacketType::nextPacketT if (p->type() < 1536) e = PacketRegistry::lookup( p->type(), nothrow ); else - e = PacketRegistry::lookup( 0x86dd, nothrow ); + e = PacketRegistry::lookup( p->type(), nothrow ); return e ? e->factory() : no_factory(); }