summaryrefslogtreecommitdiff
path: root/p2pvr/devices
diff options
context:
space:
mode:
authorDan Goodliffe <dan@randomdan.homeip.net>2017-07-30 18:28:41 +0100
committerDan Goodliffe <dan@randomdan.homeip.net>2017-07-30 18:28:41 +0100
commitfe61ba505f3b1aa7401836a97dd32284f9932a74 (patch)
tree682d06a9f995216fd24cc60d555e6f2adbabefe5 /p2pvr/devices
parentTidy SQL statements into sub-dirs (diff)
downloadp2pvr-fe61ba505f3b1aa7401836a97dd32284f9932a74.tar.bz2
p2pvr-fe61ba505f3b1aa7401836a97dd32284f9932a74.tar.xz
p2pvr-fe61ba505f3b1aa7401836a97dd32284f9932a74.zip
Move everything out of the global namespace
Diffstat (limited to 'p2pvr/devices')
-rw-r--r--p2pvr/devices/frontend.cpp6
-rw-r--r--p2pvr/devices/frontend.h4
-rw-r--r--p2pvr/devices/frontends/ofdm.cpp14
-rw-r--r--p2pvr/devices/localDevices.cpp60
-rw-r--r--p2pvr/devices/localDevices.h22
-rw-r--r--p2pvr/devices/mockTuner.cpp4
-rw-r--r--p2pvr/devices/mockTuner.h28
-rw-r--r--p2pvr/devices/tuner.cpp56
-rw-r--r--p2pvr/devices/tuner.h40
-rw-r--r--p2pvr/devices/tunerSendSi.cpp18
-rw-r--r--p2pvr/devices/tunerSendSi.h4
-rw-r--r--p2pvr/devices/tunerSendTs.cpp11
-rw-r--r--p2pvr/devices/tunerSendTs.h4
13 files changed, 162 insertions, 109 deletions
diff --git a/p2pvr/devices/frontend.cpp b/p2pvr/devices/frontend.cpp
index c1d2c61..c368fda 100644
--- a/p2pvr/devices/frontend.cpp
+++ b/p2pvr/devices/frontend.cpp
@@ -4,6 +4,8 @@
#include <linux/dvb/frontend.h>
#include <factory.impl.h>
+namespace P2PVR {
+namespace DVB {
Frontend::Frontend(Tuner * t, int fd, const struct dvb_frontend_info & i, IceTray::Logging::LoggerPtr log) :
tuner(t),
frontendFD(fd),
@@ -40,5 +42,7 @@ Frontend::FactoryKey(fe_type t)
return stringbf("Frontend:%x", t);
}
-INSTANTIATEFACTORY(Frontend, Tuner *, int, const struct dvb_frontend_info &);
+}
+}
+INSTANTIATEFACTORY(P2PVR::DVB::Frontend, P2PVR::DVB::Tuner *, int, const struct dvb_frontend_info &);
diff --git a/p2pvr/devices/frontend.h b/p2pvr/devices/frontend.h
index 51399b1..29180f4 100644
--- a/p2pvr/devices/frontend.h
+++ b/p2pvr/devices/frontend.h
@@ -6,6 +6,8 @@
#include <dvb.h>
#include <logger.h>
+namespace P2PVR {
+namespace DVB {
class Tuner;
class Frontend {
@@ -31,6 +33,8 @@ class Frontend {
typedef AdHoc::Factory<Frontend, Tuner *, int, const struct dvb_frontend_info &> FrontendFactory;
typedef boost::shared_ptr<Frontend> FrontendPtr;
+}
+}
#endif
diff --git a/p2pvr/devices/frontends/ofdm.cpp b/p2pvr/devices/frontends/ofdm.cpp
index caa42a6..15602eb 100644
--- a/p2pvr/devices/frontends/ofdm.cpp
+++ b/p2pvr/devices/frontends/ofdm.cpp
@@ -6,10 +6,13 @@
#define FREQ_OFFSET_MIN 0
#define FREQ_OFFSET_MAX 4
-class Frontend_OFDM : public Frontend {
+namespace P2PVR {
+namespace DVB {
+namespace Frontends {
+class OFDM : public Frontend {
public:
- Frontend_OFDM(Tuner * t, int fd, const struct dvb_frontend_info & i) :
- Frontend(t, fd, i, LOGMANAGER()->getLogger<Frontend_OFDM>())
+ OFDM(Tuner * t, int fd, const struct dvb_frontend_info & i) :
+ Frontend(t, fd, i, LOGMANAGER()->getLogger<OFDM>())
{
}
@@ -156,5 +159,8 @@ class Frontend_OFDM : public Frontend {
}
};
-NAMEDFACTORY(Frontend::FactoryKey(FE_OFDM), Frontend_OFDM, FrontendFactory);
+NAMEDFACTORY(Frontend::FactoryKey(FE_OFDM), OFDM, FrontendFactory);
+}
+}
+}
diff --git a/p2pvr/devices/localDevices.cpp b/p2pvr/devices/localDevices.cpp
index cbe74a8..ac13a29 100644
--- a/p2pvr/devices/localDevices.cpp
+++ b/p2pvr/devices/localDevices.cpp
@@ -3,23 +3,24 @@
#include "tuner.h"
#include "bindTimerTask.h"
-LocalDevices::Devices LocalDevices::devices;
-std::mutex LocalDevices::lock;
+namespace P2PVR {
+LocalDevicesI::Devices LocalDevicesI::devices;
+std::mutex LocalDevicesI::lock;
-LocalDevices::Options::Options() :
+LocalDevicesI::Options::Options() :
IceTray::Options("P2PVR Devices")
{
}
-ICETRAY_OPTIONS(LocalDevices::Options,
+ICETRAY_OPTIONS(LocalDevicesI::Options,
("p2pvr.localdevices.frontend", boost::program_options::value(&devices), "Frontend of DVB device(s) to use (/dev/dvb/adapterX/frontendY)")
);
-IceTray::Logging::LoggerPtr LocalDevices::logger(LOGMANAGER()->getLogger<LocalDevices>());
+IceTray::Logging::LoggerPtr LocalDevicesI::logger(LOGMANAGER()->getLogger<LocalDevicesI>());
-LocalDevices::LocalDevices(Ice::ObjectAdapterPtr adapter, IceUtil::TimerPtr t) :
+LocalDevicesI::LocalDevicesI(Ice::ObjectAdapterPtr adapter, IceUtil::TimerPtr t) :
timer(t),
- clientCheck(new BindTimerTask(boost::bind(&LocalDevices::ClientCheck, this, adapter)))
+ clientCheck(new BindTimerTask(boost::bind(&LocalDevicesI::ClientCheck, this, adapter)))
{
for (auto & device : options->devices) {
devices.insert({ device, nullptr });
@@ -28,14 +29,14 @@ LocalDevices::LocalDevices(Ice::ObjectAdapterPtr adapter, IceUtil::TimerPtr t) :
timer->scheduleRepeated(clientCheck, IceUtil::Time::seconds(30));
}
-LocalDevices::~LocalDevices()
+LocalDevicesI::~LocalDevicesI()
{
logger->message(LOG::DEBUG, __PRETTY_FUNCTION__);
timer->cancel(clientCheck);
}
void
-LocalDevices::ClientCheck(Ice::ObjectAdapterPtr adapter)
+LocalDevicesI::ClientCheck(Ice::ObjectAdapterPtr adapter)
{
std::lock_guard<std::mutex> g(lock);
for (auto & device : devices) {
@@ -50,8 +51,8 @@ LocalDevices::ClientCheck(Ice::ObjectAdapterPtr adapter)
}
}
-P2PVR::TunerPrx
-LocalDevices::GetTunerSpecific(const DVBSI::DeliveryPtr & delivery, const Ice::Current & ice)
+TunerPrx
+LocalDevicesI::GetTunerSpecific(const DVBSI::DeliveryPtr & delivery, const Ice::Current & ice)
{
std::lock_guard<std::mutex> g(lock);
logger->messagebf(LOG::DEBUG, "%s: Searching for an open sharable tuner (frequency %d)", __PRETTY_FUNCTION__, delivery->Frequency);
@@ -67,14 +68,14 @@ LocalDevices::GetTunerSpecific(const DVBSI::DeliveryPtr & delivery, const Ice::C
if (openTuner == devices.end()) {
logger->messagebf(LOG::DEBUG, "%s: None suitable and none free (frequency %d)",
__PRETTY_FUNCTION__, delivery->Frequency);
- throw P2PVR::NoSuitableDeviceAvailable();
+ throw NoSuitableDeviceAvailable();
}
logger->messagebf(LOG::DEBUG, "%s: Opening a sharable tuner (frequency %d, frontend %s)",
__PRETTY_FUNCTION__, delivery->Frequency, openTuner->first);
- P2PVR::PrivateTunerPtr t = new Tuner(openTuner->first);
+ PrivateTunerPtr t = new DVB::Tuner(openTuner->first);
t->TuneTo(delivery, ice);
- auto tuner = P2PVR::PrivateTunerPrx::checkedCast(ice.adapter->addWithUUID(t));
+ auto tuner = PrivateTunerPrx::checkedCast(ice.adapter->addWithUUID(t));
openTuner->second = OpenTunerPtr(new OpenTuner(delivery, tuner, false));
logger->messagebf(LOG::DEBUG, "%s: Tuned, returning (frequency %d, frontend %s)",
@@ -82,8 +83,8 @@ LocalDevices::GetTunerSpecific(const DVBSI::DeliveryPtr & delivery, const Ice::C
return tuner;
}
-P2PVR::TunerPrx
-LocalDevices::GetTunerAny(const DVBSI::DeliveryPtr & delivery, const Ice::Current & ice)
+TunerPrx
+LocalDevicesI::GetTunerAny(const DVBSI::DeliveryPtr & delivery, const Ice::Current & ice)
{
std::lock_guard<std::mutex> g(lock);
logger->messagebf(LOG::DEBUG, "%s: Searching for an open sharable tuner any frequency", __PRETTY_FUNCTION__);
@@ -99,14 +100,14 @@ LocalDevices::GetTunerAny(const DVBSI::DeliveryPtr & delivery, const Ice::Curren
if (openTuner == devices.end()) {
logger->messagebf(LOG::DEBUG, "%s: None suitable and none free (frequency %d)",
__PRETTY_FUNCTION__, delivery->Frequency);
- throw P2PVR::NoSuitableDeviceAvailable();
+ throw NoSuitableDeviceAvailable();
}
logger->messagebf(LOG::DEBUG, "%s: Opening a sharable tuner (frequency %d, frontend %s)",
__PRETTY_FUNCTION__, delivery->Frequency, openTuner->first);
- P2PVR::PrivateTunerPtr t = new Tuner(openTuner->first);
+ PrivateTunerPtr t = new DVB::Tuner(openTuner->first);
t->TuneTo(delivery, ice);
- auto tuner = P2PVR::PrivateTunerPrx::checkedCast(ice.adapter->addWithUUID(t));
+ auto tuner = PrivateTunerPrx::checkedCast(ice.adapter->addWithUUID(t));
openTuner->second = OpenTunerPtr(new OpenTuner(delivery, tuner, false));
logger->messagebf(LOG::DEBUG, "%s: Tuned, returning (frequency %d, frontend %s)",
@@ -114,27 +115,27 @@ LocalDevices::GetTunerAny(const DVBSI::DeliveryPtr & delivery, const Ice::Curren
return tuner;
}
-P2PVR::PrivateTunerPrx
-LocalDevices::GetPrivateTuner(short , const Ice::Current & ice)
+PrivateTunerPrx
+LocalDevicesI::GetPrivateTuner(short , const Ice::Current & ice)
{
std::lock_guard<std::mutex> g(lock);
logger->messagebf(LOG::DEBUG, "%s: Opening a private tuner", __PRETTY_FUNCTION__);
auto openTuner = std::find_if(devices.begin(), devices.end(), [](const Devices::value_type & ot) { return !ot.second; });
if (openTuner == devices.end()) {
logger->messagebf(LOG::DEBUG, "%s: None free", __PRETTY_FUNCTION__);
- throw P2PVR::NoSuitableDeviceAvailable();
+ throw NoSuitableDeviceAvailable();
}
logger->messagebf(LOG::DEBUG, "%s: Opening a private tuner (frontend %s)",
__PRETTY_FUNCTION__, openTuner->first);
- auto tuner = P2PVR::PrivateTunerPrx::checkedCast(ice.adapter->addWithUUID(new Tuner(openTuner->first)));
+ auto tuner = PrivateTunerPrx::checkedCast(ice.adapter->addWithUUID(new DVB::Tuner(openTuner->first)));
openTuner->second = OpenTunerPtr(new OpenTuner(NULL, tuner, true));
return tuner;
}
void
-LocalDevices::ReleaseTuner(const P2PVR::TunerPrx & tuner, const Ice::Current & ice)
+LocalDevicesI::ReleaseTuner(const TunerPrx & tuner, const Ice::Current & ice)
{
std::lock_guard<std::mutex> g(lock);
logger->messagebf(LOG::DEBUG, "%s", __PRETTY_FUNCTION__);
@@ -157,37 +158,38 @@ LocalDevices::ReleaseTuner(const P2PVR::TunerPrx & tuner, const Ice::Current & i
}
int
-LocalDevices::TunerCount(const Ice::Current &)
+LocalDevicesI::TunerCount(const Ice::Current &)
{
std::lock_guard<std::mutex> g(lock);
return devices.size();
}
void
-LocalDevices::Scan(const Ice::Current &)
+LocalDevicesI::Scan(const Ice::Current &)
{
std::lock_guard<std::mutex> g(lock);
}
void
-LocalDevices::Add(const std::string & frontend, const Ice::Current &)
+LocalDevicesI::Add(const std::string & frontend, const Ice::Current &)
{
std::lock_guard<std::mutex> g(lock);
devices.insert(Devices::value_type(frontend, OpenTunerPtr()));
}
void
-LocalDevices::Remove(const std::string & frontend, const Ice::Current &)
+LocalDevicesI::Remove(const std::string & frontend, const Ice::Current &)
{
std::lock_guard<std::mutex> g(lock);
devices.erase(frontend);
}
-LocalDevices::OpenTuner::OpenTuner(DVBSI::DeliveryPtr d, P2PVR::PrivateTunerPrx t, bool op) :
+LocalDevicesI::OpenTuner::OpenTuner(DVBSI::DeliveryPtr d, PrivateTunerPrx t, bool op) :
openedPrivate(op),
delivery(d),
tuner(t),
clients(1)
{
}
+}
diff --git a/p2pvr/devices/localDevices.h b/p2pvr/devices/localDevices.h
index 7bd97ee..0fd4ad2 100644
--- a/p2pvr/devices/localDevices.h
+++ b/p2pvr/devices/localDevices.h
@@ -1,7 +1,7 @@
#ifndef LOCALDEVICES_H
#define LOCALDEVICES_H
-// Local devices implements a device collection (P2PVR::Devices) for any devices physically
+// Local devices implements a device collection (Devices) for any devices physically
// attached to the local machine; that is, can be accessed directly through /dev/dvb/adapterX
#include <dvb.h>
@@ -11,7 +11,8 @@
#include <IceUtil/Timer.h>
#include <logger.h>
-class DLL_PUBLIC LocalDevices : public P2PVR::LocalDevices {
+namespace P2PVR {
+class DLL_PUBLIC LocalDevicesI : public LocalDevices {
public:
class Options : public IceTray::Options {
public:
@@ -22,13 +23,13 @@ class DLL_PUBLIC LocalDevices : public P2PVR::LocalDevices {
std::vector<std::string> devices;
};
- LocalDevices(Ice::ObjectAdapterPtr adapter, IceUtil::TimerPtr);
- ~LocalDevices();
+ LocalDevicesI(Ice::ObjectAdapterPtr adapter, IceUtil::TimerPtr);
+ ~LocalDevicesI();
- P2PVR::TunerPrx GetTunerSpecific(const DVBSI::DeliveryPtr &, const Ice::Current &);
- P2PVR::TunerPrx GetTunerAny(const DVBSI::DeliveryPtr &, const Ice::Current &);
- P2PVR::PrivateTunerPrx GetPrivateTuner(short type, const Ice::Current &);
- void ReleaseTuner(const P2PVR::TunerPrx &, const Ice::Current &);
+ TunerPrx GetTunerSpecific(const DVBSI::DeliveryPtr &, const Ice::Current &);
+ TunerPrx GetTunerAny(const DVBSI::DeliveryPtr &, const Ice::Current &);
+ PrivateTunerPrx GetPrivateTuner(short type, const Ice::Current &);
+ void ReleaseTuner(const TunerPrx &, const Ice::Current &);
int TunerCount(const Ice::Current &);
void Scan(const Ice::Current &);
@@ -45,11 +46,11 @@ class DLL_PUBLIC LocalDevices : public P2PVR::LocalDevices {
class DLL_PRIVATE OpenTuner {
public:
- OpenTuner(DVBSI::DeliveryPtr, P2PVR::PrivateTunerPrx, bool);
+ OpenTuner(DVBSI::DeliveryPtr, PrivateTunerPrx, bool);
const bool openedPrivate;
const DVBSI::DeliveryPtr delivery;
- const P2PVR::PrivateTunerPrx tuner;
+ const PrivateTunerPrx tuner;
unsigned int clients;
};
@@ -60,6 +61,7 @@ class DLL_PUBLIC LocalDevices : public P2PVR::LocalDevices {
static IceTray::Logging::LoggerPtr logger;
IceTray::OptionsResolver<Options> options;
};
+}
#endif
diff --git a/p2pvr/devices/mockTuner.cpp b/p2pvr/devices/mockTuner.cpp
index b040128..4430bc4 100644
--- a/p2pvr/devices/mockTuner.cpp
+++ b/p2pvr/devices/mockTuner.cpp
@@ -11,6 +11,8 @@ extern "C" { \
} \
static const Ice::ByteSeq resource(&resource##_start, &resource##_end);
+namespace P2PVR {
+namespace Testing {
void
MockTuner::LZMA_ASSERT(int ret_xz)
{
@@ -178,4 +180,6 @@ Ice::Long MockTuner::GetLastUsedTime(const Ice::Current&)
{
return time(NULL);
}
+}
+}
diff --git a/p2pvr/devices/mockTuner.h b/p2pvr/devices/mockTuner.h
index 60372c9..73ab27c 100644
--- a/p2pvr/devices/mockTuner.h
+++ b/p2pvr/devices/mockTuner.h
@@ -7,23 +7,25 @@
#include <boost/thread.hpp>
#include <logger.h>
-class DLL_PUBLIC MockTuner : public P2PVR::PrivateTuner {
+namespace P2PVR {
+namespace Testing {
+class DLL_PUBLIC MockTuner : public PrivateTuner {
public:
MockTuner();
void TuneTo(const DVBSI::DeliveryPtr &, const Ice::Current&);
int GetStatus(const Ice::Current&);
- void ScanAndSendNetworkInformation(const P2PVR::RawDataClientPrx & client, const Ice::Current&);
- void SendNetworkInformation(const P2PVR::RawDataClientPrx & client, const Ice::Current&);
- void SendBouquetAssociations(const P2PVR::RawDataClientPrx & client, const Ice::Current&);
- void SendServiceDescriptions(const P2PVR::RawDataClientPrx & client, const Ice::Current&);
- void SendProgramMap(Ice::Int pid, const P2PVR::RawDataClientPrx & client, const Ice::Current&);
- void SendProgramAssociationTable(const P2PVR::RawDataClientPrx & client, const Ice::Current&);
- void SendEventInformation(const P2PVR::RawDataClientPrx & client, const Ice::Current&);
+ void ScanAndSendNetworkInformation(const RawDataClientPrx & client, const Ice::Current&);
+ void SendNetworkInformation(const RawDataClientPrx & client, const Ice::Current&);
+ void SendBouquetAssociations(const RawDataClientPrx & client, const Ice::Current&);
+ void SendServiceDescriptions(const RawDataClientPrx & client, const Ice::Current&);
+ void SendProgramMap(Ice::Int pid, const RawDataClientPrx & client, const Ice::Current&);
+ void SendProgramAssociationTable(const RawDataClientPrx & client, const Ice::Current&);
+ void SendEventInformation(const RawDataClientPrx & client, const Ice::Current&);
- int StartSendingTS(const P2PVR::PacketIds & pids, const P2PVR::RawDataClientPrx & client, const Ice::Current &);
- int StartSendingSection(Ice::Int pid, const P2PVR::RawDataClientPrx & client, const Ice::Current &);
+ int StartSendingTS(const PacketIds & pids, const RawDataClientPrx & client, const Ice::Current &);
+ int StartSendingSection(Ice::Int pid, const RawDataClientPrx & client, const Ice::Current &);
void StopSending(int handle, const Ice::Current &);
Ice::Long GetLastUsedTime(const Ice::Current&);
@@ -33,8 +35,8 @@ class DLL_PUBLIC MockTuner : public P2PVR::PrivateTuner {
protected:
static Ice::ByteSeq Decompress(const Ice::ByteSeq &);
static void LZMA_ASSERT(int ret_xz);
- void DecompressAndSendPackets(const Ice::ByteSeq &, const P2PVR::RawDataClientPrx &, const Ice::Current&) const;
- void SendLoop(const P2PVR::RawDataClientPrx & t, const Ice::ByteSeq & dataxz, const Ice::Current & ice) const;
+ void DecompressAndSendPackets(const Ice::ByteSeq &, const RawDataClientPrx &, const Ice::Current&) const;
+ void SendLoop(const RawDataClientPrx & t, const Ice::ByteSeq & dataxz, const Ice::Current & ice) const;
static int eventSet;
std::map<int, boost::thread *> senders;
@@ -42,6 +44,8 @@ class DLL_PUBLIC MockTuner : public P2PVR::PrivateTuner {
static IceTray::Logging::LoggerPtr logger;
};
+}
+}
#endif
diff --git a/p2pvr/devices/tuner.cpp b/p2pvr/devices/tuner.cpp
index 148790b..f65fc32 100644
--- a/p2pvr/devices/tuner.cpp
+++ b/p2pvr/devices/tuner.cpp
@@ -12,6 +12,8 @@
#include "tunerSendSi.h"
#include "tunerSendTs.h"
+namespace P2PVR {
+namespace DVB {
IceTray::Logging::LoggerPtr Tuner::logger = LOGMANAGER()->getLogger<Tuner>();
Tuner::Tuner(const boost::filesystem::path & df) :
@@ -22,12 +24,12 @@ Tuner::Tuner(const boost::filesystem::path & df) :
{
int fd = open(deviceFrontend.string().c_str(), O_RDWR);
if (fd < 0) {
- throw P2PVR::DeviceError(deviceFrontend.string(), strerror(errno), errno);
+ throw DeviceError(deviceFrontend.string(), strerror(errno), errno);
}
try {
struct dvb_frontend_info fe_info;
if (ioctl(fd, FE_GET_INFO, &fe_info) < 0) {
- throw P2PVR::DeviceError(deviceFrontend.string(), strerror(errno), errno);
+ throw DeviceError(deviceFrontend.string(), strerror(errno), errno);
}
frontend = FrontendPtr(FrontendFactory::createNew(Frontend::FactoryKey(fe_info.type), this, fd, fe_info));
}
@@ -79,13 +81,13 @@ Tuner::OpenDemux() const
{
int demux = open((deviceRoot / "demux0").string().c_str(), O_RDWR | O_NONBLOCK);
if (demux < 0) {
- throw P2PVR::DeviceError(deviceRoot.string(), strerror(errno), errno);
+ throw DeviceError(deviceRoot.string(), strerror(errno), errno);
}
return demux;
}
void
-Tuner::ScanAndSendNetworkInformation(const P2PVR::RawDataClientPrx & client, const Ice::Current & ice)
+Tuner::ScanAndSendNetworkInformation(const RawDataClientPrx & client, const Ice::Current & ice)
{
time(&lastUsedTime);
frontend->FrequencyScan([this, &client, &ice](long) {
@@ -106,43 +108,43 @@ Tuner::ScanAndSendNetworkInformation(const P2PVR::RawDataClientPrx & client, con
}
void
-Tuner::SendNetworkInformation(const P2PVR::RawDataClientPrx & client, const Ice::Current & ice)
+Tuner::SendNetworkInformation(const RawDataClientPrx & client, const Ice::Current & ice)
{
SendPID(0x10, client, ice);
}
void
-Tuner::SendBouquetAssociations(const P2PVR::RawDataClientPrx & client, const Ice::Current & ice)
+Tuner::SendBouquetAssociations(const RawDataClientPrx & client, const Ice::Current & ice)
{
SendPID(0x11, client, ice);
}
void
-Tuner::SendServiceDescriptions(const P2PVR::RawDataClientPrx & client, const Ice::Current & ice)
+Tuner::SendServiceDescriptions(const RawDataClientPrx & client, const Ice::Current & ice)
{
SendPID(0x11, client, ice);
}
void
-Tuner::SendProgramMap(Ice::Int pid, const P2PVR::RawDataClientPrx & client, const Ice::Current & ice)
+Tuner::SendProgramMap(Ice::Int pid, const RawDataClientPrx & client, const Ice::Current & ice)
{
SendPID(pid, client, ice);
}
void
-Tuner::SendProgramAssociationTable(const P2PVR::RawDataClientPrx & client, const Ice::Current & ice)
+Tuner::SendProgramAssociationTable(const RawDataClientPrx & client, const Ice::Current & ice)
{
SendPID(0x00, client, ice);
}
void
-Tuner::SendEventInformation(const P2PVR::RawDataClientPrx & client, const Ice::Current & ice)
+Tuner::SendEventInformation(const RawDataClientPrx & client, const Ice::Current & ice)
{
SendPID(0x12, client, ice);
}
uint64_t
-Tuner::SendPID(int pid, const P2PVR::RawDataClientPrx & client, const Ice::Current & ice) const
+Tuner::SendPID(int pid, const RawDataClientPrx & client, const Ice::Current & ice) const
{
time(&lastUsedTime);
logger->messagebf(LOG::DEBUG, "%s: pid = 0x%x", __PRETTY_FUNCTION__, pid);
@@ -165,12 +167,12 @@ Tuner::RequestPID(int pid, int demux) const
sctFilterParams.flags = DMX_IMMEDIATE_START;
if (ioctl(demux, DMX_SET_FILTER, &sctFilterParams) < 0) {
- throw P2PVR::DeviceError("demux", strerror(errno), errno);
+ throw DeviceError("demux", strerror(errno), errno);
}
}
uint64_t
-Tuner::ReadDemuxAndSend(int demux, const P2PVR::RawDataClientPrx & _client) const
+Tuner::ReadDemuxAndSend(int demux, const RawDataClientPrx & _client) const
{
logger->messagebf(LOG::DEBUG, "%s: begin", __PRETTY_FUNCTION__);
struct pollfd ufd;
@@ -183,20 +185,20 @@ Tuner::ReadDemuxAndSend(int demux, const P2PVR::RawDataClientPrx & _client) cons
switch (poll(&ufd, 1, options->DemuxReadTimeout)) {
case -1:
logger->messagebf(LOG::DEBUG, "%s: poll error reading demux (%d:%s)", __PRETTY_FUNCTION__, errno, strerror(errno));
- throw P2PVR::DeviceError("demux", strerror(errno), errno);
+ throw DeviceError("demux", strerror(errno), errno);
case 0:
auto status = frontend->GetStatus();
logger->messagebf(LOG::DEBUG, "%s: Timed out waiting for data (device status 0x%02x)", __PRETTY_FUNCTION__, status);
- throw P2PVR::DeviceError("demux", "timeout", 0);
+ throw DeviceError("demux", "timeout", 0);
}
// Read it
- P2PVR::Data buf(1 << 12);
+ Data buf(1 << 12);
int nr = read(demux, &buf.front(), buf.size());
if (nr < 0) {
logger->messagebf(LOG::DEBUG, "%s: error reading demux (%d:%s) status 0x%02x",
__PRETTY_FUNCTION__, errno, strerror(errno), frontend->GetStatus());
- throw P2PVR::DeviceError("demux", strerror(errno), errno);
+ throw DeviceError("demux", strerror(errno), errno);
}
size_t n = nr;
buf.resize(n);
@@ -212,7 +214,7 @@ Tuner::ReadDemuxAndSend(int demux, const P2PVR::RawDataClientPrx & _client) cons
}
int
-Tuner::StartSendingSection(int pid, const P2PVR::RawDataClientPrx & client, const Ice::Current &)
+Tuner::StartSendingSection(int pid, const RawDataClientPrx & client, const Ice::Current &)
{
time(&lastUsedTime);
logger->message(LOG::DEBUG, __PRETTY_FUNCTION__);
@@ -226,12 +228,12 @@ Tuner::StartSendingSection(int pid, const P2PVR::RawDataClientPrx & client, cons
}
int
-Tuner::StartSendingTS(const P2PVR::PacketIds & pids, const P2PVR::RawDataClientPrx & client, const Ice::Current & ice)
+Tuner::StartSendingTS(const PacketIds & pids, const RawDataClientPrx & client, const Ice::Current & ice)
{
time(&lastUsedTime);
logger->message(LOG::DEBUG, __PRETTY_FUNCTION__);
if (pids.empty()) {
- throw P2PVR::DeviceError("demux", "Packet Id list cannot be empty", 0);
+ throw DeviceError("demux", "Packet Id list cannot be empty", 0);
}
if (ice.con) {
@@ -253,7 +255,7 @@ Tuner::StartSendingTS(const P2PVR::PacketIds & pids, const P2PVR::RawDataClientP
if (ioctl(demux, DMX_SET_PES_FILTER, &pesFilterParams) < 0) {
backgroundClients.erase(demux);
logger->messagebf(LOG::ERR, "%s: DMX_SET_PES_FILTER failed (%d: %s)", __PRETTY_FUNCTION__, errno, strerror(errno));
- throw P2PVR::DeviceError("demux", strerror(errno), errno);
+ throw DeviceError("demux", strerror(errno), errno);
}
for (unsigned int x = 1; x < pids.size(); x += 1) {
@@ -262,7 +264,7 @@ Tuner::StartSendingTS(const P2PVR::PacketIds & pids, const P2PVR::RawDataClientP
if (ioctl(demux, DMX_ADD_PID, &p) < 0) {
backgroundClients.erase(demux);
logger->messagebf(LOG::ERR, "%s: DMX_ADD_PID failed (%d: %s)", __PRETTY_FUNCTION__, errno, strerror(errno));
- throw P2PVR::DeviceError("demux", strerror(errno), errno);
+ throw DeviceError("demux", strerror(errno), errno);
}
}
@@ -270,7 +272,7 @@ Tuner::StartSendingTS(const P2PVR::PacketIds & pids, const P2PVR::RawDataClientP
if (ioctl(demux, DMX_START) < 0) {
backgroundClients.erase(demux);
logger->messagebf(LOG::ERR, "%s: DMX_START failed (%d: %s)", __PRETTY_FUNCTION__, errno, strerror(errno));
- throw P2PVR::DeviceError("demux", strerror(errno), errno);
+ throw DeviceError("demux", strerror(errno), errno);
}
startSenderThread();
@@ -282,7 +284,7 @@ Tuner::setBufferSize(int demux, unsigned long size)
{
if (ioctl(demux, DMX_SET_BUFFER_SIZE, size)) {
logger->messagebf(LOG::ERR, "%s: DMX_SET_BUFFER_SIZE to %d failed (%d: %s)", __PRETTY_FUNCTION__, size, errno, strerror(errno));
- throw P2PVR::DeviceError("demux", strerror(errno), errno);
+ throw DeviceError("demux", strerror(errno), errno);
}
logger->messagebf(LOG::DEBUG, "%s: DMX_SET_BUFFER_SIZE to %d", __PRETTY_FUNCTION__, size);
}
@@ -333,7 +335,7 @@ Tuner::senderThread()
for (auto c = backgroundClients.begin(); c != backgroundClients.end(); ) {
if (FD_ISSET(c->first, &rfds)) {
// Read it
- P2PVR::Data buf(1 << 16);
+ Data buf(1 << 16);
int nr = read(c->first, &buf.front(), buf.size());
if (nr < 0) {
logger->messagebf(LOG::DEBUG, "%s: read failed (%d:%s)", __PRETTY_FUNCTION__, errno, strerror(errno));
@@ -377,7 +379,7 @@ Tuner::GetLastUsedTime(const Ice::Current &)
return lastUsedTime;
}
-Tuner::IDataSender::IDataSender(const P2PVR::RawDataClientPrx & c) :
+Tuner::IDataSender::IDataSender(const RawDataClientPrx & c) :
_packetsSent(0),
client(c)
{
@@ -412,4 +414,6 @@ ICETRAY_OPTIONS(Tuner::Options,
("p2pvr.tuner.demuxstreambuffersize", po::value(&DemuxStreamBufferSize)->default_value(1024*1024),
"Kernel buffer size for demux stream data (bytes, default 1MB)")
)
+}
+}
diff --git a/p2pvr/devices/tuner.h b/p2pvr/devices/tuner.h
index 42f2948..e170002 100644
--- a/p2pvr/devices/tuner.h
+++ b/p2pvr/devices/tuner.h
@@ -13,20 +13,26 @@
#include <options.h>
#include <logger.h>
-class Tuner : public P2PVR::PrivateTuner {
+namespace P2PVR {
+namespace DVB {
+namespace Frontends {
+ class OFDM;
+}
+
+class Tuner : public PrivateTuner {
public:
class IDataSender {
public:
- IDataSender(const P2PVR::RawDataClientPrx &);
+ IDataSender(const RawDataClientPrx &);
virtual ~IDataSender() = 0;
- virtual void NewData(const P2PVR::Data &) = 0;
+ virtual void NewData(const Data &) = 0;
virtual bool IsFinished() = 0;
uint64_t PacketsSent() const;
protected:
uint64_t _packetsSent;
- const P2PVR::RawDataClientPrx client;
+ const RawDataClientPrx client;
};
typedef boost::shared_ptr<IDataSender> BackgroundClient;
typedef std::map<int, BackgroundClient> BackgroundClients;
@@ -38,25 +44,25 @@ class Tuner : public P2PVR::PrivateTuner {
int GetStatus(const Ice::Current&);
std::string Device() const;
- void ScanAndSendNetworkInformation(const P2PVR::RawDataClientPrx & client, const Ice::Current&);
- void SendNetworkInformation(const P2PVR::RawDataClientPrx & client, const Ice::Current&);
- void SendBouquetAssociations(const P2PVR::RawDataClientPrx & client, const Ice::Current&);
- void SendServiceDescriptions(const P2PVR::RawDataClientPrx & client, const Ice::Current&);
- void SendProgramMap(Ice::Int pid, const P2PVR::RawDataClientPrx & client, const Ice::Current&);
- void SendProgramAssociationTable(const P2PVR::RawDataClientPrx & client, const Ice::Current&);
- void SendEventInformation(const P2PVR::RawDataClientPrx & client, const Ice::Current&);
+ void ScanAndSendNetworkInformation(const RawDataClientPrx & client, const Ice::Current&);
+ void SendNetworkInformation(const RawDataClientPrx & client, const Ice::Current&);
+ void SendBouquetAssociations(const RawDataClientPrx & client, const Ice::Current&);
+ void SendServiceDescriptions(const RawDataClientPrx & client, const Ice::Current&);
+ void SendProgramMap(Ice::Int pid, const RawDataClientPrx & client, const Ice::Current&);
+ void SendProgramAssociationTable(const RawDataClientPrx & client, const Ice::Current&);
+ void SendEventInformation(const RawDataClientPrx & client, const Ice::Current&);
- int StartSendingTS(const P2PVR::PacketIds & pids, const P2PVR::RawDataClientPrx & client, const Ice::Current &);
- int StartSendingSection(Ice::Int pid, const P2PVR::RawDataClientPrx & client, const Ice::Current &);
+ int StartSendingTS(const PacketIds & pids, const RawDataClientPrx & client, const Ice::Current &);
+ int StartSendingSection(Ice::Int pid, const RawDataClientPrx & client, const Ice::Current &);
void StopSending(int handle, const Ice::Current &);
Ice::Long GetLastUsedTime(const Ice::Current&);
private:
int OpenDemux() const;
- uint64_t SendPID(int pid, const P2PVR::RawDataClientPrx & client, const Ice::Current &) const;
+ uint64_t SendPID(int pid, const RawDataClientPrx & client, const Ice::Current &) const;
void RequestPID(int pid, int fd) const;
- uint64_t ReadDemuxAndSend(int fd, const P2PVR::RawDataClientPrx & client) const;
+ uint64_t ReadDemuxAndSend(int fd, const RawDataClientPrx & client) const;
void startSenderThread();
void senderThread();
static void setBufferSize(int fd, unsigned long bytes);
@@ -86,9 +92,11 @@ class Tuner : public P2PVR::PrivateTuner {
};
private:
- friend class Frontend_OFDM;
+ friend class Frontends::OFDM;
IceTray::OptionsResolver<Options> options;
};
+}
+}
#endif
diff --git a/p2pvr/devices/tunerSendSi.cpp b/p2pvr/devices/tunerSendSi.cpp
index c8a8310..0215e47 100644
--- a/p2pvr/devices/tunerSendSi.cpp
+++ b/p2pvr/devices/tunerSendSi.cpp
@@ -3,9 +3,11 @@
#include <boost/crc.hpp>
#include "siParsers/table.h"
+namespace P2PVR {
+namespace DVB {
IceTray::Logging::LoggerPtr SendSi::logger(LOGMANAGER()->getLogger<SendSi>());
-SendSi::SendSi(const P2PVR::RawDataClientPrx & c) :
+SendSi::SendSi(const RawDataClientPrx & c) :
Tuner::IDataSender(c->ice_collocationOptimized(false))
{
}
@@ -15,7 +17,7 @@ SendSi::~SendSi()
}
void
-SendSi::NewData(const P2PVR::Data & buf)
+SendSi::NewData(const Data & buf)
{
if (!IsValidSection(buf)) {
return;
@@ -48,15 +50,15 @@ SendSi::IsFinished()
}
bool
-SendSi::IsValidSection(const P2PVR::Data & buf)
+SendSi::IsValidSection(const Data & buf)
{
auto n = buf.size();
- if (n < sizeof(SiTableHeader)) {
+ if (n < sizeof(DVBSI::SiTableHeader)) {
logger->messagebf(LOG::WARNING, "Received data too small to be an SI table.");
return false;
}
- auto * tab = (const SiTableHeader *)(&buf.front());
- size_t l = sizeof(SiTableHeaderBase) + HILO(tab->section_length);
+ auto * tab = (const DVBSI::SiTableHeader *)(&buf.front());
+ size_t l = sizeof(DVBSI::SiTableHeaderBase) + HILO(tab->section_length);
if (n < l) {
logger->messagebf(LOG::WARNING, "Received data shorter than its defined length.");
return false;
@@ -73,10 +75,12 @@ SendSi::IsValidSection(const P2PVR::Data & buf)
}
bool
-SendSi::crc32(const P2PVR::Data & buf)
+SendSi::crc32(const Data & buf)
{
boost::crc_optimal<32, 0x0, 0xFFFFFFFF, 0x0, true, false> crc;
crc.process_bytes(&buf.front(), buf.size());
return crc.checksum() == 0;
}
+}
+}
diff --git a/p2pvr/devices/tunerSendSi.h b/p2pvr/devices/tunerSendSi.h
index 27d15af..8b146ff 100644
--- a/p2pvr/devices/tunerSendSi.h
+++ b/p2pvr/devices/tunerSendSi.h
@@ -4,6 +4,8 @@
#include "tuner.h"
#include <logger.h>
+namespace P2PVR {
+namespace DVB {
class SendSi : public Tuner::IDataSender {
public:
SendSi(const P2PVR::RawDataClientPrx &);
@@ -20,6 +22,8 @@ class SendSi : public Tuner::IDataSender {
bool finish;
static IceTray::Logging::LoggerPtr logger;
};
+}
+}
#endif
diff --git a/p2pvr/devices/tunerSendTs.cpp b/p2pvr/devices/tunerSendTs.cpp
index 6d4e3e1..8005311 100644
--- a/p2pvr/devices/tunerSendTs.cpp
+++ b/p2pvr/devices/tunerSendTs.cpp
@@ -1,6 +1,8 @@
#include "tunerSendTs.h"
#include <logger.h>
+namespace P2PVR {
+namespace DVB {
// ~64kb of TS packets
#define TARGET_BUFFER_SIZE (350 * 188)
// About the ICE message size limit
@@ -8,7 +10,7 @@
IceTray::Logging::LoggerPtr SendTs::logger(LOGMANAGER()->getLogger<SendTs>());
-SendTs::SendTs(const P2PVR::RawDataClientPrx & c) :
+SendTs::SendTs(const RawDataClientPrx & c) :
Tuner::IDataSender(c->ice_collocationOptimized(false))
{
buffer.reserve(TARGET_BUFFER_SIZE);
@@ -30,7 +32,7 @@ SendTs::~SendTs()
}
void
-SendTs::NewData(const P2PVR::Data & buf)
+SendTs::NewData(const Data & buf)
{
buffer.insert(buffer.end(), buf.begin(), buf.end());
if (!async && buffer.size() >= TARGET_BUFFER_SIZE) {
@@ -43,7 +45,7 @@ SendTs::sendBufferChunk()
{
if (buffer.size() > TARGET_BUFFER_LIMIT) {
auto breakPoint = buffer.begin() + TARGET_BUFFER_LIMIT;
- async = client->begin_NewData(P2PVR::Data(buffer.begin(), breakPoint));
+ async = client->begin_NewData(Data(buffer.begin(), breakPoint));
buffer.erase(buffer.begin(), breakPoint);
}
else {
@@ -74,5 +76,6 @@ SendTs::IsFinished()
return true;
}
}
-
+}
+}
diff --git a/p2pvr/devices/tunerSendTs.h b/p2pvr/devices/tunerSendTs.h
index 162248d..cd74198 100644
--- a/p2pvr/devices/tunerSendTs.h
+++ b/p2pvr/devices/tunerSendTs.h
@@ -4,6 +4,8 @@
#include "tuner.h"
#include <logger.h>
+namespace P2PVR {
+namespace DVB {
class SendTs : public Tuner::IDataSender {
public:
SendTs(const P2PVR::RawDataClientPrx &);
@@ -19,6 +21,8 @@ class SendTs : public Tuner::IDataSender {
P2PVR::Data buffer;
static IceTray::Logging::LoggerPtr logger;
};
+}
+}
#endif