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