summaryrefslogtreecommitdiff
path: root/bin/recv-gst-rtp-v-a
blob: e767fc96d87ea408cbc8f87866d885940ff9963e (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. ID=$1
  37. CAPS=$2
  38. PLAYBIN=$3
  39. echo \
  40. udpsrc port=$((5000+ID-1)) $RECHOST caps=\""$CAPS"\" \
  41. ! rtpbin."recv_rtp_sink_$ID" rtpbin. \
  42. ! $PLAYBIN \
  43. udpsrc port=$((5010+ID-1)) "$RECHOST" \
  44. ! rtpbin."recv_rtcp_sink_$ID" \
  45. rtpbin."send_rtcp_src_$ID" \
  46. ! udpsink port=$((5020+ID-1)) "$CAMHOST" sync=false async=false
  47. }
  48. gst-launch-1.0 -v \
  49. rtpbin name=rtpbin \
  50. $(for i in $(seq "${VCOUNT:-1}"); do stream "$i" "$VCAPS" "$VDEC ! autovideosink"; done) \
  51. $(for j in $(seq "${ACOUNT:-0}"); do stream $((VCOUNT+j)) "$ACAPS" "$ADEC ! autoaudiosink"; done)