//
// 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.
+// The contents of this file are subject to the Fraunhofer FOKUS Public License
+// Version 1.0 (the "License"); you may not use this file except in compliance
+// with the License. You may obtain a copy of the License at
+// http://senf.berlios.de/license.html
//
-// 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.
+// The Fraunhofer FOKUS Public License Version 1.0 is based on,
+// but modifies the Mozilla Public License Version 1.1.
+// See the full license text for the amendments.
//
-// 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.
-
+// Software distributed under the License is distributed on an "AS IS" basis,
+// WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
+// for the specific language governing rights and limitations under the License.
+//
+// The Original Code is Fraunhofer FOKUS code.
+//
+// The Initial Developer of the Original Code is Fraunhofer-Gesellschaft e.V.
+// (registered association), Hansastraße 27 c, 80686 Munich, Germany.
+// All Rights Reserved.
+//
+// Contributor(s):
+// Anton Gillert <atx@berlios.de>
/** \file
- \brief DVBSocketControlle-r non-inline non-template implementation */
+ \brief DVBSocketController non-inline non-template implementation */
#include "DVBSocketController.hh"
#include <senf/Utils/Exception.hh>
#include <senf/Utils/Logger/Logger.hh>
#include <senf/Utils/membind.hh>
+#include <senf/Utils/Console/ParsedCommand.hh>
#include <boost/shared_ptr.hpp>
+#include "DVBProtocolWrapper.hh"
#define prefix_
-///////////////////////////////cc.p////////////////////////////////////////
-
-using namespace std;
+//-/////////////////////////////////////////////////////////////////////////////////////////////////
unsigned int senf::DVBSocketController::controllerNr(0);
-senf::DVBSocketController::DVBSocketController(DVBFrontendHandle frontendHandle_, const Callback & cb_)
+senf::DVBSocketController::DVBSocketController(DVBFrontendHandle frontendHandle_,
+ const Callback & cb_)
: dir( this ),
frontendHandle( frontendHandle_ ),
type( frontendHandle.protocol().getInfo().type ),
cb( cb_ ),
sectionNr(1),
pesNr(1),
- event( "senf::DVBSocketController::readEvent", senf::membind(&DVBSocketController::readEvent, this), frontendHandle, senf::scheduler::FdEvent::EV_PRIO, false )
+ event( "senf::DVBSocketController::readEvent",
+ senf::membind(&DVBSocketController::readEvent, this), frontendHandle,
+ senf::scheduler::FdEvent::EV_PRIO, false )
{
initConsole();
}
senf::DVBSocketController::createDVBDemuxSectionHandle(int adapternumber, int demuxnumber,
bool addToConsole)
{
- DVBDemuxSectionHandle sectionHandle(adapternumber, demuxnumber);
+ 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);
+ DVBDemuxPESHandle pesHandle(adapternumber, demuxnumber);
if (addToConsole)
this->addToConsole(pesHandle);
return pesHandle;
-
+
}
prefix_ void senf::DVBSocketController::addToConsole(senf::DVBDemuxSectionHandle sh)
pesNr++;
}
-prefix_ void senf::DVBSocketController::tuneToCMD(const string & input, const string & mode)
+prefix_ void senf::DVBSocketController::tuneToCMD(std::string const & input, std::string const & mode)
{
struct dvb_frontend_parameters frontend;
// no valid configline, so it will be treaten like a channel name
- if (input.find(":")==string::npos)
+ if (input.find(":") == std::string::npos)
{
if (mode.c_str()[0]=='a')
tuneTo(input);
if (mode.c_str()[0]=='a') {
switch (type) {
case FE_QPSK:
- tuneDVB_S(frontend.frequency, frontend.inversion, frontend.u.qpsk.symbol_rate, frontend.u.qpsk.fec_inner);
+ tuneDVB_S(frontend.frequency, frontend.inversion, frontend.u.qpsk.symbol_rate,
+ frontend.u.qpsk.fec_inner);
break;
case FE_QAM:
- tuneDVB_C(frontend.frequency, frontend.inversion, frontend.u.qam.symbol_rate, frontend.u.qam.fec_inner, frontend.u.qam.modulation);
+ tuneDVB_C(frontend.frequency, frontend.inversion, frontend.u.qam.symbol_rate,
+ frontend.u.qam.fec_inner, frontend.u.qam.modulation);
break;
case FE_OFDM:
- tuneDVB_T(frontend.frequency, frontend.inversion, frontend.u.ofdm.bandwidth, frontend.u.ofdm.code_rate_HP, frontend.u.ofdm.code_rate_LP, frontend.u.ofdm.constellation, frontend.u.ofdm.transmission_mode, frontend.u.ofdm.guard_interval, frontend.u.ofdm.hierarchy_information);
+ tuneDVB_T(frontend.frequency, frontend.inversion, frontend.u.ofdm.bandwidth,
+ frontend.u.ofdm.code_rate_HP, frontend.u.ofdm.code_rate_LP,
+ frontend.u.ofdm.constellation, frontend.u.ofdm.transmission_mode,
+ frontend.u.ofdm.guard_interval, frontend.u.ofdm.hierarchy_information);
break;
default:
SENF_THROW_SYSTEM_EXCEPTION("Could not determine type of card.");
else {
switch (type) {
case FE_QPSK:
- tuneDVB_S_sync(frontend.frequency, frontend.inversion, frontend.u.qpsk.symbol_rate, frontend.u.qpsk.fec_inner);
+ tuneDVB_S_sync(frontend.frequency, frontend.inversion, frontend.u.qpsk.symbol_rate,
+ frontend.u.qpsk.fec_inner);
break;
case FE_QAM:
- tuneDVB_C_sync(frontend.frequency, frontend.inversion, frontend.u.qam.symbol_rate, frontend.u.qam.fec_inner, frontend.u.qam.modulation);
+ tuneDVB_C_sync(frontend.frequency, frontend.inversion, frontend.u.qam.symbol_rate,
+ frontend.u.qam.fec_inner, frontend.u.qam.modulation);
break;
case FE_OFDM:
- tuneDVB_T_sync(frontend.frequency, frontend.inversion, frontend.u.ofdm.bandwidth, frontend.u.ofdm.code_rate_HP, frontend.u.ofdm.code_rate_LP, frontend.u.ofdm.constellation, frontend.u.ofdm.transmission_mode, frontend.u.ofdm.guard_interval, frontend.u.ofdm.hierarchy_information);
+ tuneDVB_T_sync(frontend.frequency, frontend.inversion, frontend.u.ofdm.bandwidth,
+ frontend.u.ofdm.code_rate_HP, frontend.u.ofdm.code_rate_LP,
+ frontend.u.ofdm.constellation, frontend.u.ofdm.transmission_mode,
+ frontend.u.ofdm.guard_interval,
+ frontend.u.ofdm.hierarchy_information);
break;
default:
SENF_THROW_SYSTEM_EXCEPTION("Could not determine type of card.");
}
}
-prefix_ void senf::DVBSocketController::tuneTo(const string & channel)
+prefix_ void senf::DVBSocketController::tuneTo(std::string const & channel)
{
struct dvb_frontend_parameters frontend;
- string configLine = parser.getConfigLine(channel);
+ std::string configLine = parser.getConfigLine(channel);
frontend = parser.getFrontendParam(configLine);
switch (type) {
case FE_QPSK:
- tuneDVB_S(frontend.frequency, frontend.inversion, frontend.u.qpsk.symbol_rate, frontend.u.qpsk.fec_inner);
+ tuneDVB_S(frontend.frequency, frontend.inversion, frontend.u.qpsk.symbol_rate,
+ frontend.u.qpsk.fec_inner);
break;
case FE_QAM:
- tuneDVB_C(frontend.frequency, frontend.inversion, frontend.u.qam.symbol_rate, frontend.u.qam.fec_inner, frontend.u.qam.modulation);
+ tuneDVB_C(frontend.frequency, frontend.inversion, frontend.u.qam.symbol_rate,
+ frontend.u.qam.fec_inner, frontend.u.qam.modulation);
break;
case FE_OFDM:
- tuneDVB_T(frontend.frequency, frontend.inversion, frontend.u.ofdm.bandwidth, frontend.u.ofdm.code_rate_HP, frontend.u.ofdm.code_rate_LP, frontend.u.ofdm.constellation, frontend.u.ofdm.transmission_mode, frontend.u.ofdm.guard_interval, frontend.u.ofdm.hierarchy_information);
+ tuneDVB_T(frontend.frequency, frontend.inversion, frontend.u.ofdm.bandwidth,
+ frontend.u.ofdm.code_rate_HP, frontend.u.ofdm.code_rate_LP,
+ frontend.u.ofdm.constellation, frontend.u.ofdm.transmission_mode,
+ frontend.u.ofdm.guard_interval, frontend.u.ofdm.hierarchy_information);
break;
default:
SENF_THROW_SYSTEM_EXCEPTION("Could not determine type of card.");
)
{
if (type != FE_OFDM)
- SENF_THROW_SYSTEM_EXCEPTION("Type of card is: ") << getTypeString() << " for this operation you need a DVB-T Card!";
+ SENF_THROW_SYSTEM_EXCEPTION("Type of card is: ")
+ << getTypeString() << " for this operation you need a DVB-T Card!";
event.enable();
hierarchy_information);
}
-prefix_ void senf::DVBSocketController::tuneDVB_S(unsigned int frequency, fe_spectral_inversion_t inversion, unsigned int symbole_rate, fe_code_rate_t code_rate)
+prefix_ void senf::DVBSocketController::tuneDVB_S(unsigned int frequency,
+ fe_spectral_inversion_t inversion,
+ unsigned int symbole_rate,
+ fe_code_rate_t code_rate)
{
if (type != FE_QPSK)
- SENF_THROW_SYSTEM_EXCEPTION("Type of card is: ") << getTypeString() << " for this operation you need a DVB-S Card!";
+ SENF_THROW_SYSTEM_EXCEPTION("Type of card is: ")
+ << getTypeString() << " for this operation you need a DVB-S Card!";
event.enable();
)
{
if (type != FE_QAM)
- SENF_THROW_SYSTEM_EXCEPTION("Type of card is: ") << getTypeString() << " for this operation you need a DVB-C Card!";
+ SENF_THROW_SYSTEM_EXCEPTION("Type of card is: ")
+ << getTypeString() << " for this operation you need a DVB-C Card!";
event.enable();
frontendHandle.protocol().tuneDVB_C(frequency, inversion, symbol_rate, fec_inner, modulation);
}
-prefix_ dvb_frontend_event senf::DVBSocketController::tuneTo_sync(const string & channel)
+prefix_ dvb_frontend_event senf::DVBSocketController::tuneTo_sync(std::string const & channel)
{
struct dvb_frontend_parameters frontend;
dvb_frontend_event ev;
- string configLine = parser.getConfigLine(channel);
+ std::string configLine = parser.getConfigLine(channel);
frontend = parser.getFrontendParam(configLine);
switch (type) {
case FE_QPSK:
- ev = tuneDVB_S_sync(frontend.frequency, frontend.inversion, frontend.u.qpsk.symbol_rate, frontend.u.qpsk.fec_inner);
+ ev = tuneDVB_S_sync(frontend.frequency, frontend.inversion,
+ frontend.u.qpsk.symbol_rate, frontend.u.qpsk.fec_inner);
break;
case FE_QAM:
- ev = tuneDVB_C_sync(frontend.frequency, frontend.inversion, frontend.u.qam.symbol_rate, frontend.u.qam.fec_inner, frontend.u.qam.modulation);
+ ev = tuneDVB_C_sync(frontend.frequency, frontend.inversion, frontend.u.qam.symbol_rate,
+ frontend.u.qam.fec_inner, frontend.u.qam.modulation);
break;
case FE_OFDM:
- ev = tuneDVB_T_sync(frontend.frequency, frontend.inversion, frontend.u.ofdm.bandwidth, frontend.u.ofdm.code_rate_HP, frontend.u.ofdm.code_rate_LP, frontend.u.ofdm.constellation, frontend.u.ofdm.transmission_mode, frontend.u.ofdm.guard_interval, frontend.u.ofdm.hierarchy_information);
+ ev = tuneDVB_T_sync(frontend.frequency, frontend.inversion, frontend.u.ofdm.bandwidth,
+ frontend.u.ofdm.code_rate_HP, frontend.u.ofdm.code_rate_LP,
+ frontend.u.ofdm.constellation, frontend.u.ofdm.transmission_mode,
+ frontend.u.ofdm.guard_interval,
+ frontend.u.ofdm.hierarchy_information);
break;
default:
SENF_THROW_SYSTEM_EXCEPTION("Could not determine type of card.");
)
{
if (type != FE_OFDM)
- SENF_THROW_SYSTEM_EXCEPTION("Type of card is: ") << getTypeString() << " for this operation you need a DVB-T Card!";
+ SENF_THROW_SYSTEM_EXCEPTION("Type of card is: ")
+ << getTypeString() << " for this operation you need a DVB-T Card!";
event.disable();
unsigned int symbole_rate, fe_code_rate_t code_rate)
{
if (type != FE_QPSK)
- SENF_THROW_SYSTEM_EXCEPTION("Type of card is: ") << getTypeString() << " for this operation you need a DVB-S Card!";
+ SENF_THROW_SYSTEM_EXCEPTION("Type of card is: ")
+ << getTypeString() << " for this operation you need a DVB-S Card!";
event.disable();
)
{
if (type != FE_QAM)
- SENF_THROW_SYSTEM_EXCEPTION("Type of card is: ") << getTypeString() << " for this operation you need a DVB-C Card!";
+ SENF_THROW_SYSTEM_EXCEPTION("Type of card is: ")
+ << getTypeString() << " for this operation you need a DVB-C Card!";
event.disable();
}
-prefix_ string senf::DVBSocketController::getTypeString()
+prefix_ std::string senf::DVBSocketController::getTypeString()
{
switch (type) {
case FE_QPSK:
return frontendHandle.protocol().signalStrength();
}
-prefix_ string senf::DVBSocketController::getTuneInfo(const string & conf)
+prefix_ std::string senf::DVBSocketController::getTuneInfo(std::string const & conf)
{
const char* cConf = conf.c_str();
- stringstream info;
+ std::stringstream info;
fe_status_t status;
frontendHandle.protocol().setNonBlock(false);
ber = frontendHandle.protocol().bitErrorRate();
uncorrected_blocks = frontendHandle.protocol().uncorrectedBlocks();
- info << hex;
+ info << std::hex;
for (unsigned int i = 0; i < conf.size(); ++i) {
if (i>0)
return info.str();
}
-prefix_ string senf::DVBSocketController::status2String(fe_status_t status)
+prefix_ std::string senf::DVBSocketController::status2String(fe_status_t status)
{
- string s("");
+ std::string s("");
if (status & FE_HAS_LOCK)
return s += "HAS LOCK";
if (status & FE_HAS_CARRIER)
return s;
}
-
-
prefix_ fe_type_t senf::DVBSocketController::getType()
{
return type;
prefix_ void senf::DVBSocketController::initConsole()
{
- namespace fty = senf::console::factory;
- namespace kw = senf::console::kw;
+ namespace fty = console::factory;
+ namespace kw = console::kw;
dir.doc("DVB Controller " + controllerNr);
++controllerNr;
dir.add("type", fty::Command(&DVBSocketController::getTypeString, this)
- .doc("Shows actual type of card DVB-{T, S, C}") );
+ .doc("Shows actual type of card DVB-{T, S, C}") );
dir.add("info", fty::Command(&DVBSocketController::getTuneInfo, this)
- .doc("Returns a string which shows actual tuning status.\n"
- "'S' prints signal strength (in hex)\n"
- "'s' prints singal to noise ration (in hex)\n"
- "'b' prints bit error rate (in hex)\n"
- "'u' prints uncorrected blocks (in hex)\n"
- "'f' prints readable overal status e.g. 'Has Lock'\n\n"
- "These characters can be used to form the output. Be aware, some\n"
- "features may not be supported be your current driver implementation\n"
- "and could end in throwing an exception!")
- .arg("conf", "Ssbuf", kw::default_value = "Ssbuf") );
+ .doc("Returns a string which shows actual tuning status.\n"
+ "'S' prints signal strength (in hex)\n"
+ "'s' prints singal to noise ration (in hex)\n"
+ "'b' prints bit error rate (in hex)\n"
+ "'u' prints uncorrected blocks (in hex)\n"
+ "'f' prints readable overal status e.g. 'Has Lock'\n\n"
+ "These characters can be used to form the output. Be aware, some\n"
+ "features may not be supported be your current driver implementation\n"
+ "and could end in throwing an exception!")
+ .arg("conf", "Ssbuf", kw::default_value = "Ssbuf") );
dir.add("tune", fty::Command(&DVBSocketController::tuneToCMD, this)
- .doc("tunes to channel listet in the configfile.")
- .arg("channel", "channel to tune")
- .arg("mode", "mode 'sync' or 'async'", kw::default_value = "async") );
+ .doc("tunes to channel listet in the configfile.")
+ .arg("channel", "channel to tune")
+ .arg("mode", "mode 'sync' or 'async'", kw::default_value = "async") );
}
-///////////////////////////////cc.e////////////////////////////////////////
+//-/////////////////////////////////////////////////////////////////////////////////////////////////
#undef prefix_
+
+\f
+// 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: