• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1#!/bin/sh
2#
3# A simple RTP server
4#  sends the output of v4l2src as h264 encoded RTP on port 5000, RTCP is sent on
5#  port 5001. The destination is 127.0.0.1.
6#  the video receiver RTCP reports are received on port 5005
7#  sends the output of autoaudiosrc as alaw encoded RTP on port 5002, RTCP is sent on
8#  port 5003. The destination is 127.0.0.1.
9#  the receiver RTCP reports are received on port 5007
10#
11#  .-------.    .-------.    .-------.      .----------.     .-------.
12#  |v4lssrc|    |h264enc|    |h264pay|      | rtpbin   |     |udpsink|  RTP
13#  |      src->sink    src->sink    src->send_rtp send_rtp->sink     | port=5000
14#  '-------'    '-------'    '-------'      |          |     '-------'
15#                                           |          |
16#                                           |          |     .-------.
17#                                           |          |     |udpsink|  RTCP
18#                                           |    send_rtcp->sink     | port=5001
19#                            .-------.      |          |     '-------' sync=false
20#                 RTCP       |udpsrc |      |          |               async=false
21#               port=5005    |     src->recv_rtcp      |
22#                            '-------'      |          |
23#                                           |          |
24# .--------.    .-------.    .-------.      |          |     .-------.
25# |audiosrc|    |alawenc|    |pcmapay|      | rtpbin   |     |udpsink|  RTP
26# |       src->sink    src->sink    src->send_rtp send_rtp->sink     | port=5002
27# '--------'    '-------'    '-------'      |          |     '-------'
28#                                           |          |
29#                                           |          |     .-------.
30#                                           |          |     |udpsink|  RTCP
31#                                           |    send_rtcp->sink     | port=5003
32#                            .-------.      |          |     '-------' sync=false
33#                 RTCP       |udpsrc |      |          |               async=false
34#               port=5007    |     src->recv_rtcp      |
35#                            '-------'      '----------'
36#
37# ideally we should transport the properties on the RTP udpsink pads to the
38# receiver in order to transmit the SPS and PPS earlier.
39
40# change this to send the RTP data and RTCP to another host
41DEST=127.0.0.1
42
43# tuning parameters to make the sender send the streams out of sync. Can be used
44# ot test the client RTCP synchronisation.
45#VOFFSET=900000000
46VOFFSET=0
47AOFFSET=0
48
49# H264 encode from the source
50VELEM="v4l2src"
51#VELEM="videotestsrc is-live=1"
52VCAPS="video/x-raw,width=352,height=288,framerate=15/1"
53VSOURCE="$VELEM ! queue ! videorate ! videoconvert ! $VCAPS"
54VENC="x264enc tune=zerolatency byte-stream=true bitrate=300 ! rtph264pay"
55
56VRTPSINK="udpsink port=5000 host=$DEST ts-offset=$VOFFSET name=vrtpsink"
57VRTCPSINK="udpsink port=5001 host=$DEST sync=false async=false name=vrtcpsink"
58VRTCPSRC="udpsrc port=5005 name=vrtpsrc"
59
60# PCMA encode from the source
61AELEM="autoaudiosrc"
62#AELEM="audiotestsrc is-live=1"
63ASOURCE="$AELEM ! queue ! audioresample ! audioconvert"
64AENC="alawenc ! rtppcmapay"
65
66ARTPSINK="udpsink port=5002 host=$DEST ts-offset=$AOFFSET name=artpsink"
67ARTCPSINK="udpsink port=5003 host=$DEST sync=false async=false name=artcpsink"
68ARTCPSRC="udpsrc port=5007 name=artpsrc"
69
70gst-launch-1.0 -v rtpbin name=rtpbin \
71    $VSOURCE ! $VENC ! rtpbin.send_rtp_sink_0                                             \
72        rtpbin.send_rtp_src_0 ! $VRTPSINK                                                 \
73        rtpbin.send_rtcp_src_0 ! $VRTCPSINK                                               \
74      $VRTCPSRC ! rtpbin.recv_rtcp_sink_0                                                 \
75    $ASOURCE ! $AENC ! rtpbin.send_rtp_sink_1                                             \
76        rtpbin.send_rtp_src_1 ! $ARTPSINK                                                 \
77        rtpbin.send_rtcp_src_1 ! $ARTCPSINK                                               \
78      $ARTCPSRC ! rtpbin.recv_rtcp_sink_1
79