diff -r 517706c7003e -r c73e1eb09a6f gmyth-stream/server/0.3/plugins/transcoders/mencoder.py --- a/gmyth-stream/server/0.3/plugins/transcoders/mencoder.py Fri Jun 01 15:36:11 2007 +0100 +++ b/gmyth-stream/server/0.3/plugins/transcoders/mencoder.py Fri Jun 01 17:12:35 2007 +0100 @@ -3,14 +3,16 @@ __author__ = "Artur Duque de Souza" __author_email__ = "artur.souza@indt.org.br" __license__ = "GPL" -__version__ = "0.1" +__version__ = "0.3" import os +import time +import fcntl import shlex +import socket +import struct import signal import subprocess -import time -import fcntl import lib.utils as utils import lib.server as server @@ -255,13 +257,32 @@ if not self._run_mencoder(output=subprocess.PIPE): return False - try: - while self.proc and self.proc.poll() == None: - d = self.proc.stdout.read(1024) - outfd.write(d) - except Exception, e: - self.log.error(self.tid, "Error: %s" % e) - return False + if not self.params_first("multicast", None): + try: + while self.proc and self.proc.poll() == None: + d = self.proc.stdout.read(1024) + outfd.write(d) + except Exception, e: + self.log.error(self.tid, "Error: %s" % e) + return False + else: + try: + outfd.write("OK ") + multicast_ip = self.params_first("multicast", + "225.100.100.100") + multicast_port = int(self.params_first("multicastport", + "12345")) + sock = socket.socket(socket.AF_INET, + socket.SOCK_DGRAM, socket.IPPROTO_UDP) + sock.setsockopt(socket.IPPROTO_IP, + socket.IP_MULTICAST_TTL, 2) + + while self.proc and self.proc.poll() == None: + d = self.proc.stdout.read(1024) + sock.sendto(d, (multicast_ip, multicast_port)) + except Exception, e: + self.log.error(self.tid, "Error: %s" % e) + return False self.log.info(self.tid, "OK: Done") return True