mirror of
https://gitlab.freedesktop.org/gstreamer/gstreamer.git
synced 2024-12-23 00:36:51 +00:00
dtls: Unconditionally use GStreamer debug log system
This commit is contained in:
parent
936fa2f1c4
commit
d9344ad820
7 changed files with 106 additions and 172 deletions
|
@ -31,6 +31,5 @@ noinst_HEADERS = \
|
|||
gstdtlssrtpenc.h \
|
||||
gstdtlsagent.h \
|
||||
gstdtlsconnection.h \
|
||||
gstdtlscertificate.h \
|
||||
gstdtlscommon.h
|
||||
gstdtlscertificate.h
|
||||
|
||||
|
|
|
@ -27,9 +27,9 @@
|
|||
#include "config.h"
|
||||
#endif
|
||||
|
||||
#include "gstdtlsagent.h"
|
||||
#include <gst/gst.h>
|
||||
|
||||
#include "gstdtlscommon.h"
|
||||
#include "gstdtlsagent.h"
|
||||
|
||||
#ifdef __APPLE__
|
||||
# define __AVAILABILITYMACROS__
|
||||
|
@ -85,7 +85,7 @@ ssl_locking_function (gint mode, gint lock_num, const gchar * file, gint line)
|
|||
reading = mode & CRYPTO_READ;
|
||||
lock = &ssl_locks[lock_num];
|
||||
|
||||
LOG_LOG (NULL, "%s SSL lock for %s, thread=%p location=%s:%d",
|
||||
GST_LOG_OBJECT (NULL, "%s SSL lock for %s, thread=%p location=%s:%d",
|
||||
locking ? "locking" : "unlocking", reading ? "reading" : "writing",
|
||||
g_thread_self (), file, line);
|
||||
|
||||
|
@ -119,12 +119,13 @@ _gst_dtls_init_openssl ()
|
|||
|
||||
if (g_once_init_enter (&is_init)) {
|
||||
if (OPENSSL_VERSION_NUMBER < 0x1000100fL) {
|
||||
LOG_WARNING (NULL, "Incorrect OpenSSL version, should be >= 1.0.1, is %s",
|
||||
GST_WARNING_OBJECT (NULL,
|
||||
"Incorrect OpenSSL version, should be >= 1.0.1, is %s",
|
||||
OPENSSL_VERSION_TEXT);
|
||||
g_assert_not_reached ();
|
||||
}
|
||||
|
||||
LOG_INFO (NULL, "initializing openssl %lx", OPENSSL_VERSION_NUMBER);
|
||||
GST_INFO_OBJECT (NULL, "initializing openssl %lx", OPENSSL_VERSION_NUMBER);
|
||||
SSL_library_init ();
|
||||
SSL_load_error_strings ();
|
||||
ERR_load_BIO_strings ();
|
||||
|
@ -177,7 +178,7 @@ gst_dtls_agent_init (GstDtlsAgent * self)
|
|||
|
||||
priv->ssl_context = NULL;
|
||||
|
||||
LOG_WARNING (self, "Error creating SSL Context: %s",
|
||||
GST_WARNING_OBJECT (self, "Error creating SSL Context: %s",
|
||||
ERR_error_string (ERR_get_error (), buf));
|
||||
|
||||
g_return_if_reached ();
|
||||
|
@ -201,7 +202,7 @@ gst_dtls_agent_finalize (GObject * gobject)
|
|||
SSL_CTX_free (priv->ssl_context);
|
||||
priv->ssl_context = NULL;
|
||||
|
||||
LOG_DEBUG (gobject, "finalized");
|
||||
GST_DEBUG_OBJECT (gobject, "finalized");
|
||||
|
||||
G_OBJECT_CLASS (gst_dtls_agent_parent_class)->finalize (gobject);
|
||||
}
|
||||
|
@ -224,18 +225,18 @@ gst_dtls_agent_set_property (GObject * object, guint prop_id,
|
|||
|
||||
if (!SSL_CTX_use_certificate (self->priv->ssl_context,
|
||||
_gst_dtls_certificate_get_internal_certificate (certificate))) {
|
||||
LOG_WARNING (self, "could not use certificate");
|
||||
GST_WARNING_OBJECT (self, "could not use certificate");
|
||||
g_return_if_reached ();
|
||||
}
|
||||
|
||||
if (!SSL_CTX_use_PrivateKey (self->priv->ssl_context,
|
||||
_gst_dtls_certificate_get_internal_key (certificate))) {
|
||||
LOG_WARNING (self, "could not use private key");
|
||||
GST_WARNING_OBJECT (self, "could not use private key");
|
||||
g_return_if_reached ();
|
||||
}
|
||||
|
||||
if (!SSL_CTX_check_private_key (self->priv->ssl_context)) {
|
||||
LOG_WARNING (self, "invalid private key");
|
||||
GST_WARNING_OBJECT (self, "invalid private key");
|
||||
g_return_if_reached ();
|
||||
}
|
||||
break;
|
||||
|
|
|
@ -27,10 +27,11 @@
|
|||
#include "config.h"
|
||||
#endif
|
||||
|
||||
#include <gst/gst.h>
|
||||
|
||||
#include "gstdtlscertificate.h"
|
||||
|
||||
#include "gstdtlsagent.h"
|
||||
#include "gstdtlscommon.h"
|
||||
|
||||
#ifdef __APPLE__
|
||||
# define __AVAILABILITYMACROS__
|
||||
|
@ -182,14 +183,14 @@ init_generated (GstDtlsCertificate * self)
|
|||
priv->private_key = EVP_PKEY_new ();
|
||||
|
||||
if (!priv->private_key) {
|
||||
LOG_WARNING (self, "failed to create private key");
|
||||
GST_WARNING_OBJECT (self, "failed to create private key");
|
||||
return;
|
||||
}
|
||||
|
||||
priv->x509 = X509_new ();
|
||||
|
||||
if (!priv->x509) {
|
||||
LOG_WARNING (self, "failed to create certificate");
|
||||
GST_WARNING_OBJECT (self, "failed to create certificate");
|
||||
EVP_PKEY_free (priv->private_key);
|
||||
priv->private_key = NULL;
|
||||
return;
|
||||
|
@ -197,7 +198,7 @@ init_generated (GstDtlsCertificate * self)
|
|||
rsa = RSA_generate_key (2048, RSA_F4, NULL, NULL);
|
||||
|
||||
if (!rsa) {
|
||||
LOG_WARNING (self, "failed to generate RSA");
|
||||
GST_WARNING_OBJECT (self, "failed to generate RSA");
|
||||
EVP_PKEY_free (priv->private_key);
|
||||
priv->private_key = NULL;
|
||||
X509_free (priv->x509);
|
||||
|
@ -206,7 +207,7 @@ init_generated (GstDtlsCertificate * self)
|
|||
}
|
||||
|
||||
if (!EVP_PKEY_assign_RSA (priv->private_key, rsa)) {
|
||||
LOG_WARNING (self, "failed to assign RSA");
|
||||
GST_WARNING_OBJECT (self, "failed to assign RSA");
|
||||
RSA_free (rsa);
|
||||
rsa = NULL;
|
||||
EVP_PKEY_free (priv->private_key);
|
||||
|
@ -232,7 +233,7 @@ init_generated (GstDtlsCertificate * self)
|
|||
name = NULL;
|
||||
|
||||
if (!X509_sign (priv->x509, priv->private_key, EVP_sha256 ())) {
|
||||
LOG_WARNING (self, "failed to sign certificate");
|
||||
GST_WARNING_OBJECT (self, "failed to sign certificate");
|
||||
EVP_PKEY_free (priv->private_key);
|
||||
priv->private_key = NULL;
|
||||
X509_free (priv->x509);
|
||||
|
@ -259,7 +260,7 @@ init_from_pem_string (GstDtlsCertificate * self, const gchar * pem)
|
|||
priv->x509 = PEM_read_bio_X509 (bio, NULL, NULL, NULL);
|
||||
|
||||
if (!priv->x509) {
|
||||
LOG_WARNING (self, "failed to read certificate from pem string");
|
||||
GST_WARNING_OBJECT (self, "failed to read certificate from pem string");
|
||||
return;
|
||||
}
|
||||
|
||||
|
@ -271,7 +272,7 @@ init_from_pem_string (GstDtlsCertificate * self, const gchar * pem)
|
|||
bio = NULL;
|
||||
|
||||
if (!priv->private_key) {
|
||||
LOG_WARNING (self, "failed to read private key from pem string");
|
||||
GST_WARNING_OBJECT (self, "failed to read private key from pem string");
|
||||
X509_free (priv->x509);
|
||||
priv->x509 = NULL;
|
||||
return;
|
||||
|
|
|
@ -1,61 +0,0 @@
|
|||
/*
|
||||
* Copyright (c) 2014, Ericsson AB. All rights reserved.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without modification,
|
||||
* are permitted provided that the following conditions are met:
|
||||
*
|
||||
* 1. Redistributions of source code must retain the above copyright notice, this
|
||||
* list of conditions and the following disclaimer.
|
||||
*
|
||||
* 2. Redistributions in binary form must reproduce the above copyright notice, this
|
||||
* list of conditions and the following disclaimer in the documentation and/or other
|
||||
* materials provided with the distribution.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
|
||||
* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
|
||||
* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
|
||||
* IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT,
|
||||
* INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
|
||||
* NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
|
||||
* PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
|
||||
* WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
|
||||
* ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY
|
||||
* OF SUCH DAMAGE.
|
||||
*/
|
||||
|
||||
#ifndef gstdtlscommon_h
|
||||
#define gstdtlscommon_h
|
||||
|
||||
#ifndef GST_DTLS_USE_GST_LOG
|
||||
# define GST_DTLS_USE_GST_LOG 0
|
||||
#endif
|
||||
|
||||
#if GST_DTLS_USE_GST_LOG
|
||||
# include <gst/gst.h>
|
||||
#endif
|
||||
|
||||
G_BEGIN_DECLS
|
||||
|
||||
#define UNUSED(param) while (0) { (void)(param); }
|
||||
|
||||
#if GST_DTLS_USE_GST_LOG
|
||||
# define LOG_ERROR(obj, ...) GST_ERROR_OBJECT(obj, __VA_ARGS__ )
|
||||
# define LOG_WARNING(obj, ...) GST_WARNING_OBJECT(obj, __VA_ARGS__ )
|
||||
# define LOG_FIXME(obj, ...) GST_FIXME_OBJECT(obj, __VA_ARGS__ )
|
||||
# define LOG_INFO(obj, ...) GST_INFO_OBJECT(obj, __VA_ARGS__ )
|
||||
# define LOG_DEBUG(obj, ...) GST_DEBUG_OBJECT(obj, __VA_ARGS__ )
|
||||
# define LOG_LOG(obj, ...) GST_LOG_OBJECT(obj, __VA_ARGS__ )
|
||||
# define LOG_TRACE(obj, ...) GST_TRACE_OBJECT(obj, __VA_ARGS__ )
|
||||
#else
|
||||
# define LOG_ERROR(obj, fmt, ...) g_log(G_LOG_DOMAIN, G_LOG_LEVEL_CRITICAL, "%p: "fmt, obj, ##__VA_ARGS__)
|
||||
# define LOG_WARNING(obj, fmt, ...) g_log(G_LOG_DOMAIN, G_LOG_LEVEL_WARNING, "%p: "fmt, obj, ##__VA_ARGS__)
|
||||
# define LOG_FIXME(obj, fmt, ...) g_log(G_LOG_DOMAIN, G_LOG_LEVEL_MESSAGE, "%p: "fmt, obj, ##__VA_ARGS__)
|
||||
# define LOG_INFO(obj, fmt, ...) g_log(G_LOG_DOMAIN, G_LOG_LEVEL_MESSAGE, "%p: "fmt, obj, ##__VA_ARGS__)
|
||||
# define LOG_DEBUG(obj, fmt, ...) g_log(G_LOG_DOMAIN, G_LOG_LEVEL_INFO, "%p: "fmt, obj, ##__VA_ARGS__)
|
||||
# define LOG_LOG(obj, fmt, ...) g_log(G_LOG_DOMAIN, G_LOG_LEVEL_DEBUG, "%p: "fmt, obj, ##__VA_ARGS__)
|
||||
# define LOG_TRACE(obj, fmt, ...) g_log(G_LOG_DOMAIN, G_LOG_LEVEL_DEBUG, "%p: "fmt, obj, ##__VA_ARGS__)
|
||||
#endif
|
||||
|
||||
G_END_DECLS
|
||||
|
||||
#endif /* gstdtlscommon_h */
|
|
@ -27,11 +27,12 @@
|
|||
#include "config.h"
|
||||
#endif
|
||||
|
||||
#include <gst/gst.h>
|
||||
|
||||
#include "gstdtlsconnection.h"
|
||||
|
||||
#include "gstdtlsagent.h"
|
||||
#include "gstdtlscertificate.h"
|
||||
#include "gstdtlscommon.h"
|
||||
|
||||
#ifdef __APPLE__
|
||||
# define __AVAILABILITYMACROS__
|
||||
|
@ -202,7 +203,7 @@ gst_dtls_connection_finalize (GObject * gobject)
|
|||
g_mutex_clear (&priv->mutex);
|
||||
g_cond_clear (&priv->condition);
|
||||
|
||||
LOG_DEBUG (self, "finalized");
|
||||
GST_DEBUG_OBJECT (self, "finalized");
|
||||
|
||||
G_OBJECT_CLASS (gst_dtls_connection_parent_class)->finalize (gobject);
|
||||
}
|
||||
|
@ -254,9 +255,9 @@ gst_dtls_connection_start (GstDtlsConnection * self, gboolean is_client)
|
|||
g_return_if_fail (priv->ssl);
|
||||
g_return_if_fail (priv->bio);
|
||||
|
||||
LOG_TRACE (self, "locking @ start");
|
||||
GST_TRACE_OBJECT (self, "locking @ start");
|
||||
g_mutex_lock (&priv->mutex);
|
||||
LOG_TRACE (self, "locked @ start");
|
||||
GST_TRACE_OBJECT (self, "locked @ start");
|
||||
|
||||
priv->is_alive = TRUE;
|
||||
priv->timeout_set = FALSE;
|
||||
|
@ -278,7 +279,7 @@ gst_dtls_connection_start (GstDtlsConnection * self, gboolean is_client)
|
|||
log_state (self, "first poll done");
|
||||
priv->thread = NULL;
|
||||
|
||||
LOG_TRACE (self, "unlocking @ start");
|
||||
GST_TRACE_OBJECT (self, "unlocking @ start");
|
||||
g_mutex_unlock (&priv->mutex);
|
||||
}
|
||||
|
||||
|
@ -291,22 +292,22 @@ gst_dtls_connection_start_timeout (GstDtlsConnection * self)
|
|||
GError *error = NULL;
|
||||
gchar *thread_name = g_strdup_printf ("connection_thread_%p", self);
|
||||
|
||||
LOG_TRACE (self, "locking @ start_timeout");
|
||||
GST_TRACE_OBJECT (self, "locking @ start_timeout");
|
||||
g_mutex_lock (&priv->mutex);
|
||||
LOG_TRACE (self, "locked @ start_timeout");
|
||||
GST_TRACE_OBJECT (self, "locked @ start_timeout");
|
||||
|
||||
LOG_INFO (self, "starting connection timeout");
|
||||
GST_INFO_OBJECT (self, "starting connection timeout");
|
||||
priv->thread = g_thread_try_new (thread_name,
|
||||
(GThreadFunc) connection_timeout_thread_func, self, &error);
|
||||
if (error) {
|
||||
LOG_WARNING (self, "error creating connection thread: %s (%d)",
|
||||
GST_WARNING_OBJECT (self, "error creating connection thread: %s (%d)",
|
||||
error->message, error->code);
|
||||
g_clear_error (&error);
|
||||
}
|
||||
|
||||
g_free (thread_name);
|
||||
|
||||
LOG_TRACE (self, "unlocking @ start_timeout");
|
||||
GST_TRACE_OBJECT (self, "unlocking @ start_timeout");
|
||||
g_mutex_unlock (&priv->mutex);
|
||||
}
|
||||
|
||||
|
@ -317,21 +318,21 @@ gst_dtls_connection_stop (GstDtlsConnection * self)
|
|||
g_return_if_fail (self->priv->ssl);
|
||||
g_return_if_fail (self->priv->bio);
|
||||
|
||||
LOG_DEBUG (self, "stopping connection");
|
||||
GST_DEBUG_OBJECT (self, "stopping connection");
|
||||
|
||||
LOG_TRACE (self, "locking @ stop");
|
||||
GST_TRACE_OBJECT (self, "locking @ stop");
|
||||
g_mutex_lock (&self->priv->mutex);
|
||||
LOG_TRACE (self, "locked @ stop");
|
||||
GST_TRACE_OBJECT (self, "locked @ stop");
|
||||
|
||||
self->priv->is_alive = FALSE;
|
||||
LOG_TRACE (self, "signaling @ stop");
|
||||
GST_TRACE_OBJECT (self, "signaling @ stop");
|
||||
g_cond_signal (&self->priv->condition);
|
||||
LOG_TRACE (self, "signaled @ stop");
|
||||
GST_TRACE_OBJECT (self, "signaled @ stop");
|
||||
|
||||
LOG_TRACE (self, "unlocking @ stop");
|
||||
GST_TRACE_OBJECT (self, "unlocking @ stop");
|
||||
g_mutex_unlock (&self->priv->mutex);
|
||||
|
||||
LOG_DEBUG (self, "stopped connection");
|
||||
GST_DEBUG_OBJECT (self, "stopped connection");
|
||||
}
|
||||
|
||||
void
|
||||
|
@ -341,18 +342,18 @@ gst_dtls_connection_close (GstDtlsConnection * self)
|
|||
g_return_if_fail (self->priv->ssl);
|
||||
g_return_if_fail (self->priv->bio);
|
||||
|
||||
LOG_DEBUG (self, "closing connection");
|
||||
GST_DEBUG_OBJECT (self, "closing connection");
|
||||
|
||||
LOG_TRACE (self, "locking @ close");
|
||||
GST_TRACE_OBJECT (self, "locking @ close");
|
||||
g_mutex_lock (&self->priv->mutex);
|
||||
LOG_TRACE (self, "locked @ close");
|
||||
GST_TRACE_OBJECT (self, "locked @ close");
|
||||
|
||||
if (self->priv->is_alive) {
|
||||
self->priv->is_alive = FALSE;
|
||||
g_cond_signal (&self->priv->condition);
|
||||
}
|
||||
|
||||
LOG_TRACE (self, "unlocking @ close");
|
||||
GST_TRACE_OBJECT (self, "unlocking @ close");
|
||||
g_mutex_unlock (&self->priv->mutex);
|
||||
|
||||
if (self->priv->thread) {
|
||||
|
@ -360,7 +361,7 @@ gst_dtls_connection_close (GstDtlsConnection * self)
|
|||
self->priv->thread = NULL;
|
||||
}
|
||||
|
||||
LOG_DEBUG (self, "closed connection");
|
||||
GST_DEBUG_OBJECT (self, "closed connection");
|
||||
}
|
||||
|
||||
void
|
||||
|
@ -369,9 +370,9 @@ gst_dtls_connection_set_send_callback (GstDtlsConnection * self,
|
|||
{
|
||||
g_return_if_fail (GST_IS_DTLS_CONNECTION (self));
|
||||
|
||||
LOG_TRACE (self, "locking @ set_send_callback");
|
||||
GST_TRACE_OBJECT (self, "locking @ set_send_callback");
|
||||
g_mutex_lock (&self->priv->mutex);
|
||||
LOG_TRACE (self, "locked @ set_send_callback");
|
||||
GST_TRACE_OBJECT (self, "locked @ set_send_callback");
|
||||
|
||||
self->priv->send_closure = closure;
|
||||
|
||||
|
@ -379,7 +380,7 @@ gst_dtls_connection_set_send_callback (GstDtlsConnection * self,
|
|||
g_closure_set_marshal (closure, g_cclosure_marshal_generic);
|
||||
}
|
||||
|
||||
LOG_TRACE (self, "unlocking @ set_send_callback");
|
||||
GST_TRACE_OBJECT (self, "unlocking @ set_send_callback");
|
||||
g_mutex_unlock (&self->priv->mutex);
|
||||
}
|
||||
|
||||
|
@ -393,9 +394,9 @@ gst_dtls_connection_process (GstDtlsConnection * self, gpointer data, gint len)
|
|||
g_return_val_if_fail (self->priv->ssl, 0);
|
||||
g_return_val_if_fail (self->priv->bio, 0);
|
||||
|
||||
LOG_TRACE (self, "locking @ process");
|
||||
GST_TRACE_OBJECT (self, "locking @ process");
|
||||
g_mutex_lock (&priv->mutex);
|
||||
LOG_TRACE (self, "locked @ process");
|
||||
GST_TRACE_OBJECT (self, "locked @ process");
|
||||
|
||||
g_warn_if_fail (!priv->bio_buffer);
|
||||
|
||||
|
@ -418,9 +419,9 @@ gst_dtls_connection_process (GstDtlsConnection * self, gpointer data, gint len)
|
|||
|
||||
log_state (self, "process after poll");
|
||||
|
||||
LOG_DEBUG (self, "read result: %d", result);
|
||||
GST_DEBUG_OBJECT (self, "read result: %d", result);
|
||||
|
||||
LOG_TRACE (self, "unlocking @ process");
|
||||
GST_TRACE_OBJECT (self, "unlocking @ process");
|
||||
g_mutex_unlock (&priv->mutex);
|
||||
|
||||
return result;
|
||||
|
@ -435,19 +436,21 @@ gst_dtls_connection_send (GstDtlsConnection * self, gpointer data, gint len)
|
|||
g_return_val_if_fail (self->priv->ssl, 0);
|
||||
g_return_val_if_fail (self->priv->bio, 0);
|
||||
|
||||
LOG_TRACE (self, "locking @ send");
|
||||
GST_TRACE_OBJECT (self, "locking @ send");
|
||||
g_mutex_lock (&self->priv->mutex);
|
||||
LOG_TRACE (self, "locked @ send");
|
||||
GST_TRACE_OBJECT (self, "locked @ send");
|
||||
|
||||
if (SSL_is_init_finished (self->priv->ssl)) {
|
||||
ret = SSL_write (self->priv->ssl, data, len);
|
||||
LOG_DEBUG (self, "data sent: input was %d B, output is %d B", len, ret);
|
||||
GST_DEBUG_OBJECT (self, "data sent: input was %d B, output is %d B", len,
|
||||
ret);
|
||||
} else {
|
||||
LOG_WARNING (self, "tried to send data before handshake was complete");
|
||||
GST_WARNING_OBJECT (self,
|
||||
"tried to send data before handshake was complete");
|
||||
ret = 0;
|
||||
}
|
||||
|
||||
LOG_TRACE (self, "unlocking @ send");
|
||||
GST_TRACE_OBJECT (self, "unlocking @ send");
|
||||
g_mutex_unlock (&self->priv->mutex);
|
||||
|
||||
return ret;
|
||||
|
@ -477,7 +480,7 @@ log_state (GstDtlsConnection * self, const gchar * str)
|
|||
states |= (! !SSL_want_write (priv->ssl) << 20);
|
||||
states |= (! !SSL_want_read (priv->ssl) << 24);
|
||||
|
||||
LOG_LOG (self, "%s: role=%s buf=(%d,%p:%d/%d) %x|%x %s",
|
||||
GST_LOG_OBJECT (self, "%s: role=%s buf=(%d,%p:%d/%d) %x|%x %s",
|
||||
str,
|
||||
priv->is_client ? "client" : "server",
|
||||
pqueue_size (priv->ssl->d1->sent_messages),
|
||||
|
@ -496,30 +499,31 @@ connection_timeout_thread_func (GstDtlsConnection * self)
|
|||
gint ret;
|
||||
|
||||
while (priv->is_alive) {
|
||||
LOG_TRACE (self, "locking @ timeout");
|
||||
GST_TRACE_OBJECT (self, "locking @ timeout");
|
||||
g_mutex_lock (&priv->mutex);
|
||||
LOG_TRACE (self, "locked @ timeout");
|
||||
GST_TRACE_OBJECT (self, "locked @ timeout");
|
||||
|
||||
if (DTLSv1_get_timeout (priv->ssl, &timeout)) {
|
||||
wait_time = timeout.tv_sec * G_USEC_PER_SEC + timeout.tv_usec;
|
||||
|
||||
if (wait_time) {
|
||||
LOG_DEBUG (self, "waiting for %" G_GINT64_FORMAT " usec", wait_time);
|
||||
GST_DEBUG_OBJECT (self, "waiting for %" G_GINT64_FORMAT " usec",
|
||||
wait_time);
|
||||
|
||||
end_time = g_get_monotonic_time () + wait_time;
|
||||
|
||||
LOG_TRACE (self, "wait @ timeout");
|
||||
GST_TRACE_OBJECT (self, "wait @ timeout");
|
||||
g_cond_wait_until (&priv->condition, &priv->mutex, end_time);
|
||||
LOG_TRACE (self, "continued @ timeout");
|
||||
GST_TRACE_OBJECT (self, "continued @ timeout");
|
||||
}
|
||||
|
||||
ret = DTLSv1_handle_timeout (priv->ssl);
|
||||
|
||||
LOG_DEBUG (self, "handle timeout returned %d, is_alive: %d", ret,
|
||||
GST_DEBUG_OBJECT (self, "handle timeout returned %d, is_alive: %d", ret,
|
||||
priv->is_alive);
|
||||
|
||||
if (ret < 0) {
|
||||
LOG_TRACE (self, "unlocking @ timeout failed");
|
||||
GST_TRACE_OBJECT (self, "unlocking @ timeout failed");
|
||||
g_mutex_unlock (&priv->mutex);
|
||||
break; /* self failed after DTLS1_TMO_ALERT_COUNT (12) attempts */
|
||||
}
|
||||
|
@ -530,18 +534,18 @@ connection_timeout_thread_func (GstDtlsConnection * self)
|
|||
log_state (self, "handling timeout after poll");
|
||||
}
|
||||
} else {
|
||||
LOG_DEBUG (self, "waiting indefinitely");
|
||||
GST_DEBUG_OBJECT (self, "waiting indefinitely");
|
||||
|
||||
priv->timeout_set = FALSE;
|
||||
|
||||
while (!priv->timeout_set && priv->is_alive) {
|
||||
LOG_TRACE (self, "wait @ timeout");
|
||||
GST_TRACE_OBJECT (self, "wait @ timeout");
|
||||
g_cond_wait (&priv->condition, &priv->mutex);
|
||||
}
|
||||
LOG_TRACE (self, "continued @ timeout");
|
||||
GST_TRACE_OBJECT (self, "continued @ timeout");
|
||||
}
|
||||
|
||||
LOG_TRACE (self, "unlocking @ timeout");
|
||||
GST_TRACE_OBJECT (self, "unlocking @ timeout");
|
||||
g_mutex_unlock (&priv->mutex);
|
||||
}
|
||||
|
||||
|
@ -589,13 +593,13 @@ export_srtp_keys (GstDtlsConnection * self)
|
|||
NULL, 0, 0);
|
||||
|
||||
if (!success) {
|
||||
LOG_WARNING (self, "failed to export srtp keys");
|
||||
GST_WARNING_OBJECT (self, "failed to export srtp keys");
|
||||
return;
|
||||
}
|
||||
|
||||
profile = SSL_get_selected_srtp_profile (self->priv->ssl);
|
||||
|
||||
LOG_INFO (self, "keys received, profile is %s", profile->name);
|
||||
GST_INFO_OBJECT (self, "keys received, profile is %s", profile->name);
|
||||
|
||||
switch (profile->id) {
|
||||
case SRTP_AES128_CM_SHA1_80:
|
||||
|
@ -607,7 +611,7 @@ export_srtp_keys (GstDtlsConnection * self)
|
|||
auth = GST_DTLS_SRTP_AUTH_HMAC_SHA1_32;
|
||||
break;
|
||||
default:
|
||||
LOG_WARNING (self, "invalid crypto suite set by handshake");
|
||||
GST_WARNING_OBJECT (self, "invalid crypto suite set by handshake");
|
||||
goto beach;
|
||||
}
|
||||
|
||||
|
@ -647,19 +651,20 @@ openssl_poll (GstDtlsConnection * self)
|
|||
|
||||
if (ret == 1) {
|
||||
if (!self->priv->keys_exported) {
|
||||
LOG_INFO (self, "handshake just completed successfully, exporting keys");
|
||||
GST_INFO_OBJECT (self,
|
||||
"handshake just completed successfully, exporting keys");
|
||||
export_srtp_keys (self);
|
||||
} else {
|
||||
LOG_INFO (self, "handshake is completed");
|
||||
GST_INFO_OBJECT (self, "handshake is completed");
|
||||
}
|
||||
return;
|
||||
} else {
|
||||
if (ret == 0) {
|
||||
LOG_DEBUG (self, "do_handshake encountered EOF");
|
||||
GST_DEBUG_OBJECT (self, "do_handshake encountered EOF");
|
||||
} else if (ret == -1) {
|
||||
LOG_WARNING (self, "do_handshake encountered BIO error");
|
||||
GST_WARNING_OBJECT (self, "do_handshake encountered BIO error");
|
||||
} else {
|
||||
LOG_DEBUG (self, "do_handshake returned %d", ret);
|
||||
GST_DEBUG_OBJECT (self, "do_handshake returned %d", ret);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -667,24 +672,24 @@ openssl_poll (GstDtlsConnection * self)
|
|||
|
||||
switch (error) {
|
||||
case SSL_ERROR_NONE:
|
||||
LOG_WARNING (self, "no error, handshake should be done");
|
||||
GST_WARNING_OBJECT (self, "no error, handshake should be done");
|
||||
break;
|
||||
case SSL_ERROR_SSL:
|
||||
LOG_LOG (self, "SSL error %d: %s", error,
|
||||
GST_LOG_OBJECT (self, "SSL error %d: %s", error,
|
||||
ERR_error_string (ERR_get_error (), buf));
|
||||
break;
|
||||
case SSL_ERROR_WANT_READ:
|
||||
LOG_LOG (self, "SSL wants read");
|
||||
GST_LOG_OBJECT (self, "SSL wants read");
|
||||
break;
|
||||
case SSL_ERROR_WANT_WRITE:
|
||||
LOG_LOG (self, "SSL wants write");
|
||||
GST_LOG_OBJECT (self, "SSL wants write");
|
||||
break;
|
||||
case SSL_ERROR_SYSCALL:{
|
||||
LOG_LOG (self, "SSL syscall (error) : %lu", ERR_get_error ());
|
||||
GST_LOG_OBJECT (self, "SSL syscall (error) : %lu", ERR_get_error ());
|
||||
break;
|
||||
}
|
||||
default:
|
||||
LOG_WARNING (self, "Unknown SSL error: %d, ret: %d", error, ret);
|
||||
GST_WARNING_OBJECT (self, "Unknown SSL error: %d, ret: %d", error, ret);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -706,7 +711,8 @@ openssl_verify_callback (int preverify_ok, X509_STORE_CTX * x509_ctx)
|
|||
pem = _gst_dtls_x509_to_pem (x509_ctx->cert);
|
||||
|
||||
if (!pem) {
|
||||
LOG_WARNING (self, "failed to convert received certificate to pem format");
|
||||
GST_WARNING_OBJECT (self,
|
||||
"failed to convert received certificate to pem format");
|
||||
} else {
|
||||
bio = BIO_new (BIO_s_mem ());
|
||||
if (bio) {
|
||||
|
@ -718,10 +724,10 @@ openssl_verify_callback (int preverify_ok, X509_STORE_CTX * x509_ctx)
|
|||
XN_FLAG_MULTILINE);
|
||||
BIO_read (bio, buffer, len);
|
||||
buffer[len] = '\0';
|
||||
LOG_DEBUG (self, "Peer certificate received:\n%s", buffer);
|
||||
GST_DEBUG_OBJECT (self, "Peer certificate received:\n%s", buffer);
|
||||
BIO_free (bio);
|
||||
} else {
|
||||
LOG_DEBUG (self, "failed to create certificate print membio");
|
||||
GST_DEBUG_OBJECT (self, "failed to create certificate print membio");
|
||||
}
|
||||
|
||||
g_signal_emit (self, signals[SIGNAL_ON_PEER_CERTIFICATE], 0, pem,
|
||||
|
@ -766,7 +772,7 @@ bio_method_write (BIO * bio, const char *data, int size)
|
|||
{
|
||||
GstDtlsConnection *self = GST_DTLS_CONNECTION (bio->ptr);
|
||||
|
||||
LOG_LOG (self, "BIO: writing %d", size);
|
||||
GST_LOG_OBJECT (self, "BIO: writing %d", size);
|
||||
|
||||
if (self->priv->send_closure) {
|
||||
GValue values[3] = { G_VALUE_INIT };
|
||||
|
@ -797,12 +803,12 @@ bio_method_read (BIO * bio, char *out_buffer, int size)
|
|||
internal_size = priv->bio_buffer_len - priv->bio_buffer_offset;
|
||||
|
||||
if (!priv->bio_buffer) {
|
||||
LOG_LOG (self, "BIO: EOF");
|
||||
GST_LOG_OBJECT (self, "BIO: EOF");
|
||||
return 0;
|
||||
}
|
||||
|
||||
if (!out_buffer || size <= 0) {
|
||||
LOG_WARNING (self, "BIO: read got invalid arguments");
|
||||
GST_WARNING_OBJECT (self, "BIO: read got invalid arguments");
|
||||
if (internal_size) {
|
||||
BIO_set_retry_read (bio);
|
||||
}
|
||||
|
@ -815,7 +821,7 @@ bio_method_read (BIO * bio, char *out_buffer, int size)
|
|||
copy_size = size;
|
||||
}
|
||||
|
||||
LOG_DEBUG (self,
|
||||
GST_DEBUG_OBJECT (self,
|
||||
"reading %d/%d bytes %d at offset %d, output buff size is %d", copy_size,
|
||||
priv->bio_buffer_len, internal_size, priv->bio_buffer_offset, size);
|
||||
|
||||
|
@ -839,7 +845,7 @@ bio_method_ctrl (BIO * bio, int cmd, long arg1, void *arg2)
|
|||
switch (cmd) {
|
||||
case BIO_CTRL_DGRAM_SET_NEXT_TIMEOUT:
|
||||
case BIO_CTRL_DGRAM_SET_RECV_TIMEOUT:
|
||||
LOG_LOG (self, "BIO: Timeout set");
|
||||
GST_LOG_OBJECT (self, "BIO: Timeout set");
|
||||
priv->timeout_set = TRUE;
|
||||
g_cond_signal (&priv->condition);
|
||||
return 1;
|
||||
|
@ -847,32 +853,32 @@ bio_method_ctrl (BIO * bio, int cmd, long arg1, void *arg2)
|
|||
priv->bio_buffer = NULL;
|
||||
priv->bio_buffer_len = 0;
|
||||
priv->bio_buffer_offset = 0;
|
||||
LOG_LOG (self, "BIO: EOF reset");
|
||||
GST_LOG_OBJECT (self, "BIO: EOF reset");
|
||||
return 1;
|
||||
case BIO_CTRL_EOF:{
|
||||
gint eof = !(priv->bio_buffer_len - priv->bio_buffer_offset);
|
||||
LOG_LOG (self, "BIO: EOF query returned %d", eof);
|
||||
GST_LOG_OBJECT (self, "BIO: EOF query returned %d", eof);
|
||||
return eof;
|
||||
}
|
||||
case BIO_CTRL_WPENDING:
|
||||
LOG_LOG (self, "BIO: pending write");
|
||||
GST_LOG_OBJECT (self, "BIO: pending write");
|
||||
return 1;
|
||||
case BIO_CTRL_PENDING:{
|
||||
gint pending = priv->bio_buffer_len - priv->bio_buffer_offset;
|
||||
LOG_LOG (self, "BIO: %d bytes pending", pending);
|
||||
GST_LOG_OBJECT (self, "BIO: %d bytes pending", pending);
|
||||
return pending;
|
||||
}
|
||||
case BIO_CTRL_FLUSH:
|
||||
LOG_LOG (self, "BIO: flushing");
|
||||
GST_LOG_OBJECT (self, "BIO: flushing");
|
||||
return 1;
|
||||
case BIO_CTRL_DGRAM_QUERY_MTU:
|
||||
LOG_DEBUG (self, "BIO: MTU query, returning 0...");
|
||||
GST_DEBUG_OBJECT (self, "BIO: MTU query, returning 0...");
|
||||
return 0;
|
||||
case BIO_CTRL_DGRAM_MTU_EXCEEDED:
|
||||
LOG_WARNING (self, "BIO: MTU exceeded");
|
||||
GST_WARNING_OBJECT (self, "BIO: MTU exceeded");
|
||||
return 0;
|
||||
default:
|
||||
LOG_LOG (self, "BIO: unhandled ctrl, %d", cmd);
|
||||
GST_LOG_OBJECT (self, "BIO: unhandled ctrl, %d", cmd);
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
|
@ -880,7 +886,7 @@ bio_method_ctrl (BIO * bio, int cmd, long arg1, void *arg2)
|
|||
static int
|
||||
bio_method_new (BIO * bio)
|
||||
{
|
||||
LOG_LOG (NULL, "BIO: new");
|
||||
GST_LOG_OBJECT (NULL, "BIO: new");
|
||||
|
||||
bio->shutdown = 0;
|
||||
bio->init = 1;
|
||||
|
@ -892,10 +898,10 @@ static int
|
|||
bio_method_free (BIO * bio)
|
||||
{
|
||||
if (!bio) {
|
||||
LOG_LOG (NULL, "BIO free called with null bio");
|
||||
GST_LOG_OBJECT (NULL, "BIO free called with null bio");
|
||||
return 0;
|
||||
}
|
||||
|
||||
LOG_LOG (GST_DTLS_CONNECTION (bio->ptr), "BIO free");
|
||||
GST_LOG_OBJECT (GST_DTLS_CONNECTION (bio->ptr), "BIO free");
|
||||
return 0;
|
||||
}
|
||||
|
|
|
@ -49,8 +49,6 @@ GST_DEBUG_CATEGORY_STATIC (gst_dtls_dec_debug);
|
|||
G_DEFINE_TYPE_WITH_CODE (GstDtlsDec, gst_dtls_dec, GST_TYPE_ELEMENT,
|
||||
GST_DEBUG_CATEGORY_INIT (gst_dtls_dec_debug, "dtlsdec", 0, "DTLS Decoder"));
|
||||
|
||||
#define UNUSED(param) while (0) { (void)(param); }
|
||||
|
||||
enum
|
||||
{
|
||||
SIGNAL_ON_KEY_RECEIVED,
|
||||
|
@ -387,7 +385,6 @@ on_key_received (GstDtlsConnection * connection, gpointer key, guint cipher,
|
|||
gpointer key_dup;
|
||||
gchar *key_str;
|
||||
|
||||
UNUSED (connection);
|
||||
g_return_if_fail (GST_IS_DTLS_DEC (self));
|
||||
|
||||
self->srtp_cipher = cipher;
|
||||
|
@ -429,7 +426,6 @@ on_pegst_certificate_received (GstDtlsConnection * connection, gchar * pem,
|
|||
{
|
||||
GWeakRef *ref;
|
||||
|
||||
UNUSED (connection);
|
||||
g_return_val_if_fail (GST_IS_DTLS_DEC (self), TRUE);
|
||||
|
||||
GST_DEBUG_OBJECT (self, "Received peer certificate PEM: \n%s", pem);
|
||||
|
@ -557,8 +553,6 @@ get_agent_by_pem (const gchar * pem)
|
|||
static void
|
||||
agent_weak_ref_notify (gchar * pem, GstDtlsAgent * agent)
|
||||
{
|
||||
UNUSED (agent);
|
||||
|
||||
G_LOCK (agent_table);
|
||||
g_hash_table_remove (agent_table, pem);
|
||||
G_UNLOCK (agent_table);
|
||||
|
@ -633,8 +627,6 @@ create_connection (GstDtlsDec * self, gchar * id)
|
|||
static void
|
||||
connection_weak_ref_notify (gchar * id, GstDtlsConnection * connection)
|
||||
{
|
||||
UNUSED (connection);
|
||||
|
||||
G_LOCK (connection_table);
|
||||
g_hash_table_remove (connection_table, id);
|
||||
G_UNLOCK (connection_table);
|
||||
|
|
|
@ -57,8 +57,6 @@ G_DEFINE_TYPE_WITH_CODE (GstDtlsSrtpDec, gst_dtls_srtp_dec,
|
|||
GST_TYPE_DTLS_SRTP_BIN, GST_DEBUG_CATEGORY_INIT (gst_dtls_srtp_dec_debug,
|
||||
"dtlssrtpdec", 0, "DTLS Decoder"));
|
||||
|
||||
#define UNUSED(param) while (0) { (void)(param); }
|
||||
|
||||
enum
|
||||
{
|
||||
PROP_0,
|
||||
|
@ -396,8 +394,6 @@ static void
|
|||
on_pegst_pem (GstElement * srtp_decoder, GParamSpec * pspec,
|
||||
GstDtlsSrtpDec * self)
|
||||
{
|
||||
UNUSED (srtp_decoder);
|
||||
UNUSED (pspec);
|
||||
g_return_if_fail (self);
|
||||
g_object_notify_by_pspec (G_OBJECT (self), properties[PROP_PEER_PEM]);
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue