f12ebd99243e8fbc3d49f321769be7250c471e53
[vuplus_dvbapp] / lib / python / Components / Converter / Streaming.py
1 from Converter import Converter
2 from Components.Element import cached
3
4 # the protocol works as the following:
5
6 # lines starting with '-' are fatal errors (no recovery possible),
7 # lines starting with '=' are progress notices,
8 # lines starting with '+' are PIDs to record:
9 #       "+d:[p:t[,p:t...]]" with d=demux nr, p: pid, t: type
10
11 class Streaming(Converter):
12         def __init__(self, type):
13                 Converter.__init__(self, type)
14
15         @cached
16         def getText(self):
17                 service = self.source.service
18                 if service is None:
19                         return "-NO SERVICE\n"
20
21                 streaming = service.stream()
22                 s = streaming and streaming.getStreamingData()
23
24                 if s is None:
25                         err = service.getError()
26                         from enigma import iRecordableService
27                         if err:
28                                 return "-SERVICE ERROR:%d\n" % err
29                         else:
30                                 return "=NO STREAM\n"
31
32                 demux = s["demux"]
33                 pids = ','.join(["%x:%s" % (x[0], x[1]) for x in s["pids"]])
34
35                 return "+%d:%s\n" % (demux, pids)
36
37         text = property(getText)