From 51a338178c8a7d69d3c0affe31941473be9fe367 Mon Sep 17 00:00:00 2001 From: Dan Goodliffe Date: Sun, 18 Jan 2015 19:27:23 +0000 Subject: Refactor decompress into its own function --- p2pvr/devices/mockTuner.cpp | 9 ++++++--- p2pvr/devices/mockTuner.h | 1 + 2 files changed, 7 insertions(+), 3 deletions(-) diff --git a/p2pvr/devices/mockTuner.cpp b/p2pvr/devices/mockTuner.cpp index c7c51a7..fa21b9a 100644 --- a/p2pvr/devices/mockTuner.cpp +++ b/p2pvr/devices/mockTuner.cpp @@ -39,7 +39,7 @@ int MockTuner::GetStatus(const Ice::Current&) return 0; } -void MockTuner::DecompressAndSendPackets(const Ice::ByteSeq & dataxz, const P2PVR::RawDataClientPrx & client, const Ice::Current & ice) const +Ice::ByteSeq MockTuner::Decompress(const Ice::ByteSeq & dataxz) { Logger()->messagebf(LOG_DEBUG, "%s: setup", __PRETTY_FUNCTION__); lzma_stream strm = LZMA_STREAM_INIT; @@ -62,10 +62,13 @@ void MockTuner::DecompressAndSendPackets(const Ice::ByteSeq & dataxz, const P2PV } } while (strm.avail_out == 0); data.shrink_to_fit(); - + return data; +} +void MockTuner::DecompressAndSendPackets(const Ice::ByteSeq & dataxz, const P2PVR::RawDataClientPrx & client, const Ice::Current & ice) const +{ Logger()->messagebf(LOG_DEBUG, "%s: deserialize", __PRETTY_FUNCTION__); std::list packets; - auto istrm = Ice::createInputStream(ice.adapter->getCommunicator(), data); + auto istrm = Ice::createInputStream(ice.adapter->getCommunicator(), Decompress(dataxz)); istrm->read(packets); Logger()->messagebf(LOG_DEBUG, "%s: send", __PRETTY_FUNCTION__); diff --git a/p2pvr/devices/mockTuner.h b/p2pvr/devices/mockTuner.h index 31d12cb..8e0c513 100644 --- a/p2pvr/devices/mockTuner.h +++ b/p2pvr/devices/mockTuner.h @@ -26,6 +26,7 @@ class MockTuner : public P2PVR::PrivateTuner { static void SetEventsSet(int n); protected: + static Ice::ByteSeq Decompress(const Ice::ByteSeq &); void DecompressAndSendPackets(const Ice::ByteSeq &, const P2PVR::RawDataClientPrx &, const Ice::Current&) const; static int eventSet; -- cgit v1.2.3