summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJonas Smedegaard <dr@jones.dk>2017-02-26 15:16:00 +0100
committerJonas Smedegaard <dr@jones.dk>2017-02-26 15:16:00 +0100
commit63f25d1e4b4a69cca51e8319d8270f5ccdbb721b (patch)
treebfe4cbca441fdbd58a218dfccb04ba30d2f8e9b1
Initial RTP receiver.
-rwxr-xr-xbin/recv-gst-rtp-v-a59
1 files changed, 59 insertions, 0 deletions
diff --git a/bin/recv-gst-rtp-v-a b/bin/recv-gst-rtp-v-a
new file mode 100755
index 0000000..88c874a
--- /dev/null
+++ b/bin/recv-gst-rtp-v-a
@@ -0,0 +1,59 @@
+#!/bin/sh
+
+# Receive RTP video and audio streams
+
+set -e
+CAMIP=${CAMIP:-$1} # origin host - default: use multicast group
+VCOUNT=${VCOUNT:-$2} # number of video stream(s) to display - default: 1
+ACOUNT=${ACOUNT:-$3} # number of audio stream(s) to play - default: 0
+VIDEO=${VIDEO:-$4} # H264 VP8 RAW - default: H264
+AUDIO=${AUDIO:-$5} # AMR - default: AMR
+set -u
+
+# set multicast groups (also for recorder host) if camera host is wildcard
+[ -n "$CAMIP" ] || RECMIP=239.255.0.1
+[ -n "$CAMIP" ] || CAMMIP=239.255.0.2
+RECHOST="${RECMIP:+address=$RECMIP auto-multicast=true}"
+CAMHOST="${CAMIP:+host=$CAMIP}${CAMMIP:+host=$CAMMIP auto-multicast=true}"
+
+case "$VIDEO" in
+ H264|'')
+ VCAPS="application/x-rtp,media=video,clock-rate=90000,payload=96,encoding-name=H264"
+ VDEC="rtph264depay ! avdec_h264"
+ ;;
+ VP8)
+ VCAPS="application/x-rtp,media=video,clock-rate=90000,payload=96,encoding-name=VP8"
+ VDEC="rtpvp8depay ! vp8dec"
+ ;;
+ RAW)
+ VCAPS="application/x-rtp,media=video,clock-rate=90000,encoding-name=RAW,sampling=YCbCr-4:2:0,depth=(string)8,width=(string)432,height=(string)240,colorimetry=BT601-5,payload=96,ssrc=(uint)2753200816,timestamp-offset=(uint)2145434971,seqnum-offset=(uint)15312,a-framerate=(string)30"
+ VDEC="rtpvrawdepay ! videoconvert ! queue"
+ ;;
+esac
+
+case "$AUDIO" in
+ AMR|'')
+ ACAPS="application/x-rtp,media=audio,clock-rate=8000,encoding-name=AMR,encoding-params=1,octet-align=1"
+ ADEC="rtpamrdepay ! amrnbdec"
+ ;;
+esac
+
+stream() {
+ RTPSRCPORT=$((5000+$1-1))
+ RTCPSRCPORT=$((5010+$1-1))
+ RTCPSINKPORT=$((5020+$1-1))
+ CAPS=$2
+ PLAYBIN=$3
+ echo \
+ udpsrc port=$RTPSRCPORT $RECHOST caps=\""$CAPS"\" \
+ ! rtpbin.recv_rtp_sink_$1 rtpbin. \
+ ! $PLAYBIN \
+ udpsrc port=$RTCPSRCPORT $RECHOST ! rtpbin.recv_rtcp_sink_$1 \
+ rtpbin.send_rtcp_src_$1 \
+ ! udpsink port=$RTCPSINKPORT $CAMHOST sync=false async=false
+}
+
+gst-launch-1.0 -v \
+ rtpbin name=rtpbin \
+ $(for i in $(seq ${VCOUNT:-1}); do stream "$i" "$VCAPS" "$VDEC ! autovideosink"; done) \
+ $(for j in $(seq ${ACOUNT:-0}); do stream $((VCOUNT+$j)) "$ACAPS" "$ADEC ! autoaudiosink"; done)