Add source and converter for streaming. Source/StreamService will start the streaming...
authorFelix Domke <tmbinc@elitedvb.net>
Tue, 9 Jan 2007 01:14:13 +0000 (01:14 +0000)
committerFelix Domke <tmbinc@elitedvb.net>
Tue, 9 Jan 2007 01:14:13 +0000 (01:14 +0000)
lib/python/Components/Converter/Makefile.am
lib/python/Components/Converter/Streaming.py [new file with mode: 0644]
lib/python/Components/Sources/Makefile.am
lib/python/Components/Sources/StreamService.py [new file with mode: 0644]

index e754a6830b9709615ea306d17dd25951eeb413e6..b25a32d899e8ce7e93ca51ce4662812751157066 100644 (file)
@@ -3,4 +3,5 @@ installdir = $(LIBDIR)/enigma2/python/Components/Converter
 install_PYTHON = \
        __init__.py ClockToText.py Converter.py EventName.py StaticText.py EventTime.py \
        Poll.py RemainingToText.py StringList.py ServiceName.py FrontendInfo.py ServiceInfo.py \
-       ConditionalShowHide.py ServicePosition.py ValueRange.py RadioText.py
+       ConditionalShowHide.py ServicePosition.py ValueRange.py RadioText.py Streaming.py
+
diff --git a/lib/python/Components/Converter/Streaming.py b/lib/python/Components/Converter/Streaming.py
new file mode 100644 (file)
index 0000000..ece1749
--- /dev/null
@@ -0,0 +1,30 @@
+from Converter import Converter
+from Components.Element import cached
+
+class Streaming(Converter):
+       def __init__(self, type):
+               Converter.__init__(self, type)
+
+       @cached
+       def getText(self):
+               service = self.source.service
+               if service is None:
+                       return "-NO SERVICE"
+
+               streaming = service.stream()
+               s = streaming and streaming.getStreamingData()
+
+               if streaming is None:
+                       err = service.getError()
+                       return "-1SERVICE ERROR:%d" % err
+
+               r = streaming.getStreamingData()
+               if r is None:
+                       return "-NO STREAM"
+
+               demux = r["demux"]
+               pids = ','.join(["%x:%s" % (x[0], x[1]) for x in r["pids"]])
+
+               return "+%d:%s\n" % (demux, pids)
+
+       text = property(getText)
index 16513e82680c40eb5aaa7a07b75159b138b50bc9..c03d89ebf0139b55aaa7ffe607fd37a5590ab42d 100644 (file)
@@ -2,4 +2,5 @@ installdir = $(LIBDIR)/enigma2/python/Components/Sources
 
 install_PYTHON = \
        __init__.py Clock.py EventInfo.py Source.py MenuList.py CurrentService.py \
-       FrontendStatus.py Boolean.py Config.py ServiceList.py RadioText.py
+       FrontendStatus.py Boolean.py Config.py ServiceList.py RadioText.py StreamService.py
+
diff --git a/lib/python/Components/Sources/StreamService.py b/lib/python/Components/Sources/StreamService.py
new file mode 100644 (file)
index 0000000..ac8db34
--- /dev/null
@@ -0,0 +1,44 @@
+from Source import Source
+from Components.Element import cached
+from enigma import eServiceReference
+
+class StreamService(Source):
+       def __init__(self, navcore):
+               Source.__init__(self)
+               self.ref = None
+               self.__service = None
+               self.navcore = navcore
+
+       def serviceEvent(self, event):
+               pass
+
+       @cached
+       def getService(self):
+               return self.__service
+
+       service = property(getService)
+
+       def handleCommand(self, cmd):
+               print "StreamService handle command", cmd
+               self.ref = eServiceReference(cmd)
+
+       def recordEvent(self, service, event):
+               if service is self.__service:
+                       return
+               print "RECORD event for us:", service
+               self.changed((self.CHANGED_ALL, ))
+
+       def execBegin(self):
+               print "StreamService execBegin", self.ref.toString()
+               self.__service = self.navcore.recordService(self.ref)
+               self.navcore.record_event.append(self.recordEvent)
+               if self.__service is not None:
+                       self.__service.prepareStreaming()
+                       self.__service.start()
+
+       def execEnd(self):
+               print "StreamService execEnd", self.ref.toString()
+               self.navcore.record_event.remove(self.recordEvent)
+               if self.__service is not None:
+                       self.navcore.stopRecordService(self.__service)
+                       self.__service = None