109 lines
3.4 KiB
Bash
Executable File
109 lines
3.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: using different players is a nasty hack)
|
|
GSTXID="$(wmctrl -l | grep "OpenGL renderer" | cut -d" " -f1)" >/dev/null 2>&1
|
|
wmctrl -i -r "$GSTXID" -e 0,2000,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 $!"
|
|
|
|
# receive audio stream from cam1
|
|
amixer -c0 sset 'Master' 100%
|
|
amixer -c0 sset 'PCM' 0%
|
|
(
|
|
while true; do
|
|
gst-launch-1.0 -v udpsrc address=:: port=5008 caps="application/x-rtp" ! rtpjitterbuffer latency=20 do-lost=True ! rtpopusdepay ! opusdec plc=true ! alsasink device=hw:0
|
|
done
|
|
) &
|
|
PIDS="$PIDS $!"
|
|
|
|
# send audio stream to cam1
|
|
amixer -c0 sset 'Mic' 100%
|
|
(
|
|
while true; do
|
|
gst-launch-1.0 -vv alsasrc device=plughw:0 ! audioconvert ! audioresample ! opusenc ! rtpopuspay ! udpsink host=cam1 port=5007
|
|
done
|
|
) &
|
|
PIDS="$PIDS $!"
|
|
|
|
# receive video stream from cam2
|
|
(
|
|
while true; do
|
|
gst-launch-1.0 -e rtpbin name=b rtp-profile=avpf do-retransmission=true \
|
|
udpsrc address=:: port=5004 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 ! xvimagesink \
|
|
udpsrc address=:: port=5006 ! b.recv_rtcp_sink_0 \
|
|
b.send_rtcp_src_0 ! udpsink host=cam2 port=5005 sync=false async=false &
|
|
GSTPID=$!
|
|
|
|
while true; do
|
|
# rename window (FIXME: using different players is a nasty hack)
|
|
GSTXID="$(wmctrl -l | grep "gst-launch-1.0" | 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" -b add,fullscreen >/dev/null 2>&1
|
|
wmctrl -i -r "$GSTXID" -b add,above >/dev/null 2>&1
|
|
wmctrl -i -r "$GSTXID" -N gst-cam2 >/dev/null 2>&1 && break
|
|
kill -s 0 $GSTPID || break
|
|
sleep .2
|
|
done
|
|
|
|
wait $GSTPID
|
|
sleep .2
|
|
done
|
|
) &
|
|
PIDS="$PIDS $!"
|
|
|
|
# receive audio stream from cam2
|
|
amixer -c1 sset 'Speaker' 100%
|
|
(
|
|
while true; do
|
|
gst-launch-1.0 -v udpsrc address=:: port=5010 caps="application/x-rtp" ! rtpjitterbuffer latency=20 do-lost=True ! rtpopusdepay ! opusdec plc=true ! alsasink device=hw:1
|
|
done
|
|
) &
|
|
PIDS="$PIDS $!"
|
|
|
|
# send audio stream to cam2
|
|
amixer -c1 sset 'Master' 100%
|
|
(
|
|
while true; do
|
|
gst-launch-1.0 -vv alsasrc device=plughw:1 ! audioconvert ! audioresample ! opusenc ! rtpopuspay ! udpsink host=cam1 port=5009
|
|
done
|
|
) &
|
|
PIDS="$PIDS $!"
|
|
|
|
|
|
wait $PIDS
|