mirror of
https://gitlab.freedesktop.org/gstreamer/gstreamer.git
synced 2025-02-20 13:06:23 +00:00
example: add TLS example
This commit is contained in:
parent
0a285290cb
commit
d1339f60f4
2 changed files with 38 additions and 1 deletions
|
@ -5,4 +5,4 @@ noinst_PROGRAMS = test-video test-ogg test-mp4 test-readme \
|
|||
#INCLUDES = -I$(top_srcdir) -I$(srcdir)
|
||||
|
||||
AM_CFLAGS = $(GST_OBJ_CFLAGS)
|
||||
AM_LDFLAGS = $(GST_OBJ_LIBS)
|
||||
AM_LDFLAGS = $(GST_OBJ_LIBS) $(GIO_LIBS)
|
||||
|
|
|
@ -25,6 +25,9 @@
|
|||
* user/admin as the password */
|
||||
#undef WITH_AUTH
|
||||
|
||||
/* define this if you want the server to use TLS */
|
||||
#undef WITH_TLS
|
||||
|
||||
/* this timeout is periodically run to clean up the expired sessions from the
|
||||
* pool. This needs to be run explicitly currently but might be done
|
||||
* automatically as part of the mainloop. */
|
||||
|
@ -51,6 +54,9 @@ main (int argc, char *argv[])
|
|||
GstRTSPAuth *auth;
|
||||
gchar *basic;
|
||||
#endif
|
||||
#ifdef WITH_TLS
|
||||
GTlsCertificate *cert;
|
||||
#endif
|
||||
|
||||
gst_init (&argc, &argv);
|
||||
|
||||
|
@ -58,6 +64,33 @@ main (int argc, char *argv[])
|
|||
|
||||
/* create a server instance */
|
||||
server = gst_rtsp_server_new ();
|
||||
#ifdef WITH_TLS
|
||||
cert = g_tls_certificate_new_from_pem ("-----BEGIN CERTIFICATE-----"
|
||||
"MIICJjCCAY+gAwIBAgIBBzANBgkqhkiG9w0BAQUFADCBhjETMBEGCgmSJomT8ixk"
|
||||
"ARkWA0NPTTEXMBUGCgmSJomT8ixkARkWB0VYQU1QTEUxHjAcBgNVBAsTFUNlcnRp"
|
||||
"ZmljYXRlIEF1dGhvcml0eTEXMBUGA1UEAxMOY2EuZXhhbXBsZS5jb20xHTAbBgkq"
|
||||
"hkiG9w0BCQEWDmNhQGV4YW1wbGUuY29tMB4XD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BXebfZVd+1Hd95IfEM5mbRwIgSkDuQwV55BBlvWph3U8wVIMIb4GStaH8"
|
||||
"W535W8UBbEg=" "-----END PRIVATE KEY-----", -1, NULL);
|
||||
gst_rtsp_server_set_tls_certificate (server, cert);
|
||||
g_object_unref (cert);
|
||||
#endif
|
||||
|
||||
/* get the mount points for this server, every server has a default object
|
||||
* that be used to map uri mount points to media factories */
|
||||
|
@ -99,7 +132,11 @@ main (int argc, char *argv[])
|
|||
g_timeout_add_seconds (2, (GSourceFunc) timeout, server);
|
||||
|
||||
/* start serving, this never stops */
|
||||
#ifdef WITH_TLS
|
||||
g_print ("stream ready at rtsps://127.0.0.1:8554/test\n");
|
||||
#else
|
||||
g_print ("stream ready at rtsp://127.0.0.1:8554/test\n");
|
||||
#endif
|
||||
g_main_loop_run (loop);
|
||||
|
||||
return 0;
|
||||
|
|
Loading…
Reference in a new issue