Merge branch 'acid-burn/bug_622_swupgrade_networkcheck' into experimental
[enigma2.git] / lib / python / Components / Sources / StreamService.py
1 from Source import Source
2 from Components.Element import cached
3 from enigma import eServiceReference
4
5 class StreamService(Source):
6         def __init__(self, navcore):
7                 Source.__init__(self)
8                 self.ref = None
9                 self.__service = None
10                 self.navcore = navcore
11
12         def serviceEvent(self, event):
13                 pass
14
15         @cached
16         def getService(self):
17                 return self.__service
18
19         service = property(getService)
20
21         def handleCommand(self, cmd):
22                 print "StreamService handle command", cmd
23                 self.ref = eServiceReference(cmd)
24
25         def recordEvent(self, service, event):
26                 if service is self.__service:
27                         return
28                 print "RECORD event for us:", service
29                 self.changed((self.CHANGED_ALL, ))
30
31         def execBegin(self):
32                 if self.ref is None:
33                         print "StreamService has no service ref set."
34                         return
35                 print "StreamService execBegin", self.ref.toString()
36                 self.__service = self.navcore.recordService(self.ref)
37                 self.navcore.record_event.append(self.recordEvent)
38                 if self.__service is not None:
39                         self.__service.prepareStreaming()
40                         self.__service.start()
41
42         def execEnd(self):
43                 print "StreamService execEnd", self.ref.toString()
44                 self.navcore.record_event.remove(self.recordEvent)
45                 if self.__service is not None:
46                         self.navcore.stopRecordService(self.__service)
47                         self.__service = None