Unverified 提交 0d7a5016 authored 作者: Nazar Mokrynskyi's avatar Nazar Mokrynskyi 提交者: GitHub

Avoid duplicated basenames so that libmediasoup-worker is compilable on macOS (#557)

上级 19f3f63b
......@@ -110,5 +110,5 @@ docker-run:
mediasoup/docker:latest
libmediasoup-worker:
$(PYTHON) ./scripts/configure.py --no-duplicate-basename-check -R libmediasoup-worker
$(PYTHON) ./scripts/configure.py -R libmediasoup-worker
$(MAKE) -j$(CORES) BUILDTYPE=$(MEDIASOUP_BUILDTYPE) -C $(MEDIASOUP_OUT_DIR)
......@@ -337,11 +337,11 @@
"-std=c++11",
"-I/usr/local/opt/openssl/include",
"-o",
"PATH/out/Release/obj.target/mediasoup-worker/src/Channel/Request.o",
"../src/Channel/Request.cpp"
"PATH/out/Release/obj.target/mediasoup-worker/src/Channel/ChannelRequest.o",
"../src/Channel/ChannelRequest.cpp"
],
"directory": "PATH/out",
"file": "../src/Channel/Request.cpp"
"file": "../src/Channel/ChannelRequest.cpp"
},
{
"arguments": [
......@@ -466,11 +466,11 @@
"-std=c++11",
"-I/usr/local/opt/openssl/include",
"-o",
"PATH/out/Release/obj.target/mediasoup-worker/src/handles/UdpSocket.o",
"../src/handles/UdpSocket.cpp"
"PATH/out/Release/obj.target/mediasoup-worker/src/handles/UdpSocketHandler.o",
"../src/handles/UdpSocketHandler.cpp"
],
"directory": "PATH/out",
"file": "../src/handles/UdpSocket.cpp"
"file": "../src/handles/UdpSocketHandler.cpp"
},
{
"arguments": [
......@@ -1670,11 +1670,11 @@
"-std=c++11",
"-I/usr/local/opt/openssl/include",
"-o",
"PATH/out/Release/obj.target/mediasoup-worker/src/PayloadChannel/UnixStreamSocket.o",
"../src/PayloadChannel/UnixStreamSocket.cpp"
"PATH/out/Release/obj.target/mediasoup-worker/src/PayloadChannel/PayloadChannelSocket.o",
"../src/PayloadChannel/PayloadChannelSocket.cpp"
],
"directory": "PATH/out",
"file": "../src/PayloadChannel/UnixStreamSocket.cpp"
"file": "../src/PayloadChannel/PayloadChannelSocket.cpp"
},
{
"arguments": [
......@@ -1842,11 +1842,11 @@
"-std=c++11",
"-I/usr/local/opt/openssl/include",
"-o",
"PATH/out/Release/obj.target/mediasoup-worker/src/PayloadChannel/Notifier.o",
"../src/PayloadChannel/Notifier.cpp"
"PATH/out/Release/obj.target/mediasoup-worker/src/PayloadChannel/PayloadChannelNotifier.o",
"../src/PayloadChannel/PayloadChannelNotifier.cpp"
],
"directory": "PATH/out",
"file": "../src/PayloadChannel/Notifier.cpp"
"file": "../src/PayloadChannel/PayloadChannelNotifier.cpp"
},
{
"arguments": [
......@@ -1885,11 +1885,11 @@
"-std=c++11",
"-I/usr/local/opt/openssl/include",
"-o",
"PATH/out/Release/obj.target/mediasoup-worker/src/handles/TcpConnection.o",
"../src/handles/TcpConnection.cpp"
"PATH/out/Release/obj.target/mediasoup-worker/src/handles/TcpConnectionHandler.o",
"../src/handles/TcpConnectionHandler.cpp"
],
"directory": "PATH/out",
"file": "../src/handles/TcpConnection.cpp"
"file": "../src/handles/TcpConnectionHandler.cpp"
},
{
"arguments": [
......@@ -2444,11 +2444,11 @@
"-std=c++11",
"-I/usr/local/opt/openssl/include",
"-o",
"PATH/out/Release/obj.target/mediasoup-worker/src/handles/TcpServer.o",
"../src/handles/TcpServer.cpp"
"PATH/out/Release/obj.target/mediasoup-worker/src/handles/TcpServerHandler.o",
"../src/handles/TcpServerHandler.cpp"
],
"directory": "PATH/out",
"file": "../src/handles/TcpServer.cpp"
"file": "../src/handles/TcpServerHandler.cpp"
},
{
"arguments": [
......@@ -2702,11 +2702,11 @@
"-std=c++11",
"-I/usr/local/opt/openssl/include",
"-o",
"PATH/out/Release/obj.target/mediasoup-worker/src/Channel/UnixStreamSocket.o",
"../src/Channel/UnixStreamSocket.cpp"
"PATH/out/Release/obj.target/mediasoup-worker/src/Channel/ChannelSocket.o",
"../src/Channel/ChannelSocket.cpp"
],
"directory": "PATH/out",
"file": "../src/Channel/UnixStreamSocket.cpp"
"file": "../src/Channel/ChannelSocket.cpp"
},
{
"arguments": [
......@@ -3691,11 +3691,11 @@
"-std=c++11",
"-I/usr/local/opt/openssl/include",
"-o",
"PATH/out/Release/obj.target/mediasoup-worker/src/Channel/Notifier.o",
"../src/Channel/Notifier.cpp"
"PATH/out/Release/obj.target/mediasoup-worker/src/Channel/ChannelNotifier.o",
"../src/Channel/ChannelNotifier.cpp"
],
"directory": "PATH/out",
"file": "../src/Channel/Notifier.cpp"
"file": "../src/Channel/ChannelNotifier.cpp"
},
{
"arguments": [
......
......@@ -2,22 +2,22 @@
#define MS_CHANNEL_NOTIFIER_HPP
#include "common.hpp"
#include "Channel/UnixStreamSocket.hpp"
#include "Channel/ChannelSocket.hpp"
#include <json.hpp>
#include <string>
namespace Channel
{
class Notifier
class ChannelNotifier
{
public:
static void ClassInit(Channel::UnixStreamSocket* channel);
static void ClassInit(Channel::ChannelSocket* channel);
static void Emit(const std::string& targetId, const char* event);
static void Emit(const std::string& targetId, const char* event, json& data);
public:
// Passed by argument.
thread_local static Channel::UnixStreamSocket* channel;
thread_local static Channel::ChannelSocket* channel;
};
} // namespace Channel
......
......@@ -12,9 +12,9 @@ namespace Channel
{
// Avoid cyclic #include problem by declaring classes instead of including
// the corresponding header files.
class UnixStreamSocket;
class ChannelSocket;
class Request
class ChannelRequest
{
public:
enum class MethodId
......@@ -76,8 +76,8 @@ namespace Channel
static std::unordered_map<std::string, MethodId> string2MethodId;
public:
Request(Channel::UnixStreamSocket* channel, json& jsonRequest);
virtual ~Request();
ChannelRequest(Channel::ChannelSocket* channel, json& jsonRequest);
virtual ~ChannelRequest();
void Accept();
void Accept(json& data);
......@@ -86,7 +86,7 @@ namespace Channel
public:
// Passed by argument.
Channel::UnixStreamSocket* channel{ nullptr };
Channel::ChannelSocket* channel{ nullptr };
uint32_t id{ 0u };
std::string method;
MethodId methodId;
......
......@@ -2,7 +2,7 @@
#define MS_CHANNEL_UNIX_STREAM_SOCKET_HPP
#include "common.hpp"
#include "Channel/Request.hpp"
#include "Channel/ChannelRequest.hpp"
#include "handles/UnixStreamSocket.hpp"
#include <json.hpp>
......@@ -47,19 +47,20 @@ namespace Channel
}
};
class UnixStreamSocket : public ConsumerSocket::Listener
class ChannelSocket : public ConsumerSocket::Listener
{
public:
class Listener
{
public:
virtual void OnChannelRequest(Channel::UnixStreamSocket* channel, Channel::Request* request) = 0;
virtual void OnChannelClosed(Channel::UnixStreamSocket* channel) = 0;
virtual void OnChannelRequest(
Channel::ChannelSocket* channel, Channel::ChannelRequest* request) = 0;
virtual void OnChannelClosed(Channel::ChannelSocket* channel) = 0;
};
public:
explicit UnixStreamSocket(int consumerFd, int producerFd);
virtual ~UnixStreamSocket();
explicit ChannelSocket(int consumerFd, int producerFd);
virtual ~ChannelSocket();
public:
void SetListener(Listener* listener);
......
......@@ -89,7 +89,7 @@
#include "common.hpp"
#include "LogLevel.hpp"
#include "Settings.hpp"
#include "Channel/UnixStreamSocket.hpp"
#include "Channel/ChannelSocket.hpp"
#include <cstdio> // std::snprintf(), std::fprintf(), stdout, stderr
#include <cstdlib> // std::abort()
#include <cstring>
......@@ -129,11 +129,11 @@
class Logger
{
public:
static void ClassInit(Channel::UnixStreamSocket* channel);
static void ClassInit(Channel::ChannelSocket* channel);
public:
static const int64_t pid;
thread_local static Channel::UnixStreamSocket* channel;
thread_local static Channel::ChannelSocket* channel;
static const size_t bufferSize {50000};
static char buffer[];
};
......
......@@ -2,16 +2,16 @@
#define MS_PAYLOAD_CHANNEL_NOTIFIER_HPP
#include "common.hpp"
#include "PayloadChannel/UnixStreamSocket.hpp"
#include "PayloadChannel/PayloadChannelSocket.hpp"
#include <json.hpp>
#include <string>
namespace PayloadChannel
{
class Notifier
class PayloadChannelNotifier
{
public:
static void ClassInit(PayloadChannel::UnixStreamSocket* payloadChannel);
static void ClassInit(PayloadChannel::PayloadChannelSocket* payloadChannel);
static void Emit(
const std::string& targetId, const char* event, const uint8_t* payload, size_t payloadLen);
static void Emit(
......@@ -23,7 +23,7 @@ namespace PayloadChannel
public:
// Passed by argument.
thread_local static PayloadChannel::UnixStreamSocket* payloadChannel;
thread_local static PayloadChannel::PayloadChannelSocket* payloadChannel;
};
} // namespace PayloadChannel
......
......@@ -12,9 +12,9 @@ namespace PayloadChannel
{
// Avoid cyclic #include problem by declaring classes instead of including
// the corresponding header files.
class UnixStreamSocket;
class PayloadChannelSocket;
class Request
class PayloadChannelRequest
{
public:
enum class MethodId
......@@ -29,8 +29,8 @@ namespace PayloadChannel
static std::unordered_map<std::string, MethodId> string2MethodId;
public:
Request(PayloadChannel::UnixStreamSocket* channel, json& jsonRequest);
virtual ~Request();
PayloadChannelRequest(PayloadChannel::PayloadChannelSocket* channel, json& jsonRequest);
virtual ~PayloadChannelRequest();
public:
void Accept();
......@@ -41,7 +41,7 @@ namespace PayloadChannel
public:
// Passed by argument.
PayloadChannel::UnixStreamSocket* channel{ nullptr };
PayloadChannel::PayloadChannelSocket* channel{ nullptr };
uint32_t id{ 0u };
std::string method;
MethodId methodId;
......
......@@ -3,7 +3,7 @@
#include "common.hpp"
#include "PayloadChannel/Notification.hpp"
#include "PayloadChannel/Request.hpp"
#include "PayloadChannel/PayloadChannelRequest.hpp"
#include "handles/UnixStreamSocket.hpp"
#include <json.hpp>
......@@ -49,23 +49,24 @@ namespace PayloadChannel
}
};
class UnixStreamSocket : public ConsumerSocket::Listener
class PayloadChannelSocket : public ConsumerSocket::Listener
{
public:
class Listener
{
public:
virtual void OnPayloadChannelNotification(
PayloadChannel::UnixStreamSocket* payloadChannel,
PayloadChannel::PayloadChannelSocket* payloadChannel,
PayloadChannel::Notification* notification) = 0;
virtual void OnPayloadChannelRequest(
PayloadChannel::UnixStreamSocket* payloadChannel, PayloadChannel::Request* request) = 0;
virtual void OnPayloadChannelClosed(PayloadChannel::UnixStreamSocket* payloadChannel) = 0;
PayloadChannel::PayloadChannelSocket* payloadChannel,
PayloadChannel::PayloadChannelRequest* request) = 0;
virtual void OnPayloadChannelClosed(PayloadChannel::PayloadChannelSocket* payloadChannel) = 0;
};
public:
explicit UnixStreamSocket(int consumerFd, int producerFd);
virtual ~UnixStreamSocket();
explicit PayloadChannelSocket(int consumerFd, int producerFd);
virtual ~PayloadChannelSocket();
public:
void SetListener(Listener* listener);
......@@ -87,7 +88,7 @@ namespace PayloadChannel
ConsumerSocket consumerSocket;
ProducerSocket producerSocket;
PayloadChannel::Notification* ongoingNotification{ nullptr };
PayloadChannel::Request* ongoingRequest{ nullptr };
PayloadChannel::PayloadChannelRequest* ongoingRequest{ nullptr };
uint8_t* WriteBuffer;
};
} // namespace PayloadChannel
......
......@@ -2,7 +2,7 @@
#define MS_RTC_CONSUMER_HPP
#include "common.hpp"
#include "Channel/Request.hpp"
#include "Channel/ChannelRequest.hpp"
#include "RTC/RTCP/CompoundPacket.hpp"
#include "RTC/RTCP/FeedbackPs.hpp"
#include "RTC/RTCP/FeedbackPsFir.hpp"
......@@ -67,7 +67,7 @@ namespace RTC
virtual void FillJson(json& jsonObject) const;
virtual void FillJsonStats(json& jsonArray) const = 0;
virtual void FillJsonScore(json& jsonObject) const = 0;
virtual void HandleRequest(Channel::Request* request);
virtual void HandleRequest(Channel::ChannelRequest* request);
RTC::Media::Kind GetKind() const
{
return this->kind;
......
......@@ -2,8 +2,8 @@
#define MS_RTC_DATA_CONSUMER_HPP
#include "common.hpp"
#include "Channel/Request.hpp"
#include "PayloadChannel/Request.hpp"
#include "Channel/ChannelRequest.hpp"
#include "PayloadChannel/PayloadChannelRequest.hpp"
#include "RTC/SctpDictionaries.hpp"
#include <json.hpp>
#include <string>
......@@ -47,8 +47,8 @@ namespace RTC
public:
void FillJson(json& jsonObject) const;
void FillJsonStats(json& jsonArray) const;
void HandleRequest(Channel::Request* request);
void HandleRequest(PayloadChannel::Request* request);
void HandleRequest(Channel::ChannelRequest* request);
void HandleRequest(PayloadChannel::PayloadChannelRequest* request);
Type GetType() const
{
return this->type;
......
......@@ -2,7 +2,7 @@
#define MS_RTC_DATA_PRODUCER_HPP
#include "common.hpp"
#include "Channel/Request.hpp"
#include "Channel/ChannelRequest.hpp"
#include "RTC/SctpDictionaries.hpp"
#include <json.hpp>
#include <string>
......@@ -33,7 +33,7 @@ namespace RTC
public:
void FillJson(json& jsonObject) const;
void FillJsonStats(json& jsonArray) const;
void HandleRequest(Channel::Request* request) const;
void HandleRequest(Channel::ChannelRequest* request) const;
Type GetType() const
{
return this->type;
......
......@@ -14,7 +14,7 @@ namespace RTC
public:
void FillJson(json& jsonObject) const override;
void FillJsonStats(json& jsonArray) override;
void HandleRequest(Channel::Request* request) override;
void HandleRequest(Channel::ChannelRequest* request) override;
void HandleNotification(PayloadChannel::Notification* notification) override;
private:
......
......@@ -21,7 +21,7 @@ namespace RTC
void FillJson(json& jsonObject) const override;
void FillJsonStats(json& jsonArray) const override;
void FillJsonScore(json& jsonObject) const override;
void HandleRequest(Channel::Request* request) override;
void HandleRequest(Channel::ChannelRequest* request) override;
void ProducerRtpStream(RTC::RtpStream* rtpStream, uint32_t mappedSsrc) override;
void ProducerNewRtpStream(RTC::RtpStream* rtpStream, uint32_t mappedSsrc) override;
void ProducerRtpStreamScore(RTC::RtpStream* rtpStream, uint8_t score, uint8_t previousScore) override;
......
......@@ -29,7 +29,7 @@ namespace RTC
public:
void FillJson(json& jsonObject) const override;
void FillJsonStats(json& jsonArray) override;
void HandleRequest(Channel::Request* request) override;
void HandleRequest(Channel::ChannelRequest* request) override;
void HandleNotification(PayloadChannel::Notification* notification) override;
private:
......
......@@ -30,7 +30,7 @@ namespace RTC
public:
void FillJson(json& jsonObject) const override;
void FillJsonStats(json& jsonArray) override;
void HandleRequest(Channel::Request* request) override;
void HandleRequest(Channel::ChannelRequest* request) override;
void HandleNotification(PayloadChannel::Notification* notification) override;
private:
......
......@@ -2,7 +2,7 @@
#define MS_RTC_PRODUCER_HPP
#include "common.hpp"
#include "Channel/Request.hpp"
#include "Channel/ChannelRequest.hpp"
#include "RTC/KeyFrameRequestManager.hpp"
#include "RTC/RTCP/CompoundPacket.hpp"
#include "RTC/RTCP/Packet.hpp"
......@@ -89,7 +89,7 @@ namespace RTC
public:
void FillJson(json& jsonObject) const;
void FillJsonStats(json& jsonArray) const;
void HandleRequest(Channel::Request* request);
void HandleRequest(Channel::ChannelRequest* request);
RTC::Media::Kind GetKind() const
{
return this->kind;
......
......@@ -2,9 +2,9 @@
#define MS_RTC_ROUTER_HPP
#include "common.hpp"
#include "Channel/Request.hpp"
#include "Channel/ChannelRequest.hpp"
#include "PayloadChannel/Notification.hpp"
#include "PayloadChannel/Request.hpp"
#include "PayloadChannel/PayloadChannelRequest.hpp"
#include "RTC/Consumer.hpp"
#include "RTC/DataConsumer.hpp"
#include "RTC/DataProducer.hpp"
......@@ -30,8 +30,8 @@ namespace RTC
public:
void FillJson(json& jsonObject) const;
void HandleRequest(Channel::Request* request);
void HandleRequest(PayloadChannel::Request* request);
void HandleRequest(Channel::ChannelRequest* request);
void HandleRequest(PayloadChannel::PayloadChannelRequest* request);
void HandleNotification(PayloadChannel::Notification* notification);
private:
......
......@@ -21,7 +21,7 @@ namespace RTC
void FillJson(json& jsonObject) const override;
void FillJsonStats(json& jsonArray) const override;
void FillJsonScore(json& jsonObject) const override;
void HandleRequest(Channel::Request* request) override;
void HandleRequest(Channel::ChannelRequest* request) override;
bool IsActive() const override
{
// clang-format off
......
......@@ -22,7 +22,7 @@ namespace RTC
void FillJson(json& jsonObject) const override;
void FillJsonStats(json& jsonArray) const override;
void FillJsonScore(json& jsonObject) const override;
void HandleRequest(Channel::Request* request) override;
void HandleRequest(Channel::ChannelRequest* request) override;
RTC::Consumer::Layers GetPreferredLayers() const override
{
RTC::Consumer::Layers layers;
......
......@@ -23,7 +23,7 @@ namespace RTC
void FillJson(json& jsonObject) const override;
void FillJsonStats(json& jsonArray) const override;
void FillJsonScore(json& jsonObject) const override;
void HandleRequest(Channel::Request* request) override;
void HandleRequest(Channel::ChannelRequest* request) override;
RTC::Consumer::Layers GetPreferredLayers() const override
{
RTC::Consumer::Layers layers;
......
......@@ -2,11 +2,11 @@
#define MS_RTC_TCP_CONNECTION_HPP
#include "common.hpp"
#include "handles/TcpConnection.hpp"
#include "handles/TcpConnectionHandler.hpp"
namespace RTC
{
class TcpConnection : public ::TcpConnection
class TcpConnection : public ::TcpConnectionHandler
{
public:
class Listener
......@@ -21,9 +21,9 @@ namespace RTC
~TcpConnection() override;
public:
void Send(const uint8_t* data, size_t len, ::TcpConnection::onSendCallback* cb);
void Send(const uint8_t* data, size_t len, ::TcpConnectionHandler::onSendCallback* cb);
/* Pure virtual methods inherited from ::TcpConnection. */
/* Pure virtual methods inherited from ::TcpConnectionHandler. */
public:
void UserOnTcpConnectionRead() override;
......
......@@ -3,13 +3,13 @@
#include "common.hpp"
#include "RTC/TcpConnection.hpp"
#include "handles/TcpConnection.hpp"
#include "handles/TcpServer.hpp"
#include "handles/TcpConnectionHandler.hpp"
#include "handles/TcpServerHandler.hpp"
#include <string>
namespace RTC
{
class TcpServer : public ::TcpServer
class TcpServer : public ::TcpServerHandler
{
public:
class Listener
......@@ -23,10 +23,10 @@ namespace RTC
TcpServer(Listener* listener, RTC::TcpConnection::Listener* connListener, std::string& ip);
~TcpServer() override;
/* Pure virtual methods inherited from ::TcpServer. */
/* Pure virtual methods inherited from ::TcpServerHandler. */
public:
void UserOnTcpConnectionAlloc() override;
void UserOnTcpConnectionClosed(::TcpConnection* connection) override;
void UserOnTcpConnectionClosed(::TcpConnectionHandler* connection) override;
private:
// Passed by argument.
......
......@@ -4,9 +4,9 @@
#include "common.hpp"
#include "DepLibUV.hpp"
#include "Channel/Request.hpp"
#include "Channel/ChannelRequest.hpp"
#include "PayloadChannel/Notification.hpp"
#include "PayloadChannel/Request.hpp"
#include "PayloadChannel/PayloadChannelRequest.hpp"
#include "RTC/Consumer.hpp"
#include "RTC/DataConsumer.hpp"
#include "RTC/DataProducer.hpp"
......@@ -121,8 +121,8 @@ namespace RTC
virtual void FillJsonStats(json& jsonArray);
// Subclasses must implement these methods and call the parent's ones to
// handle common requests.
virtual void HandleRequest(Channel::Request* request);
virtual void HandleRequest(PayloadChannel::Request* request);
virtual void HandleRequest(Channel::ChannelRequest* request);
virtual void HandleRequest(PayloadChannel::PayloadChannelRequest* request);
virtual void HandleNotification(PayloadChannel::Notification* notification);
protected:
......
......@@ -2,12 +2,12 @@
#define MS_RTC_UDP_SOCKET_HPP
#include "common.hpp"
#include "handles/UdpSocket.hpp"
#include "handles/UdpSocketHandler.hpp"
#include <string>
namespace RTC
{
class UdpSocket : public ::UdpSocket
class UdpSocket : public ::UdpSocketHandler
{
public:
class Listener
......@@ -21,7 +21,7 @@ namespace RTC
UdpSocket(Listener* listener, std::string& ip);
~UdpSocket() override;
/* Pure virtual methods inherited from ::UdpSocket. */
/* Pure virtual methods inherited from ::UdpSocketHandler. */
public:
void UserOnUdpDatagramReceived(const uint8_t* data, size_t len, const struct sockaddr* addr) override;
......
......@@ -36,7 +36,7 @@ namespace RTC
public:
void FillJson(json& jsonObject) const override;
void FillJsonStats(json& jsonArray) override;
void HandleRequest(Channel::Request* request) override;
void HandleRequest(Channel::ChannelRequest* request) override;
void HandleNotification(PayloadChannel::Notification* notification) override;
private:
......
......@@ -3,7 +3,7 @@
#include "common.hpp"
#include "LogLevel.hpp"
#include "Channel/Request.hpp"
#include "Channel/ChannelRequest.hpp"
#include <map>
#include <string>
#include <vector>
......@@ -43,7 +43,7 @@ public:
public:
static void SetConfiguration(int argc, char* argv[]);
static void PrintConfiguration();
static void HandleRequest(Channel::Request* request);
static void HandleRequest(Channel::ChannelRequest* request);
private:
static void SetLogLevel(std::string& level);
......
......@@ -2,11 +2,11 @@
#define MS_WORKER_HPP
#include "common.hpp"
#include "Channel/Request.hpp"
#include "Channel/UnixStreamSocket.hpp"
#include "Channel/ChannelRequest.hpp"
#include "Channel/ChannelSocket.hpp"
#include "PayloadChannel/Notification.hpp"
#include "PayloadChannel/Request.hpp"
#include "PayloadChannel/UnixStreamSocket.hpp"
#include "PayloadChannel/PayloadChannelRequest.hpp"
#include "PayloadChannel/PayloadChannelSocket.hpp"
#include "RTC/Router.hpp"
#include "handles/SignalsHandler.hpp"
#include <json.hpp>
......@@ -15,12 +15,12 @@
using json = nlohmann::json;
class Worker : public Channel::UnixStreamSocket::Listener,
public PayloadChannel::UnixStreamSocket::Listener,
class Worker : public Channel::ChannelSocket::Listener,
public PayloadChannel::PayloadChannelSocket::Listener,
public SignalsHandler::Listener
{
public:
explicit Worker(Channel::UnixStreamSocket* channel, PayloadChannel::UnixStreamSocket* payloadChannel);
explicit Worker(Channel::ChannelSocket* channel, PayloadChannel::PayloadChannelSocket* payloadChannel);
~Worker();
private:
......@@ -32,17 +32,18 @@ private:
/* Methods inherited from Channel::lUnixStreamSocket::Listener. */
public:
void OnChannelRequest(Channel::UnixStreamSocket* channel, Channel::Request* request) override;
void OnChannelClosed(Channel::UnixStreamSocket* channel) override;
void OnChannelRequest(Channel::ChannelSocket* channel, Channel::ChannelRequest* request) override;
void OnChannelClosed(Channel::ChannelSocket* channel) override;
/* Methods inherited from PayloadChannel::lUnixStreamSocket::Listener. */
public:
void OnPayloadChannelNotification(
PayloadChannel::UnixStreamSocket* payloadChannel,
PayloadChannel::PayloadChannelSocket* payloadChannel,
PayloadChannel::Notification* notification) override;
void OnPayloadChannelRequest(
PayloadChannel::UnixStreamSocket* payloadChannel, PayloadChannel::Request* request) override;
void OnPayloadChannelClosed(PayloadChannel::UnixStreamSocket* payloadChannel) override;
PayloadChannel::PayloadChannelSocket* payloadChannel,
PayloadChannel::PayloadChannelRequest* request) override;
void OnPayloadChannelClosed(PayloadChannel::PayloadChannelSocket* payloadChannel) override;
/* Methods inherited from SignalsHandler::Listener. */
public:
......@@ -50,8 +51,8 @@ public:
private:
// Passed by argument.
Channel::UnixStreamSocket* channel{ nullptr };
PayloadChannel::UnixStreamSocket* payloadChannel{ nullptr };
Channel::ChannelSocket* channel{ nullptr };
PayloadChannel::PayloadChannelSocket* payloadChannel{ nullptr };
// Allocated by this.
SignalsHandler* signalsHandler{ nullptr };
std::unordered_map<std::string, RTC::Router*> mapRouters;
......
......@@ -5,7 +5,7 @@
#include <uv.h>
#include <string>
class TcpConnection
class TcpConnectionHandler
{
protected:
using onSendCallback = const std::function<void(bool sent)>;
......@@ -17,7 +17,7 @@ public:
virtual ~Listener() = default;
public:
virtual void OnTcpConnectionClosed(TcpConnection* connection) = 0;
virtual void OnTcpConnectionClosed(TcpConnectionHandler* connection) = 0;
};
public:
......@@ -40,14 +40,14 @@ public:
uv_write_t req;
uint8_t* store{ nullptr };
TcpConnection::onSendCallback* cb{ nullptr };
TcpConnectionHandler::onSendCallback* cb{ nullptr };
};
public:
explicit TcpConnection(size_t bufferSize);
TcpConnection& operator=(const TcpConnection&) = delete;
TcpConnection(const TcpConnection&) = delete;
virtual ~TcpConnection();
explicit TcpConnectionHandler(size_t bufferSize);
TcpConnectionHandler& operator=(const TcpConnectionHandler&) = delete;
TcpConnectionHandler(const TcpConnectionHandler&) = delete;
virtual ~TcpConnectionHandler();
public:
void Close();
......@@ -66,13 +66,13 @@ public:
return this->uvHandle;
}
void Start();
void Write(const uint8_t* data, size_t len, TcpConnection::onSendCallback* cb);
void Write(const uint8_t* data, size_t len, TcpConnectionHandler::onSendCallback* cb);
void Write(
const uint8_t* data1,
size_t len1,
const uint8_t* data2,
size_t len2,
TcpConnection::onSendCallback* cb);
TcpConnectionHandler::onSendCallback* cb);
void ErrorReceiving();
const struct sockaddr* GetLocalAddress() const
{
......
......@@ -2,19 +2,19 @@
#define MS_TCP_SERVER_HPP
#include "common.hpp"
#include "handles/TcpConnection.hpp"
#include "handles/TcpConnectionHandler.hpp"
#include <uv.h>
#include <string>
#include <unordered_set>
class TcpServer : public TcpConnection::Listener
class TcpServerHandler : public TcpConnectionHandler::Listener
{
public:
/**
* uvHandle must be an already initialized and binded uv_tcp_t pointer.
*/
TcpServer(uv_tcp_t* uvHandle, int backlog);
virtual ~TcpServer() override;
TcpServerHandler(uv_tcp_t* uvHandle, int backlog);
virtual ~TcpServerHandler() override;
public:
void Close();
......@@ -41,23 +41,23 @@ public:
}
protected:
void AcceptTcpConnection(TcpConnection* connection);
void AcceptTcpConnection(TcpConnectionHandler* connection);
private:
bool SetLocalAddress();
/* Pure virtual methods that must be implemented by the subclass. */
protected:
virtual void UserOnTcpConnectionAlloc() = 0;
virtual void UserOnTcpConnectionClosed(TcpConnection* connection) = 0;
virtual void UserOnTcpConnectionAlloc() = 0;
virtual void UserOnTcpConnectionClosed(TcpConnectionHandler* connection) = 0;
/* Callbacks fired by UV events. */
public:
void OnUvConnection(int status);
/* Methods inherited from TcpConnection::Listener. */
/* Methods inherited from TcpConnectionHandler::Listener. */
public:
void OnTcpConnectionClosed(TcpConnection* connection) override;
void OnTcpConnectionClosed(TcpConnectionHandler* connection) override;
protected:
struct sockaddr_storage localAddr;
......@@ -68,7 +68,7 @@ private:
// Allocated by this (may be passed by argument).
uv_tcp_t* uvHandle{ nullptr };
// Others.
std::unordered_set<TcpConnection*> connections;
std::unordered_set<TcpConnectionHandler*> connections;
bool closed{ false };
};
......
......@@ -5,7 +5,7 @@
#include <uv.h>
#include <string>
class UdpSocket
class UdpSocketHandler
{
protected:
using onSendCallback = const std::function<void(bool sent)>;
......@@ -30,22 +30,23 @@ public:
uv_udp_send_t req;
uint8_t* store{ nullptr };
UdpSocket::onSendCallback* cb{ nullptr };
UdpSocketHandler::onSendCallback* cb{ nullptr };
};
public:
/**
* uvHandle must be an already initialized and binded uv_udp_t pointer.
*/
explicit UdpSocket(uv_udp_t* uvHandle);
UdpSocket& operator=(const UdpSocket&) = delete;
UdpSocket(const UdpSocket&) = delete;
virtual ~UdpSocket();
explicit UdpSocketHandler(uv_udp_t* uvHandle);
UdpSocketHandler& operator=(const UdpSocketHandler&) = delete;
UdpSocketHandler(const UdpSocketHandler&) = delete;
virtual ~UdpSocketHandler();
public:
void Close();
virtual void Dump() const;
void Send(const uint8_t* data, size_t len, const struct sockaddr* addr, UdpSocket::onSendCallback* cb);
void Send(
const uint8_t* data, size_t len, const struct sockaddr* addr, UdpSocketHandler::onSendCallback* cb);
const struct sockaddr* GetLocalAddress() const
{
return reinterpret_cast<const struct sockaddr*>(&this->localAddr);
......@@ -78,7 +79,7 @@ private:
public:
void OnUvRecvAlloc(size_t suggestedSize, uv_buf_t* buf);
void OnUvRecv(ssize_t nread, const uv_buf_t* buf, const struct sockaddr* addr, unsigned int flags);
void OnUvSend(int status, UdpSocket::onSendCallback* cb);
void OnUvSend(int status, UdpSocketHandler::onSendCallback* cb);
/* Pure virtual methods that must be implemented by the subclass. */
protected:
......
......@@ -30,18 +30,18 @@
'src/Utils/IP.cpp',
'src/Utils/String.cpp',
'src/handles/SignalsHandler.cpp',
'src/handles/TcpConnection.cpp',
'src/handles/TcpServer.cpp',
'src/handles/TcpConnectionHandler.cpp',
'src/handles/TcpServerHandler.cpp',
'src/handles/Timer.cpp',
'src/handles/UdpSocket.cpp',
'src/handles/UdpSocketHandler.cpp',
'src/handles/UnixStreamSocket.cpp',
'src/Channel/Notifier.cpp',
'src/Channel/Request.cpp',
'src/Channel/UnixStreamSocket.cpp',
'src/Channel/ChannelNotifier.cpp',
'src/Channel/ChannelRequest.cpp',
'src/Channel/ChannelSocket.cpp',
'src/PayloadChannel/Notification.cpp',
'src/PayloadChannel/Notifier.cpp',
'src/PayloadChannel/Request.cpp',
'src/PayloadChannel/UnixStreamSocket.cpp',
'src/PayloadChannel/PayloadChannelNotifier.cpp',
'src/PayloadChannel/PayloadChannelRequest.cpp',
'src/PayloadChannel/PayloadChannelSocket.cpp',
'src/RTC/AudioLevelObserver.cpp',
'src/RTC/Consumer.cpp',
'src/RTC/DataConsumer.cpp',
......@@ -142,18 +142,18 @@
'include/Worker.hpp',
'include/common.hpp',
'include/handles/SignalsHandler.hpp',
'include/handles/TcpConnection.hpp',
'include/handles/TcpServer.hpp',
'include/handles/TcpConnectionHandler.hpp',
'include/handles/TcpServerHandler.hpp',
'include/handles/Timer.hpp',
'include/handles/UdpSocket.hpp',
'include/handles/UdpSocketHandler.hpp',
'include/handles/UnixStreamSocket.hpp',
'include/Channel/Notifier.hpp',
'include/Channel/Request.hpp',
'include/Channel/UnixStreamSocket.hpp',
'include/Channel/ChannelNotifier.hpp',
'include/Channel/ChannelRequest.hpp',
'include/Channel/ChannelSocket.hpp',
'include/PayloadChannel/Notification.hpp',
'include/PayloadChannel/Notifier.hpp',
'include/PayloadChannel/Request.hpp',
'include/PayloadChannel/UnixStreamSocket.hpp',
'include/PayloadChannel/PayloadChannelNotifier.hpp',
'include/PayloadChannel/PayloadChannelRequest.hpp',
'include/PayloadChannel/PayloadChannelSocket.hpp',
'include/RTC/BweType.hpp',
'include/RTC/AudioLevelObserver.hpp',
'include/RTC/Consumer.hpp',
......
#define MS_CLASS "Channel::Notifier"
// #define MS_LOG_DEV_LEVEL 3
#include "Channel/Notifier.hpp"
#include "Channel/ChannelNotifier.hpp"
#include "Logger.hpp"
namespace Channel
{
/* Class variables. */
thread_local Channel::UnixStreamSocket* Notifier::channel{ nullptr };
thread_local Channel::ChannelSocket* ChannelNotifier::channel{ nullptr };
/* Static methods. */
void Notifier::ClassInit(Channel::UnixStreamSocket* channel)
void ChannelNotifier::ClassInit(Channel::ChannelSocket* channel)
{
MS_TRACE();
Notifier::channel = channel;
ChannelNotifier::channel = channel;
}
void Notifier::Emit(const std::string& targetId, const char* event)
void ChannelNotifier::Emit(const std::string& targetId, const char* event)
{
MS_TRACE();
MS_ASSERT(Notifier::channel, "channel unset");
MS_ASSERT(ChannelNotifier::channel, "channel unset");
json jsonNotification = json::object();
jsonNotification["targetId"] = targetId;
jsonNotification["event"] = event;
Notifier::channel->Send(jsonNotification);
ChannelNotifier::channel->Send(jsonNotification);
}
void Notifier::Emit(const std::string& targetId, const char* event, json& data)
void ChannelNotifier::Emit(const std::string& targetId, const char* event, json& data)
{
MS_TRACE();
MS_ASSERT(Notifier::channel, "channel unset");
MS_ASSERT(ChannelNotifier::channel, "channel unset");
json jsonNotification = json::object();
......@@ -45,6 +45,6 @@ namespace Channel
jsonNotification["event"] = event;
jsonNotification["data"] = data;
Notifier::channel->Send(jsonNotification);
ChannelNotifier::channel->Send(jsonNotification);
}
} // namespace Channel
#define MS_CLASS "Channel::ChannelRequest"
// #define MS_LOG_DEV_LEVEL 3
#include "Channel/ChannelRequest.hpp"
#include "Logger.hpp"
#include "MediaSoupErrors.hpp"
#include "Utils.hpp"
namespace Channel
{
/* Class variables. */
// clang-format off
std::unordered_map<std::string, ChannelRequest::MethodId> ChannelRequest::string2MethodId =
{
{ "worker.close", ChannelRequest::MethodId::WORKER_CLOSE },
{ "worker.dump", ChannelRequest::MethodId::WORKER_DUMP },
{ "worker.getResourceUsage", ChannelRequest::MethodId::WORKER_GET_RESOURCE_USAGE },
{ "worker.updateSettings", ChannelRequest::MethodId::WORKER_UPDATE_SETTINGS },
{ "worker.createRouter", ChannelRequest::MethodId::WORKER_CREATE_ROUTER },
{ "router.close", ChannelRequest::MethodId::ROUTER_CLOSE },
{ "router.dump", ChannelRequest::MethodId::ROUTER_DUMP },
{ "router.createWebRtcTransport", ChannelRequest::MethodId::ROUTER_CREATE_WEBRTC_TRANSPORT },
{ "router.createPlainTransport", ChannelRequest::MethodId::ROUTER_CREATE_PLAIN_TRANSPORT },
{ "router.createPipeTransport", ChannelRequest::MethodId::ROUTER_CREATE_PIPE_TRANSPORT },
{ "router.createDirectTransport", ChannelRequest::MethodId::ROUTER_CREATE_DIRECT_TRANSPORT },
{ "router.createAudioLevelObserver", ChannelRequest::MethodId::ROUTER_CREATE_AUDIO_LEVEL_OBSERVER },
{ "transport.close", ChannelRequest::MethodId::TRANSPORT_CLOSE },
{ "transport.dump", ChannelRequest::MethodId::TRANSPORT_DUMP },
{ "transport.getStats", ChannelRequest::MethodId::TRANSPORT_GET_STATS },
{ "transport.connect", ChannelRequest::MethodId::TRANSPORT_CONNECT },
{ "transport.setMaxIncomingBitrate", ChannelRequest::MethodId::TRANSPORT_SET_MAX_INCOMING_BITRATE },
{ "transport.restartIce", ChannelRequest::MethodId::TRANSPORT_RESTART_ICE },
{ "transport.produce", ChannelRequest::MethodId::TRANSPORT_PRODUCE },
{ "transport.consume", ChannelRequest::MethodId::TRANSPORT_CONSUME },
{ "transport.produceData", ChannelRequest::MethodId::TRANSPORT_PRODUCE_DATA },
{ "transport.consumeData", ChannelRequest::MethodId::TRANSPORT_CONSUME_DATA },
{ "transport.enableTraceEvent", ChannelRequest::MethodId::TRANSPORT_ENABLE_TRACE_EVENT },
{ "producer.close", ChannelRequest::MethodId::PRODUCER_CLOSE },
{ "producer.dump", ChannelRequest::MethodId::PRODUCER_DUMP },
{ "producer.getStats", ChannelRequest::MethodId::PRODUCER_GET_STATS },
{ "producer.pause", ChannelRequest::MethodId::PRODUCER_PAUSE },
{ "producer.resume" , ChannelRequest::MethodId::PRODUCER_RESUME },
{ "producer.enableTraceEvent", ChannelRequest::MethodId::PRODUCER_ENABLE_TRACE_EVENT },
{ "consumer.close", ChannelRequest::MethodId::CONSUMER_CLOSE },
{ "consumer.dump", ChannelRequest::MethodId::CONSUMER_DUMP },
{ "consumer.getStats", ChannelRequest::MethodId::CONSUMER_GET_STATS },
{ "consumer.pause", ChannelRequest::MethodId::CONSUMER_PAUSE },
{ "consumer.resume", ChannelRequest::MethodId::CONSUMER_RESUME },
{ "consumer.setPreferredLayers", ChannelRequest::MethodId::CONSUMER_SET_PREFERRED_LAYERS },
{ "consumer.setPriority", ChannelRequest::MethodId::CONSUMER_SET_PRIORITY },
{ "consumer.requestKeyFrame", ChannelRequest::MethodId::CONSUMER_REQUEST_KEY_FRAME },
{ "consumer.enableTraceEvent", ChannelRequest::MethodId::CONSUMER_ENABLE_TRACE_EVENT },
{ "dataProducer.close", ChannelRequest::MethodId::DATA_PRODUCER_CLOSE },
{ "dataProducer.dump", ChannelRequest::MethodId::DATA_PRODUCER_DUMP },
{ "dataProducer.getStats", ChannelRequest::MethodId::DATA_PRODUCER_GET_STATS },
{ "dataConsumer.close", ChannelRequest::MethodId::DATA_CONSUMER_CLOSE },
{ "dataConsumer.dump", ChannelRequest::MethodId::DATA_CONSUMER_DUMP },
{ "dataConsumer.getStats", ChannelRequest::MethodId::DATA_CONSUMER_GET_STATS },
{ "dataConsumer.getBufferedAmount", ChannelRequest::MethodId::DATA_CONSUMER_GET_BUFFERED_AMOUNT },
{ "dataConsumer.setBufferedAmountLowThreshold", ChannelRequest::MethodId::DATA_CONSUMER_SET_BUFFERED_AMOUNT_LOW_THRESHOLD },
{ "rtpObserver.close", ChannelRequest::MethodId::RTP_OBSERVER_CLOSE },
{ "rtpObserver.pause", ChannelRequest::MethodId::RTP_OBSERVER_PAUSE },
{ "rtpObserver.resume", ChannelRequest::MethodId::RTP_OBSERVER_RESUME },
{ "rtpObserver.addProducer", ChannelRequest::MethodId::RTP_OBSERVER_ADD_PRODUCER },
{ "rtpObserver.removeProducer", ChannelRequest::MethodId::RTP_OBSERVER_REMOVE_PRODUCER }
};
// clang-format on
/* Instance methods. */
ChannelRequest::ChannelRequest(Channel::ChannelSocket* channel, json& jsonRequest)
: channel(channel)
{
MS_TRACE();
auto jsonIdIt = jsonRequest.find("id");
if (jsonIdIt == jsonRequest.end() || !Utils::Json::IsPositiveInteger(*jsonIdIt))
MS_THROW_ERROR("missing id");
this->id = jsonIdIt->get<uint32_t>();
auto jsonMethodIt = jsonRequest.find("method");
if (jsonMethodIt == jsonRequest.end() || !jsonMethodIt->is_string())
MS_THROW_ERROR("missing method");
this->method = jsonMethodIt->get<std::string>();
auto methodIdIt = ChannelRequest::string2MethodId.find(this->method);
if (methodIdIt == ChannelRequest::string2MethodId.end())
{
Error("unknown method");
MS_THROW_ERROR("unknown method '%s'", this->method.c_str());
}
this->methodId = methodIdIt->second;
auto jsonInternalIt = jsonRequest.find("internal");
if (jsonInternalIt != jsonRequest.end() && jsonInternalIt->is_object())
this->internal = *jsonInternalIt;
else
this->internal = json::object();
auto jsonDataIt = jsonRequest.find("data");
if (jsonDataIt != jsonRequest.end() && jsonDataIt->is_object())
this->data = *jsonDataIt;
else
this->data = json::object();
}
ChannelRequest::~ChannelRequest()
{
MS_TRACE();
}
void ChannelRequest::Accept()
{
MS_TRACE();
MS_ASSERT(!this->replied, "request already replied");
this->replied = true;
json jsonResponse = json::object();
jsonResponse["id"] = this->id;
jsonResponse["accepted"] = true;
this->channel->Send(jsonResponse);
}
void ChannelRequest::Accept(json& data)
{
MS_TRACE();
MS_ASSERT(!this->replied, "request already replied");
this->replied = true;
json jsonResponse = json::object();
jsonResponse["id"] = this->id;
jsonResponse["accepted"] = true;
if (data.is_structured())
jsonResponse["data"] = data;
this->channel->Send(jsonResponse);
}
void ChannelRequest::Error(const char* reason)
{
MS_TRACE();
MS_ASSERT(!this->replied, "request already replied");
this->replied = true;
json jsonResponse = json::object();
jsonResponse["id"] = this->id;
jsonResponse["error"] = "Error";
if (reason != nullptr)
jsonResponse["reason"] = reason;
this->channel->Send(jsonResponse);
}
void ChannelRequest::TypeError(const char* reason)
{
MS_TRACE();
MS_ASSERT(!this->replied, "request already replied");
this->replied = true;
json jsonResponse = json::object();
jsonResponse["id"] = this->id;
jsonResponse["error"] = "TypeError";
if (reason != nullptr)
jsonResponse["reason"] = reason;
this->channel->Send(jsonResponse);
}
} // namespace Channel
#define MS_CLASS "Channel::UnixStreamSocket"
#define MS_CLASS "Channel::ChannelSocket"
// #define MS_LOG_DEV_LEVEL 3
#include "Channel/UnixStreamSocket.hpp"
#include "Channel/ChannelSocket.hpp"
#include "Logger.hpp"
#include "MediaSoupErrors.hpp"
#include <cmath> // std::ceil()
......@@ -21,7 +21,7 @@ namespace Channel
static constexpr size_t NsPayloadMaxLen{ 4194304 };
/* Instance methods. */
UnixStreamSocket::UnixStreamSocket(int consumerFd, int producerFd)
ChannelSocket::ChannelSocket(int consumerFd, int producerFd)
: consumerSocket(consumerFd, NsMessageMaxLen, this), producerSocket(producerFd, NsMessageMaxLen)
{
MS_TRACE_STD();
......@@ -29,21 +29,21 @@ namespace Channel
this->WriteBuffer = static_cast<uint8_t*>(std::malloc(NsMessageMaxLen));
}
UnixStreamSocket::~UnixStreamSocket()
ChannelSocket::~ChannelSocket()
{
MS_TRACE_STD();
std::free(this->WriteBuffer);
}
void UnixStreamSocket::SetListener(Listener* listener)
void ChannelSocket::SetListener(Listener* listener)
{
MS_TRACE_STD();
this->listener = listener;
}
void UnixStreamSocket::Send(json& jsonMessage)
void ChannelSocket::Send(json& jsonMessage)
{
MS_TRACE_STD();
......@@ -62,7 +62,7 @@ namespace Channel
SendImpl(message.c_str(), message.length());
}
void UnixStreamSocket::SendLog(char* message, size_t messageLen)
void ChannelSocket::SendLog(char* message, size_t messageLen)
{
MS_TRACE_STD();
......@@ -79,7 +79,7 @@ namespace Channel
SendImpl(message, messageLen);
}
inline void UnixStreamSocket::SendImpl(const void* nsPayload, size_t nsPayloadLen)
inline void ChannelSocket::SendImpl(const void* nsPayload, size_t nsPayloadLen)
{
MS_TRACE_STD();
......@@ -105,15 +105,14 @@ namespace Channel
this->producerSocket.Write(this->WriteBuffer, nsLen);
}
void UnixStreamSocket::OnConsumerSocketMessage(
ConsumerSocket* /*consumerSocket*/, char* msg, size_t msgLen)
void ChannelSocket::OnConsumerSocketMessage(ConsumerSocket* /*consumerSocket*/, char* msg, size_t msgLen)
{
MS_TRACE_STD();
try
{
json jsonMessage = json::parse(msg, msg + msgLen);
auto* request = new Channel::Request(this, jsonMessage);
auto* request = new Channel::ChannelRequest(this, jsonMessage);
// Notify the listener.
try
......@@ -142,7 +141,7 @@ namespace Channel
}
}
void UnixStreamSocket::OnConsumerSocketClosed(ConsumerSocket* /*consumerSocket*/)
void ChannelSocket::OnConsumerSocketClosed(ConsumerSocket* /*consumerSocket*/)
{
MS_TRACE_STD();
......
#define MS_CLASS "Channel::Request"
// #define MS_LOG_DEV_LEVEL 3
#include "Channel/Request.hpp"
#include "Logger.hpp"
#include "MediaSoupErrors.hpp"
#include "Utils.hpp"
namespace Channel
{
/* Class variables. */
// clang-format off
std::unordered_map<std::string, Request::MethodId> Request::string2MethodId =
{
{ "worker.close", Request::MethodId::WORKER_CLOSE },
{ "worker.dump", Request::MethodId::WORKER_DUMP },
{ "worker.getResourceUsage", Request::MethodId::WORKER_GET_RESOURCE_USAGE },
{ "worker.updateSettings", Request::MethodId::WORKER_UPDATE_SETTINGS },
{ "worker.createRouter", Request::MethodId::WORKER_CREATE_ROUTER },
{ "router.close", Request::MethodId::ROUTER_CLOSE },
{ "router.dump", Request::MethodId::ROUTER_DUMP },
{ "router.createWebRtcTransport", Request::MethodId::ROUTER_CREATE_WEBRTC_TRANSPORT },
{ "router.createPlainTransport", Request::MethodId::ROUTER_CREATE_PLAIN_TRANSPORT },
{ "router.createPipeTransport", Request::MethodId::ROUTER_CREATE_PIPE_TRANSPORT },
{ "router.createDirectTransport", Request::MethodId::ROUTER_CREATE_DIRECT_TRANSPORT },
{ "router.createAudioLevelObserver", Request::MethodId::ROUTER_CREATE_AUDIO_LEVEL_OBSERVER },
{ "transport.close", Request::MethodId::TRANSPORT_CLOSE },
{ "transport.dump", Request::MethodId::TRANSPORT_DUMP },
{ "transport.getStats", Request::MethodId::TRANSPORT_GET_STATS },
{ "transport.connect", Request::MethodId::TRANSPORT_CONNECT },
{ "transport.setMaxIncomingBitrate", Request::MethodId::TRANSPORT_SET_MAX_INCOMING_BITRATE },
{ "transport.restartIce", Request::MethodId::TRANSPORT_RESTART_ICE },
{ "transport.produce", Request::MethodId::TRANSPORT_PRODUCE },
{ "transport.consume", Request::MethodId::TRANSPORT_CONSUME },
{ "transport.produceData", Request::MethodId::TRANSPORT_PRODUCE_DATA },
{ "transport.consumeData", Request::MethodId::TRANSPORT_CONSUME_DATA },
{ "transport.enableTraceEvent", Request::MethodId::TRANSPORT_ENABLE_TRACE_EVENT },
{ "producer.close", Request::MethodId::PRODUCER_CLOSE },
{ "producer.dump", Request::MethodId::PRODUCER_DUMP },
{ "producer.getStats", Request::MethodId::PRODUCER_GET_STATS },
{ "producer.pause", Request::MethodId::PRODUCER_PAUSE },
{ "producer.resume" , Request::MethodId::PRODUCER_RESUME },
{ "producer.enableTraceEvent", Request::MethodId::PRODUCER_ENABLE_TRACE_EVENT },
{ "consumer.close", Request::MethodId::CONSUMER_CLOSE },
{ "consumer.dump", Request::MethodId::CONSUMER_DUMP },
{ "consumer.getStats", Request::MethodId::CONSUMER_GET_STATS },
{ "consumer.pause", Request::MethodId::CONSUMER_PAUSE },
{ "consumer.resume", Request::MethodId::CONSUMER_RESUME },
{ "consumer.setPreferredLayers", Request::MethodId::CONSUMER_SET_PREFERRED_LAYERS },
{ "consumer.setPriority", Request::MethodId::CONSUMER_SET_PRIORITY },
{ "consumer.requestKeyFrame", Request::MethodId::CONSUMER_REQUEST_KEY_FRAME },
{ "consumer.enableTraceEvent", Request::MethodId::CONSUMER_ENABLE_TRACE_EVENT },
{ "dataProducer.close", Request::MethodId::DATA_PRODUCER_CLOSE },
{ "dataProducer.dump", Request::MethodId::DATA_PRODUCER_DUMP },
{ "dataProducer.getStats", Request::MethodId::DATA_PRODUCER_GET_STATS },
{ "dataConsumer.close", Request::MethodId::DATA_CONSUMER_CLOSE },
{ "dataConsumer.dump", Request::MethodId::DATA_CONSUMER_DUMP },
{ "dataConsumer.getStats", Request::MethodId::DATA_CONSUMER_GET_STATS },
{ "dataConsumer.getBufferedAmount", Request::MethodId::DATA_CONSUMER_GET_BUFFERED_AMOUNT },
{ "dataConsumer.setBufferedAmountLowThreshold", Request::MethodId::DATA_CONSUMER_SET_BUFFERED_AMOUNT_LOW_THRESHOLD },
{ "rtpObserver.close", Request::MethodId::RTP_OBSERVER_CLOSE },
{ "rtpObserver.pause", Request::MethodId::RTP_OBSERVER_PAUSE },
{ "rtpObserver.resume", Request::MethodId::RTP_OBSERVER_RESUME },
{ "rtpObserver.addProducer", Request::MethodId::RTP_OBSERVER_ADD_PRODUCER },
{ "rtpObserver.removeProducer", Request::MethodId::RTP_OBSERVER_REMOVE_PRODUCER }
};
// clang-format on
/* Instance methods. */
Request::Request(Channel::UnixStreamSocket* channel, json& jsonRequest) : channel(channel)
{
MS_TRACE();
auto jsonIdIt = jsonRequest.find("id");
if (jsonIdIt == jsonRequest.end() || !Utils::Json::IsPositiveInteger(*jsonIdIt))
MS_THROW_ERROR("missing id");
this->id = jsonIdIt->get<uint32_t>();
auto jsonMethodIt = jsonRequest.find("method");
if (jsonMethodIt == jsonRequest.end() || !jsonMethodIt->is_string())
MS_THROW_ERROR("missing method");
this->method = jsonMethodIt->get<std::string>();
auto methodIdIt = Request::string2MethodId.find(this->method);
if (methodIdIt == Request::string2MethodId.end())
{
Error("unknown method");
MS_THROW_ERROR("unknown method '%s'", this->method.c_str());
}
this->methodId = methodIdIt->second;
auto jsonInternalIt = jsonRequest.find("internal");
if (jsonInternalIt != jsonRequest.end() && jsonInternalIt->is_object())
this->internal = *jsonInternalIt;
else
this->internal = json::object();
auto jsonDataIt = jsonRequest.find("data");
if (jsonDataIt != jsonRequest.end() && jsonDataIt->is_object())
this->data = *jsonDataIt;
else
this->data = json::object();
}
Request::~Request()
{
MS_TRACE();
}
void Request::Accept()
{
MS_TRACE();
MS_ASSERT(!this->replied, "request already replied");
this->replied = true;
json jsonResponse = json::object();
jsonResponse["id"] = this->id;
jsonResponse["accepted"] = true;
this->channel->Send(jsonResponse);
}
void Request::Accept(json& data)
{
MS_TRACE();
MS_ASSERT(!this->replied, "request already replied");
this->replied = true;
json jsonResponse = json::object();
jsonResponse["id"] = this->id;
jsonResponse["accepted"] = true;
if (data.is_structured())
jsonResponse["data"] = data;
this->channel->Send(jsonResponse);
}
void Request::Error(const char* reason)
{
MS_TRACE();
MS_ASSERT(!this->replied, "request already replied");
this->replied = true;
json jsonResponse = json::object();
jsonResponse["id"] = this->id;
jsonResponse["error"] = "Error";
if (reason != nullptr)
jsonResponse["reason"] = reason;
this->channel->Send(jsonResponse);
}
void Request::TypeError(const char* reason)
{
MS_TRACE();
MS_ASSERT(!this->replied, "request already replied");
this->replied = true;
json jsonResponse = json::object();
jsonResponse["id"] = this->id;
jsonResponse["error"] = "TypeError";
if (reason != nullptr)
jsonResponse["reason"] = reason;
this->channel->Send(jsonResponse);
}
} // namespace Channel
......@@ -7,12 +7,12 @@
/* Class variables. */
const int64_t Logger::pid{ static_cast<int64_t>(uv_os_getpid()) };
thread_local Channel::UnixStreamSocket* Logger::channel{ nullptr };
thread_local Channel::ChannelSocket* Logger::channel{ nullptr };
char Logger::buffer[Logger::bufferSize];
/* Class methods. */
void Logger::ClassInit(Channel::UnixStreamSocket* channel)
void Logger::ClassInit(Channel::ChannelSocket* channel)
{
Logger::channel = channel;
......
#define MS_CLASS "PayloadChannel::Notifier"
// #define MS_LOG_DEV_LEVEL 3
#include "PayloadChannel/Notifier.hpp"
#include "PayloadChannel/PayloadChannelNotifier.hpp"
#include "Logger.hpp"
namespace PayloadChannel
{
/* Class variables. */
thread_local PayloadChannel::UnixStreamSocket* Notifier::payloadChannel{ nullptr };
thread_local PayloadChannel::PayloadChannelSocket* PayloadChannelNotifier::payloadChannel{ nullptr };
/* Static methods. */
void Notifier::ClassInit(PayloadChannel::UnixStreamSocket* payloadChannel)
void PayloadChannelNotifier::ClassInit(PayloadChannel::PayloadChannelSocket* payloadChannel)
{
MS_TRACE();
Notifier::payloadChannel = payloadChannel;
PayloadChannelNotifier::payloadChannel = payloadChannel;
}
void Notifier::Emit(
void PayloadChannelNotifier::Emit(
const std::string& targetId, const char* event, const uint8_t* payload, size_t payloadLen)
{
MS_TRACE();
MS_ASSERT(Notifier::payloadChannel, "payloadChannel unset");
MS_ASSERT(PayloadChannelNotifier::payloadChannel, "payloadChannel unset");
json jsonNotification = json::object();
jsonNotification["targetId"] = targetId;
jsonNotification["event"] = event;
Notifier::payloadChannel->Send(jsonNotification, payload, payloadLen);
PayloadChannelNotifier::payloadChannel->Send(jsonNotification, payload, payloadLen);
}
void Notifier::Emit(
void PayloadChannelNotifier::Emit(
const std::string& targetId, const char* event, json& data, const uint8_t* payload, size_t payloadLen)
{
MS_TRACE();
MS_ASSERT(Notifier::payloadChannel, "payloadChannel unset");
MS_ASSERT(PayloadChannelNotifier::payloadChannel, "payloadChannel unset");
json jsonNotification = json::object();
......@@ -47,6 +47,6 @@ namespace PayloadChannel
jsonNotification["event"] = event;
jsonNotification["data"] = data;
Notifier::payloadChannel->Send(jsonNotification, payload, payloadLen);
PayloadChannelNotifier::payloadChannel->Send(jsonNotification, payload, payloadLen);
}
} // namespace PayloadChannel
#define MS_CLASS "PayloadChannel::Request"
#define MS_CLASS "PayloadChannel::PayloadChannelRequest"
// #define MS_LOG_DEV_LEVEL 3
#include "PayloadChannel/Request.hpp"
#include "PayloadChannel/PayloadChannelRequest.hpp"
#include "Logger.hpp"
#include "MediaSoupErrors.hpp"
#include "Utils.hpp"
#include "PayloadChannel/UnixStreamSocket.hpp"
#include "PayloadChannel/PayloadChannelSocket.hpp"
namespace PayloadChannel
{
/* Class variables. */
// clang-format off
std::unordered_map<std::string, Request::MethodId> Request::string2MethodId =
std::unordered_map<std::string, PayloadChannelRequest::MethodId> PayloadChannelRequest::string2MethodId =
{
{ "dataConsumer.send", Request::MethodId::DATA_CONSUMER_SEND },
{ "dataConsumer.send", PayloadChannelRequest::MethodId::DATA_CONSUMER_SEND },
};
// clang-format on
/* Class methods. */
bool Request::IsRequest(json& jsonRequest)
bool PayloadChannelRequest::IsRequest(json& jsonRequest)
{
MS_TRACE();
......@@ -38,7 +38,9 @@ namespace PayloadChannel
/* Instance methods. */
Request::Request(PayloadChannel::UnixStreamSocket* channel, json& jsonRequest) : channel(channel)
PayloadChannelRequest::PayloadChannelRequest(
PayloadChannel::PayloadChannelSocket* channel, json& jsonRequest)
: channel(channel)
{
MS_TRACE();
......@@ -56,9 +58,9 @@ namespace PayloadChannel
this->method = jsonMethodIt->get<std::string>();
auto methodIdIt = Request::string2MethodId.find(this->method);
auto methodIdIt = PayloadChannelRequest::string2MethodId.find(this->method);
if (methodIdIt == Request::string2MethodId.end())
if (methodIdIt == PayloadChannelRequest::string2MethodId.end())
{
Error("unknown method");
......@@ -82,12 +84,12 @@ namespace PayloadChannel
this->data = json::object();
}
Request::~Request()
PayloadChannelRequest::~PayloadChannelRequest()
{
MS_TRACE();
}
void Request::Accept()
void PayloadChannelRequest::Accept()
{
MS_TRACE();
......@@ -103,7 +105,7 @@ namespace PayloadChannel
this->channel->Send(jsonResponse);
}
void Request::Accept(json& data)
void PayloadChannelRequest::Accept(json& data)
{
MS_TRACE();
......@@ -122,7 +124,7 @@ namespace PayloadChannel
this->channel->Send(jsonResponse);
}
void Request::Error(const char* reason)
void PayloadChannelRequest::Error(const char* reason)
{
MS_TRACE();
......@@ -141,7 +143,7 @@ namespace PayloadChannel
this->channel->Send(jsonResponse);
}
void Request::TypeError(const char* reason)
void PayloadChannelRequest::TypeError(const char* reason)
{
MS_TRACE();
......@@ -160,7 +162,7 @@ namespace PayloadChannel
this->channel->Send(jsonResponse);
}
void Request::SetPayload(const uint8_t* payload, size_t payloadLen)
void PayloadChannelRequest::SetPayload(const uint8_t* payload, size_t payloadLen)
{
MS_TRACE();
......
#define MS_CLASS "PayloadChannel::UnixStreamSocket"
#define MS_CLASS "PayloadChannel::PayloadChannelSocket"
// #define MS_LOG_DEV_LEVEL 3
#include "PayloadChannel/UnixStreamSocket.hpp"
#include "PayloadChannel/PayloadChannelSocket.hpp"
#include "Logger.hpp"
#include "MediaSoupErrors.hpp"
#include "PayloadChannel/Request.hpp"
#include "PayloadChannel/PayloadChannelRequest.hpp"
#include <cmath> // std::ceil()
#include <cstdio> // sprintf()
#include <cstring> // std::memcpy(), std::memmove()
......@@ -22,7 +22,7 @@ namespace PayloadChannel
static constexpr size_t NsPayloadMaxLen{ 4194304 };
/* Instance methods. */
UnixStreamSocket::UnixStreamSocket(int consumerFd, int producerFd)
PayloadChannelSocket::PayloadChannelSocket(int consumerFd, int producerFd)
: consumerSocket(consumerFd, NsMessageMaxLen, this), producerSocket(producerFd, NsMessageMaxLen)
{
MS_TRACE();
......@@ -30,7 +30,7 @@ namespace PayloadChannel
this->WriteBuffer = (uint8_t*)std::malloc(NsMessageMaxLen);
}
UnixStreamSocket::~UnixStreamSocket()
PayloadChannelSocket::~PayloadChannelSocket()
{
MS_TRACE();
......@@ -38,14 +38,14 @@ namespace PayloadChannel
delete this->ongoingNotification;
}
void UnixStreamSocket::SetListener(Listener* listener)
void PayloadChannelSocket::SetListener(Listener* listener)
{
MS_TRACE();
this->listener = listener;
}
void UnixStreamSocket::Send(json& jsonMessage, const uint8_t* payload, size_t payloadLen)
void PayloadChannelSocket::Send(json& jsonMessage, const uint8_t* payload, size_t payloadLen)
{
MS_TRACE();
......@@ -71,7 +71,7 @@ namespace PayloadChannel
SendImpl(payload, payloadLen);
}
void UnixStreamSocket::Send(json& jsonMessage)
void PayloadChannelSocket::Send(json& jsonMessage)
{
MS_TRACE_STD();
......@@ -90,7 +90,7 @@ namespace PayloadChannel
SendImpl(message.c_str(), message.length());
}
inline void UnixStreamSocket::SendImpl(const void* nsPayload, size_t nsPayloadLen)
inline void PayloadChannelSocket::SendImpl(const void* nsPayload, size_t nsPayloadLen)
{
MS_TRACE();
......@@ -116,7 +116,7 @@ namespace PayloadChannel
this->producerSocket.Write(this->WriteBuffer, nsLen);
}
void UnixStreamSocket::OnConsumerSocketMessage(
void PayloadChannelSocket::OnConsumerSocketMessage(
ConsumerSocket* /*consumerSocket*/, char* msg, size_t msgLen)
{
MS_TRACE();
......@@ -124,12 +124,12 @@ namespace PayloadChannel
if (!this->ongoingNotification && !this->ongoingRequest)
{
json jsonData = json::parse(msg, msg + msgLen);
if (Request::IsRequest(jsonData))
if (PayloadChannelRequest::IsRequest(jsonData))
{
try
{
json jsonMessage = json::parse(msg, msg + msgLen);
this->ongoingRequest = new PayloadChannel::Request(this, jsonMessage);
this->ongoingRequest = new PayloadChannel::PayloadChannelRequest(this, jsonMessage);
}
catch (const json::parse_error& error)
{
......@@ -205,7 +205,7 @@ namespace PayloadChannel
}
}
void UnixStreamSocket::OnConsumerSocketClosed(ConsumerSocket* /*consumerSocket*/)
void PayloadChannelSocket::OnConsumerSocketClosed(ConsumerSocket* /*consumerSocket*/)
{
MS_TRACE();
......
......@@ -5,7 +5,7 @@
#include "Logger.hpp"
#include "MediaSoupErrors.hpp"
#include "Utils.hpp"
#include "Channel/Notifier.hpp"
#include "Channel/ChannelNotifier.hpp"
#include "RTC/RtpDictionaries.hpp"
#include <cmath> // std::lround()
#include <map>
......@@ -131,7 +131,7 @@ namespace RTC
{
this->silence = true;
Channel::Notifier::Emit(this->id, "silence");
Channel::ChannelNotifier::Emit(this->id, "silence");
}
}
......@@ -183,13 +183,13 @@ namespace RTC
jsonEntry["volume"] = rit->first;
}
Channel::Notifier::Emit(this->id, "volumes", data);
Channel::ChannelNotifier::Emit(this->id, "volumes", data);
}
else if (!this->silence)
{
this->silence = true;
Channel::Notifier::Emit(this->id, "silence");
Channel::ChannelNotifier::Emit(this->id, "silence");
}
}
......
......@@ -5,7 +5,7 @@
#include "DepLibUV.hpp"
#include "Logger.hpp"
#include "MediaSoupErrors.hpp"
#include "Channel/Notifier.hpp"
#include "Channel/ChannelNotifier.hpp"
#include <iterator> // std::ostream_iterator
#include <sstream> // std::ostringstream
......@@ -230,13 +230,13 @@ namespace RTC
jsonObject["traceEventTypes"] = traceEventTypesStream.str();
}
void Consumer::HandleRequest(Channel::Request* request)
void Consumer::HandleRequest(Channel::ChannelRequest* request)
{
MS_TRACE();
switch (request->methodId)
{
case Channel::Request::MethodId::CONSUMER_DUMP:
case Channel::ChannelRequest::MethodId::CONSUMER_DUMP:
{
json data = json::object();
......@@ -247,7 +247,7 @@ namespace RTC
break;
}
case Channel::Request::MethodId::CONSUMER_GET_STATS:
case Channel::ChannelRequest::MethodId::CONSUMER_GET_STATS:
{
json data = json::array();
......@@ -258,7 +258,7 @@ namespace RTC
break;
}
case Channel::Request::MethodId::CONSUMER_PAUSE:
case Channel::ChannelRequest::MethodId::CONSUMER_PAUSE:
{
if (this->paused)
{
......@@ -281,7 +281,7 @@ namespace RTC
break;
}
case Channel::Request::MethodId::CONSUMER_RESUME:
case Channel::ChannelRequest::MethodId::CONSUMER_RESUME:
{
if (!this->paused)
{
......@@ -302,7 +302,7 @@ namespace RTC
break;
}
case Channel::Request::MethodId::CONSUMER_SET_PRIORITY:
case Channel::ChannelRequest::MethodId::CONSUMER_SET_PRIORITY:
{
auto jsonPriorityIt = request->data.find("priority");
......@@ -325,7 +325,7 @@ namespace RTC
break;
}
case Channel::Request::MethodId::CONSUMER_ENABLE_TRACE_EVENT:
case Channel::ChannelRequest::MethodId::CONSUMER_ENABLE_TRACE_EVENT:
{
auto jsonTypesIt = request->data.find("types");
......@@ -407,7 +407,7 @@ namespace RTC
if (wasActive)
UserOnPaused();
Channel::Notifier::Emit(this->id, "producerpause");
Channel::ChannelNotifier::Emit(this->id, "producerpause");
}
void Consumer::ProducerResumed()
......@@ -424,7 +424,7 @@ namespace RTC
if (IsActive())
UserOnResumed();
Channel::Notifier::Emit(this->id, "producerresume");
Channel::ChannelNotifier::Emit(this->id, "producerresume");
}
void Consumer::ProducerRtpStreamScores(const std::vector<uint8_t>* scores)
......@@ -445,7 +445,7 @@ namespace RTC
MS_DEBUG_DEV("Producer closed [consumerId:%s]", this->id.c_str());
Channel::Notifier::Emit(this->id, "producerclose");
Channel::ChannelNotifier::Emit(this->id, "producerclose");
this->listener->OnConsumerProducerClosed(this);
}
......@@ -467,7 +467,7 @@ namespace RTC
if (isRtx)
data["info"]["isRtx"] = true;
Channel::Notifier::Emit(this->id, "trace", data);
Channel::ChannelNotifier::Emit(this->id, "trace", data);
}
else if (this->traceEventTypes.rtp)
{
......@@ -482,7 +482,7 @@ namespace RTC
if (isRtx)
data["info"]["isRtx"] = true;
Channel::Notifier::Emit(this->id, "trace", data);
Channel::ChannelNotifier::Emit(this->id, "trace", data);
}
}
......@@ -500,7 +500,7 @@ namespace RTC
data["direction"] = "in";
data["info"]["ssrc"] = ssrc;
Channel::Notifier::Emit(this->id, "trace", data);
Channel::ChannelNotifier::Emit(this->id, "trace", data);
}
void Consumer::EmitTraceEventFirType(uint32_t ssrc) const
......@@ -517,7 +517,7 @@ namespace RTC
data["direction"] = "in";
data["info"]["ssrc"] = ssrc;
Channel::Notifier::Emit(this->id, "trace", data);
Channel::ChannelNotifier::Emit(this->id, "trace", data);
}
void Consumer::EmitTraceEventNackType() const
......@@ -534,6 +534,6 @@ namespace RTC
data["direction"] = "in";
data["info"] = json::object();
Channel::Notifier::Emit(this->id, "trace", data);
Channel::ChannelNotifier::Emit(this->id, "trace", data);
}
} // namespace RTC
......@@ -6,7 +6,7 @@
#include "Logger.hpp"
#include "MediaSoupErrors.hpp"
#include "Utils.hpp"
#include "Channel/Notifier.hpp"
#include "Channel/ChannelNotifier.hpp"
namespace RTC
{
......@@ -125,13 +125,13 @@ namespace RTC
jsonObject["bufferedAmount"] = this->bufferedAmount;
}
void DataConsumer::HandleRequest(Channel::Request* request)
void DataConsumer::HandleRequest(Channel::ChannelRequest* request)
{
MS_TRACE();
switch (request->methodId)
{
case Channel::Request::MethodId::DATA_CONSUMER_DUMP:
case Channel::ChannelRequest::MethodId::DATA_CONSUMER_DUMP:
{
json data = json::object();
......@@ -142,7 +142,7 @@ namespace RTC
break;
}
case Channel::Request::MethodId::DATA_CONSUMER_GET_STATS:
case Channel::ChannelRequest::MethodId::DATA_CONSUMER_GET_STATS:
{
json data = json::array();
......@@ -153,7 +153,7 @@ namespace RTC
break;
}
case Channel::Request::MethodId::DATA_CONSUMER_SET_BUFFERED_AMOUNT_LOW_THRESHOLD:
case Channel::ChannelRequest::MethodId::DATA_CONSUMER_SET_BUFFERED_AMOUNT_LOW_THRESHOLD:
{
auto jsonThresholdIt = request->data.find("threshold");
......@@ -173,7 +173,7 @@ namespace RTC
data["bufferedAmount"] = this->bufferedAmount;
Channel::Notifier::Emit(this->id, "bufferedamountlow", data);
Channel::ChannelNotifier::Emit(this->id, "bufferedamountlow", data);
}
// Force the trigger of 'bufferedamountlow' once there is less or same
// buffered data than the given threshold.
......@@ -192,13 +192,13 @@ namespace RTC
}
}
void DataConsumer::HandleRequest(PayloadChannel::Request* request)
void DataConsumer::HandleRequest(PayloadChannel::PayloadChannelRequest* request)
{
MS_TRACE();
switch (request->methodId)
{
case PayloadChannel::Request::MethodId::DATA_CONSUMER_SEND:
case PayloadChannel::PayloadChannelRequest::MethodId::DATA_CONSUMER_SEND:
{
auto jsonPpidIt = request->data.find("ppid");
......@@ -299,7 +299,7 @@ namespace RTC
data["bufferedAmount"] = this->bufferedAmount;
Channel::Notifier::Emit(this->id, "bufferedamountlow", data);
Channel::ChannelNotifier::Emit(this->id, "bufferedamountlow", data);
}
}
......@@ -313,7 +313,7 @@ namespace RTC
MS_DEBUG_DEV("DataProducer closed [dataConsumerId:%s]", this->id.c_str());
Channel::Notifier::Emit(this->id, "dataproducerclose");
Channel::ChannelNotifier::Emit(this->id, "dataproducerclose");
this->listener->OnDataConsumerDataProducerClosed(this);
}
......
......@@ -110,13 +110,13 @@ namespace RTC
jsonObject["bytesReceived"] = this->bytesReceived;
}
void DataProducer::HandleRequest(Channel::Request* request) const
void DataProducer::HandleRequest(Channel::ChannelRequest* request) const
{
MS_TRACE();
switch (request->methodId)
{
case Channel::Request::MethodId::DATA_PRODUCER_DUMP:
case Channel::ChannelRequest::MethodId::DATA_PRODUCER_DUMP:
{
json data = json::object();
......@@ -127,7 +127,7 @@ namespace RTC
break;
}
case Channel::Request::MethodId::DATA_PRODUCER_GET_STATS:
case Channel::ChannelRequest::MethodId::DATA_PRODUCER_GET_STATS:
{
json data = json::array();
......
......@@ -4,7 +4,7 @@
#include "RTC/DirectTransport.hpp"
#include "Logger.hpp"
#include "MediaSoupErrors.hpp"
#include "PayloadChannel/Notifier.hpp"
#include "PayloadChannel/PayloadChannelNotifier.hpp"
namespace RTC
{
......@@ -43,7 +43,7 @@ namespace RTC
jsonObject["type"] = "direct-transport";
}
void DirectTransport::HandleRequest(Channel::Request* request)
void DirectTransport::HandleRequest(Channel::ChannelRequest* request)
{
MS_TRACE();
......@@ -181,7 +181,7 @@ namespace RTC
size_t len = packet->GetSize();
// Notify the Node DirectTransport.
PayloadChannel::Notifier::Emit(consumer->id, "rtp", data, len);
PayloadChannel::PayloadChannelNotifier::Emit(consumer->id, "rtp", data, len);
if (cb)
{
......@@ -201,7 +201,7 @@ namespace RTC
size_t len = packet->GetSize();
// Notify the Node DirectTransport.
PayloadChannel::Notifier::Emit(this->id, "rtcp", data, len);
PayloadChannel::PayloadChannelNotifier::Emit(this->id, "rtcp", data, len);
// Increase send transmission.
RTC::Transport::DataSent(len);
......@@ -215,7 +215,7 @@ namespace RTC
size_t len = packet->GetSize();
// Notify the Node DirectTransport.
PayloadChannel::Notifier::Emit(this->id, "rtcp", data, len);
PayloadChannel::PayloadChannelNotifier::Emit(this->id, "rtcp", data, len);
// Increase send transmission.
RTC::Transport::DataSent(len);
......@@ -231,7 +231,7 @@ namespace RTC
data["ppid"] = ppid;
PayloadChannel::Notifier::Emit(dataConsumer->id, "message", data, msg, len);
PayloadChannel::PayloadChannelNotifier::Emit(dataConsumer->id, "message", data, msg, len);
// Increase send transmission.
RTC::Transport::DataSent(len);
......
......@@ -91,13 +91,13 @@ namespace RTC
jsonObject["producerScores"] = *this->producerRtpStreamScores;
}
void PipeConsumer::HandleRequest(Channel::Request* request)
void PipeConsumer::HandleRequest(Channel::ChannelRequest* request)
{
MS_TRACE();
switch (request->methodId)
{
case Channel::Request::MethodId::CONSUMER_REQUEST_KEY_FRAME:
case Channel::ChannelRequest::MethodId::CONSUMER_REQUEST_KEY_FRAME:
{
if (IsActive())
RequestKeyFrame();
......@@ -107,7 +107,7 @@ namespace RTC
break;
}
case Channel::Request::MethodId::CONSUMER_SET_PREFERRED_LAYERS:
case Channel::ChannelRequest::MethodId::CONSUMER_SET_PREFERRED_LAYERS:
{
// Do nothing.
......
......@@ -179,13 +179,13 @@ namespace RTC
}
}
void PipeTransport::HandleRequest(Channel::Request* request)
void PipeTransport::HandleRequest(Channel::ChannelRequest* request)
{
MS_TRACE();
switch (request->methodId)
{
case Channel::Request::MethodId::TRANSPORT_CONNECT:
case Channel::ChannelRequest::MethodId::TRANSPORT_CONNECT:
{
// Ensure this method is not called twice.
if (this->tuple)
......
......@@ -5,7 +5,7 @@
#include "Logger.hpp"
#include "MediaSoupErrors.hpp"
#include "Utils.hpp"
#include "Channel/Notifier.hpp"
#include "Channel/ChannelNotifier.hpp"
namespace RTC
{
......@@ -267,13 +267,13 @@ namespace RTC
this->rtcpTuple->FillJson(jsonObject["rtcpTuple"]);
}
void PlainTransport::HandleRequest(Channel::Request* request)
void PlainTransport::HandleRequest(Channel::ChannelRequest* request)
{
MS_TRACE();
switch (request->methodId)
{
case Channel::Request::MethodId::TRANSPORT_CONNECT:
case Channel::ChannelRequest::MethodId::TRANSPORT_CONNECT:
{
// Ensure this method is not called twice.
if (this->connectCalled)
......@@ -824,7 +824,7 @@ namespace RTC
this->tuple->FillJson(data["tuple"]);
Channel::Notifier::Emit(this->id, "tuple", data);
Channel::ChannelNotifier::Emit(this->id, "tuple", data);
RTC::Transport::Connected();
}
......@@ -889,7 +889,7 @@ namespace RTC
this->tuple->FillJson(data["tuple"]);
Channel::Notifier::Emit(this->id, "tuple", data);
Channel::ChannelNotifier::Emit(this->id, "tuple", data);
RTC::Transport::Connected();
}
......@@ -917,7 +917,7 @@ namespace RTC
this->rtcpTuple->FillJson(data["rtcpTuple"]);
Channel::Notifier::Emit(this->id, "rtcptuple", data);
Channel::ChannelNotifier::Emit(this->id, "rtcptuple", data);
}
// If RTCP-mux verify that the packet's tuple matches our RTP tuple.
else if (this->rtcpMux && !this->tuple->Compare(tuple))
......@@ -979,7 +979,7 @@ namespace RTC
this->tuple->FillJson(data["tuple"]);
Channel::Notifier::Emit(this->id, "tuple", data);
Channel::ChannelNotifier::Emit(this->id, "tuple", data);
RTC::Transport::Connected();
}
......
......@@ -6,7 +6,7 @@
#include "Logger.hpp"
#include "MediaSoupErrors.hpp"
#include "Utils.hpp"
#include "Channel/Notifier.hpp"
#include "Channel/ChannelNotifier.hpp"
#include "RTC/Codecs/Tools.hpp"
#include "RTC/RTCP/FeedbackPs.hpp"
#include "RTC/RTCP/FeedbackRtp.hpp"
......@@ -454,13 +454,13 @@ namespace RTC
}
}
void Producer::HandleRequest(Channel::Request* request)
void Producer::HandleRequest(Channel::ChannelRequest* request)
{
MS_TRACE();
switch (request->methodId)
{
case Channel::Request::MethodId::PRODUCER_DUMP:
case Channel::ChannelRequest::MethodId::PRODUCER_DUMP:
{
json data = json::object();
......@@ -471,7 +471,7 @@ namespace RTC
break;
}
case Channel::Request::MethodId::PRODUCER_GET_STATS:
case Channel::ChannelRequest::MethodId::PRODUCER_GET_STATS:
{
json data = json::array();
......@@ -482,7 +482,7 @@ namespace RTC
break;
}
case Channel::Request::MethodId::PRODUCER_PAUSE:
case Channel::ChannelRequest::MethodId::PRODUCER_PAUSE:
{
if (this->paused)
{
......@@ -510,7 +510,7 @@ namespace RTC
break;
}
case Channel::Request::MethodId::PRODUCER_RESUME:
case Channel::ChannelRequest::MethodId::PRODUCER_RESUME:
{
if (!this->paused)
{
......@@ -551,7 +551,7 @@ namespace RTC
break;
}
case Channel::Request::MethodId::PRODUCER_ENABLE_TRACE_EVENT:
case Channel::ChannelRequest::MethodId::PRODUCER_ENABLE_TRACE_EVENT:
{
auto jsonTypesIt = request->data.find("types");
......@@ -1398,7 +1398,7 @@ namespace RTC
data["flip"] = this->videoOrientation.flip;
data["rotation"] = this->videoOrientation.rotation;
Channel::Notifier::Emit(this->id, "videoorientationchange", data);
Channel::ChannelNotifier::Emit(this->id, "videoorientationchange", data);
}
}
}
......@@ -1428,7 +1428,7 @@ namespace RTC
jsonEntry["score"] = rtpStream->GetScore();
}
Channel::Notifier::Emit(this->id, "score", data);
Channel::ChannelNotifier::Emit(this->id, "score", data);
}
inline void Producer::EmitTraceEventRtpAndKeyFrameTypes(RTC::RtpPacket* packet, bool isRtx) const
......@@ -1448,7 +1448,7 @@ namespace RTC
if (isRtx)
data["info"]["isRtx"] = true;
Channel::Notifier::Emit(this->id, "trace", data);
Channel::ChannelNotifier::Emit(this->id, "trace", data);
}
else if (this->traceEventTypes.rtp)
{
......@@ -1463,7 +1463,7 @@ namespace RTC
if (isRtx)
data["info"]["isRtx"] = true;
Channel::Notifier::Emit(this->id, "trace", data);
Channel::ChannelNotifier::Emit(this->id, "trace", data);
}
}
......@@ -1481,7 +1481,7 @@ namespace RTC
data["direction"] = "out";
data["info"]["ssrc"] = ssrc;
Channel::Notifier::Emit(this->id, "trace", data);
Channel::ChannelNotifier::Emit(this->id, "trace", data);
}
inline void Producer::EmitTraceEventFirType(uint32_t ssrc) const
......@@ -1498,7 +1498,7 @@ namespace RTC
data["direction"] = "out";
data["info"]["ssrc"] = ssrc;
Channel::Notifier::Emit(this->id, "trace", data);
Channel::ChannelNotifier::Emit(this->id, "trace", data);
}
inline void Producer::EmitTraceEventNackType() const
......@@ -1515,7 +1515,7 @@ namespace RTC
data["direction"] = "out";
data["info"] = json::object();
Channel::Notifier::Emit(this->id, "trace", data);
Channel::ChannelNotifier::Emit(this->id, "trace", data);
}
inline void Producer::OnRtpStreamScore(RTC::RtpStream* rtpStream, uint8_t score, uint8_t previousScore)
......
......@@ -160,13 +160,13 @@ namespace RTC
}
}
void Router::HandleRequest(Channel::Request* request)
void Router::HandleRequest(Channel::ChannelRequest* request)
{
MS_TRACE();
switch (request->methodId)
{
case Channel::Request::MethodId::ROUTER_DUMP:
case Channel::ChannelRequest::MethodId::ROUTER_DUMP:
{
json data = json::object();
......@@ -177,7 +177,7 @@ namespace RTC
break;
}
case Channel::Request::MethodId::ROUTER_CREATE_WEBRTC_TRANSPORT:
case Channel::ChannelRequest::MethodId::ROUTER_CREATE_WEBRTC_TRANSPORT:
{
std::string transportId;
......@@ -201,7 +201,7 @@ namespace RTC
break;
}
case Channel::Request::MethodId::ROUTER_CREATE_PLAIN_TRANSPORT:
case Channel::ChannelRequest::MethodId::ROUTER_CREATE_PLAIN_TRANSPORT:
{
std::string transportId;
......@@ -224,7 +224,7 @@ namespace RTC
break;
}
case Channel::Request::MethodId::ROUTER_CREATE_PIPE_TRANSPORT:
case Channel::ChannelRequest::MethodId::ROUTER_CREATE_PIPE_TRANSPORT:
{
std::string transportId;
......@@ -247,7 +247,7 @@ namespace RTC
break;
}
case Channel::Request::MethodId::ROUTER_CREATE_DIRECT_TRANSPORT:
case Channel::ChannelRequest::MethodId::ROUTER_CREATE_DIRECT_TRANSPORT:
{
std::string transportId;
......@@ -270,7 +270,7 @@ namespace RTC
break;
}
case Channel::Request::MethodId::ROUTER_CREATE_AUDIO_LEVEL_OBSERVER:
case Channel::ChannelRequest::MethodId::ROUTER_CREATE_AUDIO_LEVEL_OBSERVER:
{
std::string rtpObserverId;
......@@ -289,7 +289,7 @@ namespace RTC
break;
}
case Channel::Request::MethodId::TRANSPORT_CLOSE:
case Channel::ChannelRequest::MethodId::TRANSPORT_CLOSE:
{
// This may throw.
RTC::Transport* transport = GetTransportFromInternal(request->internal);
......@@ -311,7 +311,7 @@ namespace RTC
break;
}
case Channel::Request::MethodId::RTP_OBSERVER_CLOSE:
case Channel::ChannelRequest::MethodId::RTP_OBSERVER_CLOSE:
{
// This may throw.
RTC::RtpObserver* rtpObserver = GetRtpObserverFromInternal(request->internal);
......@@ -337,7 +337,7 @@ namespace RTC
break;
}
case Channel::Request::MethodId::RTP_OBSERVER_PAUSE:
case Channel::ChannelRequest::MethodId::RTP_OBSERVER_PAUSE:
{
// This may throw.
RTC::RtpObserver* rtpObserver = GetRtpObserverFromInternal(request->internal);
......@@ -349,7 +349,7 @@ namespace RTC
break;
}
case Channel::Request::MethodId::RTP_OBSERVER_RESUME:
case Channel::ChannelRequest::MethodId::RTP_OBSERVER_RESUME:
{
// This may throw.
RTC::RtpObserver* rtpObserver = GetRtpObserverFromInternal(request->internal);
......@@ -361,7 +361,7 @@ namespace RTC
break;
}
case Channel::Request::MethodId::RTP_OBSERVER_ADD_PRODUCER:
case Channel::ChannelRequest::MethodId::RTP_OBSERVER_ADD_PRODUCER:
{
// This may throw.
RTC::RtpObserver* rtpObserver = GetRtpObserverFromInternal(request->internal);
......@@ -377,7 +377,7 @@ namespace RTC
break;
}
case Channel::Request::MethodId::RTP_OBSERVER_REMOVE_PRODUCER:
case Channel::ChannelRequest::MethodId::RTP_OBSERVER_REMOVE_PRODUCER:
{
// This may throw.
RTC::RtpObserver* rtpObserver = GetRtpObserverFromInternal(request->internal);
......@@ -406,7 +406,7 @@ namespace RTC
}
}
void Router::HandleRequest(PayloadChannel::Request* request)
void Router::HandleRequest(PayloadChannel::PayloadChannelRequest* request)
{
MS_TRACE();
......
......@@ -5,7 +5,7 @@
#include "DepUsrSCTP.hpp"
#include "Logger.hpp"
#include "MediaSoupErrors.hpp"
#include "Channel/Notifier.hpp"
#include "Channel/ChannelNotifier.hpp"
#include <cstdlib> // std::malloc(), std::free()
#include <cstring> // std::memset(), std::memcpy()
#include <string>
......@@ -470,7 +470,7 @@ namespace RTC
if (sctpSendBufferFull)
{
Channel::Notifier::Emit(dataConsumer->id, "sctpsendbufferfull");
Channel::ChannelNotifier::Emit(dataConsumer->id, "sctpsendbufferfull");
}
}
else if (cb)
......
......@@ -5,7 +5,7 @@
#include "DepLibUV.hpp"
#include "Logger.hpp"
#include "MediaSoupErrors.hpp"
#include "Channel/Notifier.hpp"
#include "Channel/ChannelNotifier.hpp"
#include "RTC/Codecs/Tools.hpp"
namespace RTC
......@@ -81,13 +81,13 @@ namespace RTC
jsonObject["producerScores"] = *this->producerRtpStreamScores;
}
void SimpleConsumer::HandleRequest(Channel::Request* request)
void SimpleConsumer::HandleRequest(Channel::ChannelRequest* request)
{
MS_TRACE();
switch (request->methodId)
{
case Channel::Request::MethodId::CONSUMER_REQUEST_KEY_FRAME:
case Channel::ChannelRequest::MethodId::CONSUMER_REQUEST_KEY_FRAME:
{
if (IsActive())
RequestKeyFrame();
......@@ -97,7 +97,7 @@ namespace RTC
break;
}
case Channel::Request::MethodId::CONSUMER_SET_PREFERRED_LAYERS:
case Channel::ChannelRequest::MethodId::CONSUMER_SET_PREFERRED_LAYERS:
{
// Do nothing.
......@@ -561,7 +561,7 @@ namespace RTC
FillJsonScore(data);
Channel::Notifier::Emit(this->id, "score", data);
Channel::ChannelNotifier::Emit(this->id, "score", data);
}
inline void SimpleConsumer::OnRtpStreamScore(
......
......@@ -6,7 +6,7 @@
#include "Logger.hpp"
#include "MediaSoupErrors.hpp"
#include "Utils.hpp"
#include "Channel/Notifier.hpp"
#include "Channel/ChannelNotifier.hpp"
#include "RTC/Codecs/Tools.hpp"
namespace RTC
......@@ -193,13 +193,13 @@ namespace RTC
jsonObject["producerScores"] = *this->producerRtpStreamScores;
}
void SimulcastConsumer::HandleRequest(Channel::Request* request)
void SimulcastConsumer::HandleRequest(Channel::ChannelRequest* request)
{
MS_TRACE();
switch (request->methodId)
{
case Channel::Request::MethodId::CONSUMER_REQUEST_KEY_FRAME:
case Channel::ChannelRequest::MethodId::CONSUMER_REQUEST_KEY_FRAME:
{
if (IsActive())
RequestKeyFrames();
......@@ -209,7 +209,7 @@ namespace RTC
break;
}
case Channel::Request::MethodId::CONSUMER_SET_PREFERRED_LAYERS:
case Channel::ChannelRequest::MethodId::CONSUMER_SET_PREFERRED_LAYERS:
{
auto previousPreferredSpatialLayer = this->preferredSpatialLayer;
auto previousPreferredTemporalLayer = this->preferredTemporalLayer;
......@@ -1413,7 +1413,7 @@ namespace RTC
FillJsonScore(data);
Channel::Notifier::Emit(this->id, "score", data);
Channel::ChannelNotifier::Emit(this->id, "score", data);
}
inline void SimulcastConsumer::EmitLayersChange() const
......@@ -1438,7 +1438,7 @@ namespace RTC
data = nullptr;
}
Channel::Notifier::Emit(this->id, "layerschange", data);
Channel::ChannelNotifier::Emit(this->id, "layerschange", data);
}
inline RTC::RtpStream* SimulcastConsumer::GetProducerCurrentRtpStream() const
......
......@@ -6,7 +6,7 @@
#include "Logger.hpp"
#include "MediaSoupErrors.hpp"
#include "Utils.hpp"
#include "Channel/Notifier.hpp"
#include "Channel/ChannelNotifier.hpp"
#include "RTC/Codecs/Tools.hpp"
namespace RTC
......@@ -172,13 +172,13 @@ namespace RTC
jsonObject["producerScores"] = *this->producerRtpStreamScores;
}
void SvcConsumer::HandleRequest(Channel::Request* request)
void SvcConsumer::HandleRequest(Channel::ChannelRequest* request)
{
MS_TRACE();
switch (request->methodId)
{
case Channel::Request::MethodId::CONSUMER_REQUEST_KEY_FRAME:
case Channel::ChannelRequest::MethodId::CONSUMER_REQUEST_KEY_FRAME:
{
if (IsActive())
RequestKeyFrame();
......@@ -188,7 +188,7 @@ namespace RTC
break;
}
case Channel::Request::MethodId::CONSUMER_SET_PREFERRED_LAYERS:
case Channel::ChannelRequest::MethodId::CONSUMER_SET_PREFERRED_LAYERS:
{
auto previousPreferredSpatialLayer = this->preferredSpatialLayer;
auto previousPreferredTemporalLayer = this->preferredTemporalLayer;
......@@ -1044,7 +1044,7 @@ namespace RTC
FillJsonScore(data);
Channel::Notifier::Emit(this->id, "score", data);
Channel::ChannelNotifier::Emit(this->id, "score", data);
}
inline void SvcConsumer::EmitLayersChange() const
......@@ -1069,7 +1069,7 @@ namespace RTC
data = nullptr;
}
Channel::Notifier::Emit(this->id, "layerschange", data);
Channel::ChannelNotifier::Emit(this->id, "layerschange", data);
}
inline void SvcConsumer::OnRtpStreamScore(
......
......@@ -16,7 +16,7 @@ namespace RTC
/* Instance methods. */
TcpConnection::TcpConnection(Listener* listener, size_t bufferSize)
: ::TcpConnection::TcpConnection(bufferSize), listener(listener)
: ::TcpConnectionHandler::TcpConnectionHandler(bufferSize), listener(listener)
{
MS_TRACE();
}
......@@ -154,7 +154,7 @@ namespace RTC
}
}
void TcpConnection::Send(const uint8_t* data, size_t len, ::TcpConnection::onSendCallback* cb)
void TcpConnection::Send(const uint8_t* data, size_t len, ::TcpConnectionHandler::onSendCallback* cb)
{
MS_TRACE();
......@@ -163,6 +163,6 @@ namespace RTC
uint8_t frameLen[2];
Utils::Byte::Set2Bytes(frameLen, 0, len);
::TcpConnection::Write(frameLen, 2, data, len, cb);
::TcpConnectionHandler::Write(frameLen, 2, data, len, cb);
}
} // namespace RTC
......@@ -16,7 +16,7 @@ namespace RTC
TcpServer::TcpServer(Listener* listener, RTC::TcpConnection::Listener* connListener, std::string& ip)
: // This may throw.
::TcpServer::TcpServer(RTC::PortManager::BindTcp(ip), 256), listener(listener),
::TcpServerHandler::TcpServerHandler(RTC::PortManager::BindTcp(ip), 256), listener(listener),
connListener(connListener)
{
MS_TRACE();
......@@ -48,7 +48,7 @@ namespace RTC
AcceptTcpConnection(connection);
}
void TcpServer::UserOnTcpConnectionClosed(::TcpConnection* connection)
void TcpServer::UserOnTcpConnectionClosed(::TcpConnectionHandler* connection)
{
MS_TRACE();
......
......@@ -5,8 +5,8 @@
#include "Logger.hpp"
#include "MediaSoupErrors.hpp"
#include "Utils.hpp"
#include "Channel/Notifier.hpp"
#include "PayloadChannel/Notifier.hpp"
#include "Channel/ChannelNotifier.hpp"
#include "PayloadChannel/PayloadChannelNotifier.hpp"
#include "RTC/BweType.hpp"
#include "RTC/PipeConsumer.hpp"
#include "RTC/RTCP/FeedbackPs.hpp"
......@@ -554,13 +554,13 @@ namespace RTC
jsonObject["maxIncomingBitrate"] = this->maxIncomingBitrate;
}
void Transport::HandleRequest(Channel::Request* request)
void Transport::HandleRequest(Channel::ChannelRequest* request)
{
MS_TRACE();
switch (request->methodId)
{
case Channel::Request::MethodId::TRANSPORT_DUMP:
case Channel::ChannelRequest::MethodId::TRANSPORT_DUMP:
{
json data = json::object();
......@@ -571,7 +571,7 @@ namespace RTC
break;
}
case Channel::Request::MethodId::TRANSPORT_GET_STATS:
case Channel::ChannelRequest::MethodId::TRANSPORT_GET_STATS:
{
json data = json::array();
......@@ -582,7 +582,7 @@ namespace RTC
break;
}
case Channel::Request::MethodId::TRANSPORT_SET_MAX_INCOMING_BITRATE:
case Channel::ChannelRequest::MethodId::TRANSPORT_SET_MAX_INCOMING_BITRATE:
{
auto jsonBitrateIt = request->data.find("bitrate");
......@@ -608,7 +608,7 @@ namespace RTC
break;
}
case Channel::Request::MethodId::TRANSPORT_PRODUCE:
case Channel::ChannelRequest::MethodId::TRANSPORT_PRODUCE:
{
std::string producerId;
......@@ -765,7 +765,7 @@ namespace RTC
break;
}
case Channel::Request::MethodId::TRANSPORT_CONSUME:
case Channel::ChannelRequest::MethodId::TRANSPORT_CONSUME:
{
auto jsonProducerIdIt = request->internal.find("producerId");
......@@ -1017,7 +1017,7 @@ namespace RTC
break;
}
case Channel::Request::MethodId::TRANSPORT_PRODUCE_DATA:
case Channel::ChannelRequest::MethodId::TRANSPORT_PRODUCE_DATA:
{
// Early check. The Transport must support SCTP or be direct.
if (!this->sctpAssociation && !this->direct)
......@@ -1113,7 +1113,7 @@ namespace RTC
break;
}
case Channel::Request::MethodId::TRANSPORT_CONSUME_DATA:
case Channel::ChannelRequest::MethodId::TRANSPORT_CONSUME_DATA:
{
// Early check. The Transport must support SCTP or be direct.
if (!this->sctpAssociation && !this->direct)
......@@ -1214,7 +1214,7 @@ namespace RTC
break;
}
case Channel::Request::MethodId::TRANSPORT_ENABLE_TRACE_EVENT:
case Channel::ChannelRequest::MethodId::TRANSPORT_ENABLE_TRACE_EVENT:
{
auto jsonTypesIt = request->data.find("types");
......@@ -1245,7 +1245,7 @@ namespace RTC
break;
}
case Channel::Request::MethodId::PRODUCER_CLOSE:
case Channel::ChannelRequest::MethodId::PRODUCER_CLOSE:
{
// This may throw.
RTC::Producer* producer = GetProducerFromInternal(request->internal);
......@@ -1280,7 +1280,7 @@ namespace RTC
break;
}
case Channel::Request::MethodId::CONSUMER_CLOSE:
case Channel::ChannelRequest::MethodId::CONSUMER_CLOSE:
{
// This may throw.
RTC::Consumer* consumer = GetConsumerFromInternal(request->internal);
......@@ -1321,11 +1321,11 @@ namespace RTC
break;
}
case Channel::Request::MethodId::PRODUCER_DUMP:
case Channel::Request::MethodId::PRODUCER_GET_STATS:
case Channel::Request::MethodId::PRODUCER_PAUSE:
case Channel::Request::MethodId::PRODUCER_RESUME:
case Channel::Request::MethodId::PRODUCER_ENABLE_TRACE_EVENT:
case Channel::ChannelRequest::MethodId::PRODUCER_DUMP:
case Channel::ChannelRequest::MethodId::PRODUCER_GET_STATS:
case Channel::ChannelRequest::MethodId::PRODUCER_PAUSE:
case Channel::ChannelRequest::MethodId::PRODUCER_RESUME:
case Channel::ChannelRequest::MethodId::PRODUCER_ENABLE_TRACE_EVENT:
{
// This may throw.
RTC::Producer* producer = GetProducerFromInternal(request->internal);
......@@ -1335,14 +1335,14 @@ namespace RTC
break;
}
case Channel::Request::MethodId::CONSUMER_DUMP:
case Channel::Request::MethodId::CONSUMER_GET_STATS:
case Channel::Request::MethodId::CONSUMER_PAUSE:
case Channel::Request::MethodId::CONSUMER_RESUME:
case Channel::Request::MethodId::CONSUMER_SET_PREFERRED_LAYERS:
case Channel::Request::MethodId::CONSUMER_SET_PRIORITY:
case Channel::Request::MethodId::CONSUMER_REQUEST_KEY_FRAME:
case Channel::Request::MethodId::CONSUMER_ENABLE_TRACE_EVENT:
case Channel::ChannelRequest::MethodId::CONSUMER_DUMP:
case Channel::ChannelRequest::MethodId::CONSUMER_GET_STATS:
case Channel::ChannelRequest::MethodId::CONSUMER_PAUSE:
case Channel::ChannelRequest::MethodId::CONSUMER_RESUME:
case Channel::ChannelRequest::MethodId::CONSUMER_SET_PREFERRED_LAYERS:
case Channel::ChannelRequest::MethodId::CONSUMER_SET_PRIORITY:
case Channel::ChannelRequest::MethodId::CONSUMER_REQUEST_KEY_FRAME:
case Channel::ChannelRequest::MethodId::CONSUMER_ENABLE_TRACE_EVENT:
{
// This may throw.
RTC::Consumer* consumer = GetConsumerFromInternal(request->internal);
......@@ -1352,7 +1352,7 @@ namespace RTC
break;
}
case Channel::Request::MethodId::DATA_PRODUCER_CLOSE:
case Channel::ChannelRequest::MethodId::DATA_PRODUCER_CLOSE:
{
// This may throw.
RTC::DataProducer* dataProducer = GetDataProducerFromInternal(request->internal);
......@@ -1385,7 +1385,7 @@ namespace RTC
break;
}
case Channel::Request::MethodId::DATA_CONSUMER_CLOSE:
case Channel::ChannelRequest::MethodId::DATA_CONSUMER_CLOSE:
{
// This may throw.
RTC::DataConsumer* dataConsumer = GetDataConsumerFromInternal(request->internal);
......@@ -1412,8 +1412,8 @@ namespace RTC
break;
}
case Channel::Request::MethodId::DATA_PRODUCER_DUMP:
case Channel::Request::MethodId::DATA_PRODUCER_GET_STATS:
case Channel::ChannelRequest::MethodId::DATA_PRODUCER_DUMP:
case Channel::ChannelRequest::MethodId::DATA_PRODUCER_GET_STATS:
{
// This may throw.
RTC::DataProducer* dataProducer = GetDataProducerFromInternal(request->internal);
......@@ -1423,8 +1423,8 @@ namespace RTC
break;
}
case Channel::Request::MethodId::DATA_CONSUMER_DUMP:
case Channel::Request::MethodId::DATA_CONSUMER_GET_STATS:
case Channel::ChannelRequest::MethodId::DATA_CONSUMER_DUMP:
case Channel::ChannelRequest::MethodId::DATA_CONSUMER_GET_STATS:
{
// This may throw.
RTC::DataConsumer* dataConsumer = GetDataConsumerFromInternal(request->internal);
......@@ -1434,7 +1434,7 @@ namespace RTC
break;
}
case Channel::Request::MethodId::DATA_CONSUMER_GET_BUFFERED_AMOUNT:
case Channel::ChannelRequest::MethodId::DATA_CONSUMER_GET_BUFFERED_AMOUNT:
{
// This may throw.
RTC::DataConsumer* dataConsumer = GetDataConsumerFromInternal(request->internal);
......@@ -1459,7 +1459,7 @@ namespace RTC
break;
}
case Channel::Request::MethodId::DATA_CONSUMER_SET_BUFFERED_AMOUNT_LOW_THRESHOLD:
case Channel::ChannelRequest::MethodId::DATA_CONSUMER_SET_BUFFERED_AMOUNT_LOW_THRESHOLD:
{
// This may throw.
RTC::DataConsumer* dataConsumer = GetDataConsumerFromInternal(request->internal);
......@@ -1481,13 +1481,13 @@ namespace RTC
}
}
void Transport::HandleRequest(PayloadChannel::Request* request)
void Transport::HandleRequest(PayloadChannel::PayloadChannelRequest* request)
{
MS_TRACE();
switch (request->methodId)
{
case PayloadChannel::Request::MethodId::DATA_CONSUMER_SEND:
case PayloadChannel::PayloadChannelRequest::MethodId::DATA_CONSUMER_SEND:
{
// This may throw.
RTC::DataConsumer* dataConsumer = GetDataConsumerFromInternal(request->internal);
......@@ -2411,7 +2411,7 @@ namespace RTC
packet->FillJson(data["info"]);
Channel::Notifier::Emit(this->id, "trace", data);
Channel::ChannelNotifier::Emit(this->id, "trace", data);
}
inline void Transport::EmitTraceEventBweType(
......@@ -2445,7 +2445,7 @@ namespace RTC
break;
}
Channel::Notifier::Emit(this->id, "trace", data);
Channel::ChannelNotifier::Emit(this->id, "trace", data);
}
inline void Transport::OnProducerPaused(RTC::Producer* producer)
......@@ -2760,7 +2760,7 @@ namespace RTC
data["sctpState"] = "connecting";
Channel::Notifier::Emit(this->id, "sctpstatechange", data);
Channel::ChannelNotifier::Emit(this->id, "sctpstatechange", data);
}
inline void Transport::OnSctpAssociationConnected(RTC::SctpAssociation* /*sctpAssociation*/)
......@@ -2783,7 +2783,7 @@ namespace RTC
data["sctpState"] = "connected";
Channel::Notifier::Emit(this->id, "sctpstatechange", data);
Channel::ChannelNotifier::Emit(this->id, "sctpstatechange", data);
}
inline void Transport::OnSctpAssociationFailed(RTC::SctpAssociation* /*sctpAssociation*/)
......@@ -2806,7 +2806,7 @@ namespace RTC
data["sctpState"] = "failed";
Channel::Notifier::Emit(this->id, "sctpstatechange", data);
Channel::ChannelNotifier::Emit(this->id, "sctpstatechange", data);
}
inline void Transport::OnSctpAssociationClosed(RTC::SctpAssociation* /*sctpAssociation*/)
......@@ -2829,7 +2829,7 @@ namespace RTC
data["sctpState"] = "closed";
Channel::Notifier::Emit(this->id, "sctpstatechange", data);
Channel::ChannelNotifier::Emit(this->id, "sctpstatechange", data);
}
inline void Transport::OnSctpAssociationSendData(
......
......@@ -12,7 +12,7 @@ namespace RTC
UdpSocket::UdpSocket(Listener* listener, std::string& ip)
: // This may throw.
::UdpSocket::UdpSocket(PortManager::BindUdp(ip)), listener(listener)
::UdpSocketHandler::UdpSocketHandler(PortManager::BindUdp(ip)), listener(listener)
{
MS_TRACE();
}
......
......@@ -5,7 +5,7 @@
#include "Logger.hpp"
#include "MediaSoupErrors.hpp"
#include "Utils.hpp"
#include "Channel/Notifier.hpp"
#include "Channel/ChannelNotifier.hpp"
#include <cmath> // std::pow()
namespace RTC
......@@ -425,13 +425,13 @@ namespace RTC
}
}
void WebRtcTransport::HandleRequest(Channel::Request* request)
void WebRtcTransport::HandleRequest(Channel::ChannelRequest* request)
{
MS_TRACE();
switch (request->methodId)
{
case Channel::Request::MethodId::TRANSPORT_CONNECT:
case Channel::ChannelRequest::MethodId::TRANSPORT_CONNECT:
{
// Ensure this method is not called twice.
if (this->connectCalled)
......@@ -561,7 +561,7 @@ namespace RTC
break;
}
case Channel::Request::MethodId::TRANSPORT_RESTART_ICE:
case Channel::ChannelRequest::MethodId::TRANSPORT_RESTART_ICE:
{
std::string usernameFragment = Utils::Crypto::GetRandomString(16);
std::string password = Utils::Crypto::GetRandomString(32);
......@@ -1111,7 +1111,7 @@ namespace RTC
this->iceServer->GetSelectedTuple()->FillJson(data["iceSelectedTuple"]);
Channel::Notifier::Emit(this->id, "iceselectedtuplechange", data);
Channel::ChannelNotifier::Emit(this->id, "iceselectedtuplechange", data);
}
inline void WebRtcTransport::OnIceServerConnected(const RTC::IceServer* /*iceServer*/)
......@@ -1125,7 +1125,7 @@ namespace RTC
data["iceState"] = "connected";
Channel::Notifier::Emit(this->id, "icestatechange", data);
Channel::ChannelNotifier::Emit(this->id, "icestatechange", data);
// If ready, run the DTLS handler.
MayRunDtlsTransport();
......@@ -1148,7 +1148,7 @@ namespace RTC
data["iceState"] = "completed";
Channel::Notifier::Emit(this->id, "icestatechange", data);
Channel::ChannelNotifier::Emit(this->id, "icestatechange", data);
// If ready, run the DTLS handler.
MayRunDtlsTransport();
......@@ -1171,7 +1171,7 @@ namespace RTC
data["iceState"] = "disconnected";
Channel::Notifier::Emit(this->id, "icestatechange", data);
Channel::ChannelNotifier::Emit(this->id, "icestatechange", data);
// If DTLS was already connected, notify the parent class.
if (this->dtlsTransport->GetState() == RTC::DtlsTransport::DtlsState::CONNECTED)
......@@ -1191,7 +1191,7 @@ namespace RTC
data["dtlsState"] = "connecting";
Channel::Notifier::Emit(this->id, "dtlsstatechange", data);
Channel::ChannelNotifier::Emit(this->id, "dtlsstatechange", data);
}
inline void WebRtcTransport::OnDtlsTransportConnected(
......@@ -1235,7 +1235,7 @@ namespace RTC
data["dtlsState"] = "connected";
data["dtlsRemoteCert"] = remoteCert;
Channel::Notifier::Emit(this->id, "dtlsstatechange", data);
Channel::ChannelNotifier::Emit(this->id, "dtlsstatechange", data);
// Tell the parent class.
RTC::Transport::Connected();
......@@ -1260,7 +1260,7 @@ namespace RTC
data["dtlsState"] = "failed";
Channel::Notifier::Emit(this->id, "dtlsstatechange", data);
Channel::ChannelNotifier::Emit(this->id, "dtlsstatechange", data);
}
inline void WebRtcTransport::OnDtlsTransportClosed(const RTC::DtlsTransport* /*dtlsTransport*/)
......@@ -1274,7 +1274,7 @@ namespace RTC
data["dtlsState"] = "closed";
Channel::Notifier::Emit(this->id, "dtlsstatechange", data);
Channel::ChannelNotifier::Emit(this->id, "dtlsstatechange", data);
// Tell the parent class.
RTC::Transport::Disconnected();
......
......@@ -237,13 +237,13 @@ void Settings::PrintConfiguration()
MS_DEBUG_TAG(info, "</configuration>");
}
void Settings::HandleRequest(Channel::Request* request)
void Settings::HandleRequest(Channel::ChannelRequest* request)
{
MS_TRACE();
switch (request->methodId)
{
case Channel::Request::MethodId::WORKER_UPDATE_SETTINGS:
case Channel::ChannelRequest::MethodId::WORKER_UPDATE_SETTINGS:
{
auto jsonLogLevelIt = request->data.find("logLevel");
auto jsonLogTagsIt = request->data.find("logTags");
......
......@@ -6,11 +6,11 @@
#include "Logger.hpp"
#include "MediaSoupErrors.hpp"
#include "Settings.hpp"
#include "Channel/Notifier.hpp"
#include "Channel/ChannelNotifier.hpp"
/* Instance methods. */
Worker::Worker(::Channel::UnixStreamSocket* channel, PayloadChannel::UnixStreamSocket* payloadChannel)
Worker::Worker(::Channel::ChannelSocket* channel, PayloadChannel::PayloadChannelSocket* payloadChannel)
: channel(channel), payloadChannel(payloadChannel)
{
MS_TRACE();
......@@ -33,7 +33,7 @@ Worker::Worker(::Channel::UnixStreamSocket* channel, PayloadChannel::UnixStreamS
#endif
// Tell the Node process that we are running.
Channel::Notifier::Emit(std::to_string(Logger::pid), "running");
Channel::ChannelNotifier::Emit(std::to_string(Logger::pid), "running");
MS_DEBUG_DEV("starting libuv loop");
DepLibUV::RunLoop();
......@@ -192,7 +192,7 @@ RTC::Router* Worker::GetRouterFromInternal(json& internal) const
return router;
}
inline void Worker::OnChannelRequest(Channel::UnixStreamSocket* /*channel*/, Channel::Request* request)
inline void Worker::OnChannelRequest(Channel::ChannelSocket* /*channel*/, Channel::ChannelRequest* request)
{
MS_TRACE();
......@@ -201,7 +201,7 @@ inline void Worker::OnChannelRequest(Channel::UnixStreamSocket* /*channel*/, Cha
switch (request->methodId)
{
case Channel::Request::MethodId::WORKER_CLOSE:
case Channel::ChannelRequest::MethodId::WORKER_CLOSE:
{
if (this->closed)
return;
......@@ -213,7 +213,7 @@ inline void Worker::OnChannelRequest(Channel::UnixStreamSocket* /*channel*/, Cha
break;
}
case Channel::Request::MethodId::WORKER_DUMP:
case Channel::ChannelRequest::MethodId::WORKER_DUMP:
{
json data = json::object();
......@@ -224,7 +224,7 @@ inline void Worker::OnChannelRequest(Channel::UnixStreamSocket* /*channel*/, Cha
break;
}
case Channel::Request::MethodId::WORKER_GET_RESOURCE_USAGE:
case Channel::ChannelRequest::MethodId::WORKER_GET_RESOURCE_USAGE:
{
json data = json::object();
......@@ -235,14 +235,14 @@ inline void Worker::OnChannelRequest(Channel::UnixStreamSocket* /*channel*/, Cha
break;
}
case Channel::Request::MethodId::WORKER_UPDATE_SETTINGS:
case Channel::ChannelRequest::MethodId::WORKER_UPDATE_SETTINGS:
{
Settings::HandleRequest(request);
break;
}
case Channel::Request::MethodId::WORKER_CREATE_ROUTER:
case Channel::ChannelRequest::MethodId::WORKER_CREATE_ROUTER:
{
std::string routerId;
......@@ -260,7 +260,7 @@ inline void Worker::OnChannelRequest(Channel::UnixStreamSocket* /*channel*/, Cha
break;
}
case Channel::Request::MethodId::ROUTER_CLOSE:
case Channel::ChannelRequest::MethodId::ROUTER_CLOSE:
{
// This may throw.
RTC::Router* router = GetRouterFromInternal(request->internal);
......@@ -289,7 +289,7 @@ inline void Worker::OnChannelRequest(Channel::UnixStreamSocket* /*channel*/, Cha
}
}
inline void Worker::OnChannelClosed(Channel::UnixStreamSocket* /*socket*/)
inline void Worker::OnChannelClosed(Channel::ChannelSocket* /*socket*/)
{
MS_TRACE_STD();
......@@ -304,7 +304,7 @@ inline void Worker::OnChannelClosed(Channel::UnixStreamSocket* /*socket*/)
}
inline void Worker::OnPayloadChannelNotification(
PayloadChannel::UnixStreamSocket* /*payloadChannel*/, PayloadChannel::Notification* notification)
PayloadChannel::PayloadChannelSocket* /*payloadChannel*/, PayloadChannel::Notification* notification)
{
MS_TRACE();
......@@ -317,7 +317,8 @@ inline void Worker::OnPayloadChannelNotification(
}
inline void Worker::OnPayloadChannelRequest(
PayloadChannel::UnixStreamSocket* /*payloadChannel*/, PayloadChannel::Request* request)
PayloadChannel::PayloadChannelSocket* /*payloadChannel*/,
PayloadChannel::PayloadChannelRequest* request)
{
MS_TRACE();
......@@ -332,7 +333,7 @@ inline void Worker::OnPayloadChannelRequest(
router->HandleRequest(request);
}
inline void Worker::OnPayloadChannelClosed(PayloadChannel::UnixStreamSocket* /*payloadChannel*/)
inline void Worker::OnPayloadChannelClosed(PayloadChannel::PayloadChannelSocket* /*payloadChannel*/)
{
MS_TRACE();
......
#define MS_CLASS "TcpConnection"
#define MS_CLASS "TcpConnectionHandler"
// #define MS_LOG_DEV_LEVEL 3
#include "handles/TcpConnection.hpp"
#include "handles/TcpConnectionHandler.hpp"
#include "DepLibUV.hpp"
#include "Logger.hpp"
#include "MediaSoupErrors.hpp"
......@@ -12,7 +12,7 @@
inline static void onAlloc(uv_handle_t* handle, size_t suggestedSize, uv_buf_t* buf)
{
auto* connection = static_cast<TcpConnection*>(handle->data);
auto* connection = static_cast<TcpConnectionHandler*>(handle->data);
if (connection)
connection->OnUvReadAlloc(suggestedSize, buf);
......@@ -20,7 +20,7 @@ inline static void onAlloc(uv_handle_t* handle, size_t suggestedSize, uv_buf_t*
inline static void onRead(uv_stream_t* handle, ssize_t nread, const uv_buf_t* buf)
{
auto* connection = static_cast<TcpConnection*>(handle->data);
auto* connection = static_cast<TcpConnectionHandler*>(handle->data);
if (connection)
connection->OnUvRead(nread, buf);
......@@ -28,9 +28,9 @@ inline static void onRead(uv_stream_t* handle, ssize_t nread, const uv_buf_t* bu
inline static void onWrite(uv_write_t* req, int status)
{
auto* writeData = static_cast<TcpConnection::UvWriteData*>(req->data);
auto* writeData = static_cast<TcpConnectionHandler::UvWriteData*>(req->data);
auto* handle = req->handle;
auto* connection = static_cast<TcpConnection*>(handle->data);
auto* connection = static_cast<TcpConnectionHandler*>(handle->data);
auto* cb = writeData->cb;
if (connection)
......@@ -58,7 +58,7 @@ inline static void onShutdown(uv_shutdown_t* req, int /*status*/)
/* Instance methods. */
// NOLINTNEXTLINE(cppcoreguidelines-pro-type-member-init)
TcpConnection::TcpConnection(size_t bufferSize) : bufferSize(bufferSize)
TcpConnectionHandler::TcpConnectionHandler(size_t bufferSize) : bufferSize(bufferSize)
{
MS_TRACE();
......@@ -68,7 +68,7 @@ TcpConnection::TcpConnection(size_t bufferSize) : bufferSize(bufferSize)
// NOTE: Don't allocate the buffer here. Instead wait for the first uv_alloc_cb().
}
TcpConnection::~TcpConnection()
TcpConnectionHandler::~TcpConnectionHandler()
{
MS_TRACE();
......@@ -78,7 +78,7 @@ TcpConnection::~TcpConnection()
delete[] this->buffer;
}
void TcpConnection::Close()
void TcpConnectionHandler::Close()
{
MS_TRACE();
......@@ -89,7 +89,7 @@ void TcpConnection::Close()
this->closed = true;
// Tell the UV handle that the TcpConnection has been closed.
// Tell the UV handle that the TcpConnectionHandler has been closed.
this->uvHandle->data = nullptr;
// Don't read more.
......@@ -118,18 +118,18 @@ void TcpConnection::Close()
}
}
void TcpConnection::Dump() const
void TcpConnectionHandler::Dump() const
{
MS_DUMP("<TcpConnection>");
MS_DUMP("<TcpConnectionHandler>");
MS_DUMP(" localIp : %s", this->localIp.c_str());
MS_DUMP(" localPort : %" PRIu16, static_cast<uint16_t>(this->localPort));
MS_DUMP(" remoteIp : %s", this->peerIp.c_str());
MS_DUMP(" remotePort : %" PRIu16, static_cast<uint16_t>(this->peerPort));
MS_DUMP(" closed : %s", !this->closed ? "open" : "closed");
MS_DUMP("</TcpConnection>");
MS_DUMP("</TcpConnectionHandler>");
}
void TcpConnection::Setup(
void TcpConnectionHandler::Setup(
Listener* listener, struct sockaddr_storage* localAddr, const std::string& localIp, uint16_t localPort)
{
MS_TRACE();
......@@ -154,7 +154,7 @@ void TcpConnection::Setup(
this->localPort = localPort;
}
void TcpConnection::Start()
void TcpConnectionHandler::Start()
{
MS_TRACE();
......@@ -174,7 +174,8 @@ void TcpConnection::Start()
MS_THROW_ERROR("error setting peer IP and port");
}
void TcpConnection::Write(const uint8_t* data, size_t len, TcpConnection::onSendCallback* cb)
void TcpConnectionHandler::Write(
const uint8_t* data, size_t len, TcpConnectionHandler::onSendCallback* cb)
{
MS_TRACE();
......@@ -268,8 +269,12 @@ void TcpConnection::Write(const uint8_t* data, size_t len, TcpConnection::onSend
}
}
void TcpConnection::Write(
const uint8_t* data1, size_t len1, const uint8_t* data2, size_t len2, TcpConnection::onSendCallback* cb)
void TcpConnectionHandler::Write(
const uint8_t* data1,
size_t len1,
const uint8_t* data2,
size_t len2,
TcpConnectionHandler::onSendCallback* cb)
{
MS_TRACE();
......@@ -385,7 +390,7 @@ void TcpConnection::Write(
}
}
void TcpConnection::ErrorReceiving()
void TcpConnectionHandler::ErrorReceiving()
{
MS_TRACE();
......@@ -394,7 +399,7 @@ void TcpConnection::ErrorReceiving()
this->listener->OnTcpConnectionClosed(this);
}
bool TcpConnection::SetPeerAddress()
bool TcpConnectionHandler::SetPeerAddress()
{
MS_TRACE();
......@@ -418,7 +423,7 @@ bool TcpConnection::SetPeerAddress()
return true;
}
inline void TcpConnection::OnUvReadAlloc(size_t /*suggestedSize*/, uv_buf_t* buf)
inline void TcpConnectionHandler::OnUvReadAlloc(size_t /*suggestedSize*/, uv_buf_t* buf)
{
MS_TRACE();
......@@ -442,7 +447,7 @@ inline void TcpConnection::OnUvReadAlloc(size_t /*suggestedSize*/, uv_buf_t* buf
}
}
inline void TcpConnection::OnUvRead(ssize_t nread, const uv_buf_t* /*buf*/)
inline void TcpConnectionHandler::OnUvRead(ssize_t nread, const uv_buf_t* /*buf*/)
{
MS_TRACE();
......@@ -489,7 +494,7 @@ inline void TcpConnection::OnUvRead(ssize_t nread, const uv_buf_t* /*buf*/)
}
}
inline void TcpConnection::OnUvWrite(int status, TcpConnection::onSendCallback* cb)
inline void TcpConnectionHandler::OnUvWrite(int status, TcpConnectionHandler::onSendCallback* cb)
{
MS_TRACE();
......
#define MS_CLASS "TcpServer"
#define MS_CLASS "TcpServerHandler"
// #define MS_LOG_DEV_LEVEL 3
#include "handles/TcpServer.hpp"
#include "handles/TcpServerHandler.hpp"
#include "Logger.hpp"
#include "MediaSoupErrors.hpp"
#include "Utils.hpp"
......@@ -10,7 +10,7 @@
inline static void onConnection(uv_stream_t* handle, int status)
{
auto* server = static_cast<TcpServer*>(handle->data);
auto* server = static_cast<TcpServerHandler*>(handle->data);
if (server)
server->OnUvConnection(status);
......@@ -24,7 +24,7 @@ inline static void onClose(uv_handle_t* handle)
/* Instance methods. */
// NOLINTNEXTLINE(cppcoreguidelines-pro-type-member-init)
TcpServer::TcpServer(uv_tcp_t* uvHandle, int backlog) : uvHandle(uvHandle)
TcpServerHandler::TcpServerHandler(uv_tcp_t* uvHandle, int backlog) : uvHandle(uvHandle)
{
MS_TRACE();
......@@ -53,7 +53,7 @@ TcpServer::TcpServer(uv_tcp_t* uvHandle, int backlog) : uvHandle(uvHandle)
}
}
TcpServer::~TcpServer()
TcpServerHandler::~TcpServerHandler()
{
MS_TRACE();
......@@ -61,7 +61,7 @@ TcpServer::~TcpServer()
Close();
}
void TcpServer::Close()
void TcpServerHandler::Close()
{
MS_TRACE();
......@@ -70,7 +70,7 @@ void TcpServer::Close()
this->closed = true;
// Tell the UV handle that the TcpServer has been closed.
// Tell the UV handle that the TcpServerHandler has been closed.
this->uvHandle->data = nullptr;
MS_DEBUG_DEV("closing %zu active connections", this->connections.size());
......@@ -83,23 +83,23 @@ void TcpServer::Close()
uv_close(reinterpret_cast<uv_handle_t*>(this->uvHandle), static_cast<uv_close_cb>(onClose));
}
void TcpServer::Dump() const
void TcpServerHandler::Dump() const
{
MS_DUMP("<TcpServer>");
MS_DUMP("<TcpServerHandler>");
MS_DUMP(
" [TCP, local:%s :%" PRIu16 ", status:%s, connections:%zu]",
this->localIp.c_str(),
static_cast<uint16_t>(this->localPort),
(!this->closed) ? "open" : "closed",
this->connections.size());
MS_DUMP("</TcpServer>");
MS_DUMP("</TcpServerHandler>");
}
void TcpServer::AcceptTcpConnection(TcpConnection* connection)
void TcpServerHandler::AcceptTcpConnection(TcpConnectionHandler* connection)
{
MS_TRACE();
MS_ASSERT(connection != nullptr, "TcpConnection pointer was not allocated by the user");
MS_ASSERT(connection != nullptr, "TcpConnectionHandler pointer was not allocated by the user");
try
{
......@@ -137,7 +137,7 @@ void TcpServer::AcceptTcpConnection(TcpConnection* connection)
this->connections.insert(connection);
}
bool TcpServer::SetLocalAddress()
bool TcpServerHandler::SetLocalAddress()
{
MS_TRACE();
......@@ -162,7 +162,7 @@ bool TcpServer::SetLocalAddress()
return true;
}
inline void TcpServer::OnUvConnection(int status)
inline void TcpServerHandler::OnUvConnection(int status)
{
MS_TRACE();
......@@ -180,13 +180,13 @@ inline void TcpServer::OnUvConnection(int status)
UserOnTcpConnectionAlloc();
}
inline void TcpServer::OnTcpConnectionClosed(TcpConnection* connection)
inline void TcpServerHandler::OnTcpConnectionClosed(TcpConnectionHandler* connection)
{
MS_TRACE();
MS_DEBUG_DEV("TCP connection closed");
// Remove the TcpConnection from the set.
// Remove the TcpConnectionHandler from the set.
this->connections.erase(connection);
// Notify the subclass.
......
#define MS_CLASS "UdpSocket"
#define MS_CLASS "UdpSocketHandler"
// #define MS_LOG_DEV_LEVEL 3
#include "handles/UdpSocket.hpp"
#include "handles/UdpSocketHandler.hpp"
#include "Logger.hpp"
#include "MediaSoupErrors.hpp"
#include "Utils.hpp"
......@@ -16,7 +16,7 @@ thread_local static uint8_t ReadBuffer[ReadBufferSize];
inline static void onAlloc(uv_handle_t* handle, size_t suggestedSize, uv_buf_t* buf)
{
auto* socket = static_cast<UdpSocket*>(handle->data);
auto* socket = static_cast<UdpSocketHandler*>(handle->data);
if (socket)
socket->OnUvRecvAlloc(suggestedSize, buf);
......@@ -25,7 +25,7 @@ inline static void onAlloc(uv_handle_t* handle, size_t suggestedSize, uv_buf_t*
inline static void onRecv(
uv_udp_t* handle, ssize_t nread, const uv_buf_t* buf, const struct sockaddr* addr, unsigned int flags)
{
auto* socket = static_cast<UdpSocket*>(handle->data);
auto* socket = static_cast<UdpSocketHandler*>(handle->data);
if (socket)
socket->OnUvRecv(nread, buf, addr, flags);
......@@ -33,9 +33,9 @@ inline static void onRecv(
inline static void onSend(uv_udp_send_t* req, int status)
{
auto* sendData = static_cast<UdpSocket::UvSendData*>(req->data);
auto* sendData = static_cast<UdpSocketHandler::UvSendData*>(req->data);
auto* handle = req->handle;
auto* socket = static_cast<UdpSocket*>(handle->data);
auto* socket = static_cast<UdpSocketHandler*>(handle->data);
auto* cb = sendData->cb;
if (socket)
......@@ -53,7 +53,7 @@ inline static void onClose(uv_handle_t* handle)
/* Instance methods. */
// NOLINTNEXTLINE(cppcoreguidelines-pro-type-member-init)
UdpSocket::UdpSocket(uv_udp_t* uvHandle) : uvHandle(uvHandle)
UdpSocketHandler::UdpSocketHandler(uv_udp_t* uvHandle) : uvHandle(uvHandle)
{
MS_TRACE();
......@@ -80,7 +80,7 @@ UdpSocket::UdpSocket(uv_udp_t* uvHandle) : uvHandle(uvHandle)
}
}
UdpSocket::~UdpSocket()
UdpSocketHandler::~UdpSocketHandler()
{
MS_TRACE();
......@@ -88,7 +88,7 @@ UdpSocket::~UdpSocket()
Close();
}
void UdpSocket::Close()
void UdpSocketHandler::Close()
{
MS_TRACE();
......@@ -97,7 +97,7 @@ void UdpSocket::Close()
this->closed = true;
// Tell the UV handle that the UdpSocket has been closed.
// Tell the UV handle that the UdpSocketHandler has been closed.
this->uvHandle->data = nullptr;
// Don't read more.
......@@ -109,17 +109,17 @@ void UdpSocket::Close()
uv_close(reinterpret_cast<uv_handle_t*>(this->uvHandle), static_cast<uv_close_cb>(onClose));
}
void UdpSocket::Dump() const
void UdpSocketHandler::Dump() const
{
MS_DUMP("<UdpSocket>");
MS_DUMP("<UdpSocketHandler>");
MS_DUMP(" localIp : %s", this->localIp.c_str());
MS_DUMP(" localPort : %" PRIu16, static_cast<uint16_t>(this->localPort));
MS_DUMP(" closed : %s", !this->closed ? "open" : "closed");
MS_DUMP("</UdpSocket>");
MS_DUMP("</UdpSocketHandler>");
}
void UdpSocket::Send(
const uint8_t* data, size_t len, const struct sockaddr* addr, UdpSocket::onSendCallback* cb)
void UdpSocketHandler::Send(
const uint8_t* data, size_t len, const struct sockaddr* addr, UdpSocketHandler::onSendCallback* cb)
{
MS_TRACE();
......@@ -216,7 +216,7 @@ void UdpSocket::Send(
}
}
bool UdpSocket::SetLocalAddress()
bool UdpSocketHandler::SetLocalAddress()
{
MS_TRACE();
......@@ -241,7 +241,7 @@ bool UdpSocket::SetLocalAddress()
return true;
}
inline void UdpSocket::OnUvRecvAlloc(size_t /*suggestedSize*/, uv_buf_t* buf)
inline void UdpSocketHandler::OnUvRecvAlloc(size_t /*suggestedSize*/, uv_buf_t* buf)
{
MS_TRACE();
......@@ -251,7 +251,7 @@ inline void UdpSocket::OnUvRecvAlloc(size_t /*suggestedSize*/, uv_buf_t* buf)
buf->len = ReadBufferSize;
}
inline void UdpSocket::OnUvRecv(
inline void UdpSocketHandler::OnUvRecv(
ssize_t nread, const uv_buf_t* buf, const struct sockaddr* addr, unsigned int flags)
{
MS_TRACE();
......@@ -284,7 +284,7 @@ inline void UdpSocket::OnUvRecv(
}
}
inline void UdpSocket::OnUvSend(int status, UdpSocket::onSendCallback* cb)
inline void UdpSocketHandler::OnUvSend(int status, UdpSocketHandler::onSendCallback* cb)
{
MS_TRACE();
......
......@@ -12,10 +12,10 @@
#include "Settings.hpp"
#include "Utils.hpp"
#include "Worker.hpp"
#include "Channel/Notifier.hpp"
#include "Channel/UnixStreamSocket.hpp"
#include "PayloadChannel/Notifier.hpp"
#include "PayloadChannel/UnixStreamSocket.hpp"
#include "Channel/ChannelNotifier.hpp"
#include "Channel/ChannelSocket.hpp"
#include "PayloadChannel/PayloadChannelNotifier.hpp"
#include "PayloadChannel/PayloadChannelSocket.hpp"
#include "RTC/DtlsTransport.hpp"
#include "RTC/SrtpSession.hpp"
#include <uv.h>
......@@ -41,14 +41,14 @@ extern "C" int run_worker(
DepLibUV::ClassInit();
// Channel socket (it will be handled and deleted by the Worker).
Channel::UnixStreamSocket* channel{ nullptr };
Channel::ChannelSocket* channel{ nullptr };
// PayloadChannel socket (it will be handled and deleted by the Worker).
PayloadChannel::UnixStreamSocket* payloadChannel{ nullptr };
PayloadChannel::PayloadChannelSocket* payloadChannel{ nullptr };
try
{
channel = new Channel::UnixStreamSocket(consumerChannelFd, producerChannelFd);
channel = new Channel::ChannelSocket(consumerChannelFd, producerChannelFd);
}
catch (const MediaSoupError& error)
{
......@@ -60,7 +60,7 @@ extern "C" int run_worker(
try
{
payloadChannel =
new PayloadChannel::UnixStreamSocket(payloadConsumeChannelFd, payloadProduceChannelFd);
new PayloadChannel::PayloadChannelSocket(payloadConsumeChannelFd, payloadProduceChannelFd);
}
catch (const MediaSoupError& error)
{
......@@ -121,8 +121,8 @@ extern "C" int run_worker(
Utils::Crypto::ClassInit();
RTC::DtlsTransport::ClassInit();
RTC::SrtpSession::ClassInit();
Channel::Notifier::ClassInit(channel);
PayloadChannel::Notifier::ClassInit(payloadChannel);
Channel::ChannelNotifier::ClassInit(channel);
PayloadChannel::PayloadChannelNotifier::ClassInit(payloadChannel);
#ifdef MS_EXECUTABLE
{
......
Markdown 格式
0% 或
您添加了 0 人 到此讨论。请谨慎行事。
请先完成此评论的编辑!
请 注册 或者 后发表评论