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