summaryrefslogtreecommitdiff
path: root/lib/service/servicehdmi.h
blob: 1f8e6647deb0038db1b9ca1dd9492d6503410e4a (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
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
#ifndef __servicehdmi_h
#define __servicehdmi_h

#include <lib/base/message.h>
#include <lib/service/iservice.h>
#include <lib/service/servicedvb.h>
#include <lib/nav/core.h>

class eStaticServiceHDMIInfo;

class eServiceFactoryHDMI: public iServiceHandler
{
	DECLARE_REF(eServiceFactoryHDMI);
public:
	eServiceFactoryHDMI();
	virtual ~eServiceFactoryHDMI();
	enum { id = 0x2000 };

	RESULT play(const eServiceReference &, ePtr<iPlayableService> &ptr);
	RESULT record(const eServiceReference &, ePtr<iRecordableService> &ptr);
	RESULT list(const eServiceReference &, ePtr<iListableService> &ptr);
	RESULT info(const eServiceReference &, ePtr<iStaticServiceInformation> &ptr);
	RESULT offlineOperations(const eServiceReference &, ePtr<iServiceOfflineOperations> &ptr);
	void getNavInstance(ePtr<eNavigation> &nav_instance);
private:
	ePtr<eStaticServiceHDMIInfo> m_service_info;
	ePtr<eNavigation> m_nav_instance;
};

class eStaticServiceHDMIInfo: public iStaticServiceInformation
{
	DECLARE_REF(eStaticServiceHDMIInfo);
	friend class eServiceFactoryHDMI;
	eStaticServiceHDMIInfo();
public:
	RESULT getName(const eServiceReference &ref, std::string &name);
	int getLength(const eServiceReference &ref);
	int getInfo(const eServiceReference &ref, int w);
	int isPlayable(const eServiceReference &ref, const eServiceReference &ignore, bool simulate) { return 1; }
	long long getFileSize(const eServiceReference &ref);
};

class eServiceHDMI: public iPlayableService, public iServiceInformation, public Object
{
	DECLARE_REF(eServiceHDMI);
public:
	virtual ~eServiceHDMI();

	RESULT connectEvent(const Slot2<void, iPlayableService*, int> &event, ePtr<eConnection> &connection);
	RESULT start();
	RESULT stop();
	RESULT setTarget(int target);

	RESULT pause(ePtr<iPauseableService> &ptr) { ptr = 0; return -1; }
	RESULT seek(ePtr<iSeekableService> &ptr) { ptr = 0; return -1; }
	RESULT audioTracks(ePtr<iAudioTrackSelection> &ptr) { ptr = 0; return -1; }
	RESULT audioChannel(ePtr<iAudioChannelSelection> &ptr) { ptr = 0; return -1; }
	RESULT subtitle(ePtr<iSubtitleOutput> &ptr) { ptr = 0; return -1; }
	RESULT audioDelay(ePtr<iAudioDelay> &ptr) { ptr = 0; return -1; }

	RESULT frontendInfo(ePtr<iFrontendInformation> &ptr) { ptr = 0; return -1; }
	RESULT subServices(ePtr<iSubserviceList> &ptr) { ptr = 0; return -1; }
	RESULT timeshift(ePtr<iTimeshiftService> &ptr) { ptr = 0; return -1; }
	RESULT cueSheet(ePtr<iCueSheet> &ptr) { ptr = 0; return -1; }

	RESULT rdsDecoder(ePtr<iRdsDecoder> &ptr) { ptr = 0; return -1; }
	RESULT keys(ePtr<iServiceKeys> &ptr) { ptr = 0; return -1; }
	RESULT stream(ePtr<iStreamableService> &ptr) { ptr = 0; return -1; }
	RESULT streamed(ePtr<iStreamedService> &ptr) { ptr = 0; return -1; }

	RESULT info(ePtr<iServiceInformation>&);

	RESULT getName(std::string &name);
	int getInfo(int w);
	std::string getInfoString(int w);
	PyObject *getInfoObject(int w);

private:
	friend class eServiceFactoryHDMI;
	eServiceHDMI(eServiceReference ref);
	Signal2<void,iPlayableService*, int> m_event;
	eServiceReference m_ref;
	int m_decoder_index;
	ePtr<iTSMPEGDecoder> m_decoder;
};

class eServiceHDMIRecord: public eDVBServiceBase, public iRecordableService, public Object
{
	DECLARE_REF(eServiceHDMIRecord);
public:
	eServiceHDMIRecord(const eServiceReference &ref, ePtr<eNavigation> &nav_instance);
	RESULT connectEvent(const Slot2<void,iRecordableService*,int> &event, ePtr<eConnection> &connection);
	RESULT prepare(const char *filename, time_t begTime, time_t endTime, int eit_event_id, const char *name, const char *descr, const char *tags, bool descramble, bool recordecm);
	RESULT prepareStreaming();
	RESULT start(bool simulate=false);
	RESULT stop();
	RESULT getError(int &error) { error = m_error; return 0; }
	RESULT frontendInfo(ePtr<iFrontendInformation> &ptr);
	RESULT stream(ePtr<iStreamableService> &ptr);
	RESULT subServices(ePtr<iSubserviceList> &ptr);
	RESULT getServiceType(int &serviceType) { serviceType = -1; return -1; };

private:
	enum { stateIdle, statePrepared, stateRecording };
	bool m_simulate;
	int m_state;
	eDVBRecordFileThread *m_thread;
	eServiceReference m_ref;

	int m_recording, m_error;
	std::string m_filename;

	int m_target_fd;
	int m_encoder_fd;
	int m_decoder;
	ePtr<eNavigation> m_nav_instance;

	int doPrepare();
	int doRecord();

	/* events */
	Signal2<void,iRecordableService*,int> m_event;

	/* recorder events */
	void recordEvent(int event);
};

#endif