1.1 --- a/gmyth-stream/server/0.3/plugins/transcoders/mencoder.py Fri Jun 01 15:36:11 2007 +0100
1.2 +++ b/gmyth-stream/server/0.3/plugins/transcoders/mencoder.py Fri Jun 01 17:12:35 2007 +0100
1.3 @@ -3,14 +3,16 @@
1.4 __author__ = "Artur Duque de Souza"
1.5 __author_email__ = "artur.souza@indt.org.br"
1.6 __license__ = "GPL"
1.7 -__version__ = "0.1"
1.8 +__version__ = "0.3"
1.9
1.10 import os
1.11 +import time
1.12 +import fcntl
1.13 import shlex
1.14 +import socket
1.15 +import struct
1.16 import signal
1.17 import subprocess
1.18 -import time
1.19 -import fcntl
1.20
1.21 import lib.utils as utils
1.22 import lib.server as server
1.23 @@ -255,13 +257,32 @@
1.24 if not self._run_mencoder(output=subprocess.PIPE):
1.25 return False
1.26
1.27 - try:
1.28 - while self.proc and self.proc.poll() == None:
1.29 - d = self.proc.stdout.read(1024)
1.30 - outfd.write(d)
1.31 - except Exception, e:
1.32 - self.log.error(self.tid, "Error: %s" % e)
1.33 - return False
1.34 + if not self.params_first("multicast", None):
1.35 + try:
1.36 + while self.proc and self.proc.poll() == None:
1.37 + d = self.proc.stdout.read(1024)
1.38 + outfd.write(d)
1.39 + except Exception, e:
1.40 + self.log.error(self.tid, "Error: %s" % e)
1.41 + return False
1.42 + else:
1.43 + try:
1.44 + outfd.write("OK ")
1.45 + multicast_ip = self.params_first("multicast",
1.46 + "225.100.100.100")
1.47 + multicast_port = int(self.params_first("multicastport",
1.48 + "12345"))
1.49 + sock = socket.socket(socket.AF_INET,
1.50 + socket.SOCK_DGRAM, socket.IPPROTO_UDP)
1.51 + sock.setsockopt(socket.IPPROTO_IP,
1.52 + socket.IP_MULTICAST_TTL, 2)
1.53 +
1.54 + while self.proc and self.proc.poll() == None:
1.55 + d = self.proc.stdout.read(1024)
1.56 + sock.sendto(d, (multicast_ip, multicast_port))
1.57 + except Exception, e:
1.58 + self.log.error(self.tid, "Error: %s" % e)
1.59 + return False
1.60
1.61 self.log.info(self.tid, "OK: Done")
1.62 return True