summaryrefslogtreecommitdiff
path: root/p2pvr/devices
diff options
context:
space:
mode:
authorDan Goodliffe <dan@randomdan.homeip.net>2014-12-17 20:26:42 +0000
committerDan Goodliffe <dan@randomdan.homeip.net>2015-06-13 17:29:36 +0100
commit45c2eba650bb7f9eba43b4f7fcdd3bbccc03747a (patch)
treebe3ac84326db99a484695af53ba70abe848e1b19 /p2pvr/devices
parentAdd tool for creating samples of SI data (diff)
downloadp2pvr-45c2eba650bb7f9eba43b4f7fcdd3bbccc03747a.tar.bz2
p2pvr-45c2eba650bb7f9eba43b4f7fcdd3bbccc03747a.tar.xz
p2pvr-45c2eba650bb7f9eba43b4f7fcdd3bbccc03747a.zip
Add mock tuner with sample SI data
Add test suite for running maintenance jobs
Diffstat (limited to 'p2pvr/devices')
-rw-r--r--p2pvr/devices/Jamfile.jam39
-rw-r--r--p2pvr/devices/mockTuner.cpp121
-rw-r--r--p2pvr/devices/mockTuner.h32
-rw-r--r--p2pvr/devices/sampleSiData/events.datxzbin0 -> 1112856 bytes
-rw-r--r--p2pvr/devices/sampleSiData/network.datxzbin0 -> 1244 bytes
-rw-r--r--p2pvr/devices/sampleSiData/services.datxzbin0 -> 2392 bytes
6 files changed, 191 insertions, 1 deletions
diff --git a/p2pvr/devices/Jamfile.jam b/p2pvr/devices/Jamfile.jam
index a3452a4..365fbbd 100644
--- a/p2pvr/devices/Jamfile.jam
+++ b/p2pvr/devices/Jamfile.jam
@@ -1,5 +1,9 @@
+import type ;
+import generators ;
+
lib boost_system ;
lib boost_filesystem ;
+lib lzma ;
cpp-pch pch : pch.hpp :
<library>boost_system
@@ -10,7 +14,7 @@ cpp-pch pch : pch.hpp :
lib p2pvrdevices :
pch
- [ glob-tree *.cpp ]
+ [ glob-tree *.cpp : mockTuner.cpp ]
:
<library>boost_system
<library>boost_filesystem
@@ -25,3 +29,36 @@ lib p2pvrdevices :
<library>boost_system
<include>.
;
+
+type.register DATXZ : datxz ;
+
+generators.register-standard datxz.embed.asm : DATXZ : ASM ;
+
+actions datxz.embed.asm
+{
+ m4 -DNAME="$(2:B)" -DPATH="$(2)" "$(root)/embed.m4" > "$(1)"
+}
+
+IMPORT $(__name__) : datxz.embed.asm : : datxz.embed.asm ;
+
+
+lib p2pvrMockTuner :
+ pch
+ mockTuner.cpp
+ [ glob-tree *.datxz ]
+ :
+ <library>lzma
+ <library>boost_system
+ <library>boost_filesystem
+ <library>../dvb//p2pvrdvb
+ <library>../ice//p2pvrice
+ <library>../lib//p2pvrlib
+ <library>..//p2common
+ <implicit-dependency>../ice//p2pvrice
+ : :
+ <library>boost_filesystem
+ <implicit-dependency>../ice//p2pvrice
+ <library>boost_system
+ <include>.
+ ;
+
diff --git a/p2pvr/devices/mockTuner.cpp b/p2pvr/devices/mockTuner.cpp
new file mode 100644
index 0000000..10e77b7
--- /dev/null
+++ b/p2pvr/devices/mockTuner.cpp
@@ -0,0 +1,121 @@
+#include "mockTuner.h"
+#include <boost/foreach.hpp>
+#include <Ice/Service.h>
+#include <lzma.h>
+#include <logger.h>
+#include <list>
+
+#define ResourceFile(resource) \
+extern "C" { \
+ extern char resource##_start, resource##_end;\
+ extern unsigned int resource##_len; \
+} \
+static const Ice::ByteSeq resource(&resource##_start, &resource##_end);
+
+#define LZMA_ASSERT(ret_xz) \
+ if (ret_xz != LZMA_OK) { \
+ Logger()->messagebf(LOG_ERR, "%s: LZMA error (%d)", __PRETTY_FUNCTION__, ret_xz); \
+ throw P2PVR::DeviceError("LZMA", "Decompressor error", ret_xz); \
+ }
+
+ResourceFile(network);
+ResourceFile(services);
+ResourceFile(events);
+
+void MockTuner::TuneTo(const DVBSI::DeliveryPtr &, const Ice::Current&)
+{
+}
+
+int MockTuner::GetStatus(const Ice::Current&)
+{
+ return 0;
+}
+
+void MockTuner::DecompressAndSendPackets(const Ice::ByteSeq & dataxz, const P2PVR::RawDataClientPrx & client, const Ice::Current & ice) const
+{
+ Logger()->messagebf(LOG_DEBUG, "%s: setup", __PRETTY_FUNCTION__);
+ lzma_stream strm = LZMA_STREAM_INIT;
+ const uint32_t flags = LZMA_TELL_UNSUPPORTED_CHECK | LZMA_CONCATENATED;
+ const uint64_t memory_limit = UINT64_MAX;
+ LZMA_ASSERT(lzma_stream_decoder(&strm, memory_limit, flags));
+ strm.next_in = &dataxz.front();
+ strm.avail_in = dataxz.size();
+ uint8_t buf[BUFSIZ];
+
+ Logger()->messagebf(LOG_DEBUG, "%s: decompress", __PRETTY_FUNCTION__);
+ Ice::ByteSeq data;
+ data.reserve(dataxz.size() * 20);
+ do {
+ strm.next_out = buf;
+ strm.avail_out = BUFSIZ;
+ LZMA_ASSERT(lzma_code(&strm, LZMA_RUN));
+ for (auto idx = 0u; idx < BUFSIZ - strm.avail_out; idx += 1) {
+ data.push_back(buf[idx]);
+ }
+ } while (strm.avail_out == 0);
+ data.shrink_to_fit();
+
+ Logger()->messagebf(LOG_DEBUG, "%s: deserialize", __PRETTY_FUNCTION__);
+ std::list<Ice::ByteSeq> packets;
+ auto istrm = Ice::createInputStream(ice.adapter->getCommunicator(), data);
+ istrm->read(packets);
+
+ Logger()->messagebf(LOG_DEBUG, "%s: send", __PRETTY_FUNCTION__);
+ BOOST_FOREACH(const auto & packet, packets) {
+ client->NewData(packet);
+ }
+
+ Logger()->messagebf(LOG_DEBUG, "%s: complete", __PRETTY_FUNCTION__);
+}
+
+void MockTuner::ScanAndSendNetworkInformation(const P2PVR::RawDataClientPrx & client, const Ice::Current & ice)
+{
+ DecompressAndSendPackets(network, client, ice);
+}
+
+void MockTuner::SendNetworkInformation(const P2PVR::RawDataClientPrx & client, const Ice::Current & ice)
+{
+ DecompressAndSendPackets(network, client, ice);
+}
+
+void MockTuner::SendBouquetAssociations(const P2PVR::RawDataClientPrx &, const Ice::Current&)
+{
+}
+
+void MockTuner::SendServiceDescriptions(const P2PVR::RawDataClientPrx & client, const Ice::Current & ice)
+{
+ DecompressAndSendPackets(services, client, ice);
+}
+
+void MockTuner::SendProgramMap(Ice::Int, const P2PVR::RawDataClientPrx &, const Ice::Current&)
+{
+}
+
+void MockTuner::SendProgramAssociationTable(const P2PVR::RawDataClientPrx &, const Ice::Current&)
+{
+}
+
+void MockTuner::SendEventInformation(const P2PVR::RawDataClientPrx & client, const Ice::Current & ice)
+{
+ DecompressAndSendPackets(events, client, ice);
+}
+
+int MockTuner::StartSendingTS(const P2PVR::PacketIds &, const P2PVR::RawDataClientPrx &, const Ice::Current &)
+{
+ return 0;
+}
+
+int MockTuner::StartSendingSection(Ice::Int, const P2PVR::RawDataClientPrx &, const Ice::Current &)
+{
+ return 0;
+}
+
+void MockTuner::StopSending(int, const Ice::Current &)
+{
+}
+
+Ice::Long MockTuner::GetLastUsedTime(const Ice::Current&)
+{
+ return time(NULL);
+}
+
diff --git a/p2pvr/devices/mockTuner.h b/p2pvr/devices/mockTuner.h
new file mode 100644
index 0000000..220b535
--- /dev/null
+++ b/p2pvr/devices/mockTuner.h
@@ -0,0 +1,32 @@
+#ifndef P2PVR_MOCKTUNER_H
+#define P2PVR_MOCKTUNER_H
+
+#include <dvb.h>
+#include <Ice/BuiltinSequences.h>
+
+class MockTuner : public P2PVR::PrivateTuner {
+ public:
+
+ void TuneTo(const DVBSI::DeliveryPtr &, const Ice::Current&);
+ int GetStatus(const Ice::Current&);
+
+ void ScanAndSendNetworkInformation(const P2PVR::RawDataClientPrx & client, const Ice::Current&);
+ void SendNetworkInformation(const P2PVR::RawDataClientPrx & client, const Ice::Current&);
+ void SendBouquetAssociations(const P2PVR::RawDataClientPrx & client, const Ice::Current&);
+ void SendServiceDescriptions(const P2PVR::RawDataClientPrx & client, const Ice::Current&);
+ void SendProgramMap(Ice::Int pid, const P2PVR::RawDataClientPrx & client, const Ice::Current&);
+ void SendProgramAssociationTable(const P2PVR::RawDataClientPrx & client, const Ice::Current&);
+ void SendEventInformation(const P2PVR::RawDataClientPrx & client, const Ice::Current&);
+
+ int StartSendingTS(const P2PVR::PacketIds & pids, const P2PVR::RawDataClientPrx & client, const Ice::Current &);
+ int StartSendingSection(Ice::Int pid, const P2PVR::RawDataClientPrx & client, const Ice::Current &);
+ void StopSending(int handle, const Ice::Current &);
+
+ Ice::Long GetLastUsedTime(const Ice::Current&);
+
+ protected:
+ void DecompressAndSendPackets(const Ice::ByteSeq &, const P2PVR::RawDataClientPrx &, const Ice::Current&) const;
+};
+
+#endif
+
diff --git a/p2pvr/devices/sampleSiData/events.datxz b/p2pvr/devices/sampleSiData/events.datxz
new file mode 100644
index 0000000..a84d777
--- /dev/null
+++ b/p2pvr/devices/sampleSiData/events.datxz
Binary files differ
diff --git a/p2pvr/devices/sampleSiData/network.datxz b/p2pvr/devices/sampleSiData/network.datxz
new file mode 100644
index 0000000..f2e74cd
--- /dev/null
+++ b/p2pvr/devices/sampleSiData/network.datxz
Binary files differ
diff --git a/p2pvr/devices/sampleSiData/services.datxz b/p2pvr/devices/sampleSiData/services.datxz
new file mode 100644
index 0000000..0961e92
--- /dev/null
+++ b/p2pvr/devices/sampleSiData/services.datxz
Binary files differ