5 #if HAVE_DVB_API_VERSION < 3
6 #include <ost/frontend.h>
7 #define FRONTENDPARAMETERS FrontendParameters
9 #include <linux/dvb/frontend.h>
10 #define FRONTENDPARAMETERS struct dvb_frontend_parameters
12 #include <lib/dvb/frontendparms.h>
13 #include <lib/base/object.h>
14 #include <lib/base/ebase.h>
15 #include <lib/service/service.h>
16 #include <libsig_comp.h>
17 #include <connection.h>
21 std::string m_bouquet_name;
23 typedef std::list<eServiceReference> list;
25 // the following four methods are implemented in db.cpp
26 RESULT flushChanges();
27 RESULT addService(const eServiceReference &);
28 RESULT removeService(const eServiceReference &);
29 RESULT moveService(const eServiceReference &, unsigned int);
32 /* these structures have by intention no operator int() defined.
33 the reason of these structures is to avoid mixing for example
34 a onid and a tsid (as there's no general order for them).
36 defining an operator int() would implicitely convert values
37 between them over the constructor with the int argument.
39 'explicit' doesn't here - eTransportStreamID(eOriginalNetworkID(n))
42 struct eTransportStreamID
47 int get() const { return v; }
48 eTransportStreamID(int i): v(i) { }
49 eTransportStreamID(): v(-1) { }
50 bool operator == (const eTransportStreamID &c) const { return v == c.v; }
51 bool operator != (const eTransportStreamID &c) const { return v != c.v; }
52 bool operator < (const eTransportStreamID &c) const { return v < c.v; }
53 bool operator > (const eTransportStreamID &c) const { return v > c.v; }
61 int get() const { return v; }
62 eServiceID(int i): v(i) { }
63 eServiceID(): v(-1) { }
64 bool operator == (const eServiceID &c) const { return v == c.v; }
65 bool operator != (const eServiceID &c) const { return v != c.v; }
66 bool operator < (const eServiceID &c) const { return v < c.v; }
67 bool operator > (const eServiceID &c) const { return v > c.v; }
70 struct eOriginalNetworkID
75 int get() const { return v; }
76 eOriginalNetworkID(int i): v(i) { }
77 eOriginalNetworkID(): v(-1) { }
78 bool operator == (const eOriginalNetworkID &c) const { return v == c.v; }
79 bool operator != (const eOriginalNetworkID &c) const { return v != c.v; }
80 bool operator < (const eOriginalNetworkID &c) const { return v < c.v; }
81 bool operator > (const eOriginalNetworkID &c) const { return v > c.v; }
89 int get() const { return v; }
90 eDVBNamespace(int i): v(i) { }
91 eDVBNamespace(): v(-1) { }
92 bool operator == (const eDVBNamespace &c) const { return v == c.v; }
93 bool operator != (const eDVBNamespace &c) const { return v != c.v; }
94 bool operator < (const eDVBNamespace &c) const { return v < c.v; }
95 bool operator > (const eDVBNamespace &c) const { return v > c.v; }
100 eDVBNamespace dvbnamespace;
101 eTransportStreamID transport_stream_id;
102 eOriginalNetworkID original_network_id;
104 bool operator==(const eDVBChannelID &c) const
106 return dvbnamespace == c.dvbnamespace &&
107 transport_stream_id == c.transport_stream_id &&
108 original_network_id == c.original_network_id;
111 bool operator<(const eDVBChannelID &c) const
113 if (dvbnamespace < c.dvbnamespace)
115 else if (dvbnamespace == c.dvbnamespace)
117 if (original_network_id < c.original_network_id)
119 else if (original_network_id == c.original_network_id)
120 if (transport_stream_id < c.transport_stream_id)
125 eDVBChannelID(eDVBNamespace dvbnamespace, eTransportStreamID tsid, eOriginalNetworkID onid):
126 dvbnamespace(dvbnamespace), transport_stream_id(tsid), original_network_id(onid)
130 dvbnamespace(-1), transport_stream_id(-1), original_network_id(-1)
133 operator bool() const
135 return (dvbnamespace != -1) && (transport_stream_id != -1) && (original_network_id != -1);
139 struct eServiceReferenceDVB: public eServiceReference
141 int getServiceType() const { return data[0]; }
142 void setServiceType(int service_type) { data[0]=service_type; }
144 eServiceID getServiceID() const { return eServiceID(data[1]); }
145 void setServiceID(eServiceID service_id) { data[1]=service_id.get(); }
147 eTransportStreamID getTransportStreamID() const { return eTransportStreamID(data[2]); }
148 void setTransportStreamID(eTransportStreamID transport_stream_id) { data[2]=transport_stream_id.get(); }
150 eOriginalNetworkID getOriginalNetworkID() const { return eOriginalNetworkID(data[3]); }
151 void setOriginalNetworkID(eOriginalNetworkID original_network_id) { data[3]=original_network_id.get(); }
153 eDVBNamespace getDVBNamespace() const { return eDVBNamespace(data[4]); }
154 void setDVBNamespace(eDVBNamespace dvbnamespace) { data[4]=dvbnamespace.get(); }
156 eServiceReferenceDVB(eDVBNamespace dvbnamespace, eTransportStreamID transport_stream_id, eOriginalNetworkID original_network_id, eServiceID service_id, int service_type)
157 :eServiceReference(eServiceReference::idDVB, 0)
159 setTransportStreamID(transport_stream_id);
160 setOriginalNetworkID(original_network_id);
161 setDVBNamespace(dvbnamespace);
162 setServiceID(service_id);
163 setServiceType(service_type);
166 void set(const eDVBChannelID &chid)
168 setDVBNamespace(chid.dvbnamespace);
169 setOriginalNetworkID(chid.original_network_id);
170 setTransportStreamID(chid.transport_stream_id);
173 void getChannelID(eDVBChannelID &chid) const
175 chid = eDVBChannelID(getDVBNamespace(), getTransportStreamID(), getOriginalNetworkID());
178 eServiceReferenceDVB()
179 :eServiceReference(eServiceReference::idDVB, 0)
185 ////////////////// TODO: we need an interface here, but what exactly?
188 // btw, still implemented in db.cpp. FIX THIS, TOO.
190 class eDVBChannelQuery;
192 class eDVBService: public iStaticServiceInformation
194 DECLARE_REF(eDVBService);
198 cVPID, cAPID, cTPID, cPCRPID, cAC3PID, cacheMax
201 int getCachePID(cacheID);
202 void setCachePID(cacheID, int);
203 bool cacheEmpty() { return m_cache.empty(); }
206 /* m_service_name_sort is uppercase, with special chars removed, to increase sort performance. */
207 std::string m_service_name, m_service_name_sort;
208 std::string m_provider_name;
214 std::map<int,int> m_cache;
215 virtual ~eDVBService();
217 eDVBService &operator=(const eDVBService &);
219 // iStaticServiceInformation
220 RESULT getName(const eServiceReference &ref, std::string &name);
221 RESULT getEvent(const eServiceReference &ref, ePtr<eServiceEvent> &ptr);
222 bool isPlayable(const eServiceReference &ref, const eServiceReference &ignore);
225 int checkFilter(const eServiceReferenceDVB &ref, const eDVBChannelQuery &query);
232 class iDVBFrontendParameters;
234 class iDVBChannelListQuery: public iObject
237 virtual RESULT getNextResult(eServiceReferenceDVB &ref)=0;
238 virtual int compareLessEqual(const eServiceReferenceDVB &a, const eServiceReferenceDVB &b)=0;
241 class eDVBChannelQuery: public iObject
243 DECLARE_REF(eDVBChannelQuery);
260 std::string m_string;
262 eDVBChannelID m_channelid;
264 /* sort is only valid in root, and must be from the enum above. */
266 std::string m_bouquet_name;
268 static RESULT compile(ePtr<eDVBChannelQuery> &res, std::string query);
270 ePtr<eDVBChannelQuery> m_p1, m_p2;
273 class iDVBChannelList: public iObject
276 virtual RESULT addChannelToList(const eDVBChannelID &id, iDVBFrontendParameters *feparm)=0;
277 virtual RESULT removeChannel(const eDVBChannelID &id)=0;
279 virtual RESULT getChannelFrontendData(const eDVBChannelID &id, ePtr<iDVBFrontendParameters> &parm)=0;
281 virtual RESULT addService(const eServiceReferenceDVB &service, eDVBService *service)=0;
282 virtual RESULT getService(const eServiceReferenceDVB &reference, ePtr<eDVBService> &service)=0;
283 virtual RESULT flush()=0;
285 virtual RESULT getBouquet(const eServiceReference &ref, eBouquet* &bouquet)=0;
287 virtual RESULT startQuery(ePtr<iDVBChannelListQuery> &query, eDVBChannelQuery *query, const eServiceReference &source)=0;
290 class iDVBFrontendParameters: public iObject
293 virtual RESULT getSystem(int &type) const = 0;
294 virtual RESULT getDVBS(eDVBFrontendParametersSatellite &p) const = 0;
295 virtual RESULT getDVBC(eDVBFrontendParametersCable &p) const = 0;
296 virtual RESULT getDVBT(eDVBFrontendParametersTerrestrial &p) const = 0;
298 virtual RESULT calculateDifference(const iDVBFrontendParameters *parm, int &diff) const = 0;
299 virtual RESULT getHash(unsigned long &hash) const = 0;
302 #define MAX_DISEQC_LENGTH 16
304 class eDVBDiseqcCommand
308 __u8 data[MAX_DISEQC_LENGTH];
309 #if HAVE_DVB_API_VERSION < 3
315 class iDVBSatelliteEquipmentControl;
316 class eSecCommandList;
318 class iDVBFrontend: public iObject
322 feSatellite, feCable, feTerrestrial
324 virtual RESULT getFrontendType(int &type)=0;
325 virtual RESULT tune(const iDVBFrontendParameters &where)=0;
326 virtual RESULT connectStateChange(const Slot1<void,iDVBFrontend*> &stateChange, ePtr<eConnection> &connection)=0;
334 virtual RESULT getState(int &state)=0;
338 virtual RESULT setTone(int tone)=0;
340 voltageOff, voltage13, voltage18
342 virtual RESULT setVoltage(int voltage)=0;
343 virtual RESULT sendDiseqc(const eDVBDiseqcCommand &diseqc)=0;
344 virtual RESULT sendToneburst(int burst)=0;
345 virtual RESULT setSEC(iDVBSatelliteEquipmentControl *sec)=0;
346 virtual RESULT setSecSequence(const eSecCommandList &list)=0;
347 virtual RESULT getData(int num, int &data)=0;
348 virtual RESULT setData(int num, int val)=0;
350 /* 0 means: not compatible. other values are a priority. */
351 virtual int isCompatibleWith(ePtr<iDVBFrontendParameters> &feparm)=0;
354 class iDVBSatelliteEquipmentControl: public iObject
357 virtual RESULT prepare(iDVBFrontend &frontend, FRONTENDPARAMETERS &parm, eDVBFrontendParametersSatellite &sat, int frontend_id)=0;
358 virtual int canTune(const eDVBFrontendParametersSatellite &feparm, iDVBFrontend *fe, int frontend_id)=0;
359 virtual void setRotorMoving(bool)=0;
367 class iDVBChannel: public iObject
372 state_idle, /* not yet tuned */
373 state_tuning, /* currently tuning (first time) */
374 state_failed, /* tuning failed. */
375 state_unavailable, /* currently unavailable, will be back without further interaction */
377 state_release /* channel is being shut down. */
379 virtual RESULT connectStateChange(const Slot1<void,iDVBChannel*> &stateChange, ePtr<eConnection> &connection)=0;
380 virtual RESULT getState(int &state)=0;
382 /* demux capabilities */
388 virtual RESULT setCIRouting(const eDVBCIRouting &routing)=0;
389 virtual RESULT getDemux(ePtr<iDVBDemux> &demux, int cap=0)=0;
391 /* direct frontend access for raw channels and/or status inquiries. */
392 virtual RESULT getFrontend(ePtr<iDVBFrontend> &frontend)=0;
394 /* use count handling */
395 virtual void AddUse() = 0;
396 virtual void ReleaseUse() = 0;
399 /* signed, so we can express deltas. */
400 typedef long long pts_t;
402 class iDVBPVRChannel: public iDVBChannel
407 state_eof = state_release + 1 /* end-of-file reached. */
410 /* FIXME: there are some very ugly buffer-end and ... related problems */
411 /* so this is VERY UGLY. */
412 virtual RESULT playFile(const char *file) = 0;
414 virtual RESULT getLength(pts_t &pts) = 0;
416 /* we explicitely ask for the decoding demux here because a channel
417 can be shared between multiple decoders.
418 Of couse skipping doesn't make much sense
419 then, but getCurrentPosition does. */
420 virtual RESULT getCurrentPosition(iDVBDemux *decoding_demux, pts_t &pos) = 0;
421 virtual RESULT seekTo(iDVBDemux *decoding_demux, int relative, pts_t &pts) = 0;
422 virtual RESULT seekToPosition(iDVBDemux *decoding_demux, const off_t &pts) = 0;
425 class iDVBSectionReader;
426 class iDVBTSRecorder;
427 class iTSMPEGDecoder;
429 class iDVBDemux: public iObject
432 virtual RESULT createSectionReader(eMainloop *context, ePtr<iDVBSectionReader> &reader)=0;
433 virtual RESULT createTSRecorder(ePtr<iDVBTSRecorder> &recorder)=0;
434 virtual RESULT getMPEGDecoder(ePtr<iTSMPEGDecoder> &reader)=0;
435 virtual RESULT getSTC(pts_t &pts)=0;
436 virtual RESULT getCADemuxID(uint8_t &id)=0;
437 virtual RESULT flush()=0;
440 class iTSMPEGDecoder: public iObject
443 enum { pidDisabled = -1 };
444 /** Set Displayed Video PID */
445 virtual RESULT setVideoPID(int vpid)=0;
447 enum { af_MPEG, af_AC3, af_DTS };
448 /** Set Displayed Audio PID and type */
449 virtual RESULT setAudioPID(int apid, int type)=0;
451 /** Set Sync mode to PCR */
452 virtual RESULT setSyncPCR(int pcrpid)=0;
453 enum { sm_Audio, sm_Video };
454 /** Set Sync mode to either audio or video master */
455 virtual RESULT setSyncMaster(int who)=0;
457 /** Apply settings */
458 virtual RESULT start()=0;
460 /** Freeze frame. Either continue decoding (without display) or halt. */
461 virtual RESULT freeze(int cont)=0;
462 /** Continue after freeze. */
463 virtual RESULT unfreeze()=0;
465 // stop on .. Picture
466 enum { spm_I, spm_Ref, spm_Any };
467 /** Stop on specific decoded picture. For I-Frame display. */
468 virtual RESULT setSinglePictureMode(int when)=0;
470 enum { pkm_B, pkm_PB };
471 /** Fast forward by skipping either B or P/B pictures */
472 virtual RESULT setPictureSkipMode(int what)=0;
474 /** Slow Motion by repeating pictures */
475 virtual RESULT setSlowMotion(int repeat)=0;
477 enum { zoom_Normal, zoom_PanScan, zoom_Letterbox, zoom_Fullscreen };
478 /** Set Zoom. mode *must* be fitting. */
479 virtual RESULT setZoom(int what)=0;