bc444b374eb0a301fae14a7de48b99b3cfa3befb
[vuplus_dvbapp] / lib / dvb / idvb.h
1 #ifndef __dvb_idvb_h
2 #define __dvb_idvb_h
3
4 #ifndef SWIG
5
6 #if HAVE_DVB_API_VERSION < 3
7 #include <ost/frontend.h>
8 #define FRONTENDPARAMETERS FrontendParameters
9 #else
10 #include <linux/dvb/frontend.h>
11 #include <linux/dvb/video.h>
12 #define FRONTENDPARAMETERS struct dvb_frontend_parameters
13 #endif
14 #include <lib/dvb/frontendparms.h>
15 #include <lib/base/object.h>
16 #include <lib/base/ebase.h>
17 #include <lib/base/elock.h>
18 #include <lib/base/itssource.h>
19 #include <lib/service/service.h>
20 #include <libsig_comp.h>
21 #include <connection.h>
22
23 #if defined(__GNUC__) && ((__GNUC__ == 3 && __GNUC_MINOR__ >= 1) || __GNUC__ == 4 )  // check if gcc version >= 3.1
24 #include <ext/slist>
25 #define CAID_LIST __gnu_cxx::slist<uint16_t>
26 #else
27 #include <slist>
28 #define CAID_LIST std::slist<uint16_t>
29 #endif
30
31 #ifndef DMX_FILTER_SIZE
32 #define DMX_FILTER_SIZE   16
33 #endif
34
35 struct eDVBSectionFilterMask
36 {
37         int pid;
38                 /* mode is 0 for positive, 1 for negative filtering */
39         __u8 data[DMX_FILTER_SIZE], mask[DMX_FILTER_SIZE], mode[DMX_FILTER_SIZE];
40         enum {
41                 rfCRC=1,
42                 rfNoAbort=2
43         };
44         int flags;
45 };
46
47 struct eDVBTableSpec
48 {
49         int pid, tid, tidext, tid_mask, tidext_mask;
50         int version;
51         int timeout;        /* timeout in ms */
52         enum
53         {
54                 tfInOrder=1,
55                 /*
56                         tfAnyVersion      filter ANY version
57                         0                 filter all EXCEPT given version (negative filtering)
58                         tfThisVersion     filter only THIS version
59                 */
60                 tfAnyVersion=2,
61                 tfThisVersion=4,
62                 tfHaveTID=8,
63                 tfHaveTIDExt=16,
64                 tfCheckCRC=32,
65                 tfHaveTimeout=64,
66                 tfHaveTIDMask=128,
67                 tfHaveTIDExtMask=256
68         };
69         int flags;
70 };
71
72 struct eBouquet
73 {
74         std::string m_bouquet_name;
75         std::string m_filename;  // without path.. just name
76         typedef std::list<eServiceReference> list;
77         list m_services;
78 // the following five methods are implemented in db.cpp
79         RESULT flushChanges();
80         RESULT addService(const eServiceReference &, eServiceReference before=eServiceReference());
81         RESULT removeService(const eServiceReference &);
82         RESULT moveService(const eServiceReference &, unsigned int);
83         RESULT setListName(const std::string &name);
84 };
85
86                 /* these structures have by intention no operator int() defined.
87                    the reason of these structures is to avoid mixing for example
88                    a onid and a tsid (as there's no general order for them).
89                    
90                    defining an operator int() would implicitely convert values
91                    between them over the constructor with the int argument.
92                    
93                    'explicit' doesn't here - eTransportStreamID(eOriginalNetworkID(n)) 
94                    would still work. */
95
96 struct eTransportStreamID
97 {
98 private:
99         int v;
100 public:
101         int get() const { return v; }
102         eTransportStreamID(int i): v(i) { }
103         eTransportStreamID(): v(-1) { }
104         bool operator == (const eTransportStreamID &c) const { return v == c.v; }
105         bool operator != (const eTransportStreamID &c) const { return v != c.v; }
106         bool operator < (const eTransportStreamID &c) const { return v < c.v; }
107         bool operator > (const eTransportStreamID &c) const { return v > c.v; }
108 };
109
110 struct eServiceID
111 {
112 private:
113         int v;
114 public:
115         int get() const { return v; }
116         eServiceID(int i): v(i) { }
117         eServiceID(): v(-1) { }
118         bool operator == (const eServiceID &c) const { return v == c.v; }
119         bool operator != (const eServiceID &c) const { return v != c.v; }
120         bool operator < (const eServiceID &c) const { return v < c.v; }
121         bool operator > (const eServiceID &c) const { return v > c.v; }
122 };
123
124 struct eOriginalNetworkID
125 {
126 private:
127         int v;
128 public:
129         int get() const { return v; }
130         eOriginalNetworkID(int i): v(i) { }
131         eOriginalNetworkID(): v(-1) { }
132         bool operator == (const eOriginalNetworkID &c) const { return v == c.v; }
133         bool operator != (const eOriginalNetworkID &c) const { return v != c.v; }
134         bool operator < (const eOriginalNetworkID &c) const { return v < c.v; }
135         bool operator > (const eOriginalNetworkID &c) const { return v > c.v; }
136 };
137
138 struct eDVBNamespace
139 {
140 private:
141         int v;
142 public:
143         int get() const { return v; }
144         eDVBNamespace(int i): v(i) { }
145         eDVBNamespace(): v(-1) { }
146         bool operator == (const eDVBNamespace &c) const { return v == c.v; }
147         bool operator != (const eDVBNamespace &c) const { return v != c.v; }
148         bool operator < (const eDVBNamespace &c) const { return v < c.v; }
149         bool operator > (const eDVBNamespace &c) const { return v > c.v; }
150 };
151
152 struct eDVBChannelID
153 {
154         eDVBNamespace dvbnamespace;
155         eTransportStreamID transport_stream_id;
156         eOriginalNetworkID original_network_id;
157         
158         bool operator==(const eDVBChannelID &c) const
159         {
160                 return dvbnamespace == c.dvbnamespace &&
161                         transport_stream_id == c.transport_stream_id &&
162                         original_network_id == c.original_network_id;
163         }
164         
165         bool operator<(const eDVBChannelID &c) const
166         {
167                 if (dvbnamespace < c.dvbnamespace)
168                         return 1;
169                 else if (dvbnamespace == c.dvbnamespace)
170                 {
171                         if (original_network_id < c.original_network_id)
172                                 return 1;
173                         else if (original_network_id == c.original_network_id)
174                                 if (transport_stream_id < c.transport_stream_id)
175                                         return 1;
176                 }
177                 return 0;
178         }
179         eDVBChannelID(eDVBNamespace dvbnamespace, eTransportStreamID tsid, eOriginalNetworkID onid): 
180                         dvbnamespace(dvbnamespace), transport_stream_id(tsid), original_network_id(onid)
181         {
182         }
183         eDVBChannelID():
184                         dvbnamespace(-1), transport_stream_id(-1), original_network_id(-1)
185         {
186         }
187         operator bool() const
188         {
189                 return (dvbnamespace != -1) && (transport_stream_id != -1) && (original_network_id != -1);
190         }
191 };
192
193 struct eServiceReferenceDVB: public eServiceReference
194 {
195         int getServiceType() const { return data[0]; }
196         void setServiceType(int service_type) { data[0]=service_type; }
197
198         eServiceID getServiceID() const { return eServiceID(data[1]); }
199         void setServiceID(eServiceID service_id) { data[1]=service_id.get(); }
200
201         eTransportStreamID getTransportStreamID() const { return eTransportStreamID(data[2]); }
202         void setTransportStreamID(eTransportStreamID transport_stream_id) { data[2]=transport_stream_id.get(); }
203
204         eOriginalNetworkID getOriginalNetworkID() const { return eOriginalNetworkID(data[3]); }
205         void setOriginalNetworkID(eOriginalNetworkID original_network_id) { data[3]=original_network_id.get(); }
206
207         eDVBNamespace getDVBNamespace() const { return eDVBNamespace(data[4]); }
208         void setDVBNamespace(eDVBNamespace dvbnamespace) { data[4]=dvbnamespace.get(); }
209
210         eServiceID getParentServiceID() const { return eServiceID(data[5]); }
211         void setParentServiceID( eServiceID sid ) { data[5]=sid.get(); }
212
213         eTransportStreamID getParentTransportStreamID() const { return eTransportStreamID(data[6]); }
214         void setParentTransportStreamID( eTransportStreamID tsid ) { data[6]=tsid.get(); }
215
216         eServiceReferenceDVB getParentServiceReference() const
217         {
218                 eServiceReferenceDVB tmp(*this);
219                 if (data[5] && data[6])
220                 {
221                         tmp.data[1] = data[5];
222                         tmp.data[2] = data[6];
223                         tmp.data[5] = tmp.data[6] = 0;
224                 }
225                 else
226                         tmp.type = idInvalid;
227                 return tmp;
228         }
229
230         eServiceReferenceDVB(eDVBNamespace dvbnamespace, eTransportStreamID transport_stream_id, eOriginalNetworkID original_network_id, eServiceID service_id, int service_type)
231                 :eServiceReference(eServiceReference::idDVB, 0)
232         {
233                 setTransportStreamID(transport_stream_id);
234                 setOriginalNetworkID(original_network_id);
235                 setDVBNamespace(dvbnamespace);
236                 setServiceID(service_id);
237                 setServiceType(service_type);
238         }
239         
240         void set(const eDVBChannelID &chid)
241         {
242                 setDVBNamespace(chid.dvbnamespace);
243                 setOriginalNetworkID(chid.original_network_id);
244                 setTransportStreamID(chid.transport_stream_id);
245         }
246         
247         void getChannelID(eDVBChannelID &chid) const
248         {
249                 chid = eDVBChannelID(getDVBNamespace(), getTransportStreamID(), getOriginalNetworkID());
250         }
251
252         eServiceReferenceDVB()
253                 :eServiceReference(eServiceReference::idDVB, 0)
254         {
255         }
256
257         eServiceReferenceDVB(const std::string &string)
258                 :eServiceReference(string)
259         {
260         }
261 };
262
263
264 ////////////////// TODO: we need an interface here, but what exactly?
265
266 #include <set>
267 // btw, still implemented in db.cpp. FIX THIS, TOO.
268
269 class eDVBChannelQuery;
270
271 class eDVBService: public iStaticServiceInformation
272 {
273         DECLARE_REF(eDVBService);
274         int *m_cache;
275         void initCache();
276         void copyCache(int *source);
277 public:
278         enum cacheID
279         {
280                 cVPID, cMPEGAPID, cTPID, cPCRPID, cAC3PID,
281                 cVTYPE, cACHANNEL, cAC3DELAY, cPCMDELAY,
282                 cSUBTITLE, cAACHEAPID=12, cDDPPID, cAACAPID, cacheMax
283         };
284
285         int getCacheEntry(cacheID);
286         void setCacheEntry(cacheID, int);
287
288         bool cacheEmpty();
289
290         eDVBService();
291                 /* m_service_name_sort is uppercase, with special chars removed, to increase sort performance. */
292         std::string m_service_name, m_service_name_sort;
293         std::string m_provider_name;
294         
295         void genSortName();
296
297         int m_flags;
298         enum
299         {
300                 dxNoSDT=1,    // don't get SDT
301                 dxDontshow=2,
302                 dxNoDVB=4,  // dont use PMT for this service ( use cached pids )
303                 dxHoldName=8,
304                 dxNewFound=64,
305         };
306
307         bool usePMT() const { return !(m_flags & dxNoDVB); }
308         bool isHidden() const { return m_flags & dxDontshow; }
309
310         CAID_LIST m_ca;
311
312         virtual ~eDVBService();
313         
314         eDVBService &operator=(const eDVBService &);
315         
316         // iStaticServiceInformation
317         RESULT getName(const eServiceReference &ref, std::string &name);
318         RESULT getEvent(const eServiceReference &ref, ePtr<eServiceEvent> &ptr, time_t start_time);
319         int isPlayable(const eServiceReference &ref, const eServiceReference &ignore, bool simulate=false);
320         PyObject *getInfoObject(const eServiceReference &ref, int);  // implemented in lib/service/servicedvb.h
321
322                 /* for filtering: */
323         int checkFilter(const eServiceReferenceDVB &ref, const eDVBChannelQuery &query);
324 };
325
326 //////////////////
327
328 class iDVBChannel;
329 class iDVBDemux;
330 class iDVBFrontendParameters;
331
332 class iDVBChannelListQuery: public iObject
333 {
334 public:
335         virtual RESULT getNextResult(eServiceReferenceDVB &ref)=0;
336         virtual int compareLessEqual(const eServiceReferenceDVB &a, const eServiceReferenceDVB &b)=0;
337 };
338
339 class eDVBChannelQuery: public iObject
340 {
341         DECLARE_REF(eDVBChannelQuery);
342 public:
343         enum
344         {
345                 tName,
346                 tProvider,
347                 tType,
348                 tBouquet,
349                 tSatellitePosition,
350                 tChannelID,
351                 tAND,
352                 tOR,
353                 tAny,
354                 tFlags
355         };
356         
357         int m_type;
358         int m_inverse;
359         
360         std::string m_string;
361         int m_int;
362         eDVBChannelID m_channelid;
363         
364                 /* sort is only valid in root, and must be from the enum above. */
365         int m_sort;
366         std::string m_bouquet_name;
367         
368         static RESULT compile(ePtr<eDVBChannelQuery> &res, std::string query);
369         
370         ePtr<eDVBChannelQuery> m_p1, m_p2;
371 };
372
373 class iDVBChannelList: public iObject
374 {
375 public:
376         virtual RESULT removeService(const eServiceReference &service)=0;
377         virtual RESULT removeServices(eDVBChannelID chid=eDVBChannelID(), unsigned int orb_pos=0xFFFFFFFF)=0;
378         virtual RESULT removeServices(int dvb_namespace=-1, int tsid=-1, int onid=-1, unsigned int orb_pos=0xFFFFFFFF)=0;
379         virtual RESULT removeServices(iDVBFrontendParameters *feparm)=0;
380         virtual RESULT addFlag(const eServiceReference &service, unsigned int flagmask=0xFFFFFFFF)=0;
381         virtual RESULT removeFlag(const eServiceReference &service, unsigned int flagmask=0xFFFFFFFF)=0;
382         virtual RESULT removeFlags(unsigned int flagmask, eDVBChannelID chid=eDVBChannelID(), unsigned int orb_pos=0xFFFFFFFF)=0;
383         virtual RESULT removeFlags(unsigned int flagmask, int dvb_namespace=-1, int tsid=-1, int onid=-1, unsigned int orb_pos=0xFFFFFFFF)=0;
384         virtual RESULT addChannelToList(const eDVBChannelID &id, iDVBFrontendParameters *feparm)=0;
385         virtual RESULT removeChannel(const eDVBChannelID &id)=0;
386         
387         virtual RESULT getChannelFrontendData(const eDVBChannelID &id, ePtr<iDVBFrontendParameters> &parm)=0;
388         
389         virtual RESULT addService(const eServiceReferenceDVB &reference, eDVBService *service)=0;
390         virtual RESULT getService(const eServiceReferenceDVB &reference, ePtr<eDVBService> &service)=0;
391         virtual RESULT flush()=0;
392
393         virtual RESULT getBouquet(const eServiceReference &ref,  eBouquet* &bouquet)=0;
394
395         virtual RESULT startQuery(ePtr<iDVBChannelListQuery> &query, eDVBChannelQuery *q, const eServiceReference &source)=0;
396 };
397
398 #endif  // SWIG
399
400 class iDVBFrontendParameters: public iObject
401 {
402 #ifdef SWIG
403         iDVBFrontendParameters();
404         ~iDVBFrontendParameters();
405 #endif
406 public:
407         enum { flagOnlyFree = 1 };
408         virtual SWIG_VOID(RESULT) getSystem(int &SWIG_OUTPUT) const = 0;
409         virtual SWIG_VOID(RESULT) getDVBS(eDVBFrontendParametersSatellite &SWIG_OUTPUT) const = 0;
410         virtual SWIG_VOID(RESULT) getDVBC(eDVBFrontendParametersCable &SWIG_OUTPUT) const = 0;
411         virtual SWIG_VOID(RESULT) getDVBT(eDVBFrontendParametersTerrestrial &SWIG_OUTPUT) const = 0;
412         virtual SWIG_VOID(RESULT) getFlags(unsigned int &SWIG_OUTPUT) const = 0;
413 #ifndef SWIG
414         virtual SWIG_VOID(RESULT) calculateDifference(const iDVBFrontendParameters *parm, int &, bool exact) const = 0;
415         virtual SWIG_VOID(RESULT) getHash(unsigned long &) const = 0;
416         virtual SWIG_VOID(RESULT) calcLockTimeout(unsigned int &) const = 0;
417 #endif
418 };
419 SWIG_TEMPLATE_TYPEDEF(ePtr<iDVBFrontendParameters>, iDVBFrontendParametersPtr);
420
421 #define MAX_DISEQC_LENGTH  16
422
423 class eDVBDiseqcCommand
424 {
425 #ifndef SWIG
426 public:
427 #endif
428         int len;
429         __u8 data[MAX_DISEQC_LENGTH];
430 #if HAVE_DVB_API_VERSION < 3
431         int tone;
432         int voltage;
433 #endif
434 #ifdef SWIG
435 public:
436 #endif
437         void setCommandString(const char *str);
438 };
439
440 class iDVBSatelliteEquipmentControl;
441 class eSecCommandList;
442
443 class iDVBFrontend_ENUMS
444 {
445 #ifdef SWIG
446         iDVBFrontend_ENUMS();
447         ~iDVBFrontend_ENUMS();
448 #endif
449 public:
450         enum { feSatellite, feCable, feTerrestrial };
451         enum { stateIdle, stateTuning, stateFailed, stateLock, stateLostLock, stateClosed };
452         enum { toneOff, toneOn };
453         enum { voltageOff, voltage13, voltage18, voltage13_5, voltage18_5 };
454         enum { bitErrorRate, signalPower, signalQuality, locked, synced, frontendNumber, signalQualitydB, isUsbTuner };
455 };
456
457 SWIG_IGNORE(iDVBFrontend);
458 class iDVBFrontend: public iDVBFrontend_ENUMS, public iObject
459 {
460 public:
461         virtual RESULT tune(const iDVBFrontendParameters &where)=0;
462         virtual int closeFrontend(bool force = false, bool no_delayed = false)=0;
463         virtual void reopenFrontend()=0;
464 #ifndef SWIG
465         virtual RESULT connectStateChange(const Slot1<void,iDVBFrontend*> &stateChange, ePtr<eConnection> &connection)=0;
466 #endif
467         virtual RESULT getState(int &SWIG_OUTPUT)=0;
468         virtual RESULT setTone(int tone)=0;
469         virtual RESULT setVoltage(int voltage)=0;
470         virtual RESULT sendDiseqc(const eDVBDiseqcCommand &diseqc)=0;
471         virtual RESULT sendToneburst(int burst)=0;
472 #ifndef SWIG
473         virtual RESULT setSEC(iDVBSatelliteEquipmentControl *sec)=0;
474         virtual RESULT setSecSequence(eSecCommandList &list)=0;
475 #endif
476         virtual int readFrontendData(int type)=0;
477         virtual void getFrontendStatus(SWIG_PYOBJECT(ePyObject) dest)=0;
478         virtual void getTransponderData(SWIG_PYOBJECT(ePyObject) dest, bool original)=0;
479         virtual void getFrontendData(SWIG_PYOBJECT(ePyObject) dest)=0;
480 #ifndef SWIG
481         virtual RESULT getData(int num, long &data)=0;
482         virtual RESULT setData(int num, long val)=0;
483                 /* 0 means: not compatible. other values are a priority. */
484         virtual int isCompatibleWith(ePtr<iDVBFrontendParameters> &feparm)=0;
485 #endif
486 };
487 SWIG_TEMPLATE_TYPEDEF(ePtr<iDVBFrontend>, iDVBFrontendPtr);
488
489 #ifndef SWIG
490 class iDVBSatelliteEquipmentControl: public iObject
491 {
492 public:
493         virtual RESULT prepare(iDVBFrontend &frontend, FRONTENDPARAMETERS &parm, const eDVBFrontendParametersSatellite &sat, int frontend_id, unsigned int timeout)=0;
494         virtual void prepareTurnOffSatCR(iDVBFrontend &frontend)=0;
495         virtual int canTune(const eDVBFrontendParametersSatellite &feparm, iDVBFrontend *fe, int frontend_id, int *highest_score_lnb=0)=0;
496         virtual void setRotorMoving(int slotid, bool)=0;
497 };
498
499 struct eDVBCIRouting
500 {
501         int enabled;
502 };
503 #endif // SWIG
504
505 SWIG_IGNORE(iDVBChannel);
506 class iDVBChannel: public iObject
507 {
508 public:
509                 /* direct frontend access for raw channels and/or status inquiries. */
510         virtual SWIG_VOID(RESULT) getFrontend(ePtr<iDVBFrontend> &SWIG_OUTPUT)=0;
511         virtual RESULT requestTsidOnid(SWIG_PYOBJECT(ePyObject) callback) { return -1; }
512         virtual int reserveDemux() { return -1; }
513 #ifndef SWIG
514         enum
515         {
516                 state_idle,        /* not yet tuned */
517                 state_tuning,      /* currently tuning (first time) */
518                 state_failed,      /* tuning failed. */
519                 state_unavailable, /* currently unavailable, will be back without further interaction */
520                 state_ok,          /* ok */
521                 state_last_instance, /* just one reference to this channel is left */
522                 state_release      /* channel is being shut down. */
523         };
524         virtual RESULT getState(int &)=0;
525
526         virtual RESULT getCurrentFrontendParameters(ePtr<iDVBFrontendParameters> &)=0;
527         enum 
528         {
529                 evtPreStart, evtEOF, evtSOF, evtFailed
530         };
531         virtual RESULT connectStateChange(const Slot1<void,iDVBChannel*> &stateChange, ePtr<eConnection> &connection)=0;
532         virtual RESULT connectEvent(const Slot2<void,iDVBChannel*,int> &eventChange, ePtr<eConnection> &connection)=0;
533
534                 /* demux capabilities */
535         enum
536         {
537                 capDecode = 1,
538                 /* capCI = 2 */
539         };
540         virtual RESULT setCIRouting(const eDVBCIRouting &routing)=0;
541         virtual RESULT getDemux(ePtr<iDVBDemux> &demux, int cap=0)=0;
542         
543                 /* use count handling */
544         virtual void AddUse() = 0;
545         virtual void ReleaseUse() = 0;
546 #endif
547 };
548 SWIG_TEMPLATE_TYPEDEF(eUsePtr<iDVBChannel>, iDVBChannelPtr);
549
550 #ifndef SWIG
551         /* signed, so we can express deltas. */
552         
553 typedef long long pts_t;
554
555 class iFilePushScatterGather;
556 class iTSMPEGDecoder;
557
558         /* note that a cue sheet describes the logical positions. thus 
559            everything is specified in pts and not file positions */
560
561         /* implemented in dvb.cpp */
562 class eCueSheet: public iObject, public Object
563 {
564         DECLARE_REF(eCueSheet);
565 public:
566         eCueSheet();
567         
568                         /* frontend */
569         void seekTo(int relative, const pts_t &pts);
570         
571         void clear();
572         void addSourceSpan(const pts_t &begin, const pts_t &end);
573         void commitSpans();
574         
575         void setSkipmode(const pts_t &ratio); /* 90000 is 1:1 */
576         void setDecodingDemux(iDVBDemux *demux, iTSMPEGDecoder *decoder);
577         
578                         /* frontend and backend */
579         eRdWrLock m_lock;
580         
581                         /* backend */
582         enum { evtSeek, evtSkipmode, evtSpanChanged };
583         RESULT connectEvent(const Slot1<void, int> &event, ePtr<eConnection> &connection);
584
585         std::list<std::pair<pts_t,pts_t> > m_spans;     /* begin, end */
586         std::list<std::pair<int, pts_t> > m_seek_requests; /* relative, delta */
587         pts_t m_skipmode_ratio;
588         Signal1<void,int> m_event;
589         ePtr<iDVBDemux> m_decoding_demux;
590         ePtr<iTSMPEGDecoder> m_decoder;
591 };
592
593 class iDVBPVRChannel: public iDVBChannel
594 {
595 public:
596         enum
597         {
598                 state_eof = state_release + 1  /* end-of-file reached. */
599         };
600         
601                 /* FIXME: there are some very ugly buffer-end and ... related problems */
602                 /* so this is VERY UGLY. 
603                 
604                    ok, it's going to get better. but still...*/
605         virtual RESULT playFile(const char *file) = 0;
606         virtual void stopFile() = 0;
607         
608         /* new interface */
609         virtual RESULT playSource(ePtr<iTsSource> &source, const char *priv=NULL) = 0;
610         virtual void stopSource() = 0;
611         
612         virtual void setCueSheet(eCueSheet *cuesheet) = 0;
613         
614         virtual RESULT getLength(pts_t &pts) = 0;
615         
616                 /* we explicitely ask for the decoding demux here because a channel
617                    can be shared between multiple decoders.
618                 */
619         virtual RESULT getCurrentPosition(iDVBDemux *decoding_demux, pts_t &pos, int mode) = 0;
620                 /* skipping must be done with a cue sheet */
621 };
622
623 class iDVBSectionReader;
624 class iDVBPESReader;
625 class iDVBTSRecorder;
626 class iTSMPEGDecoder;
627
628 class iDVBDemux: public iObject
629 {
630 public:
631         virtual RESULT createSectionReader(eMainloop *context, ePtr<iDVBSectionReader> &reader)=0;
632         virtual RESULT createPESReader(eMainloop *context, ePtr<iDVBPESReader> &reader)=0;
633         virtual RESULT createTSRecorder(ePtr<iDVBTSRecorder> &recorder)=0;
634         virtual RESULT getMPEGDecoder(ePtr<iTSMPEGDecoder> &reader, int primary=1)=0;
635         virtual RESULT getSTC(pts_t &pts, int num=0)=0;
636         virtual RESULT getCADemuxID(uint8_t &id)=0;
637         virtual RESULT flush()=0;
638         virtual int openDVR(int flags)=0;
639         virtual int getSource()=0;
640 };
641
642 #if HAVE_DVB_API_VERSION < 3 && !defined(VIDEO_EVENT_SIZE_CHANGED)
643 #define VIDEO_EVENT_SIZE_CHANGED 1
644 #define VIDEO_EVENT_FRAME_RATE_CHANGED 2
645 #endif
646
647 class iTSMPEGDecoder: public iObject
648 {
649 public:
650         enum { pidDisabled = -1 };
651                 /** Set Displayed Video PID and type */
652         virtual RESULT setVideoPID(int vpid, int type)=0;
653
654         enum { af_MPEG, af_AC3, af_DTS, af_AAC, af_DTSHD };
655                 /** Set Displayed Audio PID and type */
656         virtual RESULT setAudioPID(int apid, int type)=0;
657
658         enum { ac_left, ac_stereo, ac_right };
659                 /** Set Displayed Audio Channel */
660         virtual RESULT setAudioChannel(int channel)=0;
661         virtual int getAudioChannel()=0;
662
663         virtual RESULT setPCMDelay(int delay)=0;
664         virtual int getPCMDelay()=0;
665         virtual RESULT setAC3Delay(int delay)=0;
666         virtual int getAC3Delay()=0;
667
668                 /** Set Displayed Videotext PID */
669         virtual RESULT setTextPID(int vpid)=0;
670
671                 /** Set Sync mode to PCR */
672         virtual RESULT setSyncPCR(int pcrpid)=0;
673         enum { sm_Audio, sm_Video };
674                 /** Set Sync mode to either audio or video master */
675         virtual RESULT setSyncMaster(int who)=0;
676
677                 /** Apply settings but don't change state */
678         virtual RESULT set()=0;
679                 /* all those apply settings, then transition to the given state */
680
681                 /** play */
682         virtual RESULT play()=0;
683                 /** Freeze frame. */
684         virtual RESULT pause()=0;
685
686                 /** fast forward by skipping frames. 0 is disabled, 2 is twice-the-speed, ... */
687         virtual RESULT setFastForward(int skip=0)=0;
688
689                 /** Slow Motion by repeating pictures */
690         virtual RESULT setSlowMotion(int repeat)=0;
691
692                 /** Display any complete data as fast as possible */
693         virtual RESULT setTrickmode()=0;
694
695         virtual RESULT prepareFCC(int fe_id, int vpid, int vtype, int pcrpid)=0;
696
697         virtual RESULT fccDecoderStart()=0;
698
699         virtual RESULT fccDecoderStop()=0;
700
701         virtual RESULT fccUpdatePids(int fe_id, int vpid, int vtype, int pcrpid)=0;
702         
703         virtual RESULT getPTS(int what, pts_t &pts) = 0;
704
705         virtual RESULT showSinglePic(const char *filename) = 0;
706
707         virtual RESULT setRadioPic(const std::string &filename) = 0;
708
709         struct videoEvent
710         {
711                 enum { eventUnknown = 0,
712                         eventSizeChanged = VIDEO_EVENT_SIZE_CHANGED,
713                         eventFrameRateChanged = VIDEO_EVENT_FRAME_RATE_CHANGED,
714                         eventProgressiveChanged = 16
715                 } type;
716                 unsigned char aspect;
717                 unsigned short height;
718                 unsigned short width;
719                 bool progressive;
720                 unsigned short framerate;
721         };
722
723         virtual RESULT connectVideoEvent(const Slot1<void, struct videoEvent> &event, ePtr<eConnection> &connection) = 0;
724
725         virtual int getVideoWidth() = 0;
726         virtual int getVideoHeight() = 0;
727         virtual int getVideoProgressive() = 0;
728         virtual int getVideoFrameRate() = 0;
729         virtual int getVideoAspect() = 0;
730 };
731
732 #endif //SWIG
733 #endif