1.1 --- a/gmyth-stream/server/plugins/media/gstreamer.py Wed Apr 11 18:40:50 2007 +0100
1.2 +++ b/gmyth-stream/server/plugins/media/gstreamer.py Fri Apr 13 20:07:32 2007 +0100
1.3 @@ -7,40 +7,40 @@
1.4 from threading import Thread
1.5
1.6 class Media:
1.7 - class StreamListener(Thread):
1.8 - def __init__ (self, stream_data):
1.9 - Thread.__init__(self)
1.10 - self.stream = stream_data
1.11 - print "Thread Created"
1.12 + class StreamListener(Thread):
1.13 + def __init__ (self, stream_data):
1.14 + Thread.__init__(self)
1.15 + self.stream = stream_data
1.16 + print "Thread Created"
1.17
1.18 - def run (self):
1.19 - #Create socket
1.20 - print "Waiting connection"
1.21 - self.stream.Socket.listen(1)
1.22 - self.stream.Connection, self.stream.Addr = self.stream.Socket.accept ()
1.23 - print "Connection requested"
1.24 - self.stream.Sink.set_property ("fd", self.stream.Connection.fileno())
1.25 - self.stream.Pipe.set_state(gst.STATE_PLAYING)
1.26 - print "PLAYING"
1.27 + def run (self):
1.28 + #Create socket
1.29 + print "Waiting connection"
1.30 + self.stream.Socket.listen(1)
1.31 + self.stream.Connection, self.stream.Addr = self.stream.Socket.accept ()
1.32 + print "Connection requested"
1.33 + self.stream.Sink.set_property ("fd", self.stream.Connection.fileno())
1.34 + self.stream.Pipe.set_state(gst.STATE_PLAYING)
1.35 + print "PLAYING"
1.36
1.37
1.38 class StreamData:
1.39 stream_count = 0
1.40
1.41 - def __init__ (self, pipe, abin, vbin, sink):
1.42 - self.stream_count += 1
1.43 - self.Id = self.stream_count
1.44 - self.Pipe = pipe
1.45 - self.Abin = abin
1.46 - self.Vbin = vbin
1.47 - self.Sink = sink
1.48 - self.Loop = gobject.MainLoop()
1.49 - self.ACaps = ""
1.50 - self.VCaps = ""
1.51 - self.Ready = False
1.52 - self.Socket = None
1.53 - self.Connection = None
1.54 - self.Addr = None
1.55 + def __init__ (self, pipe, abin, vbin, sink):
1.56 + self.stream_count += 1
1.57 + self.Id = self.stream_count
1.58 + self.Pipe = pipe
1.59 + self.Abin = abin
1.60 + self.Vbin = vbin
1.61 + self.Sink = sink
1.62 + self.Loop = gobject.MainLoop()
1.63 + self.ACaps = ""
1.64 + self.VCaps = ""
1.65 + self.Ready = False
1.66 + self.Socket = None
1.67 + self.Connection = None
1.68 + self.Addr = None
1.69
1.70 def __init__(self, config):
1.71 # set gstreamer basic options
1.72 @@ -49,7 +49,7 @@
1.73 self.socket = None
1.74 self.connection = None
1.75 self.addr = None
1.76 - self.ready = False
1.77 + self.ready = False
1.78
1.79
1.80 def setup(self, uri, mux, vcodec, vbitrate,
1.81 @@ -181,26 +181,25 @@
1.82 print "End run"
1.83
1.84
1.85 - #Create socket
1.86 - stream_data.Socket = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
1.87 - print "Bind on port %d" % port
1.88 - stream_data.Socket.bind(('', int (port)))
1.89 + #Create socket
1.90 + stream_data.Socket = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
1.91 + print "Bind on port %d" % port
1.92 + stream_data.Socket.bind(('', int (port)))
1.93 + self.streams.append (stream_data)
1.94 + return (True, "")
1.95
1.96 - self.streams.append (stream_data)
1.97 - return True
1.98 -
1.99 - def play(self):
1.100 - stream = self.streams[0]
1.101 - current = self.StreamListener(stream)
1.102 - current.start ()
1.103 - print "Saindo"
1.104 - return True
1.105 + def play(self):
1.106 + stream = self.streams[0]
1.107 + current = self.StreamListener(stream)
1.108 + current.start ()
1.109 + print "Saindo"
1.110 + return (True, "")
1.111
1.112 def stop(self):
1.113 - stream = self.streams[0]
1.114 - stream.Pipe.set_state(gst.STATE_NULL)
1.115 - stream.Connection.close ()
1.116 - return True
1.117 + stream = self.streams[0]
1.118 + stream.Pipe.set_state(gst.STATE_NULL)
1.119 + stream.Connection.close ()
1.120 + return (True, "")
1.121
1.122
1.123 def __on_bus_message (self, bus, message, stream_data):