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

Remove Syslog stuff.

上级 d899c399
......@@ -5,3 +5,4 @@
/worker/cldoc/
/worker/mediasoup-tester.sh
/TODO
/test.js
......@@ -17,8 +17,8 @@ const WORKER_BIN_PATH = path.join(__dirname, '..', 'worker', 'bin', 'mediasoup-w
const DEFAULT_NUM_WORKERS = Object.keys(os.cpus()).length;
const VALID_PARAMETERS =
[
'logLevel', 'useSyslog', 'syslogFacility', 'rtcListenIPv4', 'rtcListenIPv6',
'rtcMinPort', 'rtcMaxPort', 'dtlsCertificateFile', 'dtlsPrivateKeyFile'
'logLevel', 'rtcListenIPv4', 'rtcListenIPv6', 'rtcMinPort', 'rtcMaxPort',
'dtlsCertificateFile', 'dtlsPrivateKeyFile'
];
var servers = new Set();
......@@ -67,12 +67,19 @@ class Server
// Create mediasoup-worker child processes
for (let i = 1; i <= numWorkers; i++)
{
let workerId = serverId + '#' + i;
let worker;
let workerId = serverId + '#' + i;
let spawnArgs = [ workerId ].concat(parameters);
let spawnOptions =
{
detached : false,
stdio : [ 'pipe', 'pipe', 'pipe', 'ipc' ]
};
debug('constructor() | creating worker [workerId:%s]', workerId);
worker = spawn(WORKER_BIN_PATH, [ workerId ].concat(parameters));
// Create the worker child process
worker = spawn(WORKER_BIN_PATH, spawnArgs, spawnOptions);
// Store worker id within the worker process
worker.workerId = workerId;
......@@ -102,6 +109,8 @@ class Server
worker.on('exit', (code, signal) =>
{
debug('worker process closed [workerId:%s, code:%s, signal:%s]', worker.workerId, code, signal);
this._workers.delete(worker.workerId);
});
worker.on('error', (error) =>
......
......@@ -8,10 +8,6 @@
#include <cstring>
#include <cstdlib> // std::_Exit(), std::abort()
#include <uv.h>
extern "C"
{
#include <syslog.h>
}
/*
* Logger facility.
......@@ -24,10 +20,8 @@ extern "C"
* - MS_TRACE() Shows current file/line/class/function.
* - MS_DEBUG(...)
* - MS_INFO(...)
* - MS_NOTICE(...)
* - MS_WARN(...)
* - MS_ERROR(...)
* - MS_CRIT(...)
* - MS_ABORT(...)
*
* Arguments to those macros (except MS_TRACE) have the same format as printf.
......@@ -45,7 +39,7 @@ extern "C"
/*
* This macro must point to a unsigned int function, method or variable that
* returns the Syslog logging level.
* returns the logging level.
*/
#define MS_GET_LOG_LEVEL Settings::configuration.logLevel
......@@ -55,14 +49,11 @@ public:
static void Init(const std::string id);
static const char* GetProcessName();
static const char* GetProcessMinName();
static void EnableSyslog();
static bool IsSyslogEnabled();
static bool HasDebugLevel();
private:
static std::string processName;
static std::string processMinName;
static bool isSyslogEnabled;
};
/* Inline static methods. */
......@@ -79,16 +70,10 @@ const char* Logger::GetProcessMinName()
return Logger::processMinName.c_str();
}
inline
bool Logger::IsSyslogEnabled()
{
return Logger::isSyslogEnabled;
}
inline
bool Logger::HasDebugLevel()
{
return (LOG_DEBUG == MS_GET_LOG_LEVEL);
return (MS_LOG_LEVEL_DEBUG == MS_GET_LOG_LEVEL);
}
// NOTE: Each file including Logger.h MUST define its own MS_CLASS macro.
......@@ -105,53 +90,22 @@ bool Logger::HasDebugLevel()
#endif
#define _MS_TO_STDOUT() \
if (!Logger::IsSyslogEnabled()) \
{ \
std::fprintf(stdout, _MS_LOG_STR "\n", _MS_LOG_ARG); \
fflush(stdout); \
}
std::fprintf(stdout, _MS_LOG_STR "\n", _MS_LOG_ARG); \
fflush(stdout);
#define _MS_TO_STDOUT_DESC(desc, ...) \
if (!Logger::IsSyslogEnabled()) \
{ \
std::fprintf(stdout, _MS_LOG_STR_DESC desc "\n", _MS_LOG_ARG, ##__VA_ARGS__); \
fflush(stdout); \
}
std::fprintf(stdout, _MS_LOG_STR_DESC desc "\n", _MS_LOG_ARG, ##__VA_ARGS__); \
fflush(stdout); \
#define _MS_TO_STDERR_DESC(desc, ...) \
if (!Logger::IsSyslogEnabled()) \
{ \
std::fprintf(stderr, _MS_LOG_STR_DESC desc "\n", _MS_LOG_ARG, ##__VA_ARGS__); \
fflush(stderr); \
}
#define _MS_TO_SYSLOG(severity, prefix) \
if (Logger::IsSyslogEnabled()) \
syslog(severity, prefix _MS_LOG_STR, _MS_LOG_ARG);
#define _MS_TO_SYSLOG_DESC(severity, prefix, desc, ...) \
if (Logger::IsSyslogEnabled()) \
syslog(severity, prefix _MS_LOG_STR_DESC desc, _MS_LOG_ARG, ##__VA_ARGS__);
/*
* Log levels in syslog.h:
*
* LOG_EMERG 0 system is unusable
* LOG_ALERT 1 action must be taken immediately
* LOG_CRIT 2 critical conditions
* LOG_ERR 3 error conditions
* LOG_WARNING 4 warning conditions
* LOG_NOTICE 5 normal but significant condition
* LOG_INFO 6 informational
* LOG_DEBUG 7 debug-level messages
*/
std::fprintf(stderr, _MS_LOG_STR_DESC desc "\n", _MS_LOG_ARG, ##__VA_ARGS__); \
fflush(stderr); \
#ifdef MS_DEVEL
#define MS_TRACE() \
do \
{ \
_MS_TO_STDOUT(); \
_MS_TO_SYSLOG(LOG_DEBUG, "TRACE "); \
} \
while (0)
#else
......@@ -161,10 +115,9 @@ bool Logger::HasDebugLevel()
#define MS_DEBUG(desc, ...) \
do \
{ \
if (LOG_DEBUG == MS_GET_LOG_LEVEL) \
if (MS_LOG_LEVEL_DEBUG == MS_GET_LOG_LEVEL) \
{ \
_MS_TO_STDOUT_DESC(desc, ##__VA_ARGS__); \
_MS_TO_SYSLOG_DESC(LOG_DEBUG, "DEBUG ", desc, ##__VA_ARGS__); \
} \
} \
while (0)
......@@ -172,21 +125,9 @@ bool Logger::HasDebugLevel()
#define MS_INFO(desc, ...) \
do \
{ \
if (LOG_INFO <= MS_GET_LOG_LEVEL) \
{ \
_MS_TO_STDOUT_DESC(desc, ##__VA_ARGS__); \
_MS_TO_SYSLOG_DESC(LOG_INFO, "INFO ", desc, ##__VA_ARGS__); \
} \
} \
while (0)
#define MS_NOTICE(desc, ...) \
do \
{ \
if (LOG_NOTICE <= MS_GET_LOG_LEVEL) \
if (MS_LOG_LEVEL_INFO <= MS_GET_LOG_LEVEL) \
{ \
_MS_TO_STDOUT_DESC(desc, ##__VA_ARGS__); \
_MS_TO_SYSLOG_DESC(LOG_NOTICE, "NOTICE ", desc, ##__VA_ARGS__); \
} \
} \
while (0)
......@@ -194,10 +135,9 @@ bool Logger::HasDebugLevel()
#define MS_WARN(desc, ...) \
do \
{ \
if (LOG_WARNING <= MS_GET_LOG_LEVEL) \
if (MS_LOG_LEVEL_WARN <= MS_GET_LOG_LEVEL) \
{ \
_MS_TO_STDERR_DESC(desc, ##__VA_ARGS__); \
_MS_TO_SYSLOG_DESC(LOG_WARNING, "WARN ", desc, ##__VA_ARGS__); \
} \
} \
while (0)
......@@ -206,22 +146,13 @@ bool Logger::HasDebugLevel()
do \
{ \
_MS_TO_STDERR_DESC(desc, ##__VA_ARGS__); \
_MS_TO_SYSLOG_DESC(LOG_ERR, "ERROR ", desc, ##__VA_ARGS__); \
} \
while (0)
#define MS_CRIT(desc, ...) \
do \
{ \
_MS_TO_STDERR_DESC(desc, ##__VA_ARGS__); \
_MS_TO_SYSLOG_DESC(LOG_ERR, "CRIT ", desc, ##__VA_ARGS__); \
} \
while (0)
#define MS_EXIT_SUCCESS(desc, ...) \
do \
{ \
MS_NOTICE("SUCCESS EXIT | " desc, ##__VA_ARGS__); \
MS_INFO("SUCCESS EXIT | " desc, ##__VA_ARGS__); \
std::_Exit(EXIT_SUCCESS); \
} \
while (0)
......@@ -229,7 +160,7 @@ bool Logger::HasDebugLevel()
#define MS_EXIT_FAILURE(desc, ...) \
do \
{ \
MS_CRIT("FAILURE EXIT | " desc, ##__VA_ARGS__); \
MS_ERROR("FAILURE EXIT | " desc, ##__VA_ARGS__); \
std::_Exit(EXIT_FAILURE); \
} \
while (0)
......@@ -237,7 +168,7 @@ bool Logger::HasDebugLevel()
#define MS_ABORT(desc, ...) \
do \
{ \
MS_CRIT("ABORT | " desc, ##__VA_ARGS__); \
MS_ERROR("ABORT | " desc, ##__VA_ARGS__); \
std::abort(); \
} \
while (0)
......
#ifndef MS_RTC_DTLS_ROLE_H
#define MS_RTC_DTLS_ROLE_H
namespace RTC {
namespace RTC
{
enum class DTLSRole
{
NONE = 0,
SERVER = 1,
CLIENT
};
} // namespace RTC
}
#endif
......@@ -4,10 +4,6 @@
#include "common.h"
#include <map>
#include <string>
extern "C"
{
#include <syslog.h>
}
class Settings
{
......@@ -15,23 +11,16 @@ public:
// Struct holding the configuration.
struct Configuration
{
unsigned int logLevel { LOG_DEBUG };
bool useSyslog { false };
unsigned int syslogFacility { LOG_USER };
struct
{
std::string listenIPv4;
std::string listenIPv6;
MS_PORT minPort { 10000 };
MS_PORT maxPort { 59999 };
std::string dtlsCertificateFile;
std::string dtlsPrivateKeyFile;
// Private fields.
bool hasIPv4 { false };
bool hasIPv6 { false };
} RTC;
unsigned int logLevel { MS_LOG_LEVEL_DEBUG };
std::string rtcListenIPv4;
std::string rtcListenIPv6;
MS_PORT rtcMinPort { 10000 };
MS_PORT rtcMaxPort { 59999 };
std::string dtlsCertificateFile;
std::string dtlsPrivateKeyFile;
// Private fields.
bool hasIPv4 { false };
bool hasIPv6 { false };
};
public:
......@@ -41,7 +30,6 @@ public:
private:
static void SetDefaultRtcListenIP(int requested_family);
static void SetLogLevel(std::string &level);
static void SetSyslogFacility(std::string &facility);
static void SetRtcListenIPv4(const std::string &ip);
static void SetRtcListenIPv6(const std::string &ip);
static void SetRtcPorts();
......@@ -53,8 +41,6 @@ public:
private:
static std::map<std::string, unsigned int> string2LogLevel;
static std::map<unsigned int, std::string> logLevel2String;
static std::map<std::string, unsigned int> string2SyslogFacility;
static std::map<unsigned int, std::string> syslogFacility2String;
};
#endif
......@@ -7,9 +7,15 @@
#include <netinet/in.h> // sockaddr_in, sockaddr_in6
#include <arpa/inet.h> // htonl(), htons(), ntohl(), ntohs()
#define MS_APP_NAME "mediasoup"
#define MS_PROCESS_NAME "mediasoup-worker"
#define MS_PROCESS_MIN_NAME "worker"
#define MS_LOG_LEVEL_DEBUG 3
#define MS_LOG_LEVEL_INFO 2
#define MS_LOG_LEVEL_WARN 1
#define MS_LOG_LEVEL_ERROR 0
#define MS_BYTE uint8_t
#define MS_2BYTES uint16_t
#define MS_4BYTES uint32_t
......
......@@ -57,5 +57,5 @@ void DepLibSRTP::ClassDestroy()
err = srtp_shutdown();
if (DepLibSRTP::IsError(err))
MS_CRIT("srtp_shutdown() failed: %s", DepLibSRTP::GetErrorString(err));
MS_ERROR("srtp_shutdown() failed: %s", DepLibSRTP::GetErrorString(err));
}
......@@ -25,5 +25,5 @@ void DepUsrSCTP::ClassDestroy()
// Free usrsctp.
err = usrsctp_finish();
if (err)
MS_CRIT("usrsctp_finish() failed");
MS_ERROR("usrsctp_finish() failed");
}
......@@ -6,7 +6,6 @@
std::string Logger::processName;
std::string Logger::processMinName;
bool Logger::isSyslogEnabled = false;
/* Static methods. */
......@@ -17,14 +16,3 @@ void Logger::Init(const std::string id)
MS_TRACE();
}
void Logger::EnableSyslog()
{
MS_TRACE();
MS_DEBUG("logging to Syslog");
openlog(MS_PROCESS_NAME, (LOG_PID), Settings::configuration.syslogFacility);
Logger::isSyslogEnabled = true;
}
......@@ -62,17 +62,17 @@ void Loop::onSignal(SignalsHandler* signalsHandler, int signum)
switch (signum)
{
case SIGINT:
MS_NOTICE("signal INT received, exiting");
MS_DEBUG("signal INT received, exiting");
Close();
break;
case SIGTERM:
MS_NOTICE("signal TERM received, exiting");
MS_DEBUG("signal TERM received, exiting");
Close();
break;
default:
MS_ERROR("received a signal (with signum %d) for which there is no handling code", signum);
MS_WARN("received a signal (with signum %d) for which there is no handling code", signum);
}
}
......
......@@ -84,7 +84,7 @@ namespace RTC
MS_TRACE();
// Generate a X509 certificate and private key (unless PEM files are provided).
if (Settings::configuration.RTC.dtlsCertificateFile.empty() || Settings::configuration.RTC.dtlsPrivateKeyFile.empty())
if (Settings::configuration.dtlsCertificateFile.empty() || Settings::configuration.dtlsPrivateKeyFile.empty())
GenerateCertificateAndPrivateKey();
else
ReadCertificateAndPrivateKeyFromFiles();
......@@ -207,8 +207,8 @@ namespace RTC
LOG_OPENSSL_ERROR("X509_get_subject_name() failed");
goto error;
}
X509_NAME_add_entry_by_txt(cert_name, "O", MBSTRING_ASC, (unsigned char *)MS_PROCESS_NAME, -1, -1, 0);
X509_NAME_add_entry_by_txt(cert_name, "CN", MBSTRING_ASC, (unsigned char *)MS_PROCESS_NAME, -1, -1, 0);
X509_NAME_add_entry_by_txt(cert_name, "O", MBSTRING_ASC, (unsigned char *)MS_APP_NAME, -1, -1, 0);
X509_NAME_add_entry_by_txt(cert_name, "CN", MBSTRING_ASC, (unsigned char *)MS_APP_NAME, -1, -1, 0);
// It is self signed so set the issuer name to be the same as the subject.
ret = X509_set_issuer_name(DTLSHandler::certificate, cert_name);
......@@ -249,7 +249,7 @@ namespace RTC
FILE* file = nullptr;
file = fopen(Settings::configuration.RTC.dtlsCertificateFile.c_str(), "r");
file = fopen(Settings::configuration.dtlsCertificateFile.c_str(), "r");
if (!file)
{
MS_ERROR("error reading DTLS certificate file: %s", std::strerror(errno));
......@@ -263,7 +263,7 @@ namespace RTC
}
fclose(file);
file = fopen(Settings::configuration.RTC.dtlsPrivateKeyFile.c_str(), "r");
file = fopen(Settings::configuration.dtlsPrivateKeyFile.c_str(), "r");
if (!file)
{
MS_ERROR("error reading DTLS private key file: %s", std::strerror(errno));
......@@ -694,7 +694,7 @@ namespace RTC
{
if (!this->isConnected)
{
MS_NOTICE("ignoring application data received while DTLS not fully connected");
MS_DEBUG("ignoring application data received while DTLS not fully connected");
return;
}
......@@ -760,33 +760,28 @@ namespace RTC
switch (err)
{
case SSL_ERROR_NONE:
// MS_DEBUG("SSL status: SSL_ERROR_NONE");
break;
case SSL_ERROR_SSL:
// MS_NOTICE("SSL status: SSL_ERROR_SSL");
LOG_OPENSSL_ERROR("SSL status: SSL_ERROR_SSL");
break;
case SSL_ERROR_WANT_READ:
// MS_DEBUG("SSL status: SSL_ERROR_WANT_READ");
break;
case SSL_ERROR_WANT_WRITE:
MS_DEBUG("SSL status: SSL_ERROR_WANT_WRITE");
break;
case SSL_ERROR_WANT_X509_LOOKUP:
MS_NOTICE("SSL status: SSL_ERROR_WANT_X509_LOOKUP");
MS_DEBUG("SSL status: SSL_ERROR_WANT_X509_LOOKUP");
break;
case SSL_ERROR_SYSCALL:
// MS_WARN("SSL status: SSL_ERROR_SYSCALL");
LOG_OPENSSL_ERROR("SSL status: SSL_ERROR_SYSCALL");
break;
case SSL_ERROR_ZERO_RETURN:
// MS_DEBUG("SSL status: SSL_ERROR_ZERO_RETURN");
break;
case SSL_ERROR_WANT_CONNECT:
MS_WARN("SSL status: SSL_ERROR_WANT_CONNECT");
MS_DEBUG("SSL status: SSL_ERROR_WANT_CONNECT");
break;
case SSL_ERROR_WANT_ACCEPT:
MS_WARN("SSL status: SSL_ERROR_WANT_ACCEPT");
MS_DEBUG("SSL status: SSL_ERROR_WANT_ACCEPT");
break;
}
......@@ -822,7 +817,7 @@ namespace RTC
}
else
{
MS_NOTICE("DTLS connection failed");
MS_DEBUG("DTLS connection failed");
// Notify to the listener.
this->listener->onDTLSFailed(this);
......@@ -949,7 +944,7 @@ namespace RTC
}
else
{
MS_NOTICE("SRTP profile not negotiated");
MS_DEBUG("SRTP profile not negotiated");
}
}
......@@ -1021,7 +1016,7 @@ namespace RTC
if (this->remoteFingerprint.compare(hex_fingerprint) != 0)
{
MS_NOTICE("fingerprint in the remote certificate (%s) does not match the announced one (%s)", hex_fingerprint, this->remoteFingerprint.c_str());
MS_DEBUG("fingerprint in the remote certificate (%s) does not match the announced one (%s)", hex_fingerprint, this->remoteFingerprint.c_str());
return false;
}
......@@ -1145,7 +1140,7 @@ namespace RTC
else if (where & SSL_CB_EXIT)
{
if (ret == 0)
MS_NOTICE("role: %s | failed in: %s", role, SSL_state_string_long(this->ssl));
MS_DEBUG("role: %s | failed in: %s", role, SSL_state_string_long(this->ssl));
else if (ret < 0)
MS_DEBUG("role: %s | waiting for: %s", role, SSL_state_string_long(this->ssl));
}
......
......@@ -126,7 +126,7 @@ namespace RTC
// The remote peer must be ICE controlling.
if (msg->GetIceControlled())
{
MS_NOTICE("peer indicates ICE-CONTROLLED in STUN Binding Request => 487");
MS_DEBUG("peer indicates ICE-CONTROLLED in STUN Binding Request => 487");
// Reply 487 (Role Conflict).
RTC::STUNMessage* response = msg->CreateErrorResponse(487);
......
......@@ -36,7 +36,7 @@ namespace RTC
{
RTC::UDPSocket* socket = RTC::UDPSocket::New(AF_INET);
this->transport->AddUDPSocket(socket);
MS_NOTICE("---- TEST: transport listens in IPv4 UDP '%s' : %u", socket->GetLocalIP().c_str(), socket->GetLocalPort());
MS_INFO("---- TEST: transport listens in IPv4 UDP '%s' : %u", socket->GetLocalIP().c_str(), socket->GetLocalPort());
}
catch (const MediaSoupError &error)
{
......@@ -47,7 +47,7 @@ namespace RTC
{
RTC::TCPServer* server = RTC::TCPServer::New(AF_INET);
this->transport->AddTCPServer(server);
MS_NOTICE("---- TEST: transport listens in IPv4 TCP '%s' : %u", server->GetLocalIP().c_str(), server->GetLocalPort());
MS_INFO("---- TEST: transport listens in IPv4 TCP '%s' : %u", server->GetLocalIP().c_str(), server->GetLocalPort());
}
catch (const MediaSoupError &error)
{
......@@ -112,4 +112,4 @@ namespace RTC
this->listener->onRTCPPacket(this, packet);
}
} // namespace RTC
}
......@@ -51,7 +51,7 @@ namespace RTC
break;
}
MS_NOTICE("SSRC %llu: %s", (unsigned long long)data->stream->ssrc, event_desc);
MS_WARN("SSRC %llu: %s", (unsigned long long)data->stream->ssrc, event_desc);
}
/* Instance methods. */
......
......@@ -41,22 +41,22 @@ namespace RTC
int err;
if (!Settings::configuration.RTC.listenIPv4.empty())
if (!Settings::configuration.rtcListenIPv4.empty())
{
err = uv_ip4_addr(Settings::configuration.RTC.listenIPv4.c_str(), 0, (struct sockaddr_in*)&RTC::TCPServer::sockaddrStorageIPv4);
err = uv_ip4_addr(Settings::configuration.rtcListenIPv4.c_str(), 0, (struct sockaddr_in*)&RTC::TCPServer::sockaddrStorageIPv4);
if (err)
MS_ABORT("uv_ipv4_addr() failed: %s", uv_strerror(err));
}
if (!Settings::configuration.RTC.listenIPv6.empty())
if (!Settings::configuration.rtcListenIPv6.empty())
{
err = uv_ip6_addr(Settings::configuration.RTC.listenIPv6.c_str(), 0, (struct sockaddr_in6*)&RTC::TCPServer::sockaddrStorageIPv6);
err = uv_ip6_addr(Settings::configuration.rtcListenIPv6.c_str(), 0, (struct sockaddr_in6*)&RTC::TCPServer::sockaddrStorageIPv6);
if (err)
MS_ABORT("uv_ipv6_addr() failed: %s", uv_strerror(err));
}
TCPServer::minPort = Settings::configuration.RTC.minPort;
TCPServer::maxPort = Settings::configuration.RTC.maxPort;
TCPServer::minPort = Settings::configuration.rtcMinPort;
TCPServer::maxPort = Settings::configuration.rtcMaxPort;
MS_PORT i = RTC::TCPServer::minPort;
do
......@@ -98,9 +98,9 @@ namespace RTC
{
MS_TRACE();
if (address_family == AF_INET && !Settings::configuration.RTC.hasIPv4)
if (address_family == AF_INET && !Settings::configuration.hasIPv4)
MS_THROW_ERROR("IPv4 family not available for RTC");
else if (address_family == AF_INET6 && !Settings::configuration.RTC.hasIPv6)
else if (address_family == AF_INET6 && !Settings::configuration.hasIPv6)
MS_THROW_ERROR("IPv6 family not available for RTC");
int err;
......@@ -121,14 +121,14 @@ namespace RTC
available_ports = &RTC::TCPServer::availableIPv4Ports;
first_bind_addr = RTC::TCPServer::sockaddrStorageIPv4;
second_bind_addr = RTC::TCPServer::sockaddrStorageIPv4;
listenIP = Settings::configuration.RTC.listenIPv4.c_str();
listenIP = Settings::configuration.rtcListenIPv4.c_str();
break;
case AF_INET6:
available_ports = &RTC::TCPServer::availableIPv6Ports;
first_bind_addr = RTC::TCPServer::sockaddrStorageIPv6;
second_bind_addr = RTC::TCPServer::sockaddrStorageIPv6;
listenIP = Settings::configuration.RTC.listenIPv6.c_str();
listenIP = Settings::configuration.rtcListenIPv6.c_str();
// Don't also bind into IPv4 when listening in IPv6.
flags |= UV_TCP_IPV6ONLY;
break;
......
......@@ -427,7 +427,7 @@ namespace RTC
RTC::RTPPacket* packet = RTC::RTPPacket::Parse(data, len);
if (!packet)
{
MS_NOTICE("data received via %s is not a valid RTP packet", TRANSPORT_NAME(source));
MS_DEBUG("data received via %s is not a valid RTP packet", TRANSPORT_NAME(source));
return;
}
// MS_DEBUG("valid RTP packet received via %s [ssrc: %llu | payload: %hu | size: %zu]",
......@@ -460,7 +460,7 @@ namespace RTC
if (!this->srtpRecvSession->DecryptSRTCP(data, &len))
{
MS_WARN("error decrypting SRTCP packet received via %s: %s", TRANSPORT_NAME(source), this->srtpRecvSession->GetLastErrorDesc());
MS_DEBUG("error decrypting SRTCP packet received via %s: %s", TRANSPORT_NAME(source), this->srtpRecvSession->GetLastErrorDesc());
return;
}
}
......@@ -468,7 +468,7 @@ namespace RTC
RTC::RTCPPacket* packet = RTC::RTCPPacket::Parse(data, len);
if (!packet)
{
MS_NOTICE("data received via %s is not a valid RTCP packet", TRANSPORT_NAME(source));
MS_DEBUG("data received via %s is not a valid RTCP packet", TRANSPORT_NAME(source));
return;
}
// MS_DEBUG("valid RTCP packet received via %s", TRANSPORT_NAME(source));
......@@ -598,7 +598,7 @@ namespace RTC
if (!this->sendingSource)
{
MS_ERROR("no sending address set, cannot send DTLS packet");
MS_WARN("no sending address set, cannot send DTLS packet");
return;
}
......@@ -630,7 +630,7 @@ namespace RTC
{
MS_TRACE();
MS_NOTICE("DTLS failed");
MS_DEBUG("DTLS failed");
Reset();
Dump();
......
......@@ -41,22 +41,22 @@ namespace RTC
int err;
if (Settings::configuration.RTC.hasIPv4)
if (Settings::configuration.hasIPv4)
{
err = uv_ip4_addr(Settings::configuration.RTC.listenIPv4.c_str(), 0, (struct sockaddr_in*)&RTC::UDPSocket::sockaddrStorageIPv4);
err = uv_ip4_addr(Settings::configuration.rtcListenIPv4.c_str(), 0, (struct sockaddr_in*)&RTC::UDPSocket::sockaddrStorageIPv4);
if (err)
MS_ABORT("uv_ipv4_addr() failed: %s", uv_strerror(err));
}
if (Settings::configuration.RTC.hasIPv6)
if (Settings::configuration.hasIPv6)
{
err = uv_ip6_addr(Settings::configuration.RTC.listenIPv6.c_str(), 0, (struct sockaddr_in6*)&RTC::UDPSocket::sockaddrStorageIPv6);
err = uv_ip6_addr(Settings::configuration.rtcListenIPv6.c_str(), 0, (struct sockaddr_in6*)&RTC::UDPSocket::sockaddrStorageIPv6);
if (err)
MS_ABORT("uv_ipv6_addr() failed: %s", uv_strerror(err));
}
UDPSocket::minPort = Settings::configuration.RTC.minPort;
UDPSocket::maxPort = Settings::configuration.RTC.maxPort;
UDPSocket::minPort = Settings::configuration.rtcMinPort;
UDPSocket::maxPort = Settings::configuration.rtcMaxPort;
MS_PORT i = RTC::UDPSocket::minPort;
do
......@@ -98,9 +98,9 @@ namespace RTC
{
MS_TRACE();
if (address_family == AF_INET && !Settings::configuration.RTC.hasIPv4)
if (address_family == AF_INET && !Settings::configuration.hasIPv4)
MS_THROW_ERROR("IPv4 family not available for RTC");
else if (address_family == AF_INET6 && !Settings::configuration.RTC.hasIPv6)
else if (address_family == AF_INET6 && !Settings::configuration.hasIPv6)
MS_THROW_ERROR("IPv6 family not available for RTC");
int err;
......@@ -121,14 +121,14 @@ namespace RTC
available_ports = &RTC::UDPSocket::availableIPv4Ports;
first_bind_addr = RTC::UDPSocket::sockaddrStorageIPv4;
second_bind_addr = RTC::UDPSocket::sockaddrStorageIPv4;
listenIP = Settings::configuration.RTC.listenIPv4.c_str();
listenIP = Settings::configuration.rtcListenIPv4.c_str();
break;
case AF_INET6:
available_ports = &RTC::UDPSocket::availableIPv6Ports;
first_bind_addr = RTC::UDPSocket::sockaddrStorageIPv6;
second_bind_addr = RTC::UDPSocket::sockaddrStorageIPv6;
listenIP = Settings::configuration.RTC.listenIPv6.c_str();
listenIP = Settings::configuration.rtcListenIPv6.c_str();
// Don't also bind into IPv4 when listening in IPv6.
flags |= UV_UDP_IPV6ONLY;
break;
......
差异被折叠。
......@@ -154,7 +154,7 @@ void TCPConnection::Write(const MS_BYTE* data, size_t len)
// Error. Should not happen.
else if (written < 0)
{
MS_NOTICE("uv_try_write() failed: %s | closing the connection", uv_strerror(written));
MS_WARN("uv_try_write() failed: %s | closing the connection", uv_strerror(written));
Close();
return;
}
......@@ -216,7 +216,7 @@ void TCPConnection::Write(const MS_BYTE* data1, size_t len1, const MS_BYTE* data
// Error. Should not happen.
else if (written < 0)
{
MS_NOTICE("uv_try_write() failed: %s | closing the connection", uv_strerror(written));
MS_WARN("uv_try_write() failed: %s | closing the connection", uv_strerror(written));
Close();
return;
}
......@@ -366,7 +366,7 @@ void TCPConnection::onUvRead(ssize_t nread, const uv_buf_t* buf)
// Some error.
else
{
MS_NOTICE("read error: %s | closing the connection", uv_strerror(nread));
MS_INFO("read error: %s | closing the connection", uv_strerror(nread));
this->hasError = true;
// Close server side of the connection.
......@@ -389,7 +389,7 @@ void TCPConnection::onUvWriteError(int error)
}
else
{
MS_NOTICE("write error: %s | closing the connection", uv_strerror(error));
MS_INFO("write error: %s | closing the connection", uv_strerror(error));
this->hasError = true;
}
......@@ -406,7 +406,7 @@ void TCPConnection::onUvShutdown(uv_shutdown_t* req, int status)
if (status == UV_EPIPE || status == UV_ENOTCONN || status == UV_ECANCELED)
MS_DEBUG("shutdown error: %s", uv_strerror(status));
else if (status)
MS_NOTICE("shutdown error: %s", uv_strerror(status));
MS_INFO("shutdown error: %s", uv_strerror(status));
// Now do close the handle.
uv_close((uv_handle_t*)this->uvHandle, (uv_close_cb)on_close);
......
......@@ -192,7 +192,7 @@ void UDPSocket::Send(const MS_BYTE* data, size_t len, const struct sockaddr* add
// Error,
else if (sent != UV_EAGAIN)
{
MS_ERROR("uv_udp_try_send() failed: %s", uv_strerror(sent));
MS_WARN("uv_udp_try_send() failed: %s", uv_strerror(sent));
return;
}
// Otherwise UV_EAGAIN was returned so cannot send data at first time. Use uv_udp_send().
......@@ -214,7 +214,7 @@ void UDPSocket::Send(const MS_BYTE* data, size_t len, const struct sockaddr* add
{
// NOTE: uv_udp_send() returns error if a wrong INET family is given
// (IPv6 destination on a IPv4 binded socket), so be ready.
MS_ERROR("uv_udp_send() failed: %s", uv_strerror(err));
MS_WARN("uv_udp_send() failed: %s", uv_strerror(err));
// Delete the UvSendData struct (which includes the uv_req_t and the store char[]).
std::free(send_data);
......@@ -344,7 +344,7 @@ void UDPSocket::onUvRecv(ssize_t nread, const uv_buf_t* buf, const struct sockad
// Some error.
else
{
MS_NOTICE("read error: %s", uv_strerror(nread));
MS_INFO("read error: %s", uv_strerror(nread));
}
}
......@@ -356,7 +356,7 @@ void UDPSocket::onUvSendError(int error)
if (this->isClosing)
return;
MS_NOTICE("send error: %s", uv_strerror(error));
MS_INFO("send error: %s", uv_strerror(error));
}
inline
......
......@@ -144,7 +144,7 @@ void UnixStreamSocket::Write(const MS_BYTE* data, size_t len)
// Error. Should not happen.
else if (written < 0)
{
MS_NOTICE("uv_try_write() failed: %s | closing the connection", uv_strerror(written));
MS_WARN("uv_try_write() failed: %s | closing the connection", uv_strerror(written));
Close();
return;
}
......@@ -257,7 +257,7 @@ void UnixStreamSocket::onUvRead(ssize_t nread, const uv_buf_t* buf)
// Some error.
else
{
MS_NOTICE("read error: %s | closing the pipe", uv_strerror(nread));
MS_INFO("read error: %s | closing the pipe", uv_strerror(nread));
this->hasError = true;
// Close the socket.
......@@ -280,7 +280,7 @@ void UnixStreamSocket::onUvWriteError(int error)
}
else
{
MS_NOTICE("write error: %s | closing the pipe", uv_strerror(error));
MS_INFO("write error: %s | closing the pipe", uv_strerror(error));
this->hasError = true;
}
......@@ -297,7 +297,7 @@ void UnixStreamSocket::onUvShutdown(uv_shutdown_t* req, int status)
if (status == UV_EPIPE || status == UV_ENOTCONN || status == UV_ECANCELED)
MS_DEBUG("shutdown error: %s", uv_strerror(status));
else if (status)
MS_NOTICE("shutdown error: %s", uv_strerror(status));
MS_INFO("shutdown error: %s", uv_strerror(status));
// Now do close the handle.
uv_close((uv_handle_t*)this->uvHandle, (uv_close_cb)on_close);
......
......@@ -24,8 +24,14 @@ static void init();
static void ignoreSignals();
static void destroy();
int main(int argc, char* argv[])
int main(int argc, char* argv[], char** envp)
{
char** env;
for (env = envp; *env != 0; env++)
{
// printf("%s\n", *env);
}
std::string id;
if (argc == 1)
......
Markdown 格式
0% 或
您添加了 0 人 到此讨论。请谨慎行事。
请先完成此评论的编辑!
请 注册 或者 后发表评论