forked from vysakh-i/Python-Streamer
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathCLIENT
More file actions
33 lines (25 loc) · 884 Bytes
/
CLIENT
File metadata and controls
33 lines (25 loc) · 884 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
import gobject, pygst
pygst.require("0.10")
import gst
# Callback for the decodebin source pad
def new_decode_pad(dbin, pad, islast):
pad.link(convert.get_pad("sink"))
# create a pipeline and add [tcpserversrc ! decodebin ! audioconvert ! alsasink]
pipeline = gst.Pipeline("server")
tcpsrc = gst.element_factory_make("tcpserversrc", "source")
pipeline.add(tcpsrc)
tcpsrc.set_property("host", "127.0.0.1")
tcpsrc.set_property("port", 3000)
decode = gst.element_factory_make("decodebin", "decode")
decode.connect("new-decoded-pad", new_decode_pad)
pipeline.add(decode)
tcpsrc.link(decode)
convert = gst.element_factory_make("audioconvert", "convert")
pipeline.add(convert)
sink = gst.element_factory_make("alsasink", "sink")
pipeline.add(sink)
convert.link(sink)
pipeline.set_state(gst.STATE_PLAYING)
# enter into a mainloop
loop = gobject.MainLoop()
loop.run()