6 #if HAVE_DVB_API_VERSION < 3
7 #include <ost/frontend.h>
8 #define FRONTENDPARAMETERS FrontendParameters
10 #include <linux/dvb/frontend.h>
11 #define FRONTENDPARAMETERS struct dvb_frontend_parameters
13 #include <lib/dvb/frontendparms.h>
14 #include <lib/base/object.h>
15 #include <lib/base/ebase.h>
16 #include <lib/base/elock.h>
17 #include <lib/service/service.h>
18 #include <libsig_comp.h>
19 #include <connection.h>
23 std::string m_bouquet_name;
24 std::string m_filename; // without path.. just name
25 typedef std::list<eServiceReference> list;
27 // the following five methods are implemented in db.cpp
28 RESULT flushChanges();
29 RESULT addService(const eServiceReference &);
30 RESULT removeService(const eServiceReference &);
31 RESULT moveService(const eServiceReference &, unsigned int);
32 RESULT setListName(const std::string &name);
35 /* these structures have by intention no operator int() defined.
36 the reason of these structures is to avoid mixing for example
37 a onid and a tsid (as there's no general order for them).
39 defining an operator int() would implicitely convert values
40 between them over the constructor with the int argument.
42 'explicit' doesn't here - eTransportStreamID(eOriginalNetworkID(n))
45 struct eTransportStreamID
50 int get() const { return v; }
51 eTransportStreamID(int i): v(i) { }
52 eTransportStreamID(): v(-1) { }
53 bool operator == (const eTransportStreamID &c) const { return v == c.v; }
54 bool operator != (const eTransportStreamID &c) const { return v != c.v; }
55 bool operator < (const eTransportStreamID &c) const { return v < c.v; }
56 bool operator > (const eTransportStreamID &c) const { return v > c.v; }
64 int get() const { return v; }
65 eServiceID(int i): v(i) { }
66 eServiceID(): v(-1) { }
67 bool operator == (const eServiceID &c) const { return v == c.v; }
68 bool operator != (const eServiceID &c) const { return v != c.v; }
69 bool operator < (const eServiceID &c) const { return v < c.v; }
70 bool operator > (const eServiceID &c) const { return v > c.v; }
73 struct eOriginalNetworkID
78 int get() const { return v; }
79 eOriginalNetworkID(int i): v(i) { }
80 eOriginalNetworkID(): v(-1) { }
81 bool operator == (const eOriginalNetworkID &c) const { return v == c.v; }
82 bool operator != (const eOriginalNetworkID &c) const { return v != c.v; }
83 bool operator < (const eOriginalNetworkID &c) const { return v < c.v; }
84 bool operator > (const eOriginalNetworkID &c) const { return v > c.v; }
92 int get() const { return v; }
93 eDVBNamespace(int i): v(i) { }
94 eDVBNamespace(): v(-1) { }
95 bool operator == (const eDVBNamespace &c) const { return v == c.v; }
96 bool operator != (const eDVBNamespace &c) const { return v != c.v; }
97 bool operator < (const eDVBNamespace &c) const { return v < c.v; }
98 bool operator > (const eDVBNamespace &c) const { return v > c.v; }
103 eDVBNamespace dvbnamespace;
104 eTransportStreamID transport_stream_id;
105 eOriginalNetworkID original_network_id;
107 bool operator==(const eDVBChannelID &c) const
109 return dvbnamespace == c.dvbnamespace &&
110 transport_stream_id == c.transport_stream_id &&
111 original_network_id == c.original_network_id;
114 bool operator<(const eDVBChannelID &c) const
116 if (dvbnamespace < c.dvbnamespace)
118 else if (dvbnamespace == c.dvbnamespace)
120 if (original_network_id < c.original_network_id)
122 else if (original_network_id == c.original_network_id)
123 if (transport_stream_id < c.transport_stream_id)
128 eDVBChannelID(eDVBNamespace dvbnamespace, eTransportStreamID tsid, eOriginalNetworkID onid):
129 dvbnamespace(dvbnamespace), transport_stream_id(tsid), original_network_id(onid)
133 dvbnamespace(-1), transport_stream_id(-1), original_network_id(-1)
136 operator bool() const
138 return (dvbnamespace != -1) && (transport_stream_id != -1) && (original_network_id != -1);
142 struct eServiceReferenceDVB: public eServiceReference
144 int getServiceType() const { return data[0]; }
145 void setServiceType(int service_type) { data[0]=service_type; }
147 eServiceID getServiceID() const { return eServiceID(data[1]); }
148 void setServiceID(eServiceID service_id) { data[1]=service_id.get(); }
150 eTransportStreamID getTransportStreamID() const { return eTransportStreamID(data[2]); }
151 void setTransportStreamID(eTransportStreamID transport_stream_id) { data[2]=transport_stream_id.get(); }
153 eOriginalNetworkID getOriginalNetworkID() const { return eOriginalNetworkID(data[3]); }
154 void setOriginalNetworkID(eOriginalNetworkID original_network_id) { data[3]=original_network_id.get(); }
156 eDVBNamespace getDVBNamespace() const { return eDVBNamespace(data[4]); }
157 void setDVBNamespace(eDVBNamespace dvbnamespace) { data[4]=dvbnamespace.get(); }
159 eServiceID getParentServiceID() const { return eServiceID(data[5]); }
160 void setParentServiceID( eServiceID sid ) { data[5]=sid.get(); }
162 eTransportStreamID getParentTransportStreamID() const { return eTransportStreamID(data[6]); }
163 void setParentTransportStreamID( eTransportStreamID tsid ) { data[6]=tsid.get(); }
165 eServiceReferenceDVB getParentServiceReference() const
167 eServiceReferenceDVB tmp(*this);
168 if (data[5] && data[6])
170 tmp.data[1] = data[5];
171 tmp.data[2] = data[6];
172 tmp.data[5] = tmp.data[6] = 0;
175 tmp.type = idInvalid;
179 eServiceReferenceDVB(eDVBNamespace dvbnamespace, eTransportStreamID transport_stream_id, eOriginalNetworkID original_network_id, eServiceID service_id, int service_type)
180 :eServiceReference(eServiceReference::idDVB, 0)
182 setTransportStreamID(transport_stream_id);
183 setOriginalNetworkID(original_network_id);
184 setDVBNamespace(dvbnamespace);
185 setServiceID(service_id);
186 setServiceType(service_type);
189 void set(const eDVBChannelID &chid)
191 setDVBNamespace(chid.dvbnamespace);
192 setOriginalNetworkID(chid.original_network_id);
193 setTransportStreamID(chid.transport_stream_id);
196 void getChannelID(eDVBChannelID &chid) const
198 chid = eDVBChannelID(getDVBNamespace(), getTransportStreamID(), getOriginalNetworkID());
201 eServiceReferenceDVB()
202 :eServiceReference(eServiceReference::idDVB, 0)
206 eServiceReferenceDVB(const std::string &string)
207 :eServiceReference(string)
213 ////////////////// TODO: we need an interface here, but what exactly?
216 // btw, still implemented in db.cpp. FIX THIS, TOO.
218 class eDVBChannelQuery;
220 class eDVBService: public iStaticServiceInformation
222 DECLARE_REF(eDVBService);
226 cVPID, cAPID, cTPID, cPCRPID, cAC3PID, cacheMax
229 int getCachePID(cacheID);
230 void setCachePID(cacheID, int);
231 bool cacheEmpty() { return m_cache.empty(); }
234 /* m_service_name_sort is uppercase, with special chars removed, to increase sort performance. */
235 std::string m_service_name, m_service_name_sort;
236 std::string m_provider_name;
243 #if 0 // not yet implemented
244 dxNoSDT=1, // don't get SDT
247 dxNewFound=64, // found in prev scan
249 dxNoDVB=4 // dont use PMT for this service ( use cached pids )
252 bool usePMT() const { return !(m_flags & dxNoDVB); }
255 std::map<int,int> m_cache;
256 virtual ~eDVBService();
258 eDVBService &operator=(const eDVBService &);
260 // iStaticServiceInformation
261 RESULT getName(const eServiceReference &ref, std::string &name);
262 RESULT getEvent(const eServiceReference &ref, ePtr<eServiceEvent> &ptr, time_t start_time);
263 bool isPlayable(const eServiceReference &ref, const eServiceReference &ignore);
266 int checkFilter(const eServiceReferenceDVB &ref, const eDVBChannelQuery &query);
273 class iDVBFrontendParameters;
275 class iDVBChannelListQuery: public iObject
278 virtual RESULT getNextResult(eServiceReferenceDVB &ref)=0;
279 virtual int compareLessEqual(const eServiceReferenceDVB &a, const eServiceReferenceDVB &b)=0;
282 class eDVBChannelQuery: public iObject
284 DECLARE_REF(eDVBChannelQuery);
301 std::string m_string;
303 eDVBChannelID m_channelid;
305 /* sort is only valid in root, and must be from the enum above. */
307 std::string m_bouquet_name;
309 static RESULT compile(ePtr<eDVBChannelQuery> &res, std::string query);
311 ePtr<eDVBChannelQuery> m_p1, m_p2;
314 class iDVBChannelList: public iObject
317 virtual RESULT addChannelToList(const eDVBChannelID &id, iDVBFrontendParameters *feparm)=0;
318 virtual RESULT removeChannel(const eDVBChannelID &id)=0;
320 virtual RESULT getChannelFrontendData(const eDVBChannelID &id, ePtr<iDVBFrontendParameters> &parm)=0;
322 virtual RESULT addService(const eServiceReferenceDVB &service, eDVBService *service)=0;
323 virtual RESULT getService(const eServiceReferenceDVB &reference, ePtr<eDVBService> &service)=0;
324 virtual RESULT flush()=0;
326 virtual RESULT getBouquet(const eServiceReference &ref, eBouquet* &bouquet)=0;
328 virtual RESULT startQuery(ePtr<iDVBChannelListQuery> &query, eDVBChannelQuery *query, const eServiceReference &source)=0;
333 class iDVBFrontendParameters: public iObject
336 iDVBFrontendParameters();
337 ~iDVBFrontendParameters();
340 virtual RESULT getSystem(int &SWIG_OUTPUT) const = 0;
341 virtual RESULT getDVBS(eDVBFrontendParametersSatellite &SWIG_OUTPUT) const = 0;
342 virtual RESULT getDVBC(eDVBFrontendParametersCable &SWIG_OUTPUT) const = 0;
343 virtual RESULT getDVBT(eDVBFrontendParametersTerrestrial &SWIG_OUTPUT) const = 0;
345 virtual RESULT calculateDifference(const iDVBFrontendParameters *parm, int &SWIG_OUTPUT) const = 0;
346 virtual RESULT getHash(unsigned long &SWIG_OUTPUT) const = 0;
349 #define MAX_DISEQC_LENGTH 16
351 class eDVBDiseqcCommand
357 __u8 data[MAX_DISEQC_LENGTH];
358 #if HAVE_DVB_API_VERSION < 3
365 void setCommandString(const char *str);
368 class iDVBSatelliteEquipmentControl;
369 class eSecCommandList;
371 class iDVBFrontend: public iObject
375 feSatellite, feCable, feTerrestrial
377 virtual RESULT getFrontendType(int &SWIG_OUTPUT)=0;
378 virtual RESULT tune(const iDVBFrontendParameters &where)=0;
380 virtual RESULT connectStateChange(const Slot1<void,iDVBFrontend*> &stateChange, ePtr<eConnection> &connection)=0;
389 virtual RESULT getState(int &SWIG_OUTPUT)=0;
393 virtual RESULT setTone(int tone)=0;
395 voltageOff, voltage13, voltage18, voltage13_5, voltage18_5
397 virtual RESULT setVoltage(int voltage)=0;
398 virtual RESULT sendDiseqc(const eDVBDiseqcCommand &diseqc)=0;
399 virtual RESULT sendToneburst(int burst)=0;
401 virtual RESULT setSEC(iDVBSatelliteEquipmentControl *sec)=0;
402 virtual RESULT setSecSequence(const eSecCommandList &list)=0;
405 bitErrorRate, signalPower, signalQuality, Locked, Synced
407 virtual int readFrontendData(int type)=0;
408 virtual PyObject *readTransponderData(bool original)=0;
411 virtual RESULT getData(int num, int &data)=0;
412 virtual RESULT setData(int num, int val)=0;
413 /* 0 means: not compatible. other values are a priority. */
414 virtual int isCompatibleWith(ePtr<iDVBFrontendParameters> &feparm)=0;
417 TEMPLATE_TYPEDEF(ePtr<iDVBFrontend>, iDVBFrontendPtr);
420 class iDVBSatelliteEquipmentControl: public iObject
423 virtual RESULT prepare(iDVBFrontend &frontend, FRONTENDPARAMETERS &parm, const eDVBFrontendParametersSatellite &sat, int frontend_id)=0;
424 virtual int canTune(const eDVBFrontendParametersSatellite &feparm, iDVBFrontend *fe, int frontend_id)=0;
425 virtual void setRotorMoving(bool)=0;
434 class iDVBChannel: public iObject
439 state_idle, /* not yet tuned */
440 state_tuning, /* currently tuning (first time) */
441 state_failed, /* tuning failed. */
442 state_unavailable, /* currently unavailable, will be back without further interaction */
444 state_last_instance, /* just one reference to this channel is left */
445 state_release /* channel is being shut down. */
447 virtual RESULT getState(int &SWIG_OUTPUT)=0;
449 /* direct frontend access for raw channels and/or status inquiries. */
450 virtual RESULT getFrontend(ePtr<iDVBFrontend> &)=0;
453 virtual RESULT getCurrentFrontendParameters(ePtr<iDVBFrontendParameters> &)=0;
456 evtEOF, evtSOF, evtFailed
458 virtual RESULT connectStateChange(const Slot1<void,iDVBChannel*> &stateChange, ePtr<eConnection> &connection)=0;
459 virtual RESULT connectEvent(const Slot2<void,iDVBChannel*,int> &eventChange, ePtr<eConnection> &connection)=0;
461 /* demux capabilities */
467 virtual RESULT setCIRouting(const eDVBCIRouting &routing)=0;
468 virtual RESULT getDemux(ePtr<iDVBDemux> &demux, int cap=0)=0;
470 /* use count handling */
471 virtual void AddUse() = 0;
472 virtual void ReleaseUse() = 0;
475 TEMPLATE_TYPEDEF(eUsePtr<iDVBChannel>, iDVBChannelPtr);
479 /* signed, so we can express deltas. */
481 typedef long long pts_t;
483 class iFilePushScatterGather;
484 class iTSMPEGDecoder;
486 /* note that a cue sheet describes the logical positions. thus
487 everything is specified in pts and not file positions */
489 /* implemented in dvb.cpp */
490 class eCueSheet: public iObject, public Object
492 DECLARE_REF(eCueSheet);
497 void seekTo(int relative, const pts_t &pts);
500 void addSourceSpan(const pts_t &begin, const pts_t &end);
503 void setSkipmode(const pts_t &ratio); /* 90000 is 1:1 */
504 void setDecodingDemux(iDVBDemux *demux, iTSMPEGDecoder *decoder);
506 /* frontend and backend */
510 enum { evtSeek, evtSkipmode, evtSpanChanged };
511 RESULT connectEvent(const Slot1<void, int> &event, ePtr<eConnection> &connection);
513 std::list<std::pair<pts_t,pts_t> > m_spans; /* begin, end */
514 std::list<std::pair<int, pts_t> > m_seek_requests; /* relative, delta */
515 pts_t m_skipmode_ratio;
516 Signal1<void,int> m_event;
517 ePtr<iDVBDemux> m_decoding_demux;
518 ePtr<iTSMPEGDecoder> m_decoder;
521 class iDVBPVRChannel: public iDVBChannel
526 state_eof = state_release + 1 /* end-of-file reached. */
529 /* FIXME: there are some very ugly buffer-end and ... related problems */
530 /* so this is VERY UGLY.
532 ok, it's going to get better. but still...*/
533 virtual RESULT playFile(const char *file) = 0;
534 virtual void stopFile() = 0;
536 virtual void setCueSheet(eCueSheet *cuesheet) = 0;
538 virtual RESULT getLength(pts_t &pts) = 0;
540 /* we explicitely ask for the decoding demux here because a channel
541 can be shared between multiple decoders.
543 virtual RESULT getCurrentPosition(iDVBDemux *decoding_demux, pts_t &pos, int mode) = 0;
544 /* skipping must be done with a cue sheet */
547 class iDVBSectionReader;
548 class iDVBTSRecorder;
549 class iTSMPEGDecoder;
551 class iDVBDemux: public iObject
554 virtual RESULT createSectionReader(eMainloop *context, ePtr<iDVBSectionReader> &reader)=0;
555 virtual RESULT createTSRecorder(ePtr<iDVBTSRecorder> &recorder)=0;
556 virtual RESULT getMPEGDecoder(ePtr<iTSMPEGDecoder> &reader)=0;
557 virtual RESULT getSTC(pts_t &pts, int num=0)=0;
558 virtual RESULT getCADemuxID(uint8_t &id)=0;
559 virtual RESULT flush()=0;
562 class iTSMPEGDecoder: public iObject
565 enum { pidDisabled = -1 };
566 /** Set Displayed Video PID */
567 virtual RESULT setVideoPID(int vpid)=0;
569 enum { af_MPEG, af_AC3, af_DTS };
570 /** Set Displayed Audio PID and type */
571 virtual RESULT setAudioPID(int apid, int type)=0;
573 /** Set Displayed Videotext PID */
574 virtual RESULT setTextPID(int vpid)=0;
576 /** Set Sync mode to PCR */
577 virtual RESULT setSyncPCR(int pcrpid)=0;
578 enum { sm_Audio, sm_Video };
579 /** Set Sync mode to either audio or video master */
580 virtual RESULT setSyncMaster(int who)=0;
582 /** Apply settings */
583 virtual RESULT start()=0;
585 /** Freeze frame. Either continue decoding (without display) or halt. */
586 virtual RESULT freeze(int cont)=0;
587 /** Continue after freeze. */
588 virtual RESULT unfreeze()=0;
590 /** fast forward by skipping frames. 0 is disabled, 2 is twice-the-speed, ... */
591 virtual RESULT setFastForward(int skip=0)=0;
593 // stop on .. Picture
594 enum { spm_I, spm_Ref, spm_Any };
595 /** Stop on specific decoded picture. For I-Frame display. */
596 virtual RESULT setSinglePictureMode(int when)=0;
598 enum { pkm_B, pkm_PB };
599 /** Fast forward by skipping either B or P/B pictures */
600 virtual RESULT setPictureSkipMode(int what)=0;
602 /** Slow Motion by repeating pictures */
603 virtual RESULT setSlowMotion(int repeat)=0;
605 enum { zoom_Normal, zoom_PanScan, zoom_Letterbox, zoom_Fullscreen };
606 /** Set Zoom. mode *must* be fitting. */
607 virtual RESULT setZoom(int what)=0;
609 virtual RESULT setTrickmode(int what) = 0;
611 virtual RESULT getPTS(int what, pts_t &pts) = 0;