mirror of
https://gitlab.freedesktop.org/gstreamer/gstreamer.git
synced 2025-02-17 03:35:21 +00:00
rtsp: add method to get the TLS connection
This commit is contained in:
parent
c0f13c2513
commit
0b933ff87b
3 changed files with 51 additions and 0 deletions
|
@ -108,6 +108,7 @@ struct _GstRTSPConnection
|
|||
/* URL for the remote connection */
|
||||
GstRTSPUrl *url;
|
||||
|
||||
gboolean server;
|
||||
GSocketClient *client;
|
||||
GIOStream *stream0;
|
||||
GIOStream *stream1;
|
||||
|
@ -308,6 +309,7 @@ gst_rtsp_connection_create_from_socket (GSocket * socket, const gchar * ip,
|
|||
stream = G_IO_STREAM (g_socket_connection_factory_create_connection (socket));
|
||||
|
||||
/* both read and write initially */
|
||||
newconn->server = TRUE;
|
||||
newconn->socket0 = socket;
|
||||
newconn->stream0 = stream;
|
||||
newconn->write_socket = newconn->read_socket = newconn->socket0;
|
||||
|
@ -397,6 +399,51 @@ getnameinfo_failed:
|
|||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* gst_rtsp_connection_get_tls:
|
||||
* @conn: a #GstRTSPConnection
|
||||
* @error: #GError for error reporting, or NULL to ignore.
|
||||
*
|
||||
* Get the TLS connection of @conn.
|
||||
*
|
||||
* For client side this will return the #GTlsClientConnection when connected
|
||||
* over TLS.
|
||||
*
|
||||
* For server side connections, this function will create a GTlsServerConnection
|
||||
* when called the first time and will return that same connection on subsequent
|
||||
* calls. The server is then responsible for configuring the TLS connection.
|
||||
*
|
||||
* Returns: (transfer none): the TLS connection for @conn.
|
||||
*
|
||||
* Since: 1.2
|
||||
*/
|
||||
GTlsConnection *
|
||||
gst_rtsp_connection_get_tls (GstRTSPConnection * conn, GError ** error)
|
||||
{
|
||||
GTlsConnection *result;
|
||||
|
||||
if (G_IS_TLS_CONNECTION (conn->stream0)) {
|
||||
/* we already had one, return it */
|
||||
result = G_TLS_CONNECTION (conn->stream0);
|
||||
} else if (conn->server) {
|
||||
/* no TLS connection but we are server, make one */
|
||||
result = (GTlsConnection *)
|
||||
g_tls_server_connection_new (conn->stream0, NULL, error);
|
||||
if (result) {
|
||||
g_object_unref (conn->stream0);
|
||||
conn->stream0 = G_IO_STREAM (result);
|
||||
conn->input_stream = g_io_stream_get_input_stream (conn->stream0);
|
||||
conn->output_stream = g_io_stream_get_output_stream (conn->stream0);
|
||||
}
|
||||
} else {
|
||||
/* client */
|
||||
result = NULL;
|
||||
g_set_error (error, GST_LIBRARY_ERROR, GST_LIBRARY_ERROR_FAILED,
|
||||
"client not connected with TLS");
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
static GstRTSPResult
|
||||
setup_tunneling (GstRTSPConnection * conn, GTimeVal * timeout, gchar * uri)
|
||||
{
|
||||
|
|
|
@ -72,6 +72,9 @@ GstRTSPResult gst_rtsp_connection_connect (GstRTSPConnection *conn,
|
|||
GstRTSPResult gst_rtsp_connection_close (GstRTSPConnection *conn);
|
||||
GstRTSPResult gst_rtsp_connection_free (GstRTSPConnection *conn);
|
||||
|
||||
/* TLS connections */
|
||||
GTlsConnection * gst_rtsp_connection_get_tls (GstRTSPConnection * conn, GError ** error);
|
||||
|
||||
|
||||
/* sending/receiving raw bytes */
|
||||
GstRTSPResult gst_rtsp_connection_read (GstRTSPConnection * conn, guint8 * data,
|
||||
|
|
|
@ -12,6 +12,7 @@ EXPORTS
|
|||
gst_rtsp_connection_get_ip
|
||||
gst_rtsp_connection_get_read_socket
|
||||
gst_rtsp_connection_get_remember_session_id
|
||||
gst_rtsp_connection_get_tls
|
||||
gst_rtsp_connection_get_tunnelid
|
||||
gst_rtsp_connection_get_url
|
||||
gst_rtsp_connection_get_write_socket
|
||||
|
|
Loading…
Reference in a new issue