summaryrefslogtreecommitdiff
path: root/bin/recv-gst-rtp-v-a
blob: 88c874a020549a242350b31253addbab6ddc4b92 (plain)
  1. #!/bin/sh
  2. # Receive RTP video and audio streams
  3. set -e
  4. CAMIP=${CAMIP:-$1} # origin host - default: use multicast group
  5. VCOUNT=${VCOUNT:-$2} # number of video stream(s) to display - default: 1
  6. ACOUNT=${ACOUNT:-$3} # number of audio stream(s) to play - default: 0
  7. VIDEO=${VIDEO:-$4} # H264 VP8 RAW - default: H264
  8. AUDIO=${AUDIO:-$5} # AMR - default: AMR
  9. set -u
  10. # set multicast groups (also for recorder host) if camera host is wildcard
  11. [ -n "$CAMIP" ] || RECMIP=239.255.0.1
  12. [ -n "$CAMIP" ] || CAMMIP=239.255.0.2
  13. RECHOST="${RECMIP:+address=$RECMIP auto-multicast=true}"
  14. CAMHOST="${CAMIP:+host=$CAMIP}${CAMMIP:+host=$CAMMIP auto-multicast=true}"
  15. case "$VIDEO" in
  16. H264|'')
  17. VCAPS="application/x-rtp,media=video,clock-rate=90000,payload=96,encoding-name=H264"
  18. VDEC="rtph264depay ! avdec_h264"
  19. ;;
  20. VP8)
  21. VCAPS="application/x-rtp,media=video,clock-rate=90000,payload=96,encoding-name=VP8"
  22. VDEC="rtpvp8depay ! vp8dec"
  23. ;;
  24. RAW)
  25. 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"
  26. VDEC="rtpvrawdepay ! videoconvert ! queue"
  27. ;;
  28. esac
  29. case "$AUDIO" in
  30. AMR|'')
  31. ACAPS="application/x-rtp,media=audio,clock-rate=8000,encoding-name=AMR,encoding-params=1,octet-align=1"
  32. ADEC="rtpamrdepay ! amrnbdec"
  33. ;;
  34. esac
  35. stream() {
  36. RTPSRCPORT=$((5000+$1-1))
  37. RTCPSRCPORT=$((5010+$1-1))
  38. RTCPSINKPORT=$((5020+$1-1))
  39. CAPS=$2
  40. PLAYBIN=$3
  41. echo \
  42. udpsrc port=$RTPSRCPORT $RECHOST caps=\""$CAPS"\" \
  43. ! rtpbin.recv_rtp_sink_$1 rtpbin. \
  44. ! $PLAYBIN \
  45. udpsrc port=$RTCPSRCPORT $RECHOST ! rtpbin.recv_rtcp_sink_$1 \
  46. rtpbin.send_rtcp_src_$1 \
  47. ! udpsink port=$RTCPSINKPORT $CAMHOST sync=false async=false
  48. }
  49. gst-launch-1.0 -v \
  50. rtpbin name=rtpbin \
  51. $(for i in $(seq ${VCOUNT:-1}); do stream "$i" "$VCAPS" "$VDEC ! autovideosink"; done) \
  52. $(for j in $(seq ${ACOUNT:-0}); do stream $((VCOUNT+$j)) "$ACAPS" "$ADEC ! autoaudiosink"; done)