提交 eb1115e9 authored 作者: Iñaki Baz Castillo's avatar Iñaki Baz Castillo

Rename class names of dependency handlers.

上级 c0fad081
#ifndef MS_LIBSRTP_H #ifndef MS_DEP_LIBSRTP_H
#define MS_LIBSRTP_H #define MS_DEP_LIBSRTP_H
#include <vector> #include <vector>
#include <srtp/srtp.h> #include <srtp/srtp.h>
class LibSRTP class DepLibSRTP
{ {
public: public:
static void ClassInit(); static void ClassInit();
...@@ -19,16 +19,16 @@ private: ...@@ -19,16 +19,16 @@ private:
/* Inline static methods. */ /* Inline static methods. */
inline inline
bool LibSRTP::IsError(err_status_t code) bool DepLibSRTP::IsError(err_status_t code)
{ {
return (code != err_status_ok); return (code != err_status_ok);
} }
inline inline
const char* LibSRTP::GetErrorString(err_status_t code) const char* DepLibSRTP::GetErrorString(err_status_t code)
{ {
// This throws out_of_range if the given index is not in the vector. // This throws out_of_range if the given index is not in the vector.
return LibSRTP::errors.at(code); return DepLibSRTP::errors.at(code);
} }
#endif #endif
#ifndef MS_LIBUV_H #ifndef MS_DEP_LIBUV_H
#define MS_LIBUV_H #define MS_DEP_LIBUV_H
#include "common.h" #include "common.h"
#include <uv.h> #include <uv.h>
class LibUV class DepLibUV
{ {
public: public:
static void ClassInit(); static void ClassInit();
...@@ -20,9 +20,9 @@ private: ...@@ -20,9 +20,9 @@ private:
/* Inline static methods. */ /* Inline static methods. */
inline inline
uv_loop_t* LibUV::GetLoop() uv_loop_t* DepLibUV::GetLoop()
{ {
return LibUV::loop; return DepLibUV::loop;
} }
#endif #endif
#ifndef MS_OPENSSL_H #ifndef MS_DEP_OPENSSL_H
#define MS_OPENSSL_H #define MS_DEP_OPENSSL_H
#include "common.h" #include "common.h"
#include <openssl/ssl.h> #include <openssl/ssl.h>
...@@ -11,7 +11,7 @@ struct CRYPTO_dynlock_value ...@@ -11,7 +11,7 @@ struct CRYPTO_dynlock_value
pthread_mutex_t mutex; pthread_mutex_t mutex;
}; };
class OpenSSL class DepOpenSSL
{ {
public: public:
static void ClassInit(); static void ClassInit();
......
#ifndef MS_DEP_USRSCTP_H
#define MS_DEP_USRSCTP_H
class DepUsrSCTP
{
public:
static void ClassInit();
static void ClassDestroy();
};
#endif
...@@ -2,7 +2,7 @@ ...@@ -2,7 +2,7 @@
#define MS_RTC_SRTP_SESSION_H #define MS_RTC_SRTP_SESSION_H
#include "common.h" #include "common.h"
#include "LibSRTP.h" #include "DepLibSRTP.h"
#include "RTC/SRTPProfile.h" #include "RTC/SRTPProfile.h"
#include <srtp/srtp.h> #include <srtp/srtp.h>
...@@ -51,7 +51,7 @@ namespace RTC ...@@ -51,7 +51,7 @@ namespace RTC
{ {
const char* error_string; const char* error_string;
error_string = LibSRTP::GetErrorString(this->lastError); error_string = DepLibSRTP::GetErrorString(this->lastError);
this->lastError = (err_status_t)0; // Reset it. this->lastError = (err_status_t)0; // Reset it.
return error_string; return error_string;
......
#define MS_CLASS "LibSRTP" #define MS_CLASS "DepLibSRTP"
#include "LibSRTP.h" #include "DepLibSRTP.h"
#include "MediaSoupError.h" #include "MediaSoupError.h"
#include "Logger.h" #include "Logger.h"
/* Static variables. */ /* Static variables. */
std::vector<const char*> LibSRTP::errors = std::vector<const char*> DepLibSRTP::errors =
{ {
// From 0 (err_status_ok) to 24 (err_status_pfkey_err). // From 0 (err_status_ok) to 24 (err_status_pfkey_err).
"nothing to report (err_status_ok)", "nothing to report (err_status_ok)",
...@@ -38,28 +38,24 @@ std::vector<const char*> LibSRTP::errors = ...@@ -38,28 +38,24 @@ std::vector<const char*> LibSRTP::errors =
/* Static methods. */ /* Static methods. */
void LibSRTP::ClassInit() void DepLibSRTP::ClassInit()
{ {
MS_TRACE(); MS_TRACE();
err_status_t err; err_status_t err;
MS_DEBUG("loaded libsrtp");
err = srtp_init(); err = srtp_init();
if (LibSRTP::IsError(err)) if (DepLibSRTP::IsError(err))
MS_THROW_ERROR("srtp_init() failed: %s", LibSRTP::GetErrorString(err)); MS_THROW_ERROR("srtp_init() failed: %s", DepLibSRTP::GetErrorString(err));
} }
void LibSRTP::ClassDestroy() void DepLibSRTP::ClassDestroy()
{ {
MS_TRACE(); MS_TRACE();
err_status_t err; err_status_t err;
MS_DEBUG("unloading libsrtp");
err = srtp_shutdown(); err = srtp_shutdown();
if (LibSRTP::IsError(err)) if (DepLibSRTP::IsError(err))
MS_CRIT("srtp_shutdown() failed: %s", LibSRTP::GetErrorString(err)); MS_CRIT("srtp_shutdown() failed: %s", DepLibSRTP::GetErrorString(err));
} }
#define MS_CLASS "LibUV" #define MS_CLASS "DepLibUV"
#include "LibUV.h" #include "DepLibUV.h"
#include "Logger.h" #include "Logger.h"
/* Static variables. */ /* Static variables. */
__thread uv_loop_t* LibUV::loop = nullptr; __thread uv_loop_t* DepLibUV::loop = nullptr;
/* Static methods. */ /* Static methods. */
void LibUV::ClassInit() void DepLibUV::ClassInit()
{ {
MS_TRACE(); MS_TRACE();
...@@ -17,41 +17,41 @@ void LibUV::ClassInit() ...@@ -17,41 +17,41 @@ void LibUV::ClassInit()
MS_DEBUG("loaded libuv version: %s", uv_version_string()); MS_DEBUG("loaded libuv version: %s", uv_version_string());
} }
void LibUV::ThreadInit() void DepLibUV::ThreadInit()
{ {
MS_TRACE(); MS_TRACE();
int err; int err;
// This should never happen. // This should never happen.
if (LibUV::loop) if (DepLibUV::loop)
MS_ABORT("LibUV::loop alread allocated in this thread"); MS_ABORT("DepLibUV::loop alread allocated in this thread");
LibUV::loop = new uv_loop_t; DepLibUV::loop = new uv_loop_t;
err = uv_loop_init(LibUV::loop); err = uv_loop_init(DepLibUV::loop);
if (err) if (err)
MS_ABORT("uv_loop_init() failed: %s", uv_strerror(err)); MS_ABORT("uv_loop_init() failed: %s", uv_strerror(err));
} }
void LibUV::ThreadDestroy() void DepLibUV::ThreadDestroy()
{ {
MS_TRACE(); MS_TRACE();
// This should never happen. // This should never happen.
if (!LibUV::loop) if (!DepLibUV::loop)
MS_ABORT("LibUV::loop was not allocated in this thread"); MS_ABORT("DepLibUV::loop was not allocated in this thread");
uv_loop_close(LibUV::loop); uv_loop_close(DepLibUV::loop);
delete LibUV::loop; delete DepLibUV::loop;
} }
void LibUV::RunLoop() void DepLibUV::RunLoop()
{ {
MS_TRACE(); MS_TRACE();
// This should never happen. // This should never happen.
if (!LibUV::loop) if (!DepLibUV::loop)
MS_ABORT("LibUV::loop was not allocated in this thread"); MS_ABORT("DepLibUV::loop was not allocated in this thread");
uv_run(LibUV::loop, UV_RUN_DEFAULT); uv_run(DepLibUV::loop, UV_RUN_DEFAULT);
} }
#define MS_CLASS "OpenSSL" #define MS_CLASS "DepOpenSSL"
#include "OpenSSL.h" #include "DepOpenSSL.h"
#include "MediaSoupError.h" #include "MediaSoupError.h"
#include "Logger.h" #include "Logger.h"
#include <openssl/err.h> #include <openssl/err.h>
...@@ -9,12 +9,12 @@ ...@@ -9,12 +9,12 @@
/* Static attributes. */ /* Static attributes. */
// This array will store all of the mutex available for OpenSSL. // This array will store all of the mutex available for OpenSSL.
pthread_mutex_t* OpenSSL::mutexes = nullptr; pthread_mutex_t* DepOpenSSL::mutexes = nullptr;
int OpenSSL::numMutexes = 0; int DepOpenSSL::numMutexes = 0;
/* Static methods. */ /* Static methods. */
void OpenSSL::ClassInit() void DepOpenSSL::ClassInit()
{ {
MS_TRACE(); MS_TRACE();
...@@ -26,32 +26,30 @@ void OpenSSL::ClassInit() ...@@ -26,32 +26,30 @@ void OpenSSL::ClassInit()
RAND_poll(); RAND_poll();
// Make OpenSSL thread-safe. // Make OpenSSL thread-safe.
OpenSSL::mutexes = new pthread_mutex_t[CRYPTO_num_locks()]; DepOpenSSL::mutexes = new pthread_mutex_t[CRYPTO_num_locks()];
if (!OpenSSL::mutexes) if (!DepOpenSSL::mutexes)
MS_THROW_ERROR("allocation of mutexes failed"); MS_THROW_ERROR("allocation of mutexes failed");
OpenSSL::numMutexes = CRYPTO_num_locks(); DepOpenSSL::numMutexes = CRYPTO_num_locks();
for (int i = 0; i < OpenSSL::numMutexes; i++) for (int i = 0; i < DepOpenSSL::numMutexes; i++)
{ {
int err = pthread_mutex_init(&OpenSSL::mutexes[i], nullptr); int err = pthread_mutex_init(&DepOpenSSL::mutexes[i], nullptr);
if (err) if (err)
MS_THROW_ERROR("pthread_mutex_init() failed with return code %d\n", err); MS_THROW_ERROR("pthread_mutex_init() failed with return code %d\n", err);
} }
CRYPTO_THREADID_set_callback(OpenSSL::SetThreadId); CRYPTO_THREADID_set_callback(DepOpenSSL::SetThreadId);
CRYPTO_set_locking_callback(OpenSSL::LockingFunction); CRYPTO_set_locking_callback(DepOpenSSL::LockingFunction);
CRYPTO_set_dynlock_create_callback(OpenSSL::DynCreateFunction); CRYPTO_set_dynlock_create_callback(DepOpenSSL::DynCreateFunction);
CRYPTO_set_dynlock_lock_callback(OpenSSL::DynLockFunction); CRYPTO_set_dynlock_lock_callback(DepOpenSSL::DynLockFunction);
CRYPTO_set_dynlock_destroy_callback(OpenSSL::DynDestroyFunction); CRYPTO_set_dynlock_destroy_callback(DepOpenSSL::DynDestroyFunction);
} }
void OpenSSL::ClassDestroy() void DepOpenSSL::ClassDestroy()
{ {
MS_TRACE(); MS_TRACE();
MS_DEBUG("unloading openssl");
// FAQ: https://www.openssl.org/support/faq.html#PROG13 // FAQ: https://www.openssl.org/support/faq.html#PROG13
// Thread-local cleanup functions. // Thread-local cleanup functions.
...@@ -70,14 +68,14 @@ void OpenSSL::ClassDestroy() ...@@ -70,14 +68,14 @@ void OpenSSL::ClassDestroy()
sk_SSL_COMP_free(SSL_COMP_get_compression_methods()); sk_SSL_COMP_free(SSL_COMP_get_compression_methods());
// Free mutexes. // Free mutexes.
for (int i = 0; i < OpenSSL::numMutexes; i++) for (int i = 0; i < DepOpenSSL::numMutexes; i++)
{ {
int err = pthread_mutex_destroy(&OpenSSL::mutexes[i]); int err = pthread_mutex_destroy(&DepOpenSSL::mutexes[i]);
if (err) if (err)
MS_ERROR("pthread_mutex_destroy() failed with return code %d\n", err); MS_ERROR("pthread_mutex_destroy() failed with return code %d\n", err);
} }
if (OpenSSL::mutexes) if (DepOpenSSL::mutexes)
delete[] OpenSSL::mutexes; delete[] DepOpenSSL::mutexes;
// Reset callbacks. // Reset callbacks.
CRYPTO_THREADID_set_callback(nullptr); CRYPTO_THREADID_set_callback(nullptr);
...@@ -87,14 +85,14 @@ void OpenSSL::ClassDestroy() ...@@ -87,14 +85,14 @@ void OpenSSL::ClassDestroy()
CRYPTO_set_dynlock_destroy_callback(nullptr); CRYPTO_set_dynlock_destroy_callback(nullptr);
} }
void OpenSSL::SetThreadId(CRYPTO_THREADID* id) void DepOpenSSL::SetThreadId(CRYPTO_THREADID* id)
{ {
// MS_TRACE(); // MS_TRACE();
CRYPTO_THREADID_set_numeric(id, (unsigned long)pthread_self()); CRYPTO_THREADID_set_numeric(id, (unsigned long)pthread_self());
} }
void OpenSSL::LockingFunction(int mode, int n, const char *file, int line) void DepOpenSSL::LockingFunction(int mode, int n, const char *file, int line)
{ {
// MS_TRACE(); // MS_TRACE();
...@@ -112,12 +110,12 @@ void OpenSSL::LockingFunction(int mode, int n, const char *file, int line) ...@@ -112,12 +110,12 @@ void OpenSSL::LockingFunction(int mode, int n, const char *file, int line)
// MS_DEBUG("[mode: %s+%s, mutex id: %d, file: %s, line: %d]", mode & CRYPTO_LOCK ? "LOCK" : "UNLOCK", mode & CRYPTO_READ ? "READ" : "WRITE", n, file, line); // MS_DEBUG("[mode: %s+%s, mutex id: %d, file: %s, line: %d]", mode & CRYPTO_LOCK ? "LOCK" : "UNLOCK", mode & CRYPTO_READ ? "READ" : "WRITE", n, file, line);
if (mode & CRYPTO_LOCK) if (mode & CRYPTO_LOCK)
pthread_mutex_lock(&OpenSSL::mutexes[n]); pthread_mutex_lock(&DepOpenSSL::mutexes[n]);
else else
pthread_mutex_unlock(&OpenSSL::mutexes[n]); pthread_mutex_unlock(&DepOpenSSL::mutexes[n]);
} }
CRYPTO_dynlock_value* OpenSSL::DynCreateFunction(const char* file, int line) CRYPTO_dynlock_value* DepOpenSSL::DynCreateFunction(const char* file, int line)
{ {
// MS_TRACE(); // MS_TRACE();
...@@ -132,7 +130,7 @@ CRYPTO_dynlock_value* OpenSSL::DynCreateFunction(const char* file, int line) ...@@ -132,7 +130,7 @@ CRYPTO_dynlock_value* OpenSSL::DynCreateFunction(const char* file, int line)
return value; return value;
} }
void OpenSSL::DynLockFunction(int mode, CRYPTO_dynlock_value* v, const char* file, int line) void DepOpenSSL::DynLockFunction(int mode, CRYPTO_dynlock_value* v, const char* file, int line)
{ {
// MS_TRACE(); // MS_TRACE();
...@@ -142,7 +140,7 @@ void OpenSSL::DynLockFunction(int mode, CRYPTO_dynlock_value* v, const char* fil ...@@ -142,7 +140,7 @@ void OpenSSL::DynLockFunction(int mode, CRYPTO_dynlock_value* v, const char* fil
pthread_mutex_unlock(&v->mutex); pthread_mutex_unlock(&v->mutex);
} }
void OpenSSL::DynDestroyFunction(CRYPTO_dynlock_value* v, const char* file, int line) void DepOpenSSL::DynDestroyFunction(CRYPTO_dynlock_value* v, const char* file, int line)
{ {
// MS_TRACE(); // MS_TRACE();
......
#define MS_CLASS "DepUsrSCTP"
#include "DepUsrSCTP.h"
#include "Logger.h"
#include <usrsctp.h>
/* Static methods. */
void DepUsrSCTP::ClassInit()
{
MS_TRACE();
// Initialize usrsctp.
// TODO: second argment must be a function to get outgoing SCTP data
// (to be sent on top of DTLS)
usrsctp_init(0, nullptr, nullptr);
}
void DepUsrSCTP::ClassDestroy()
{
MS_TRACE();
int err;
// Free usrsctp.
err = usrsctp_finish();
if (err)
MS_CRIT("usrsctp_finish() failed");
}
...@@ -5,7 +5,7 @@ ...@@ -5,7 +5,7 @@
#include "Daemon.h" #include "Daemon.h"
#include "Worker.h" #include "Worker.h"
#include "Utils.h" #include "Utils.h"
#include "LibUV.h" #include "DepLibUV.h"
#include "ControlProtocol/messages.h" #include "ControlProtocol/messages.h"
#include "MediaSoupError.h" #include "MediaSoupError.h"
#include "Logger.h" #include "Logger.h"
...@@ -86,7 +86,7 @@ Dispatcher::Dispatcher() ...@@ -86,7 +86,7 @@ Dispatcher::Dispatcher()
Daemon::SendOKStatusToAncestor(); Daemon::SendOKStatusToAncestor();
// Run the loop. // Run the loop.
LibUV::RunLoop(); DepLibUV::RunLoop();
MS_DEBUG("libuv loop ends"); MS_DEBUG("libuv loop ends");
} }
......
...@@ -5,9 +5,10 @@ ...@@ -5,9 +5,10 @@
#include "Daemon.h" #include "Daemon.h"
#include "Dispatcher.h" #include "Dispatcher.h"
#include "Worker.h" #include "Worker.h"
#include "LibUV.h" #include "DepLibUV.h"
#include "OpenSSL.h" #include "DepOpenSSL.h"
#include "LibSRTP.h" #include "DepLibSRTP.h"
#include "DepUsrSCTP.h"
#include "Utils.h" #include "Utils.h"
#include "RTC/UDPSocket.h" #include "RTC/UDPSocket.h"
#include "RTC/TCPServer.h" #include "RTC/TCPServer.h"
...@@ -358,7 +359,7 @@ void MediaSoup::ThreadInit() ...@@ -358,7 +359,7 @@ void MediaSoup::ThreadInit()
Logger::ThreadInit("main"); Logger::ThreadInit("main");
// Load libuv stuff. // Load libuv stuff.
LibUV::ThreadInit(); DepLibUV::ThreadInit();
// Load the crypto utils. // Load the crypto utils.
Utils::Crypto::ThreadInit(); Utils::Crypto::ThreadInit();
...@@ -368,7 +369,7 @@ void MediaSoup::ThreadDestroy() ...@@ -368,7 +369,7 @@ void MediaSoup::ThreadDestroy()
{ {
MS_TRACE(); MS_TRACE();
LibUV::ThreadDestroy(); DepLibUV::ThreadDestroy();
Utils::Crypto::ThreadDestroy(); Utils::Crypto::ThreadDestroy();
} }
...@@ -378,9 +379,10 @@ void MediaSoup::ClassInit() ...@@ -378,9 +379,10 @@ void MediaSoup::ClassInit()
MS_TRACE(); MS_TRACE();
// Initialize static stuff. // Initialize static stuff.
LibUV::ClassInit(); DepLibUV::ClassInit();
OpenSSL::ClassInit(); DepOpenSSL::ClassInit();
LibSRTP::ClassInit(); DepLibSRTP::ClassInit();
DepUsrSCTP::ClassInit();
RTC::UDPSocket::ClassInit(); RTC::UDPSocket::ClassInit();
RTC::TCPServer::ClassInit(); RTC::TCPServer::ClassInit();
RTC::DTLSHandler::ClassInit(); RTC::DTLSHandler::ClassInit();
...@@ -393,8 +395,9 @@ void MediaSoup::ClassDestroy() ...@@ -393,8 +395,9 @@ void MediaSoup::ClassDestroy()
// Free static stuff. // Free static stuff.
RTC::DTLSHandler::ClassDestroy(); RTC::DTLSHandler::ClassDestroy();
OpenSSL::ClassDestroy(); DepOpenSSL::ClassDestroy();
LibSRTP::ClassDestroy(); DepLibSRTP::ClassDestroy();
DepUsrSCTP::ClassDestroy();
} }
/* This method is called within a new thread and creates a Worker. */ /* This method is called within a new thread and creates a Worker. */
......
...@@ -23,9 +23,9 @@ namespace RTC ...@@ -23,9 +23,9 @@ namespace RTC
err_status_t err; err_status_t err;
err = srtp_install_event_handler((srtp_event_handler_func_t*)onSRTPEvent); err = srtp_install_event_handler((srtp_event_handler_func_t*)onSRTPEvent);
if (LibSRTP::IsError(err)) if (DepLibSRTP::IsError(err))
{ {
MS_THROW_ERROR("srtp_install_event_handler() failed: %s", LibSRTP::GetErrorString(err)); MS_THROW_ERROR("srtp_install_event_handler() failed: %s", DepLibSRTP::GetErrorString(err));
} }
} }
...@@ -101,9 +101,9 @@ namespace RTC ...@@ -101,9 +101,9 @@ namespace RTC
// Set the SRTP session. // Set the SRTP session.
err = srtp_create(&this->session, &policy); err = srtp_create(&this->session, &policy);
if (LibSRTP::IsError(err)) if (DepLibSRTP::IsError(err))
{ {
MS_THROW_ERROR("srtp_create() failed: %s", LibSRTP::GetErrorString(err)); MS_THROW_ERROR("srtp_create() failed: %s", DepLibSRTP::GetErrorString(err));
} }
} }
...@@ -116,9 +116,9 @@ namespace RTC ...@@ -116,9 +116,9 @@ namespace RTC
err_status_t err; err_status_t err;
err = srtp_dealloc(this->session); err = srtp_dealloc(this->session);
if (LibSRTP::IsError(err)) if (DepLibSRTP::IsError(err))
{ {
MS_ABORT("srtp_dealloc() failed: %s", LibSRTP::GetErrorString(err)); MS_ABORT("srtp_dealloc() failed: %s", DepLibSRTP::GetErrorString(err));
} }
} }
} }
...@@ -140,9 +140,9 @@ namespace RTC ...@@ -140,9 +140,9 @@ namespace RTC
std::memcpy(SRTPSession::encryptBuffer, *data, *len); std::memcpy(SRTPSession::encryptBuffer, *data, *len);
this->lastError = srtp_protect(this->session, (void*)SRTPSession::encryptBuffer, (int*)len); this->lastError = srtp_protect(this->session, (void*)SRTPSession::encryptBuffer, (int*)len);
if (LibSRTP::IsError(this->lastError)) if (DepLibSRTP::IsError(this->lastError))
{ {
MS_DEBUG("srtp_protect() failed: %s", LibSRTP::GetErrorString(this->lastError)); MS_DEBUG("srtp_protect() failed: %s", DepLibSRTP::GetErrorString(this->lastError));
return false; return false;
} }
...@@ -157,9 +157,9 @@ namespace RTC ...@@ -157,9 +157,9 @@ namespace RTC
MS_TRACE(); MS_TRACE();
this->lastError = srtp_unprotect(this->session, (void*)data, (int*)len); this->lastError = srtp_unprotect(this->session, (void*)data, (int*)len);
if (LibSRTP::IsError(this->lastError)) if (DepLibSRTP::IsError(this->lastError))
{ {
MS_DEBUG("srtp_unprotect() failed: %s", LibSRTP::GetErrorString(this->lastError)); MS_DEBUG("srtp_unprotect() failed: %s", DepLibSRTP::GetErrorString(this->lastError));
return false; return false;
} }
...@@ -181,9 +181,9 @@ namespace RTC ...@@ -181,9 +181,9 @@ namespace RTC
std::memcpy(SRTPSession::encryptBuffer, *data, *len); std::memcpy(SRTPSession::encryptBuffer, *data, *len);
this->lastError = srtp_protect_rtcp(this->session, (void*)SRTPSession::encryptBuffer, (int*)len); this->lastError = srtp_protect_rtcp(this->session, (void*)SRTPSession::encryptBuffer, (int*)len);
if (LibSRTP::IsError(this->lastError)) if (DepLibSRTP::IsError(this->lastError))
{ {
MS_DEBUG("srtp_protect_rtcp() failed: %s", LibSRTP::GetErrorString(this->lastError)); MS_DEBUG("srtp_protect_rtcp() failed: %s", DepLibSRTP::GetErrorString(this->lastError));
return false; return false;
} }
...@@ -198,9 +198,9 @@ namespace RTC ...@@ -198,9 +198,9 @@ namespace RTC
MS_TRACE(); MS_TRACE();
this->lastError = srtp_unprotect_rtcp(this->session, (void*)data, (int*)len); this->lastError = srtp_unprotect_rtcp(this->session, (void*)data, (int*)len);
if (LibSRTP::IsError(this->lastError)) if (DepLibSRTP::IsError(this->lastError))
{ {
MS_DEBUG("srtp_unprotect_rtcp() failed: %s", LibSRTP::GetErrorString(this->lastError)); MS_DEBUG("srtp_unprotect_rtcp() failed: %s", DepLibSRTP::GetErrorString(this->lastError));
return false; return false;
} }
......
...@@ -6,7 +6,7 @@ ...@@ -6,7 +6,7 @@
#include "RTC/DTLSHandler.h" #include "RTC/DTLSHandler.h"
#include "Settings.h" #include "Settings.h"
#include "Utils.h" #include "Utils.h"
#include "LibUV.h" #include "DepLibUV.h"
#include "MediaSoupError.h" #include "MediaSoupError.h"
#include "Logger.h" #include "Logger.h"
#include <string> #include <string>
...@@ -232,7 +232,7 @@ namespace RTC ...@@ -232,7 +232,7 @@ namespace RTC
uvHandles[0] = new uv_tcp_t(); uvHandles[0] = new uv_tcp_t();
err = uv_tcp_init(LibUV::GetLoop(), uvHandles[0]); err = uv_tcp_init(DepLibUV::GetLoop(), uvHandles[0]);
if (err) if (err)
{ {
delete uvHandles[0]; delete uvHandles[0];
...@@ -272,7 +272,7 @@ namespace RTC ...@@ -272,7 +272,7 @@ namespace RTC
{ {
uvHandles[1] = new uv_tcp_t(); uvHandles[1] = new uv_tcp_t();
err = uv_tcp_init(LibUV::GetLoop(), uvHandles[1]); err = uv_tcp_init(DepLibUV::GetLoop(), uvHandles[1]);
if (err) if (err)
{ {
uv_close((uv_handle_t*)uvHandles[0], (uv_close_cb)on_error_close); uv_close((uv_handle_t*)uvHandles[0], (uv_close_cb)on_error_close);
......
...@@ -7,7 +7,7 @@ ...@@ -7,7 +7,7 @@
#include "RTC/RTCPPacket.h" #include "RTC/RTCPPacket.h"
#include "Settings.h" #include "Settings.h"
#include "Utils.h" #include "Utils.h"
#include "LibUV.h" #include "DepLibUV.h"
#include "MediaSoupError.h" #include "MediaSoupError.h"
#include "Logger.h" #include "Logger.h"
#include <string> #include <string>
...@@ -230,7 +230,7 @@ namespace RTC ...@@ -230,7 +230,7 @@ namespace RTC
uvHandles[0] = new uv_udp_t(); uvHandles[0] = new uv_udp_t();
err = uv_udp_init(LibUV::GetLoop(), uvHandles[0]); err = uv_udp_init(DepLibUV::GetLoop(), uvHandles[0]);
if (err) if (err)
{ {
delete uvHandles[0]; delete uvHandles[0];
...@@ -270,7 +270,7 @@ namespace RTC ...@@ -270,7 +270,7 @@ namespace RTC
{ {
uvHandles[1] = new uv_udp_t(); uvHandles[1] = new uv_udp_t();
err = uv_udp_init(LibUV::GetLoop(), uvHandles[1]); err = uv_udp_init(DepLibUV::GetLoop(), uvHandles[1]);
if (err) if (err)
{ {
uv_close((uv_handle_t*)uvHandles[0], (uv_close_cb)on_error_close); uv_close((uv_handle_t*)uvHandles[0], (uv_close_cb)on_error_close);
......
...@@ -2,7 +2,7 @@ ...@@ -2,7 +2,7 @@
#include "Worker.h" #include "Worker.h"
#include "Utils.h" #include "Utils.h"
#include "LibUV.h" #include "DepLibUV.h"
#include "ControlProtocol/messages.h" #include "ControlProtocol/messages.h"
#include "MediaSoupError.h" #include "MediaSoupError.h"
#include "Logger.h" #include "Logger.h"
...@@ -23,7 +23,7 @@ void Worker::ThreadInit(int workerId) ...@@ -23,7 +23,7 @@ void Worker::ThreadInit(int workerId)
Logger::ThreadInit("worker #" + std::to_string(workerId)); Logger::ThreadInit("worker #" + std::to_string(workerId));
MS_TRACE(); MS_TRACE();
LibUV::ThreadInit(); DepLibUV::ThreadInit();
Utils::Crypto::ThreadInit(); Utils::Crypto::ThreadInit();
} }
...@@ -32,7 +32,7 @@ void Worker::ThreadDestroy() ...@@ -32,7 +32,7 @@ void Worker::ThreadDestroy()
{ {
MS_TRACE(); MS_TRACE();
LibUV::ThreadDestroy(); DepLibUV::ThreadDestroy();
Utils::Crypto::ThreadDestroy(); Utils::Crypto::ThreadDestroy();
} }
...@@ -156,7 +156,7 @@ Worker::Worker(int workerId) : ...@@ -156,7 +156,7 @@ Worker::Worker(int workerId) :
Worker::numWorkersRunning++; Worker::numWorkersRunning++;
// Run the loop. // Run the loop.
LibUV::RunLoop(); DepLibUV::RunLoop();
MS_DEBUG("libuv loop ends"); MS_DEBUG("libuv loop ends");
} }
......
#define MS_CLASS "SignalsHandler" #define MS_CLASS "SignalsHandler"
#include "handles/SignalsHandler.h" #include "handles/SignalsHandler.h"
#include "LibUV.h" #include "DepLibUV.h"
#include "MediaSoupError.h" #include "MediaSoupError.h"
#include "Logger.h" #include "Logger.h"
...@@ -36,7 +36,7 @@ void SignalsHandler::AddSignal(int signum, std::string name) ...@@ -36,7 +36,7 @@ void SignalsHandler::AddSignal(int signum, std::string name)
uv_signal_t* uvHandle = new uv_signal_t; uv_signal_t* uvHandle = new uv_signal_t;
uvHandle->data = (void*)this; uvHandle->data = (void*)this;
err = uv_signal_init(LibUV::GetLoop(), uvHandle); err = uv_signal_init(DepLibUV::GetLoop(), uvHandle);
if (err) if (err)
{ {
delete uvHandle; delete uvHandle;
......
...@@ -2,7 +2,7 @@ ...@@ -2,7 +2,7 @@
#include "handles/TCPConnection.h" #include "handles/TCPConnection.h"
#include "Utils.h" #include "Utils.h"
#include "LibUV.h" #include "DepLibUV.h"
#include "MediaSoupError.h" #include "MediaSoupError.h"
#include "Logger.h" #include "Logger.h"
#include <cstring> // std::memcpy() #include <cstring> // std::memcpy()
...@@ -85,7 +85,7 @@ void TCPConnection::Setup(Listener* listener, const std::string &localIP, MS_POR ...@@ -85,7 +85,7 @@ void TCPConnection::Setup(Listener* listener, const std::string &localIP, MS_POR
int err; int err;
// Set the UV handle. // Set the UV handle.
err = uv_tcp_init(LibUV::GetLoop(), this->uvHandle); err = uv_tcp_init(DepLibUV::GetLoop(), this->uvHandle);
if (err) if (err)
{ {
delete this->uvHandle; delete this->uvHandle;
......
...@@ -2,7 +2,7 @@ ...@@ -2,7 +2,7 @@
#include "handles/TCPServer.h" #include "handles/TCPServer.h"
#include "Utils.h" #include "Utils.h"
#include "LibUV.h" #include "DepLibUV.h"
#include "MediaSoupError.h" #include "MediaSoupError.h"
#include "Logger.h" #include "Logger.h"
...@@ -45,7 +45,7 @@ TCPServer::TCPServer(const std::string &ip, MS_PORT port, int backlog) ...@@ -45,7 +45,7 @@ TCPServer::TCPServer(const std::string &ip, MS_PORT port, int backlog)
this->uvHandle = new uv_tcp_t; this->uvHandle = new uv_tcp_t;
this->uvHandle->data = (void*)this; this->uvHandle->data = (void*)this;
err = uv_tcp_init(LibUV::GetLoop(), this->uvHandle); err = uv_tcp_init(DepLibUV::GetLoop(), this->uvHandle);
if (err) if (err)
{ {
delete this->uvHandle; delete this->uvHandle;
......
...@@ -2,7 +2,7 @@ ...@@ -2,7 +2,7 @@
#include "handles/Timer.h" #include "handles/Timer.h"
#include "MediaSoupError.h" #include "MediaSoupError.h"
#include "LibUV.h" #include "DepLibUV.h"
#include "Logger.h" #include "Logger.h"
/* Static methods for UV callbacks. */ /* Static methods for UV callbacks. */
...@@ -31,7 +31,7 @@ Timer::Timer(Listener* listener) : ...@@ -31,7 +31,7 @@ Timer::Timer(Listener* listener) :
this->uvHandle = new uv_timer_t; this->uvHandle = new uv_timer_t;
uvHandle->data = (void*)this; uvHandle->data = (void*)this;
err = uv_timer_init(LibUV::GetLoop(), this->uvHandle); err = uv_timer_init(DepLibUV::GetLoop(), this->uvHandle);
if (err) if (err)
{ {
delete this->uvHandle; delete this->uvHandle;
......
...@@ -2,7 +2,7 @@ ...@@ -2,7 +2,7 @@
#include "handles/UDPSocket.h" #include "handles/UDPSocket.h"
#include "Utils.h" #include "Utils.h"
#include "LibUV.h" #include "DepLibUV.h"
#include "MediaSoupError.h" #include "MediaSoupError.h"
#include "Logger.h" #include "Logger.h"
...@@ -71,7 +71,7 @@ UDPSocket::UDPSocket(const std::string &ip, MS_PORT port) ...@@ -71,7 +71,7 @@ UDPSocket::UDPSocket(const std::string &ip, MS_PORT port)
this->uvHandle = new uv_udp_t; this->uvHandle = new uv_udp_t;
this->uvHandle->data = (void*)this; this->uvHandle->data = (void*)this;
err = uv_udp_init(LibUV::GetLoop(), this->uvHandle); err = uv_udp_init(DepLibUV::GetLoop(), this->uvHandle);
if (err) if (err)
{ {
delete this->uvHandle; delete this->uvHandle;
......
#define MS_CLASS "UnixStreamSocket" #define MS_CLASS "UnixStreamSocket"
#include "handles/UnixStreamSocket.h" #include "handles/UnixStreamSocket.h"
#include "LibUV.h" #include "DepLibUV.h"
#include "MediaSoupError.h" #include "MediaSoupError.h"
#include "Logger.h" #include "Logger.h"
#include <cstring> // std::memcpy() #include <cstring> // std::memcpy()
...@@ -72,7 +72,7 @@ UnixStreamSocket::UnixStreamSocket(int fd, size_t bufferSize) : ...@@ -72,7 +72,7 @@ UnixStreamSocket::UnixStreamSocket(int fd, size_t bufferSize) :
this->uvHandle = new uv_pipe_t; this->uvHandle = new uv_pipe_t;
this->uvHandle->data = (void*)this; this->uvHandle->data = (void*)this;
err = uv_pipe_init(LibUV::GetLoop(), this->uvHandle, 0); err = uv_pipe_init(DepLibUV::GetLoop(), this->uvHandle, 0);
if (err) if (err)
{ {
delete this->uvHandle; delete this->uvHandle;
......
Markdown 格式
0% 或
您添加了 0 人 到此讨论。请谨慎行事。
请先完成此评论的编辑!
请 注册 或者 后发表评论