Skip to content

Instantly share code, notes, and snippets.

@half2me
Created April 23, 2020 19:23
Show Gist options
  • Star 4 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save half2me/dfa35245016a2e0f1fe969bd490d1187 to your computer and use it in GitHub Desktop.
Save half2me/dfa35245016a2e0f1fe969bd490d1187 to your computer and use it in GitHub Desktop.
RTSP authentication with python and gst-rtsp-server
server = GstRtspServer.RTSPServer()
auth = GstRtspServer.RTSPAuth()
token = GstRtspServer.RTSPToken()
token.set_string('media.factory.role', "user")
basic = GstRtspServer.RTSPAuth.make_basic("user", "password")
auth.add_basic(basic, token)
server.set_auth(auth)
factory = RtspFactory()
permissions = GstRtspServer.RTSPPermissions()
permissions.add_permission_for_role("user", "media.factory.access", True)
permissions.add_permission_for_role("user", "media.factory.construct", True)
factory.set_permissions(permissions)
@siretru
Copy link

siretru commented Apr 22, 2024

Hello,

I really appreciate this piece of code and sharing it.

Given your knowledge of this subject, I was wondering if you had any idea how difficult it would be to implement a gstRtspServer.RTSPServer() using TLS? There's a GStreamer example here implementing this functionality in C: GStreamer RTSP server with TLS

Unfortunately I haven't managed to translate this into python...

@half2me
Copy link
Author

half2me commented Apr 22, 2024

@siretru I've never tried, but looking at the auth class: https://lazka.github.io/pgi-docs/GstRtspServer-1.0/classes/RTSPAuth.html it seems to have options for TLS.

@siretru
Copy link

siretru commented Apr 22, 2024

That's what I'm trying to do.
The problem is that in the implemented c code I've shared, I manage to consume the stream with authentication enabled. When I activate TLS, there's no way of consuming the stream...

Thanks for your answer

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment