From 2a551c907b3fd0c282bce46970066cfd402a594c Mon Sep 17 00:00:00 2001 From: Dan Goodliffe Date: Thu, 3 Sep 2015 00:29:40 +0100 Subject: Use libadhocutil --- p2pvr/Jamfile.jam | 6 ++---- p2pvr/daemon/Jamfile.jam | 1 + p2pvr/daemon/dbClient.h | 4 ++-- p2pvr/daemon/maintenance.cpp | 2 +- p2pvr/daemon/muxedFileSink.cpp | 19 ++++++++----------- p2pvr/daemon/muxedFileSink.h | 6 ++++-- p2pvr/daemon/recorder.cpp | 6 +++--- p2pvr/daemon/unittests/Jamfile.jam | 16 ++++++++-------- p2pvr/daemon/unittests/mockDefs.cpp | 12 ++++++------ p2pvr/daemon/unittests/testErrorHandling.cpp | 3 +-- p2pvr/daemon/unittests/testMaint.cpp | 3 +-- p2pvr/daemon/unittests/testRecording.cpp | 3 +-- p2pvr/daemon/unittests/testRecordings.cpp | 3 +-- p2pvr/daemon/unittests/testSched.cpp | 2 +- p2pvr/daemon/unittests/testSi.cpp | 2 +- .../daemon/unittests/testSqlSelectDeserializer.cpp | 2 +- p2pvr/daemon/unittests/testp2ice.cpp | 6 +++--- p2pvr/daemonbase/Jamfile.jam | 1 + p2pvr/devices/Jamfile.jam | 2 ++ p2pvr/devices/tuner.cpp | 4 ++-- p2pvr/dvb/Jamfile.jam | 1 + p2pvr/dvb/siParsers/network.cpp | 15 +++++++-------- p2pvr/dvb/unittests/createBroadcast.cpp | 1 - p2pvr/dvb/unittests/createSamples.cpp | 4 ++-- p2pvr/ice/Jamfile.jam | 2 +- p2pvr/ice/commonHelpers.cpp | 1 - p2pvr/lib/Jamfile.jam | 4 ++-- p2pvr/lib/muxer.cpp | 22 ++++++++++------------ p2pvr/lib/muxer.h | 6 ++++-- p2pvr/p2comp/Jamfile.jam | 1 + p2pvr/p2comp/recordingStream.cpp | 1 - p2pvr/p2comp/serviceStream.cpp | 1 - 32 files changed, 78 insertions(+), 84 deletions(-) diff --git a/p2pvr/Jamfile.jam b/p2pvr/Jamfile.jam index 0504b65..9be3180 100644 --- a/p2pvr/Jamfile.jam +++ b/p2pvr/Jamfile.jam @@ -3,6 +3,7 @@ import type ; import generators ; lib boost_utf : : boost_unit_test_framework ; +lib adhocutil : : : : /usr/include/adhocutil ; alias glibmm : : : : "`pkg-config --cflags glibmm-2.4`" @@ -23,12 +24,9 @@ alias p2xml : glibmm : : : ; alias p2sql : glibmm : : : /usr/include/project2/sql + /usr/include/project2/basics "-lp2sql -ldbpp" ; -alias p2lib : glibmm : : : - /usr/include/project2/lib - "-lp2lib" -; alias p2streams : glibmm : : : /usr/include/project2/streams "-lp2streams" diff --git a/p2pvr/daemon/Jamfile.jam b/p2pvr/daemon/Jamfile.jam index a2a20c0..c565234 100644 --- a/p2pvr/daemon/Jamfile.jam +++ b/p2pvr/daemon/Jamfile.jam @@ -21,6 +21,7 @@ lib p2pvrdaemon : ..//p2sql ../devices//p2pvrdevices ../daemonbase//p2pvrdaemonbase + ..//adhocutil ../../libtmdb//tmdb slicer yes diff --git a/p2pvr/daemon/dbClient.h b/p2pvr/daemon/dbClient.h index 84cf5e7..cd846e5 100644 --- a/p2pvr/daemon/dbClient.h +++ b/p2pvr/daemon/dbClient.h @@ -6,7 +6,7 @@ #include #include #include -#include +#include #include #include #include @@ -28,7 +28,7 @@ class DatabaseClient : public virtual CommonObjects { private: const DatabaseClient * client; - ScopeObject so; + AdHoc::ScopeExit so; }; template diff --git a/p2pvr/daemon/maintenance.cpp b/p2pvr/daemon/maintenance.cpp index e3747b3..f6878ec 100644 --- a/p2pvr/daemon/maintenance.cpp +++ b/p2pvr/daemon/maintenance.cpp @@ -64,7 +64,7 @@ Maintenance::ScheduledUpdate() if (!updateRunning) { std::thread update([this] { try { - ScopeObject notRunning([this]{ updateRunning = false; }); + AdHoc::ScopeExit notRunning([this]{ updateRunning = false; }); updateRunning = true; auto si = P2PVR::MaintenancePrx::checkedCast(adapter->createProxy(adapter->getCommunicator()->stringToIdentity("Maintenance"))); time_t now = time(NULL); diff --git a/p2pvr/daemon/muxedFileSink.cpp b/p2pvr/daemon/muxedFileSink.cpp index 3008aa7..16a3588 100644 --- a/p2pvr/daemon/muxedFileSink.cpp +++ b/p2pvr/daemon/muxedFileSink.cpp @@ -1,7 +1,6 @@ #include #include "muxedFileSink.h" #include -#include #include #include #include @@ -19,21 +18,19 @@ MuxedFileSink::MuxedFileSink(const boost::filesystem::path & t, const std::strin c = t.string(); } } - muxerPid = popenrwe(params, fds); - fcntl(fds[0], F_SETFL, O_NONBLOCK); + fds = ProcessPipesPtr(new AdHoc::System::ProcessPipes(params, true, true, true)); + fcntl(fds->fdIn(), F_SETFL, O_NONBLOCK); Logger()->messagebf(LOG_INFO, "Muxer::%p started with command '%s' for %s", this, cmd, t); } MuxedFileSink::~MuxedFileSink() { - close(fds[0]); + close(fds->fdIn()); int status; - while (waitpid(muxerPid, &status, WNOHANG) == 0) { + while (waitpid(fds->pid(), &status, WNOHANG) == 0) { ReadMuxer(5); } Logger()->messagebf(LOG_INFO, "Muxer::%p finished with status %d", this, status); - close(fds[1]); - close(fds[2]); } bool @@ -45,7 +42,7 @@ MuxedFileSink::NewData(const P2PVR::Data & data, const Ice::Current &) if (ReadWaiting()) return true; // Send some input - auto w = write(fds[0], &data[off], data.size() - off); + auto w = write(fds->fdIn(), &data[off], data.size() - off); if (w == -1 && errno != EAGAIN && errno != EWOULDBLOCK) { Logger()->messagebf(LOG_ERR, "Muxer::%p write failed (%d:%s)", this, errno, strerror(errno)); throw MuxerFailure(); @@ -59,7 +56,7 @@ MuxedFileSink::NewData(const P2PVR::Data & data, const Ice::Current &) bool MuxedFileSink::ReadWaiting() const { - pollfd fd = { fds[0], POLLOUT, 0 }; + pollfd fd = { fds->fdIn(), POLLOUT, 0 }; while (true) { auto p = poll(&fd, 1, 0); if (p < 0) { @@ -88,7 +85,7 @@ MuxedFileSink::ReadAvailable() const bool MuxedFileSink::ReadMuxer(int waitTime) const { - pollfd fd[2] = { { fds[1], POLLIN | POLLHUP, 0 }, { fds[2], POLLIN | POLLHUP, 0 } }; + pollfd fd[2] = { { fds->fdOut(), POLLIN | POLLHUP, 0 }, { fds->fdError(), POLLIN | POLLHUP, 0 } }; while (true) { auto p = poll(fd, 2, waitTime); if (p < 0) { @@ -104,7 +101,7 @@ MuxedFileSink::ReadMuxer(int waitTime) const for (int i = 0; i < 2; ++i) { if (fd[i].revents & (POLLIN | POLLHUP)) { P2PVR::Data buf(BUFSIZ); - auto len = read(fds[i + 1], &buf.front(), buf.size()); + auto len = read(fd[i].fd, &buf.front(), buf.size()); if (len == 0) { // ok, proc exit closed = true; diff --git a/p2pvr/daemon/muxedFileSink.h b/p2pvr/daemon/muxedFileSink.h index 9cca6fa..ec22a62 100644 --- a/p2pvr/daemon/muxedFileSink.h +++ b/p2pvr/daemon/muxedFileSink.h @@ -4,6 +4,8 @@ #include #include #include +#include +#include class MuxedFileSink : public P2PVR::RawDataClient { public: @@ -16,8 +18,8 @@ class MuxedFileSink : public P2PVR::RawDataClient { bool ReadWaiting() const; bool ReadAvailable() const; bool ReadMuxer(int wait) const; - int fds[3]; - pid_t muxerPid; + typedef boost::shared_ptr ProcessPipesPtr; + ProcessPipesPtr fds; mutable std::mutex lock; }; diff --git a/p2pvr/daemon/recorder.cpp b/p2pvr/daemon/recorder.cpp index 3c97fc6..e965253 100644 --- a/p2pvr/daemon/recorder.cpp +++ b/p2pvr/daemon/recorder.cpp @@ -4,7 +4,7 @@ #include #include #include -#include +#include #include "serviceStreamer.h" #include "storage.h" #include "muxer.h" @@ -66,14 +66,14 @@ Recorder::StartRecording(P2PVR::SchedulePtr schedule, DVBSI::ServicePtr service, auto id = boost::lexical_cast(boost::uuids::random_generator()()); auto store = storage->OpenForWrite(id); - ScopeObject _store(NULL, NULL, [this,&store,&storage,&id]() { storage->Close(store); storage->Delete(id); }); + AdHoc::ScopeExit _store(NULL, NULL, [this,&store,&storage,&id]() { storage->Close(store); storage->Delete(id); }); auto target = store; P2PVR::RawDataClientPrx muxer; if (!muxerCommand.empty()) { muxer = P2PVR::RawDataClientPrx::checkedCast(adapter->addWithUUID(new Muxer(store, muxerCommand))); target = muxer; } - ScopeObject _muxer(NULL, NULL, [this,&muxer]() { if (muxer) adapter->remove(muxer->ice_getIdentity()); }); + AdHoc::ScopeExit _muxer(NULL, NULL, [this,&muxer]() { if (muxer) adapter->remove(muxer->ice_getIdentity()); }); auto ss = ServiceStreamerPtr(new ServiceStreamer(service->ServiceId, target, adapter->getCommunicator(), adapter)); ss->Start(); diff --git a/p2pvr/daemon/unittests/Jamfile.jam b/p2pvr/daemon/unittests/Jamfile.jam index 0acbd9e..2097b7a 100644 --- a/p2pvr/daemon/unittests/Jamfile.jam +++ b/p2pvr/daemon/unittests/Jamfile.jam @@ -29,7 +29,7 @@ lib testCommon : p2sqlmodPQ ../..//p2sql ../..//p2common - ../..//p2lib + ../..//adhocutil ../..//p2ut ROOT=\"$(me)\" boost_system @@ -70,7 +70,7 @@ run BOOST_TEST_DYN_LINK ../..//p2common ../..//p2basics - ../..//p2lib + ../..//adhocutil ../..//p2xml ../..//p2ut ..//p2pvrdaemon @@ -93,7 +93,7 @@ run BOOST_TEST_DYN_LINK ../..//p2common ../..//p2basics - ../..//p2lib + ../..//adhocutil ../..//p2xml ../..//p2ut ..//p2pvrdaemon @@ -116,7 +116,7 @@ run BOOST_TEST_DYN_LINK ../..//p2common ../..//p2basics - ../..//p2lib + ../..//adhocutil ../..//p2xml ../..//p2ut ..//p2pvrdaemon @@ -140,7 +140,7 @@ run BOOST_TEST_DYN_LINK ../..//p2common ../..//p2basics - ../..//p2lib + ../..//adhocutil ../..//p2xml ../..//p2ut ..//p2pvrdaemon @@ -162,7 +162,7 @@ run BOOST_TEST_DYN_LINK ../..//p2common ../..//p2basics - ../..//p2lib + ../..//adhocutil ../..//p2xml ../..//p2ut ..//p2pvrdaemon @@ -185,7 +185,7 @@ run BOOST_TEST_DYN_LINK ../..//p2common ../..//p2basics - ../..//p2lib + ../..//adhocutil ../..//p2xml ../..//p2ut ..//p2pvrdaemon @@ -208,7 +208,7 @@ run BOOST_TEST_DYN_LINK ../..//p2common ../..//p2basics - ../..//p2lib + ../..//adhocutil ../..//p2xml ../..//p2ut ..//p2pvrdaemon diff --git a/p2pvr/daemon/unittests/mockDefs.cpp b/p2pvr/daemon/unittests/mockDefs.cpp index 466bfe2..76abb80 100644 --- a/p2pvr/daemon/unittests/mockDefs.cpp +++ b/p2pvr/daemon/unittests/mockDefs.cpp @@ -3,22 +3,22 @@ SchemaOnlyMockDatabase::SchemaOnlyMockDatabase() : MockPqDatabase("user=postgres dbname=postgres", "postgres", { - RootDir.parent_path().parent_path() / "datasources" / "schema.sql" }) + rootDir.parent_path().parent_path() / "datasources" / "schema.sql" }) { } StandardMockDatabase::StandardMockDatabase() : MockPqDatabase("user=postgres dbname=postgres", "postgres", { - RootDir.parent_path().parent_path() / "datasources/schema.sql", - RootDir / "datasources" / "data.sql" }) + rootDir.parent_path().parent_path() / "datasources/schema.sql", + rootDir / "datasources" / "data.sql" }) { } StandardMockDatabasePlusOffset::StandardMockDatabasePlusOffset() : MockPqDatabase("user=postgres dbname=postgres", "postgres", { - RootDir.parent_path().parent_path() / "datasources" / "schema.sql", - RootDir / "datasources" / "data.sql", - RootDir / "datasources" / "eventOffset.sql" }) + rootDir.parent_path().parent_path() / "datasources" / "schema.sql", + rootDir / "datasources" / "data.sql", + rootDir / "datasources" / "eventOffset.sql" }) { } diff --git a/p2pvr/daemon/unittests/testErrorHandling.cpp b/p2pvr/daemon/unittests/testErrorHandling.cpp index 9c720a2..b522557 100644 --- a/p2pvr/daemon/unittests/testErrorHandling.cpp +++ b/p2pvr/daemon/unittests/testErrorHandling.cpp @@ -4,7 +4,6 @@ #include #include #include -#include #include #include #include "mockDevices.h" @@ -26,7 +25,7 @@ class Core : public TestAppInstance { ic = Ice::initialize(paramCount, NULL); adapter = ic->createObjectAdapterWithEndpoints("Adp", "tcp -p 12006"); TestOptionsSource::LoadTestOptions({ - { "common.datasourceRoot", (RootDir / "datasources").string() }, + { "common.datasourceRoot", (rootDir / "datasources").string() }, }); adapter->add(new MockDevices(), ic->stringToIdentity("GlobalDevices")); adapter->add(new SI(), ic->stringToIdentity("SI")); diff --git a/p2pvr/daemon/unittests/testMaint.cpp b/p2pvr/daemon/unittests/testMaint.cpp index 0d7d5a0..38c9478 100644 --- a/p2pvr/daemon/unittests/testMaint.cpp +++ b/p2pvr/daemon/unittests/testMaint.cpp @@ -4,7 +4,6 @@ #include #include #include -#include #include #include #include "mockDevices.h" @@ -27,7 +26,7 @@ class Core : public CommonObjects, public TestAppInstance { ic = Ice::initialize(paramCount, NULL); auto adapter = ic->createObjectAdapterWithEndpoints("Adp", "tcp -p 12000"); TestOptionsSource::LoadTestOptions({ - { "common.datasourceRoot", (RootDir / "datasources").string() }, + { "common.datasourceRoot", (rootDir / "datasources").string() }, }); adapter->add(new MockDevices(), ic->stringToIdentity("GlobalDevices")); adapter->add(new MockScheduler(), ic->stringToIdentity("Schedules")); diff --git a/p2pvr/daemon/unittests/testRecording.cpp b/p2pvr/daemon/unittests/testRecording.cpp index 720b868..d3ecee6 100644 --- a/p2pvr/daemon/unittests/testRecording.cpp +++ b/p2pvr/daemon/unittests/testRecording.cpp @@ -4,7 +4,6 @@ #include #include #include -#include #include #include #include "mockDevices.h" @@ -29,7 +28,7 @@ class Core : public CommonObjects, public TestAppInstance { ic = Ice::initialize(paramCount, NULL); adapter = ic->createObjectAdapterWithEndpoints("Adp", "tcp -p 12005"); TestOptionsSource::LoadTestOptions({ - { "common.datasourceRoot", (RootDir / "datasources").string() }, + { "common.datasourceRoot", (rootDir / "datasources").string() }, }); adapter->add(new MockDevices(), ic->stringToIdentity("GlobalDevices")); adapter->add(new MockScheduler(), ic->stringToIdentity("Schedules")); diff --git a/p2pvr/daemon/unittests/testRecordings.cpp b/p2pvr/daemon/unittests/testRecordings.cpp index eb3d5db..ff8f676 100644 --- a/p2pvr/daemon/unittests/testRecordings.cpp +++ b/p2pvr/daemon/unittests/testRecordings.cpp @@ -4,7 +4,6 @@ #include #include #include -#include #include #include #include @@ -25,7 +24,7 @@ class Core : public TestAppInstance { ic = Ice::initialize(paramCount, NULL); auto adapter = ic->createObjectAdapterWithEndpoints("Adp", "tcp -p 12001"); TestOptionsSource::LoadTestOptions({ - { "common.datasourceRoot", (RootDir / "datasources").string() }, + { "common.datasourceRoot", (rootDir / "datasources").string() }, }); adapter->add(new Recordings(), ic->stringToIdentity("Recordings")); adapter->add(new SI(), ic->stringToIdentity("SI")); diff --git a/p2pvr/daemon/unittests/testSched.cpp b/p2pvr/daemon/unittests/testSched.cpp index 3a513d0..9afdaad 100644 --- a/p2pvr/daemon/unittests/testSched.cpp +++ b/p2pvr/daemon/unittests/testSched.cpp @@ -26,7 +26,7 @@ class Core : public TestAppInstance { ic = Ice::initialize(paramCount, NULL); auto adapter = ic->createObjectAdapterWithEndpoints("Adp", "tcp -p 12003"); TestOptionsSource::LoadTestOptions({ - { "common.datasourceRoot", (RootDir / "datasources").string() }, + { "common.datasourceRoot", (rootDir / "datasources").string() }, }); adapter->add(new Schedules(), ic->stringToIdentity("Schedules")); adapter->add(new MockDevices(), ic->stringToIdentity("GlobalDevices")); diff --git a/p2pvr/daemon/unittests/testSi.cpp b/p2pvr/daemon/unittests/testSi.cpp index 6cc810b..9e42e74 100644 --- a/p2pvr/daemon/unittests/testSi.cpp +++ b/p2pvr/daemon/unittests/testSi.cpp @@ -23,7 +23,7 @@ class Core : public TestAppInstance { ic = Ice::initialize(paramCount, NULL); auto adapter = ic->createObjectAdapterWithEndpoints("Adp", "tcp -p 12002"); TestOptionsSource::LoadTestOptions({ - { "common.datasourceRoot", (RootDir / "datasources").string() }, + { "common.datasourceRoot", (rootDir / "datasources").string() }, }); adapter->add(new SI(), ic->stringToIdentity("SI")); adapter->activate(); diff --git a/p2pvr/daemon/unittests/testSqlSelectDeserializer.cpp b/p2pvr/daemon/unittests/testSqlSelectDeserializer.cpp index 2608fd8..077486c 100644 --- a/p2pvr/daemon/unittests/testSqlSelectDeserializer.cpp +++ b/p2pvr/daemon/unittests/testSqlSelectDeserializer.cpp @@ -20,7 +20,7 @@ class TestCommonObjects : public CommonObjects, public TestAppInstance { TestCommonObjects() { TestOptionsSource::LoadTestOptions({ - { "common.datasourceRoot", (RootDir / "datasources").string() }, + { "common.datasourceRoot", (rootDir / "datasources").string() }, }); } }; diff --git a/p2pvr/daemon/unittests/testp2ice.cpp b/p2pvr/daemon/unittests/testp2ice.cpp index 4d29cc9..8229bf5 100644 --- a/p2pvr/daemon/unittests/testp2ice.cpp +++ b/p2pvr/daemon/unittests/testp2ice.cpp @@ -6,9 +6,9 @@ #include #include -const boost::filesystem::path variant = BinDir.leaf(); -const boost::filesystem::path compiler = BinDir.parent_path().leaf(); -const boost::filesystem::path root = RootDir.parent_path().parent_path(); +const boost::filesystem::path variant = binDir.leaf(); +const boost::filesystem::path compiler = binDir.parent_path().leaf(); +const boost::filesystem::path root = rootDir.parent_path().parent_path(); const boost::filesystem::path iceroot = root / "ice"; static diff --git a/p2pvr/daemonbase/Jamfile.jam b/p2pvr/daemonbase/Jamfile.jam index d25bdcf..f02a172 100644 --- a/p2pvr/daemonbase/Jamfile.jam +++ b/p2pvr/daemonbase/Jamfile.jam @@ -14,6 +14,7 @@ lib p2pvrdaemonbase : ..//p2common ../lib//p2pvrlib ../ice//p2pvrice + ..//adhocutil ../ice//p2pvrice : : ../ice//p2pvrice diff --git a/p2pvr/devices/Jamfile.jam b/p2pvr/devices/Jamfile.jam index 8e18afa..f39256b 100644 --- a/p2pvr/devices/Jamfile.jam +++ b/p2pvr/devices/Jamfile.jam @@ -23,6 +23,7 @@ lib p2pvrdevices : ../ice//p2pvrice ../lib//p2pvrlib ..//p2common + ..//adhocutil ../ice//p2pvrice : : boost_filesystem @@ -56,6 +57,7 @@ lib p2pvrMockTuner : ../ice//p2pvrice ../lib//p2pvrlib ..//p2common + ..//adhocutil ../ice//p2pvrice : : boost_filesystem diff --git a/p2pvr/devices/tuner.cpp b/p2pvr/devices/tuner.cpp index ee1625a..ea3ccad 100644 --- a/p2pvr/devices/tuner.cpp +++ b/p2pvr/devices/tuner.cpp @@ -5,7 +5,6 @@ #include #include #include -#include #include #include #include @@ -18,7 +17,8 @@ class FrontendNotSupported : public NotSupported { public: FrontendNotSupported(fe_type t) : NotSupported(stringbf("Frontend not supported: %s", t)) - { } + { + } }; Tuner::Tuner(const boost::filesystem::path & df) : diff --git a/p2pvr/dvb/Jamfile.jam b/p2pvr/dvb/Jamfile.jam index 2dbbbda..e71093a 100644 --- a/p2pvr/dvb/Jamfile.jam +++ b/p2pvr/dvb/Jamfile.jam @@ -7,6 +7,7 @@ lib p2pvrdvb : [ glob-tree *.cpp : unittests ] : ../ice//p2pvrice + ..//adhocutil ../ice//p2pvrice : : ../ice//p2pvrice diff --git a/p2pvr/dvb/siParsers/network.cpp b/p2pvr/dvb/siParsers/network.cpp index b91da1a..6527d58 100644 --- a/p2pvr/dvb/siParsers/network.cpp +++ b/p2pvr/dvb/siParsers/network.cpp @@ -3,7 +3,6 @@ #include #include #include -#include struct NetworkStreamsHeader { #if __BYTE_ORDER__ == __ORDER_BIG_ENDIAN__ @@ -219,16 +218,16 @@ SiNetworkInformationParser::parseDescriptor_TerrestrialDelivery(DVBSI::NetworkTr DVBSI::TerrestrialDeliveryPtr td = new DVBSI::TerrestrialDelivery; td->Frequency = ((uint64_t)ntohl(tdd->Frequency)) * 10; td->TransportStreamId = nts->TransportStreamId; - td->Bandwidth = safeMapLookup(tbandwidths, tdd->Bandwidth); + td->Bandwidth = AdHoc::safeMapLookup(tbandwidths, tdd->Bandwidth); td->Priority = tdd->Priority; td->TimeSlicing = tdd->TimeSlicing; td->MpeFec = tdd->MpeFec; - td->Constellation = safeMapLookup(tconstellations, tdd->Constellation); - td->Hierarchy = safeMapLookup(thierarchies, tdd->Hierarchy); - td->CodeRateHP = safeMapLookup(tcoderates, tdd->CodeRateHP); - td->CodeRateLP = safeMapLookup(tcoderates, tdd->CodeRateLP); - td->GuardInterval = safeMapLookup(tguardintervals, tdd->GuardInterval); - td->TransmissionMode = safeMapLookup(ttransmitmodes, tdd->TransmissionMode); + td->Constellation = AdHoc::safeMapLookup(tconstellations, tdd->Constellation); + td->Hierarchy = AdHoc::safeMapLookup(thierarchies, tdd->Hierarchy); + td->CodeRateHP = AdHoc::safeMapLookup(tcoderates, tdd->CodeRateHP); + td->CodeRateLP = AdHoc::safeMapLookup(tcoderates, tdd->CodeRateLP); + td->GuardInterval = AdHoc::safeMapLookup(tguardintervals, tdd->GuardInterval); + td->TransmissionMode = AdHoc::safeMapLookup(ttransmitmodes, tdd->TransmissionMode); td->OtherFrequencyFlag = tdd->OtherFrequencyFlag; nts->Terrestrial = td; } diff --git a/p2pvr/dvb/unittests/createBroadcast.cpp b/p2pvr/dvb/unittests/createBroadcast.cpp index c65c9ad..1b13d37 100644 --- a/p2pvr/dvb/unittests/createBroadcast.cpp +++ b/p2pvr/dvb/unittests/createBroadcast.cpp @@ -7,7 +7,6 @@ #include #include #include -#include #include #include "serviceStreamerCore.h" #include "bindDataHandler.h" diff --git a/p2pvr/dvb/unittests/createSamples.cpp b/p2pvr/dvb/unittests/createSamples.cpp index 1bb8f92..b9f2aaa 100644 --- a/p2pvr/dvb/unittests/createSamples.cpp +++ b/p2pvr/dvb/unittests/createSamples.cpp @@ -6,7 +6,7 @@ #include #include #include -#include +#include #include #include #include @@ -70,7 +70,7 @@ CaptureAndSave(const boost::filesystem::path & fileName, const boost::function(icp); auto adap = boost::get<1>(icp); auto p = boost::get<2>(icp); - ScopeObject _([&ic]{ ic->destroy(); }); + ScopeExit _([&ic]{ ic->destroy(); }); auto devs = P2PVR::DevicesPrx::checkedCast(ic->stringToProxy("Devices:tcp -h defiant -p 10000")); auto parser = P2PVR::RawDataClientPrx::checkedCast(adap->createProxy(ic->stringToIdentity("parser"))); diff --git a/p2pvr/ice/Jamfile.jam b/p2pvr/ice/Jamfile.jam index 5720bf1..ca27324 100644 --- a/p2pvr/ice/Jamfile.jam +++ b/p2pvr/ice/Jamfile.jam @@ -9,7 +9,7 @@ lib p2pvrice : IceUtil pthread ..//p2common - ..//p2lib + ..//adhocutil ..//p2ice slicer yes diff --git a/p2pvr/ice/commonHelpers.cpp b/p2pvr/ice/commonHelpers.cpp index 6ad120b..9344438 100644 --- a/p2pvr/ice/commonHelpers.cpp +++ b/p2pvr/ice/commonHelpers.cpp @@ -1,5 +1,4 @@ #include "commonHelpers.h" -#include #include namespace Common { diff --git a/p2pvr/lib/Jamfile.jam b/p2pvr/lib/Jamfile.jam index 2083c30..31974b7 100644 --- a/p2pvr/lib/Jamfile.jam +++ b/p2pvr/lib/Jamfile.jam @@ -6,7 +6,7 @@ cpp-pch pch : pch.hpp : boost_system boost_filesystem ..//p2common - ..//p2lib + ..//adhocutil ../ice//p2pvrice ; @@ -19,7 +19,7 @@ lib p2pvrlib : ../ice//p2pvrice ../dvb//p2pvrdvb ..//p2common - ..//p2lib + ..//adhocutil ../ice//p2pvrice slicer : : diff --git a/p2pvr/lib/muxer.cpp b/p2pvr/lib/muxer.cpp index 15152a2..cfec6d0 100644 --- a/p2pvr/lib/muxer.cpp +++ b/p2pvr/lib/muxer.cpp @@ -1,7 +1,7 @@ #include #include "muxer.h" #include -#include +#include #include #include #include @@ -15,21 +15,19 @@ Muxer::Muxer(const P2PVR::RawDataClientPrx & t, const std::string & cmd) : { std::vector params; boost::algorithm::split(params, cmd, isspace, boost::algorithm::token_compress_on); - muxerPid = popenrwe(params, fds); - fcntl(fds[0], F_SETFL, O_NONBLOCK); + fds = ProcessPipesPtr(new AdHoc::System::ProcessPipes(params, true, true, true)); + fcntl(fds->fdIn(), F_SETFL, O_NONBLOCK); Logger()->messagebf(LOG_INFO, "Muxer::%p started with command '%s'", this, cmd); } Muxer::~Muxer() { - close(fds[0]); + close(fds->fdIn()); int status; - while (waitpid(muxerPid, &status, WNOHANG) == 0) { + while (waitpid(fds->pid(), &status, WNOHANG) == 0) { ReadMuxerAndSend(5); } Logger()->messagebf(LOG_INFO, "Muxer::%p finished with status %d", this, status); - close(fds[1]); - close(fds[2]); } bool @@ -41,7 +39,7 @@ Muxer::NewData(const P2PVR::Data & data, const Ice::Current &) if (ReadWaiting()) return true; // Send some input - auto w = write(fds[0], &data[off], data.size() - off); + auto w = write(fds->fdIn(), &data[off], data.size() - off); if (w == -1 && errno != EAGAIN && errno != EWOULDBLOCK) { Logger()->messagebf(LOG_ERR, "Muxer::%p write failed (%d:%s)", this, errno, strerror(errno)); throw MuxerFailure(); @@ -55,7 +53,7 @@ Muxer::NewData(const P2PVR::Data & data, const Ice::Current &) bool Muxer::ReadWaiting() const { - pollfd fd = { fds[0], POLLOUT, 0 }; + pollfd fd = { fds->fdIn(), POLLOUT, 0 }; while (true) { auto p = poll(&fd, 1, 0); if (p < 0) { @@ -84,7 +82,7 @@ Muxer::ReadAvailable() const bool Muxer::ReadMuxerAndSend(int waitTime) const { - pollfd fd[2] = { { fds[1], POLLIN | POLLHUP, 0 }, { fds[2], POLLIN | POLLHUP, 0 } }; + pollfd fd[2] = { { fds->fdOut(), POLLIN | POLLHUP, 0 }, { fds->fdError(), POLLIN | POLLHUP, 0 } }; while (true) { auto p = poll(fd, 2, waitTime); if (p < 0) { @@ -99,7 +97,7 @@ Muxer::ReadMuxerAndSend(int waitTime) const bool closed = false; if (fd[0].revents & (POLLIN | POLLHUP)) { P2PVR::Data buf(BUFSIZ); - auto len = read(fds[1], &buf.front(), buf.size()); + auto len = read(fds->fdOut(), &buf.front(), buf.size()); if (len == 0) { // ok, proc exit closed = true; @@ -113,7 +111,7 @@ Muxer::ReadMuxerAndSend(int waitTime) const } if (fd[1].revents & (POLLIN | POLLHUP)) { P2PVR::Data buf(BUFSIZ); - auto len = read(fds[2], &buf.front(), buf.size()); + auto len = read(fds->fdError(), &buf.front(), buf.size()); if (len == 0) { // ok, proc exit closed = true; diff --git a/p2pvr/lib/muxer.h b/p2pvr/lib/muxer.h index 3a492bd..cf0db1c 100644 --- a/p2pvr/lib/muxer.h +++ b/p2pvr/lib/muxer.h @@ -3,6 +3,8 @@ #include #include +#include +#include class Muxer : public P2PVR::RawDataClient { public: @@ -16,8 +18,8 @@ class Muxer : public P2PVR::RawDataClient { bool ReadAvailable() const; bool ReadMuxerAndSend(int wait) const; const P2PVR::RawDataClientPrx target; - int fds[3]; - pid_t muxerPid; + typedef boost::shared_ptr ProcessPipesPtr; + ProcessPipesPtr fds; mutable std::mutex lock; }; diff --git a/p2pvr/p2comp/Jamfile.jam b/p2pvr/p2comp/Jamfile.jam index 6a847b7..10b7fea 100644 --- a/p2pvr/p2comp/Jamfile.jam +++ b/p2pvr/p2comp/Jamfile.jam @@ -6,5 +6,6 @@ lib p2pvrp2comp : ..//p2streams ..//p2ice ..//p2cgi + ..//adhocutil ../ice//p2pvrice ; diff --git a/p2pvr/p2comp/recordingStream.cpp b/p2pvr/p2comp/recordingStream.cpp index b77a2ce..74d8ba0 100644 --- a/p2pvr/p2comp/recordingStream.cpp +++ b/p2pvr/p2comp/recordingStream.cpp @@ -1,6 +1,5 @@ #include #include -#include #include #include "streamSinkWrapper.h" #include "streamBase.h" diff --git a/p2pvr/p2comp/serviceStream.cpp b/p2pvr/p2comp/serviceStream.cpp index 02d19d1..323234f 100644 --- a/p2pvr/p2comp/serviceStream.cpp +++ b/p2pvr/p2comp/serviceStream.cpp @@ -2,7 +2,6 @@ #include #include #include -#include #include #include #include -- cgit v1.2.3