GstRtspSink - Basic Authentication

From RidgeRun Developer Wiki


Previous: RTSP_over_HTTP_Tunneling Index Next: Stream_Encryption




The page describes how to use the basic RTSP authentication shipped with GstRtspSink.

Configuring Authentication

GstRtspSink can be configured to allow streaming to a restricted set username/password pairs. To do so, use the auth property.

The auth property syntax adheres to the following syntax:

auth=user1:password1,user2:password2,....userN:passwordN

The following example will allow streaming to two different users: adrian and user. Their passwords are, respectively: cervantes and pass.

gst-launch-1.0 videotestsrc ! x264enc ! video/x-h264, mapping=/stream1  ! rtspsink service=5000 auth=adrian:cervantes,user:pass

Considerations

  • If the "auth" property is not set, the clients will not require any authentication from the server.
  • If a user entry is malformed, GstRtspSink will ignore it and will continue processing the rest. For example, the following snippet is malformed because there are no colons ":" after user1.
rtspsink service=5000 auth=adrian:cervantes,user1,user:pass

In such case, user1 would be ignored.

  • If a user has an empty password, that user will not need a password to connect. For example:
 rtspsink service=5000 auth=user:

Streaming will be restricted to user but a password will not be required.


Receiving the Stream

The following subsections show, as examples, how to connect to an authenticated session from two standard clients: VLC and GStreamer. Both examples assume that GstRtspSink was started as the following:

gst-launch-1.0 videotestsrc is-live=true ! x264enc tune=zerolatency ! capsfilter caps="video/x-h264,mapping=/auth_test" ! rtspsink auth=anonymous:secret service=5000

VLC

To connect via VLC you may provide the username and password directly:

SERVER_IP=localhost
PORT=5000
MAPPING=auth_test
USER=anonymous
PASSWORD=secret
vlc rtsp://${USER}:${PASSWORD}@${SERVER_IP}:${PORT}/${MAPPING}

Additionally, the username and password can be left out of the command, in which case VLC will prompt for them in a dialog.

GStreamer

To connect via GstRtspSrc you provide the username and password directly into the URI.

SERVER_IP=localhost
PORT=5000
MAPPING=auth_test
USER=anonymous
PASSWORD=secret
gst-launch-1.0 rtspsrc location="rtsp://${USER}:${PASSWORD}@${SERVER_IP}:${PORT}/${MAPPING}" ! rtph264depay !  decodebin ! videoconvert ! autovideosink



Previous: RTSP_over_HTTP_Tunneling Index Next: Stream_Encryption