|
@@ -20,23 +20,23 @@ def bus_call(bus, msg, *args):
|
|
|
return True
|
|
return True
|
|
|
|
|
|
|
|
zoom = 1
|
|
zoom = 1
|
|
|
-direction=1
|
|
|
|
|
def quit():
|
|
def quit():
|
|
|
pipeline.send_event(Gst.Event.new_eos())
|
|
pipeline.send_event(Gst.Event.new_eos())
|
|
|
|
|
|
|
|
-def unset_preview():
|
|
|
|
|
- videosrc.set_property("preview-x", 800)
|
|
|
|
|
- videosrc.set_property("preview-y", 600)
|
|
|
|
|
-
|
|
|
|
|
-def set_preview():
|
|
|
|
|
- videosrc.set_property("preview-x", 0)
|
|
|
|
|
- videosrc.set_property("preview-y", 0)
|
|
|
|
|
|
|
+def set_preview(val):
|
|
|
|
|
+ if val == 0:
|
|
|
|
|
+ videosrc.set_property("preview-x", 800)
|
|
|
|
|
+ videosrc.set_property("preview-y", 600)
|
|
|
|
|
+ else:
|
|
|
|
|
+ videosrc.set_property("preview-x", 0)
|
|
|
|
|
+ videosrc.set_property("preview-y", 0)
|
|
|
|
|
|
|
|
def set_zoom(target):
|
|
def set_zoom(target):
|
|
|
global zoom
|
|
global zoom
|
|
|
- direction = 1
|
|
|
|
|
if target < zoom:
|
|
if target < zoom:
|
|
|
direction = -1
|
|
direction = -1
|
|
|
|
|
+ else:
|
|
|
|
|
+ direction = 1
|
|
|
|
|
|
|
|
target=min(target, 1)
|
|
target=min(target, 1)
|
|
|
target=max(target, 0.50)
|
|
target=max(target, 0.50)
|
|
@@ -44,7 +44,7 @@ def set_zoom(target):
|
|
|
while abs(target-zoom) > 0.01: #fuck IEEE floats
|
|
while abs(target-zoom) > 0.01: #fuck IEEE floats
|
|
|
zoom = zoom + direction*0.015
|
|
zoom = zoom + direction*0.015
|
|
|
zoom = min(zoom, 1)
|
|
zoom = min(zoom, 1)
|
|
|
- zoom = max(zoom, 0.50)
|
|
|
|
|
|
|
+ zoom = max(zoom, 0.4)
|
|
|
videosrc.set_property("roi-x", (1-zoom)/2)
|
|
videosrc.set_property("roi-x", (1-zoom)/2)
|
|
|
videosrc.set_property("roi-y", (1-zoom)/2)
|
|
videosrc.set_property("roi-y", (1-zoom)/2)
|
|
|
videosrc.set_property("roi-w", zoom)
|
|
videosrc.set_property("roi-w", zoom)
|
|
@@ -73,18 +73,23 @@ def control():
|
|
|
while True:
|
|
while True:
|
|
|
with open(FIFO) as fifo:
|
|
with open(FIFO) as fifo:
|
|
|
line=fifo.read().strip()
|
|
line=fifo.read().strip()
|
|
|
- if line=="preview":
|
|
|
|
|
- set_preview()
|
|
|
|
|
- if line=="nopreview":
|
|
|
|
|
- unset_preview()
|
|
|
|
|
- if "zoom=" in line:
|
|
|
|
|
- level = float(line.split("=")[1])
|
|
|
|
|
- set_zoom(level)
|
|
|
|
|
- if "client=" in line:
|
|
|
|
|
- client = line.split("=")[1]
|
|
|
|
|
- add_client(client)
|
|
|
|
|
-
|
|
|
|
|
print("Got: ", line)
|
|
print("Got: ", line)
|
|
|
|
|
+ if "=" not in line:
|
|
|
|
|
+ print("Invalid line.")
|
|
|
|
|
+ continue
|
|
|
|
|
+ key = line.split("=")[0]
|
|
|
|
|
+ val = line.split("=")[1]
|
|
|
|
|
+
|
|
|
|
|
+ if key == "preview":
|
|
|
|
|
+ set_preview(val)
|
|
|
|
|
+
|
|
|
|
|
+ if key == "zoom":
|
|
|
|
|
+ set_zoom(float(val))
|
|
|
|
|
+
|
|
|
|
|
+ if key == "client" :
|
|
|
|
|
+ add_client(val)
|
|
|
|
|
+
|
|
|
|
|
+
|
|
|
if __name__ == "__main__":
|
|
if __name__ == "__main__":
|
|
|
# initialization
|
|
# initialization
|
|
|
Gst.init(None)
|
|
Gst.init(None)
|
|
@@ -99,9 +104,9 @@ if __name__ == "__main__":
|
|
|
videosrc = pipeline.get_by_name ("src")
|
|
videosrc = pipeline.get_by_name ("src")
|
|
|
videosrc.set_property("preview", 1)
|
|
videosrc.set_property("preview", 1)
|
|
|
videosrc.set_property("fullscreen", False)
|
|
videosrc.set_property("fullscreen", False)
|
|
|
- videosrc.set_property("bitrate", 300000)
|
|
|
|
|
|
|
+ videosrc.set_property("bitrate", 800000)
|
|
|
videosrc.set_property("rotation", 180)
|
|
videosrc.set_property("rotation", 180)
|
|
|
- unset_preview()
|
|
|
|
|
|
|
+ set_preview(0)
|
|
|
|
|
|
|
|
sink = pipeline.get_by_name ("out")
|
|
sink = pipeline.get_by_name ("out")
|
|
|
sink.set_property("clients", ",".join(["192.168.2.120:5000"]))
|
|
sink.set_property("clients", ",".join(["192.168.2.120:5000"]))
|