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

Worker: Remove useless class factories.

上级 fc9b9c51
......@@ -20,10 +20,7 @@ namespace RTC
};
public:
static RTC::Peer* Factory(Listener* listener, std::string& peerId, Json::Value& data);
public:
Peer(Listener* listener, std::string& peerId);
Peer(Listener* listener, std::string& peerId, Json::Value& data);
virtual ~Peer();
void SendRTPPacket(RTC::RTPPacket* packet);
......
......@@ -14,10 +14,7 @@ namespace RTC
class Room : public RTC::Peer::Listener
{
public:
static RTC::Room* Factory(unsigned int roomId, Json::Value& data);
public:
Room(unsigned int roomId);
Room(unsigned int roomId, Json::Value& data);
virtual ~Room();
void HandleCreatePeerRequest(Channel::Request* request);
......
......@@ -167,13 +167,13 @@ void Loop::onChannelRequest(Channel::UnixStreamSocket* channel, Channel::Request
return;
}
room = RTC::Room::Factory(roomId, request->data);
if (!room)
try
{
MS_ERROR("failed to create Room");
request->Reject(500, "failed to create Room");
room = new RTC::Room(roomId, request->data);
}
catch (const MediaSoupError &error)
{
request->Reject(500, error.what());
return;
}
......
......@@ -10,60 +10,15 @@
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. */
Peer::Peer(Listener* listener, std::string& peerId) :
Peer::Peer(Listener* listener, std::string& peerId, Json::Value& data) :
listener(listener),
peerId(peerId)
{
MS_TRACE();
// TMP
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());
}
// TODO: do something wit data and throw if incorrect.
}
Peer::~Peer()
......
......@@ -13,35 +13,14 @@
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. */
Room::Room(unsigned int roomId) :
Room::Room(unsigned int roomId, Json::Value& data) :
roomId(roomId)
{
MS_TRACE();
// TMP
// 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);
// }
// TODO: do something wit data and throw if incorrect.
}
Room::~Room()
......@@ -76,14 +55,13 @@ namespace RTC
return;
}
peer = RTC::Peer::Factory(this, peerId, request->data);
if (!peer)
try
{
MS_ERROR("failed to create Peer");
request->Reject(500, "failed to create Peer");
peer = new RTC::Peer(this, peerId, request->data);
}
catch (const MediaSoupError &error)
{
request->Reject(500, error.what());
return;
}
......
......@@ -291,7 +291,6 @@ namespace RTC
this->sendingSource->Send(data, len);
}
// TODO: do it
void Transport::Dump()
{
MS_DEBUG("%zu valid sources:", this->sources.size());
......
Markdown 格式
0% 或
您添加了 0 人 到此讨论。请谨慎行事。
请先完成此评论的编辑!
请 注册 或者 后发表评论