6 # @brief <p> Plugin for GMyth-Stream
8 # Copyright (C) 2007 INdT - Instituto Nokia de Tecnologia.
9 # @author Artur Duque de Souza <artur.souza@indt.org.br>
12 # This program is free software; you can redistribute it and/or modify
13 # it under the terms of the GNU Lesser General Public License as published by
14 # the Free Software Foundation; either version 2 of the License, or
15 # (at your option) any later version.
17 # This program is distributed in the hope that it will be useful,
18 # but WITHOUT ANY WARRANTY; without even the implied warranty of
19 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
20 # GNU General Public License for more details.
22 # You should have received a copy of the GNU Lesser General Public License
23 # along with this program; if not, write to the Free Software
24 # Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
35 def __init__(self, config):
37 # set gstreamer basic options
41 def setup(self, filename, codec, bitrate, width, height, port):
43 self.filename = filename
45 self.bitrate = int(bitrate)
46 self.width = int(width)
47 self.height = int(height)
52 #queue ! videoscale ! video/x-raw-yuv,width=240,height=144\
53 #! videorate ! ffenc_h263p bitrate=256000 me-method=2 \
54 #! rtph263ppay ! udpsink host=224.0.0.1 port=5000
57 #audio/x-raw-int ! queue ! audioconvert ! faac ! rtpmp4gpay\
58 #! udpsink name=upd_audio host=224.0.0.1 port=5002
60 self.pipe = "filesrc location=%s ! decodebin name=d ! queue ! videoscale !"\
61 "video/x-raw-yuv,width=(int)%d,height=(int)%d ! ffenc_h263p bitrate=%d"\
62 " me-method=2 ! rtph263ppay ! udpsink host=224.0.0.1 port=%d d. ! "\
63 "queue ! audioconvert ! faac ! rtpmp4gpay ! udpsink name=udp_audio "\
64 "host=224.0.0.1 port=%d" % (self.filename, self.width, self.height,\
65 self.bitrate, self.port, self.port+2)
67 #self.pipe = "filesrc location=/tmp/mpg/cpm.mpg ! decodebin ! ffmpegcolorspace ! ximagesink"
69 self.pipeline = gst.parse_launch(self.pipe)
74 print "Trying to play pipeline: %s" % self.pipe
77 self.pipeline.set_state(gst.STATE_PLAYING)
78 except gobject.GError, e:
79 print "Error: " + str(e)
84 print "Trying to stop pipeline: %s" % self.pipe
87 self.pipeline.set_state(gst.STATE_NULL)
88 except gobject.GError, e:
89 print "Error: " + str(e)