GstRtspSink - Basic Authentication: Difference between revisions
mNo edit summary |
Crodriguez (talk | contribs) |
||
(6 intermediate revisions by 4 users not shown) | |||
Line 1: | Line 1: | ||
{{GstRtspSink | {{GstRtspSink/Head|previous=RTSP_over_HTTP_Tunneling|next=Stream_Encryption|metakeywords=}} | ||
The page describes how to use the basic RTSP authentication shipped with GstRtspSink. | The page describes how to use the basic RTSP authentication shipped with GstRtspSink. | ||
Line 9: | Line 7: | ||
== Configuring Authentication == | == Configuring Authentication == | ||
GstRtspSink can be configured to allow streaming to a restricted set username/ | [https://www.ridgerun.com/gst-multistream-rtspserver 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: | The '''auth''' property syntax adheres to the following syntax: | ||
Line 22: | Line 20: | ||
gst-launch-1.0 videotestsrc ! x264enc ! video/x-h264, mapping=/stream1 ! rtspsink service=5000 auth=adrian:cervantes,user:pass | gst-launch-1.0 videotestsrc ! x264enc ! video/x-h264, mapping=/stream1 ! rtspsink service=5000 auth=adrian:cervantes,user:pass | ||
</syntaxhighlight> | </syntaxhighlight> | ||
== Considerations == | == Considerations == | ||
Line 43: | Line 40: | ||
<syntaxhighlight lang='bash'> | <syntaxhighlight lang='bash'> | ||
gst-launch-1.0 videotestsrc is-live=true ! x264enc tune=zerolatency ! capsfilter caps="video/x- | 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 | ||
</syntaxhighlight> | </syntaxhighlight> | ||
Line 71: | Line 68: | ||
USER=anonymous | USER=anonymous | ||
PASSWORD=secret | PASSWORD=secret | ||
gst-launch-1.0 rtspsrc location="rtsp://${USER}:${PASSWORD}@${SERVER_IP}:${PORT}/${MAPPING}" ! rtph264depay ! decodebin ! autovideosink | gst-launch-1.0 rtspsrc location="rtsp://${USER}:${PASSWORD}@${SERVER_IP}:${PORT}/${MAPPING}" ! rtph264depay ! decodebin ! videoconvert ! autovideosink | ||
</syntaxhighlight> | </syntaxhighlight> | ||
}} | |||
{{GstRtspSink/Foot|previous=RTSP_over_HTTP_Tunneling|next=Stream_Encryption}} |
Latest revision as of 21:51, 18 October 2023
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