summaryrefslogtreecommitdiff
path: root/p2pvr/devices/mockTuner.h
blob: 74578dbcde9bb093803968111412ddbda6d1693a (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
#ifndef P2PVR_MOCKTUNER_H
#define P2PVR_MOCKTUNER_H

#include <dvb.h>
#include <visibility.h>
#include <Ice/BuiltinSequences.h>
#include <boost/thread.hpp>
#include <logger.h>
#include "tuner.h"

namespace P2PVR {
namespace Testing {
class DLL_PUBLIC MockTuner : public DVB::TunerI {
	public:
		MockTuner(const boost::filesystem::path & deviceFrontend, Ice::CommunicatorPtr);

		AdHoc::FileUtils::FileHandle OpenDemux() const override;
		void RequestPID(int, int) const override;
		void RequestTS(const PacketIds &, int fd) const override;

		static void SetEventsSet(int n);

	protected:
		int iopoll(struct pollfd *fds, nfds_t nfds, int timeout) const override;
		ssize_t ioread(int fd, void *buf, size_t count) const override;
		int ioselect(int nfds, fd_set *readfds, fd_set *writefds, fd_set *exceptfds, struct timeval *timeout) const override;

		static Ice::ByteSeq Decompress(const Ice::ByteSeq &);
		static void LZMA_ASSERT(int ret_xz);
		std::list<Ice::ByteSeq> DecompressAndRead(const Ice::ByteSeq &) const;

		Ice::CommunicatorPtr ic;
		// The open fh -> list of DVB packets
		mutable std::map<int, std::list<Ice::ByteSeq>> selectedPackets;

		static int eventSet;
		static IceTray::Logging::LoggerPtr logger;
};
}
}

#endif