This web application consists of a simple RTP stream pipeline: an RtpEndpoint is configured in KMS to listen for one incoming video stream. This stream must be generated by an external program. Visual feedback is provided in this page, by connecting the RtpEndpoint to a WebRtcEndpoint in receive-only mode.
The Java client application connects to all events emitted from Kurento and prints log messages for each one, so this application is also a good reference to understand what are those events and their relationship with how KMS works.
To run this demo follow these steps:
You should be able to send an RTP stream to Kurento with any external
application or device that supports this kind of streams. For example,
VLC should be able to output an RTP stream, and also there are some
devices in the market -such as video surveillance cameras- which also
output an RTP stream.
For this tutorial, we provide a sample GStreamer launch command which
simulates an RTP streaming application. You just need to copy
the provided commands, substitute any placeholder with the actual
required values, and run them.
First step is to install the required dependencies for these sample
GStreamer commands:
sudo apt-get install \ gstreamer1.0-{tools,libav} gstreamer1.0-plugins-{base,good,bad,ugly} \ gstreamer1.5-{tools,libav} gstreamer1.5-plugins-{base,good,bad,ugly}
This sample GStreamer pipeline command includes the following features:
- Sends RTP and RTCP packets to KMS (for both Audio and Video streams).
- Receives and prints Video RTCP packets received from KMS.
- Binds to specific output ports for automatic RTP/RTCP port discovery.
PEER_A={KMS_AUDIO_PORT} PEER_V={KMS_VIDEO_PORT} PEER_IP={KMS_PUBLIC_IP} \ SELF_PATH="{PATH_TO_VIDEO_FILE}" \ SELF_A=5006 SELF_ASSRC=445566 \ SELF_V=5004 SELF_VSSRC=112233 \ bash -c 'gst-launch-1.0 -e \ rtpbin name=r sdes="application/x-rtp-source-sdes,cname=(string)\"user\@example.com\"" \ filesrc location="$SELF_PATH" ! decodebin name=d \ d. ! queue ! audioconvert ! opusenc \ ! rtpopuspay ! "application/x-rtp,payload=(int)96,clock-rate=(int)48000,ssrc=(uint)$SELF_ASSRC" \ ! r.send_rtp_sink_0 \ d. ! queue ! videoconvert ! x264enc tune=zerolatency \ ! rtph264pay ! "application/x-rtp,payload=(int)103,clock-rate=(int)90000,ssrc=(uint)$SELF_VSSRC" \ ! r.send_rtp_sink_1 \ r.send_rtp_src_0 ! udpsink host=$PEER_IP port=$PEER_A bind-port=$SELF_A \ r.send_rtcp_src_0 ! udpsink host=$PEER_IP port=$((PEER_A+1)) bind-port=$((SELF_A+1)) sync=false async=false \ udpsrc port=$((SELF_A+1)) ! r.recv_rtcp_sink_0 \ r.send_rtp_src_1 ! udpsink host=$PEER_IP port=$PEER_V bind-port=$SELF_V \ r.send_rtcp_src_1 ! udpsink host=$PEER_IP port=$((PEER_V+1)) bind-port=$((SELF_V+1)) sync=false async=false \ udpsrc port=$((SELF_V+1)) ! tee name=t \ t. ! queue ! r.recv_rtcp_sink_1 \ t. ! queue ! fakesink dump=true async=false'
This sample GStreamer pipeline command includes the following features:
- Sends SRTP and SRTCP packets to KMS (only for the Video stream).
- Receives and prints Video SRTCP packets received from KMS.
- Binds to specific output ports for automatic RTP/RTCP port discovery.
PEER_V={KMS_VIDEO_PORT} PEER_VSSRC={KMS_VIDEO_SSRC} PEER_IP={KMS_PUBLIC_IP} \ PEER_KEY="343332315A595857565554535251504F4E4D4C4B4A494847464544434241" \ SELF_PATH="{PATH_TO_VIDEO_FILE}" \ SELF_V=5004 SELF_VSSRC=112233 \ SELF_KEY="4142434445464748494A4B4C4D4E4F505152535455565758595A31323334" \ SRTP_CAPS="payload=(int)103,ssrc=(uint)$PEER_VSSRC,roc=(uint)0, \ srtp-key=(buffer)$PEER_KEY, \ srtp-cipher=(string)aes-128-icm,srtp-auth=(string)hmac-sha1-80, \ srtcp-cipher=(string)aes-128-icm,srtcp-auth=(string)hmac-sha1-80" \ bash -c 'gst-launch-1.5 -e \ rtpsession name=r sdes="application/x-rtp-source-sdes,cname=(string)\"user\@example.com\"" \ srtpenc name=e key="$SELF_KEY" \ rtp-cipher="aes-128-icm" rtp-auth="hmac-sha1-80" \ rtcp-cipher="aes-128-icm" rtcp-auth="hmac-sha1-80" \ srtpdec name=d \ filesrc location="$SELF_PATH" ! decodebin \ ! x264enc tune=zerolatency \ ! rtph264pay ! "application/x-rtp,payload=(int)103,ssrc=(uint)$SELF_VSSRC" \ ! r.send_rtp_sink \ r.send_rtp_src ! e.rtp_sink_0 \ e.rtp_src_0 ! udpsink host=$PEER_IP port=$PEER_V \ r.send_rtcp_src ! e.rtcp_sink_0 \ e.rtcp_src_0 ! udpsink host=$PEER_IP port=$((PEER_V+1)) sync=false async=false \ udpsrc port=$((SELF_V+1)) ! "application/x-srtcp,$SRTP_CAPS" ! d.rtcp_sink \ d.rtcp_src ! tee name=t \ t. ! queue ! r.recv_rtcp_sink \ t. ! queue ! fakesink dump=true async=false'