summaryrefslogtreecommitdiff
path: root/p2pvr/devices/localDevices.h
blob: 18452561607833466342fd6c8a5e71c1ba577705 (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
44
45
46
47
48
49
50
51
52
53
54
#ifndef LOCALDEVICES_H
#define LOCALDEVICES_H

// Local devices implements a device collection (P2PVR::Devices) for any devices physically
// attached to the local machine; that is, can be accessed directly through /dev/dvb/adapterX

#include <dvb.h>
#include <options.h>
#include <mutex>
#include <visibility.h>
#include <IceUtil/Timer.h>

class DLL_PUBLIC LocalDevices : public P2PVR::LocalDevices {
	public:
		LocalDevices(Ice::ObjectAdapterPtr adapter, IceUtil::TimerPtr);
		~LocalDevices();

		P2PVR::TunerPrx GetTunerSpecific(const DVBSI::DeliveryPtr &, const Ice::Current &);
		P2PVR::TunerPrx GetTunerAny(const DVBSI::DeliveryPtr &, const Ice::Current &);
		P2PVR::PrivateTunerPrx GetPrivateTuner(short type, const Ice::Current &);
		void ReleaseTuner(const P2PVR::TunerPrx &, const Ice::Current &);
		int TunerCount(const Ice::Current &);

		void Scan(const Ice::Current &);
		void Add(const std::string & frontend, const Ice::Current &);
		void Remove(const std::string & frontend, const Ice::Current &);

		INITOPTIONS;
	private:
		// Reference to global timer
		IceUtil::TimerPtr timer;
		IceUtil::TimerTaskPtr clientCheck;

		// Check that registered clients haven't silently gone away
		DLL_PRIVATE void ClientCheck(Ice::ObjectAdapterPtr adapter);

		class DLL_PRIVATE OpenTuner {
			public:
				OpenTuner(DVBSI::DeliveryPtr, P2PVR::PrivateTunerPrx, bool);

				const bool openedPrivate;
				const DVBSI::DeliveryPtr delivery;
				const P2PVR::PrivateTunerPrx tuner;

				unsigned int clients;
		};
		typedef boost::shared_ptr<OpenTuner> OpenTunerPtr;
		typedef std::map<std::string, OpenTunerPtr> Devices;
		static Devices devices;
		static std::mutex lock;
};

#endif