summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDan Goodliffe <dan@randomdan.homeip.net>2018-04-29 19:41:12 +0100
committerDan Goodliffe <dan@randomdan.homeip.net>2018-04-29 19:41:12 +0100
commit7cce01c40746c3e9925c1ecb4474b025bf2f9c1c (patch)
tree01de3cb198f5df22a2aef1971a3dc306e29fa3a5
parentRelease events update transaction before beginning reschedule (diff)
downloadp2pvr-7cce01c40746c3e9925c1ecb4474b025bf2f9c1c.tar.bz2
p2pvr-7cce01c40746c3e9925c1ecb4474b025bf2f9c1c.tar.xz
p2pvr-7cce01c40746c3e9925c1ecb4474b025bf2f9c1c.zip
C++17 and Ice 3.7p2pvr-0.3.0
Updates all components to be C++17 and Ice 3.7
-rw-r--r--Jamroot.jam14
-rw-r--r--libtmdb/Jamfile.jam5
-rw-r--r--libtmdb/conversions.cpp2
-rw-r--r--libtmdb/conversions.h2
-rw-r--r--libtmdb/testModels.cpp14
-rw-r--r--libtmdb/tmdb-proxy.cpp8
-rw-r--r--libtmdb/tmdb-proxy.h8
-rw-r--r--p2pvr/Jamfile.jam2
-rw-r--r--p2pvr/carddaemon/carddaemon.cpp6
-rw-r--r--p2pvr/daemon/Jamfile.jam2
-rw-r--r--p2pvr/daemon/daemon.cpp24
-rw-r--r--p2pvr/daemon/icetraySupport.cpp4
-rw-r--r--p2pvr/daemon/icetraySupport.h15
-rw-r--r--p2pvr/daemon/maintenance.cpp20
-rw-r--r--p2pvr/daemon/maintenance.h2
-rw-r--r--p2pvr/daemon/maintenance/events.cpp41
-rw-r--r--p2pvr/daemon/maintenance/network.cpp19
-rw-r--r--p2pvr/daemon/maintenance/services.cpp21
-rw-r--r--p2pvr/daemon/p2pvr-int.ice6
-rw-r--r--p2pvr/daemon/recorder.cpp51
-rw-r--r--p2pvr/daemon/recorder.h10
-rw-r--r--p2pvr/daemon/recordings.cpp17
-rw-r--r--p2pvr/daemon/recordings.h8
-rw-r--r--p2pvr/daemon/schedules.cpp53
-rw-r--r--p2pvr/daemon/schedules.h27
-rw-r--r--p2pvr/daemon/si.cpp52
-rw-r--r--p2pvr/daemon/si.h36
-rw-r--r--p2pvr/daemon/storage.cpp13
-rw-r--r--p2pvr/daemon/storage.h6
-rw-r--r--p2pvr/daemon/unittests/Jamfile.jam7
-rw-r--r--p2pvr/daemon/unittests/mockDefs.cpp15
-rw-r--r--p2pvr/daemon/unittests/mockDefs.h16
-rw-r--r--p2pvr/daemon/unittests/mockDevices.cpp2
-rw-r--r--p2pvr/daemon/unittests/mockScheduler.cpp4
-rw-r--r--p2pvr/daemon/unittests/mockScheduler.h4
-rw-r--r--p2pvr/daemon/unittests/testErrorHandling.cpp16
-rw-r--r--p2pvr/daemon/unittests/testMaint.cpp50
-rw-r--r--p2pvr/daemon/unittests/testRecording.cpp12
-rw-r--r--p2pvr/daemon/unittests/testSched.cpp13
-rw-r--r--p2pvr/daemon/unittests/testSi.cpp38
-rw-r--r--p2pvr/daemon/unittests/testStorage.cpp6
-rw-r--r--p2pvr/devices/devices.cpp42
-rw-r--r--p2pvr/devices/devices.h26
-rw-r--r--p2pvr/devices/frontend.cpp4
-rw-r--r--p2pvr/devices/frontend.h4
-rw-r--r--p2pvr/devices/frontends/ofdm.cpp20
-rw-r--r--p2pvr/devices/mockData.cpp6
-rw-r--r--p2pvr/devices/mockDataValidate.cpp4
-rw-r--r--p2pvr/devices/mockTuner.cpp6
-rw-r--r--p2pvr/devices/tuner.cpp66
-rw-r--r--p2pvr/devices/tuner.h28
-rw-r--r--p2pvr/devices/tunerSendSi.cpp27
-rw-r--r--p2pvr/devices/tunerSendSi.h6
-rw-r--r--p2pvr/devices/tunerSendTs.cpp23
-rw-r--r--p2pvr/devices/tunerSendTs.h8
-rw-r--r--p2pvr/dvb/siParsers/event.cpp18
-rw-r--r--p2pvr/dvb/siParsers/network.cpp12
-rw-r--r--p2pvr/dvb/siParsers/programAssociation.cpp2
-rw-r--r--p2pvr/dvb/siParsers/programMap.cpp2
-rw-r--r--p2pvr/dvb/siParsers/service.cpp10
-rw-r--r--p2pvr/dvb/siParsers/table.cpp2
-rw-r--r--p2pvr/dvb/siParsers/table.h2
-rw-r--r--p2pvr/dvb/unittests/Jamfile.jam5
-rw-r--r--p2pvr/dvb/unittests/bindDataHandler.cpp2
-rw-r--r--p2pvr/dvb/unittests/bindDataHandler.h2
-rw-r--r--p2pvr/dvb/unittests/createBroadcast.cpp23
-rw-r--r--p2pvr/dvb/unittests/createSamples.cpp40
-rw-r--r--p2pvr/ice/Jamfile.jam5
-rw-r--r--p2pvr/ice/chrono.ice (renamed from p2pvr/ice/common.ice)6
-rw-r--r--p2pvr/ice/chronoHelpers.cpp (renamed from p2pvr/ice/commonHelpers.cpp)16
-rw-r--r--p2pvr/ice/chronoHelpers.h29
-rw-r--r--p2pvr/ice/commonHelpers.h29
-rw-r--r--p2pvr/ice/converters.cpp12
-rw-r--r--p2pvr/ice/dvbsi.ice6
-rw-r--r--p2pvr/ice/p2pvr.ice10
-rw-r--r--p2pvr/lib/muxer.cpp14
-rw-r--r--p2pvr/lib/muxer.h8
-rw-r--r--p2pvr/lib/serviceStreamer.cpp2
-rw-r--r--p2pvr/lib/serviceStreamer.h6
-rw-r--r--p2pvr/lib/serviceStreamerCore.cpp14
-rw-r--r--p2pvr/lib/serviceStreamerCore.h12
-rw-r--r--p2pvr/lib/temporaryIceAdapterObject.h14
82 files changed, 665 insertions, 579 deletions
diff --git a/Jamroot.jam b/Jamroot.jam
index ff136c1..134212b 100644
--- a/Jamroot.jam
+++ b/Jamroot.jam
@@ -7,12 +7,14 @@ variant coverage : debug ;
project
: requirements
- <variant>release:<cxxflags>"-std=c++1y -fvisibility=hidden"
- <variant>release:<linkflags>"-Wl,-z,defs,--warn-once,--gc-sections"
- <variant>debug:<cxxflags>"-W -Wall -Werror -Wwrite-strings -std=c++1y -fvisibility=hidden"
- <variant>debug:<linkflags>"-Wl,-z,defs,--warn-once"
- <variant>coverage:<cxxflags>"-W -Wall -Werror -Wwrite-strings -std=c++1y --coverage -fvisibility=hidden"
- <variant>coverage:<linkflags>"-Wl,-z,defs,--warn-once --coverage"
+ <define>ICE_CPP11_MAPPING
+ <cxxflags>"-std=c++17 -fvisibility=hidden -fvisibility-inlines-hidden"
+ <linkflags>"-Wl,-z,defs,--warn-once,--gc-sections"
+ <variant>release:<cxxflags>"-flto=2"
+ <variant>release:<linkflags>"-flto=2"
+ <variant>debug:<cxxflags>"-W -Wall -Werror -Wextra"
+ <variant>coverage:<cxxflags>"--coverage"
+ <variant>coverage:<linkflags>"--coverage"
;
build-project p2pvr ;
diff --git a/libtmdb/Jamfile.jam b/libtmdb/Jamfile.jam
index faf02b9..f6c8366 100644
--- a/libtmdb/Jamfile.jam
+++ b/libtmdb/Jamfile.jam
@@ -2,8 +2,7 @@ import testing ;
lib slicer : : : : <include>/usr/include/slicer ;
lib slicer-json : : : : <include>/usr/include/slicer ;
-lib Ice ;
-lib IceUtil ;
+lib Ice : : <name>Ice++11 ;
lib jsonpp ;
lib pthread ;
lib boost_system ;
@@ -15,7 +14,6 @@ lib adhocutil : : : : <include>/usr/include/adhocutil ;
lib tmdb :
[ glob *.cpp *.ice : test*.cpp ] :
<library>Ice
- <library>IceUtil
<library>jsonpp
<library>pthread
<library>slicer
@@ -29,7 +27,6 @@ lib tmdb :
: :
<include>.
<library>Ice
- <library>IceUtil
<library>pthread
;
diff --git a/libtmdb/conversions.cpp b/libtmdb/conversions.cpp
index 7f291da..1067dd8 100644
--- a/libtmdb/conversions.cpp
+++ b/libtmdb/conversions.cpp
@@ -6,7 +6,7 @@
namespace Slicer {
std::string
- dateToString(const IceUtil::Optional<::TMDb::Date> & in)
+ dateToString(const Ice::optional<::TMDb::Date> & in)
{
if (!in) {
return std::string();
diff --git a/libtmdb/conversions.h b/libtmdb/conversions.h
index c64cf92..72aeee2 100644
--- a/libtmdb/conversions.h
+++ b/libtmdb/conversions.h
@@ -5,7 +5,7 @@
#include <tmdb-common.h>
namespace Slicer {
- DLL_PUBLIC std::string dateToString(const IceUtil::Optional<::TMDb::Date> &);
+ DLL_PUBLIC std::string dateToString(const Ice::optional<::TMDb::Date> &);
DLL_PUBLIC IceUtil::Optional<::TMDb::Date> stringToDate(const std::string &);
}
diff --git a/libtmdb/testModels.cpp b/libtmdb/testModels.cpp
index 3b1b289..2b61644 100644
--- a/libtmdb/testModels.cpp
+++ b/libtmdb/testModels.cpp
@@ -8,6 +8,14 @@
namespace std {
std::ostream &
+ operator<<(std::ostream & o, const Ice::optional<TMDb::Date> & d)
+ {
+ if (d) {
+ o << *d;
+ }
+ return o;
+ }
+ std::ostream &
operator<<(std::ostream & o, const TMDb::Date & d)
{
o << d.Year << '-' << d.Month << '-' << d.Day;
@@ -23,13 +31,13 @@ BOOST_AUTO_TEST_CASE( deserialize_searchmulti_json_breakingbad )
BOOST_REQUIRE_EQUAL(3, results->TotalResults);
BOOST_REQUIRE_EQUAL("::TMDb::SearchMatchTv", results->Results[0]->ice_id());
- auto tv = TMDb::SearchMatchTvPtr::dynamicCast(results->Results[0]);
+ auto tv = std::dynamic_pointer_cast<TMDb::SearchMatchTv>(results->Results[0]);
BOOST_REQUIRE_EQUAL("Breaking Bad", tv->Name);
BOOST_REQUIRE_EQUAL("/1yeVJox3rjo2jBKrrihIMj7uoS9.jpg", tv->PosterPath);
BOOST_REQUIRE_EQUAL(1396, tv->Id);
BOOST_REQUIRE_EQUAL("::TMDb::SearchMatchMovie", results->Results[1]->ice_id());
- auto movie = TMDb::SearchMatchMoviePtr::dynamicCast(results->Results[1]);
+ auto movie = std::dynamic_pointer_cast<TMDb::SearchMatchMovie>(results->Results[1]);
BOOST_REQUIRE_EQUAL("No Half Measures: Creating the Final Season of Breaking Bad", movie->Title);
BOOST_REQUIRE_EQUAL("/8OixSR45U5dbqv8F0tlspmTbXxN.jpg", movie->PosterPath);
BOOST_REQUIRE_EQUAL(239459, movie->Id);
@@ -43,7 +51,7 @@ BOOST_AUTO_TEST_CASE( deserialize_searchmulti_json_bradpitt )
BOOST_REQUIRE_EQUAL(1, results->TotalResults);
BOOST_REQUIRE_EQUAL("::TMDb::SearchMatchPerson", results->Results[0]->ice_id());
- auto person = TMDb::SearchMatchPersonPtr::dynamicCast(results->Results[0]);
+ auto person = std::dynamic_pointer_cast<TMDb::SearchMatchPerson>(results->Results[0]);
BOOST_REQUIRE_EQUAL("Brad Pitt", person->Name);
BOOST_REQUIRE_EQUAL(287, person->Id);
}
diff --git a/libtmdb/tmdb-proxy.cpp b/libtmdb/tmdb-proxy.cpp
index b20752c..d3c1e8f 100644
--- a/libtmdb/tmdb-proxy.cpp
+++ b/libtmdb/tmdb-proxy.cpp
@@ -7,25 +7,25 @@ namespace TMDb {
}
SearchMultiResultsPtr
- Proxy::SearchMulti(const std::string & query, const IceUtil::Optional<int> & page, const Ice::Current&)
+ Proxy::SearchMulti(const std::string query, const IceUtil::Optional<int> page, const Ice::Current&)
{
return GetData<SearchMultiResultsPtr>("/search/multi", { { "query", query }, { "page", page } });
}
SearchMovieResultsPtr
- Proxy::SearchMovies(const std::string & query, const IceUtil::Optional<int> & year, const IceUtil::Optional<int> & page, const Ice::Current&)
+ Proxy::SearchMovies(const std::string query, const IceUtil::Optional<int> year, const IceUtil::Optional<int> page, const Ice::Current&)
{
return GetData<SearchMovieResultsPtr>("/search/movies", { { "query", query }, { "page", page }, { "year", year } });
}
SearchPersonResultsPtr
- Proxy::SearchPersons(const std::string & query, const IceUtil::Optional<int> & page, const Ice::Current&)
+ Proxy::SearchPersons(const std::string query, const IceUtil::Optional<int> page, const Ice::Current&)
{
return GetData<SearchPersonResultsPtr>("/search/person", { { "query", query }, { "page", page } });
}
SearchTvResultsPtr
- Proxy::SearchTv(const std::string & query, const IceUtil::Optional<int> & page, const Ice::Current&)
+ Proxy::SearchTv(const std::string query, const IceUtil::Optional<int> page, const Ice::Current&)
{
return GetData<SearchTvResultsPtr>("/search/tv", { { "query", query}, { "page", page } });
}
diff --git a/libtmdb/tmdb-proxy.h b/libtmdb/tmdb-proxy.h
index 472e522..1fbe9d1 100644
--- a/libtmdb/tmdb-proxy.h
+++ b/libtmdb/tmdb-proxy.h
@@ -7,10 +7,10 @@ namespace TMDb {
public:
Proxy(const std::string & baseUrl, const std::string & apikey);
- SearchMultiResultsPtr SearchMulti(const std::string&, const IceUtil::Optional<int>&, const Ice::Current&) override;
- SearchMovieResultsPtr SearchMovies(const std::string&, const IceUtil::Optional<int>&, const IceUtil::Optional<int>&, const Ice::Current&) override;
- SearchPersonResultsPtr SearchPersons(const std::string&, const IceUtil::Optional<int>&, const Ice::Current&) override;
- SearchTvResultsPtr SearchTv(const std::string&, const IceUtil::Optional<int>&, const Ice::Current&) override;
+ SearchMultiResultsPtr SearchMulti(const std::string, const IceUtil::Optional<int>, const Ice::Current&) override;
+ SearchMovieResultsPtr SearchMovies(const std::string, const IceUtil::Optional<int>, const IceUtil::Optional<int>, const Ice::Current&) override;
+ SearchPersonResultsPtr SearchPersons(const std::string, const IceUtil::Optional<int>, const Ice::Current&) override;
+ SearchTvResultsPtr SearchTv(const std::string, const IceUtil::Optional<int>, const Ice::Current&) override;
MoviePtr GetMovie(Ice::Int, const Ice::Current&) override;
TvSeriesPtr GetTvSeries(Ice::Int, const Ice::Current&) override;
};
diff --git a/p2pvr/Jamfile.jam b/p2pvr/Jamfile.jam
index 79ebcc1..0c418b7 100644
--- a/p2pvr/Jamfile.jam
+++ b/p2pvr/Jamfile.jam
@@ -3,7 +3,7 @@ import package ;
lib boost_utf : : <name>boost_unit_test_framework ;
lib adhocutil : : : : <include>/usr/include/adhocutil ;
lib icetray : : : : <include>/usr/include/dbpp <include>/usr/include/adhocutil <include>/usr/include/icetray ;
-lib IceBox ;
+lib IceBox : : <name>IceBox++11 ;
build-project daemon ;
build-project carddaemon ;
diff --git a/p2pvr/carddaemon/carddaemon.cpp b/p2pvr/carddaemon/carddaemon.cpp
index c20ca4e..84c464d 100644
--- a/p2pvr/carddaemon/carddaemon.cpp
+++ b/p2pvr/carddaemon/carddaemon.cpp
@@ -1,15 +1,15 @@
#include <icetrayService.h>
#include "devices.h"
#include <Ice/ObjectAdapter.h>
-#include <Ice/Communicator.h>
+#include <Ice/Initialize.h>
#include <IceUtil/Timer.h>
namespace P2PVR {
class CardDaemon : public IceTray::Service {
public:
- void addObjects(const std::string &, const Ice::CommunicatorPtr & ic, const Ice::StringSeq &, const Ice::ObjectAdapterPtr & adapter) override
+ void addObjects(const std::string &, const Ice::CommunicatorPtr &, const Ice::StringSeq &, const Ice::ObjectAdapterPtr & adapter) override
{
- adapter->add(new DevicesI(), ic->stringToIdentity("Devices"));
+ adapter->add(std::make_shared<DevicesI>(), Ice::stringToIdentity("Devices"));
}
};
diff --git a/p2pvr/daemon/Jamfile.jam b/p2pvr/daemon/Jamfile.jam
index f276437..df1e310 100644
--- a/p2pvr/daemon/Jamfile.jam
+++ b/p2pvr/daemon/Jamfile.jam
@@ -1,7 +1,7 @@
import icetray ;
lib slicer : : <name>slicer : : <include>/usr/include/slicer ;
-lib slicer-db : : <name>slicer-db : : <include>/usr/include/slicer ;
+lib slicer-db : : <name>slicer-db : : <include>/usr/include/slicer/slicer ;
lib boost_program_options ;
lib dbppcore ;
diff --git a/p2pvr/daemon/daemon.cpp b/p2pvr/daemon/daemon.cpp
index fbaa380..902b18f 100644
--- a/p2pvr/daemon/daemon.cpp
+++ b/p2pvr/daemon/daemon.cpp
@@ -6,6 +6,7 @@
#include "recorder.h"
#include "recordings.h"
#include <Ice/ObjectAdapter.h>
+#include <Ice/Initialize.h>
#include <tmdb-proxy.h>
#include <icetrayService.h>
@@ -36,20 +37,21 @@ class P2PvrDaemon : public IceTray::Service {
IceUtil::TimerPtr timer = new IceUtil::Timer();
auto db = getConnectionPool(ic, "postgresql", "p2pvr");
- auto devices = add<Tuners>(ic, adapter, new DevicesI(), "Devices");
- auto maintenance = add<Maintenance>(ic, adapter, new MaintenanceI(db, adapter, timer), "Maintenance");
- auto si = add<SI>(ic, adapter, new SII(db), "SI");
- auto schedules = add<Schedules>(ic, adapter, new SchedulesI(db), "Schedules");
- auto storage = add<Storage>(ic, adapter, new StorageI(db), "Storage");
- auto recorder = add<Recorder>(ic, adapter, new RecorderI(adapter, timer), "Recorder");
- auto recordings = add<Recordings>(ic, adapter, new RecordingsI(db), "Recordings");
- auto tmdb = add<TMDb::Proxy>(ic, adapter, new TMDb::Proxy(tmdbOpts->baseUrl, tmdbOpts->apikey), "TMDb");
+ auto devices = add<DevicesI>(adapter, "Devices");
+ auto maintenance = add<MaintenanceI>(adapter, "Maintenance", db, adapter, timer);
+ auto si = add<SII>(adapter, "SI", db);
+ auto schedules = add<SchedulesI>(adapter, "Schedules", db);
+ auto storage = add<StorageI>(adapter, "Storage", db);
+ auto recorder = add<RecorderI>(adapter, "Recorder", adapter, timer);
+ auto recordings = add<RecordingsI>(adapter, "Recordings", db);
+ auto tmdb = add<TMDb::Proxy>(adapter, "TMDb", tmdbOpts->baseUrl, tmdbOpts->apikey);
}
- template<typename Object>
- typename Object::ProxyType add(const Ice::CommunicatorPtr & ic, const Ice::ObjectAdapterPtr & adapter, const IceUtil::Handle<Object> & object, const std::string & name) const
+ template<typename Object, typename ... Params>
+ std::shared_ptr<typename Object::ProxyType> add(const Ice::ObjectAdapterPtr & adapter,
+ const std::string & name, const Params & ... ps) const
{
- return Object::ProxyType::uncheckedCast(adapter->add(object, ic->stringToIdentity(name)));
+ return Ice::uncheckedCast<typename Object::ProxyType>(adapter->add(std::make_shared<Object>(ps...), Ice::stringToIdentity(name)));
}
};
diff --git a/p2pvr/daemon/icetraySupport.cpp b/p2pvr/daemon/icetraySupport.cpp
index 8f81ec4..646896f 100644
--- a/p2pvr/daemon/icetraySupport.cpp
+++ b/p2pvr/daemon/icetraySupport.cpp
@@ -1,9 +1,9 @@
#include "icetraySupport.h"
-#include "commonHelpers.h"
+#include "chronoHelpers.h"
template<>
void
-IceTray::AbstractDatabaseClient::bind1<Common::DateTime>(int x, DB::Command * cmd, const Common::DateTime & dt)
+IceTray::AbstractDatabaseClient::bind1<Chrono::DateTime>(int x, DB::Command * cmd, const Chrono::DateTime & dt)
{
cmd->bindParamT(x, *dt);
}
diff --git a/p2pvr/daemon/icetraySupport.h b/p2pvr/daemon/icetraySupport.h
index 4174665..c9b633b 100644
--- a/p2pvr/daemon/icetraySupport.h
+++ b/p2pvr/daemon/icetraySupport.h
@@ -2,12 +2,23 @@
#define P2PVR_ICETRAY_SUPPORT_H
#include <abstractDatabaseClient.h>
-#include <common.h>
+#include <chrono.h>
namespace IceTray {
template<>
void
- AbstractDatabaseClient::bind1<Common::DateTime>(int x, DB::Command * cmd, const Common::DateTime &);
+ AbstractDatabaseClient::bind1<Chrono::DateTime>(int x, DB::Command * cmd, const Chrono::DateTime &);
+}
+
+namespace std {
+ template<typename X>
+ ostream & operator<<(ostream & s, const Ice::optional<X> & x)
+ {
+ if (x) {
+ s << *x;
+ }
+ return s;
+ }
}
#endif
diff --git a/p2pvr/daemon/maintenance.cpp b/p2pvr/daemon/maintenance.cpp
index 6abad00..58d9dc2 100644
--- a/p2pvr/daemon/maintenance.cpp
+++ b/p2pvr/daemon/maintenance.cpp
@@ -6,8 +6,10 @@
#include <linux/dvb/frontend.h>
#include <cxxabi.h>
#include <scopeExit.h>
+#include <boost/bind.hpp>
namespace po = boost::program_options;
+using namespace IceTray::Logging;
namespace P2PVR {
MaintenanceI::Options::Options() : IceTray::Options("P2PVR Maintenance options") { }
@@ -24,11 +26,11 @@ ICETRAY_OPTIONS(MaintenanceI::Options,
IceTray::Logging::LoggerPtr MaintenanceI::logger(LOGMANAGER()->getLogger<MaintenanceI>());
-MaintenanceI::MaintenanceI(IceTray::DatabasePoolPtr db, Ice::ObjectAdapterPtr a, IceUtil::TimerPtr t) :
+MaintenanceI::MaintenanceI(DB::ConnectionPoolPtr db, Ice::ObjectAdapterPtr a, IceUtil::TimerPtr t) :
IceTray::AbstractDatabaseClient(db),
adapter(a),
timer(t),
- clientCheck(new BindTimerTask(boost::bind(&MaintenanceI::ScheduledUpdate, this))),
+ clientCheck(std::make_shared<BindTimerTask>(boost::bind(&MaintenanceI::ScheduledUpdate, this))),
lastUpdateNetwork(0),
lastUpdateServices(0),
lastUpdateEvents(0),
@@ -62,7 +64,7 @@ MaintenanceI::UpdateAll(short type, const Ice::Current & ice)
void
MaintenanceI::ScheduledUpdate()
{
- logger->messagebf(LOG::DEBUG, "%s: triggered", __PRETTY_FUNCTION__);
+ logger->messagebf(LogLevel::DEBUG, "%s: triggered", __PRETTY_FUNCTION__);
if (!updateRunning) {
std::thread update([this] {
try {
@@ -70,29 +72,29 @@ MaintenanceI::ScheduledUpdate()
updateRunning = true;
time_t now = time(NULL);
if (lastUpdateNetwork < now - options->periodUpdateNetwork) {
- logger->messagebf(LOG::INFO, "%s: updating network", __PRETTY_FUNCTION__);
+ logger->messagebf(LogLevel::INFO, "%s: updating network", __PRETTY_FUNCTION__);
this->UpdateNetwork(FE_OFDM, Ice::Current());
time(&lastUpdateNetwork);
}
if (lastUpdateServices < now - options->periodUpdateServices) {
- logger->messagebf(LOG::INFO, "%s: updating services", __PRETTY_FUNCTION__);
+ logger->messagebf(LogLevel::INFO, "%s: updating services", __PRETTY_FUNCTION__);
this->UpdateServices(Ice::Current());
time(&lastUpdateServices);
}
if (lastUpdateEvents < now - options->periodUpdateEvents) {
- logger->messagebf(LOG::INFO, "%s: updating events", __PRETTY_FUNCTION__);
+ logger->messagebf(LogLevel::INFO, "%s: updating events", __PRETTY_FUNCTION__);
this->UpdateEvents(Ice::Current());
time(&lastUpdateEvents);
}
- logger->messagebf(LOG::DEBUG, "%s: completed", __PRETTY_FUNCTION__);
+ logger->messagebf(LogLevel::DEBUG, "%s: completed", __PRETTY_FUNCTION__);
}
catch (const std::exception & ex) {
char * buf = __cxxabiv1::__cxa_demangle(typeid(ex).name(), NULL, NULL, NULL);
- logger->messagebf(LOG::ERR, "%s: failed %s: %s", __PRETTY_FUNCTION__, buf, ex.what());
+ logger->messagebf(LogLevel::ERR, "%s: failed %s: %s", __PRETTY_FUNCTION__, buf, ex.what());
free(buf);
}
catch (...) {
- logger->messagebf(LOG::ERR, "%s: failed (unknown exception)", __PRETTY_FUNCTION__);
+ logger->messagebf(LogLevel::ERR, "%s: failed (unknown exception)", __PRETTY_FUNCTION__);
}
});
update.detach();
diff --git a/p2pvr/daemon/maintenance.h b/p2pvr/daemon/maintenance.h
index ff53ca6..ccbafca 100644
--- a/p2pvr/daemon/maintenance.h
+++ b/p2pvr/daemon/maintenance.h
@@ -20,7 +20,7 @@ class MaintenanceI : public Maintenance, public IceTray::AbstractDatabaseClient
bool scanOnStart;
};
- MaintenanceI(IceTray::DatabasePoolPtr db, Ice::ObjectAdapterPtr, IceUtil::TimerPtr);
+ MaintenanceI(DB::ConnectionPoolPtr db, Ice::ObjectAdapterPtr, IceUtil::TimerPtr);
void UpdateAll(const Ice::Current &);
void UpdateAll(short type, const Ice::Current &);
diff --git a/p2pvr/daemon/maintenance/events.cpp b/p2pvr/daemon/maintenance/events.cpp
index 30e0a83..18538a4 100644
--- a/p2pvr/daemon/maintenance/events.cpp
+++ b/p2pvr/daemon/maintenance/events.cpp
@@ -1,8 +1,9 @@
#include "../maintenance.h"
#include <siParsers/event.h>
#include <Ice/Communicator.h>
+#include <Ice/Initialize.h>
#include <temporaryIceAdapterObject.h>
-#include <commonHelpers.h>
+#include <chronoHelpers.h>
#include <db/sqlTablePatchSerializer.h>
#include <tablepatch.h>
#include <sqlWriter.h>
@@ -10,6 +11,8 @@
#include "sql/maintenance/pruneEvents.sql.h"
#include "sql/si/serviceIdsWithEit.sql.h"
+using namespace IceTray::Logging;
+
namespace P2PVR {
class SiEventsStream : public Slicer::Stream<::DVBSI::EventPtr> {
private:
@@ -24,7 +27,7 @@ class SiEventsStream : public Slicer::Stream<::DVBSI::EventPtr> {
bool HandleTable(const ::DVBSI::EventPtr & e) override
{
- logger->messagebf(LOG::DEBUG, "Service Id: %d Program Id: %d Title: %s Time: %s - %s",
+ logger->messagebf(LogLevel::DEBUG, "Service Id: %d Program Id: %d Title: %s Time: %s - %s",
e->ServiceId, e->EventId, e->Title, e->StartTime, e->StopTime);
consumer(e);
return false;
@@ -33,7 +36,7 @@ class SiEventsStream : public Slicer::Stream<::DVBSI::EventPtr> {
static RequiredContentIds getIds(DB::Connection * db)
{
auto sel = sql::si::serviceIdsWithEit.select(db);
- auto ids = Slicer::DeserializeAny<Slicer::SqlSelectDeserializer, std::vector<Ice::Int>>(*sel);
+ auto ids = Slicer::DeserializeAny<Slicer::SqlSelectDeserializer, std::vector<Ice::Int>>(sel.get());
return {ids.begin(), ids.end()};
}
@@ -53,8 +56,8 @@ class SiEventsStream : public Slicer::Stream<::DVBSI::EventPtr> {
void Produce(const Consumer & ch) override
{
auto ic = ice.adapter->getCommunicator();
- auto devs = TunersPrx::checkedCast(ice.adapter->createProxy(ic->stringToIdentity("Devices")));
- auto si = SIPrx::checkedCast(ice.adapter->createProxy(ic->stringToIdentity("SI")));
+ auto devs = Ice::checkedCast<TunersPrx>(ice.adapter->createProxy(Ice::stringToIdentity("Devices")));
+ auto si = Ice::checkedCast<SIPrx>(ice.adapter->createProxy(Ice::stringToIdentity("SI")));
if (!devs || !si) {
throw std::runtime_error("bad proxy(s)");
}
@@ -63,9 +66,9 @@ class SiEventsStream : public Slicer::Stream<::DVBSI::EventPtr> {
if (!delivery) {
throw std::runtime_error("no delivery methods");
}
- logger->messagebf(LOG::DEBUG, "%s: Getting a tuner", __PRETTY_FUNCTION__);
- logger->messagebf(LOG::DEBUG, "%s: Fetching events", __PRETTY_FUNCTION__);
- TemporaryIceAdapterObject<RawDataClient> parser(ice.adapter, new SiEventsHandler(ch, db, logger));
+ logger->messagebf(LogLevel::DEBUG, "%s: Getting a tuner", __PRETTY_FUNCTION__);
+ logger->messagebf(LogLevel::DEBUG, "%s: Fetching events", __PRETTY_FUNCTION__);
+ TemporaryIceAdapterObject<RawDataClient> parser(ice.adapter, std::make_shared<SiEventsHandler>(ch, db, logger));
devs->SendEventInformation(delivery, parser);
}
@@ -84,19 +87,19 @@ MaintenanceI::UpdateEvents(const Ice::Current & ice)
SiEventsStream stream(ice, dbc.get(), logger);
- auto tx = std::make_unique<DB::TransactionScope>(dbc.get());
- DB::TablePatch tp;
- tp.dest = "events";
- tp.insteadOfDelete = new DB::StaticSqlWriter("current = false");
- tp.where = new DB::StaticSqlWriter("a.current");
- Slicer::SerializeAny<Slicer::SqlTablePatchSerializer>(stream, dbc.get(), tp);
-
+ {
+ DB::TransactionScope tx(*dbc.get());
+ DB::TablePatch tp;
+ tp.dest = "events";
+ tp.insteadOfDelete = new DB::StaticSqlWriter("current = false");
+ tp.where = new DB::StaticSqlWriter("a.current");
+ Slicer::SerializeAny<Slicer::SqlTablePatchSerializer>(stream, dbc.get(), tp);
- sql::maintenance::pruneEvents.modify(dbc.get())->execute();
- tx = nullptr;
- logger->messagebf(LOG::INFO, "%s: Updated events", __PRETTY_FUNCTION__);
+ sql::maintenance::pruneEvents.modify(dbc.get())->execute();
+ logger->messagebf(LogLevel::INFO, "%s: Updated events", __PRETTY_FUNCTION__);
+ }
- auto sch = SchedulesPrx::checkedCast(ice.adapter->createProxy(ic->stringToIdentity("Schedules")));
+ auto sch = Ice::checkedCast<SchedulesPrx>(ice.adapter->createProxy(Ice::stringToIdentity("Schedules")));
sch->DoReschedule();
}
}
diff --git a/p2pvr/daemon/maintenance/network.cpp b/p2pvr/daemon/maintenance/network.cpp
index 2f74050..f128eb8 100644
--- a/p2pvr/daemon/maintenance/network.cpp
+++ b/p2pvr/daemon/maintenance/network.cpp
@@ -1,11 +1,14 @@
#include "../maintenance.h"
#include <siParsers/network.h>
#include <Ice/Communicator.h>
+#include <Ice/Initialize.h>
#include <temporaryIceAdapterObject.h>
#include <tablepatch.h>
#include <db/sqlInsertSerializer.h>
#include <db/sqlTablePatchSerializer.h>
+using namespace IceTray::Logging;
+
namespace P2PVR {
class SiNetworkInformationMerger : public DVBSI::SiNetworkInformationParser {
public:
@@ -17,14 +20,14 @@ class SiNetworkInformationMerger : public DVBSI::SiNetworkInformationParser {
bool HandleTable(const ::DVBSI::NetworkPtr & n)
{
- logger->messagebf(LOG::DEBUG, "Network Id: %d Name: %s", n->NetworkId, *n->Name);
+ logger->messagebf(LogLevel::DEBUG, "Network Id: %d Name: %s", n->NetworkId, *n->Name);
for (const auto & ts : n->TransportStreams) {
- logger->messagebf(LOG::DEBUG, "\tTransport Stream Id: %d Original Network Id: %d", ts->TransportStreamId, ts->OriginalNetworkId);
+ logger->messagebf(LogLevel::DEBUG, "\tTransport Stream Id: %d Original Network Id: %d", ts->TransportStreamId, ts->OriginalNetworkId);
for (const auto & s : ts->Services) {
- logger->messagebf(LOG::DEBUG, "\t\tService Id: %d Service Type: %d", s.ServiceId, s.Type);
+ logger->messagebf(LogLevel::DEBUG, "\t\tService Id: %d Service Type: %d", s.ServiceId, s.Type);
}
if (ts->Terrestrial) {
- logger->messagebf(LOG::DEBUG, "\t\tDVB-T: Frequency: %d", ts->Terrestrial->Frequency);
+ logger->messagebf(LogLevel::DEBUG, "\t\tDVB-T: Frequency: %d", ts->Terrestrial->Frequency);
}
}
@@ -80,16 +83,16 @@ MaintenanceI::UpdateNetwork(short, const Ice::Current & ice)
{
auto dbc = db->get();
auto ic = ice.adapter->getCommunicator();
- auto devs = TunersPrx::checkedCast(ice.adapter->createProxy(ic->stringToIdentity("Devices")));
- auto si = SIPrx::checkedCast(ice.adapter->createProxy(ic->stringToIdentity("SI")));
- auto siparser = new SiNetworkInformationMerger(dbc.get(), logger);
+ auto devs = Ice::checkedCast<TunersPrx>(ice.adapter->createProxy(Ice::stringToIdentity("Devices")));
+ auto si = Ice::checkedCast<SIPrx>(ice.adapter->createProxy(Ice::stringToIdentity("SI")));
+ auto siparser = std::make_shared<SiNetworkInformationMerger>(dbc.get(), logger);
TemporaryIceAdapterObject<RawDataClient> parser(ice.adapter, siparser);
if (!devs) {
throw std::runtime_error("bad proxy(s)");
}
- DB::TransactionScope tx(dbc.get());
+ DB::TransactionScope tx(*dbc.get());
auto transport = si->GetDeliveryForSi();
if (transport) {
diff --git a/p2pvr/daemon/maintenance/services.cpp b/p2pvr/daemon/maintenance/services.cpp
index 288dd99..8a0ef52 100644
--- a/p2pvr/daemon/maintenance/services.cpp
+++ b/p2pvr/daemon/maintenance/services.cpp
@@ -2,12 +2,15 @@
#include <siParsers/service.h>
#include <tablepatch.h>
#include <Ice/Communicator.h>
+#include <Ice/Initialize.h>
#include <temporaryIceAdapterObject.h>
#include <slicer/slicer.h>
#include <db/sqlTablePatchSerializer.h>
#include <tablepatch.h>
#include <sql/si/allDeliveriesTransportStreamId.sql.h>
+using namespace IceTray::Logging;
+
namespace P2PVR {
class SiServicesMerger : public DVBSI::SiServicesParser {
public:
@@ -20,9 +23,9 @@ class SiServicesMerger : public DVBSI::SiServicesParser {
bool HandleTable(const ::DVBSI::TransportStreamPtr & ts)
{
- logger->messagebf(LOG::DEBUG, "Transport Stream Id: %d Original Network Id: %s", ts->TransportStreamId, ts->OriginalNetworkId);
+ logger->messagebf(LogLevel::DEBUG, "Transport Stream Id: %d Original Network Id: %s", ts->TransportStreamId, ts->OriginalNetworkId);
for (const auto & s : ts->Services) {
- logger->messagebf(LOG::DEBUG, "\tService Id: %d Name: %s Type: %d, Provider: %s, DefaultAuthority: %s, RunningStatus %d FreeCaMode %d",
+ logger->messagebf(LogLevel::DEBUG, "\tService Id: %d Name: %s Type: %d, Provider: %s, DefaultAuthority: %s, RunningStatus %d FreeCaMode %d",
s->ServiceId, (s->Name ? *s->Name : "?"), (s->Type ? *s->Type : -1),
(s->ProviderName ? *s->ProviderName : "?"), (s->DefaultAuthority ? *s->DefaultAuthority : "?"),
s->RunningStatus, s->FreeCaMode);
@@ -39,7 +42,7 @@ class SiServicesMerger : public DVBSI::SiServicesParser {
static RequiredContentIds getIds(DB::Connection * db)
{
auto sel = sql::si::allDeliveriesTransportStreamId.select(db);
- auto ids = Slicer::DeserializeAny<Slicer::SqlSelectDeserializer, std::vector<Ice::Int>>(*sel);
+ auto ids = Slicer::DeserializeAny<Slicer::SqlSelectDeserializer, std::vector<Ice::Int>>(sel.get());
return {ids.begin(), ids.end()};
}
@@ -52,15 +55,15 @@ void
MaintenanceI::UpdateServices(const Ice::Current & ice)
{
auto ic = ice.adapter->getCommunicator();
- auto devs = TunersPrx::checkedCast(ice.adapter->createProxy(ic->stringToIdentity("Devices")));
- auto si = SIPrx::checkedCast(ice.adapter->createProxy(ic->stringToIdentity("SI")));
+ auto devs = Ice::checkedCast<TunersPrx>(ice.adapter->createProxy(Ice::stringToIdentity("Devices")));
+ auto si = Ice::checkedCast<SIPrx>(ice.adapter->createProxy(Ice::stringToIdentity("SI")));
if (!devs || !si) {
throw std::runtime_error("bad proxy(s)");
}
auto dbc = db->get();
- auto siparser = new SiServicesMerger(logger, dbc.get());
+ auto siparser = std::make_shared<SiServicesMerger>(logger, dbc.get());
TemporaryIceAdapterObject<RawDataClient> parser(ice.adapter, siparser);
auto delivery = si->GetDeliveryForSi();
@@ -68,10 +71,10 @@ MaintenanceI::UpdateServices(const Ice::Current & ice)
throw std::runtime_error("no delivery methods");
}
- DB::TransactionScope tx(dbc.get());
- logger->messagebf(LOG::DEBUG, "%s: Fetching service list", __PRETTY_FUNCTION__);
+ DB::TransactionScope tx(*dbc.get());
+ logger->messagebf(LogLevel::DEBUG, "%s: Fetching service list", __PRETTY_FUNCTION__);
devs->SendServiceDescriptions(delivery, parser);
- logger->messagebf(LOG::INFO, "%s: Updated service list", __PRETTY_FUNCTION__);
+ logger->messagebf(LogLevel::INFO, "%s: Updated service list", __PRETTY_FUNCTION__);
}
}
diff --git a/p2pvr/daemon/p2pvr-int.ice b/p2pvr/daemon/p2pvr-int.ice
index 9a99239..8a6ae62 100644
--- a/p2pvr/daemon/p2pvr-int.ice
+++ b/p2pvr/daemon/p2pvr-int.ice
@@ -1,4 +1,4 @@
-#include <common.ice>
+#include <chrono.ice>
#include <dvbsi.ice>
module P2PVR {
@@ -6,8 +6,8 @@ module P2PVR {
string What;
int EventUid;
int TransportStreamId;
- Common::DateTime StartTime;
- Common::DateTime StopTime;
+ Chrono::DateTime StartTime;
+ Chrono::DateTime StopTime;
int Priority;
int ScheduleId;
};
diff --git a/p2pvr/daemon/recorder.cpp b/p2pvr/daemon/recorder.cpp
index f32eb73..25709c8 100644
--- a/p2pvr/daemon/recorder.cpp
+++ b/p2pvr/daemon/recorder.cpp
@@ -2,14 +2,16 @@
#include "bindTimerTask.h"
#include <boost/bind.hpp>
#include <logger.h>
-#include <commonHelpers.h>
+#include <chronoHelpers.h>
#include <scopeExit.h>
#include "serviceStreamer.h"
#include "storage.h"
#include "muxer.h"
#include <boost/lexical_cast.hpp>
+#include <Ice/Initialize.h>
namespace po = boost::program_options;
+using namespace IceTray::Logging;
namespace P2PVR {
IceTray::Logging::LoggerPtr RecorderI::logger(LOGMANAGER()->getLogger<RecorderI>());
@@ -18,10 +20,21 @@ RecorderI::RecorderI(Ice::ObjectAdapterPtr a, IceUtil::TimerPtr t) :
adapter(a),
timer(t)
{
- logger->message(LOG::DEBUG, __PRETTY_FUNCTION__);
+ logger->message(LogLevel::DEBUG, __PRETTY_FUNCTION__);
RefreshSchedules(Ice::Current());
}
+RecorderI::Current::Current(RawDataClientPrxPtr str, ServiceStreamerPtr strm,
+ SchedulePtr sch, ::DVBSI::ServicePtr srv, EventPtr e, IceUtil::TimerTaskPtr st) :
+ store(str),
+ stream(strm),
+ schedule(sch),
+ service(srv),
+ event(e),
+ stopTimer(st)
+{
+}
+
void
RecorderI::RefreshSchedules(const Ice::Current &)
{
@@ -30,8 +43,8 @@ RecorderI::RefreshSchedules(const Ice::Current &)
timer->cancel(t);
}
pendingRecordings.clear();
- auto schedules = SchedulesPrx::checkedCast(adapter->createProxy(adapter->getCommunicator()->stringToIdentity("Schedules")));
- auto si = SIPrx::checkedCast(adapter->createProxy(adapter->getCommunicator()->stringToIdentity("SI")));
+ auto schedules = Ice::checkedCast<SchedulesPrx>(adapter->createProxy(Ice::stringToIdentity("Schedules")));
+ auto si = Ice::checkedCast<SIPrx>(adapter->createProxy(Ice::stringToIdentity("SI")));
for (const auto & s : schedules->GetScheduledToRecord()) {
if (std::find_if(currentRecordings.begin(), currentRecordings.end(), [&s](const CurrentPtr & c) {
return s->ScheduleId == c->schedule->ScheduleId && s->EventUid == c->event->EventUid;
@@ -43,10 +56,10 @@ RecorderI::RefreshSchedules(const Ice::Current &)
auto service = si->GetService(event->ServiceId);
auto startIn = std::max<time_t>((*event->StartTime - *schedule->Early - boost::posix_time::second_clock::universal_time()).total_seconds(), 0);
- IceUtil::TimerTaskPtr startTimer = new BindTimerTask(boost::bind(&RecorderI::StartRecording, this, schedule, service, event));
+ IceUtil::TimerTaskPtr startTimer = std::make_shared<BindTimerTask>(boost::bind(&RecorderI::StartRecording, this, schedule, service, event));
timer->schedule(startTimer, IceUtil::Time::seconds(startIn));
pendingRecordings.push_back(startTimer);
- logger->messagebf(LOG::DEBUG, "Recording %s scheduled for %s seconds", event->Title, startIn);
+ logger->messagebf(LogLevel::DEBUG, "Recording %s scheduled for %s seconds", event->Title, startIn);
}
}
@@ -54,39 +67,39 @@ void
RecorderI::StartRecording(SchedulePtr schedule, ::DVBSI::ServicePtr service, EventPtr event)
{
std::lock_guard<std::mutex> g(lock);
- auto storage = StoragePrx::checkedCast(adapter->createProxy(adapter->getCommunicator()->stringToIdentity("Storage")));
- auto recordings = RecordingsPrx::checkedCast(adapter->createProxy(adapter->getCommunicator()->stringToIdentity("Recordings")));
- auto devices = TunersPrx::checkedCast(adapter->createProxy(adapter->getCommunicator()->stringToIdentity("Devices")));
- auto si = SIPrx::checkedCast(adapter->createProxy(adapter->getCommunicator()->stringToIdentity("SI")));
+ auto storage = Ice::checkedCast<StoragePrx>(adapter->createProxy(Ice::stringToIdentity("Storage")));
+ auto recordings = Ice::checkedCast<RecordingsPrx>(adapter->createProxy(Ice::stringToIdentity("Recordings")));
+ auto devices = Ice::checkedCast<TunersPrx>(adapter->createProxy(Ice::stringToIdentity("Devices")));
+ auto si = Ice::checkedCast<SIPrx>(adapter->createProxy(Ice::stringToIdentity("SI")));
- auto recordingId = recordings->NewRecording(new Recording(0, schedule->ScheduleId, event->EventUid));
+ auto recordingId = recordings->NewRecording(std::make_shared<Recording>(0, schedule->ScheduleId, event->EventUid));
auto target = storage->OpenForWrite(recordingId);
- auto ss = ServiceStreamerPtr(new ServiceStreamer(service->ServiceId, target, devices, si, adapter));
+ auto ss = ServiceStreamerPtr(std::make_shared<ServiceStreamer>(service->ServiceId, target, devices, si, adapter));
ss->Start();
- logger->messagebf(LOG::INFO, "Started recording %s (%s - %s) on %s (%d)",
+ logger->messagebf(LogLevel::INFO, "Started recording %s (%s - %s) on %s (%d)",
event->Title, event->StartTime, event->StopTime,
service->Name ? *service->Name : "<no name>", service->ServiceId);
- auto newCurrent = CurrentPtr(new Current({target, ss, schedule, service, event, IceUtil::TimerTaskPtr()}));
+ auto newCurrent = std::make_shared<Current>(target, ss, schedule, service, event, IceUtil::TimerTaskPtr());
currentRecordings.insert(newCurrent);
auto stopIn = (*event->StopTime + *schedule->Late - boost::posix_time::second_clock::universal_time()).total_seconds();
- newCurrent->stopTimer = new BindTimerTask(boost::bind(&RecorderI::StopRecording, this, newCurrent));
+ newCurrent->stopTimer = std::make_shared<BindTimerTask>(boost::bind(&RecorderI::StopRecording, this, newCurrent));
timer->schedule(newCurrent->stopTimer, IceUtil::Time::seconds(stopIn));
- logger->messagebf(LOG::DEBUG, "Recording %s scheduled stop in %s seconds", event->Title, stopIn);
+ logger->messagebf(LogLevel::DEBUG, "Recording %s scheduled stop in %s seconds", event->Title, stopIn);
}
void
RecorderI::StopRecording(CurrentPtr c)
{
std::lock_guard<std::mutex> g(lock);
- logger->messagebf(LOG::DEBUG, "Stopping %s", c->event->Title);
+ logger->messagebf(LogLevel::DEBUG, "Stopping %s", c->event->Title);
c->stream->Stop();
currentRecordings.erase(c);
- auto storage = StoragePrx::checkedCast(adapter->createProxy(adapter->getCommunicator()->stringToIdentity("Storage")));
+ auto storage = Ice::checkedCast<StoragePrx>(adapter->createProxy(Ice::stringToIdentity("Storage")));
storage->Close(c->store);
- logger->messagebf(LOG::DEBUG, "Stopped %s", c->event->Title);
+ logger->messagebf(LogLevel::DEBUG, "Stopped %s", c->event->Title);
}
}
diff --git a/p2pvr/daemon/recorder.h b/p2pvr/daemon/recorder.h
index b2d581c..8a4fd77 100644
--- a/p2pvr/daemon/recorder.h
+++ b/p2pvr/daemon/recorder.h
@@ -15,14 +15,20 @@ class RecorderI : public Recorder {
class Current {
public:
- RawDataClientPrx store;
+ Current(RawDataClientPrxPtr store,
+ ServiceStreamerPtr stream,
+ SchedulePtr schedule,
+ ::DVBSI::ServicePtr service,
+ EventPtr event,
+ IceUtil::TimerTaskPtr stopTimer);
+ RawDataClientPrxPtr store;
ServiceStreamerPtr stream;
SchedulePtr schedule;
::DVBSI::ServicePtr service;
EventPtr event;
IceUtil::TimerTaskPtr stopTimer;
};
- typedef boost::shared_ptr<Current> CurrentPtr;
+ typedef std::shared_ptr<Current> CurrentPtr;
typedef std::set<CurrentPtr> Currents;
RecorderI(Ice::ObjectAdapterPtr a, IceUtil::TimerPtr);
diff --git a/p2pvr/daemon/recordings.cpp b/p2pvr/daemon/recordings.cpp
index 0ab2e46..5bb0fd0 100644
--- a/p2pvr/daemon/recordings.cpp
+++ b/p2pvr/daemon/recordings.cpp
@@ -6,23 +6,26 @@
#include <slicer/db/sqlInsertSerializer.h>
#include <sql/recordings/deleteById.sql.h>
#include <sql/recordings/getAll.sql.h>
+#include <modifycommand.h>
+
+using namespace IceTray::Logging;
namespace P2PVR {
IceTray::Logging::LoggerPtr RecordingsI::logger(LOGMANAGER()->getLogger<RecordingsI>());
-RecordingsI::RecordingsI(IceTray::DatabasePoolPtr db) :
+RecordingsI::RecordingsI(DB::ConnectionPoolPtr db) :
IceTray::AbstractDatabaseClient(db)
{
}
Ice::Int
-RecordingsI::NewRecording(const RecordingPtr & r, const Ice::Current &)
+RecordingsI::NewRecording(const RecordingPtr r, const Ice::Current &)
{
auto dbc = db->get();
- logger->messagebf(LOG::INFO, "%s: Creating new recording for %d (EventUid %d)", __PRETTY_FUNCTION__, r->RecordingId, r->EventUid);
- DB::TransactionScope tx(dbc.get());
+ logger->messagebf(LogLevel::INFO, "%s: Creating new recording for %d (EventUid %d)", __PRETTY_FUNCTION__, r->RecordingId, r->EventUid);
+ DB::TransactionScope tx(*dbc.get());
Slicer::SerializeAny<Slicer::SqlFetchIdInsertSerializer>(r, dbc.get(), "recordings");
- logger->messagebf(LOG::INFO, "%s: Created recording Id: %d", __PRETTY_FUNCTION__, r->RecordingId);
+ logger->messagebf(LogLevel::INFO, "%s: Created recording Id: %d", __PRETTY_FUNCTION__, r->RecordingId);
return r->RecordingId;
}
@@ -30,7 +33,7 @@ void
RecordingsI::DeleteRecording(int id, const Ice::Current &)
{
auto dbc = db->get();
- logger->messagebf(LOG::INFO, "%s: Deleting recording Id: %d", __PRETTY_FUNCTION__, id);
+ logger->messagebf(LogLevel::INFO, "%s: Deleting recording Id: %d", __PRETTY_FUNCTION__, id);
auto del = sql::recordings::deleteById.modify(dbc.get());
del->bindParamI(0, id);
del->execute();
@@ -39,7 +42,7 @@ RecordingsI::DeleteRecording(int id, const Ice::Current &)
RecordingList
RecordingsI::GetRecordings(const Ice::Current &)
{
- logger->message(LOG::DEBUG, __PRETTY_FUNCTION__);
+ logger->message(LogLevel::DEBUG, __PRETTY_FUNCTION__);
return fetch<RecordingList>(sql::recordings::getAll);
}
}
diff --git a/p2pvr/daemon/recordings.h b/p2pvr/daemon/recordings.h
index e705e43..2246f03 100644
--- a/p2pvr/daemon/recordings.h
+++ b/p2pvr/daemon/recordings.h
@@ -9,11 +9,11 @@
namespace P2PVR {
class RecordingsI : public Recordings, public IceTray::AbstractDatabaseClient {
public:
- RecordingsI(IceTray::DatabasePoolPtr db);
+ RecordingsI(DB::ConnectionPoolPtr db);
- Ice::Int NewRecording(const RecordingPtr & rec, const Ice::Current &);
- void DeleteRecording(int recordingId, const Ice::Current &);
- RecordingList GetRecordings(const Ice::Current &);
+ Ice::Int NewRecording(const RecordingPtr rec, const Ice::Current &) override;
+ void DeleteRecording(int recordingId, const Ice::Current &) override;
+ RecordingList GetRecordings(const Ice::Current &) override;
private:
static IceTray::Logging::LoggerPtr logger;
diff --git a/p2pvr/daemon/schedules.cpp b/p2pvr/daemon/schedules.cpp
index d948603..273aa38 100644
--- a/p2pvr/daemon/schedules.cpp
+++ b/p2pvr/daemon/schedules.cpp
@@ -1,7 +1,7 @@
#include "schedules.h"
#include <logger.h>
#include <Ice/Ice.h>
-#include "commonHelpers.h"
+#include "chronoHelpers.h"
#include <boost/date_time/posix_time/posix_time.hpp>
#include <factory.impl.h>
#include <slicer/db/sqlSelectDeserializer.h>
@@ -18,6 +18,7 @@
#include "sql/schedules/scheduledToRecord.sql.h"
namespace po = boost::program_options;
+using namespace IceTray::Logging;
namespace P2PVR {
IceTray::Logging::LoggerPtr SchedulesI::logger(LOGMANAGER()->getLogger<SchedulesI>());
@@ -164,7 +165,7 @@ EpisodeGroup::SuggestWithFeedback(const Showings & showings)
}
}
-SchedulesI::SchedulesI(IceTray::DatabasePoolPtr db) :
+SchedulesI::SchedulesI(DB::ConnectionPoolPtr db) :
IceTray::AbstractDatabaseClient(db)
{
}
@@ -178,7 +179,7 @@ SchedulesI::GetEpisodeIntersects(Episodes & all, Episodes & grouped)
for (const auto & gs : ge->showings) {
for (const auto & as : ae->showings) {
if (gs->period.intersects(as->period)) {
- logger->messagebf(LOG::DEBUG, " added %s", ae->what);
+ logger->messagebf(LogLevel::DEBUG, " added %s", ae->what);
grouped.push_back(ae);
all.erase(aei);
GetEpisodeIntersects(all, grouped);
@@ -194,7 +195,7 @@ void
SchedulesI::DoReschedule(const Ice::Current & ice)
{
auto ic = ice.adapter->getCommunicator();
- auto devs = P2PVR::TunersPrx::checkedCast(ice.adapter->createProxy(ic->stringToIdentity("Devices")));
+ auto devs = Ice::checkedCast<P2PVR::TunersPrx>(ice.adapter->createProxy(Ice::stringToIdentity("Devices")));
unsigned int tunerCount = devs->TunerCount();
// Load list from database
@@ -206,18 +207,18 @@ SchedulesI::DoReschedule(const Ice::Current & ice)
int minPriority = 0;
for (const auto & c : episodes) {
if (!cur || cur->what != c->What) {
- cur = new Episode(c->What);
+ cur = std::make_shared<Episode>(c->What);
scheduleList.push_back(cur);
}
- ShowingPtr s = new Showing(c->EventUid, c->TransportStreamId, c->ScheduleId,
+ ShowingPtr s = std::make_shared<Showing>(c->EventUid, c->TransportStreamId, c->ScheduleId,
*c->StartTime, *c->StopTime, c->Priority, cur.get());
minPriority = std::min(minPriority, s->priority);
cur->showings.push_back(s);
allShowings.push_back(s);
}
- logger->messagebf(LOG::DEBUG, "%d episodes created, %s showings", scheduleList.size(), allShowings.size());
+ logger->messagebf(LogLevel::DEBUG, "%d episodes created, %s showings", scheduleList.size(), allShowings.size());
for (const auto & e : scheduleList) {
- logger->messagebf(LOG::DEBUG, " %s", e->what);
+ logger->messagebf(LogLevel::DEBUG, " %s", e->what);
for (const auto & s : e->showings) {
s->priority += 1 - minPriority;
e->priority += s->priority;
@@ -229,7 +230,7 @@ SchedulesI::DoReschedule(const Ice::Current & ice)
// Solve
while (!scheduleList.empty()) {
auto work = scheduleList.begin();
- logger->messagebf(LOG::DEBUG, "start %s", (*work)->what);
+ logger->messagebf(LogLevel::DEBUG, "start %s", (*work)->what);
Episodes group;
group.push_back(*work);
scheduleList.erase(work);
@@ -240,15 +241,15 @@ SchedulesI::DoReschedule(const Ice::Current & ice)
return a->what < b->what;
});
- logger->messagebf(LOG::DEBUG, "group created with %d episodes", group.size());
+ logger->messagebf(LogLevel::DEBUG, "group created with %d episodes", group.size());
double total = 1;
// Measure and add the optional to not record
for (const auto & e : group) {
- logger->messagebf(LOG::DEBUG, " %d * %d:%s", e->showings.size(), e->priority, e->what);
+ logger->messagebf(LogLevel::DEBUG, " %d * %d:%s", e->showings.size(), e->priority, e->what);
e->showings.push_back(NULL);
total *= e->showings.size();
}
- logger->messagebf(LOG::DEBUG, "group complexity of %d options", total);
+ logger->messagebf(LogLevel::DEBUG, "group complexity of %d options", total);
EpisodeGroupPtr sched = EpisodeGroupPtr(EpisodeGroupFactory::createNew(options->SchedulerAlgorithm, group));
sched->tuners = tunerCount;
@@ -258,17 +259,17 @@ SchedulesI::DoReschedule(const Ice::Current & ice)
}
for (const auto & c : group) {
- logger->messagebf(LOG::DEBUG, "Episode %s, %d options", c->what, c->showings.size());
+ logger->messagebf(LogLevel::DEBUG, "Episode %s, %d options", c->what, c->showings.size());
for (const auto & i : c->showings) {
if (selected.find(i) != selected.end()) {
- logger->messagebf(LOG::DEBUG, " %s - %s (%d) <-", i->startTime, i->stopTime, i->transportStreamId);
+ logger->messagebf(LogLevel::DEBUG, " %s - %s (%d) <-", i->startTime, i->stopTime, i->transportStreamId);
}
else if (i) {
- logger->messagebf(LOG::DEBUG, " %s - %s (%d)", i->startTime, i->stopTime, i->transportStreamId);
+ logger->messagebf(LogLevel::DEBUG, " %s - %s (%d)", i->startTime, i->stopTime, i->transportStreamId);
}
}
}
- logger->message(LOG::DEBUG, "----------");
+ logger->message(LogLevel::DEBUG, "----------");
for (const auto & c : group) {
bool found = false;
for (const auto & i : c->showings) {
@@ -279,22 +280,22 @@ SchedulesI::DoReschedule(const Ice::Current & ice)
}
for (const auto & i : c->showings) {
if (i) {
- records.push_back(new P2PVR::ScheduledToRecord(i->eventUid,
+ records.push_back(std::make_shared<P2PVR::ScheduledToRecord>(i->eventUid,
found ?
- selected.find(i) != selected.end() ? P2PVR::WillRecordThisShowing : P2PVR::WillRecordOtherShowing :
- P2PVR::CannotRecordAnyShowing, i->scheduleId));
+ selected.find(i) != selected.end() ? RecordStatuses::WillRecordThisShowing : RecordStatuses::WillRecordOtherShowing :
+ RecordStatuses::CannotRecordAnyShowing, i->scheduleId));
}
}
}
}
auto dbc = db->get();
- DB::TransactionScope tx(dbc.get());
+ DB::TransactionScope tx(*dbc.get());
DB::TablePatch mergeRecords;
mergeRecords.dest = "record";
Slicer::SerializeAny<Slicer::SqlTablePatchSerializer>(records, dbc.get(), mergeRecords);
- auto recorder = P2PVR::RecorderPrx::checkedCast(ice.adapter->createProxy(ice.adapter->getCommunicator()->stringToIdentity("Recorder")));
+ auto recorder = Ice::checkedCast<RecorderPrx>(ice.adapter->createProxy(Ice::stringToIdentity("Recorder")));
recorder->RefreshSchedules();
}
@@ -311,14 +312,14 @@ SchedulesI::DeleteSchedule(int id, const Ice::Current & ice)
P2PVR::ScheduleList
SchedulesI::GetSchedules(const Ice::Current &)
{
- logger->message(LOG::DEBUG, __PRETTY_FUNCTION__);
+ logger->message(LogLevel::DEBUG, __PRETTY_FUNCTION__);
return fetch<P2PVR::ScheduleList>(P2PVR::sql::schedules::selectAll);
}
P2PVR::SchedulePtr
SchedulesI::GetSchedule(int id, const Ice::Current &)
{
- logger->messagebf(LOG::DEBUG, "%s(%d)", __PRETTY_FUNCTION__, id);
+ logger->messagebf(LogLevel::DEBUG, "%s(%d)", __PRETTY_FUNCTION__, id);
auto schedules = fetch<P2PVR::ScheduleList>(P2PVR::sql::schedules::selectById, id);
if (schedules.empty()) throw P2PVR::NotFound();
return schedules.front();
@@ -327,12 +328,12 @@ SchedulesI::GetSchedule(int id, const Ice::Current &)
P2PVR::ScheduledToRecordList
SchedulesI::GetScheduledToRecord(const Ice::Current &)
{
- logger->message(LOG::DEBUG, __PRETTY_FUNCTION__);
+ logger->message(LogLevel::DEBUG, __PRETTY_FUNCTION__);
return fetch<P2PVR::ScheduledToRecordList>(P2PVR::sql::schedules::scheduledToRecord);
}
Ice::Int
-SchedulesI::NewSchedule(const P2PVR::SchedulePtr & s, const Ice::Current & ice)
+SchedulesI::NewSchedule(const P2PVR::SchedulePtr s, const Ice::Current & ice)
{
auto dbc = db->get();
Slicer::SerializeAny<Slicer::SqlFetchIdInsertSerializer>(s, dbc.get(), "schedules");
@@ -341,7 +342,7 @@ SchedulesI::NewSchedule(const P2PVR::SchedulePtr & s, const Ice::Current & ice)
}
void
-SchedulesI::UpdateSchedule(const P2PVR::SchedulePtr & s, const Ice::Current & ice)
+SchedulesI::UpdateSchedule(const P2PVR::SchedulePtr s, const Ice::Current & ice)
{
auto dbc = db->get();
Slicer::SerializeAny<Slicer::SqlUpdateSerializer>(s, dbc.get(), "schedules");
diff --git a/p2pvr/daemon/schedules.h b/p2pvr/daemon/schedules.h
index f1fcde2..7b235a9 100644
--- a/p2pvr/daemon/schedules.h
+++ b/p2pvr/daemon/schedules.h
@@ -5,14 +5,13 @@
#include <options.h>
#include <abstractDatabaseClient.h>
#include <factory.h>
-#include <intrusivePtrBase.h>
#include <logger.h>
namespace P2PVR {
typedef boost::posix_time::ptime datetime;
class Episode;
-class Showing : public IntrusivePtrBase {
+class Showing {
public:
Showing(unsigned int e, unsigned int t, unsigned int sc, datetime start, datetime stop, int p, const Episode * ep);
// Record what?
@@ -26,18 +25,18 @@ class Showing : public IntrusivePtrBase {
const datetime stopTime;
const boost::posix_time::time_period period;
};
-typedef boost::intrusive_ptr<Showing> ShowingPtr;
+typedef std::shared_ptr<Showing> ShowingPtr;
typedef std::vector<ShowingPtr> Showings;
typedef Showings::const_iterator ShowingsIter;
-class Episode : public IntrusivePtrBase {
+class Episode {
public:
Episode(const std::string & w);
int priority;
const std::string what;
Showings showings;
};
-typedef boost::intrusive_ptr<Episode> EpisodePtr;
+typedef std::shared_ptr<Episode> EpisodePtr;
typedef std::vector<EpisodePtr> Episodes;
typedef Episodes::const_iterator EpisodesIter;
@@ -75,15 +74,15 @@ class SchedulesI : public Schedules, public IceTray::AbstractDatabaseClient {
std::string SchedulerAlgorithm;
};
- SchedulesI(IceTray::DatabasePoolPtr);
+ SchedulesI(DB::ConnectionPoolPtr);
- void DeleteSchedule(int id, const Ice::Current &);
- SchedulePtr GetSchedule(int id, const Ice::Current &);
- ScheduleList GetSchedules(const Ice::Current &);
- ScheduledToRecordList GetScheduledToRecord(const Ice::Current &);
- Ice::Int NewSchedule(const SchedulePtr &, const Ice::Current &);
- void UpdateSchedule(const SchedulePtr &, const Ice::Current &);
- void DoReschedule(const Ice::Current &);
+ void DeleteSchedule(int id, const Ice::Current &) override;
+ SchedulePtr GetSchedule(int id, const Ice::Current &) override;
+ ScheduleList GetSchedules(const Ice::Current &) override;
+ ScheduledToRecordList GetScheduledToRecord(const Ice::Current &) override;
+ Ice::Int NewSchedule(const SchedulePtr, const Ice::Current &) override;
+ void UpdateSchedule(const SchedulePtr, const Ice::Current &) override;
+ void DoReschedule(const Ice::Current &) override;
protected:
static void GetEpisodeIntersects(Episodes &, Episodes &);
@@ -94,7 +93,7 @@ class SchedulesI : public Schedules, public IceTray::AbstractDatabaseClient {
};
typedef AdHoc::Factory<EpisodeGroup, const Episodes &> EpisodeGroupFactory;
-typedef boost::shared_ptr<EpisodeGroup> EpisodeGroupPtr;
+typedef std::shared_ptr<EpisodeGroup> EpisodeGroupPtr;
}
#endif
diff --git a/p2pvr/daemon/si.cpp b/p2pvr/daemon/si.cpp
index f8a49be..b87c127 100644
--- a/p2pvr/daemon/si.cpp
+++ b/p2pvr/daemon/si.cpp
@@ -2,7 +2,8 @@
#include <slicer/db/sqlSelectDeserializer.h>
#include <slicer/common.h>
#include <slicer/db/sqlExceptions.h>
-#include "commonHelpers.h"
+#include "chronoHelpers.h"
+#include "icetraySupport.h"
#include <slicer/slicer.h>
#include <logger.h>
@@ -21,10 +22,13 @@
#include "sql/si/eventsInRange.sql.h"
#include "sql/si/eventSearch.sql.h"
+using namespace std::literals;
+using namespace IceTray::Logging;
+
namespace P2PVR {
IceTray::Logging::LoggerPtr SII::logger(LOGMANAGER()->getLogger<SII>());
-SII::SII(IceTray::DatabasePoolPtr db) :
+SII::SII(DB::ConnectionPoolPtr db) :
IceTray::AbstractDatabaseClient(db)
{
}
@@ -32,16 +36,16 @@ SII::SII(IceTray::DatabasePoolPtr db) :
DVBSI::Networks
SII::GetNetworks(const Ice::Current &)
{
- logger->message(LOG::DEBUG, __PRETTY_FUNCTION__);
+ logger->message(LogLevel::DEBUG, __PRETTY_FUNCTION__);
return fetch<DVBSI::Networks>(sql::si::allNetworks);
}
Deliveries
SII::GetAllDeliveries(const Ice::Current &)
{
- logger->message(LOG::DEBUG, __PRETTY_FUNCTION__);
- auto rtn = fetch<Deliveries>("delivery_type", sql::si::allDeliveries);
- logger->messagebf(LOG::DEBUG, "%s: Found %d delivery methods", __PRETTY_FUNCTION__, rtn.size());
+ logger->message(LogLevel::DEBUG, __PRETTY_FUNCTION__);
+ auto rtn = fetch<Deliveries>("delivery_type"s, sql::si::allDeliveries);
+ logger->messagebf(LogLevel::DEBUG, "%s: Found %d delivery methods", __PRETTY_FUNCTION__, rtn.size());
return rtn;
}
@@ -49,8 +53,8 @@ DVBSI::DeliveryPtr
SII::GetDeliveryForTransport(int id, const Ice::Current&)
{
try {
- logger->messagef(LOG::DEBUG, "%s(%d)", __PRETTY_FUNCTION__, id);
- return fetch<DVBSI::DeliveryPtr>("delivery_type", sql::si::deliveryForTransport, id);
+ logger->messagef(LogLevel::DEBUG, "%s(%d)", __PRETTY_FUNCTION__, id);
+ return fetch<DVBSI::DeliveryPtr>("delivery_type"s, sql::si::deliveryForTransport, id);
}
catch (const Slicer::NoRowsReturned &) {
throw NotFound();
@@ -61,8 +65,8 @@ DVBSI::DeliveryPtr
SII::GetDeliveryForSi(const Ice::Current&)
{
try {
- logger->message(LOG::DEBUG, __PRETTY_FUNCTION__);
- return fetch<DVBSI::DeliveryPtr>("delivery_type", sql::si::serviceNextUsed);
+ logger->message(LogLevel::DEBUG, __PRETTY_FUNCTION__);
+ return fetch<DVBSI::DeliveryPtr>("delivery_type"s, sql::si::serviceNextUsed);
}
catch (const Slicer::NoRowsReturned &) {
return NULL;
@@ -73,8 +77,8 @@ DVBSI::DeliveryPtr
SII::GetDeliveryForService(int id, const Ice::Current&)
{
try {
- logger->messagef(LOG::DEBUG, "%s(%d)", __PRETTY_FUNCTION__, id);
- return fetch<DVBSI::DeliveryPtr>("delivery_type", sql::si::deliveryForService, id);
+ logger->messagef(LogLevel::DEBUG, "%s(%d)", __PRETTY_FUNCTION__, id);
+ return fetch<DVBSI::DeliveryPtr>("delivery_type"s, sql::si::deliveryForService, id);
}
catch (const Slicer::NoRowsReturned &) {
throw NotFound();
@@ -84,23 +88,23 @@ SII::GetDeliveryForService(int id, const Ice::Current&)
DVBSI::ServiceList
SII::GetServices(const Ice::Current&)
{
- logger->message(LOG::DEBUG, __PRETTY_FUNCTION__);
+ logger->message(LogLevel::DEBUG, __PRETTY_FUNCTION__);
return fetch<DVBSI::ServiceList>(sql::si::servicesSelectAll);
}
DVBSI::ServicePtr
SII::GetService(int id, const Ice::Current&)
{
- logger->messagef(LOG::DEBUG, "%s(%d)", __PRETTY_FUNCTION__, id);
+ logger->messagef(LogLevel::DEBUG, "%s(%d)", __PRETTY_FUNCTION__, id);
auto rtn = fetch<DVBSI::ServiceList>(sql::si::servicesSelectById, id);
if (rtn.empty()) throw NotFound();
return rtn.front();
}
Events
-SII::GetEvents(const IntSequence & eventUids, const Ice::Current &)
+SII::GetEvents(const IntSequence eventUids, const Ice::Current &)
{
- logger->message(LOG::DEBUG, __PRETTY_FUNCTION__);
+ logger->message(LogLevel::DEBUG, __PRETTY_FUNCTION__);
Events rtn;
for (const auto & uid : eventUids) {
auto list = fetch<Events>(sql::si::eventByUid, uid);
@@ -113,7 +117,7 @@ SII::GetEvents(const IntSequence & eventUids, const Ice::Current &)
EventPtr
SII::GetEvent(int serviceId, int eventId, const Ice::Current &)
{
- logger->messagef(LOG::DEBUG, "%s(s=%d, e=%d)", __PRETTY_FUNCTION__, serviceId, eventId);
+ logger->messagef(LogLevel::DEBUG, "%s(s=%d, e=%d)", __PRETTY_FUNCTION__, serviceId, eventId);
auto rtn = fetch<Events>(sql::si::eventById, serviceId, eventId);
if (rtn.empty()) throw NotFound();
return rtn.front();
@@ -122,21 +126,21 @@ SII::GetEvent(int serviceId, int eventId, const Ice::Current &)
Events
SII::EventsOnNow(const Ice::Current &)
{
- logger->message(LOG::DEBUG, __PRETTY_FUNCTION__);
+ logger->message(LogLevel::DEBUG, __PRETTY_FUNCTION__);
return fetch<Events>(sql::si::eventsOnNow);
}
Events
-SII::EventsInRange(const Common::DateTime & from, const Common::DateTime & to, const Ice::Current &)
+SII::EventsInRange(const Chrono::DateTime from, const Chrono::DateTime to, const Ice::Current &)
{
- logger->messagebf(LOG::DEBUG, "%s([%s]-[%s])", from, to, __PRETTY_FUNCTION__);
+ logger->messagebf(LogLevel::DEBUG, "%s([%s]-[%s])", from, to, __PRETTY_FUNCTION__);
return fetch<Events>(sql::si::eventsInRange, from, to);
}
Events
-SII::EventSearch(const IceUtil::Optional<std::string> & keywords, const IceUtil::Optional<Ice::Int> & serviceId, const IceUtil::Optional<Common::DateTime> & from, const IceUtil::Optional<Common::DateTime> & to, const Ice::Current &)
+SII::EventSearch(const IceUtil::Optional<std::string> keywords, const IceUtil::Optional<Ice::Int> serviceId, const IceUtil::Optional<Chrono::DateTime> from, const IceUtil::Optional<Chrono::DateTime> to, const Ice::Current &)
{
- logger->messagebf(LOG::DEBUG, "%s(keywords=%s,serviceId=%s,from=%s,to=%s)",
+ logger->messagebf(LogLevel::DEBUG, "%s(keywords=%s,serviceId=%s,from=%s,to=%s)",
keywords, serviceId, from, to, __PRETTY_FUNCTION__);
return fetch<Events>(sql::si::eventSearch, from, to, serviceId, serviceId, keywords, keywords, keywords, keywords);
}
@@ -144,14 +148,14 @@ SII::EventSearch(const IceUtil::Optional<std::string> & keywords, const IceUtil:
Events
SII::EventsInSchedules(const Ice::Current &)
{
- logger->message(LOG::DEBUG, __PRETTY_FUNCTION__);
+ logger->message(LogLevel::DEBUG, __PRETTY_FUNCTION__);
return fetch<Events>(sql::si::eventsInSchedules);
}
Events
SII::EventsInSchedule(int scheduleId, const Ice::Current &)
{
- logger->messagebf(LOG::DEBUG, "%s(%d)", scheduleId, __PRETTY_FUNCTION__);
+ logger->messagebf(LogLevel::DEBUG, "%s(%d)", scheduleId, __PRETTY_FUNCTION__);
return fetch<Events>(sql::si::eventsInSchedule, scheduleId);
}
}
diff --git a/p2pvr/daemon/si.h b/p2pvr/daemon/si.h
index 820118d..e184779 100644
--- a/p2pvr/daemon/si.h
+++ b/p2pvr/daemon/si.h
@@ -8,24 +8,24 @@
namespace P2PVR {
class SII : public SI, public IceTray::AbstractDatabaseClient {
public:
- SII(IceTray::DatabasePoolPtr);
-
- DVBSI::Networks GetNetworks(const Ice::Current &);
- Deliveries GetAllDeliveries(const Ice::Current &);
- DVBSI::DeliveryPtr GetDeliveryForService(int id, const Ice::Current &);
- DVBSI::DeliveryPtr GetDeliveryForTransport(int id, const Ice::Current &);
- DVBSI::DeliveryPtr GetDeliveryForSi(const Ice::Current &);
-
- DVBSI::ServiceList GetServices(const Ice::Current &);
- DVBSI::ServicePtr GetService(int id, const Ice::Current &);
-
- Events GetEvents(const IntSequence & eventUids, const Ice::Current &);
- EventPtr GetEvent(int serviceId, int eventId, const Ice::Current &);
- Events EventsOnNow(const Ice::Current &);
- Events EventsInSchedules(const Ice::Current &);
- Events EventsInSchedule(int scheduleId, const Ice::Current &);
- Events EventsInRange(const Common::DateTime &, const Common::DateTime &, const Ice::Current &);
- Events EventSearch(const IceUtil::Optional<std::string> & keywords, const IceUtil::Optional<Ice::Int> & serviceId, const IceUtil::Optional<Common::DateTime> & from, const IceUtil::Optional<Common::DateTime> & to, const Ice::Current &);
+ SII(DB::ConnectionPoolPtr);
+
+ DVBSI::Networks GetNetworks(const Ice::Current &) override;
+ Deliveries GetAllDeliveries(const Ice::Current &) override;
+ DVBSI::DeliveryPtr GetDeliveryForService(int id, const Ice::Current &) override;
+ DVBSI::DeliveryPtr GetDeliveryForTransport(int id, const Ice::Current &) override;
+ DVBSI::DeliveryPtr GetDeliveryForSi(const Ice::Current &) override;
+
+ DVBSI::ServiceList GetServices(const Ice::Current &) override;
+ DVBSI::ServicePtr GetService(int id, const Ice::Current &) override;
+
+ Events GetEvents(const IntSequence eventUids, const Ice::Current &) override;
+ EventPtr GetEvent(int serviceId, int eventId, const Ice::Current &) override;
+ Events EventsOnNow(const Ice::Current &) override;
+ Events EventsInSchedules(const Ice::Current &) override;
+ Events EventsInSchedule(int scheduleId, const Ice::Current &) override;
+ Events EventsInRange(const Chrono::DateTime, const Chrono::DateTime, const Ice::Current &) override;
+ Events EventSearch(const IceUtil::Optional<std::string> keywords, const IceUtil::Optional<Ice::Int> serviceId, const IceUtil::Optional<Chrono::DateTime> from, const IceUtil::Optional<Chrono::DateTime> to, const Ice::Current &) override;
static IceTray::Logging::LoggerPtr logger;
};
diff --git a/p2pvr/daemon/storage.cpp b/p2pvr/daemon/storage.cpp
index ba5d931..d53adf1 100644
--- a/p2pvr/daemon/storage.cpp
+++ b/p2pvr/daemon/storage.cpp
@@ -1,6 +1,7 @@
#include "storage.h"
#include "muxer.h"
#include <logger.h>
+#include <modifycommand.h>
#include <sql/storage/getVideoStats.sql.h>
#include <sql/storage/writeBlock.sql.h>
@@ -28,7 +29,7 @@ class RecordingSink : public RawDataClient {
ins->bindParamI(0, recordingId);
}
- bool NewData(const Data & data, const Ice::Current &) override
+ bool NewData(const Data data, const Ice::Current &) override
{
if (!data.empty()) {
ins->bindParamBLOB(1, data);
@@ -42,25 +43,25 @@ class RecordingSink : public RawDataClient {
DB::ModifyCommandPtr ins;
};
-StorageI::StorageI(IceTray::DatabasePoolPtr db) :
+StorageI::StorageI(DB::ConnectionPoolPtr db) :
IceTray::AbstractDatabaseClient(db)
{
}
-RawDataClientPrx
+RawDataClientPrxPtr
StorageI::OpenForWrite(Ice::Int recordingId, const Ice::Current & ice)
{
- auto target = RawDataClientPrx::uncheckedCast(ice.adapter->addWithUUID(new RecordingSink(db->get(), recordingId)));
+ auto target = Ice::uncheckedCast<RawDataClientPrx>(ice.adapter->addWithUUID(std::make_shared<RecordingSink>(db->get(), recordingId)));
if (!options->muxerCommand.empty()) {
auto storageId = target->ice_getIdentity();
- target = RawDataClientPrx::uncheckedCast(ice.adapter->addWithUUID(new Muxer(target, options->muxerCommand)));
+ target = Ice::uncheckedCast<RawDataClientPrx>(ice.adapter->addWithUUID(std::make_shared<Muxer>(target, options->muxerCommand)));
muxerStorageLink.insert({ target->ice_getIdentity(), storageId });
}
return target;
}
void
-StorageI::Close(const RawDataClientPrx & file, const Ice::Current & ice)
+StorageI::Close(const RawDataClientPrxPtr file, const Ice::Current & ice)
{
ice.adapter->remove(file->ice_getIdentity());
auto storageIdItr = muxerStorageLink.find(file->ice_getIdentity());
diff --git a/p2pvr/daemon/storage.h b/p2pvr/daemon/storage.h
index 3dae5d4..c9c984d 100644
--- a/p2pvr/daemon/storage.h
+++ b/p2pvr/daemon/storage.h
@@ -23,10 +23,10 @@ class StorageI : public Storage, IceTray::AbstractDatabaseClient {
std::string muxerCommand;
};
- StorageI(IceTray::DatabasePoolPtr db);
+ StorageI(DB::ConnectionPoolPtr db);
- RawDataClientPrx OpenForWrite(Ice::Int recordingId, const Ice::Current &) override;
- void Close(const RawDataClientPrx &, const Ice::Current &) override;
+ RawDataClientPrxPtr OpenForWrite(Ice::Int recordingId, const Ice::Current &) override;
+ void Close(const RawDataClientPrxPtr, const Ice::Current &) override;
VideoStats GetVideoStats(Ice::Int recordingId, const Ice::Current &) override;
protected:
diff --git a/p2pvr/daemon/unittests/Jamfile.jam b/p2pvr/daemon/unittests/Jamfile.jam
index 4426646..8c25c07 100644
--- a/p2pvr/daemon/unittests/Jamfile.jam
+++ b/p2pvr/daemon/unittests/Jamfile.jam
@@ -2,9 +2,8 @@ import testing ;
lib boost_system ;
lib boost_filesystem ;
-lib IceUtil ;
-lib Ice ;
-lib IceBox ;
+lib Ice : : <name>Ice++11 ;
+lib IceBox : : <name>IceBox++11 ;
lib dbppcore : : : : <include>/usr/include/dbpp ;
lib dbpp-postgresql : : : : <include>/usr/include/dbpp-postgresql ;
lib dryice : : : : <include>/usr/include/icetray ;
@@ -36,7 +35,6 @@ lib testCommon :
<library>dryice
<library>icetray
<library>Ice
- <library>IceUtil
<library>IceBox
<library>dbppcore
<library>dbpp-postgresql
@@ -56,7 +54,6 @@ lib testCommon :
<library>dbpp-postgresql
<library>Ice
<library>IceBox
- <library>IceUtil
<library>boost_system
<library>boost_filesystem
<library>../..//boost_utf
diff --git a/p2pvr/daemon/unittests/mockDefs.cpp b/p2pvr/daemon/unittests/mockDefs.cpp
index 6d180e5..adf2608 100644
--- a/p2pvr/daemon/unittests/mockDefs.cpp
+++ b/p2pvr/daemon/unittests/mockDefs.cpp
@@ -4,25 +4,28 @@
namespace P2PVR {
namespace Testing {
SchemaOnlyMockDatabase::SchemaOnlyMockDatabase(const Ice::StringSeq & opts) :
- PQ::Mock("user=postgres dbname=postgres", "p2pvr", {
- rootDir.parent_path().parent_path() / "datasources" / "schema.sql" }),
+ DB::PluginMock<PQ::Mock>("p2pvr", {
+ rootDir.parent_path().parent_path() / "datasources" / "schema.sql" },
+ "user=postgres dbname=postgres"),
IceTray::DryIce(opts)
{
}
StandardMockDatabase::StandardMockDatabase(const Ice::StringSeq & opts) :
- PQ::Mock("user=postgres dbname=postgres", "p2pvr", {
+ DB::PluginMock<PQ::Mock>("p2pvr", {
rootDir.parent_path().parent_path() / "datasources/schema.sql",
- rootDir / "datasources" / "data.sql" }),
+ rootDir / "datasources" / "data.sql" },
+ "user=postgres dbname=postgres"),
IceTray::DryIce(opts)
{
}
StandardMockDatabasePlusOffset::StandardMockDatabasePlusOffset(const Ice::StringSeq & opts) :
- PQ::Mock("user=postgres dbname=postgres", "p2pvr", {
+ DB::PluginMock<PQ::Mock>("p2pvr", {
rootDir.parent_path().parent_path() / "datasources" / "schema.sql",
rootDir / "datasources" / "data.sql",
- rootDir / "datasources" / "eventOffset.sql" }),
+ rootDir / "datasources" / "eventOffset.sql" },
+ "user=postgres dbname=postgres"),
IceTray::DryIce(opts)
{
}
diff --git a/p2pvr/daemon/unittests/mockDefs.h b/p2pvr/daemon/unittests/mockDefs.h
index 1589440..c226a42 100644
--- a/p2pvr/daemon/unittests/mockDefs.h
+++ b/p2pvr/daemon/unittests/mockDefs.h
@@ -8,7 +8,7 @@
namespace P2PVR {
namespace Testing {
-#define DECLAREMOCK(Name) class DLL_PUBLIC Name : public PQ::Mock, public IceTray::DryIce { public: Name(const Ice::StringSeq & opts = {}); }
+#define DECLAREMOCK(Name) class DLL_PUBLIC Name : public DB::PluginMock<PQ::Mock>, public IceTray::DryIce { public: Name(const Ice::StringSeq & opts = {}); }
DECLAREMOCK(SchemaOnlyMockDatabase);
DECLAREMOCK(StandardMockDatabase);
@@ -20,13 +20,13 @@ class DLL_PUBLIC TestClient : public IceTray::DryIceClient {
public:
TestClient();
- TunersPrx devices;
- MaintenancePrx maint;
- SIPrx si;
- SchedulesPrx schedules;
- StoragePrx storage;
- RecorderPrx recorder;
- RecordingsPrx recordings;
+ TunersPrxPtr devices;
+ MaintenancePrxPtr maint;
+ SIPrxPtr si;
+ SchedulesPrxPtr schedules;
+ StoragePrxPtr storage;
+ RecorderPrxPtr recorder;
+ RecordingsPrxPtr recordings;
};
}
}
diff --git a/p2pvr/daemon/unittests/mockDevices.cpp b/p2pvr/daemon/unittests/mockDevices.cpp
index e5ec6a4..135664f 100644
--- a/p2pvr/daemon/unittests/mockDevices.cpp
+++ b/p2pvr/daemon/unittests/mockDevices.cpp
@@ -13,7 +13,7 @@ namespace P2PVR {
TunerPtr
MockDevices::openTuner(const boost::filesystem::path & path) const
{
- return new P2PVR::DVB::Testing::MockTuner(path, ic);
+ return std::make_shared<P2PVR::DVB::Testing::MockTuner>(path, ic);
}
}
}
diff --git a/p2pvr/daemon/unittests/mockScheduler.cpp b/p2pvr/daemon/unittests/mockScheduler.cpp
index b19673c..3f5ee99 100644
--- a/p2pvr/daemon/unittests/mockScheduler.cpp
+++ b/p2pvr/daemon/unittests/mockScheduler.cpp
@@ -31,13 +31,13 @@ MockScheduler::GetScheduledToRecord(const::Ice::Current &)
}
Ice::Int
-MockScheduler::NewSchedule(const::P2PVR::SchedulePtr &, const::Ice::Current &)
+MockScheduler::NewSchedule(const::P2PVR::SchedulePtr, const::Ice::Current &)
{
return 1;
}
void
-MockScheduler::UpdateSchedule(const::P2PVR::SchedulePtr &, const::Ice::Current &)
+MockScheduler::UpdateSchedule(const::P2PVR::SchedulePtr, const::Ice::Current &)
{
}
}
diff --git a/p2pvr/daemon/unittests/mockScheduler.h b/p2pvr/daemon/unittests/mockScheduler.h
index f718363..d94f502 100644
--- a/p2pvr/daemon/unittests/mockScheduler.h
+++ b/p2pvr/daemon/unittests/mockScheduler.h
@@ -13,8 +13,8 @@ class DLL_PUBLIC MockScheduler : public Schedules {
SchedulePtr GetSchedule(::Ice::Int, const ::Ice::Current&) override;
ScheduleList GetSchedules(const ::Ice::Current&) override;
ScheduledToRecordList GetScheduledToRecord(const ::Ice::Current&) override;
- Ice::Int NewSchedule(const SchedulePtr&, const ::Ice::Current&) override;
- void UpdateSchedule(const SchedulePtr&, const ::Ice::Current&) override;
+ Ice::Int NewSchedule(const SchedulePtr, const ::Ice::Current&) override;
+ void UpdateSchedule(const SchedulePtr, const ::Ice::Current&) override;
};
}
}
diff --git a/p2pvr/daemon/unittests/testErrorHandling.cpp b/p2pvr/daemon/unittests/testErrorHandling.cpp
index be44ebc..e38ac8e 100644
--- a/p2pvr/daemon/unittests/testErrorHandling.cpp
+++ b/p2pvr/daemon/unittests/testErrorHandling.cpp
@@ -26,7 +26,7 @@ class Core : public StandardMockDatabase {
public:
Core()
{
- replace("Devices", new MockDevices(ic));
+ replace("Devices", std::make_shared<MockDevices>(ic));
}
};
@@ -36,7 +36,7 @@ class TestDataClient : public RawDataClient {
packets(3)
{
}
- virtual bool NewData(const Data &, const Ice::Current &) override
+ virtual bool NewData(const Data, const Ice::Current &) override
{
return !--packets;
}
@@ -45,7 +45,7 @@ class TestDataClient : public RawDataClient {
class FailingTestClient : public RawDataClient {
public:
- bool NewData(const Data &, const Ice::Current &) override
+ bool NewData(const Data, const Ice::Current &) override
{
throw DataHandlingException();
}
@@ -85,7 +85,7 @@ BOOST_AUTO_TEST_CASE(TestRawDataClient)
{
BOOST_TEST_CHECKPOINT("Setup");
auto del = si->GetDeliveryForSi();
- TemporaryIceAdapterObject<RawDataClient> a(getAdapter(), new TestDataClient());
+ TemporaryIceAdapterObject<RawDataClient> a(getAdapter(), std::make_shared<TestDataClient>());
BOOST_TEST_CHECKPOINT("Make successful call");
devices->SendNetworkInformation(del, a);
}
@@ -94,7 +94,7 @@ BOOST_AUTO_TEST_CASE(TestParser)
{
BOOST_TEST_CHECKPOINT("Setup");
auto del = si->GetDeliveryForSi();
- TemporaryIceAdapterObject<RawDataClient> a(getAdapter(), new TestNetworkParser());
+ TemporaryIceAdapterObject<RawDataClient> a(getAdapter(), std::make_shared<TestNetworkParser>());
BOOST_TEST_CHECKPOINT("Make successful call");
devices->SendNetworkInformation(del, a);
}
@@ -103,7 +103,7 @@ BOOST_AUTO_TEST_CASE(TestRawDataClientWithError)
{
BOOST_TEST_CHECKPOINT("Setup");
auto del = si->GetDeliveryForSi();
- TemporaryIceAdapterObject<RawDataClient> a(getAdapter(), new FailingTestClient());
+ TemporaryIceAdapterObject<RawDataClient> a(getAdapter(), std::make_shared<FailingTestClient>());
BOOST_TEST_CHECKPOINT("Make failing call");
BOOST_REQUIRE_THROW(devices->SendNetworkInformation(del, a), DataHandlingException);
}
@@ -112,7 +112,7 @@ BOOST_AUTO_TEST_CASE(TestParserWithError)
{
BOOST_TEST_CHECKPOINT("Setup");
auto del = si->GetDeliveryForSi();
- TemporaryIceAdapterObject<RawDataClient> a(getAdapter(), new FailingTestNetworkParser());
+ TemporaryIceAdapterObject<RawDataClient> a(getAdapter(), std::make_shared<FailingTestNetworkParser>());
BOOST_TEST_CHECKPOINT("Make failing call");
BOOST_REQUIRE_THROW(devices->SendNetworkInformation(del, a), DataHandlingException);
}
@@ -121,7 +121,7 @@ BOOST_AUTO_TEST_CASE(TestParserBroken)
{
BOOST_TEST_CHECKPOINT("Setup");
auto del = si->GetDeliveryForSi();
- TemporaryIceAdapterObject<RawDataClient> a(getAdapter(), new BrokenTestNetworkParser());
+ TemporaryIceAdapterObject<RawDataClient> a(getAdapter(), std::make_shared<BrokenTestNetworkParser>());
BOOST_TEST_CHECKPOINT("Make failing call");
BOOST_REQUIRE_THROW(devices->SendNetworkInformation(del, a), Ice::UnknownException);
}
diff --git a/p2pvr/daemon/unittests/testMaint.cpp b/p2pvr/daemon/unittests/testMaint.cpp
index c15dee3..feb5153 100644
--- a/p2pvr/daemon/unittests/testMaint.cpp
+++ b/p2pvr/daemon/unittests/testMaint.cpp
@@ -7,6 +7,7 @@
#include <Ice/Service.h>
#include <maintenance.h>
#include <mockTuner.h>
+#include <modifycommand.h>
#include "mockDevices.h"
#include "mockScheduler.h"
#include <si.h>
@@ -15,11 +16,13 @@
#include <definedDirs.h>
#include "mockDefs.h"
#include <slicer/db/sqlSelectDeserializer.h>
-#include "commonHelpers.h"
+#include "chronoHelpers.h"
+#include "icetraySupport.h"
#include <slicer/slicer.h>
using namespace P2PVR;
using namespace P2PVR::Testing;
+using namespace std::literals;
namespace P2PVR {
namespace Testing {
@@ -27,8 +30,8 @@ class TestService : public SchemaOnlyMockDatabase {
public:
TestService()
{
- replace("Devices", new MockDevices(ic));
- replace("Schedules", new MockScheduler());
+ replace("Devices", std::make_shared<MockDevices>(ic));
+ replace("Schedules", std::make_shared<MockScheduler>());
}
};
}
@@ -101,7 +104,8 @@ BOOST_AUTO_TEST_CASE( GetNetworks )
auto ns = si->GetNetworks();
BOOST_REQUIRE_EQUAL(ns.size(), 1);
BOOST_REQUIRE_EQUAL(ns[0]->NetworkId, 12333);
- BOOST_REQUIRE_EQUAL(ns[0]->Name, "Yorkshire");
+ BOOST_REQUIRE(ns[0]->Name);
+ BOOST_REQUIRE_EQUAL(*ns[0]->Name, "Yorkshire");
}
BOOST_AUTO_TEST_CASE( GetDeliveryForService )
@@ -167,8 +171,10 @@ BOOST_AUTO_TEST_CASE( GetServices )
BOOST_REQUIRE_EQUAL(services.size(), 180);
BOOST_REQUIRE_EQUAL(services[0]->ServiceId, 4170);
BOOST_REQUIRE_EQUAL(services[0]->TransportStreamId, 4170);
- BOOST_REQUIRE_EQUAL(services[0]->Name, "BBC ONE Yorks");
- BOOST_REQUIRE_EQUAL(services[0]->DefaultAuthority, "fp.bbc.co.uk");
+ BOOST_REQUIRE(services[0]->Name);
+ BOOST_REQUIRE_EQUAL(*services[0]->Name, "BBC ONE Yorks");
+ BOOST_REQUIRE(services[0]->DefaultAuthority);
+ BOOST_REQUIRE_EQUAL(*services[0]->DefaultAuthority, "fp.bbc.co.uk");
}
BOOST_AUTO_TEST_CASE( GetService )
@@ -176,8 +182,10 @@ BOOST_AUTO_TEST_CASE( GetService )
auto service = si->GetService(serviceId);
BOOST_REQUIRE_EQUAL(service->ServiceId, serviceId);
BOOST_REQUIRE_EQUAL(service->TransportStreamId, 4170);
- BOOST_REQUIRE_EQUAL(service->Name, "BBC ONE Yorks");
- BOOST_REQUIRE_EQUAL(service->DefaultAuthority, "fp.bbc.co.uk");
+ BOOST_REQUIRE(service->Name);
+ BOOST_REQUIRE_EQUAL(*service->Name, "BBC ONE Yorks");
+ BOOST_REQUIRE(service->DefaultAuthority);
+ BOOST_REQUIRE_EQUAL(*service->DefaultAuthority, "fp.bbc.co.uk");
}
BOOST_AUTO_TEST_CASE( update_events )
@@ -188,8 +196,8 @@ BOOST_AUTO_TEST_CASE( update_events )
BOOST_TEST_CHECKPOINT("Write first events");
P2PVR::DVB::Testing::MockTuner::SetEventsSet(0);
maint->UpdateEvents();
- auto dayOneEvents = si->EventSearch(IceUtil::Optional<std::string>(), IceUtil::Optional<int>(),
- Common::DateTime {2017, 8, 22, 3, 0}, Common::DateTime {2017, 8, 23, 3, 0});
+ auto dayOneEvents = si->EventSearch(Ice::optional<std::string>(), Ice::optional<int>(),
+ Chrono::DateTime {2017, 8, 22, 3, 0}, Chrono::DateTime {2017, 8, 23, 3, 0});
BOOST_REQUIRE_EQUAL(dayOneEvents.size(), 3023);
BOOST_REQUIRE(si->GetEvent(15048, 29747));
BOOST_REQUIRE_THROW(si->GetEvent(15856, 3591), P2PVR::NotFound);
@@ -198,34 +206,32 @@ BOOST_AUTO_TEST_CASE( update_events )
auto keyEvent1 = dayOneEvents[1000];
auto keyEvent2 = dayOneEvents[2000];
db->execute("INSERT INTO schedules(repeats) VALUES(false)");
- auto irecorded = boost::shared_ptr<DB::ModifyCommand>(
- db->newModifyCommand("INSERT INTO recorded(scheduleId, eventUid) VALUES(?, ?)"));
+ auto irecorded = db->modify("INSERT INTO recorded(scheduleId, eventUid) VALUES(?, ?)");
irecorded->bindParamI(0, 1);
irecorded->bindParamI(1, keyEvent1->EventUid);
irecorded->execute();
- auto irecordings = boost::shared_ptr<DB::ModifyCommand>(
- db->newModifyCommand("INSERT INTO recordings(scheduleId, eventUid) VALUES(?, ?)"));
+ auto irecordings = db->modify("INSERT INTO recordings(scheduleId, eventUid) VALUES(?, ?)");
irecordings->bindParamI(0, 1);
irecordings->bindParamI(1, keyEvent2->EventUid);
irecordings->execute();
BOOST_REQUIRE(keyEvent1);
BOOST_REQUIRE(keyEvent2);
BOOST_REQUIRE(keyEvent1->Current);
- BOOST_REQUIRE_EQUAL(keyEvent1->StartTime, Common::DateTime({2017, 8, 22, 5, 0}));
+ BOOST_REQUIRE_EQUAL(keyEvent1->StartTime, Chrono::DateTime({2017, 8, 22, 5, 0}));
BOOST_REQUIRE(keyEvent2->Current);
- BOOST_REQUIRE_EQUAL(keyEvent2->StartTime, Common::DateTime({2017, 8, 22, 6, 30}));
+ BOOST_REQUIRE_EQUAL(keyEvent2->StartTime, Chrono::DateTime({2017, 8, 22, 6, 30}));
BOOST_TEST_CHECKPOINT("Write second events");
P2PVR::DVB::Testing::MockTuner::SetEventsSet(1);
maint->UpdateEvents();
- auto dayTwoEvents = si->EventSearch(IceUtil::Optional<std::string>(), IceUtil::Optional<int>(),
- Common::DateTime {2017, 8, 23, 3, 0}, Common::DateTime {2017, 8, 24, 3, 0});
+ auto dayTwoEvents = si->EventSearch(Ice::optional<std::string>(), Ice::optional<int>(),
+ Chrono::DateTime {2017, 8, 23, 3, 0}, Chrono::DateTime {2017, 8, 24, 3, 0});
BOOST_REQUIRE_THROW(si->GetEvent(15064, 22), P2PVR::NotFound);
BOOST_REQUIRE(si->GetEvent(15048, 29791));
BOOST_TEST_CHECKPOINT("Check our faked stuff is still there and right");
- auto dayOneEventsOnDayTwo = si->EventSearch(IceUtil::Optional<std::string>(), IceUtil::Optional<int>(),
- Common::DateTime {2017, 8, 22, 3, 0}, Common::DateTime {2017, 8, 23, 3, 0});
+ auto dayOneEventsOnDayTwo = si->EventSearch(Ice::optional<std::string>(), Ice::optional<int>(),
+ Chrono::DateTime {2017, 8, 22, 3, 0}, Chrono::DateTime {2017, 8, 23, 3, 0});
// Some datetime range overlap, but most are gone
BOOST_REQUIRE_EQUAL(dayOneEventsOnDayTwo.size(), 316);
BOOST_REQUIRE_EQUAL(std::count_if(dayOneEventsOnDayTwo.begin(), dayOneEventsOnDayTwo.end(),
@@ -243,8 +249,8 @@ BOOST_AUTO_TEST_CASE( update_events )
BOOST_AUTO_TEST_CASE( test_titleFiltering )
{
- auto thingsWithNew = si->EventSearch("new", IceUtil::Optional<int>(),
- IceUtil::Optional<Common::DateTime>(), IceUtil::Optional<Common::DateTime>());
+ auto thingsWithNew = si->EventSearch("new"s, Ice::optional<int>(),
+ Ice::optional<Chrono::DateTime>(), Ice::optional<Chrono::DateTime>());
BOOST_REQUIRE_EQUAL(0, std::count_if(thingsWithNew.begin(), thingsWithNew.end(), [](auto e) {
return boost::algorithm::starts_with(e->Title, "New:");
}));
diff --git a/p2pvr/daemon/unittests/testRecording.cpp b/p2pvr/daemon/unittests/testRecording.cpp
index d875130..533859a 100644
--- a/p2pvr/daemon/unittests/testRecording.cpp
+++ b/p2pvr/daemon/unittests/testRecording.cpp
@@ -14,7 +14,7 @@
#include <definedDirs.h>
#include "mockDefs.h"
#include <slicer/db/sqlSelectDeserializer.h>
-#include "commonHelpers.h"
+#include "chronoHelpers.h"
#include "serviceStreamer.h"
#include "temporaryIceAdapterObject.h"
#include <slicer/slicer.h>
@@ -28,8 +28,8 @@ class TestService : public StandardMockDatabase {
public:
TestService()
{
- replace("Devices", new MockDevices(ic));
- replace("Schedules", new MockScheduler());
+ replace("Devices", std::make_shared<MockDevices>(ic));
+ replace("Schedules", std::make_shared<MockScheduler>());
}
};
@@ -37,7 +37,7 @@ class MockTarget : public RawDataClient {
public:
MockTarget() : bytesReceived(0) { }
- bool NewData(const Data & data, const Ice::Current &) override
+ bool NewData(const Data data, const Ice::Current &) override
{
bytesReceived += data.size();
return false;
@@ -55,11 +55,11 @@ BOOST_FIXTURE_TEST_SUITE( RecordingCore, TestClient );
BOOST_AUTO_TEST_CASE( streamServiceToTarget )
{
BOOST_TEST_CHECKPOINT("Create mock target");
- IceUtil::Handle<MockTarget> target = new MockTarget();
+ auto target = std::make_shared<MockTarget>();
TemporaryIceAdapterObject<RawDataClient> targetPrx(getAdapter(), target);
BOOST_TEST_CHECKPOINT("Create service streamer");
- auto ss = ServiceStreamerPtr(new ServiceStreamer(4170, targetPrx, devices, si, getAdapter()));
+ auto ss = std::make_shared<ServiceStreamer>(4170, targetPrx, devices, si, getAdapter());
BOOST_TEST_CHECKPOINT("Start");
ss->Start();
diff --git a/p2pvr/daemon/unittests/testSched.cpp b/p2pvr/daemon/unittests/testSched.cpp
index 18e375c..8450a4c 100644
--- a/p2pvr/daemon/unittests/testSched.cpp
+++ b/p2pvr/daemon/unittests/testSched.cpp
@@ -14,11 +14,12 @@
#include <boost/uuid/uuid_generators.hpp>
#include <boost/uuid/uuid_io.hpp>
#include <boost/lexical_cast.hpp>
-#include <commonHelpers.h>
+#include <chronoHelpers.h>
#include "mockDefs.h"
using namespace P2PVR;
using namespace P2PVR::Testing;
+using namespace std::literals;
namespace P2PVR {
namespace Testing {
@@ -26,8 +27,8 @@ class TestService : public StandardMockDatabasePlusOffset {
public:
TestService()
{
- replace("Devices", new MockDevices(ic));
- replace("Recorder", new MockRecorder());
+ replace("Devices", std::make_shared<MockDevices>(ic));
+ replace("Recorder", std::make_shared<MockRecorder>());
}
};
}
@@ -60,8 +61,8 @@ BOOST_AUTO_TEST_CASE( sc_getScheduled )
BOOST_AUTO_TEST_CASE( sc_crud )
{
- P2PVR::SchedulePtr schedule = new P2PVR::Schedule();
- schedule->Search = "Top Gear";
+ auto schedule = std::make_shared<P2PVR::Schedule>();
+ schedule->Search = "Top Gear"s;
schedule->ScheduleId = schedules->NewSchedule(schedule);
BOOST_REQUIRE_EQUAL(187, schedule->ScheduleId);
@@ -74,7 +75,7 @@ BOOST_AUTO_TEST_CASE( sc_crud )
BOOST_REQUIRE_EQUAL(schedule->Early, fetched->Early);
BOOST_REQUIRE_EQUAL(schedule->Late, fetched->Late);
- schedule->Search = "Top Gear Special";
+ schedule->Search = "Top Gear Special"s;
schedule->Early.Minutes = 5;
schedule->Late.Minutes = 15;
schedules->UpdateSchedule(schedule);
diff --git a/p2pvr/daemon/unittests/testSi.cpp b/p2pvr/daemon/unittests/testSi.cpp
index 73f92f3..a894155 100644
--- a/p2pvr/daemon/unittests/testSi.cpp
+++ b/p2pvr/daemon/unittests/testSi.cpp
@@ -13,9 +13,11 @@
#include <boost/uuid/uuid_io.hpp>
#include <boost/lexical_cast.hpp>
#include "mockDefs.h"
+#include "icetraySupport.h"
using namespace P2PVR;
using namespace P2PVR::Testing;
+using namespace std::literals;
BOOST_GLOBAL_FIXTURE( StandardMockDatabase );
@@ -68,19 +70,19 @@ BOOST_AUTO_TEST_CASE( si_getEventsInScheds )
BOOST_AUTO_TEST_CASE( si_getEventsInRange )
{
- si->EventsInRange(Common::DateTime {2014, 12, 19, 3, 0}, Common::DateTime {2014, 12, 20, 3, 0});
+ si->EventsInRange(Chrono::DateTime {2014, 12, 19, 3, 0}, Chrono::DateTime {2014, 12, 20, 3, 0});
}
BOOST_AUTO_TEST_CASE( si_getEventSearch )
{
- si->EventSearch("Top Gear", IceUtil::Optional< ::Ice::Int >(),
- IceUtil::Optional<Common::DateTime>(), IceUtil::Optional<Common::DateTime>());
- si->EventSearch("Top Gear", 22272,
- IceUtil::Optional<Common::DateTime>(), IceUtil::Optional<Common::DateTime>());
- si->EventSearch("Top Gear", 22272,
- Common::DateTime {2014, 12, 19, 3, 0}, IceUtil::Optional<Common::DateTime>());
- si->EventSearch("Top Gear", 22272,
- Common::DateTime {2014, 12, 19, 3, 0}, Common::DateTime {2014, 12, 20, 3, 0});
+ si->EventSearch("Top Gear"s, Ice::optional< ::Ice::Int >(),
+ Ice::optional<Chrono::DateTime>(), Ice::optional<Chrono::DateTime>());
+ si->EventSearch("Top Gear"s, 22272,
+ Ice::optional<Chrono::DateTime>(), Ice::optional<Chrono::DateTime>());
+ si->EventSearch("Top Gear"s, 22272,
+ Chrono::DateTime {2014, 12, 19, 3, 0}, Ice::optional<Chrono::DateTime>());
+ si->EventSearch("Top Gear"s, 22272,
+ Chrono::DateTime {2014, 12, 19, 3, 0}, Chrono::DateTime {2014, 12, 20, 3, 0});
}
BOOST_AUTO_TEST_CASE( si_getAllDeliveries )
@@ -93,7 +95,7 @@ BOOST_AUTO_TEST_CASE( si_getDeliveryForTransport )
{
auto del = si->GetDeliveryForTransport(4170);
BOOST_REQUIRE(del);
- auto dvbt = DVBSI::TerrestrialDeliveryPtr::dynamicCast(del);
+ auto dvbt = std::dynamic_pointer_cast<DVBSI::TerrestrialDelivery>(del);
BOOST_REQUIRE(dvbt);
BOOST_REQUIRE_EQUAL(dvbt->TransportStreamId, 4170);
}
@@ -102,7 +104,7 @@ BOOST_AUTO_TEST_CASE( si_getDeliveryForSI )
{
auto del = si->GetDeliveryForSi();
BOOST_REQUIRE(del);
- auto dvbt = DVBSI::TerrestrialDeliveryPtr::dynamicCast(del);
+ auto dvbt = std::dynamic_pointer_cast<DVBSI::TerrestrialDelivery>(del);
BOOST_REQUIRE(dvbt);
}
@@ -110,7 +112,7 @@ BOOST_AUTO_TEST_CASE( si_getDeliveryForService )
{
auto del = si->GetDeliveryForService(4170);
BOOST_REQUIRE(del);
- auto dvbt = DVBSI::TerrestrialDeliveryPtr::dynamicCast(del);
+ auto dvbt = std::dynamic_pointer_cast<DVBSI::TerrestrialDelivery>(del);
BOOST_REQUIRE(dvbt);
BOOST_REQUIRE_EQUAL(dvbt->TransportStreamId, 4170);
}
@@ -119,8 +121,10 @@ BOOST_AUTO_TEST_CASE( si_getServices )
{
auto services = si->GetServices();
BOOST_REQUIRE_EQUAL(services.size(), 145);
- BOOST_REQUIRE_EQUAL(services[0]->Name, "BBC ONE Yorks");
- BOOST_REQUIRE_EQUAL(services[0]->DefaultAuthority, "fp.bbc.co.uk");
+ BOOST_REQUIRE(services[0]->Name);
+ BOOST_REQUIRE_EQUAL(*services[0]->Name, "BBC ONE Yorks");
+ BOOST_REQUIRE(services[0]->DefaultAuthority);
+ BOOST_REQUIRE_EQUAL(*services[0]->DefaultAuthority, "fp.bbc.co.uk");
BOOST_REQUIRE_EQUAL(services[0]->EitSchedule, true);
BOOST_REQUIRE_EQUAL(services[0]->EitPresentFollowing, true);
}
@@ -128,8 +132,10 @@ BOOST_AUTO_TEST_CASE( si_getServices )
BOOST_AUTO_TEST_CASE( si_getService )
{
auto service = si->GetService(4170);
- BOOST_REQUIRE_EQUAL(service->Name, "BBC ONE Yorks");
- BOOST_REQUIRE_EQUAL(service->DefaultAuthority, "fp.bbc.co.uk");
+ BOOST_REQUIRE(service->Name);
+ BOOST_REQUIRE_EQUAL(*service->Name, "BBC ONE Yorks");
+ BOOST_REQUIRE(service->DefaultAuthority);
+ BOOST_REQUIRE_EQUAL(*service->DefaultAuthority, "fp.bbc.co.uk");
BOOST_REQUIRE_EQUAL(service->EitSchedule, true);
BOOST_REQUIRE_EQUAL(service->EitPresentFollowing, true);
}
diff --git a/p2pvr/daemon/unittests/testStorage.cpp b/p2pvr/daemon/unittests/testStorage.cpp
index e7eee95..f186f4f 100644
--- a/p2pvr/daemon/unittests/testStorage.cpp
+++ b/p2pvr/daemon/unittests/testStorage.cpp
@@ -9,7 +9,7 @@
#include <si.h>
#include <storage.h>
#include <boost/lexical_cast.hpp>
-#include <commonHelpers.h>
+#include <chronoHelpers.h>
#include <definedDirs.h>
#include "mockDefs.h"
@@ -37,9 +37,9 @@ BOOST_FIXTURE_TEST_SUITE( StCore, TestClient );
static
void
-runTest(RecordingsPrx recordings, StoragePrx storage)
+runTest(RecordingsPrxPtr recordings, StoragePrxPtr storage)
{
- auto id = recordings->NewRecording(new Recording(0, 8, 2556));
+ auto id = recordings->NewRecording(std::make_shared<Recording>(0, 8, 2556));
auto rdc = storage->OpenForWrite(id);
BOOST_REQUIRE(rdc);
auto stats1 = storage->GetVideoStats(id);
diff --git a/p2pvr/devices/devices.cpp b/p2pvr/devices/devices.cpp
index a9fb214..4e7bb09 100644
--- a/p2pvr/devices/devices.cpp
+++ b/p2pvr/devices/devices.cpp
@@ -4,6 +4,8 @@
#include "bindTimerTask.h"
#include <lockHelpers.h>
+using namespace IceTray::Logging;
+
namespace P2PVR {
template<typename T>
T *
@@ -36,12 +38,12 @@ IceTray::Logging::LoggerPtr DevicesI::logger(LOGMANAGER()->getLogger<DevicesI>()
DevicesI::DevicesI()
{
devices = options->devices;
- logger->message(LOG::DEBUG, __PRETTY_FUNCTION__);
+ logger->message(LogLevel::DEBUG, __PRETTY_FUNCTION__);
}
DevicesI::~DevicesI()
{
- logger->message(LOG::DEBUG, __PRETTY_FUNCTION__);
+ logger->message(LogLevel::DEBUG, __PRETTY_FUNCTION__);
}
TunerPtr
@@ -57,7 +59,7 @@ DevicesI::getTuner()
return tuner;
}
catch (const std::exception & ex) {
- logger->messagebf(LOG::DEBUG, "%s: Failed to open device %s (%s)", __PRETTY_FUNCTION__,
+ logger->messagebf(LogLevel::DEBUG, "%s: Failed to open device %s (%s)", __PRETTY_FUNCTION__,
*devItr, ex.what());
}
}
@@ -67,7 +69,7 @@ DevicesI::getTuner()
TunerPtr
DevicesI::getTuner(const DVBSI::DeliveryPtr & delivery)
{
- logger->messagebf(LOG::DEBUG, "%s: Searching for an open sharable tuner (frequency %d)", __PRETTY_FUNCTION__, delivery->Frequency);
+ logger->messagebf(LogLevel::DEBUG, "%s: Searching for an open sharable tuner (frequency %d)", __PRETTY_FUNCTION__, delivery->Frequency);
Lock(lock);
// Check for an already open tuner which is correctly tuned.
auto existingItr = openDevices.find(delivery->TransportStreamId);
@@ -88,11 +90,11 @@ DevicesI::getTuner(const DVBSI::DeliveryPtr & delivery)
return tuner;
}
catch (const std::exception & ex) {
- logger->messagebf(LOG::DEBUG, "%s: Failed to open and tune device %s (%s) to frequency %d", __PRETTY_FUNCTION__,
+ logger->messagebf(LogLevel::DEBUG, "%s: Failed to open and tune device %s (%s) to frequency %d", __PRETTY_FUNCTION__,
*devItr, ex.what(), delivery->Frequency);
}
}
- logger->messagebf(LOG::DEBUG, "%s: Failed to open and tune any device to frequency %d", __PRETTY_FUNCTION__,
+ logger->messagebf(LogLevel::DEBUG, "%s: Failed to open and tune any device to frequency %d", __PRETTY_FUNCTION__,
delivery->Frequency);
throw NoSuitableDeviceAvailable();
}
@@ -114,14 +116,14 @@ DevicesI::getTuner(const DeliveryProvider & provider)
TunerPtr
DevicesI::openTuner(const boost::filesystem::path & path) const
{
- return new DVB::TunerI(path);
+ return std::make_shared<DVB::TunerI>(path);
}
void
DevicesI::releaseTuner(const TunerPtr & tuner)
{
Lock(lock);
- logger->messagebf(LOG::DEBUG, "%s", __PRETTY_FUNCTION__);
+ logger->messagebf(LogLevel::DEBUG, "%s", __PRETTY_FUNCTION__);
auto openTuner = std::find_if(openDevices.begin(), openDevices.end(), [&tuner](const auto & ot) {
return ot.second->tuner == tuner;
});
@@ -138,20 +140,20 @@ DevicesI::releaseTuner(const TunerPtr & tuner)
}
void
-DevicesI::Scan(const std::string &, const Ice::Current &)
+DevicesI::Scan(const std::string, const Ice::Current &)
{
Lock(lock);
}
void
-DevicesI::Add(const std::string & frontend, const Ice::Current &)
+DevicesI::Add(const std::string frontend, const Ice::Current &)
{
Lock(lock);
devices.push_back(frontend);
}
void
-DevicesI::Remove(const std::string & frontend, const Ice::Current &)
+DevicesI::Remove(const std::string frontend, const Ice::Current &)
{
Lock(lock);
devices.erase(std::remove(devices.begin(), devices.end(), frontend), devices.end());
@@ -185,49 +187,49 @@ DevicesI::finiteTunerOperation(TunerPtr && tuner, const Target & target)
}
void
-DevicesI::ScanAndSendNetworkInformation(const RawDataClientPrx & target, const ::Ice::Current&)
+DevicesI::ScanAndSendNetworkInformation(const RawDataClientPrxPtr target, const ::Ice::Current&)
{
finiteTunerOperation(getTuner(), boost::bind(&Tuner::ScanAndSendNetworkInformation, _1, target));
}
void
-DevicesI::SendNetworkInformation(const ::DVBSI::DeliveryPtr & del, const RawDataClientPrx & target, const ::Ice::Current&)
+DevicesI::SendNetworkInformation(const ::DVBSI::DeliveryPtr del, const RawDataClientPrxPtr target, const ::Ice::Current&)
{
finiteTunerOperation(getTuner(del), boost::bind(&Tuner::SendNetworkInformation, _1, target));
}
void
-DevicesI::SendBouquetAssociations(const ::DVBSI::DeliveryPtr & del, const RawDataClientPrx & target, const ::Ice::Current &)
+DevicesI::SendBouquetAssociations(const ::DVBSI::DeliveryPtr del, const RawDataClientPrxPtr target, const ::Ice::Current &)
{
finiteTunerOperation(getTuner(del), boost::bind(&Tuner::SendBouquetAssociations, _1, target));
}
void
-DevicesI::SendServiceDescriptions(const ::DVBSI::DeliveryPtr & del, const RawDataClientPrx & target, const ::Ice::Current&)
+DevicesI::SendServiceDescriptions(const ::DVBSI::DeliveryPtr del, const RawDataClientPrxPtr target, const ::Ice::Current&)
{
finiteTunerOperation(getTuner(del), boost::bind(&Tuner::SendServiceDescriptions, _1, target));
}
void
-DevicesI::SendProgramAssociationTable(const ::DVBSI::DeliveryPtr & del, const RawDataClientPrx & target, const ::Ice::Current&)
+DevicesI::SendProgramAssociationTable(const ::DVBSI::DeliveryPtr del, const RawDataClientPrxPtr target, const ::Ice::Current&)
{
finiteTunerOperation(getTuner(del), boost::bind(&Tuner::SendProgramAssociationTable, _1, target));
}
void
-DevicesI::SendProgramMap(const ::DVBSI::DeliveryPtr & del, ::Ice::Int pids, const RawDataClientPrx & target, const ::Ice::Current&)
+DevicesI::SendProgramMap(const ::DVBSI::DeliveryPtr del, ::Ice::Int pids, const RawDataClientPrxPtr target, const ::Ice::Current&)
{
finiteTunerOperation(getTuner(del), boost::bind(&Tuner::SendProgramMap, _1, pids, target));
}
void
-DevicesI::SendEventInformation(const ::DVBSI::DeliveryPtr & del, const RawDataClientPrx & target, const ::Ice::Current&)
+DevicesI::SendEventInformation(const ::DVBSI::DeliveryPtr del, const RawDataClientPrxPtr target, const ::Ice::Current&)
{
finiteTunerOperation(getTuner(del), boost::bind(&Tuner::SendEventInformation, _1, target));
}
::Ice::Int
-DevicesI::StartSendingTS(const ::DVBSI::DeliveryPtr & del, const PacketIds & pids, const RawDataClientPrx & target, const ::Ice::Current&)
+DevicesI::StartSendingTS(const ::DVBSI::DeliveryPtr del, const PacketIds pids, const RawDataClientPrxPtr target, const ::Ice::Current&)
{
auto tuner = getTuner(del);
try {
@@ -240,7 +242,7 @@ DevicesI::StartSendingTS(const ::DVBSI::DeliveryPtr & del, const PacketIds & pid
}
::Ice::Int
-DevicesI::StartSendingSection(const ::DVBSI::DeliveryPtr & del, ::Ice::Int sid, const RawDataClientPrx & target, const ::Ice::Current&)
+DevicesI::StartSendingSection(const ::DVBSI::DeliveryPtr del, ::Ice::Int sid, const RawDataClientPrxPtr target, const ::Ice::Current&)
{
auto tuner = getTuner(del);
try {
diff --git a/p2pvr/devices/devices.h b/p2pvr/devices/devices.h
index e575ce6..f734012 100644
--- a/p2pvr/devices/devices.h
+++ b/p2pvr/devices/devices.h
@@ -27,20 +27,20 @@ class DLL_PUBLIC DevicesI : public Tuners {
DevicesI();
~DevicesI();
- virtual void ScanAndSendNetworkInformation(const RawDataClientPrx&, const ::Ice::Current&) override;
- virtual void SendNetworkInformation(const ::DVBSI::DeliveryPtr&, const RawDataClientPrx&, const ::Ice::Current&) override;
- virtual void SendBouquetAssociations(const ::DVBSI::DeliveryPtr&, const RawDataClientPrx&, const ::Ice::Current&) override;
- virtual void SendServiceDescriptions(const ::DVBSI::DeliveryPtr&, const RawDataClientPrx&, const ::Ice::Current&) override;
- virtual void SendProgramAssociationTable(const ::DVBSI::DeliveryPtr&, const RawDataClientPrx&, const ::Ice::Current&) override;
- virtual void SendProgramMap(const ::DVBSI::DeliveryPtr&, ::Ice::Int, const RawDataClientPrx&, const ::Ice::Current&) override;
- virtual void SendEventInformation(const ::DVBSI::DeliveryPtr&, const RawDataClientPrx&, const ::Ice::Current&) override;
- virtual ::Ice::Int StartSendingTS(const ::DVBSI::DeliveryPtr&, const PacketIds&, const RawDataClientPrx&, const ::Ice::Current&) override;
- virtual ::Ice::Int StartSendingSection(const ::DVBSI::DeliveryPtr&, ::Ice::Int, const RawDataClientPrx&, const ::Ice::Current&) override;
+ virtual void ScanAndSendNetworkInformation(const RawDataClientPrxPtr, const ::Ice::Current&) override;
+ virtual void SendNetworkInformation(const ::DVBSI::DeliveryPtr, const RawDataClientPrxPtr, const ::Ice::Current&) override;
+ virtual void SendBouquetAssociations(const ::DVBSI::DeliveryPtr, const RawDataClientPrxPtr, const ::Ice::Current&) override;
+ virtual void SendServiceDescriptions(const ::DVBSI::DeliveryPtr, const RawDataClientPrxPtr, const ::Ice::Current&) override;
+ virtual void SendProgramAssociationTable(const ::DVBSI::DeliveryPtr, const RawDataClientPrxPtr, const ::Ice::Current&) override;
+ virtual void SendProgramMap(const ::DVBSI::DeliveryPtr, ::Ice::Int, const RawDataClientPrxPtr, const ::Ice::Current&) override;
+ virtual void SendEventInformation(const ::DVBSI::DeliveryPtr, const RawDataClientPrxPtr, const ::Ice::Current&) override;
+ virtual ::Ice::Int StartSendingTS(const ::DVBSI::DeliveryPtr, const PacketIds, const RawDataClientPrxPtr, const ::Ice::Current&) override;
+ virtual ::Ice::Int StartSendingSection(const ::DVBSI::DeliveryPtr, ::Ice::Int, const RawDataClientPrxPtr, const ::Ice::Current&) override;
virtual void StopSending(::Ice::Int, const ::Ice::Current&) override;
- void Scan(const std::string & path, const Ice::Current &) override;
- void Add(const std::string & frontend, const Ice::Current &) override;
- void Remove(const std::string & frontend, const Ice::Current &) override;
+ void Scan(const std::string path, const Ice::Current &) override;
+ void Add(const std::string frontend, const Ice::Current &) override;
+ void Remove(const std::string frontend, const Ice::Current &) override;
::Ice::Int TunerCount(const Ice::Current &) override;
protected:
@@ -48,7 +48,7 @@ class DLL_PUBLIC DevicesI : public Tuners {
typedef boost::function<DVBSI::DeliveryPtr()> DeliveryProvider;
typedef boost::function<void(TunerPtr)> Target;
- typedef boost::shared_ptr<OpenTuner> OpenTunerPtr;
+ typedef std::shared_ptr<OpenTuner> OpenTunerPtr;
typedef std::map<Ice::Int, OpenTunerPtr> OpenDevices;
typedef std::map<Ice::Int, TunerPtr> BackgroundOperations;
diff --git a/p2pvr/devices/frontend.cpp b/p2pvr/devices/frontend.cpp
index 1026a20..b1def01 100644
--- a/p2pvr/devices/frontend.cpp
+++ b/p2pvr/devices/frontend.cpp
@@ -4,6 +4,8 @@
#include <linux/dvb/frontend.h>
#include <factory.impl.h>
+using namespace IceTray::Logging;
+
namespace P2PVR {
namespace DVB {
Frontend::Frontend(TunerI * t, const struct dvb_frontend_info & i, IceTray::Logging::LoggerPtr log) :
@@ -28,7 +30,7 @@ Frontend::GetStatus() const
{
fe_status_t status;
if (ioctl(tuner->frontendFD, FE_READ_STATUS, &status) < 0) {
- logger->messagebf(LOG::ERR, "Reading frontend %s status failed (%s:%d)", tuner->GetDevice(), strerror(errno), errno);
+ logger->messagebf(LogLevel::ERR, "Reading frontend %s status failed (%s:%d)", tuner->GetDevice(), strerror(errno), errno);
throw P2PVR::DeviceError(tuner->GetDevice(), strerror(errno), errno);
}
return status;
diff --git a/p2pvr/devices/frontend.h b/p2pvr/devices/frontend.h
index 6d9a0fa..0525c6d 100644
--- a/p2pvr/devices/frontend.h
+++ b/p2pvr/devices/frontend.h
@@ -12,7 +12,7 @@ class TunerI;
class DLL_PUBLIC Frontend {
public:
- typedef boost::function<bool(long)> OnFrequencyFound;
+ typedef std::function<bool(long)> OnFrequencyFound;
Frontend(TunerI *, const struct dvb_frontend_info &, IceTray::Logging::LoggerPtr);
virtual ~Frontend();
@@ -31,7 +31,7 @@ class DLL_PUBLIC Frontend {
};
typedef AdHoc::Factory<Frontend, TunerI *, const struct dvb_frontend_info &> FrontendFactory;
-typedef boost::shared_ptr<Frontend> FrontendPtr;
+typedef std::shared_ptr<Frontend> FrontendPtr;
}
}
diff --git a/p2pvr/devices/frontends/ofdm.cpp b/p2pvr/devices/frontends/ofdm.cpp
index e6c3979..ab13c70 100644
--- a/p2pvr/devices/frontends/ofdm.cpp
+++ b/p2pvr/devices/frontends/ofdm.cpp
@@ -6,6 +6,8 @@
#define FREQ_OFFSET_MIN 0
#define FREQ_OFFSET_MAX 4
+using namespace IceTray::Logging;
+
namespace P2PVR {
namespace DVB {
namespace Frontends {
@@ -18,7 +20,7 @@ class OFDM : public Frontend {
void TuneTo(const DVBSI::DeliveryPtr & mp) const
{
- auto td = DVBSI::TerrestrialDeliveryPtr::dynamicCast(mp);
+ auto td = std::dynamic_pointer_cast<DVBSI::TerrestrialDelivery>(mp);
if (!td) {
throw P2PVR::IncorrectDeliveryType();
}
@@ -42,7 +44,7 @@ class OFDM : public Frontend {
dvb_frontend_parameters feparams;
memset(&feparams, 0, sizeof(dvb_frontend_parameters));
if (ioctl(tuner->frontendFD, FE_GET_FRONTEND, &feparams) < 0) {
- logger->messagebf(LOG::ERR, "Reading frontend parameters failed (%s:%d)", tuner->GetDevice(), strerror(errno), errno);
+ logger->messagebf(LogLevel::ERR, "Reading frontend parameters failed (%s:%d)", tuner->GetDevice(), strerror(errno), errno);
throw P2PVR::DeviceError(tuner->GetDevice(), strerror(errno), errno);
}
return feparams;
@@ -57,7 +59,7 @@ class OFDM : public Frontend {
}
// Was it useful?
if (!(status & (FE_HAS_SIGNAL | FE_HAS_CARRIER))) {
- logger->messagebf(LOG::ERR, "Tuning of device %s failed (No signal or carrier: 0x%02x)", tuner->GetDevice(), status);
+ logger->messagebf(LogLevel::ERR, "Tuning of device %s failed (No signal or carrier: 0x%02x)", tuner->GetDevice(), status);
throw P2PVR::DeviceError(tuner->GetDevice(), "No carrier", 0);
}
// Wait for lock
@@ -65,7 +67,7 @@ class OFDM : public Frontend {
usleep(10000);
}
if (!(status & FE_HAS_LOCK)) {
- logger->messagebf(LOG::ERR, "Tuning of device %s failed (%s)", tuner->GetDevice(), "No lock");
+ logger->messagebf(LogLevel::ERR, "Tuning of device %s failed (%s)", tuner->GetDevice(), "No lock");
throw P2PVR::DeviceError(tuner->GetDevice(), "No lock", 0);
}
}
@@ -73,7 +75,7 @@ class OFDM : public Frontend {
void SetParameters(const dvb_frontend_parameters & feparams) const
{
if (ioctl(tuner->frontendFD, FE_SET_FRONTEND, &feparams) < 0) {
- logger->messagebf(LOG::ERR, "Tuning of device %s failed (%s:%d)", tuner->GetDevice(), strerror(errno), errno);
+ logger->messagebf(LogLevel::ERR, "Tuning of device %s failed (%s:%d)", tuner->GetDevice(), strerror(errno), errno);
throw P2PVR::DeviceError(tuner->GetDevice(), strerror(errno), errno);
}
}
@@ -138,15 +140,15 @@ class OFDM : public Frontend {
continue;
}
if (fe_info.frequency_min > feparams.frequency || fe_info.frequency_max < feparams.frequency) {
- logger->messagebf(LOG::WARNING, "Channel %d, freq (%d Hz) outside card range", channel, feparams.frequency);
+ logger->messagebf(LogLevel::WARNING, "Channel %d, freq (%d Hz) outside card range", channel, feparams.frequency);
continue;
}
try {
- logger->messagebf(LOG::DEBUG, "Channel %d, Frequency %d Hz", channel, feparams.frequency);
+ logger->messagebf(LogLevel::DEBUG, "Channel %d, Frequency %d Hz", channel, feparams.frequency);
SetParameters(feparams);
WaitForLock();
- logger->messagebf(LOG::INFO, "Found multiplex at %d Hz", feparams.frequency);
- logger->messagebf(LOG::DEBUG, "frequency %d", feparams.frequency);
+ logger->messagebf(LogLevel::INFO, "Found multiplex at %d Hz", feparams.frequency);
+ logger->messagebf(LogLevel::DEBUG, "frequency %d", feparams.frequency);
if (onFrequencyFound(feparams.frequency)) {
return;
}
diff --git a/p2pvr/devices/mockData.cpp b/p2pvr/devices/mockData.cpp
index 31a7100..015daf0 100644
--- a/p2pvr/devices/mockData.cpp
+++ b/p2pvr/devices/mockData.cpp
@@ -1,6 +1,5 @@
#include "mockData.h"
#include <lzma.h>
-#include <Ice/Stream.h>
#include <Ice/Initialize.h>
#include <Ice/Communicator.h>
@@ -57,8 +56,9 @@ namespace P2PVR {
MockData::PacketList MockData::decompressAndRead(const char * front, size_t len) const
{
PacketList packets;
- auto istrm = Ice::createInputStream(ic, decompress(front, len));
- istrm->read(packets);
+ auto data = decompress(front, len);
+ Ice::InputStream istrm(ic, data);
+ istrm.read(packets);
return packets;
}
diff --git a/p2pvr/devices/mockDataValidate.cpp b/p2pvr/devices/mockDataValidate.cpp
index 6bd6b5b..dd14ac1 100644
--- a/p2pvr/devices/mockDataValidate.cpp
+++ b/p2pvr/devices/mockDataValidate.cpp
@@ -17,12 +17,12 @@ template <typename SIObject, typename Base>
class DiscardSI : public Base, public P2PVR::DVB::Testing::MockData {
public:
DiscardSI() :
- MockData(Ice::initialize({}))
+ MockData(Ice::initialize())
{
}
DiscardSI(const P2PVR::DVBSI::SiTableParserBase::RequiredContentIds & ids) :
Base(ids),
- MockData(Ice::initialize({}))
+ MockData(Ice::initialize())
{
}
virtual ~DiscardSI() { ic->destroy(); }
diff --git a/p2pvr/devices/mockTuner.cpp b/p2pvr/devices/mockTuner.cpp
index 706bbd9..531e6a1 100644
--- a/p2pvr/devices/mockTuner.cpp
+++ b/p2pvr/devices/mockTuner.cpp
@@ -4,6 +4,8 @@
#include <logger.h>
#include <list>
+using namespace IceTray::Logging;
+
#define ResourceFile(resource) \
extern "C" { \
extern char resource##_start, resource##_end;\
@@ -117,7 +119,7 @@ MockTuner::ioselect(int nfds, fd_set *readfds, fd_set *, fd_set *, struct timeva
void
MockTuner::RequestPID(int pid, int fh) const
{
- logger->messagef(LOG::DEBUG, "%s: pid %x, fh %d", __PRETTY_FUNCTION__, pid, fh);
+ logger->messagef(LogLevel::DEBUG, "%s: pid %x, fh %d", __PRETTY_FUNCTION__, pid, fh);
switch (pid) {
case 0: // pat
selectedPackets[fh] = getPAT();
@@ -140,7 +142,7 @@ MockTuner::RequestPID(int pid, int fh) const
void
MockTuner::RequestTS(const PacketIds & pids, int fh) const
{
- logger->messagef(LOG::DEBUG, "%s: pids %zu, fh %d", __PRETTY_FUNCTION__, pids.size(), fh);
+ logger->messagef(LogLevel::DEBUG, "%s: pids %zu, fh %d", __PRETTY_FUNCTION__, pids.size(), fh);
selectedPackets[fh] = getVideo();
}
diff --git a/p2pvr/devices/tuner.cpp b/p2pvr/devices/tuner.cpp
index 7358428..531397d 100644
--- a/p2pvr/devices/tuner.cpp
+++ b/p2pvr/devices/tuner.cpp
@@ -11,6 +11,8 @@
#include "tunerSendSi.h"
#include "tunerSendTs.h"
+using namespace IceTray::Logging;
+
namespace P2PVR {
namespace DVB {
IceTray::Logging::LoggerPtr TunerI::logger = LOGMANAGER()->getLogger<TunerI>();
@@ -31,7 +33,7 @@ TunerI::TunerI(const boost::filesystem::path & df, FrontendPtr pfe) :
}
frontend = FrontendPtr(FrontendFactory::createNew(Frontend::FactoryKey(fe_info.type), this, fe_info));
}
- logger->messagebf(LOG::INFO, "%s: Attached to %s (%s, type %s)", __PRETTY_FUNCTION__,
+ logger->messagebf(LogLevel::INFO, "%s: Attached to %s (%s, type %s)", __PRETTY_FUNCTION__,
deviceRoot, frontend->Info().name, frontend->Type());
}
@@ -71,7 +73,7 @@ TunerI::OpenDemux() const
}
void
-TunerI::ScanAndSendNetworkInformation(const RawDataClientPrx & client)
+TunerI::ScanAndSendNetworkInformation(const RawDataClientPrxPtr & client)
{
frontend->FrequencyScan([this, &client](long) {
try {
@@ -79,57 +81,57 @@ TunerI::ScanAndSendNetworkInformation(const RawDataClientPrx & client)
}
catch (const std::exception & ex) {
char * buf = __cxxabiv1::__cxa_demangle(typeid(ex).name(), NULL, NULL, NULL);
- logger->messagebf(LOG::DEBUG, "%s: frequency scan lock event failed %s:%s", __PRETTY_FUNCTION__, buf, ex.what());
+ logger->messagebf(LogLevel::DEBUG, "%s: frequency scan lock event failed %s:%s", __PRETTY_FUNCTION__, buf, ex.what());
free(buf);
return false;
}
catch (...) {
- logger->messagebf(LOG::DEBUG, "%s: frequency scan lock event failed", __PRETTY_FUNCTION__);
+ logger->messagebf(LogLevel::DEBUG, "%s: frequency scan lock event failed", __PRETTY_FUNCTION__);
return false;
}
});
}
void
-TunerI::SendNetworkInformation(const RawDataClientPrx & client)
+TunerI::SendNetworkInformation(const RawDataClientPrxPtr & client)
{
SendPID(0x10, client);
}
void
-TunerI::SendBouquetAssociations(const RawDataClientPrx & client)
+TunerI::SendBouquetAssociations(const RawDataClientPrxPtr & client)
{
SendPID(0x11, client);
}
void
-TunerI::SendServiceDescriptions(const RawDataClientPrx & client)
+TunerI::SendServiceDescriptions(const RawDataClientPrxPtr & client)
{
SendPID(0x11, client);
}
void
-TunerI::SendProgramMap(Ice::Int pid, const RawDataClientPrx & client)
+TunerI::SendProgramMap(Ice::Int pid, const RawDataClientPrxPtr & client)
{
SendPID(pid, client);
}
void
-TunerI::SendProgramAssociationTable(const RawDataClientPrx & client)
+TunerI::SendProgramAssociationTable(const RawDataClientPrxPtr & client)
{
SendPID(0x00, client);
}
void
-TunerI::SendEventInformation(const RawDataClientPrx & client)
+TunerI::SendEventInformation(const RawDataClientPrxPtr & client)
{
SendPID(0x12, client);
}
uint64_t
-TunerI::SendPID(int pid, const RawDataClientPrx & client) const
+TunerI::SendPID(int pid, const RawDataClientPrxPtr & client) const
{
- logger->messagebf(LOG::DEBUG, "%s: pid = 0x%x", __PRETTY_FUNCTION__, pid);
+ logger->messagebf(LogLevel::DEBUG, "%s: pid = 0x%x", __PRETTY_FUNCTION__, pid);
auto demux = OpenDemux();
RequestPID(pid, demux);
@@ -169,9 +171,9 @@ TunerI::ioselect(int nfds, fd_set *readfds, fd_set *writefds, fd_set *exceptfds,
}
uint64_t
-TunerI::ReadDemuxAndSend(AdHoc::FileUtils::FileHandle demux, const RawDataClientPrx & _client) const
+TunerI::ReadDemuxAndSend(AdHoc::FileUtils::FileHandle demux, const RawDataClientPrxPtr & _client) const
{
- logger->messagebf(LOG::DEBUG, "%s: begin", __PRETTY_FUNCTION__);
+ logger->messagebf(LogLevel::DEBUG, "%s: begin", __PRETTY_FUNCTION__);
struct pollfd ufd;
memset(&ufd, 0, sizeof(pollfd));
ufd.fd = demux;
@@ -183,10 +185,10 @@ TunerI::ReadDemuxAndSend(AdHoc::FileUtils::FileHandle demux, const RawDataClient
case -2:
break;
case -1:
- logger->messagef(LOG::ERR, "%s: poll error reading demux (%d:%s)", __PRETTY_FUNCTION__, errno, strerror(errno));
+ logger->messagef(LogLevel::ERR, "%s: poll error reading demux (%d:%s)", __PRETTY_FUNCTION__, errno, strerror(errno));
throw DeviceError("demux", strerror(errno), errno);
case 0:
- logger->messagef(LOG::WARNING, "%s: Timed out waiting for data (device status 0x%02x)",
+ logger->messagef(LogLevel::WARNING, "%s: Timed out waiting for data (device status 0x%02x)",
__PRETTY_FUNCTION__, frontend->GetStatus());
throw DeviceError("demux", "timeout", 0);
default:
@@ -195,7 +197,7 @@ TunerI::ReadDemuxAndSend(AdHoc::FileUtils::FileHandle demux, const RawDataClient
Data buf(1 << 12);
int nr = ioread(ufd.fd, &buf.front(), buf.size());
if (nr < 0) {
- logger->messagef(LOG::ERR, "%s: error reading demux (%d:%s) status 0x%02x",
+ logger->messagef(LogLevel::ERR, "%s: error reading demux (%d:%s) status 0x%02x",
__PRETTY_FUNCTION__, errno, strerror(errno), frontend->GetStatus());
throw DeviceError("demux", strerror(errno), errno);
}
@@ -208,12 +210,12 @@ TunerI::ReadDemuxAndSend(AdHoc::FileUtils::FileHandle demux, const RawDataClient
} while (!client->IsFinished());
auto packetsSent = client->PacketsSent();
client.reset();
- logger->messagebf(LOG::DEBUG, "%s: end (sent %d packets)", __PRETTY_FUNCTION__, packetsSent);
+ logger->messagebf(LogLevel::DEBUG, "%s: end (sent %d packets)", __PRETTY_FUNCTION__, packetsSent);
return packetsSent;
}
int
-TunerI::StartSendingSection(int pid, const RawDataClientPrx & client)
+TunerI::StartSendingSection(int pid, const RawDataClientPrxPtr & client)
{
Lock(lock);
BackgroundClient bgc(new SendSiStream(OpenDemux(), client));
@@ -225,7 +227,7 @@ TunerI::StartSendingSection(int pid, const RawDataClientPrx & client)
}
int
-TunerI::StartSendingTS(const PacketIds & pids, const RawDataClientPrx & client)
+TunerI::StartSendingTS(const PacketIds & pids, const RawDataClientPrxPtr & client)
{
if (pids.empty()) {
throw DeviceError("demux", "Packet Id list cannot be empty", 0);
@@ -247,7 +249,7 @@ TunerI::RequestTS(const PacketIds & pids, int demux) const
{
struct dmx_pes_filter_params pesFilterParams;
memset(&pesFilterParams, 0, sizeof(struct dmx_pes_filter_params));
- logger->messagef(LOG::ERR, "%s: DMX_SET_PES_FILTER for pid %d", __PRETTY_FUNCTION__, pids[0]);
+ logger->messagef(LogLevel::ERR, "%s: DMX_SET_PES_FILTER for pid %d", __PRETTY_FUNCTION__, pids[0]);
pesFilterParams.pid = pids[0];
pesFilterParams.input = DMX_IN_FRONTEND;
pesFilterParams.output = DMX_OUT_TSDEMUX_TAP;
@@ -255,22 +257,22 @@ TunerI::RequestTS(const PacketIds & pids, int demux) const
pesFilterParams.flags = 0;
if (ioctl(demux, DMX_SET_PES_FILTER, &pesFilterParams) < 0) {
- logger->messagef(LOG::ERR, "%s: DMX_SET_PES_FILTER failed (%d: %s)", __PRETTY_FUNCTION__, errno, strerror(errno));
+ logger->messagef(LogLevel::ERR, "%s: DMX_SET_PES_FILTER failed (%d: %s)", __PRETTY_FUNCTION__, errno, strerror(errno));
throw DeviceError("demux", strerror(errno), errno);
}
for (unsigned int x = 1; x < pids.size(); x += 1) {
__u16 p = pids[x];
- logger->messagef(LOG::ERR, "%s: DMX_ADD_PID for pid %d", __PRETTY_FUNCTION__, p);
+ logger->messagef(LogLevel::ERR, "%s: DMX_ADD_PID for pid %d", __PRETTY_FUNCTION__, p);
if (ioctl(demux, DMX_ADD_PID, &p) < 0) {
- logger->messagef(LOG::ERR, "%s: DMX_ADD_PID failed (%d: %s)", __PRETTY_FUNCTION__, errno, strerror(errno));
+ logger->messagef(LogLevel::ERR, "%s: DMX_ADD_PID failed (%d: %s)", __PRETTY_FUNCTION__, errno, strerror(errno));
throw DeviceError("demux", strerror(errno), errno);
}
}
setBufferSize(demux, options->DemuxStreamBufferSize);
if (ioctl(demux, DMX_START) < 0) {
- logger->messagef(LOG::ERR, "%s: DMX_START failed (%d: %s)", __PRETTY_FUNCTION__, errno, strerror(errno));
+ logger->messagef(LogLevel::ERR, "%s: DMX_START failed (%d: %s)", __PRETTY_FUNCTION__, errno, strerror(errno));
throw DeviceError("demux", strerror(errno), errno);
}
}
@@ -279,16 +281,16 @@ void
TunerI::setBufferSize(int demux, unsigned long size)
{
if (ioctl(demux, DMX_SET_BUFFER_SIZE, size)) {
- logger->messagef(LOG::ERR, "%s: DMX_SET_BUFFER_SIZE to %lu failed (%d: %s)", __PRETTY_FUNCTION__, size, errno, strerror(errno));
+ logger->messagef(LogLevel::ERR, "%s: DMX_SET_BUFFER_SIZE to %lu failed (%d: %s)", __PRETTY_FUNCTION__, size, errno, strerror(errno));
throw DeviceError("demux", strerror(errno), errno);
}
- logger->messagef(LOG::DEBUG, "%s: DMX_SET_BUFFER_SIZE to %lu", __PRETTY_FUNCTION__, size);
+ logger->messagef(LogLevel::DEBUG, "%s: DMX_SET_BUFFER_SIZE to %lu", __PRETTY_FUNCTION__, size);
}
void
TunerI::StopSending(int handle)
{
- logger->messagef(LOG::DEBUG, "%s: handle %d", __PRETTY_FUNCTION__, handle);
+ logger->messagef(LogLevel::DEBUG, "%s: handle %d", __PRETTY_FUNCTION__, handle);
std::lock_guard<std::mutex> g(lock);
if (backgroundClients.find(handle) != backgroundClients.end()) {
backgroundClients.erase(handle);
@@ -321,7 +323,7 @@ TunerI::senderThread()
lock.lock();
switch (s) {
case -1: // error
- logger->messagebf(LOG::WARNING, "%s: select failed (%d:%s)", __PRETTY_FUNCTION__, errno, strerror(errno));
+ logger->messagebf(LogLevel::WARNING, "%s: select failed (%d:%s)", __PRETTY_FUNCTION__, errno, strerror(errno));
case 0: // nothing to read, but all is well
break;
default:
@@ -332,7 +334,7 @@ TunerI::senderThread()
Data buf(1 << 16);
int nr = ioread(c->first, &buf.front(), buf.size());
if (nr < 0) {
- logger->messagef(LOG::ERR, "%s: read failed (%d:%s)", __PRETTY_FUNCTION__, errno, strerror(errno));
+ logger->messagef(LogLevel::ERR, "%s: read failed (%d:%s)", __PRETTY_FUNCTION__, errno, strerror(errno));
c = backgroundClients.erase(c);
}
else {
@@ -360,11 +362,11 @@ TunerI::senderThread()
}
}
backgroundThread = NULL;
- logger->messagebf(LOG::DEBUG, "%s: Unlocking", __PRETTY_FUNCTION__);
+ logger->messagebf(LogLevel::DEBUG, "%s: Unlocking", __PRETTY_FUNCTION__);
lock.unlock();
}
-TunerI::IDataSender::IDataSender(AdHoc::FileUtils::FileHandle h, const RawDataClientPrx & c) :
+TunerI::IDataSender::IDataSender(AdHoc::FileUtils::FileHandle h, const RawDataClientPrxPtr & c) :
_packetsSent(0),
fh(std::move(h)),
client(c)
diff --git a/p2pvr/devices/tuner.h b/p2pvr/devices/tuner.h
index 5a70e94..11fbf07 100644
--- a/p2pvr/devices/tuner.h
+++ b/p2pvr/devices/tuner.h
@@ -26,7 +26,7 @@ class DLL_PUBLIC TunerI : public Tuner {
public:
class IDataSender {
public:
- IDataSender(AdHoc::FileUtils::FileHandle, const RawDataClientPrx &);
+ IDataSender(AdHoc::FileUtils::FileHandle, const RawDataClientPrxPtr &);
virtual ~IDataSender() = 0;
virtual void NewData(const Data &) = 0;
@@ -37,9 +37,9 @@ class DLL_PUBLIC TunerI : public Tuner {
protected:
uint64_t _packetsSent;
const AdHoc::FileUtils::FileHandle fh;
- const RawDataClientPrx client;
+ const RawDataClientPrxPtr client;
};
- typedef boost::shared_ptr<IDataSender> BackgroundClient;
+ typedef std::shared_ptr<IDataSender> BackgroundClient;
typedef std::map<int, BackgroundClient> BackgroundClients;
TunerI(const boost::filesystem::path & deviceFrontend, FrontendPtr = FrontendPtr());
@@ -49,16 +49,16 @@ class DLL_PUBLIC TunerI : public Tuner {
int GetStatus() override;
std::string GetDevice() override;
- void ScanAndSendNetworkInformation(const RawDataClientPrx & client) override;
- void SendNetworkInformation(const RawDataClientPrx & client) override;
- void SendBouquetAssociations(const RawDataClientPrx & client) override;
- void SendServiceDescriptions(const RawDataClientPrx & client) override;
- void SendProgramMap(Ice::Int pid, const RawDataClientPrx & client) override;
- void SendProgramAssociationTable(const RawDataClientPrx & client) override;
- void SendEventInformation(const RawDataClientPrx & client) override;
+ void ScanAndSendNetworkInformation(const RawDataClientPrxPtr & client) override;
+ void SendNetworkInformation(const RawDataClientPrxPtr & client) override;
+ void SendBouquetAssociations(const RawDataClientPrxPtr & client) override;
+ void SendServiceDescriptions(const RawDataClientPrxPtr & client) override;
+ void SendProgramMap(Ice::Int pid, const RawDataClientPrxPtr & client) override;
+ void SendProgramAssociationTable(const RawDataClientPrxPtr & client) override;
+ void SendEventInformation(const RawDataClientPrxPtr & client) override;
- int StartSendingTS(const PacketIds & pids, const RawDataClientPrx & client) override;
- int StartSendingSection(Ice::Int pid, const RawDataClientPrx & client) override;
+ int StartSendingTS(const PacketIds & pids, const RawDataClientPrxPtr & client) override;
+ int StartSendingSection(Ice::Int pid, const RawDataClientPrxPtr & client) override;
void StopSending(int handle) override;
protected:
@@ -68,10 +68,10 @@ class DLL_PUBLIC TunerI : public Tuner {
private:
virtual AdHoc::FileUtils::FileHandle OpenDemux() const;
- uint64_t SendPID(int pid, const RawDataClientPrx & client) const;
+ uint64_t SendPID(int pid, const RawDataClientPrxPtr & client) const;
virtual void RequestPID(int pid, int fd) const;
virtual void RequestTS(const PacketIds &, int fd) const;
- uint64_t ReadDemuxAndSend(AdHoc::FileUtils::FileHandle fd, const RawDataClientPrx & client) const;
+ uint64_t ReadDemuxAndSend(AdHoc::FileUtils::FileHandle fd, const RawDataClientPrxPtr & client) const;
void startSenderThread();
void senderThread();
static void setBufferSize(int fd, unsigned long bytes);
diff --git a/p2pvr/devices/tunerSendSi.cpp b/p2pvr/devices/tunerSendSi.cpp
index 76eb2b7..3482f94 100644
--- a/p2pvr/devices/tunerSendSi.cpp
+++ b/p2pvr/devices/tunerSendSi.cpp
@@ -3,11 +3,14 @@
#include <boost/crc.hpp>
#include "siParsers/table.h"
+using namespace std::chrono_literals;
+using namespace IceTray::Logging;
+
namespace P2PVR {
namespace DVB {
IceTray::Logging::LoggerPtr SendSi::logger(LOGMANAGER()->getLogger<SendSi>());
-SendSi::SendSi(AdHoc::FileUtils::FileHandle fh, const RawDataClientPrx & c) :
+SendSi::SendSi(AdHoc::FileUtils::FileHandle fh, const RawDataClientPrxPtr & c) :
TunerI::IDataSender(std::move(fh), c->ice_collocationOptimized(false))
{
}
@@ -16,7 +19,7 @@ SendSi::~SendSi()
{
}
-SendSiStream::SendSiStream(AdHoc::FileUtils::FileHandle fh, const RawDataClientPrx & c) :
+SendSiStream::SendSiStream(AdHoc::FileUtils::FileHandle fh, const RawDataClientPrxPtr & c) :
SendSi(std::move(fh), c)
{
}
@@ -32,19 +35,19 @@ SendSi::NewData(const Data & buf)
return;
}
_packetsSent += 1;
- asyncs.insert(client->begin_NewData(buf));
+ asyncs.push_back(client->NewDataAsync(buf));
}
bool
SendSi::IsFinished()
{
for (auto c = asyncs.begin(); c != asyncs.end(); ) {
- if ((*c)->isCompleted()) {
- auto a = *c;
- c = asyncs.erase(c);
- if (client->end_NewData(a)) {
+ if (c->wait_for(5ms) == std::future_status::ready) {
+ if (c->get()) {
+ asyncs.erase(c);
return true;
}
+ c = asyncs.erase(c);
}
else {
c++;
@@ -60,7 +63,7 @@ SendSiStream::IsFinished()
return SendSi::IsFinished();
}
catch (const std::exception & ex) {
- logger->messagebf(LOG::DEBUG, "%s: Client transmit error (%s)", __PRETTY_FUNCTION__, ex.what());
+ logger->messagebf(LogLevel::DEBUG, "%s: Client transmit error (%s)", __PRETTY_FUNCTION__, ex.what());
return true;
}
}
@@ -70,21 +73,21 @@ SendSi::IsValidSection(const Data & buf)
{
auto n = buf.size();
if (n < sizeof(DVBSI::SiTableHeader)) {
- logger->messagebf(LOG::WARNING, "Received data too small to be an SI table.");
+ logger->messagebf(LogLevel::WARNING, "Received data too small to be an SI table.");
return false;
}
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.");
+ logger->messagebf(LogLevel::WARNING, "Received data shorter than its defined length.");
return false;
}
if (n > l) {
- logger->messagebf(LOG::WARNING, "Received data longer than its defined length.");
+ logger->messagebf(LogLevel::WARNING, "Received data longer than its defined length.");
return false;
}
if (!crc32(buf)) {
- logger->messagebf(LOG::WARNING, "Received data is corrupted (crc32 failed).");
+ logger->messagebf(LogLevel::WARNING, "Received data is corrupted (crc32 failed).");
return false;
}
return true;
diff --git a/p2pvr/devices/tunerSendSi.h b/p2pvr/devices/tunerSendSi.h
index a2b8b4f..3198135 100644
--- a/p2pvr/devices/tunerSendSi.h
+++ b/p2pvr/devices/tunerSendSi.h
@@ -8,7 +8,7 @@ namespace P2PVR {
namespace DVB {
class SendSi : public TunerI::IDataSender {
public:
- SendSi(AdHoc::FileUtils::FileHandle, const P2PVR::RawDataClientPrx &);
+ SendSi(AdHoc::FileUtils::FileHandle, const P2PVR::RawDataClientPrxPtr &);
~SendSi();
void NewData(const P2PVR::Data &) override;
@@ -18,13 +18,13 @@ class SendSi : public TunerI::IDataSender {
static bool crc32(const P2PVR::Data &);
static bool IsValidSection(const P2PVR::Data &);
- std::set<Ice::AsyncResultPtr> asyncs;
+ std::vector<std::future<bool>> asyncs;
bool finish;
static IceTray::Logging::LoggerPtr logger;
};
class SendSiStream : public SendSi {
public:
- SendSiStream(AdHoc::FileUtils::FileHandle, const P2PVR::RawDataClientPrx &);
+ SendSiStream(AdHoc::FileUtils::FileHandle, const P2PVR::RawDataClientPrxPtr &);
~SendSiStream();
bool IsFinished() override;
diff --git a/p2pvr/devices/tunerSendTs.cpp b/p2pvr/devices/tunerSendTs.cpp
index 0cddb93..22b94bb 100644
--- a/p2pvr/devices/tunerSendTs.cpp
+++ b/p2pvr/devices/tunerSendTs.cpp
@@ -1,6 +1,9 @@
#include "tunerSendTs.h"
#include <logger.h>
+using namespace std::chrono_literals;
+using namespace IceTray::Logging;
+
namespace P2PVR {
namespace DVB {
// ~64kb of TS packets
@@ -10,7 +13,7 @@ namespace DVB {
IceTray::Logging::LoggerPtr SendTs::logger(LOGMANAGER()->getLogger<SendTs>());
-SendTs::SendTs(AdHoc::FileUtils::FileHandle fh, const RawDataClientPrx & c) :
+SendTs::SendTs(AdHoc::FileUtils::FileHandle fh, const RawDataClientPrxPtr & c) :
TunerI::IDataSender(std::move(fh), c->ice_collocationOptimized(false))
{
buffer.reserve(TARGET_BUFFER_SIZE);
@@ -20,11 +23,11 @@ SendTs::~SendTs()
{
try {
if (async) {
- if (client->end_NewData(async)) return;
+ if (async->get()) return;
}
while (!buffer.empty()) {
sendBufferChunk();
- if (client->end_NewData(async)) return;
+ if (async->get()) return;
}
}
catch (...) {
@@ -45,11 +48,11 @@ SendTs::sendBufferChunk()
{
if (buffer.size() > TARGET_BUFFER_LIMIT) {
auto breakPoint = buffer.begin() + TARGET_BUFFER_LIMIT;
- async = client->begin_NewData(Data(buffer.begin(), breakPoint));
+ async = client->NewDataAsync(Data(buffer.begin(), breakPoint));
buffer.erase(buffer.begin(), breakPoint);
}
else {
- async = client->begin_NewData(buffer);
+ async = client->NewDataAsync(buffer);
buffer.clear();
buffer.reserve(TARGET_BUFFER_SIZE);
}
@@ -60,9 +63,9 @@ bool
SendTs::IsFinished()
{
try {
- if (async && async->isCompleted()) {
- auto finished = client->end_NewData(async);
- async = NULL;
+ if (async && async->wait_for(5ms) == std::future_status::ready) {
+ auto finished = async->get();
+ async.reset();
if (finished) {
buffer.clear();
}
@@ -71,8 +74,8 @@ SendTs::IsFinished()
return false;
}
catch (const std::exception & ex) {
- async = NULL;
- logger->messagebf(LOG::DEBUG, "%s: Client transmit error (%s)", __PRETTY_FUNCTION__, ex.what());
+ async.reset();
+ logger->messagebf(LogLevel::DEBUG, "%s: Client transmit error (%s)", __PRETTY_FUNCTION__, ex.what());
return true;
}
}
diff --git a/p2pvr/devices/tunerSendTs.h b/p2pvr/devices/tunerSendTs.h
index a3f584c..dca4b74 100644
--- a/p2pvr/devices/tunerSendTs.h
+++ b/p2pvr/devices/tunerSendTs.h
@@ -8,16 +8,16 @@ namespace P2PVR {
namespace DVB {
class SendTs : public TunerI::IDataSender {
public:
- SendTs(AdHoc::FileUtils::FileHandle, const P2PVR::RawDataClientPrx &);
+ SendTs(AdHoc::FileUtils::FileHandle, const P2PVR::RawDataClientPrxPtr &);
~SendTs();
- void NewData(const P2PVR::Data &);
- bool IsFinished();
+ void NewData(const P2PVR::Data &) override;
+ bool IsFinished() override;
private:
void sendBufferChunk();
- Ice::AsyncResultPtr async;
+ std::optional<std::future<bool>> async;
P2PVR::Data buffer;
static IceTray::Logging::LoggerPtr logger;
};
diff --git a/p2pvr/dvb/siParsers/event.cpp b/p2pvr/dvb/siParsers/event.cpp
index 26751a7..5aa11b3 100644
--- a/p2pvr/dvb/siParsers/event.cpp
+++ b/p2pvr/dvb/siParsers/event.cpp
@@ -111,7 +111,7 @@ SiEpgParser::parseDescriptor_ShortEvent(::DVBSI::EventPtr current, const u_char
*subtitle = yearRegex->replace_literal(*subtitle, 0, "", Glib::REGEX_MATCH_NOTEMPTY);
}
if (flagsRegex->match(*subtitle, matches)) {
- current->Flags = matches.fetch(1);
+ current->Flags = matches.fetch(1).raw();
*subtitle = flagsRegex->replace_literal(*subtitle, 0, "", Glib::REGEX_MATCH_NOTEMPTY);
}
if (episodeRegex->match(*subtitle, matches)) {
@@ -164,13 +164,13 @@ SiEpgParser::parseDescriptor_ShortEvent(::DVBSI::EventPtr current, const u_char
if (subtitle) {
boost::algorithm::trim_if(*subtitle, isspace);
if (!subtitle->empty()) {
- current->Subtitle = *subtitle;
+ current->Subtitle = subtitle->raw();
}
}
if (desc) {
boost::algorithm::trim_if(*desc, isspace);
if (!desc->empty()) {
- current->Description = *desc;
+ current->Description = desc->raw();
}
}
}
@@ -188,10 +188,10 @@ SiEpgParser::parseDescriptor_Component(::DVBSI::EventPtr current, const u_char *
break;
case 0x02: // Audio Info
current->AudioChannels = dc->component_type;
- current->AudioLanguage = Glib::ustring(dc->lang_code, 3);
+ current->AudioLanguage = Glib::ustring(dc->lang_code, 3).raw();
break;
case 0x03: // Teletext Info
- current->SubtitleLanguage = Glib::ustring(dc->lang_code, 3);
+ current->SubtitleLanguage = Glib::ustring(dc->lang_code, 3).raw();
break;
}
}
@@ -215,7 +215,7 @@ SiEpgParser::parseDescriptor_ParentalRating(::DVBSI::EventPtr current, const u_c
break;
case 0x00: /*undefined*/
case 0x10 ... 0xFF: /*broadcaster defined*/
- current->DvbRating = NULL;
+ current->DvbRating.reset();
break;
}
}
@@ -232,8 +232,8 @@ SiEpgParser::HandleTable(const ::DVBSI::EitInformationPtr &)
return false;
}
-Common::DateTime &
-operator<<(Common::DateTime & dt, const boost::posix_time::ptime & pt)
+Chrono::DateTime &
+operator<<(Chrono::DateTime & dt, const boost::posix_time::ptime & pt)
{
dt.Year = pt.date().year();
dt.Month = pt.date().month();
@@ -250,7 +250,7 @@ SiEpgParser::ParseSiTable(const EventInformation * eit, const ::DVBSI::EitInform
ei->TransportStreamId = ntohs(eit->TransportStreamId);
ei->OriginalNetworkId = ntohs(eit->OriginalNetworkId);
LoopOver<EventDescriptor>(eit->data, HILO(eit->header.section_length) - 15, [this,ei](const EventDescriptor * ed) {
- ::DVBSI::EventPtr e = new ::DVBSI::Event();
+ ::DVBSI::EventPtr e = std::make_shared<::DVBSI::Event>();
e->EventId = ntohs(ed->EventId);
e->ServiceId = ei->ServiceId;
// <ew>
diff --git a/p2pvr/dvb/siParsers/network.cpp b/p2pvr/dvb/siParsers/network.cpp
index ea39209..ec71aab 100644
--- a/p2pvr/dvb/siParsers/network.cpp
+++ b/p2pvr/dvb/siParsers/network.cpp
@@ -150,8 +150,8 @@ SiNetworkInformationParser::ParseSiTable(const struct NetworkInformation * nit,
n->NetworkId = ntohs(nit->header.content_id);
auto nsh = ParseDescriptors<NetworkStreamsHeader>(nit->data, HILO(nit->network_descriptor_length),
0x40, boost::bind(&SiNetworkInformationParser::parseDescriptor_NetworkName, n, _1, _2));
- LoopOver<TransportStream>(nsh->data, HILO(nsh->transport_stream_loop_length), [this,n](const TransportStream * ts) {
- ::DVBSI::NetworkTransportStreamPtr nts = new ::DVBSI::NetworkTransportStream();
+ LoopOver<TransportStream>(nsh->data, HILO(nsh->transport_stream_loop_length), [n](const TransportStream * ts) {
+ ::DVBSI::NetworkTransportStreamPtr nts = std::make_shared<::DVBSI::NetworkTransportStream>();
nts->TransportStreamId = ntohs(ts->transportStreamId);
nts->NetworkId = n->NetworkId;
nts->OriginalNetworkId = ntohs(ts->originalNetworkId);
@@ -167,7 +167,7 @@ SiNetworkInformationParser::ParseSiTable(const struct NetworkInformation * nit,
void
SiNetworkInformationParser::parseDescriptor_NetworkName(::DVBSI::NetworkPtr n, const u_char * p, size_t len)
{
- n->Name = *convert((const char *)p, len);
+ n->Name = convert((const char *)p, len)->raw();
}
AdHocFormatter(WhatIsntSupported, "%? %x");
@@ -237,7 +237,7 @@ SiNetworkInformationParser::parseDescriptor_TerrestrialDelivery(::DVBSI::Network
{
assert(len == sizeof(TerrestrialDeliveryDescriptor));
auto tdd = reinterpret_cast<const TerrestrialDeliveryDescriptor *>(data);
- ::DVBSI::TerrestrialDeliveryPtr td = new ::DVBSI::TerrestrialDelivery;
+ ::DVBSI::TerrestrialDeliveryPtr td = std::make_shared<::DVBSI::TerrestrialDelivery>();
td->Frequency = ((uint64_t)ntohl(tdd->Frequency)) * 10;
td->TransportStreamId = nts->TransportStreamId;
td->Bandwidth = AdHoc::safeMapLookup<BandwidthNotSupported>(tbandwidths, tdd->Bandwidth);
@@ -259,7 +259,7 @@ SiNetworkInformationParser::parseDescriptor_CableDelivery(::DVBSI::NetworkTransp
{
assert(len == sizeof(CableDeliveryDescriptor));
auto cdd = reinterpret_cast<const CableDeliveryDescriptor *>(data);
- ::DVBSI::CableDeliveryPtr cd = new ::DVBSI::CableDelivery;
+ ::DVBSI::CableDeliveryPtr cd = std::make_shared<::DVBSI::CableDelivery>();
cd->Frequency = ((uint64_t)ntohl(cdd->Frequency)) * 10;
cd->TransportStreamId = nts->TransportStreamId;
cd->FecOuter = cdd->FecOuter;
@@ -274,7 +274,7 @@ SiNetworkInformationParser::parseDescriptor_SatelliteDelivery(::DVBSI::NetworkTr
{
assert(len == sizeof(SatelliteDeliveryDescriptor));
auto sdd = reinterpret_cast<const SatelliteDeliveryDescriptor *>(data);
- ::DVBSI::SatelliteDeliveryPtr sd = new ::DVBSI::SatelliteDelivery;
+ ::DVBSI::SatelliteDeliveryPtr sd = std::make_shared<::DVBSI::SatelliteDelivery>();
sd->Frequency = ((uint64_t)ntohl(sdd->Frequency)) * 10;
sd->TransportStreamId = nts->TransportStreamId;
sd->OrbitalPosition = ntohs(sdd->OrbitalPosition);
diff --git a/p2pvr/dvb/siParsers/programAssociation.cpp b/p2pvr/dvb/siParsers/programAssociation.cpp
index 64beff2..e80472b 100644
--- a/p2pvr/dvb/siParsers/programAssociation.cpp
+++ b/p2pvr/dvb/siParsers/programAssociation.cpp
@@ -24,7 +24,7 @@ SiProgramAssociationParser::CheckTableId(u_char tableId) const
void
SiProgramAssociationParser::ParseSiTable(const ProgramAssociationSection * pas, const ProgramAssociationMapPtr & pam)
{
- LoopOverSection<ProgramAssociation>(pas->data, HILO(pas->header.section_length) - 12, [this,&pam](const ProgramAssociation * sd) {
+ LoopOverSection<ProgramAssociation>(pas->data, HILO(pas->header.section_length) - 12, [&pam](const ProgramAssociation * sd) {
(*pam)[ntohs(sd->program_number)] = HILO(sd->pid);
});
}
diff --git a/p2pvr/dvb/siParsers/programMap.cpp b/p2pvr/dvb/siParsers/programMap.cpp
index 3491e88..a6fd745 100644
--- a/p2pvr/dvb/siParsers/programMap.cpp
+++ b/p2pvr/dvb/siParsers/programMap.cpp
@@ -38,7 +38,7 @@ SiProgramMapParser::ParseSiTable(const struct ProgramMap * pm, const ::DVBSI::Pr
pmp->ServiceId = ntohs(pm->header.content_id);
auto pms = ParseDescriptors<ProgramMapStream>(pm->data, HILO(pm->program_info_len));
while (reinterpret_cast<const u_char*>(pms) < &pm->header.section_length_lo + HILO(pm->header.section_length) - 4) {
- ::DVBSI::StreamPtr s = new ::DVBSI::Stream();
+ ::DVBSI::StreamPtr s = std::make_shared<::DVBSI::Stream>();
s->Type = pms->stream_type;
s->Id = HILO(pms->elementary_PID);
s->ServiceId = pmp->ServiceId;
diff --git a/p2pvr/dvb/siParsers/service.cpp b/p2pvr/dvb/siParsers/service.cpp
index 9ee9341..99a4a3f 100644
--- a/p2pvr/dvb/siParsers/service.cpp
+++ b/p2pvr/dvb/siParsers/service.cpp
@@ -44,8 +44,8 @@ SiServicesParser::ParseSiTable(const TransportStreamDescriptor * tsd, const ::DV
{
ts->TransportStreamId = ntohs(tsd->header.content_id);
ts->OriginalNetworkId = ntohs(tsd->original_network_id);
- LoopOver<ServiceDescriptor>(tsd->data, HILO(tsd->header.section_length) - 12, [this,&ts](const ServiceDescriptor * sd) {
- ::DVBSI::ServicePtr s = new ::DVBSI::Service();
+ LoopOver<ServiceDescriptor>(tsd->data, HILO(tsd->header.section_length) - 12, [&ts](const ServiceDescriptor * sd) {
+ ::DVBSI::ServicePtr s = std::make_shared<::DVBSI::Service>();
s->ServiceId = ntohs(sd->ServiceId);
s->TransportStreamId = ts->TransportStreamId;
s->EitSchedule = sd->EitSchedule;
@@ -64,15 +64,15 @@ SiServicesParser::parseDescriptor_Service(::DVBSI::ServicePtr s, const u_char *
{
s->Type = p[0];
if (p[1]) {
- s->ProviderName = *convert((const char *)(p + 2), p[1]);
+ s->ProviderName = convert((const char *)(p + 2), p[1])->raw();
}
- s->Name = *convert((const char *)(p + 3 + p[1]), p[2 + p[1]]);
+ s->Name = convert((const char *)(p + 3 + p[1]), p[2 + p[1]])->raw();
}
void
SiServicesParser::parseDescriptor_DefaultAuthority(::DVBSI::ServicePtr s, const u_char * p, size_t len)
{
- s->DefaultAuthority = *convert((const char *)p, len);
+ s->DefaultAuthority = convert((const char *)p, len)->raw();
}
template DLL_PUBLIC SiTableParser<TransportStreamDescriptor, ::DVBSI::TransportStreamPtr, int>::SiTableParser(const RequiredContentIds &);
template bool DLL_PUBLIC SiTableParser<TransportStreamDescriptor, ::DVBSI::TransportStreamPtr, int>::ParseInfoTable(const u_char * data, size_t len);
diff --git a/p2pvr/dvb/siParsers/table.cpp b/p2pvr/dvb/siParsers/table.cpp
index e1214bf..19b442a 100644
--- a/p2pvr/dvb/siParsers/table.cpp
+++ b/p2pvr/dvb/siParsers/table.cpp
@@ -25,7 +25,7 @@ SiTableParserBase::~SiTableParserBase()
}
bool
-SiTableParserBase::NewData(const P2PVR::Data & bytes, const Ice::Current&)
+SiTableParserBase::NewData(const P2PVR::Data bytes, const Ice::Current&)
{
currentRawData = &bytes;
return ParseInfoTable(&bytes.front(), bytes.size());
diff --git a/p2pvr/dvb/siParsers/table.h b/p2pvr/dvb/siParsers/table.h
index 30d3614..5cc81b2 100644
--- a/p2pvr/dvb/siParsers/table.h
+++ b/p2pvr/dvb/siParsers/table.h
@@ -34,7 +34,7 @@ class DLL_PUBLIC SiTableParserBase : public P2PVR::RawDataClient {
typedef std::unique_ptr<Glib::ustring> StrPtr;
- bool NewData(const P2PVR::Data & bytes, const Ice::Current&) override;
+ bool NewData(const P2PVR::Data bytes, const Ice::Current&) override;
static StrPtr convert(const char * txt, size_t len);
diff --git a/p2pvr/dvb/unittests/Jamfile.jam b/p2pvr/dvb/unittests/Jamfile.jam
index c3a75ed..c812c5c 100644
--- a/p2pvr/dvb/unittests/Jamfile.jam
+++ b/p2pvr/dvb/unittests/Jamfile.jam
@@ -3,8 +3,7 @@ import testing ;
lib adhocutil ;
lib boost_system ;
lib boost_filesystem ;
-lib IceUtil ;
-lib Ice ;
+lib Ice : : <name>Ice++11 ;
path-constant me : . ;
@@ -15,7 +14,6 @@ exe createSamples :
<library>adhocutil
<library>..//p2pvrdvb
<library>../../ice//p2pvrice
- <library>IceUtil
<library>Ice
<library>boost_system
<library>boost_filesystem
@@ -31,7 +29,6 @@ exe createBroadcast :
<library>..//p2pvrdvb
<library>../../lib//p2pvrlib
<library>../../ice//p2pvrice
- <library>IceUtil
<library>Ice
<library>boost_system
<library>boost_filesystem
diff --git a/p2pvr/dvb/unittests/bindDataHandler.cpp b/p2pvr/dvb/unittests/bindDataHandler.cpp
index 7b25b91..67fba1e 100644
--- a/p2pvr/dvb/unittests/bindDataHandler.cpp
+++ b/p2pvr/dvb/unittests/bindDataHandler.cpp
@@ -7,7 +7,7 @@ BindDataHandler::BindDataHandler(const Callback & cb) :
{
}
-bool BindDataHandler::NewData(const Data & data, const Ice::Current &)
+bool BindDataHandler::NewData(const Data data, const Ice::Current &)
{
return callBack(data);
}
diff --git a/p2pvr/dvb/unittests/bindDataHandler.h b/p2pvr/dvb/unittests/bindDataHandler.h
index acbe6df..01e0738 100644
--- a/p2pvr/dvb/unittests/bindDataHandler.h
+++ b/p2pvr/dvb/unittests/bindDataHandler.h
@@ -12,7 +12,7 @@ class DLL_PUBLIC BindDataHandler : public RawDataClient {
typedef boost::function<bool(const Data &)> Callback;
BindDataHandler(const Callback & cb);
- bool NewData(const Data & data, const Ice::Current &) override;
+ bool NewData(const Data data, const Ice::Current &) override;
private:
const Callback callBack;
diff --git a/p2pvr/dvb/unittests/createBroadcast.cpp b/p2pvr/dvb/unittests/createBroadcast.cpp
index d381641..b7e047b 100644
--- a/p2pvr/dvb/unittests/createBroadcast.cpp
+++ b/p2pvr/dvb/unittests/createBroadcast.cpp
@@ -5,6 +5,7 @@
#include <boost/bind.hpp>
#include <boost/tuple/tuple.hpp>
#include <Ice/ObjectAdapter.h>
+#include <Ice/Initialize.h>
#include <Ice/Service.h>
#include <linux/dvb/frontend.h>
#include "serviceStreamerCore.h"
@@ -29,7 +30,7 @@ class Core {
{
adapter->activate();
- devs = TunersPrx::checkedCast(ic->stringToProxy("Devices:tcp -h defiant -p 10000"));
+ devs = Ice::checkedCast<TunersPrx>(ic->stringToProxy("Devices:tcp -h defiant -p 10000"));
BOOST_REQUIRE(devs);
devs->ice_ping();
}
@@ -39,7 +40,7 @@ class Core {
ic->destroy();
}
- TunersPrx devs;
+ TunersPrxPtr devs;
Ice::CommunicatorPtr ic;
Ice::ObjectAdapterPtr adapter;
@@ -47,10 +48,10 @@ class Core {
class Sampler {
public:
- Sampler(int sid, TunersPrx d, Ice::ObjectAdapterPtr a) :
- patp(a, new DVBSI::BindDataHandler(boost::bind(&Sampler::Handle, this, _1, boost::ref(pat)))),
- pmtp(a, new DVBSI::BindDataHandler(boost::bind(&Sampler::Handle, this, _1, boost::ref(pmt)))),
- vidp(a, new DVBSI::BindDataHandler(boost::bind(&Sampler::Handle, this, _1, boost::ref(vid)))),
+ Sampler(int sid, TunersPrxPtr d, Ice::ObjectAdapterPtr a) :
+ patp(a, std::make_shared<DVBSI::BindDataHandler>(boost::bind(&Sampler::Handle, this, _1, boost::ref(pat)))),
+ pmtp(a, std::make_shared<DVBSI::BindDataHandler>(boost::bind(&Sampler::Handle, this, _1, boost::ref(pmt)))),
+ vidp(a, std::make_shared<DVBSI::BindDataHandler>(boost::bind(&Sampler::Handle, this, _1, boost::ref(vid)))),
ss(sid, patp, pmtp, vidp, d, a)
{
}
@@ -82,10 +83,10 @@ class Sampler {
private:
void Save(Ice::CommunicatorPtr ic, const Sampled & s, const boost::filesystem::path & fileName)
{
- auto out = Ice::createOutputStream(ic);
- out->write(s);
+ Ice::OutputStream out(ic);
+ out.write(s);
Ice::ByteSeq buf;
- out->finished(buf);
+ out.finished(buf);
BOOST_TEST_MESSAGE(rootDir);
auto outFile = fopen((rootDir / fileName).string().c_str(), "w");
BOOST_REQUIRE(outFile);
@@ -101,9 +102,9 @@ BOOST_FIXTURE_TEST_SUITE( X, P2PVR::Testing::Core )
BOOST_AUTO_TEST_CASE( broadcast_sample )
{
- DVBSI::TerrestrialDeliveryPtr transport = new DVBSI::TerrestrialDelivery {
+ DVBSI::TerrestrialDeliveryPtr transport = std::make_shared<DVBSI::TerrestrialDelivery>(
4170, 682000000, 0, true, true, true, 3, 0, 2, 1, 0, 1, true
- };
+ );
BOOST_REQUIRE_EQUAL(transport->Frequency, 682000000);
BOOST_REQUIRE_EQUAL(transport->TransmissionMode, 1);
diff --git a/p2pvr/dvb/unittests/createSamples.cpp b/p2pvr/dvb/unittests/createSamples.cpp
index d0d4890..c36b49d 100644
--- a/p2pvr/dvb/unittests/createSamples.cpp
+++ b/p2pvr/dvb/unittests/createSamples.cpp
@@ -17,7 +17,7 @@ namespace P2PVR {
namespace Testing {
template <class Parser, class ... P>
static
-boost::tuple<Ice::CommunicatorPtr, Ice::ObjectAdapterPtr, IceUtil::Handle<Parser>>
+std::tuple<Ice::CommunicatorPtr, Ice::ObjectAdapterPtr, std::shared_ptr<Parser>>
standardConfig(const P & ... p)
{
Ice::StringSeq params {
@@ -28,8 +28,8 @@ standardConfig(const P & ... p)
};
Ice::CommunicatorPtr ic = Ice::initialize(params);
auto adapter = ic->createObjectAdapterWithEndpoints("Adp", "tcp -p 12000");
- IceUtil::Handle<Parser> parser = new Parser(p...);
- adapter->add(parser, ic->stringToIdentity("parser"));
+ auto parser = std::make_shared<Parser>(p...);
+ adapter->add(parser, Ice::stringToIdentity("parser"));
adapter->activate();
return { ic, adapter, parser };
}
@@ -50,7 +50,7 @@ class SiSampleCollector : public Base {
return false;
}
- bool NewData(const Data & bytes, const Ice::Current & ice) override
+ bool NewData(const Data bytes, const Ice::Current & ice) override
{
std::lock_guard<std::mutex> g(lock);
packets.push_back(bytes);
@@ -66,25 +66,25 @@ class SiSampleCollector : public Base {
template <class Base, class Object, class ... P>
static
-IceUtil::Handle<SiSampleCollector<Base, Object>>
-CaptureAndSave(const boost::filesystem::path & fileName, const boost::function<void(TunersPrx, ::DVBSI::DeliveryPtr, RawDataClientPrx)> & method, const P & ... pp)
+std::shared_ptr<SiSampleCollector<Base, Object>>
+CaptureAndSave(const boost::filesystem::path & fileName, const boost::function<void(TunersPrxPtr, ::DVBSI::DeliveryPtr, RawDataClientPrxPtr)> & method, const P & ... pp)
{
auto icp = standardConfig<SiSampleCollector<Base, Object>>(pp...);
- auto ic = boost::get<0>(icp);
- auto adap = boost::get<1>(icp);
- auto p = boost::get<2>(icp);
+ auto ic = std::get<0>(icp);
+ auto adap = std::get<1>(icp);
+ auto p = std::get<2>(icp);
AdHoc::ScopeExit _([&ic]{ ic->destroy(); });
- auto devs = TunersPrx::checkedCast(ic->stringToProxy("Devices:tcp -h defiant -p 10000"));
- auto parser = RawDataClientPrx::checkedCast(adap->createProxy(ic->stringToIdentity("parser")));
+ auto devs = Ice::checkedCast<TunersPrx>(ic->stringToProxy("Devices:tcp -h defiant -p 10000"));
+ auto parser = Ice::checkedCast<RawDataClientPrx>(adap->createProxy(Ice::stringToIdentity("parser")));
BOOST_REQUIRE(devs);
devs->ice_ping();
BOOST_REQUIRE(parser);
parser->ice_ping();
- ::DVBSI::TerrestrialDeliveryPtr transport = new ::DVBSI::TerrestrialDelivery {
+ ::DVBSI::TerrestrialDeliveryPtr transport = std::make_shared<::DVBSI::TerrestrialDelivery>(
4170, 682000000, 0, true, true, true, 3, 0, 2, 1, 0, 1, true
- };
+ );
BOOST_REQUIRE_EQUAL(transport->Frequency, 682000000);
BOOST_REQUIRE_EQUAL(transport->TransmissionMode, 1);
@@ -99,16 +99,16 @@ CaptureAndSave(const boost::filesystem::path & fileName, const boost::function<v
BOOST_TEST_MESSAGE("Total objects: " << p->objects.size());
BOOST_REQUIRE_GT(p->objects.size(), 0);
- auto out = Ice::createOutputStream(ic);
- out->write(p->packets);
+ Ice::OutputStream out(ic);
+ out.write(p->packets);
Ice::ByteSeq buf;
- out->finished(buf);
+ out.finished(buf);
BOOST_TEST_MESSAGE(rootDir);
auto outFile = fopen((rootDir / fileName).string().c_str(), "w");
BOOST_REQUIRE(outFile);
BOOST_REQUIRE_EQUAL(1, fwrite(&buf.front(), buf.size(), 1, outFile));
BOOST_REQUIRE_EQUAL(0, fclose(outFile));
- return boost::get<2>(icp);
+ return std::get<2>(icp);
}
}
}
@@ -122,7 +122,7 @@ std::list<::DVBSI::TransportStreamPtr> streams;
BOOST_AUTO_TEST_CASE( network_sample )
{
auto parser = CaptureAndSave<SiNetworkInformationParser, ::DVBSI::NetworkPtr>("network.dat",
- [](TunersPrx t, ::DVBSI::DeliveryPtr del, RawDataClientPrx rdc) { t->SendNetworkInformation(del, rdc); });
+ [](TunersPrxPtr t, ::DVBSI::DeliveryPtr del, RawDataClientPrxPtr rdc) { t->SendNetworkInformation(del, rdc); });
network = parser->objects.front();
}
@@ -135,7 +135,7 @@ BOOST_AUTO_TEST_CASE( services_sample )
}
}
auto parser = CaptureAndSave<SiServicesParser, ::DVBSI::TransportStreamPtr>("services.dat",
- [ids](TunersPrx t, ::DVBSI::DeliveryPtr del, RawDataClientPrx rdc) { t->SendServiceDescriptions(del, rdc); }, ids);
+ [ids](TunersPrxPtr t, ::DVBSI::DeliveryPtr del, RawDataClientPrxPtr rdc) { t->SendServiceDescriptions(del, rdc); }, ids);
streams = parser->objects;
streams.erase(std::remove_if(streams.begin(), streams.end(), [ids](const auto & s) {
return ids.find(s->TransportStreamId) == ids.end();
@@ -155,6 +155,6 @@ BOOST_AUTO_TEST_CASE( events_sample )
}
std::cerr << "Added " << ids.size() << std::endl;
CaptureAndSave<SiEpgParser, ::DVBSI::EventPtr>("events.dat",
- [ids](TunersPrx t, ::DVBSI::DeliveryPtr del, RawDataClientPrx rdc) { t->SendEventInformation(del, rdc); }, ids);
+ [ids](TunersPrxPtr t, ::DVBSI::DeliveryPtr del, RawDataClientPrxPtr rdc) { t->SendEventInformation(del, rdc); }, ids);
}
diff --git a/p2pvr/ice/Jamfile.jam b/p2pvr/ice/Jamfile.jam
index 2283438..e91dcf2 100644
--- a/p2pvr/ice/Jamfile.jam
+++ b/p2pvr/ice/Jamfile.jam
@@ -1,12 +1,10 @@
lib slicer : : : : <include>/usr/include/slicer ;
-lib Ice ;
-lib IceUtil ;
+lib Ice : : <name>Ice++11 ;
lib pthread ;
lib p2pvrice :
[ glob *.cpp *.ice ] :
<library>Ice
- <library>IceUtil
<library>pthread
<library>..//adhocutil
<library>slicer
@@ -14,7 +12,6 @@ lib p2pvrice :
: :
<include>.
<library>Ice
- <library>IceUtil
<library>pthread
;
diff --git a/p2pvr/ice/common.ice b/p2pvr/ice/chrono.ice
index 3dc309c..eddda7f 100644
--- a/p2pvr/ice/common.ice
+++ b/p2pvr/ice/chrono.ice
@@ -1,9 +1,9 @@
-#ifndef COMMON_ICE
-#define COMMON_ICE
+#ifndef CHRONO_ICE
+#define CHRONO_ICE
[["cpp:include:boost/date_time/posix_time/posix_time_types.hpp"]]
-module Common {
+module Chrono {
[ "slicer:conversion:boost.posix_time.ptime:ptimeToDateTime:dateTimeToPTime" ]
struct DateTime {
short Year;
diff --git a/p2pvr/ice/commonHelpers.cpp b/p2pvr/ice/chronoHelpers.cpp
index 95d4ad6..058a99f 100644
--- a/p2pvr/ice/commonHelpers.cpp
+++ b/p2pvr/ice/chronoHelpers.cpp
@@ -1,4 +1,4 @@
-#include "commonHelpers.h"
+#include "chronoHelpers.h"
#include <iomanip>
#include <boost/numeric/conversion/cast.hpp>
#include <compileTimeFormatter.h>
@@ -16,16 +16,16 @@ namespace AdHoc {
};
}
-namespace Common {
+namespace Chrono {
AdHocFormatter(DateTimeFormat, "%0p-%0p-%0pT%0p:%0p");
std::ostream &
- operator<<(std::ostream & o, const Common::DateTime & dt)
+ operator<<(std::ostream & o, const DateTime & dt)
{
return DateTimeFormat::write(o, dt.Year, dt.Month, dt.Day, dt.Hour, dt.Minute);
}
std::ostream &
- operator<<(std::ostream & o, const Common::Duration & d)
+ operator<<(std::ostream & o, const Duration & d)
{
if (d.Hours) {
o << d.Hours << "hrs ";
@@ -34,14 +34,14 @@ namespace Common {
return o;
}
- boost::posix_time::ptime operator*(const Common::DateTime & dt)
+ boost::posix_time::ptime operator*(const DateTime & dt)
{
return boost::posix_time::ptime(
boost::gregorian::date(dt.Year, dt.Month, dt.Day),
boost::posix_time::time_duration(dt.Hour, dt.Minute, 0));
}
- boost::posix_time::time_duration operator*(const Common::Duration & d)
+ boost::posix_time::time_duration operator*(const Duration & d)
{
return boost::posix_time::time_duration(d.Hours, d.Minutes, 0);
}
@@ -49,7 +49,7 @@ namespace Common {
namespace boost {
namespace posix_time {
- Common::DateTime operator*(const boost::posix_time::ptime & dt)
+ Chrono::DateTime operator*(const boost::posix_time::ptime & dt)
{
return {
boost::numeric_cast<short, int>(dt.date().year()),
@@ -59,7 +59,7 @@ namespace boost {
boost::numeric_cast<short>(dt.time_of_day().minutes()) };
}
- Common::Duration operator*(const boost::posix_time::time_duration & d)
+ Chrono::Duration operator*(const boost::posix_time::time_duration & d)
{
return {
boost::numeric_cast<short>(d.hours()),
diff --git a/p2pvr/ice/chronoHelpers.h b/p2pvr/ice/chronoHelpers.h
new file mode 100644
index 0000000..69d2b87
--- /dev/null
+++ b/p2pvr/ice/chronoHelpers.h
@@ -0,0 +1,29 @@
+#ifndef ICE_CHRONO_HELPERS_H
+#define ICE_CHRONO_HELPERS_H
+
+#include <chrono.h>
+#include <ostream>
+#include <boost/date_time/posix_time/posix_time_types.hpp>
+#include <visibility.h>
+
+namespace Chrono {
+ DLL_PUBLIC
+ std::ostream &
+ operator<<(std::ostream & o, const Chrono::DateTime & dt);
+
+ DLL_PUBLIC
+ std::ostream &
+ operator<<(std::ostream & o, const Chrono::Duration & d);
+
+ DLL_PUBLIC boost::posix_time::ptime operator*(const Chrono::DateTime &);
+ DLL_PUBLIC boost::posix_time::time_duration operator*(const Chrono::Duration &);
+}
+namespace boost {
+ namespace posix_time {
+ DLL_PUBLIC Chrono::DateTime operator*(const boost::posix_time::ptime &);
+ DLL_PUBLIC Chrono::Duration operator*(const boost::posix_time::time_duration &);
+ }
+}
+
+#endif
+
diff --git a/p2pvr/ice/commonHelpers.h b/p2pvr/ice/commonHelpers.h
deleted file mode 100644
index fb7826d..0000000
--- a/p2pvr/ice/commonHelpers.h
+++ /dev/null
@@ -1,29 +0,0 @@
-#ifndef ICE_COMMON_HELPERS_H
-#define ICE_COMMON_HELPERS_H
-
-#include <common.h>
-#include <ostream>
-#include <boost/date_time/posix_time/posix_time_types.hpp>
-#include <visibility.h>
-
-namespace Common {
- DLL_PUBLIC
- std::ostream &
- operator<<(std::ostream & o, const Common::DateTime & dt);
-
- DLL_PUBLIC
- std::ostream &
- operator<<(std::ostream & o, const Common::Duration & d);
-
- DLL_PUBLIC boost::posix_time::ptime operator*(const Common::DateTime &);
- DLL_PUBLIC boost::posix_time::time_duration operator*(const Common::Duration &);
-}
-namespace boost {
- namespace posix_time {
- DLL_PUBLIC Common::DateTime operator*(const boost::posix_time::ptime &);
- DLL_PUBLIC Common::Duration operator*(const boost::posix_time::time_duration &);
- }
-}
-
-#endif
-
diff --git a/p2pvr/ice/converters.cpp b/p2pvr/ice/converters.cpp
index c4e9332..59cf278 100644
--- a/p2pvr/ice/converters.cpp
+++ b/p2pvr/ice/converters.cpp
@@ -1,27 +1,27 @@
-#include <common.h>
-#include "commonHelpers.h"
+#include <chrono.h>
+#include "chronoHelpers.h"
namespace Slicer {
- Common::DateTime
+ Chrono::DateTime
DLL_PUBLIC ptimeToDateTime(boost::posix_time::ptime const & p)
{
return *p;
}
boost::posix_time::ptime
- DLL_PUBLIC dateTimeToPTime(Common::DateTime const & c)
+ DLL_PUBLIC dateTimeToPTime(Chrono::DateTime const & c)
{
return *c;
}
- Common::Duration
+ Chrono::Duration
DLL_PUBLIC timedurationToDuration(const boost::posix_time::time_duration & td)
{
return *td;
}
boost::posix_time::time_duration
- DLL_PUBLIC durationToTimeDuration(const Common::Duration & td)
+ DLL_PUBLIC durationToTimeDuration(const Chrono::Duration & td)
{
return *td;
}
diff --git a/p2pvr/ice/dvbsi.ice b/p2pvr/ice/dvbsi.ice
index 63123f2..75d44f0 100644
--- a/p2pvr/ice/dvbsi.ice
+++ b/p2pvr/ice/dvbsi.ice
@@ -1,7 +1,7 @@
#ifndef DVISI_ICE
#define DVISI_ICE
-#include "common.ice"
+#include "chrono.ice"
// This attempts to define an ICE representation of domain objects contained
// within the DVB SI (Digital Video Broadcasting specification for Service
@@ -149,8 +149,8 @@ module DVBSI {
optional(1) string Subtitle;
optional(2) string Description;
optional(3) string DescriptionLang;
- Common::DateTime StartTime;
- Common::DateTime StopTime;
+ Chrono::DateTime StartTime;
+ Chrono::DateTime StopTime;
optional(4) short Episode;
optional(5) short Episodes;
optional(6) short Year;
diff --git a/p2pvr/ice/p2pvr.ice b/p2pvr/ice/p2pvr.ice
index 566dd3c..e1263b4 100644
--- a/p2pvr/ice/p2pvr.ice
+++ b/p2pvr/ice/p2pvr.ice
@@ -1,7 +1,7 @@
#ifndef P2PVR_ICE
#define P2PVR_ICE
-#include "common.ice"
+#include "chrono.ice"
#include "dvb.ice"
#include "dvbsi.ice"
@@ -33,8 +33,8 @@ module P2PVR {
optional(3) string Title;
optional(4) string Search;
int Priority = 0;
- Common::Duration Early;
- Common::Duration Late;
+ Chrono::Duration Early;
+ Chrono::Duration Late;
bool Repeats = false;
};
sequence<Schedule> ScheduleList;
@@ -108,8 +108,8 @@ module P2PVR {
idempotent Events EventsOnNow();
idempotent Events EventsInSchedules();
idempotent Events EventsInSchedule(int scheduleId);
- idempotent Events EventsInRange(Common::DateTime from, Common::DateTime to);
- idempotent Events EventSearch(optional(1) string keywords, optional(2) int serviceId, optional(3) Common::DateTime from, optional(4) Common::DateTime to);
+ idempotent Events EventsInRange(Chrono::DateTime from, Chrono::DateTime to);
+ idempotent Events EventSearch(optional(1) string keywords, optional(2) int serviceId, optional(3) Chrono::DateTime from, optional(4) Chrono::DateTime to);
};
interface Recorder {
diff --git a/p2pvr/lib/muxer.cpp b/p2pvr/lib/muxer.cpp
index b4a249c..cf4e2c1 100644
--- a/p2pvr/lib/muxer.cpp
+++ b/p2pvr/lib/muxer.cpp
@@ -6,19 +6,21 @@
#include <boost/algorithm/string/split.hpp>
#include <boost/algorithm/string/classification.hpp>
+using namespace IceTray::Logging;
+
namespace P2PVR {
IceTray::Logging::LoggerPtr Muxer::log(LOGMANAGER()->getLogger<Muxer>());
class MuxerFailure : public DataHandlingException { };
-Muxer::Muxer(const RawDataClientPrx & t, const std::string & cmd) :
+Muxer::Muxer(const RawDataClientPrxPtr & t, const std::string & cmd) :
target(t)
{
std::vector<std::string> params;
boost::algorithm::split(params, cmd, isspace, boost::algorithm::token_compress_on);
fds = ProcessPipesPtr(new AdHoc::System::ProcessPipes(params, true, true, true));
fcntl(fds->fdIn(), F_SETFL, O_NONBLOCK);
- log->messagebf(LOG::INFO, "Muxer::%p started with command '%s'", this, cmd);
+ log->messagebf(LogLevel::INFO, "Muxer::%p started with command '%s'", this, cmd);
}
Muxer::~Muxer()
@@ -28,11 +30,11 @@ Muxer::~Muxer()
while (waitpid(fds->pid(), &status, WNOHANG) == 0) {
ReadMuxerAndSend(5);
}
- log->messagebf(LOG::INFO, "Muxer::%p finished with status %d", this, status);
+ log->messagebf(LogLevel::INFO, "Muxer::%p finished with status %d", this, status);
}
bool
-Muxer::NewData(const Data & data, const Ice::Current &)
+Muxer::NewData(const Data data, const Ice::Current &)
{
std::lock_guard<std::mutex> g(lock);
for (size_t off = 0; off < data.size(); ) {
@@ -42,7 +44,7 @@ Muxer::NewData(const Data & data, const Ice::Current &)
// Send some input
auto w = write(fds->fdIn(), &data[off], data.size() - off);
if (w == -1 && errno != EAGAIN && errno != EWOULDBLOCK) {
- log->messagebf(LOG::ERR, "Muxer::%p write failed (%d:%s)", this, errno, strerror(errno));
+ log->messagebf(LogLevel::ERR, "Muxer::%p write failed (%d:%s)", this, errno, strerror(errno));
throw MuxerFailure();
}
off += w;
@@ -126,7 +128,7 @@ Muxer::ReadMuxerAndSend(int waitTime) const
boost::algorithm::split(lines, buf, boost::algorithm::is_any_of("\r\n\f"), boost::algorithm::token_compress_on);
for (const auto & line : lines) {
if (line.empty()) continue;
- log->messagebf(LOG::INFO, "Muxer::%p > %s", this, line);
+ log->messagebf(LogLevel::INFO, "Muxer::%p > %s", this, line);
}
}
if (closed) return true;
diff --git a/p2pvr/lib/muxer.h b/p2pvr/lib/muxer.h
index 0888268..cd82e34 100644
--- a/p2pvr/lib/muxer.h
+++ b/p2pvr/lib/muxer.h
@@ -11,17 +11,17 @@
namespace P2PVR {
class DLL_PUBLIC Muxer : public RawDataClient {
public:
- Muxer(const RawDataClientPrx & target, const std::string & cmd);
+ Muxer(const RawDataClientPrxPtr & target, const std::string & cmd);
~Muxer();
- bool NewData(const Data &, const Ice::Current &);
+ bool NewData(const Data, const Ice::Current &) override;
private:
DLL_PRIVATE bool ReadWaiting() const;
DLL_PRIVATE bool ReadAvailable() const;
DLL_PRIVATE bool ReadMuxerAndSend(int wait) const;
- const RawDataClientPrx target;
- typedef boost::shared_ptr<AdHoc::System::ProcessPipes> ProcessPipesPtr;
+ const RawDataClientPrxPtr target;
+ typedef std::shared_ptr<AdHoc::System::ProcessPipes> ProcessPipesPtr;
ProcessPipesPtr fds;
mutable std::mutex lock;
diff --git a/p2pvr/lib/serviceStreamer.cpp b/p2pvr/lib/serviceStreamer.cpp
index 2b88643..db12ddb 100644
--- a/p2pvr/lib/serviceStreamer.cpp
+++ b/p2pvr/lib/serviceStreamer.cpp
@@ -1,7 +1,7 @@
#include "serviceStreamer.h"
namespace P2PVR {
-ServiceStreamer::ServiceStreamer(int sid, RawDataClientPrx t, const TunersPrx & d, const SIPrx & s, const Ice::ObjectAdapterPtr & a) :
+ServiceStreamer::ServiceStreamer(int sid, RawDataClientPrxPtr t, const TunersPrxPtr d, const SIPrxPtr s, const Ice::ObjectAdapterPtr & a) :
ServiceStreamerCore(sid, t, t, t, d, a),
si(s)
{
diff --git a/p2pvr/lib/serviceStreamer.h b/p2pvr/lib/serviceStreamer.h
index 165d5a0..0e1b0a5 100644
--- a/p2pvr/lib/serviceStreamer.h
+++ b/p2pvr/lib/serviceStreamer.h
@@ -8,16 +8,16 @@
namespace P2PVR {
class DLL_PUBLIC ServiceStreamer : public ServiceStreamerCore {
public:
- ServiceStreamer(int sid, RawDataClientPrx, const TunersPrx & d, const SIPrx & s, const Ice::ObjectAdapterPtr & a);
+ ServiceStreamer(int sid, RawDataClientPrxPtr, const TunersPrxPtr d, const SIPrxPtr s, const Ice::ObjectAdapterPtr & a);
~ServiceStreamer();
void Start();
private:
- SIPrx si;
+ SIPrxPtr si;
};
-typedef boost::shared_ptr<ServiceStreamer> ServiceStreamerPtr;
+typedef std::shared_ptr<ServiceStreamer> ServiceStreamerPtr;
}
#endif
diff --git a/p2pvr/lib/serviceStreamerCore.cpp b/p2pvr/lib/serviceStreamerCore.cpp
index 1c37027..6733d3b 100644
--- a/p2pvr/lib/serviceStreamerCore.cpp
+++ b/p2pvr/lib/serviceStreamerCore.cpp
@@ -2,18 +2,20 @@
#include <boost/bind.hpp>
#include "bindSiParserHandler.h"
+using namespace IceTray::Logging;
+
namespace P2PVR {
IceTray::Logging::LoggerPtr ServiceStreamerCore::log(LOGMANAGER()->getLogger<ServiceStreamerCore>());
-ServiceStreamerCore::ServiceStreamerCore(int sid, RawDataClientPrx pat, RawDataClientPrx pmt, RawDataClientPrx ser,
- TunersPrx d, Ice::ObjectAdapterPtr a) :
+ServiceStreamerCore::ServiceStreamerCore(int sid, RawDataClientPrxPtr pat, RawDataClientPrxPtr pmt, RawDataClientPrxPtr ser,
+ TunersPrxPtr d, Ice::ObjectAdapterPtr a) :
adapter(a),
devs(d),
patTarget(pat),
pmtTarget(pmt),
serTarget(ser),
- patParser(adapter, new DVBSI::BindSiParserHandler<DVBSI::ProgramAssociationMapPtr, DVBSI::SiProgramAssociationParser>(boost::bind(&ServiceStreamerCore::HandlePAT, this, _1))),
- pmtParser(adapter, new DVBSI::BindSiParserHandler<::DVBSI::ProgramMapPtr, DVBSI::SiProgramMapParser>(boost::bind(&ServiceStreamerCore::HandlePMT, this, _1))),
+ patParser(adapter, std::make_shared<DVBSI::BindSiParserHandler<DVBSI::ProgramAssociationMapPtr, DVBSI::SiProgramAssociationParser>>(boost::bind(&ServiceStreamerCore::HandlePAT, this, _1))),
+ pmtParser(adapter, std::make_shared<DVBSI::BindSiParserHandler<::DVBSI::ProgramMapPtr, DVBSI::SiProgramMapParser>>(boost::bind(&ServiceStreamerCore::HandlePMT, this, _1))),
serviceId(sid),
patHandle(0), pmtStream(0), pmtHandle(0), serviceHandle(0)
{
@@ -29,7 +31,7 @@ ServiceStreamerCore::HandlePAT(const DVBSI::ProgramAssociationMapPtr & pam)
const auto p = pam->find(serviceId);
if (p != pam->end() && p->second != pmtStream) {
pmtStream = p->second;
- log->messagef(LOG::DEBUG, "%s: Got ProgramAssociationMap, pmtStream now = %d", __PRETTY_FUNCTION__, pmtStream);
+ log->messagef(LogLevel::DEBUG, "%s: Got ProgramAssociationMap, pmtStream now = %d", __PRETTY_FUNCTION__, pmtStream);
stopHandle(pmtHandle);
pmtHandle = devs->StartSendingSection(transport, pmtStream, pmtParser);
}
@@ -48,7 +50,7 @@ ServiceStreamerCore::HandlePMT(const ::DVBSI::ProgramMapPtr & pmp)
}
if (strms != streams) {
streams = strms;
- log->messagebf(LOG::DEBUG, "%s: Got ProgramMap, switching to %d streams", __PRETTY_FUNCTION__, streams.size());
+ log->messagebf(LogLevel::DEBUG, "%s: Got ProgramMap, switching to %d streams", __PRETTY_FUNCTION__, streams.size());
stopHandle(serviceHandle);
serviceHandle = devs->StartSendingTS(transport, PacketIds(streams.begin(), streams.end()), serTarget);
}
diff --git a/p2pvr/lib/serviceStreamerCore.h b/p2pvr/lib/serviceStreamerCore.h
index c134fec..32894f1 100644
--- a/p2pvr/lib/serviceStreamerCore.h
+++ b/p2pvr/lib/serviceStreamerCore.h
@@ -14,8 +14,8 @@
namespace P2PVR {
class DLL_PUBLIC ServiceStreamerCore {
public:
- ServiceStreamerCore(int sid, RawDataClientPrx, RawDataClientPrx, RawDataClientPrx,
- TunersPrx, Ice::ObjectAdapterPtr);
+ ServiceStreamerCore(int sid, RawDataClientPrxPtr, RawDataClientPrxPtr, RawDataClientPrxPtr,
+ TunersPrxPtr, Ice::ObjectAdapterPtr);
virtual ~ServiceStreamerCore();
void Start(::DVBSI::DeliveryPtr);
@@ -27,10 +27,10 @@ class DLL_PUBLIC ServiceStreamerCore {
void stopHandle(int & handle);
const Ice::ObjectAdapterPtr & adapter;
- TunersPrx devs;
- RawDataClientPrx patTarget;
- RawDataClientPrx pmtTarget;
- RawDataClientPrx serTarget;
+ TunersPrxPtr devs;
+ RawDataClientPrxPtr patTarget;
+ RawDataClientPrxPtr pmtTarget;
+ RawDataClientPrxPtr serTarget;
TemporaryIceAdapterObject<DVBSI::SiTableParserBase> patParser;
TemporaryIceAdapterObject<DVBSI::SiTableParserBase> pmtParser;
::DVBSI::DeliveryPtr transport;
diff --git a/p2pvr/lib/temporaryIceAdapterObject.h b/p2pvr/lib/temporaryIceAdapterObject.h
index a11da53..1672a39 100644
--- a/p2pvr/lib/temporaryIceAdapterObject.h
+++ b/p2pvr/lib/temporaryIceAdapterObject.h
@@ -8,10 +8,10 @@ namespace P2PVR {
template <typename Object>
class DLL_PUBLIC TemporaryIceAdapterObject {
public:
- TemporaryIceAdapterObject(Ice::ObjectAdapterPtr a, IceUtil::Handle<Object> o) :
+ TemporaryIceAdapterObject(Ice::ObjectAdapterPtr a, std::shared_ptr<Object> o) :
adapter(a),
object(o),
- proxy(Object::ProxyType::checkedCast(adapter->addWithUUID(object)))
+ proxy(Ice::checkedCast<typename Object::ProxyType>(adapter->addWithUUID(object)))
{
if (!proxy) {
throw std::runtime_error("Failed to set up new object proxy");
@@ -26,7 +26,7 @@ class DLL_PUBLIC TemporaryIceAdapterObject {
TemporaryIceAdapterObject(const TemporaryIceAdapterObject &) = delete;
void operator=(const TemporaryIceAdapterObject &) = delete;
- operator typename Object::ProxyType() const
+ operator std::shared_ptr<typename Object::ProxyType>() const
{
return proxy;
}
@@ -41,7 +41,7 @@ class DLL_PUBLIC TemporaryIceAdapterObject {
return proxy;
}
- bool operator==(const typename Object::ProxyType & pr) const
+ bool operator==(const std::shared_ptr<typename Object::ProxyType> & pr) const
{
return pr == proxy;
}
@@ -50,14 +50,14 @@ class DLL_PUBLIC TemporaryIceAdapterObject {
{
if (proxy) {
adapter->remove(proxy->ice_getIdentity());
- proxy = NULL;
+ proxy.reset();
}
}
private:
Ice::ObjectAdapterPtr adapter;
- IceUtil::Handle<Object> object;
- typename Object::ProxyType proxy;
+ std::shared_ptr<Object> object;
+ std::shared_ptr<typename Object::ProxyType> proxy;
};
}