mirror of
https://gitlab.freedesktop.org/gstreamer/gstreamer.git
synced 2025-01-22 15:18:21 +00:00
test-record-auth: Add the option to build in TLS support
This commit is contained in:
parent
a062b9c562
commit
eaf7b1488c
1 changed files with 48 additions and 0 deletions
|
@ -23,6 +23,9 @@
|
|||
|
||||
#include <gst/rtsp-server/rtsp-server.h>
|
||||
|
||||
/* define this if you want the server to use TLS */
|
||||
//#define WITH_TLS
|
||||
|
||||
#define DEFAULT_RTSP_PORT "8554"
|
||||
|
||||
static char *port = (char *) DEFAULT_RTSP_PORT;
|
||||
|
@ -45,6 +48,9 @@ main (int argc, char *argv[])
|
|||
GstRTSPAuth *auth;
|
||||
GstRTSPToken *token;
|
||||
gchar *basic;
|
||||
#ifdef WITH_TLS
|
||||
GTlsCertificate *cert;
|
||||
#endif
|
||||
|
||||
optctx = g_option_context_new ("<launch line> - Test RTSP Server, Launch\n\n"
|
||||
"Example: \"( decodebin name=depay0 ! autovideosink )\"");
|
||||
|
@ -79,6 +85,13 @@ main (int argc, char *argv[])
|
|||
GST_RTSP_TRANSPORT_MODE_RECORD);
|
||||
gst_rtsp_media_factory_set_launch (factory, argv[1]);
|
||||
gst_rtsp_media_factory_set_latency (factory, 2000);
|
||||
#ifdef WITH_TLS
|
||||
gst_rtsp_media_factory_set_profiles (factory,
|
||||
GST_RTSP_PROFILE_SAVP | GST_RTSP_PROFILE_SAVPF);
|
||||
#else
|
||||
gst_rtsp_media_factory_set_profiles (factory,
|
||||
GST_RTSP_PROFILE_AVP | GST_RTSP_PROFILE_AVPF);
|
||||
#endif
|
||||
|
||||
/* allow user to access this resource */
|
||||
gst_rtsp_media_factory_add_role (factory, "user",
|
||||
|
@ -98,6 +111,37 @@ main (int argc, char *argv[])
|
|||
/* Set up the auth for user account */
|
||||
/* make a new authentication manager */
|
||||
auth = gst_rtsp_auth_new ();
|
||||
#ifdef WITH_TLS
|
||||
cert = g_tls_certificate_new_from_pem ("-----BEGIN CERTIFICATE-----"
|
||||
"MIICJjCCAY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QZbT/2xq9dUc9GW"
|
||||
"U3kiVw4lL8v/+sPjtTPCYYdzHHOyDen6znVhAiEA9qJT7BtQvRxCvGrAhr9MS022"
|
||||
"tTdPbW829BoUtIeH64cCIQDggG5i48v7HPacPBIH1RaSVhXl8qHCpQD3qrIw3FMw"
|
||||
"DwIga8PqH5Sf5sHedy2+CiK0V4MRfoU4c3zQ6kArI+bEgSkCIQCLA1vXBiE31B5s"
|
||||
"bdHoYa1BXebfZVd+1Hd95IfEM5mbRwIgSkDuQwV55BBlvWph3U8wVIMIb4GStaH8"
|
||||
"W535W8UBbEg=" "-----END PRIVATE KEY-----", -1, &error);
|
||||
if (cert == NULL) {
|
||||
g_printerr ("failed to parse PEM: %s\n", error->message);
|
||||
return -1;
|
||||
}
|
||||
gst_rtsp_auth_set_tls_certificate (auth, cert);
|
||||
g_object_unref (cert);
|
||||
#endif
|
||||
|
||||
/* make default token - anonymous unauthenticated access */
|
||||
token =
|
||||
|
@ -123,7 +167,11 @@ main (int argc, char *argv[])
|
|||
gst_rtsp_server_attach (server, NULL);
|
||||
|
||||
/* start serving */
|
||||
#ifdef WITH_TLS
|
||||
g_print ("stream ready at rtsps://127.0.0.1:%s/test\n", port);
|
||||
#else
|
||||
g_print ("stream ready at rtsp://127.0.0.1:%s/test\n", port);
|
||||
#endif
|
||||
g_main_loop_run (loop);
|
||||
|
||||
return 0;
|
||||
|
|
Loading…
Reference in a new issue