RTSP authentication with python and gst-rtsp-server

It’s not as easy as it would seem to enable authentication on an rtsp resource with gst-rtsp-server. There are test cases, tutorials and documentation for C, but not really anything usable for python. I spent the better part of a day debugging, searching, and failing to enable authentication.

Here is a solution which actually works.

First we create an RTSPServer instance. Then we create an RTSPAuth and RTSPToken object.
On the token, we need to set the media.factory.role string to the value of the username.
Here we just use basic authentication which we set on the auth object, and then set it on the server instance.

In our factory, we also need to set some things up:

This allows access for the user that we specified.

Leave a Reply

Your email address will not be published. Required fields are marked *

This site uses Akismet to reduce spam. Learn how your comment data is processed.