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

Cleanup and optimize JSON usage.

上级 9bc4d37a
...@@ -38,7 +38,10 @@ class Peer extends EventEmitter ...@@ -38,7 +38,10 @@ class Peer extends EventEmitter
*/ */
close(error, dontSendChannel) close(error, dontSendChannel)
{ {
logger.debug('close() [error:%s]', error); if (!error)
logger.debug('close()');
else
logger.error('close() [error:%s]', error);
if (this._closed) if (this._closed)
return; return;
......
...@@ -35,7 +35,10 @@ class Room extends EventEmitter ...@@ -35,7 +35,10 @@ class Room extends EventEmitter
*/ */
close(error, dontSendChannel) close(error, dontSendChannel)
{ {
logger.debug('close() [error:%s]', error); if (!error)
logger.debug('close()');
else
logger.error('close() [error:%s]', error);
if (this._closed) if (this._closed)
return; return;
......
...@@ -114,7 +114,10 @@ class Server extends EventEmitter ...@@ -114,7 +114,10 @@ class Server extends EventEmitter
*/ */
close(error) close(error)
{ {
logger.debug('close() [error:%s]', error); if (!error)
logger.debug('close()');
else
logger.error('close() [error:%s]', error);
if (this._closed) if (this._closed)
return; return;
......
...@@ -40,7 +40,10 @@ class Transport extends EventEmitter ...@@ -40,7 +40,10 @@ class Transport extends EventEmitter
*/ */
close(error, dontSendChannel) close(error, dontSendChannel)
{ {
logger.debug('close() [error:%s]', error); if (!error)
logger.debug('close()');
else
logger.error('close() [error:%s]', error);
if (this._closed) if (this._closed)
return; return;
......
...@@ -88,7 +88,10 @@ class Worker extends EventEmitter ...@@ -88,7 +88,10 @@ class Worker extends EventEmitter
close(error) close(error)
{ {
logger.debug('close() [error:%s]', error); if (!error)
logger.debug('close()');
else
logger.error('close() [error:%s]', error);
// Close every Room // Close every Room
this._rooms.forEach((room) => room.close(undefined, true)); this._rooms.forEach((room) => room.close(undefined, true));
......
...@@ -8,6 +8,7 @@ class DepLibUV ...@@ -8,6 +8,7 @@ class DepLibUV
public: public:
static void ClassInit(); static void ClassInit();
static void ClassDestroy(); static void ClassDestroy();
static void PrintVersion();
static void RunLoop(); static void RunLoop();
static uv_loop_t* GetLoop(); static uv_loop_t* GetLoop();
......
...@@ -10,7 +10,8 @@ ...@@ -10,7 +10,8 @@
class Loop : class Loop :
public SignalsHandler::Listener, public SignalsHandler::Listener,
public Channel::UnixStreamSocket::Listener public Channel::UnixStreamSocket::Listener,
public RTC::Room::Listener
{ {
public: public:
Loop(Channel::UnixStreamSocket* channel); Loop(Channel::UnixStreamSocket* channel);
...@@ -30,6 +31,10 @@ public: ...@@ -30,6 +31,10 @@ public:
virtual void onChannelRequest(Channel::UnixStreamSocket* channel, Channel::Request* request) override; virtual void onChannelRequest(Channel::UnixStreamSocket* channel, Channel::Request* request) override;
virtual void onChannelUnixStreamSocketRemotelyClosed(Channel::UnixStreamSocket* channel) override; virtual void onChannelUnixStreamSocketRemotelyClosed(Channel::UnixStreamSocket* channel) override;
/* Methods inherited from RTC::Room::Listener. */
public:
virtual void onRoomClosed(RTC::Room* room) override;
private: private:
// Passed by argument. // Passed by argument.
Channel::UnixStreamSocket* channel = nullptr; Channel::UnixStreamSocket* channel = nullptr;
......
...@@ -32,7 +32,7 @@ namespace RTC ...@@ -32,7 +32,7 @@ namespace RTC
/* Pure virtual methods inherited from RTC::Transport::Listener. */ /* Pure virtual methods inherited from RTC::Transport::Listener. */
public: public:
// TODO virtual void onTransportClosed(RTC::Transport* transport) override;
public: public:
// Passed by argument. // Passed by argument.
......
...@@ -9,10 +9,18 @@ ...@@ -9,10 +9,18 @@
namespace RTC namespace RTC
{ {
class Room : public RTC::Peer::Listener class Room :
public RTC::Peer::Listener
{ {
public: public:
Room(unsigned int roomId, Json::Value& data); class Listener
{
public:
virtual void onRoomClosed(RTC::Room* room) = 0;
};
public:
Room(Listener* listener, unsigned int roomId, Json::Value& data);
virtual ~Room(); virtual ~Room();
void Close(); void Close();
...@@ -31,6 +39,8 @@ namespace RTC ...@@ -31,6 +39,8 @@ namespace RTC
unsigned int roomId; unsigned int roomId;
private: private:
// Passed by argument.
Listener* listener = nullptr;
// Others. // Others.
typedef std::unordered_map<std::string, RTC::Peer*> Peers; typedef std::unordered_map<std::string, RTC::Peer*> Peers;
Peers peers; Peers peers;
......
...@@ -25,7 +25,7 @@ namespace RTC ...@@ -25,7 +25,7 @@ namespace RTC
class Listener class Listener
{ {
public: public:
// TODO virtual void onTransportClosed(RTC::Transport* transport) = 0;
}; };
public: public:
...@@ -35,18 +35,12 @@ namespace RTC ...@@ -35,18 +35,12 @@ namespace RTC
RTCP = 2 RTCP = 2
}; };
public:
typedef struct IceParameters
{
std::string usernameFragment;
std::string password;
} IceParameters;
public: public:
Transport(Listener* listener, unsigned int transportId, Json::Value& data, Transport* rtpTransport = nullptr); Transport(Listener* listener, unsigned int transportId, Json::Value& data, Transport* rtpTransport = nullptr);
virtual ~Transport(); virtual ~Transport();
void Close(); void Close();
Json::Value Dump();
Json::Value toJson(); Json::Value toJson();
std::string& GetIceUsernameFragment(); std::string& GetIceUsernameFragment();
std::string& GetIcePassword(); std::string& GetIcePassword();
...@@ -88,17 +82,19 @@ namespace RTC ...@@ -88,17 +82,19 @@ namespace RTC
bool hasIPv4tcp = false; bool hasIPv4tcp = false;
bool hasIPv6tcp = false; bool hasIPv6tcp = false;
public:
// Passed by argument.
unsigned int transportId;
private: private:
// Passed by argument. // Passed by argument.
Listener* listener = nullptr; Listener* listener = nullptr;
unsigned int transportId;
RTC::Transport::IceComponent iceComponent; RTC::Transport::IceComponent iceComponent;
// Allocated by this. // Allocated by this.
RTC::IceServer* iceServer = nullptr; RTC::IceServer* iceServer = nullptr;
std::vector<RTC::UDPSocket*> udpSockets; std::vector<RTC::UDPSocket*> udpSockets;
std::vector<RTC::TCPServer*> tcpServers; std::vector<RTC::TCPServer*> tcpServers;
// Others. // Others.
IceParameters iceLocalParameters;
std::vector<IceCandidate> iceLocalCandidates; std::vector<IceCandidate> iceLocalCandidates;
bool allocated = false; bool allocated = false;
}; };
......
...@@ -32,17 +32,21 @@ namespace Channel ...@@ -32,17 +32,21 @@ namespace Channel
{ {
MS_TRACE(); MS_TRACE();
if (json["id"].isUInt()) static const Json::StaticString k_id("id");
this->id = json["id"].asUInt(); static const Json::StaticString k_method("method");
static const Json::StaticString k_data("data");
if (json[k_id].isUInt())
this->id = json[k_id].asUInt();
else else
MS_THROW_ERROR("json has no numeric .id field"); MS_THROW_ERROR("json has no numeric .id field");
if (json["method"].isString()) if (json[k_method].isString())
this->method = json["method"].asString(); this->method = json[k_method].asString();
else else
MS_THROW_ERROR("json has no string .method field"); MS_THROW_ERROR("json has no string .method field");
auto it = Request::string2MethodId.find(method); auto it = Request::string2MethodId.find(this->method);
if (it != Request::string2MethodId.end()) if (it != Request::string2MethodId.end())
{ {
...@@ -52,11 +56,11 @@ namespace Channel ...@@ -52,11 +56,11 @@ namespace Channel
{ {
Reject(405, "method not allowed"); Reject(405, "method not allowed");
MS_THROW_ERROR("unknown .method '%s'", method.c_str()); MS_THROW_ERROR("unknown .method '%s'", this->method.c_str());
} }
if (json["data"].isObject()) if (json[k_data].isObject())
this->data = json["data"]; this->data = json[k_data];
else else
this->data = Json::Value(Json::objectValue); this->data = Json::Value(Json::objectValue);
} }
...@@ -80,15 +84,19 @@ namespace Channel ...@@ -80,15 +84,19 @@ namespace Channel
MS_ASSERT(!this->replied, "Request already replied"); MS_ASSERT(!this->replied, "Request already replied");
this->replied = true; this->replied = true;
static const Json::StaticString k_id("id");
static const Json::StaticString k_status("status");
static const Json::StaticString k_data("data");
Json::Value json; Json::Value json;
json["id"] = this->id; json[k_id] = this->id;
json["status"] = 200; json[k_status] = 200;
if (data.isObject()) if (data.isObject())
json["data"] = data; json[k_data] = data;
else else
json["data"] = empty_data; json[k_data] = empty_data;
this->channel->Send(json); this->channel->Send(json);
} }
...@@ -114,13 +122,17 @@ namespace Channel ...@@ -114,13 +122,17 @@ namespace Channel
MS_ASSERT(status >= 400 && status <= 599, "status must be between 400 and 500"); MS_ASSERT(status >= 400 && status <= 599, "status must be between 400 and 500");
static const Json::StaticString k_id("id");
static const Json::StaticString k_status("status");
static const Json::StaticString k_reason("reason");
Json::Value json; Json::Value json;
json["id"] = this->id; json[k_id] = this->id;
json["status"] = status; json[k_status] = status;
if (reason) if (reason)
json["reason"] = reason; json[k_reason] = reason;
this->channel->Send(json); this->channel->Send(json);
} }
......
...@@ -34,6 +34,13 @@ void DepLibUV::ClassDestroy() ...@@ -34,6 +34,13 @@ void DepLibUV::ClassDestroy()
delete DepLibUV::loop; delete DepLibUV::loop;
} }
void DepLibUV::PrintVersion()
{
MS_TRACE();
MS_DEBUG("loaded libuv version: %s", uv_version_string());
}
void DepLibUV::RunLoop() void DepLibUV::RunLoop()
{ {
MS_TRACE(); MS_TRACE();
......
...@@ -43,7 +43,9 @@ RTC::Room* Loop::GetRoomFromRequest(Channel::Request* request, unsigned int* roo ...@@ -43,7 +43,9 @@ RTC::Room* Loop::GetRoomFromRequest(Channel::Request* request, unsigned int* roo
{ {
MS_TRACE(); MS_TRACE();
auto jsonRoomId = request->data["roomId"]; static const Json::StaticString k_roomId("roomId");
auto jsonRoomId = request->data[k_roomId];
if (!jsonRoomId.isUInt()) if (!jsonRoomId.isUInt())
MS_THROW_ERROR("Request has not numeric .roomId field"); MS_THROW_ERROR("Request has not numeric .roomId field");
...@@ -92,10 +94,14 @@ void Loop::Close() ...@@ -92,10 +94,14 @@ void Loop::Close()
this->signalsHandler->Close(); this->signalsHandler->Close();
// Close all the Rooms. // Close all the Rooms.
for (auto& kv : this->rooms) // NOTE: Upon Room closure the onRoomClosed() method is called which
// removes it from the map, so this is the safe way to iterate the mao
// and remove elements.
for (auto it = this->rooms.begin(); it != this->rooms.end();)
{ {
RTC::Room* room = kv.second; RTC::Room* room = it->second;
it = this->rooms.erase(it);
room->Close(); room->Close();
} }
...@@ -142,19 +148,20 @@ void Loop::onChannelRequest(Channel::UnixStreamSocket* channel, Channel::Request ...@@ -142,19 +148,20 @@ void Loop::onChannelRequest(Channel::UnixStreamSocket* channel, Channel::Request
{ {
case Channel::Request::MethodId::dumpWorker: case Channel::Request::MethodId::dumpWorker:
{ {
static const Json::StaticString k_rooms("rooms");
Json::Value json(Json::objectValue); Json::Value json(Json::objectValue);
Json::Value jsonWorker(Json::objectValue); Json::Value json_worker(Json::objectValue);
Json::Value jsonRooms(Json::objectValue); Json::Value json_rooms(Json::objectValue);
for (auto& kv : this->rooms) for (auto& kv : this->rooms)
{ {
auto room = kv.second; auto room = kv.second;
jsonRooms[std::to_string(room->roomId)] = room->Dump(); json_rooms[std::to_string(room->roomId)] = room->Dump();
} }
json_worker[k_rooms] = json_rooms;
jsonWorker["rooms"] = jsonRooms; json[Logger::id] = json_worker;
json[Logger::id] = jsonWorker;
request->Accept(json); request->Accept(json);
...@@ -192,7 +199,7 @@ void Loop::onChannelRequest(Channel::UnixStreamSocket* channel, Channel::Request ...@@ -192,7 +199,7 @@ void Loop::onChannelRequest(Channel::UnixStreamSocket* channel, Channel::Request
try try
{ {
room = new RTC::Room(roomId, request->data); room = new RTC::Room(this, roomId, request->data);
} }
catch (const MediaSoupError &error) catch (const MediaSoupError &error)
{ {
...@@ -233,9 +240,6 @@ void Loop::onChannelRequest(Channel::UnixStreamSocket* channel, Channel::Request ...@@ -233,9 +240,6 @@ void Loop::onChannelRequest(Channel::UnixStreamSocket* channel, Channel::Request
room->Close(); room->Close();
// TODO: Instead of this, the Room should fire an onRoomClosed() here.
this->rooms.erase(roomId);
MS_DEBUG("Room closed [roomId:%u]", roomId); MS_DEBUG("Room closed [roomId:%u]", roomId);
request->Accept(); request->Accept();
...@@ -295,3 +299,10 @@ void Loop::onChannelUnixStreamSocketRemotelyClosed(Channel::UnixStreamSocket* so ...@@ -295,3 +299,10 @@ void Loop::onChannelUnixStreamSocketRemotelyClosed(Channel::UnixStreamSocket* so
Close(); Close();
} }
void Loop::onRoomClosed(RTC::Room* room)
{
MS_TRACE();
this->rooms.erase(room->roomId);
}
...@@ -27,31 +27,43 @@ namespace RTC ...@@ -27,31 +27,43 @@ namespace RTC
Json::Value IceCandidate::toJson() Json::Value IceCandidate::toJson()
{ {
static const Json::StaticString k_foundation("foundation");
static const Json::StaticString k_priority("priority");
static const Json::StaticString k_ip("ip");
static const Json::StaticString k_port("port");
static const Json::StaticString k_type("type");
static const Json::StaticString v_host("host");
static const Json::StaticString k_protocol("protocol");
static const Json::StaticString v_udp("udp");
static const Json::StaticString v_tcp("tcp");
static const Json::StaticString k_tcpType("tcpType");
static const Json::StaticString v_passive("passive");
Json::Value data; Json::Value data;
data["foundation"] = this->foundation; data[k_foundation] = this->foundation;
data["priority"] = (unsigned int)this->priority; data[k_priority] = (unsigned int)this->priority;
data["ip"] = this->ip; data[k_ip] = this->ip;
data["port"] = this->port; data[k_port] = this->port;
switch (this->type) switch (this->type)
{ {
case CandidateType::HOST: case CandidateType::HOST:
data["type"] = "host"; data[k_type] = v_host;
break; break;
} }
switch (this->protocol) switch (this->protocol)
{ {
case Protocol::UDP: case Protocol::UDP:
data["protocol"] = "udp"; data[k_protocol] = v_udp;
break; break;
case Protocol::TCP: case Protocol::TCP:
data["protocol"] = "tcp"; data[k_protocol] = v_tcp;
switch (this->tcpType) switch (this->tcpType)
{ {
case TcpCandidateType::PASSIVE: case TcpCandidateType::PASSIVE:
data["tcpType"] = "passive"; data[k_tcpType] = v_passive;
break; break;
} }
break; break;
......
...@@ -28,10 +28,14 @@ namespace RTC ...@@ -28,10 +28,14 @@ namespace RTC
MS_TRACE(); MS_TRACE();
// Close all the Transports. // Close all the Transports.
for (auto& kv : this->transports) // NOTE: Upon Transport closure the onTransportClosed() method is called which
// removes it from the map, so this is the safe way to iterate the mao
// and remove elements.
for (auto it = this->transports.begin(); it != this->transports.end();)
{ {
RTC::Transport* transport = kv.second; RTC::Transport* transport = it->second;
it = this->transports.erase(it);
transport->Close(); transport->Close();
} }
...@@ -45,9 +49,18 @@ namespace RTC ...@@ -45,9 +49,18 @@ namespace RTC
{ {
MS_TRACE(); MS_TRACE();
static const Json::StaticString k_transports("transports");
Json::Value json(Json::objectValue); Json::Value json(Json::objectValue);
Json::Value json_transports(Json::objectValue);
// TODO for (auto& kv : this->transports)
{
RTC::Transport* transport = kv.second;
json_transports[std::to_string(transport->transportId)] = transport->Dump();
}
json[k_transports] = json_transports;
return json; return json;
} }
...@@ -125,7 +138,9 @@ namespace RTC ...@@ -125,7 +138,9 @@ namespace RTC
return; return;
} }
auto jsonRtpTransportId = request->data["rtpTransportId"]; static const Json::StaticString k_rtpTransportId("rtpTransportId");
auto jsonRtpTransportId = request->data[k_rtpTransportId];
if (!jsonRtpTransportId.isUInt()) if (!jsonRtpTransportId.isUInt())
{ {
...@@ -170,8 +185,30 @@ namespace RTC ...@@ -170,8 +185,30 @@ namespace RTC
case Channel::Request::MethodId::closeTransport: case Channel::Request::MethodId::closeTransport:
{ {
// TODO RTC::Transport* transport;
unsigned int transportId;
try
{
transport = GetTransportFromRequest(request, &transportId);
}
catch (const MediaSoupError &error)
{
request->Reject(500, error.what());
return;
}
if (!transport)
{
MS_ERROR("Transport does not exist");
request->Reject(500, "Transport does not exist");
return;
}
transport->Close();
MS_DEBUG("Transport closed [transportId:%u]", transportId);
request->Accept(); request->Accept();
break; break;
...@@ -188,7 +225,9 @@ namespace RTC ...@@ -188,7 +225,9 @@ namespace RTC
{ {
MS_TRACE(); MS_TRACE();
auto jsonTransportId = request->data["transportId"]; static const Json::StaticString k_transportId("transportId");
auto jsonTransportId = request->data[k_transportId];
if (!jsonTransportId.isUInt()) if (!jsonTransportId.isUInt())
MS_THROW_ERROR("Request has not numeric .transportId field"); MS_THROW_ERROR("Request has not numeric .transportId field");
...@@ -210,4 +249,11 @@ namespace RTC ...@@ -210,4 +249,11 @@ namespace RTC
return nullptr; return nullptr;
} }
} }
void Peer::onTransportClosed(RTC::Transport* transport)
{
MS_TRACE();
this->transports.erase(transport->transportId);
}
} }
...@@ -8,8 +8,9 @@ namespace RTC ...@@ -8,8 +8,9 @@ namespace RTC
{ {
/* Instance methods. */ /* Instance methods. */
Room::Room(unsigned int roomId, Json::Value& data) : Room::Room(Listener* listener, unsigned int roomId, Json::Value& data) :
roomId(roomId) roomId(roomId),
listener(listener)
{ {
MS_TRACE(); MS_TRACE();
...@@ -31,12 +32,15 @@ namespace RTC ...@@ -31,12 +32,15 @@ namespace RTC
// and remove elements. // and remove elements.
for (auto it = this->peers.begin(); it != this->peers.end();) for (auto it = this->peers.begin(); it != this->peers.end();)
{ {
auto peer = it->second; RTC::Peer* peer = it->second;
it = this->peers.erase(it); it = this->peers.erase(it);
peer->Close(); peer->Close();
} }
// Notify the listener.
this->listener->onRoomClosed(this);
delete this; delete this;
} }
...@@ -44,17 +48,18 @@ namespace RTC ...@@ -44,17 +48,18 @@ namespace RTC
{ {
MS_TRACE(); MS_TRACE();
static const Json::StaticString k_peers("peers");
Json::Value json(Json::objectValue); Json::Value json(Json::objectValue);
Json::Value jsonPeers(Json::objectValue); Json::Value json_peers(Json::objectValue);
for (auto& kv : this->peers) for (auto& kv : this->peers)
{ {
auto peer = kv.second; RTC::Peer* peer = kv.second;
jsonPeers[peer->peerId] = peer->Dump(); json_peers[peer->peerId] = peer->Dump();
} }
json[k_peers] = json_peers;
json["peers"] = jsonPeers;
return json; return json;
} }
...@@ -175,7 +180,9 @@ namespace RTC ...@@ -175,7 +180,9 @@ namespace RTC
{ {
MS_TRACE(); MS_TRACE();
auto jsonPeerId = request->data["peerId"]; static const Json::StaticString k_peerId("peerId");
auto jsonPeerId = request->data[k_peerId];
if (!jsonPeerId.isString()) if (!jsonPeerId.isString())
MS_THROW_ERROR("Request has not string .peerId field"); MS_THROW_ERROR("Request has not string .peerId field");
......
...@@ -21,13 +21,13 @@ namespace RTC ...@@ -21,13 +21,13 @@ namespace RTC
/* Instance methods. */ /* Instance methods. */
Transport::Transport(Listener* listener, unsigned int transportId, Json::Value& data, Transport* rtpTransport) : Transport::Transport(Listener* listener, unsigned int transportId, Json::Value& data, Transport* rtpTransport) :
listener(listener), transportId(transportId),
transportId(transportId) listener(listener)
{ {
MS_TRACE(); MS_TRACE();
static const Json::StaticString udp("udp"); static const Json::StaticString k_udp("udp");
static const Json::StaticString tcp("tcp"); static const Json::StaticString k_tcp("tcp");
bool try_IPv4_udp = false; bool try_IPv4_udp = false;
bool try_IPv6_udp = false; bool try_IPv6_udp = false;
...@@ -43,11 +43,11 @@ namespace RTC ...@@ -43,11 +43,11 @@ namespace RTC
Utils::Crypto::GetRandomString(16), Utils::Crypto::GetRandomString(16),
Utils::Crypto::GetRandomString(32)); Utils::Crypto::GetRandomString(32));
if (data[udp].isBool()) if (data[k_udp].isBool())
try_IPv4_udp = try_IPv6_udp = data[udp].asBool(); try_IPv4_udp = try_IPv6_udp = data[k_udp].asBool();
if (data[tcp].isBool()) if (data[k_tcp].isBool())
try_IPv4_tcp = try_IPv6_tcp = data[tcp].asBool(); try_IPv4_tcp = try_IPv6_tcp = data[k_tcp].asBool();
} }
// RTCP transport associated to a given RTP transport. // RTCP transport associated to a given RTP transport.
else else
...@@ -64,10 +64,6 @@ namespace RTC ...@@ -64,10 +64,6 @@ namespace RTC
try_IPv6_tcp = rtpTransport->hasIPv6tcp; try_IPv6_tcp = rtpTransport->hasIPv6tcp;
} }
// Fill IceParameters.
this->iceLocalParameters.usernameFragment = this->iceServer->GetUsernameFragment();
this->iceLocalParameters.password = this->iceServer->GetPassword();
// Open a IPv4 UDP socket. // Open a IPv4 UDP socket.
if (try_IPv4_udp && Settings::configuration.hasIPv4) if (try_IPv4_udp && Settings::configuration.hasIPv4)
{ {
...@@ -208,32 +204,48 @@ namespace RTC ...@@ -208,32 +204,48 @@ namespace RTC
server->Close(); server->Close();
if (this->allocated) if (this->allocated)
{
// Notify the listener.
this->listener->onTransportClosed(this);
delete this; delete this;
}
} }
Json::Value Transport::toJson() Json::Value Transport::Dump()
{ {
MS_TRACE(); MS_TRACE();
return toJson();
}
Json::Value Transport::toJson()
{
MS_TRACE();
static const Json::StaticString iceLocalParameters("iceLocalParameters"); static const Json::StaticString k_iceComponent("iceComponent");
static const Json::StaticString iceLocalCandidates("iceLocalCandidates"); static const Json::StaticString k_iceLocalParameters("iceLocalParameters");
static const Json::StaticString k_usernameFragment("usernameFragment");
static const Json::StaticString k_password("password");
static const Json::StaticString k_iceLocalCandidates("iceLocalCandidates");
static const Json::StaticString v_RTP("RTP");
static const Json::StaticString v_RTCP("RTCP");
Json::Value data; Json::Value data;
if (this->iceComponent == IceComponent::RTP) if (this->iceComponent == IceComponent::RTP)
data["iceComponent"] = "RTP"; data[k_iceComponent] = v_RTP;
else else
data["iceComponent"] = "RTCP"; data[k_iceComponent] = v_RTCP;
data[iceLocalParameters]["usernameFragment"] = this->iceLocalParameters.usernameFragment; data[k_iceLocalParameters][k_usernameFragment] = this->iceServer->GetUsernameFragment();
data[iceLocalParameters]["password"] = this->iceLocalParameters.password; data[k_iceLocalParameters][k_password] = this->iceServer->GetPassword();
data[iceLocalCandidates] = Json::arrayValue; data[k_iceLocalCandidates] = Json::arrayValue;
for (auto iceCandidate : this->iceLocalCandidates) for (auto iceCandidate : this->iceLocalCandidates)
{ {
data[iceLocalCandidates].append(iceCandidate.toJson()); data[k_iceLocalCandidates].append(iceCandidate.toJson());
} }
return data; return data;
......
...@@ -49,8 +49,6 @@ void SignalsHandler::AddSignal(int signum, std::string name) ...@@ -49,8 +49,6 @@ void SignalsHandler::AddSignal(int signum, std::string name)
// Enter the UV handle into the vector. // Enter the UV handle into the vector.
this->uvHandles.push_back(uvHandle); this->uvHandles.push_back(uvHandle);
MS_DEBUG("signal %s added", name.c_str());
} }
void SignalsHandler::Close() void SignalsHandler::Close()
......
...@@ -41,9 +41,6 @@ int main(int argc, char* argv[], char** envp) ...@@ -41,9 +41,6 @@ int main(int argc, char* argv[], char** envp)
Logger::Init(id, channel); Logger::Init(id, channel);
// Print libuv version.
MS_DEBUG("loaded libuv version: %s", uv_version_string());
try try
{ {
Settings::SetConfiguration(argc, argv); Settings::SetConfiguration(argc, argv);
...@@ -100,6 +97,8 @@ void init() ...@@ -100,6 +97,8 @@ void init()
ignoreSignals(); ignoreSignals();
DepLibUV::PrintVersion();
// Initialize static stuff. // Initialize static stuff.
DepOpenSSL::ClassInit(); DepOpenSSL::ClassInit();
DepLibSRTP::ClassInit(); DepLibSRTP::ClassInit();
......
Markdown 格式
0% 或
您添加了 0 人 到此讨论。请谨慎行事。
请先完成此评论的编辑!
请 注册 或者 后发表评论