Skip to content
Snippets Groups Projects
Commit 8fc96819 authored by atx23's avatar atx23
Browse files

added consolewrapper vor DVB-Demuxfilter

parent 93f58a75
No related branches found
No related tags found
No related merge requests found
......@@ -92,10 +92,19 @@ prefix_ unsigned senf::DVBDemuxPESSocketProtocol::available()
return 4096; //???
}
prefix_ void senf::DVBDemuxPESSocketProtocol::setPESFilter(struct dmx_pes_filter_params *filter)
prefix_ void senf::DVBDemuxPESSocketProtocol::setPESFilter(unsigned short int pid, dmx_input_t input, dmx_output_t output, dmx_pes_type_t pesType, unsigned int flags)
const
{
if (::ioctl(fd(), DMX_SET_PES_FILTER, filter) < 0)
struct dmx_pes_filter_params pes_filter;
::memset(&pes_filter, 0, sizeof(struct dmx_pes_filter_params));
pes_filter.pid = pid;
pes_filter.input = input;
pes_filter.output = output;
pes_filter.pes_type = pesType;
pes_filter.flags = flags;
if (::ioctl(fd(), DMX_SET_PES_FILTER, &pes_filter) < 0)
SENF_THROW_SYSTEM_EXCEPTION("Could not set PES filter of DVB adapter.");
}
......
......@@ -34,6 +34,9 @@
#include "DVBDemuxSocketProtocol.hh"
//#include "DVBDemuxHandles.mpp"
#include <boost/enable_shared_from_this.hpp>
#include <boost/shared_ptr.hpp>
#include <iostream>
///////////////////////////////hh.p////////////////////////////////////////
namespace senf {
......@@ -51,10 +54,36 @@ namespace senf {
/** \brief xxx
*/
class DVBPrococolWrapper :public boost::enable_shared_from_this<DVBPrococolWrapper> {
public:
DVBPrococolWrapper(){}
virtual ~DVBPrococolWrapper(){}
};
class DVBSocketProtocol : public virtual SocketProtocol {
private:
boost::shared_ptr<DVBPrococolWrapper> wrap_;
public:
DVBSocketProtocol() {}
~DVBSocketProtocol() {}
void addWrapper(boost::shared_ptr<DVBPrococolWrapper> wrap) {
wrap_ = wrap;
}
virtual void close(){
wrap_.reset();
SocketProtocol::close();
}
};
class DVBDemuxSectionSocketProtocol
: public ConcreteSocketProtocol<DVBDemux_Policy, DVBDemuxSectionSocketProtocol>,
public DVBDemuxSocketProtocol
public DVBDemuxSocketProtocol,
public DVBSocketProtocol
{
public:
///////////////////////////////////////////////////////////////////////////
// internal interface
......@@ -76,11 +105,12 @@ namespace senf {
///@}
void setSectionFilter(unsigned short int pid,
unsigned char filter,
unsigned int flags,
unsigned char mask,
unsigned char mode,
unsigned int timeout ) const;
unsigned char filter= 0x3e,
unsigned int flags= DMX_IMMEDIATE_START | DMX_CHECK_CRC,
unsigned char mask = 0xff,
unsigned char mode =0x00,
unsigned int timeout =0x00) const;
};
typedef ProtocolClientSocketHandle<DVBDemuxSectionSocketProtocol> DVBDemuxSectionHandle;
......@@ -91,7 +121,8 @@ namespace senf {
*/
class DVBDemuxPESSocketProtocol
: public ConcreteSocketProtocol<DVBDemux_Policy,DVBDemuxPESSocketProtocol>,
public DVBDemuxSocketProtocol
public DVBDemuxSocketProtocol,
public DVBSocketProtocol
{
public:
///////////////////////////////////////////////////////////////////////////
......@@ -113,7 +144,7 @@ namespace senf {
///@}
void setPESFilter(struct dmx_pes_filter_params *filter) const;
void setPESFilter(unsigned short int pid, dmx_input_t input, dmx_output_t output, dmx_pes_type_t pesType, unsigned int flags)const;
};
typedef ProtocolClientSocketHandle<DVBDemuxPESSocketProtocol> DVBDemuxPESHandle;
......
......@@ -74,6 +74,8 @@ namespace senf {
private:
void tune(const struct dvb_frontend_parameters & frontend) const;
public:
///////////////////////////////////////////////////////////////////////////
// internal interface
......@@ -86,6 +88,7 @@ namespace senf {
constructor */
///@}
void setNonBlock(bool on = true) const;
void tuneDVB_S(unsigned int frequency, fe_spectral_inversion_t inversion, unsigned int symbole_rate, fe_code_rate_t code_rate) const;
......
// $Id: DVBSocketController.cc 1119 2009-02-16 13:36:59Z tho $
//
// Copyright (C) 2007
// Fraunhofer Institute for Open Communication Systems (FOKUS)
// Competence Center NETwork research (NET), St. Augustin, GERMANY
// Anton Gillert <atx@berlios.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 DVBSocketController non-inline non-template implementation */
#include "DVBProtocolWrapper.hh"
// Custom includes
#define prefix_
///////////////////////////////cc.p////////////////////////////////////////
///////////////////////////////cc.e////////////////////////////////////////
#undef prefix_
// $Id: DVBSocketController.hh 1119 2009-02-16 13:36:59Z tho $
//
// Copyright (C) 2007
// Fraunhofer Institute for Open Communication Systems (FOKUS)
// Competence Center NETwork research (NET), St. Augustin, GERMANY
// Anton Gillert <atx@berlios.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.
#ifndef HH_SENF_Socket_Protocols_DVB_DVBProtocolWrapper_
#define HH_SENF_Socket_Protocols_DVB_DVBProtocolWrapper_ 1
#include "senf/Utils/Console/Console.hh"
#include "senf/Utils/Console/Console.hh"
#include "DVBDemuxHandles.hh"
// Custom includes
SENF_CONSOLE_REGISTER_ENUM( dmx_input_t, (DMX_IN_FRONTEND)(DMX_IN_DVR) )
;
SENF_CONSOLE_REGISTER_ENUM( dmx_output_t, (DMX_OUT_DECODER)(DMX_OUT_TAP)(DMX_OUT_TS_TAP) )
;
SENF_CONSOLE_REGISTER_ENUM( dmx_pes_type_t, (DMX_PES_AUDIO0)(DMX_PES_VIDEO0)(DMX_PES_TELETEXT0)(DMX_PES_SUBTITLE0)(DMX_PES_PCR0)
(DMX_PES_AUDIO1)(DMX_PES_VIDEO1)(DMX_PES_TELETEXT1)(DMX_PES_SUBTITLE1)(DMX_PES_PCR1)
(DMX_PES_AUDIO2)(DMX_PES_VIDEO2)(DMX_PES_TELETEXT2)(DMX_PES_SUBTITLE2)(DMX_PES_PCR2)
(DMX_PES_AUDIO3)(DMX_PES_VIDEO3)(DMX_PES_TELETEXT3)(DMX_PES_SUBTITLE3)(DMX_PES_PCR3)
(DMX_PES_OTHER))
;
namespace senf {
/** \brief Helperclass for configuration and controlling DVB protokoll handles.
*/
class DVBSectionProtocolWrapper : public senf::DVBPrococolWrapper {
public:
enum Flags {CHECK_CRC = DMX_CHECK_CRC,
ONESHOT = DMX_ONESHOT,
IMMEDIATE_START = DMX_IMMEDIATE_START,
KERNEL_CLIENT = DMX_KERNEL_CLIENT};
senf::console::ScopedDirectory<DVBSectionProtocolWrapper> dir;
private:
const senf::DVBDemuxSectionSocketProtocol& protocol;
public:
DVBSectionProtocolWrapper(senf::DVBDemuxSectionHandle sh) :
dir(this), protocol(sh.protocol()) {
namespace kw = senf::console::kw;
dir.add("buffersize", &DVBSectionProtocolWrapper::setBufferSize)
.doc("Set the size of the circular buffer used for filtered data.")
.arg("size", "in byte");
dir.add("start", &DVBSectionProtocolWrapper::startFiltering)
.doc("Starts filtering");
dir.add("stop", &DVBSectionProtocolWrapper::setBufferSize)
.doc("Stops filtering");
dir.node().add("filter", boost::function<void (unsigned short int, unsigned, senf::console::FlagCollection<Flags>, unsigned, unsigned, unsigned)>(senf::membind(&DVBSectionProtocolWrapper::setSectionFilter, this)))
.arg("pid", "pid to filter")
.arg("filter", "filter", kw::default_value = 62, kw::default_doc = "0x3e")
.arg("flags", "or-able: CHECK_CRC, ONESHOT, IMMEDIATE_START, KERNEL_CLIENT", kw::default_value = DMX_IMMEDIATE_START | DMX_CHECK_CRC, kw::default_doc = "(IMMEDIATE_START CHECK_CRC)")
.arg("mask", "mask", kw::default_value = 0xff, kw::default_doc = "0xff")
.arg("mode", "mode", kw::default_value = 0, kw::default_doc = "0x00")
.arg("timeout", "timeout", kw::default_value = 0, kw::default_doc = "0x00")
.doc("Sets parameters for section filter.");
dir.add("stop", &DVBSectionProtocolWrapper::setBufferSize)
.doc("Stops filtering");
}
~DVBSectionProtocolWrapper() {
}
void setSectionFilter(unsigned short int pid, u_int8_t filter,
unsigned int flags, u_int8_t mask, u_int8_t mode,
unsigned int timeout) {
protocol.setSectionFilter(pid, timeout, flags, filter, mask, mode);
}
///< Set the size of the circular buffer used for filtered data.
/**< The default size is two maximum sized sections, i.e. if
this function is not called a buffer size of 2 * 4096
bytes will be used.
\param[in] size Size of circular buffer. */
void setBufferSize(unsigned long size) {
protocol.setBufferSize(size);
}
void startFiltering() ///< Starts filtering
{
protocol.startFiltering();
}
void stopFiltering() ///< Stops filtering
{
protocol.stopFiltering();
}
};
SENF_CONSOLE_REGISTER_ENUM_MEMBER(DVBSectionProtocolWrapper, Flags,
(CHECK_CRC)(ONESHOT)(IMMEDIATE_START)(KERNEL_CLIENT))
;
class DVBPESProtocolWrapper : public senf::DVBPrococolWrapper {
public:
enum Flags {CHECK_CRC = DMX_CHECK_CRC,
ONESHOT = DMX_ONESHOT,
IMMEDIATE_START = DMX_IMMEDIATE_START,
KERNEL_CLIENT = DMX_KERNEL_CLIENT};
senf::console::ScopedDirectory<DVBPESProtocolWrapper> dir;
private:
const senf::DVBDemuxPESSocketProtocol& protocol;
public:
DVBPESProtocolWrapper(senf::DVBDemuxPESHandle sh) :
dir(this), protocol(sh.protocol()) {
namespace kw = senf::console::kw;
dir.node().add("filter", boost::function<void ( unsigned short int, dmx_input_t, dmx_output_t, dmx_pes_type_t, senf::console::FlagCollection<Flags>)>(senf::membind(&DVBPESProtocolWrapper::setPESFilter, this)))
.arg("pid", "pid to filter")
.arg("input", "input-filter: DMX_IN_FRONTEND DMX_IN_DVR ")
.arg("output", "output-filter: DMX_OUT_DECODER DMX_OUT_TAP DMX_OUT_TS_TAP ")
.arg("pesType", "PES type: DMX_PES_AUDIO[0-3] DMX_PES_VIDEO[0-3] DMX_PES_TELETEXT[0-3], DMX_PES_SUBTITLE[0-3], DMX_PES_PCR[0-3], DMX_PES_OTHER")
.arg("flags", "or-able: CHECK_CRC, ONESHOT, IMMEDIATE_START, KERNEL_CLIENT", kw::default_value = DMX_IMMEDIATE_START | DMX_CHECK_CRC, kw::default_doc = "(IMMEDIATE_START CHECK_CRC)")
.doc("Sets parameters for PES filter.");
dir.add("start", &DVBPESProtocolWrapper::startFiltering)
.doc("Starts filtering");
dir.add("stop", &DVBPESProtocolWrapper::stopFiltering)
.doc("Stops filtering");
}
~DVBPESProtocolWrapper() {
}
;
void setPESFilter(unsigned short int pid, dmx_input_t input,
dmx_output_t output, dmx_pes_type_t pesType, unsigned int flags) {
protocol.setPESFilter(pid, input, output, pesType, flags);
}
void startFiltering() ///< Starts filtering
{
protocol.startFiltering();
}
void stopFiltering() ///< Stops filtering
{
protocol.stopFiltering();
}
};
SENF_CONSOLE_REGISTER_ENUM_MEMBER(DVBPESProtocolWrapper, Flags,
(CHECK_CRC)(ONESHOT)(IMMEDIATE_START)(KERNEL_CLIENT))
;
}
#endif
......@@ -21,7 +21,7 @@
// 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
/** \file
\brief DVBSocketController non-inline non-template implementation */
\brief DVBSocketControlle-r non-inline non-template implementation */
#include "DVBSocketController.hh"
......@@ -30,19 +30,23 @@
#include "senf/Utils/Exception.hh"
#include "senf/Utils/Logger/Logger.hh"
#include "senf/Utils/membind.hh"
#include <boost/shared_ptr.hpp>
#define prefix_
///////////////////////////////cc.p////////////////////////////////////////
using namespace std;
senf::DVBSocketController::DVBSocketController(DVBFrontendHandle frontendHandle_, DVBDemuxSectionHandle sectionHandle_ , const Callback & cb_)
unsigned int senf::DVBSocketController::controllerNr(0);
senf::DVBSocketController::DVBSocketController(DVBFrontendHandle frontendHandle_, const Callback & cb_)
: dir( this ),
frontendHandle( frontendHandle_ ),
sectionHandle( sectionHandle_ ),
type( frontendHandle.protocol().getInfo().type ),
parser( type ),
cb( cb_ ),
sectionNr(1),
pesNr(1),
event( "senf::DVBSocketController::readEvent", senf::membind(&DVBSocketController::readEvent, this), frontendHandle, senf::scheduler::FdEvent::EV_PRIO, false )
{
initConsole();
......@@ -52,6 +56,35 @@ prefix_ senf::DVBSocketController::~DVBSocketController()
{
}
prefix_ senf::DVBDemuxSectionHandle senf::DVBSocketController::createDVBDemuxSectionHandle( int adapternumber, int demuxnumber, bool addToConsole ){
DVBDemuxSectionHandle sectionHandle(adapternumber, demuxnumber);
if(addToConsole)
this->addToConsole(sectionHandle);
return sectionHandle;
}
prefix_ senf::DVBDemuxPESHandle senf::DVBSocketController::createDVBDemuxPESHandle( int adapternumber, int demuxnumber, bool addToConsole ){
DVBDemuxPESHandle pesHandle(adapternumber, demuxnumber);
if(addToConsole )
this->addToConsole(pesHandle);
return pesHandle;
}
prefix_ void senf::DVBSocketController::addToConsole(senf::DVBDemuxSectionHandle sh){
boost::shared_ptr<DVBSectionProtocolWrapper> wrap(new DVBSectionProtocolWrapper(sh));
sh.protocol().addWrapper(wrap);
dir.node().add("section" + senf::str(sectionNr), wrap->dir);
sectionNr++;
}
prefix_ void senf::DVBSocketController::addToConsole(senf::DVBDemuxPESHandle sh){
boost::shared_ptr<DVBPESProtocolWrapper> wrap(new DVBPESProtocolWrapper(sh));
sh.protocol().addWrapper(wrap);
dir.node().add("pes"+ senf::str(pesNr), wrap->dir);
pesNr++;
}
prefix_ void senf::DVBSocketController::tuneToCMD(const string & input, const string & mode)
{
struct dvb_frontend_parameters frontend;
......@@ -364,31 +397,7 @@ prefix_ string senf::DVBSocketController::status2String(fe_status_t status)
return s;
}
prefix_ void senf::DVBSocketController::setSectionFilter(unsigned short int pid,
u_int8_t filter,
unsigned int flags,
u_int8_t mask,
u_int8_t mode,
unsigned int timeout)
{
sectionHandle.protocol().setSectionFilter(pid, timeout, flags, filter, mask, mode);
}
prefix_ void senf::DVBSocketController::setBufferSize(unsigned long size)
{
sectionHandle.protocol().setBufferSize(size);
}
prefix_ void senf::DVBSocketController::startFiltering()
{
sectionHandle.protocol().startFiltering();
}
prefix_ void senf::DVBSocketController::stopFiltering()
{
sectionHandle.protocol().stopFiltering();
}
prefix_ fe_type_t senf::DVBSocketController::getType()
{
......@@ -405,7 +414,8 @@ prefix_ void senf::DVBSocketController::initConsole()
{
// binding functions to console
namespace kw = senf::console::kw;
dir.doc("DVB Controller");
dir.doc("DVB Controller " + controllerNr);
++controllerNr;
dir.add("type", &DVBSocketController::getTypeString)
.doc("Shows actual type of card DVB-{T, S, C}");
......@@ -426,28 +436,6 @@ prefix_ void senf::DVBSocketController::initConsole()
.doc("tunes to channel listet in the configfile.")
.arg("channel", "channel to tune")
.arg("mode", "mode \"sync\" or \"async\"", kw::default_value = "async");
dir.add("buffersize", &DVBSocketController::setBufferSize)
.doc("Set the size of the circular buffer used for filtered data.")
.arg("size", "in byte");
dir.add("start", &DVBSocketController::startFiltering)
.doc("Starts filtering");
dir.add("stop", &DVBSocketController::setBufferSize)
.doc("Stops filtering");
dir.add("filter", &DVBSocketController::setSectionFilter)
.arg("pid", "pid to filter")
.arg("filter", "filter", kw::default_value = 62, kw::default_doc = "0x3e")
.arg("flags", "or-able: DMX_CHECK_CRC(0x01), DMX_ONESHOT(0x02), DMX_IMMEDIATE_START(0x04), DMX_KERNEL_CLIENT(0x8000)", kw::default_value = DMX_IMMEDIATE_START | DMX_CHECK_CRC, kw::default_doc = "0x05")
.arg("mask", "mask", kw::default_value = 0xff, kw::default_doc = "0xff")
.arg("mode", "mode", kw::default_value = 0, kw::default_doc = "0x00")
.arg("timeout", "timeout", kw::default_value = 0, kw::default_doc = "0x00")
.doc("Sets parameters for section filter.");
dir.add("stop", &DVBSocketController::setBufferSize)
.doc("Stops filtering");
}
///////////////////////////////cc.e////////////////////////////////////////
......
......@@ -30,6 +30,7 @@
#include "DVBFrontendHandle.hh"
#include "DVBDemuxHandles.hh"
#include "DVBConfigParser.hh"
#include "DVBProtocolWrapper.hh"
#include "../../../Scheduler/Scheduler.hh"
#include "../../../Utils/Console/Console.hh"
......@@ -52,17 +53,37 @@ namespace senf {
You have to find out which parts of these functionality are implemented by your preferred
device driver by your own.
*/
class DVBSocketController : boost::noncopyable
{
public:
senf::console::ScopedDirectory<DVBSocketController> dir;
typedef boost::function<void (const struct dvb_frontend_event & )> Callback;
///< Callback which is called when an asynchronous tuning succeeds.
DVBSocketController(DVBFrontendHandle frontendHandle_ = DVBFrontendHandle(0,0), DVBDemuxSectionHandle sectionHandle_ = DVBDemuxSectionHandle(0,0), const Callback & cb = NULL);
DVBSocketController(DVBFrontendHandle frontendHandle_ = DVBFrontendHandle(0,0), const Callback & cb = NULL);
~DVBSocketController();
senf::DVBDemuxSectionHandle createDVBDemuxSectionHandle( int adapternumber=0, int demuxnumber=0, bool addToConsole=false );
senf::DVBDemuxPESHandle createDVBDemuxPESHandle( int adapternumber=0, int demuxnumber=0, bool addToConsole=false );
void addToConsole(senf::DVBDemuxSectionHandle sh);
///< Adds an DVBDemuxSectionHandle to the console
/**< Allocates the functionality of DVBDemuxSectionProtocol into the folder
of the DVBSocketController. If the protocol is closed, or all handles are
discarded the console support will automatically removed.
\param[in] handle of a protocol*/
void addToConsole(senf::DVBDemuxPESHandle sh);
///< Adds an DVBDemuxPESHandle to the console
/**< Allocates the functionality of DVBDemuxPESProtocol into the folder
of the DVBSocketController. If the protocol is closed, or all handles are
discarded the console support will automatically removed.
\param[in] handle of a protocol*/
void tuneToCMD( const std::string & input, const std::string & mode = "async");
///< Tunes a DVB device given by the type of the DVBFrontendHandle
/**< Tunes a DVB device by a channel name or complete
......@@ -189,25 +210,6 @@ public:
specific driver implementation. In this case the output is
random.*/
void setSectionFilter(unsigned short int pid,
u_int8_t filter = MPE_TABLEID,
unsigned int flags = DMX_IMMEDIATE_START | DMX_CHECK_CRC,
u_int8_t mask = 0xff,
u_int8_t mode = 0,
unsigned int timeout = 0);
///< Set the section filter
void setBufferSize(unsigned long size);
///< Set the size of the circular buffer used for filtered data.
/**< The default size is two maximum sized sections, i.e. if
this function is not called a buffer size of 2 * 4096
bytes will be used.
\param[in] size Size of circular buffer. */
void startFiltering(); ///< Starts filtering
void stopFiltering(); ///< Stops filtering
std::string getTuneInfo(const std::string & conf ="Ssbuf");
///< Returns a string which shows actual tuning status
/**< <br>"S" prints signal strength (in hex)
......@@ -221,12 +223,13 @@ public:
an exception! */
private:
DVBFrontendHandle frontendHandle;
senf::DVBDemuxSectionHandle sectionHandle;
fe_type_t type;
DVBConfigParser parser;
Callback cb;
static unsigned int controllerNr;
unsigned int sectionNr;
unsigned int pesNr;
senf::scheduler::FdEvent event;
void readEvent(int i);
void initConsole();
};
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment