summaryrefslogtreecommitdiff
path: root/example-scripts/gstreamer/source-remote-desktop-as-cam1.py
diff options
context:
space:
mode:
authorMaZderMind <git@mazdermind.de>2016-02-05 12:54:25 +0100
committerMaZderMind <git@mazdermind.de>2016-02-05 12:54:25 +0100
commit9ad4f83327c472a7119d105891416b8c9cc3cdd1 (patch)
treeb449059f073b2cfb8da9d016c58712cebae81857 /example-scripts/gstreamer/source-remote-desktop-as-cam1.py
parent5408b306ca699b3f8a64aaa1e5ae70ceecdfcd18 (diff)
honour the example-script config.sh in the py-source-files
Diffstat (limited to 'example-scripts/gstreamer/source-remote-desktop-as-cam1.py')
-rwxr-xr-xexample-scripts/gstreamer/source-remote-desktop-as-cam1.py29
1 files changed, 17 insertions, 12 deletions
diff --git a/example-scripts/gstreamer/source-remote-desktop-as-cam1.py b/example-scripts/gstreamer/source-remote-desktop-as-cam1.py
index 686cc73..7d1c7f2 100755
--- a/example-scripts/gstreamer/source-remote-desktop-as-cam1.py
+++ b/example-scripts/gstreamer/source-remote-desktop-as-cam1.py
@@ -1,5 +1,5 @@
#!/usr/bin/python3
-import sys, gi, signal
+import os, sys, gi, signal
import argparse, socket
gi.require_version('Gst', '1.0')
@@ -10,8 +10,7 @@ GObject.threads_init()
Gst.init([])
class Source(object):
- def __init__(self, ip):
- # it works much better with a local file
+ def __init__(self, settings):
pipeline = """
ximagesrc use-damage=0 startx=0 starty=0 endx=1919 endy=1079 !
queue !
@@ -19,28 +18,26 @@ class Source(object):
videorate !
timeoverlay !
videoconvert !
- video/x-raw,format=I420,width=1280,height=720,framerate=25/1,pixel-aspect-ratio=1/1 !
+ video/x-raw,format=I420,width={WIDTH},height={HEIGHT},framerate={FRAMERATE}/1,pixel-aspect-ratio=1/1 !
queue !
mux.
pulsesrc !
- audio/x-raw,format=S16LE,channels=2,layout=interleaved,rate=48000 !
+ audio/x-raw,format=S16LE,channels=2,layout=interleaved,rate={AUDIORATE} !
queue !
mux.
matroskamux name=mux !
- tcpclientsink host={ip} port=10000
- """.format(
- ip=ip
- )
+ tcpclientsink host={IP} port=10000
+ """.format_map(settings)
- self.clock = GstNet.NetClientClock.new('voctocore', ip, 9998, 0)
+ self.clock = GstNet.NetClientClock.new('voctocore', settings['IP'], 9998, 0)
print('obtained NetClientClock from host', self.clock)
print('waiting for NetClientClock to sync…')
self.clock.wait_for_sync(Gst.CLOCK_TIME_NONE)
- print('starting pipeline')
+ print('starting pipeline '+pipeline)
self.senderPipeline = Gst.parse_launch(pipeline)
self.senderPipeline.use_clock(self.clock)
self.src = self.senderPipeline.get_by_name('src')
@@ -79,7 +76,15 @@ def main():
print('Using IP '+addrs[0])
- src = Source(addrs[0])
+ config = os.path.join(os.path.dirname(os.path.realpath(__file__)), '../config.sh')
+ with open(config) as config:
+ lines = [ line.strip() for line in config if line[0] != '#' ]
+ pairs = [ line.split('=', 1) for line in lines ]
+ settings = { pair[0]: pair[1] for pair in pairs }
+
+ settings['IP'] = addrs[0]
+
+ src = Source(settings)
mainloop = GObject.MainLoop()
try:
mainloop.run()