add possible todo regarding mounted/ismount
[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                 print "StreamService execBegin", self.ref.toString()
33                 self.__service = self.navcore.recordService(self.ref)
34                 self.navcore.record_event.append(self.recordEvent)
35                 if self.__service is not None:
36                         self.__service.prepareStreaming()
37                         self.__service.start()
38
39         def execEnd(self):
40                 print "StreamService execEnd", self.ref.toString()
41                 self.navcore.record_event.remove(self.recordEvent)
42                 if self.__service is not None:
43                         self.navcore.stopRecordService(self.__service)
44                         self.__service = None