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