[vlma-devel] commit: Add broadcast DVB channel support with VLC. (Adrien Maglo )
git version control
git at videolan.org
Mon Dec 21 21:34:09 CET 2009
vlma | branch: master | Adrien Maglo <magsoft at videolan.org> | Mon Dec 21 21:36:46 2009 +0100| [4e753cadca307b9dd2f23fdb504ed5955ddd05a8] | committer: Adrien Maglo
Add broadcast DVB channel support with VLC.
> http://git.videolan.org/gitweb.cgi/vlma.git/?a=commit;h=4e753cadca307b9dd2f23fdb504ed5955ddd05a8
---
vlma-watchdog/src/streamer/vlc.py | 68 +++++++++++++++++++++++++++++++++++--
1 files changed, 65 insertions(+), 3 deletions(-)
diff --git a/vlma-watchdog/src/streamer/vlc.py b/vlma-watchdog/src/streamer/vlc.py
index 1fec0f9..c67f7df 100644
--- a/vlma-watchdog/src/streamer/vlc.py
+++ b/vlma-watchdog/src/streamer/vlc.py
@@ -1,8 +1,8 @@
#! /usr/bin/env python
# -*- coding: utf-8 -*-
-from api import Streamer
-import constants, os, utils
+from api import *
+import constants, os, utils, socket
if utils.platform_is_windows:
import win32api
@@ -60,8 +60,70 @@ class VLC(Streamer):
def can_stream(self, order):
return True
+ def _waitForPrompt(self, myS):
+ PASSWORD_PROMPT = "Password: \xff\xfb\x01"
+ CMD_PROMPT = "> "
+ test1 = ""
+ test2 = ""
+ while(test1 != CMD_PROMPT and test2 != PASSWORD_PROMPT ):
+ buf = myS.recv(256)
+ test1 = buf[-len(CMD_PROMPT):]
+ test2 = buf[-len(PASSWORD_PROMPT):]
+
+ def _sendCmd(self, myS, orderStr):
+ myS.send(orderStr + "\n")
+ self._waitForPrompt(myS)
+
+ def _destToSoutStr(self, dest):
+ return "dst=standard{mux=%s,access=%s,dst=%s:%d}" \
+ % (dest.streaming.mux, dest.streaming.protocol, dest.ip, dest.port)
+
def start_streaming(self, order):
- pass
+ # Connect to the VLC telnet interface
+ myS = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
+ myS.connect(("localhost", self.options[VLCOption.TELNET_PORT]))
+ # Wait for the password invitation
+ self._waitForPrompt(myS)
+ # Give the password
+ self._sendCmd(myS, "admin")
+ # Stop the previous order with the same nane if one exists.
+ self._sendCmd(myS, "setup %s disabled" % order.id)
+ self._sendCmd(myS, "control %s stop" % order.id)
+ self._sendCmd(myS, "del %s" % order.id)
+
+ # Handle DVB orders.
+ if isinstance(order, DVBOrder):
+ # TODO handle schedule and VoD ?
+ self._sendCmd(myS, "new %s broadcast enabled\n" % order.id)
+ self._sendCmd(myS, "setup %s input \"dvb://\"" % order.id)
+ self._sendCmd(myS, "setup %s option dvb-adapter=%d" % (order.id, order.adapter))
+ self._sendCmd(myS, "setup %s option dvb-frequency=%d" % (order.id, order.frequency))
+ # Give PIDs
+ cmd = "setup %s option programs=" % order.id
+ for src in order.programs.keys():
+ cmd += "%s," % str(src)
+ # Remove the last comma
+ cmd = cmd[:-1]
+ self._sendCmd(myS, cmd)
+ # Special case of DVB-S.
+ if isinstance(order, DVBSOrder):
+ self._sendCmd(myS, "setup %s option dvb-voltage=%d" % (order.id, order.voltage))
+ self._sendCmd(myS, "setup %s option dvb-srate=%d" % (order.id, order.srate))
+ self._sendCmd(myS, "setup %s option dvb-fec=%d" % (order.id, order.fec))
+ self._sendCmd(myS, "setup %s option dvb-bandwidth=%d" % (order.id, order.bandwidth))
+ # Prepare sout command line.
+ cmd = "setup %s output #duplicate{" % order.id
+ for src, dests in order.programs.items():
+ # TODO Handle SAP announces, handle multiple destinations.
+ cmd += self._destToSoutStr(dests[0]) + ",select=\"program=%s\"," % str(src)
+ # Remove the last comma, close the duplicate structure.
+ cmd = cmd[:-1] + "}"
+ self._sendCmd(myS, cmd)
+
+ # Start the new order.
+ self._sendCmd(myS, "control %s play" % order.id)
+ # Close the socket connection
+ myS.close()
def stop_streaming(self, order):
pass
More information about the vlma-devel
mailing list