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

Worker: Remove useless class factories.

上级 fc9b9c51
...@@ -20,10 +20,7 @@ namespace RTC ...@@ -20,10 +20,7 @@ namespace RTC
}; };
public: public:
static RTC::Peer* Factory(Listener* listener, std::string& peerId, Json::Value& data); Peer(Listener* listener, std::string& peerId, Json::Value& data);
public:
Peer(Listener* listener, std::string& peerId);
virtual ~Peer(); virtual ~Peer();
void SendRTPPacket(RTC::RTPPacket* packet); void SendRTPPacket(RTC::RTPPacket* packet);
......
...@@ -14,10 +14,7 @@ namespace RTC ...@@ -14,10 +14,7 @@ namespace RTC
class Room : public RTC::Peer::Listener class Room : public RTC::Peer::Listener
{ {
public: public:
static RTC::Room* Factory(unsigned int roomId, Json::Value& data); Room(unsigned int roomId, Json::Value& data);
public:
Room(unsigned int roomId);
virtual ~Room(); virtual ~Room();
void HandleCreatePeerRequest(Channel::Request* request); void HandleCreatePeerRequest(Channel::Request* request);
......
...@@ -167,13 +167,13 @@ void Loop::onChannelRequest(Channel::UnixStreamSocket* channel, Channel::Request ...@@ -167,13 +167,13 @@ void Loop::onChannelRequest(Channel::UnixStreamSocket* channel, Channel::Request
return; return;
} }
room = RTC::Room::Factory(roomId, request->data); try
if (!room)
{ {
MS_ERROR("failed to create Room"); room = new RTC::Room(roomId, request->data);
}
request->Reject(500, "failed to create Room"); catch (const MediaSoupError &error)
{
request->Reject(500, error.what());
return; return;
} }
......
...@@ -10,60 +10,15 @@ ...@@ -10,60 +10,15 @@
namespace RTC namespace RTC
{ {
/* Class methods. */
RTC::Peer* Peer::Factory(Listener* listener, std::string& peerId, Json::Value& data)
{
MS_TRACE();
// TODO: Check and use data for something.
return new RTC::Peer(listener, peerId);
}
/* Instance methods. */ /* Instance methods. */
Peer::Peer(Listener* listener, std::string& peerId) : Peer::Peer(Listener* listener, std::string& peerId, Json::Value& data) :
listener(listener), listener(listener),
peerId(peerId) peerId(peerId)
{ {
MS_TRACE(); MS_TRACE();
// TMP // TODO: do something wit data and throw if incorrect.
this->transport = RTC::Transport::NewWebRTC(this);
// Local DTLS role.
RTC::DTLSRole local_dtls_role = RTC::DTLSRole::SERVER;
// Chrome's fingerprint.
std::string remote_fingerprint = "74:24:E1:0A:30:48:FB:F2:72:6E:2C:70:FA:96:FD:06:81:AA:F8:1F:65:2E:D4:81:3E:93:0C:0F:E1:D0:FE:19";
this->transport->SetLocalDTLSRole(local_dtls_role);
this->transport->SetRemoteDTLSFingerprint(RTC::FingerprintHash::SHA256, remote_fingerprint);
try
{
RTC::UDPSocket* socket = RTC::UDPSocket::New(AF_INET);
this->transport->AddUDPSocket(socket);
MS_WARN("---- TEST: transport listens in IPv4 UDP '%s' : %u", socket->GetLocalIP().c_str(), socket->GetLocalPort());
}
catch (const MediaSoupError &error)
{
MS_ERROR("---- TEST: error adding IPv4 UDP to transport: %s", error.what());
}
try
{
RTC::TCPServer* server = RTC::TCPServer::New(AF_INET);
this->transport->AddTCPServer(server);
MS_WARN("---- TEST: transport listens in IPv4 TCP '%s' : %u", server->GetLocalIP().c_str(), server->GetLocalPort());
}
catch (const MediaSoupError &error)
{
MS_ERROR("---- TEST: error adding IPv4 TCP to transport: %s", error.what());
}
} }
Peer::~Peer() Peer::~Peer()
......
...@@ -13,35 +13,14 @@ ...@@ -13,35 +13,14 @@
namespace RTC namespace RTC
{ {
/* Class methods. */
RTC::Room* Room::Factory(unsigned int roomId, Json::Value& data)
{
MS_TRACE();
// TODO: Check and use data for something.
return new RTC::Room(roomId);
}
/* Instance methods. */ /* Instance methods. */
Room::Room(unsigned int roomId) : Room::Room(unsigned int roomId, Json::Value& data) :
roomId(roomId) roomId(roomId)
{ {
MS_TRACE(); MS_TRACE();
// TMP // TODO: do something wit data and throw if incorrect.
// for (int i = 1; i <= NUM_PEERS; i++)
// {
// RTC::Peer* peer = new RTC::Peer(this);
// // TODO: this is not being freed
// int* data = new int(i);
// peer->SetUserData((void*)data);
// this->peers.push_back(peer);
// }
} }
Room::~Room() Room::~Room()
...@@ -76,14 +55,13 @@ namespace RTC ...@@ -76,14 +55,13 @@ namespace RTC
return; return;
} }
peer = RTC::Peer::Factory(this, peerId, request->data); try
if (!peer)
{ {
MS_ERROR("failed to create Peer"); peer = new RTC::Peer(this, peerId, request->data);
}
request->Reject(500, "failed to create Peer"); catch (const MediaSoupError &error)
{
request->Reject(500, error.what());
return; return;
} }
......
...@@ -291,7 +291,6 @@ namespace RTC ...@@ -291,7 +291,6 @@ namespace RTC
this->sendingSource->Send(data, len); this->sendingSource->Send(data, len);
} }
// TODO: do it
void Transport::Dump() void Transport::Dump()
{ {
MS_DEBUG("%zu valid sources:", this->sources.size()); MS_DEBUG("%zu valid sources:", this->sources.size());
......
Markdown 格式
0% 或
您添加了 0 人 到此讨论。请谨慎行事。
请先完成此评论的编辑!
请 注册 或者 后发表评论