diff --git a/Examples/DVBdec/MPEdec.cc b/Examples/DVBAdapter/MPEdec.cc similarity index 100% rename from Examples/DVBdec/MPEdec.cc rename to Examples/DVBAdapter/MPEdec.cc diff --git a/Examples/DVBdec/SConscript b/Examples/DVBAdapter/SConscript similarity index 52% rename from Examples/DVBdec/SConscript rename to Examples/DVBAdapter/SConscript index f18f7dd02957bb215cd135e206312c32e8b0dd52..c1618e33b46313535128c270bb4ac14a71fbd706 100644 --- a/Examples/DVBdec/SConscript +++ b/Examples/DVBAdapter/SConscript @@ -1,12 +1,14 @@ Import('env') import SENFSCons -########################################################################### +import glob +import os.path -SENFSCons.Binary(env, 'uledec', 'ULEdec.cc', - LIBS = [ 'Scheduler', 'Packets', 'Socket', 'Utils' ], - OBJECTS = [ '#/Packets/MPEGDVBBundle/MPEGDVBBundle.o' ]); +########################################################################### -SENFSCons.Binary(env, 'mpedec', 'MPEdec.cc', +for f in glob.glob('*.cc'): + bin = os.path.splitext(f)[0] + + SENFSCons.Binary(env, bin, f, LIBS = [ 'Scheduler', 'Packets', 'Socket', 'Utils' ], OBJECTS = [ '#/Packets/MPEGDVBBundle/MPEGDVBBundle.o' ]); diff --git a/Examples/DVBdec/ULEdec.cc b/Examples/DVBAdapter/ULEdec.cc similarity index 100% rename from Examples/DVBdec/ULEdec.cc rename to Examples/DVBAdapter/ULEdec.cc diff --git a/Examples/DVBAdapter/frontend.cc b/Examples/DVBAdapter/frontend.cc new file mode 100644 index 0000000000000000000000000000000000000000..f29190548f0c14f275fa2312af5d8d7ce44479cf --- /dev/null +++ b/Examples/DVBAdapter/frontend.cc @@ -0,0 +1,73 @@ +// $Id: ULEdec.cc 327 2007-07-20 10:03:44Z tho $ +// +// Copyright (C) 2006 +// Fraunhofer Institut fuer offene Kommunikationssysteme (FOKUS) +// Kompetenzzentrum fuer Satelitenkommunikation (SatCom) +// Stefan Bund <stefan.bund@fokus.fraunhofer.de> +// +// 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. + +#include <string> +#include <iostream> +#include <iomanip> +#include <sys/ioctl.h> +#include <linux/sockios.h> +#include <linux/dvb/dmx.h> + +#include "Scheduler/Scheduler.hh" +#include "Packets/DefaultBundle/EthernetPacket.hh" +#include "Packets/MPEGDVBBundle/DatagramSection.hh" +#include "Utils/membind.hh" +#include "Socket/DVBFrontendHandle.hh" +#include "Packets/ParseInt.hh" +#include "Packets/Packet.hh" +#include "Packets/PacketData.hh" + +#define prefix_ +///////////////////////////////cc.p//////////////////////////////////////// + +int main(int argc, char const * argv[]) +{ + try { + senf::DVBFrontendHandle handle; + int16_t strength; + + while (true) { + handle.protocol().signalStrength(&strength); + std::cout << "signal strength: " << strength << "\n"; + sleep(1); + } + } + catch (std::exception const & ex) { + std::cerr << senf::prettyName(typeid(ex)) << ": " << ex.what() << "\n"; + } + return 0; +} + + +///////////////////////////////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/Packets/Mainpage.dox b/Packets/Mainpage.dox index 085525047e09581f25e810d80a647b5110840f90..f412bfa53106928181d26dc6272d32fbe7b96bae 100644 --- a/Packets/Mainpage.dox +++ b/Packets/Mainpage.dox @@ -135,7 +135,7 @@ \li <a href="../../DefaultBundle/doc/html/index.html">DefaultBundle</a>: Some basic default protocols: Ethernet, Ip, TCP, UDP - \li <a href="../../MPEG_DVBBundle/doc/html/index.html">MPEG_DVBBundle</a>: MPEG and DVB + \li <a href="../../MPEGDVBBundle/doc/html/index.html">MPEGDVBBundle</a>: MPEG and DVB protocols */ diff --git a/Socket/DVBDemuxHandles.hh b/Socket/DVBDemuxHandles.hh index 6823577459b3c646062a224fe88c770bd70400b8..574757dc36053d551db96024e176f6de6b86d876 100644 --- a/Socket/DVBDemuxHandles.hh +++ b/Socket/DVBDemuxHandles.hh @@ -28,11 +28,9 @@ #define HH_DVBDemuxHandles_ 1 // Custom includes -#include "BSDSocketProtocol.hh" #include "FramingPolicy.hh" #include "CommunicationPolicy.hh" #include "ReadWritePolicy.hh" -#include "BufferingPolicy.hh" #include "ProtocolClientSocketHandle.hh" #include "DVBDemuxProtocol.hh" diff --git a/Socket/DVBDemuxProtocol.cc b/Socket/DVBDemuxProtocol.cc index 00c07c5d439090203729f665a59c1c4812e5b85b..dcc3a62c5c7914d546187fdd108028dd687b7c09 100644 --- a/Socket/DVBDemuxProtocol.cc +++ b/Socket/DVBDemuxProtocol.cc @@ -39,8 +39,6 @@ #define prefix_ ///////////////////////////////cc.p//////////////////////////////////////// - - prefix_ void senf::DVBDemuxProtocol::setBufferSize(unsigned long size) const { diff --git a/Socket/DVBDemuxProtocol.hh b/Socket/DVBDemuxProtocol.hh index ab9e571718ce2cfbc1d31a9ea6b5f8951eb91079..9e2f4d0f45625307b4195ae31964e2afaf252060 100644 --- a/Socket/DVBDemuxProtocol.hh +++ b/Socket/DVBDemuxProtocol.hh @@ -31,7 +31,6 @@ // Custom includes #include "SocketProtocol.hh" -#include "INetAddressing.hh" //#include "DVBProtocol.mpp" ///////////////////////////////hh.p//////////////////////////////////////// @@ -54,15 +53,11 @@ namespace senf { ///\name Abstract Interface Implementation ///@{ - - //unsigned available() const; + bool eof() const; ///@} - - }; - } ///////////////////////////////hh.e//////////////////////////////////////// diff --git a/Socket/DVBFrontendHandle.cc b/Socket/DVBFrontendHandle.cc new file mode 100644 index 0000000000000000000000000000000000000000..651565d7209c49e9407f07affc5c5c85277923d3 --- /dev/null +++ b/Socket/DVBFrontendHandle.cc @@ -0,0 +1,98 @@ +// $Id: DVBDemuxHandles.cc 329 2007-07-20 12:29:34Z tho $ +// +// Copyright (C) 2007 +// Fraunhofer Institut fuer offene Kommunikationssysteme (FOKUS) +// Kompetenzzentrum fuer Satelitenkommunikation (SatCom) +// Stefan Bund <stefan.bund@fokus.fraunhofer.de> +// +// 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 xxx + */ + +#include "DVBFrontendHandle.hh" +//#include "DVBFrontendHandle.ih" + +// Custom includes +#include <sys/types.h> +#include <sys/socket.h> +#include <iostream> +#include <string> +#include <sys/ioctl.h> +#include <linux/sockios.h> +#include <stdio.h> +#include <fcntl.h> +#include "SocketHandle.hh" + +#include "Utils/Exception.hh" + +//#include "DVBFrontendHandle.mpp" +#define prefix_ +///////////////////////////////cc.p//////////////////////////////////////// + +/////////////////////////////////////////////////////////////////////////// +// senf::DVBFrontendHandle + +prefix_ void senf::DVBFrontendProtocol::init_client() + const +{ + int fd = open("/dev/dvb/adapter0/frontend0", O_RDONLY | O_NONBLOCK); + if (fd < 0) + throw SystemException(errno); + body().fd(fd); +} + +prefix_ unsigned senf::DVBFrontendProtocol::available() + const +{ + return 0; +} + +prefix_ bool senf::DVBFrontendProtocol::eof() + const +{ + return false; +} + +prefix_ std::auto_ptr<senf::SocketProtocol> senf::DVBFrontendProtocol::clone() + const +{ + return std::auto_ptr<SocketProtocol>(new DVBFrontendProtocol()); +} + + +prefix_ void senf::DVBFrontendProtocol::signalStrength(int16_t *strength) + const +{ + if (::ioctl(body().fd(), FE_READ_SIGNAL_STRENGTH, strength) < 0) + throw SystemException(errno); +} + +///////////////////////////////cc.e//////////////////////////////////////// +#undef prefix_ +//#include "DVBFrontendHandle.mpp" + + +// 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/Socket/DVBFrontendHandle.hh b/Socket/DVBFrontendHandle.hh new file mode 100644 index 0000000000000000000000000000000000000000..e8381b1a270df1fbdb8c1e4c25bd3e2e40fe7435 --- /dev/null +++ b/Socket/DVBFrontendHandle.hh @@ -0,0 +1,105 @@ +// $Id: DVBDemuxSectionHandle.hh 321 2007-07-19 09:00:23Z tho $ +// +// Copyright (C) 2007 +// Fraunhofer Institut fuer offene Kommunikationssysteme (FOKUS) +// Kompetenzzentrum fuer Satelitenkommunikation (SatCom) +// Stefan Bund <stefan.bund@fokus.fraunhofer.de> +// +// 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 DVBHandles + */ + +#ifndef HH_DVBFrontendHandle_ +#define HH_DVBFrontendHandle_ 1 + +// Custom includes +#include "FramingPolicy.hh" +#include "CommunicationPolicy.hh" +#include "ReadWritePolicy.hh" +#include "ProtocolClientSocketHandle.hh" +#include "SocketProtocol.hh" + +#include <linux/dvb/frontend.h> + +//#include "DVBFrontendHandle.mpp" +///////////////////////////////hh.p//////////////////////////////////////// + +namespace senf { + + /// \addtogroup concrete_protocol_group + /// @{ + + typedef MakeSocketPolicy< + NoAddressingPolicy, + DatagramFramingPolicy, + UnconnectedCommunicationPolicy, + NotReadablePolicy, + NotWriteablePolicy + >::policy DVBFrontend_Policy; ///< Socket Policy for xxxx + + /** \brief xxx + */ + class DVBFrontendProtocol + : public ConcreteSocketProtocol<DVBFrontend_Policy> + { + public: + /////////////////////////////////////////////////////////////////////////// + // internal interface + + ///\name Constructors + ///@{ + + void init_client() const; ///< xxx + /**< \note This member is implicitly called from the + ProtocolClientSocketHandle::ProtocolClientSocketHandle() + constructor */ + + ///@} + ///\name Abstract Interface Implementation + + unsigned available() const; + bool eof() const; + + std::auto_ptr<SocketProtocol> clone() const; + + ///@} + + void signalStrength(int16_t *strength) const; + }; + + typedef ProtocolClientSocketHandle<DVBFrontendProtocol> DVBFrontendHandle; + +} + + +///////////////////////////////hh.e//////////////////////////////////////// +//#include "DVBFrontendHandle.cci" +//#include "DVBFrontendHandle.ct" +//#include "DVBFrontendHandle.cti" +#endif + + +// 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: