LiveCam/terminal1/start.sh

46 lines
1.4 KiB
Bash
Executable File

#! /bin/bash
trap do_exit INT
PIDS=""
do_exit() {
kill $PIDS >/dev/null 2>&1
sleep 10
kill -9 $PIDS >/dev/null 2>&1
pkill -9 gst-launch-1.0
}
export DISPLAY=:0
(sleep 60; export DISPLAY=:0; xset s off; xset -dpms; xset s noblank) &
# receive video stream from cam1
(
while true; do
gst-launch-1.0 -e rtpbin name=b rtp-profile=avpf do-retransmission=true \
udpsrc address=:: port=5001 caps="application/x-rtp, media=(string)video, clock-rate=(int)90000, encoding-name=(string)H264, payload=(int)96" ! b.recv_rtp_sink_0 b. ! rtpulpfecdec ! rtph264depay ! decodebin ! videoconvert ! videoscale ! video/x-raw,width=1024,height=786 ! glimagesink \
udpsrc address=:: port=5003 ! b.recv_rtcp_sink_0 \
b.send_rtcp_src_0 ! udpsink host=cam1 port=5002 sync=false async=false &
GSTPID=$!
while true; do
# rename window (FIXME: possible race condition with window for cam 2)
GSTXID="$(wmctrl -l | grep "OpenGL renderer" | cut -d" " -f1)" >/dev/null 2>&1
wmctrl -i -r "$GSTXID" -e 0,0,0,1000,1000 >/dev/null 2>&1
# wmctrl -i -r "$GSTXID" -e 0,1500,0,1000,1000 >/dev/null 2>&1
wmctrl -i -r "$GSTXID" -b add,fullscreen >/dev/null 2>&1
wmctrl -i -r "$GSTXID" -b add,above >/dev/null 2>&1
wmctrl -i -r "$GSTXID" -N gst-cam1 >/dev/null 2>&1 && break
kill -s 0 $GSTPID || break
sleep .2
done
wait $GSTPID
sleep .2
done
) &
PIDS="$PIDS $!"
wait $PIDS