2 * Copyright (c) 2014, Ericsson AB. All rights reserved.
4 * Redistribution and use in source and binary forms, with or without modification,
5 * are permitted provided that the following conditions are met:
7 * 1. Redistributions of source code must retain the above copyright notice, this
8 * list of conditions and the following disclaimer.
10 * 2. Redistributions in binary form must reproduce the above copyright notice, this
11 * list of conditions and the following disclaimer in the documentation and/or other
12 * materials provided with the distribution.
14 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
15 * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
16 * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
17 * IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT,
18 * INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
19 * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
20 * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
21 * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
22 * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY
26 #ifndef gstdtlsconnection_h
27 #define gstdtlsconnection_h
29 #include <glib-object.h>
33 #define GST_TYPE_DTLS_CONNECTION (gst_dtls_connection_get_type())
34 #define GST_DTLS_CONNECTION(obj) (G_TYPE_CHECK_INSTANCE_CAST((obj), GST_TYPE_DTLS_CONNECTION, GstDtlsConnection))
35 #define GST_DTLS_CONNECTION_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST((klass), GST_TYPE_DTLS_CONNECTION, GstDtlsConnectionClass))
36 #define GST_IS_DTLS_CONNECTION(obj) (G_TYPE_CHECK_INSTANCE_TYPE((obj), GST_TYPE_DTLS_CONNECTION))
37 #define GST_IS_DTLS_CONNECTION_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE((klass), GST_TYPE_DTLS_CONNECTION))
38 #define GST_DTLS_CONNECTION_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS((obj), GST_TYPE_DTLS_CONNECTION, GstDtlsConnectionClass))
40 typedef struct _GstDtlsConnection GstDtlsConnection;
41 typedef struct _GstDtlsConnectionClass GstDtlsConnectionClass;
42 typedef struct _GstDtlsConnectionPrivate GstDtlsConnectionPrivate;
46 * @GST_DTLS_SRTP_CIPHER_AES_128_ICM: aes-128-icm
48 * SRTP Cipher selected by the DTLS handshake, should match the enums in gstsrtp
51 GST_DTLS_SRTP_CIPHER_AES_128_ICM = 1
56 * @GST_DTLS_SRTP_AUTH_HMAC_SHA1_32: hmac-sha1-32
57 * @GST_DTLS_SRTP_AUTH_HMAC_SHA1_80: hmac-sha1-80
59 * SRTP Auth selected by the DTLS handshake, should match the enums in gstsrtp
62 GST_DTLS_SRTP_AUTH_HMAC_SHA1_32 = 1,
63 GST_DTLS_SRTP_AUTH_HMAC_SHA1_80 = 2
66 #define GST_DTLS_SRTP_MASTER_KEY_LENGTH 30
71 * A class that handles a single DTLS connection.
72 * Any connection needs to be created with the agent property set.
73 * Once the DTLS handshake is completed, on-encoder-key and on-decoder-key will be signalled.
75 struct _GstDtlsConnection {
76 GObject parent_instance;
78 GstDtlsConnectionPrivate *priv;
81 struct _GstDtlsConnectionClass {
82 GObjectClass parent_class;
85 GType gst_dtls_connection_get_type(void) G_GNUC_CONST;
87 void gst_dtls_connection_start(GstDtlsConnection *, gboolean is_client);
88 void gst_dtls_connection_check_timeout(GstDtlsConnection *);
91 * Stops the connections, it is not required to call this function.
93 void gst_dtls_connection_stop(GstDtlsConnection *);
96 * Closes the connection, the function will block until the connection has been stopped.
97 * If stop is called some time before, close will return instantly.
99 void gst_dtls_connection_close(GstDtlsConnection *);
102 * Sets the closure that will be called whenever data needs to be sent.
104 * The closure will get called with the following arguments:
105 * void cb(GstDtlsConnection *, gpointer data, gint length, gpointer user_data)
107 void gst_dtls_connection_set_send_callback(GstDtlsConnection *, GClosure *);
110 * Processes data that has been received, the transformation is done in-place.
111 * Returns the length of the plaintext data that was decoded, if no data is available, 0<= will be returned.
113 gint gst_dtls_connection_process(GstDtlsConnection *, gpointer ptr, gint len);
116 * If the DTLS handshake is completed this function will encode the given data.
117 * Returns the length of the data sent, or 0 if the DTLS handshake is not completed.
119 gint gst_dtls_connection_send(GstDtlsConnection *, gpointer ptr, gint len);
123 #endif /* gstdtlsconnection_h */