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

Use capitalized CamelCase for C++ classes.

上级 80d70719
...@@ -2,7 +2,7 @@ ...@@ -2,7 +2,7 @@
#define MS_RTC_DTLS_TRANSPORT_H #define MS_RTC_DTLS_TRANSPORT_H
#include "common.h" #include "common.h"
#include "RTC/SRTPSession.h" #include "RTC/SrtpSession.h"
#include "handles/Timer.h" #include "handles/Timer.h"
#include <string> #include <string>
#include <map> #include <map>
...@@ -15,7 +15,7 @@ ...@@ -15,7 +15,7 @@
namespace RTC namespace RTC
{ {
class DTLSTransport : class DtlsTransport :
public Timer::Listener public Timer::Listener
{ {
public: public:
...@@ -58,7 +58,7 @@ namespace RTC ...@@ -58,7 +58,7 @@ namespace RTC
private: private:
struct SrtpProfileMapEntry struct SrtpProfileMapEntry
{ {
RTC::SRTPSession::Profile profile; RTC::SrtpSession::Profile profile;
const char* name; const char* name;
}; };
...@@ -69,24 +69,24 @@ namespace RTC ...@@ -69,24 +69,24 @@ namespace RTC
// DTLS is in the process of negotiating a secure connection. Incoming // DTLS is in the process of negotiating a secure connection. Incoming
// media can flow through. // media can flow through.
// NOTE: The caller MUST NOT call any method during this callback. // NOTE: The caller MUST NOT call any method during this callback.
virtual void onDTLSConnecting(DTLSTransport* dtlsTransport) = 0; virtual void onDtlsConnecting(DtlsTransport* dtlsTransport) = 0;
// DTLS has completed negotiation of a secure connection (including DTLS-SRTP // DTLS has completed negotiation of a secure connection (including DTLS-SRTP
// and remote fingerprint verification). Outgoing media can now flow through. // and remote fingerprint verification). Outgoing media can now flow through.
// NOTE: The caller MUST NOT call any method during this callback. // NOTE: The caller MUST NOT call any method during this callback.
virtual void onDTLSConnected(DTLSTransport* dtlsTransport, RTC::SRTPSession::Profile srtp_profile, uint8_t* srtp_local_key, size_t srtp_local_key_len, uint8_t* srtp_remote_key, size_t srtp_remote_key_len) = 0; virtual void onDtlsConnected(DtlsTransport* dtlsTransport, RTC::SrtpSession::Profile srtp_profile, uint8_t* srtp_local_key, size_t srtp_local_key_len, uint8_t* srtp_remote_key, size_t srtp_remote_key_len) = 0;
// The DTLS connection has been closed as the result of an error (such as a // The DTLS connection has been closed as the result of an error (such as a
// DTLS alert or a failure to validate the remote fingerprint). // DTLS alert or a failure to validate the remote fingerprint).
// NOTE: The caller MUST NOT call Close() during this callback. // NOTE: The caller MUST NOT call Close() during this callback.
virtual void onDTLSFailed(DTLSTransport* dtlsTransport) = 0; virtual void onDtlsFailed(DtlsTransport* dtlsTransport) = 0;
// The DTLS connection has been closed due to receipt of a close_notify alert. // The DTLS connection has been closed due to receipt of a close_notify alert.
// NOTE: The caller MUST NOT call Close() during this callback. // NOTE: The caller MUST NOT call Close() during this callback.
virtual void onDTLSClosed(DTLSTransport* dtlsTransport) = 0; virtual void onDtlsClosed(DtlsTransport* dtlsTransport) = 0;
// Need to send DTLS data to the peer. // Need to send DTLS data to the peer.
// NOTE: The caller MUST NOT call Close() during this callback. // NOTE: The caller MUST NOT call Close() during this callback.
virtual void onOutgoingDTLSData(DTLSTransport* dtlsTransport, const uint8_t* data, size_t len) = 0; virtual void onOutgoingDtlsData(DtlsTransport* dtlsTransport, const uint8_t* data, size_t len) = 0;
// DTLS application data received. // DTLS application data received.
// NOTE: The caller MUST NOT call Close() during this callback. // NOTE: The caller MUST NOT call Close() during this callback.
virtual void onDTLSApplicationData(DTLSTransport* dtlsTransport, const uint8_t* data, size_t len) = 0; virtual void onDtlsApplicationData(DtlsTransport* dtlsTransport, const uint8_t* data, size_t len) = 0;
}; };
public: public:
...@@ -95,7 +95,7 @@ namespace RTC ...@@ -95,7 +95,7 @@ namespace RTC
static Json::Value& GetLocalFingerprints(); static Json::Value& GetLocalFingerprints();
static Role StringToRole(std::string role); static Role StringToRole(std::string role);
static FingerprintAlgorithm GetFingerprintAlgorithm(std::string fingerprint); static FingerprintAlgorithm GetFingerprintAlgorithm(std::string fingerprint);
static bool IsDTLS(const uint8_t* data, size_t len); static bool IsDtls(const uint8_t* data, size_t len);
private: private:
static void GenerateCertificateAndPrivateKey(); static void GenerateCertificateAndPrivateKey();
...@@ -114,14 +114,14 @@ namespace RTC ...@@ -114,14 +114,14 @@ namespace RTC
static std::vector<SrtpProfileMapEntry> srtpProfiles; static std::vector<SrtpProfileMapEntry> srtpProfiles;
public: public:
DTLSTransport(Listener* listener); DtlsTransport(Listener* listener);
virtual ~DTLSTransport(); virtual ~DtlsTransport();
void Close(); void Close();
void Dump(); void Dump();
void Run(Role localRole); void Run(Role localRole);
void SetRemoteFingerprint(Fingerprint fingerprint); void SetRemoteFingerprint(Fingerprint fingerprint);
void ProcessDTLSData(const uint8_t* data, size_t len); void ProcessDtlsData(const uint8_t* data, size_t len);
DtlsState GetState(); DtlsState GetState();
Role GetLocalRole(); Role GetLocalRole();
void SendApplicationData(const uint8_t* data, size_t len); void SendApplicationData(const uint8_t* data, size_t len);
...@@ -130,12 +130,12 @@ namespace RTC ...@@ -130,12 +130,12 @@ namespace RTC
bool IsRunning(); bool IsRunning();
void Reset(); void Reset();
bool CheckStatus(int return_code); bool CheckStatus(int return_code);
void SendPendingOutgoingDTLSData(); void SendPendingOutgoingDtlsData();
bool SetTimeout(); bool SetTimeout();
void ProcessHandshake(); void ProcessHandshake();
bool CheckRemoteFingerprint(); bool CheckRemoteFingerprint();
void ExtractSRTPKeys(RTC::SRTPSession::Profile srtp_profile); void ExtractSrtpKeys(RTC::SrtpSession::Profile srtp_profile);
RTC::SRTPSession::Profile GetNegotiatedSRTPProfile(); RTC::SrtpSession::Profile GetNegotiatedSrtpProfile();
/* Callbacks fired by OpenSSL events. */ /* Callbacks fired by OpenSSL events. */
public: public:
...@@ -164,35 +164,35 @@ namespace RTC ...@@ -164,35 +164,35 @@ namespace RTC
/* Inline static methods. */ /* Inline static methods. */
inline inline
Json::Value& DTLSTransport::GetLocalFingerprints() Json::Value& DtlsTransport::GetLocalFingerprints()
{ {
return DTLSTransport::localFingerprints; return DtlsTransport::localFingerprints;
} }
inline inline
DTLSTransport::Role DTLSTransport::StringToRole(std::string role) DtlsTransport::Role DtlsTransport::StringToRole(std::string role)
{ {
auto it = DTLSTransport::string2Role.find(role); auto it = DtlsTransport::string2Role.find(role);
if (it != DTLSTransport::string2Role.end()) if (it != DtlsTransport::string2Role.end())
return it->second; return it->second;
else else
return DTLSTransport::Role::NONE; return DtlsTransport::Role::NONE;
} }
inline inline
DTLSTransport::FingerprintAlgorithm DTLSTransport::GetFingerprintAlgorithm(std::string fingerprint) DtlsTransport::FingerprintAlgorithm DtlsTransport::GetFingerprintAlgorithm(std::string fingerprint)
{ {
auto it = DTLSTransport::string2FingerprintAlgorithm.find(fingerprint); auto it = DtlsTransport::string2FingerprintAlgorithm.find(fingerprint);
if (it != DTLSTransport::string2FingerprintAlgorithm.end()) if (it != DtlsTransport::string2FingerprintAlgorithm.end())
return it->second; return it->second;
else else
return DTLSTransport::FingerprintAlgorithm::NONE; return DtlsTransport::FingerprintAlgorithm::NONE;
} }
inline inline
bool DTLSTransport::IsDTLS(const uint8_t* data, size_t len) bool DtlsTransport::IsDtls(const uint8_t* data, size_t len)
{ {
return ( return (
// Minimum DTLS record length is 13 bytes. // Minimum DTLS record length is 13 bytes.
...@@ -205,7 +205,7 @@ namespace RTC ...@@ -205,7 +205,7 @@ namespace RTC
/* Inline instance methods. */ /* Inline instance methods. */
inline inline
bool DTLSTransport::IsRunning() bool DtlsTransport::IsRunning()
{ {
switch (this->state) switch (this->state)
{ {
...@@ -224,13 +224,13 @@ namespace RTC ...@@ -224,13 +224,13 @@ namespace RTC
} }
inline inline
DTLSTransport::DtlsState DTLSTransport::GetState() DtlsTransport::DtlsState DtlsTransport::GetState()
{ {
return this->state; return this->state;
} }
inline inline
DTLSTransport::Role DTLSTransport::GetLocalRole() DtlsTransport::Role DtlsTransport::GetLocalRole()
{ {
return this->localRole; return this->localRole;
} }
......
...@@ -2,8 +2,8 @@ ...@@ -2,8 +2,8 @@
#define MS_RTC_ICE_CANDIDATE_H #define MS_RTC_ICE_CANDIDATE_H
#include "common.h" #include "common.h"
#include "RTC/UDPSocket.h" #include "RTC/UdpSocket.h"
#include "RTC/TCPServer.h" #include "RTC/TcpServer.h"
#include <string> #include <string>
#include <json/json.h> #include <json/json.h>
...@@ -31,8 +31,8 @@ namespace RTC ...@@ -31,8 +31,8 @@ namespace RTC
}; };
public: public:
IceCandidate(RTC::UDPSocket* udpSocket, uint32_t priority); IceCandidate(RTC::UdpSocket* udpSocket, uint32_t priority);
IceCandidate(RTC::TCPServer* tcpServer, uint32_t priority); IceCandidate(RTC::TcpServer* tcpServer, uint32_t priority);
Json::Value toJson(); Json::Value toJson();
......
#ifndef MS_RTC_ICE_SERVER_H #ifndef MS_RTC_Ice_SERVER_H
#define MS_RTC_ICE_SERVER_H #define MS_RTC_Ice_SERVER_H
#include "common.h" #include "common.h"
#include "RTC/STUNMessage.h" #include "RTC/StunMessage.h"
#include "RTC/TransportTuple.h" #include "RTC/TransportTuple.h"
#include <string> #include <string>
#include <list> #include <list>
namespace RTC namespace RTC
{ {
class ICEServer class IceServer
{ {
public: public:
enum class IceState enum class IceState
...@@ -25,21 +25,21 @@ namespace RTC ...@@ -25,21 +25,21 @@ namespace RTC
{ {
public: public:
/** /**
* These callbacks are guaranteed to be called before ProcessSTUNMessage() * These callbacks are guaranteed to be called before ProcessStunMessage()
* returns, so the given pointers are still usable. * returns, so the given pointers are still usable.
*/ */
virtual void onOutgoingSTUNMessage(ICEServer* iceServer, RTC::STUNMessage* msg, RTC::TransportTuple* tuple) = 0; virtual void onOutgoingStunMessage(IceServer* iceServer, RTC::StunMessage* msg, RTC::TransportTuple* tuple) = 0;
virtual void onICESelectedTuple(ICEServer* iceServer, RTC::TransportTuple* tuple) = 0; virtual void onIceSelectedTuple(IceServer* iceServer, RTC::TransportTuple* tuple) = 0;
virtual void onICEConnected(ICEServer* iceServer) = 0; virtual void onIceConnected(IceServer* iceServer) = 0;
virtual void onICECompleted(ICEServer* iceServer) = 0; virtual void onIceCompleted(IceServer* iceServer) = 0;
virtual void onICEDisconnected(ICEServer* iceServer) = 0; virtual void onIceDisconnected(IceServer* iceServer) = 0;
}; };
public: public:
ICEServer(Listener* listener, const std::string& usernameFragment, const std::string password); IceServer(Listener* listener, const std::string& usernameFragment, const std::string password);
void Close(); void Close();
void ProcessSTUNMessage(RTC::STUNMessage* msg, RTC::TransportTuple* tuple); void ProcessStunMessage(RTC::StunMessage* msg, RTC::TransportTuple* tuple);
std::string& GetUsernameFragment(); std::string& GetUsernameFragment();
std::string& GetPassword(); std::string& GetPassword();
IceState GetState(); IceState GetState();
...@@ -79,19 +79,19 @@ namespace RTC ...@@ -79,19 +79,19 @@ namespace RTC
/* Inline methods. */ /* Inline methods. */
inline inline
std::string& ICEServer::GetUsernameFragment() std::string& IceServer::GetUsernameFragment()
{ {
return this->usernameFragment; return this->usernameFragment;
} }
inline inline
std::string& ICEServer::GetPassword() std::string& IceServer::GetPassword()
{ {
return this->password; return this->password;
} }
inline inline
ICEServer::IceState ICEServer::GetState() IceServer::IceState IceServer::GetState()
{ {
return this->state; return this->state;
} }
......
...@@ -5,7 +5,7 @@ ...@@ -5,7 +5,7 @@
namespace RTC namespace RTC
{ {
class RTCPPacket class RtcpPacket
{ {
public: public:
/* Struct for RTCP common header. */ /* Struct for RTCP common header. */
...@@ -25,12 +25,12 @@ namespace RTC ...@@ -25,12 +25,12 @@ namespace RTC
}; };
public: public:
static bool IsRTCP(const uint8_t* data, size_t len); static bool IsRtcp(const uint8_t* data, size_t len);
static RTCPPacket* Parse(const uint8_t* data, size_t len); static RtcpPacket* Parse(const uint8_t* data, size_t len);
public: public:
RTCPPacket(CommonHeader* header, const uint8_t* raw, size_t length); RtcpPacket(CommonHeader* header, const uint8_t* raw, size_t length);
~RTCPPacket(); ~RtcpPacket();
const uint8_t* GetRaw(); const uint8_t* GetRaw();
size_t GetLength(); size_t GetLength();
...@@ -45,7 +45,7 @@ namespace RTC ...@@ -45,7 +45,7 @@ namespace RTC
/* Inline static methods. */ /* Inline static methods. */
inline inline
bool RTCPPacket::IsRTCP(const uint8_t* data, size_t len) bool RtcpPacket::IsRtcp(const uint8_t* data, size_t len)
{ {
CommonHeader* header = (CommonHeader*)data; CommonHeader* header = (CommonHeader*)data;
...@@ -65,13 +65,13 @@ namespace RTC ...@@ -65,13 +65,13 @@ namespace RTC
/* Inline instance methods. */ /* Inline instance methods. */
inline inline
const uint8_t* RTCPPacket::GetRaw() const uint8_t* RtcpPacket::GetRaw()
{ {
return this->raw; return this->raw;
} }
inline inline
size_t RTCPPacket::GetLength() size_t RtcpPacket::GetLength()
{ {
return this->length; return this->length;
} }
......
...@@ -4,7 +4,7 @@ ...@@ -4,7 +4,7 @@
#include "common.h" #include "common.h"
#include "RTC/RtpReceiver.h" #include "RTC/RtpReceiver.h"
#include "RTC/RtpParameters.h" #include "RTC/RtpParameters.h"
#include "RTC/RTPPacket.h" #include "RTC/RtpPacket.h"
#include <unordered_map> #include <unordered_map>
#include <json/json.h> #include <json/json.h>
...@@ -19,7 +19,7 @@ namespace RTC ...@@ -19,7 +19,7 @@ namespace RTC
Json::Value toJson(); Json::Value toJson();
void AddRtpReceiver(RTC::RtpReceiver *rtpReceiver, RTC::RtpParameters* rtpParameters); void AddRtpReceiver(RTC::RtpReceiver *rtpReceiver, RTC::RtpParameters* rtpParameters);
void RemoveRtpReceiver(RTC::RtpReceiver* rtpReceiver); void RemoveRtpReceiver(RTC::RtpReceiver* rtpReceiver);
RTC::RtpReceiver* GetRtpReceiver(RTC::RTPPacket* packet); RTC::RtpReceiver* GetRtpReceiver(RTC::RtpPacket* packet);
private: private:
// Others. // Others.
......
...@@ -5,7 +5,7 @@ ...@@ -5,7 +5,7 @@
namespace RTC namespace RTC
{ {
class RTPPacket class RtpPacket
{ {
public: public:
/* Struct for RTP header. */ /* Struct for RTP header. */
...@@ -40,12 +40,12 @@ namespace RTC ...@@ -40,12 +40,12 @@ namespace RTC
}; };
public: public:
static bool IsRTP(const uint8_t* data, size_t len); static bool IsRtp(const uint8_t* data, size_t len);
static RTPPacket* Parse(const uint8_t* data, size_t len); static RtpPacket* Parse(const uint8_t* data, size_t len);
public: public:
RTPPacket(Header* header, ExtensionHeader* extensionHeader, const uint8_t* payload, size_t payloadLen, uint8_t payloadPadding, const uint8_t* raw, size_t length); RtpPacket(Header* header, ExtensionHeader* extensionHeader, const uint8_t* payload, size_t payloadLen, uint8_t payloadPadding, const uint8_t* raw, size_t length);
~RTPPacket(); ~RtpPacket();
void Dump(); void Dump();
const uint8_t* GetRaw(); const uint8_t* GetRaw();
...@@ -56,8 +56,8 @@ namespace RTC ...@@ -56,8 +56,8 @@ namespace RTC
void SetMarker(bool marker); void SetMarker(bool marker);
uint16_t GetSequenceNumber(); uint16_t GetSequenceNumber();
uint32_t GetTimestamp(); uint32_t GetTimestamp();
uint32_t GetSSRC(); uint32_t GetSsrc();
void SetSSRC(uint32_t ssrc); // TODO: yes? void SetSsrc(uint32_t ssrc); // TODO: yes?
bool HasExtensionHeader(); bool HasExtensionHeader();
uint16_t GetExtensionHeaderId(); uint16_t GetExtensionHeaderId();
size_t GetExtensionHeaderLength(); size_t GetExtensionHeaderLength();
...@@ -82,9 +82,9 @@ namespace RTC ...@@ -82,9 +82,9 @@ namespace RTC
/* Inline static methods. */ /* Inline static methods. */
inline inline
bool RTPPacket::IsRTP(const uint8_t* data, size_t len) bool RtpPacket::IsRtp(const uint8_t* data, size_t len)
{ {
// NOTE: RTCPPacket::IsRTCP() must always be called before this method. // NOTE: RtcpPacket::IsRtcp() must always be called before this method.
Header* header = (Header*)data; Header* header = (Header*)data;
...@@ -100,74 +100,74 @@ namespace RTC ...@@ -100,74 +100,74 @@ namespace RTC
/* Inline instance methods. */ /* Inline instance methods. */
inline inline
const uint8_t* RTPPacket::GetRaw() const uint8_t* RtpPacket::GetRaw()
{ {
return this->raw; return this->raw;
} }
inline inline
size_t RTPPacket::GetLength() size_t RtpPacket::GetLength()
{ {
return this->length; return this->length;
} }
inline inline
uint8_t RTPPacket::GetPayloadType() uint8_t RtpPacket::GetPayloadType()
{ {
return this->header->payload_type; return this->header->payload_type;
} }
inline inline
void RTPPacket::SetPayloadType(uint8_t payload_type) void RtpPacket::SetPayloadType(uint8_t payload_type)
{ {
this->header->payload_type = payload_type; this->header->payload_type = payload_type;
} }
inline inline
bool RTPPacket::HasMarker() bool RtpPacket::HasMarker()
{ {
return this->header->marker; return this->header->marker;
} }
inline inline
void RTPPacket::SetMarker(bool marker) void RtpPacket::SetMarker(bool marker)
{ {
this->header->marker = marker; this->header->marker = marker;
} }
inline inline
uint16_t RTPPacket::GetSequenceNumber() uint16_t RtpPacket::GetSequenceNumber()
{ {
return (uint16_t)ntohs(this->header->sequence_number); return (uint16_t)ntohs(this->header->sequence_number);
} }
inline inline
uint32_t RTPPacket::GetTimestamp() uint32_t RtpPacket::GetTimestamp()
{ {
return (uint32_t)ntohl(this->header->timestamp); return (uint32_t)ntohl(this->header->timestamp);
} }
inline inline
uint32_t RTPPacket::GetSSRC() uint32_t RtpPacket::GetSsrc()
{ {
return (uint32_t)ntohl(this->header->ssrc); return (uint32_t)ntohl(this->header->ssrc);
} }
// TODO temp // TODO temp
inline inline
void RTPPacket::SetSSRC(uint32_t ssrc) void RtpPacket::SetSsrc(uint32_t ssrc)
{ {
this->header->ssrc = htonl(ssrc); this->header->ssrc = htonl(ssrc);
} }
inline inline
bool RTPPacket::HasExtensionHeader() bool RtpPacket::HasExtensionHeader()
{ {
return (this->extensionHeader ? true : false); return (this->extensionHeader ? true : false);
} }
inline inline
uint16_t RTPPacket::GetExtensionHeaderId() uint16_t RtpPacket::GetExtensionHeaderId()
{ {
if (this->extensionHeader) if (this->extensionHeader)
return uint16_t(ntohs(this->extensionHeader->id)); return uint16_t(ntohs(this->extensionHeader->id));
...@@ -176,7 +176,7 @@ namespace RTC ...@@ -176,7 +176,7 @@ namespace RTC
} }
inline inline
size_t RTPPacket::GetExtensionHeaderLength() size_t RtpPacket::GetExtensionHeaderLength()
{ {
if (this->extensionHeader) if (this->extensionHeader)
return size_t(ntohs(this->extensionHeader->length) * 4); return size_t(ntohs(this->extensionHeader->length) * 4);
...@@ -185,13 +185,13 @@ namespace RTC ...@@ -185,13 +185,13 @@ namespace RTC
} }
inline inline
uint8_t* RTPPacket::GetPayload() uint8_t* RtpPacket::GetPayload()
{ {
return this->payload; return this->payload;
} }
inline inline
size_t RTPPacket::GetPayloadLength() size_t RtpPacket::GetPayloadLength()
{ {
return this->payloadLength; return this->payloadLength;
} }
......
...@@ -7,7 +7,7 @@ ...@@ -7,7 +7,7 @@
namespace RTC namespace RTC
{ {
class SRTPSession class SrtpSession
{ {
public: public:
enum class Profile enum class Profile
...@@ -28,19 +28,19 @@ namespace RTC ...@@ -28,19 +28,19 @@ namespace RTC
static void ClassInit(); static void ClassInit();
// private: // private:
// static void onSRTPEvent(srtp_event_data_t* data); // static void onSrtpEvent(srtp_event_data_t* data);
private: private:
static uint8_t encryptBuffer[]; static uint8_t encryptBuffer[];
public: public:
SRTPSession(Type type, Profile profile, uint8_t* key, size_t key_len); SrtpSession(Type type, Profile profile, uint8_t* key, size_t key_len);
~SRTPSession(); ~SrtpSession();
bool EncryptRTP(const uint8_t** data, size_t* len); bool EncryptRtp(const uint8_t** data, size_t* len);
bool DecryptSRTP(const uint8_t* data, size_t* len); bool DecryptSrtp(const uint8_t* data, size_t* len);
bool EncryptRTCP(const uint8_t** data, size_t* len); bool EncryptRtcp(const uint8_t** data, size_t* len);
bool DecryptSRTCP(const uint8_t* data, size_t* len); bool DecryptSrtcp(const uint8_t* data, size_t* len);
const char* GetLastErrorDesc(); const char* GetLastErrorDesc();
void Close(); void Close();
...@@ -54,7 +54,7 @@ namespace RTC ...@@ -54,7 +54,7 @@ namespace RTC
/* Inline instance methods. */ /* Inline instance methods. */
inline inline
const char* SRTPSession::GetLastErrorDesc() const char* SrtpSession::GetLastErrorDesc()
{ {
const char* error_string; const char* error_string;
......
...@@ -6,7 +6,7 @@ ...@@ -6,7 +6,7 @@
namespace RTC namespace RTC
{ {
class STUNMessage class StunMessage
{ {
public: public:
// STUN message class. // STUN message class.
...@@ -53,15 +53,15 @@ namespace RTC ...@@ -53,15 +53,15 @@ namespace RTC
}; };
public: public:
static bool IsSTUN(const uint8_t* data, size_t len); static bool IsStun(const uint8_t* data, size_t len);
static STUNMessage* Parse(const uint8_t* data, size_t len); static StunMessage* Parse(const uint8_t* data, size_t len);
private: private:
static const uint8_t magicCookie[]; static const uint8_t magicCookie[];
public: public:
STUNMessage(Class klass, Method method, const uint8_t* transactionId, const uint8_t* raw, size_t length); StunMessage(Class klass, Method method, const uint8_t* transactionId, const uint8_t* raw, size_t length);
~STUNMessage(); ~StunMessage();
void Dump(); void Dump();
Class GetClass(); Class GetClass();
...@@ -87,8 +87,8 @@ namespace RTC ...@@ -87,8 +87,8 @@ namespace RTC
bool HasMessageIntegrity(); bool HasMessageIntegrity();
bool HasFingerprint(); bool HasFingerprint();
Authentication CheckAuthentication(const std::string &local_username, const std::string &local_password); Authentication CheckAuthentication(const std::string &local_username, const std::string &local_password);
STUNMessage* CreateSuccessResponse(); StunMessage* CreateSuccessResponse();
STUNMessage* CreateErrorResponse(uint16_t errorCode); StunMessage* CreateErrorResponse(uint16_t errorCode);
void Authenticate(const std::string &password); void Authenticate(const std::string &password);
void Serialize(); void Serialize();
...@@ -117,7 +117,7 @@ namespace RTC ...@@ -117,7 +117,7 @@ namespace RTC
/* Inline methods. */ /* Inline methods. */
inline inline
bool STUNMessage::IsSTUN(const uint8_t* data, size_t len) bool StunMessage::IsStun(const uint8_t* data, size_t len)
{ {
return ( return (
// STUN headers are 20 bytes. // STUN headers are 20 bytes.
...@@ -125,147 +125,147 @@ namespace RTC ...@@ -125,147 +125,147 @@ namespace RTC
// DOC: https://tools.ietf.org/html/draft-petithuguenin-avtcore-rfc5764-mux-fixes-00 // DOC: https://tools.ietf.org/html/draft-petithuguenin-avtcore-rfc5764-mux-fixes-00
(data[0] < 20) && (data[0] < 20) &&
// Magic cookie must match. // Magic cookie must match.
(data[4] == STUNMessage::magicCookie[0]) && (data[4] == StunMessage::magicCookie[0]) &&
(data[5] == STUNMessage::magicCookie[1]) && (data[5] == StunMessage::magicCookie[1]) &&
(data[6] == STUNMessage::magicCookie[2]) && (data[6] == StunMessage::magicCookie[2]) &&
(data[7] == STUNMessage::magicCookie[3]) (data[7] == StunMessage::magicCookie[3])
); );
} }
inline inline
STUNMessage::Class STUNMessage::GetClass() StunMessage::Class StunMessage::GetClass()
{ {
return this->klass; return this->klass;
} }
inline inline
STUNMessage::Method STUNMessage::GetMethod() StunMessage::Method StunMessage::GetMethod()
{ {
return this->method; return this->method;
} }
inline inline
const uint8_t* STUNMessage::GetRaw() const uint8_t* StunMessage::GetRaw()
{ {
return this->raw; return this->raw;
} }
inline inline
void STUNMessage::SetLength(size_t length) void StunMessage::SetLength(size_t length)
{ {
this->length = length; this->length = length;
} }
inline inline
size_t STUNMessage::GetLength() size_t StunMessage::GetLength()
{ {
return this->length; return this->length;
} }
inline inline
void STUNMessage::SetUsername(const char* username, size_t len) void StunMessage::SetUsername(const char* username, size_t len)
{ {
if (this->username.empty()) if (this->username.empty())
this->username = std::string(username, len); this->username = std::string(username, len);
} }
inline inline
void STUNMessage::SetPriority(const uint32_t priority) void StunMessage::SetPriority(const uint32_t priority)
{ {
if (!this->priority) if (!this->priority)
this->priority = priority; this->priority = priority;
} }
inline inline
void STUNMessage::SetIceControlling(const uint64_t iceControlling) void StunMessage::SetIceControlling(const uint64_t iceControlling)
{ {
if (!this->iceControlling) if (!this->iceControlling)
this->iceControlling = iceControlling; this->iceControlling = iceControlling;
} }
inline inline
void STUNMessage::SetIceControlled(const uint64_t iceControlled) void StunMessage::SetIceControlled(const uint64_t iceControlled)
{ {
if (!this->iceControlled) if (!this->iceControlled)
this->iceControlled = iceControlled; this->iceControlled = iceControlled;
} }
inline inline
void STUNMessage::SetUseCandidate() void StunMessage::SetUseCandidate()
{ {
this->hasUseCandidate = true; this->hasUseCandidate = true;
} }
inline inline
void STUNMessage::SetXorMappedAddress(const struct sockaddr* xorMappedAddress) void StunMessage::SetXorMappedAddress(const struct sockaddr* xorMappedAddress)
{ {
if (!this->xorMappedAddress) if (!this->xorMappedAddress)
this->xorMappedAddress = xorMappedAddress; this->xorMappedAddress = xorMappedAddress;
} }
inline inline
void STUNMessage::SetErrorCode(uint16_t errorCode) void StunMessage::SetErrorCode(uint16_t errorCode)
{ {
this->errorCode = errorCode; this->errorCode = errorCode;
} }
inline inline
void STUNMessage::SetMessageIntegrity(const uint8_t* messageIntegrity) void StunMessage::SetMessageIntegrity(const uint8_t* messageIntegrity)
{ {
if (!this->messageIntegrity) if (!this->messageIntegrity)
this->messageIntegrity = messageIntegrity; this->messageIntegrity = messageIntegrity;
} }
inline inline
void STUNMessage::SetFingerprint() void StunMessage::SetFingerprint()
{ {
this->hasFingerprint = true; this->hasFingerprint = true;
} }
inline inline
const std::string& STUNMessage::GetUsername() const std::string& StunMessage::GetUsername()
{ {
return this->username; return this->username;
} }
inline inline
const uint32_t STUNMessage::GetPriority() const uint32_t StunMessage::GetPriority()
{ {
return this->priority; return this->priority;
} }
inline inline
const uint64_t STUNMessage::GetIceControlling() const uint64_t StunMessage::GetIceControlling()
{ {
return this->iceControlling; return this->iceControlling;
} }
inline inline
const uint64_t STUNMessage::GetIceControlled() const uint64_t StunMessage::GetIceControlled()
{ {
return this->iceControlled; return this->iceControlled;
} }
inline inline
bool STUNMessage::HasUseCandidate() bool StunMessage::HasUseCandidate()
{ {
return this->hasUseCandidate; return this->hasUseCandidate;
} }
inline inline
uint16_t STUNMessage::GetErrorCode() uint16_t StunMessage::GetErrorCode()
{ {
return this->errorCode; return this->errorCode;
} }
inline inline
bool STUNMessage::HasMessageIntegrity() bool StunMessage::HasMessageIntegrity()
{ {
return (this->messageIntegrity ? true : false); return (this->messageIntegrity ? true : false);
} }
inline inline
bool STUNMessage::HasFingerprint() bool StunMessage::HasFingerprint()
{ {
return this->hasFingerprint; return this->hasFingerprint;
} }
......
...@@ -2,29 +2,29 @@ ...@@ -2,29 +2,29 @@
#define MS_RTC_TCP_CONNECTION_H #define MS_RTC_TCP_CONNECTION_H
#include "common.h" #include "common.h"
#include "handles/TCPConnection.h" #include "handles/TcpConnection.h"
namespace RTC namespace RTC
{ {
class TCPConnection : class TcpConnection :
public ::TCPConnection public ::TcpConnection
{ {
public: public:
class Listener class Listener
{ {
public: public:
virtual void onPacketRecv(RTC::TCPConnection *connection, const uint8_t* data, size_t len) = 0; virtual void onPacketRecv(RTC::TcpConnection *connection, const uint8_t* data, size_t len) = 0;
}; };
public: public:
TCPConnection(Listener* listener, size_t bufferSize); TcpConnection(Listener* listener, size_t bufferSize);
virtual ~TCPConnection(); virtual ~TcpConnection();
void Send(const uint8_t* data, size_t len); void Send(const uint8_t* data, size_t len);
/* Pure virtual methods inherited from ::TCPConnection. */ /* Pure virtual methods inherited from ::TcpConnection. */
public: public:
virtual void userOnTCPConnectionRead() override; virtual void userOnTcpConnectionRead() override;
private: private:
// Passed by argument. // Passed by argument.
......
...@@ -2,22 +2,22 @@ ...@@ -2,22 +2,22 @@
#define MS_RTC_TCP_SERVER_H #define MS_RTC_TCP_SERVER_H
#include "common.h" #include "common.h"
#include "handles/TCPServer.h" #include "handles/TcpServer.h"
#include "handles/TCPConnection.h" #include "handles/TcpConnection.h"
#include "RTC/TCPConnection.h" #include "RTC/TcpConnection.h"
#include <unordered_map> #include <unordered_map>
#include <uv.h> #include <uv.h>
namespace RTC namespace RTC
{ {
class TCPServer : class TcpServer :
public ::TCPServer public ::TcpServer
{ {
public: public:
class Listener class Listener
{ {
public: public:
virtual void onRTCTCPConnectionClosed(RTC::TCPServer* tcpServer, RTC::TCPConnection* connection, bool is_closed_by_peer) = 0; virtual void onRtcTcpConnectionClosed(RTC::TcpServer* tcpServer, RTC::TcpConnection* connection, bool is_closed_by_peer) = 0;
}; };
public: public:
...@@ -35,19 +35,19 @@ namespace RTC ...@@ -35,19 +35,19 @@ namespace RTC
static std::unordered_map<uint16_t, bool> availableIPv6Ports; static std::unordered_map<uint16_t, bool> availableIPv6Ports;
public: public:
TCPServer(Listener* listener, RTC::TCPConnection::Listener* connListener, int address_family); TcpServer(Listener* listener, RTC::TcpConnection::Listener* connListener, int address_family);
/* Pure virtual methods inherited from ::TCPServer. */ /* Pure virtual methods inherited from ::TcpServer. */
public: public:
virtual void userOnTCPConnectionAlloc(::TCPConnection** connection) override; virtual void userOnTcpConnectionAlloc(::TcpConnection** connection) override;
virtual void userOnNewTCPConnection(::TCPConnection* connection) override; virtual void userOnNewTcpConnection(::TcpConnection* connection) override;
virtual void userOnTCPConnectionClosed(::TCPConnection* connection, bool is_closed_by_peer) override; virtual void userOnTcpConnectionClosed(::TcpConnection* connection, bool is_closed_by_peer) override;
virtual void userOnTCPServerClosed() override; virtual void userOnTcpServerClosed() override;
private: private:
// Passed by argument. // Passed by argument.
Listener* listener = nullptr; Listener* listener = nullptr;
RTC::TCPConnection::Listener* connListener = nullptr; RTC::TcpConnection::Listener* connListener = nullptr;
}; };
} }
......
...@@ -2,18 +2,15 @@ ...@@ -2,18 +2,15 @@
#define MS_RTC_TRANSPORT_H #define MS_RTC_TRANSPORT_H
#include "common.h" #include "common.h"
#include "RTC/UDPSocket.h" #include "RTC/UdpSocket.h"
#include "RTC/TCPServer.h" #include "RTC/TcpServer.h"
#include "RTC/TCPConnection.h" #include "RTC/TcpConnection.h"
#include "RTC/IceCandidate.h" #include "RTC/IceCandidate.h"
#include "RTC/ICEServer.h" #include "RTC/IceServer.h"
#include "RTC/STUNMessage.h" #include "RTC/StunMessage.h"
#include "RTC/TransportTuple.h" #include "RTC/TransportTuple.h"
#include "RTC/DTLSTransport.h" #include "RTC/DtlsTransport.h"
#include "RTC/RTPPacket.h"
#include "RTC/RTCPPacket.h"
#include "RTC/RtpListener.h" #include "RTC/RtpListener.h"
#include "RTC/RtpReceiver.h" // TODO: let's see if needed here or not
#include "Channel/Request.h" #include "Channel/Request.h"
#include "Channel/Notifier.h" #include "Channel/Notifier.h"
#include <string> #include <string>
...@@ -24,12 +21,11 @@ ...@@ -24,12 +21,11 @@
namespace RTC namespace RTC
{ {
class Transport : class Transport :
public RTC::UDPSocket::Listener, public RTC::UdpSocket::Listener,
public RTC::TCPServer::Listener, public RTC::TcpServer::Listener,
public RTC::TCPConnection::Listener, public RTC::TcpConnection::Listener,
public RTC::ICEServer::Listener, public RTC::IceServer::Listener,
public RTC::DTLSTransport::Listener, public RTC::DtlsTransport::Listener,
// Transport is also a RtpListener.
public RTC::RtpListener public RTC::RtpListener
{ {
public: public:
...@@ -48,44 +44,44 @@ namespace RTC ...@@ -48,44 +44,44 @@ namespace RTC
void HandleRequest(Channel::Request* request); void HandleRequest(Channel::Request* request);
private: private:
void MayRunDTLSTransport(); void MayRunDtlsTransport();
/* Private methods to unify UDP and TCP behavior. */ /* Private methods to unify UDP and TCP behavior. */
private: private:
void onPacketRecv(RTC::TransportTuple* tuple, const uint8_t* data, size_t len); void onPacketRecv(RTC::TransportTuple* tuple, const uint8_t* data, size_t len);
void onSTUNDataRecv(RTC::TransportTuple* tuple, const uint8_t* data, size_t len); void onStunDataRecv(RTC::TransportTuple* tuple, const uint8_t* data, size_t len);
void onDTLSDataRecv(RTC::TransportTuple* tuple, const uint8_t* data, size_t len); void onDtlsDataRecv(RTC::TransportTuple* tuple, const uint8_t* data, size_t len);
void onRTPDataRecv(RTC::TransportTuple* tuple, const uint8_t* data, size_t len); void onRtpDataRecv(RTC::TransportTuple* tuple, const uint8_t* data, size_t len);
void onRTCPDataRecv(RTC::TransportTuple* tuple, const uint8_t* data, size_t len); void onRtcpDataRecv(RTC::TransportTuple* tuple, const uint8_t* data, size_t len);
/* Pure virtual methods inherited from RTC::UDPSocket::Listener. */ /* Pure virtual methods inherited from RTC::UdpSocket::Listener. */
public: public:
virtual void onPacketRecv(RTC::UDPSocket *socket, const uint8_t* data, size_t len, const struct sockaddr* remote_addr) override; virtual void onPacketRecv(RTC::UdpSocket *socket, const uint8_t* data, size_t len, const struct sockaddr* remote_addr) override;
/* Pure virtual methods inherited from RTC::TCPServer::Listener. */ /* Pure virtual methods inherited from RTC::TcpServer::Listener. */
public: public:
virtual void onRTCTCPConnectionClosed(RTC::TCPServer* tcpServer, RTC::TCPConnection* connection, bool is_closed_by_peer) override; virtual void onRtcTcpConnectionClosed(RTC::TcpServer* tcpServer, RTC::TcpConnection* connection, bool is_closed_by_peer) override;
/* Pure virtual methods inherited from RTC::TCPConnection::Listener. */ /* Pure virtual methods inherited from RTC::TcpConnection::Listener. */
public: public:
virtual void onPacketRecv(RTC::TCPConnection *connection, const uint8_t* data, size_t len) override; virtual void onPacketRecv(RTC::TcpConnection *connection, const uint8_t* data, size_t len) override;
/* Pure virtual methods inherited from RTC::ICEServer::Listener. */ /* Pure virtual methods inherited from RTC::IceServer::Listener. */
public: public:
virtual void onOutgoingSTUNMessage(RTC::ICEServer* iceServer, RTC::STUNMessage* msg, RTC::TransportTuple* tuple) override; virtual void onOutgoingStunMessage(RTC::IceServer* iceServer, RTC::StunMessage* msg, RTC::TransportTuple* tuple) override;
virtual void onICESelectedTuple(ICEServer* iceServer, RTC::TransportTuple* tuple) override; virtual void onIceSelectedTuple(IceServer* iceServer, RTC::TransportTuple* tuple) override;
virtual void onICEConnected(ICEServer* iceServer) override; virtual void onIceConnected(IceServer* iceServer) override;
virtual void onICECompleted(ICEServer* iceServer) override; virtual void onIceCompleted(IceServer* iceServer) override;
virtual void onICEDisconnected(ICEServer* iceServer) override; virtual void onIceDisconnected(IceServer* iceServer) override;
/* Pure virtual methods inherited from RTC::DTLSTransport::Listener. */ /* Pure virtual methods inherited from RTC::DtlsTransport::Listener. */
public: public:
virtual void onDTLSConnecting(DTLSTransport* dtlsTransport) override; virtual void onDtlsConnecting(DtlsTransport* dtlsTransport) override;
virtual void onDTLSConnected(DTLSTransport* dtlsTransport, RTC::SRTPSession::Profile srtp_profile, uint8_t* srtp_local_key, size_t srtp_local_key_len, uint8_t* srtp_remote_key, size_t srtp_remote_key_len) override; virtual void onDtlsConnected(DtlsTransport* dtlsTransport, RTC::SrtpSession::Profile srtp_profile, uint8_t* srtp_local_key, size_t srtp_local_key_len, uint8_t* srtp_remote_key, size_t srtp_remote_key_len) override;
virtual void onDTLSFailed(DTLSTransport* dtlsTransport) override; virtual void onDtlsFailed(DtlsTransport* dtlsTransport) override;
virtual void onDTLSClosed(DTLSTransport* dtlsTransport) override; virtual void onDtlsClosed(DtlsTransport* dtlsTransport) override;
virtual void onOutgoingDTLSData(RTC::DTLSTransport* dtlsTransport, const uint8_t* data, size_t len) override; virtual void onOutgoingDtlsData(RTC::DtlsTransport* dtlsTransport, const uint8_t* data, size_t len) override;
virtual void onDTLSApplicationData(RTC::DTLSTransport* dtlsTransport, const uint8_t* data, size_t len) override; virtual void onDtlsApplicationData(RTC::DtlsTransport* dtlsTransport, const uint8_t* data, size_t len) override;
public: public:
// Passed by argument. // Passed by argument.
...@@ -96,10 +92,10 @@ namespace RTC ...@@ -96,10 +92,10 @@ namespace RTC
Listener* listener = nullptr; Listener* listener = nullptr;
Channel::Notifier* notifier = nullptr; Channel::Notifier* notifier = nullptr;
// Allocated by this. // Allocated by this.
RTC::ICEServer* iceServer = nullptr; RTC::IceServer* iceServer = nullptr;
std::vector<RTC::UDPSocket*> udpSockets; std::vector<RTC::UdpSocket*> udpSockets;
std::vector<RTC::TCPServer*> tcpServers; std::vector<RTC::TcpServer*> tcpServers;
RTC::DTLSTransport* dtlsTransport = nullptr; RTC::DtlsTransport* dtlsTransport = nullptr;
// Others. // Others.
bool allocated = false; bool allocated = false;
// Others (ICE). // Others (ICE).
...@@ -107,7 +103,7 @@ namespace RTC ...@@ -107,7 +103,7 @@ namespace RTC
RTC::TransportTuple* selectedTuple = nullptr; RTC::TransportTuple* selectedTuple = nullptr;
// Others (DTLS). // Others (DTLS).
bool remoteDtlsParametersGiven = false; bool remoteDtlsParametersGiven = false;
RTC::DTLSTransport::Role dtlsLocalRole = RTC::DTLSTransport::Role::AUTO; RTC::DtlsTransport::Role dtlsLocalRole = RTC::DtlsTransport::Role::AUTO;
}; };
} }
......
...@@ -2,8 +2,8 @@ ...@@ -2,8 +2,8 @@
#define MS_RTC_TRANSPORT_TUPLE_H #define MS_RTC_TRANSPORT_TUPLE_H
#include "common.h" #include "common.h"
#include "RTC/UDPSocket.h" #include "RTC/UdpSocket.h"
#include "RTC/TCPConnection.h" #include "RTC/TcpConnection.h"
#include "Utils.h" #include "Utils.h"
#include <json/json.h> #include <json/json.h>
...@@ -19,8 +19,8 @@ namespace RTC ...@@ -19,8 +19,8 @@ namespace RTC
}; };
public: public:
TransportTuple(RTC::UDPSocket* udpSocket, const struct sockaddr* udpRemoteAddr); TransportTuple(RTC::UdpSocket* udpSocket, const struct sockaddr* udpRemoteAddr);
TransportTuple(RTC::TCPConnection* tcpConnection); TransportTuple(RTC::TcpConnection* tcpConnection);
void Close(); void Close();
Json::Value toJson(); Json::Value toJson();
...@@ -34,10 +34,10 @@ namespace RTC ...@@ -34,10 +34,10 @@ namespace RTC
private: private:
// Passed by argument. // Passed by argument.
RTC::UDPSocket* udpSocket = nullptr; RTC::UdpSocket* udpSocket = nullptr;
struct sockaddr* udpRemoteAddr = nullptr; struct sockaddr* udpRemoteAddr = nullptr;
sockaddr_storage udpRemoteAddrStorage; sockaddr_storage udpRemoteAddrStorage;
RTC::TCPConnection* tcpConnection = nullptr; RTC::TcpConnection* tcpConnection = nullptr;
// Others. // Others.
Protocol protocol; Protocol protocol;
}; };
...@@ -52,14 +52,14 @@ namespace RTC ...@@ -52,14 +52,14 @@ namespace RTC
} }
inline inline
TransportTuple::TransportTuple(RTC::UDPSocket* udpSocket, const struct sockaddr* udpRemoteAddr) : TransportTuple::TransportTuple(RTC::UdpSocket* udpSocket, const struct sockaddr* udpRemoteAddr) :
udpSocket(udpSocket), udpSocket(udpSocket),
udpRemoteAddr((struct sockaddr*)udpRemoteAddr), udpRemoteAddr((struct sockaddr*)udpRemoteAddr),
protocol(Protocol::UDP) protocol(Protocol::UDP)
{} {}
inline inline
TransportTuple::TransportTuple(RTC::TCPConnection* tcpConnection) : TransportTuple::TransportTuple(RTC::TcpConnection* tcpConnection) :
tcpConnection(tcpConnection), tcpConnection(tcpConnection),
protocol(Protocol::TCP) protocol(Protocol::TCP)
{} {}
......
...@@ -2,20 +2,20 @@ ...@@ -2,20 +2,20 @@
#define MS_RTC_UDP_SOCKET_H #define MS_RTC_UDP_SOCKET_H
#include "common.h" #include "common.h"
#include "handles/UDPSocket.h" #include "handles/UdpSocket.h"
#include <unordered_map> #include <unordered_map>
#include <uv.h> #include <uv.h>
namespace RTC namespace RTC
{ {
class UDPSocket : class UdpSocket :
public ::UDPSocket public ::UdpSocket
{ {
public: public:
class Listener class Listener
{ {
public: public:
virtual void onPacketRecv(RTC::UDPSocket *socket, const uint8_t* data, size_t len, const struct sockaddr* remote_addr) = 0; virtual void onPacketRecv(RTC::UdpSocket *socket, const uint8_t* data, size_t len, const struct sockaddr* remote_addr) = 0;
}; };
public: public:
...@@ -33,12 +33,12 @@ namespace RTC ...@@ -33,12 +33,12 @@ namespace RTC
static std::unordered_map<uint16_t, bool> availableIPv6Ports; static std::unordered_map<uint16_t, bool> availableIPv6Ports;
public: public:
UDPSocket(Listener* listener, int address_family); UdpSocket(Listener* listener, int address_family);
/* Pure virtual methods inherited from ::UDPSocket. */ /* Pure virtual methods inherited from ::UdpSocket. */
public: public:
virtual void userOnUDPDatagramRecv(const uint8_t* data, size_t len, const struct sockaddr* addr) override; virtual void userOnUdpDatagramRecv(const uint8_t* data, size_t len, const struct sockaddr* addr) override;
virtual void userOnUDPSocketClosed() override; virtual void userOnUdpSocketClosed() override;
private: private:
// Passed by argument. // Passed by argument.
......
...@@ -5,27 +5,27 @@ ...@@ -5,27 +5,27 @@
#include <string> #include <string>
#include <uv.h> #include <uv.h>
class TCPConnection class TcpConnection
{ {
public: public:
class Listener class Listener
{ {
public: public:
virtual void onTCPConnectionClosed(TCPConnection* connection, bool is_closed_by_peer) = 0; virtual void onTcpConnectionClosed(TcpConnection* connection, bool is_closed_by_peer) = 0;
}; };
public: public:
/* Struct for the data field of uv_req_t when writing into the connection. */ /* Struct for the data field of uv_req_t when writing into the connection. */
struct UvWriteData struct UvWriteData
{ {
TCPConnection* connection; TcpConnection* connection;
uv_write_t req; uv_write_t req;
uint8_t store[1]; uint8_t store[1];
}; };
public: public:
TCPConnection(size_t bufferSize); TcpConnection(size_t bufferSize);
virtual ~TCPConnection(); virtual ~TcpConnection();
void Close(); void Close();
virtual void Dump(); virtual void Dump();
...@@ -56,7 +56,7 @@ public: ...@@ -56,7 +56,7 @@ public:
/* Pure virtual methods that must be implemented by the subclass. */ /* Pure virtual methods that must be implemented by the subclass. */
protected: protected:
virtual void userOnTCPConnectionRead() = 0; virtual void userOnTcpConnectionRead() = 0;
private: private:
// Passed by argument. // Passed by argument.
...@@ -86,55 +86,55 @@ protected: ...@@ -86,55 +86,55 @@ protected:
/* Inline methods. */ /* Inline methods. */
inline inline
bool TCPConnection::IsClosing() bool TcpConnection::IsClosing()
{ {
return this->isClosing; return this->isClosing;
} }
inline inline
uv_tcp_t* TCPConnection::GetUvHandle() uv_tcp_t* TcpConnection::GetUvHandle()
{ {
return this->uvHandle; return this->uvHandle;
} }
inline inline
void TCPConnection::Write(const std::string &data) void TcpConnection::Write(const std::string &data)
{ {
Write((const uint8_t*)data.c_str(), data.size()); Write((const uint8_t*)data.c_str(), data.size());
} }
inline inline
const struct sockaddr* TCPConnection::GetLocalAddress() const struct sockaddr* TcpConnection::GetLocalAddress()
{ {
return (const struct sockaddr*)this->localAddr; return (const struct sockaddr*)this->localAddr;
} }
inline inline
const std::string& TCPConnection::GetLocalIP() const std::string& TcpConnection::GetLocalIP()
{ {
return this->localIP; return this->localIP;
} }
inline inline
uint16_t TCPConnection::GetLocalPort() uint16_t TcpConnection::GetLocalPort()
{ {
return this->localPort; return this->localPort;
} }
inline inline
const struct sockaddr* TCPConnection::GetPeerAddress() const struct sockaddr* TcpConnection::GetPeerAddress()
{ {
return (const struct sockaddr*)&this->peerAddr; return (const struct sockaddr*)&this->peerAddr;
} }
inline inline
const std::string& TCPConnection::GetPeerIP() const std::string& TcpConnection::GetPeerIP()
{ {
return this->peerIP; return this->peerIP;
} }
inline inline
uint16_t TCPConnection::GetPeerPort() uint16_t TcpConnection::GetPeerPort()
{ {
return this->peerPort; return this->peerPort;
} }
......
...@@ -2,20 +2,20 @@ ...@@ -2,20 +2,20 @@
#define MS_TCP_SERVER_H #define MS_TCP_SERVER_H
#include "common.h" #include "common.h"
#include "handles/TCPConnection.h" #include "handles/TcpConnection.h"
#include <string> #include <string>
#include <unordered_set> #include <unordered_set>
#include <uv.h> #include <uv.h>
class TCPServer : public TCPConnection::Listener class TcpServer : public TcpConnection::Listener
{ {
public: public:
TCPServer(const std::string &ip, uint16_t port, int backlog); TcpServer(const std::string &ip, uint16_t port, int backlog);
/** /**
* 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); TcpServer(uv_tcp_t* uvHandle, int backlog);
virtual ~TCPServer(); virtual ~TcpServer();
void Close(); void Close();
virtual void Dump(); virtual void Dump();
...@@ -30,25 +30,25 @@ private: ...@@ -30,25 +30,25 @@ private:
/* 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(TCPConnection** connection) = 0; virtual void userOnTcpConnectionAlloc(TcpConnection** connection) = 0;
virtual void userOnNewTCPConnection(TCPConnection* connection) = 0; virtual void userOnNewTcpConnection(TcpConnection* connection) = 0;
virtual void userOnTCPConnectionClosed(TCPConnection* connection, bool is_closed_by_peer) = 0; virtual void userOnTcpConnectionClosed(TcpConnection* connection, bool is_closed_by_peer) = 0;
virtual void userOnTCPServerClosed() = 0; virtual void userOnTcpServerClosed() = 0;
/* Callbacks fired by UV events. */ /* Callbacks fired by UV events. */
public: public:
void onUvConnection(int status); void onUvConnection(int status);
void onUvClosed(); void onUvClosed();
/* Methods inherited from TCPConnection::Listener. */ /* Methods inherited from TcpConnection::Listener. */
public: public:
virtual void onTCPConnectionClosed(TCPConnection* connection, bool is_closed_by_peer); virtual void onTcpConnectionClosed(TcpConnection* connection, bool is_closed_by_peer);
private: 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<TcpConnection*> connections;
bool isClosing = false; bool isClosing = false;
protected: protected:
...@@ -60,13 +60,13 @@ protected: ...@@ -60,13 +60,13 @@ protected:
/* Inline methods. */ /* Inline methods. */
inline inline
bool TCPServer::IsClosing() bool TcpServer::IsClosing()
{ {
return this->isClosing; return this->isClosing;
} }
inline inline
size_t TCPServer::GetNumConnections() size_t TcpServer::GetNumConnections()
{ {
return this->connections.size(); return this->connections.size();
} }
......
...@@ -5,13 +5,13 @@ ...@@ -5,13 +5,13 @@
#include <string> #include <string>
#include <uv.h> #include <uv.h>
class UDPSocket class UdpSocket
{ {
public: public:
/* Struct for the data field of uv_req_t when sending a datagram. */ /* Struct for the data field of uv_req_t when sending a datagram. */
struct UvSendData struct UvSendData
{ {
UDPSocket* socket; UdpSocket* socket;
uv_udp_send_t req; uv_udp_send_t req;
uint8_t store[1]; uint8_t store[1];
}; };
...@@ -20,12 +20,12 @@ private: ...@@ -20,12 +20,12 @@ private:
static uint8_t readBuffer[]; static uint8_t readBuffer[];
public: public:
UDPSocket(const std::string &ip, uint16_t port); UdpSocket(const std::string &ip, uint16_t port);
/** /**
* uvHandle must be an already initialized and binded uv_udp_t pointer. * uvHandle must be an already initialized and binded uv_udp_t pointer.
*/ */
UDPSocket(uv_udp_t* uvHandle); UdpSocket(uv_udp_t* uvHandle);
virtual ~UDPSocket(); virtual ~UdpSocket();
void Close(); void Close();
virtual void Dump(); virtual void Dump();
...@@ -49,8 +49,8 @@ public: ...@@ -49,8 +49,8 @@ public:
/* Pure virtual methods that must be implemented by the subclass. */ /* Pure virtual methods that must be implemented by the subclass. */
protected: protected:
virtual void userOnUDPDatagramRecv(const uint8_t* data, size_t len, const struct sockaddr* addr) = 0; virtual void userOnUdpDatagramRecv(const uint8_t* data, size_t len, const struct sockaddr* addr) = 0;
virtual void userOnUDPSocketClosed() = 0; virtual void userOnUdpSocketClosed() = 0;
private: private:
// Allocated by this (may be passed by argument). // Allocated by this (may be passed by argument).
...@@ -67,31 +67,31 @@ protected: ...@@ -67,31 +67,31 @@ protected:
/* Inline methods. */ /* Inline methods. */
inline inline
void UDPSocket::Send(const std::string &data, const struct sockaddr* addr) void UdpSocket::Send(const std::string &data, const struct sockaddr* addr)
{ {
Send((const uint8_t*)data.c_str(), data.size(), addr); Send((const uint8_t*)data.c_str(), data.size(), addr);
} }
inline inline
void UDPSocket::Send(const std::string &data, const std::string &ip, uint16_t port) void UdpSocket::Send(const std::string &data, const std::string &ip, uint16_t port)
{ {
Send((const uint8_t*)data.c_str(), data.size(), ip, port); Send((const uint8_t*)data.c_str(), data.size(), ip, port);
} }
inline inline
const struct sockaddr* UDPSocket::GetLocalAddress() const struct sockaddr* UdpSocket::GetLocalAddress()
{ {
return (const struct sockaddr*)&this->localAddr; return (const struct sockaddr*)&this->localAddr;
} }
inline inline
const std::string& UDPSocket::GetLocalIP() const std::string& UdpSocket::GetLocalIP()
{ {
return this->localIP; return this->localIP;
} }
inline inline
uint16_t UDPSocket::GetLocalPort() uint16_t UdpSocket::GetLocalPort()
{ {
return this->localPort; return this->localPort;
} }
......
...@@ -6,7 +6,7 @@ namespace RTC ...@@ -6,7 +6,7 @@ namespace RTC
{ {
/* Instance methods. */ /* Instance methods. */
IceCandidate::IceCandidate(RTC::UDPSocket* udpSocket, uint32_t priority) : IceCandidate::IceCandidate(RTC::UdpSocket* udpSocket, uint32_t priority) :
foundation("udpcandidate"), foundation("udpcandidate"),
priority(priority), priority(priority),
ip(udpSocket->GetLocalIP()), ip(udpSocket->GetLocalIP()),
...@@ -15,7 +15,7 @@ namespace RTC ...@@ -15,7 +15,7 @@ namespace RTC
type(CandidateType::HOST) type(CandidateType::HOST)
{} {}
IceCandidate::IceCandidate(RTC::TCPServer* tcpServer, uint32_t priority) : IceCandidate::IceCandidate(RTC::TcpServer* tcpServer, uint32_t priority) :
foundation("tcpcandidate"), foundation("tcpcandidate"),
priority(priority), priority(priority),
ip(tcpServer->GetLocalIP()), ip(tcpServer->GetLocalIP()),
......
#define MS_CLASS "RTC::ICEServer" #define MS_CLASS "RTC::IceServer"
#include "RTC/ICEServer.h" #include "RTC/IceServer.h"
#include "Logger.h" #include "Logger.h"
namespace RTC namespace RTC
{ {
/* Instance methods. */ /* Instance methods. */
ICEServer::ICEServer(Listener* listener, const std::string& usernameFragment, const std::string password) : IceServer::IceServer(Listener* listener, const std::string& usernameFragment, const std::string password) :
listener(listener), listener(listener),
usernameFragment(usernameFragment), usernameFragment(usernameFragment),
password(password) password(password)
...@@ -17,28 +17,28 @@ namespace RTC ...@@ -17,28 +17,28 @@ namespace RTC
MS_DEBUG("[usernameFragment:%s, password:%s]", this->usernameFragment.c_str(), this->password.c_str()); MS_DEBUG("[usernameFragment:%s, password:%s]", this->usernameFragment.c_str(), this->password.c_str());
} }
void ICEServer::Close() void IceServer::Close()
{ {
MS_TRACE(); MS_TRACE();
delete this; delete this;
} }
void ICEServer::ProcessSTUNMessage(RTC::STUNMessage* msg, RTC::TransportTuple* tuple) void IceServer::ProcessStunMessage(RTC::StunMessage* msg, RTC::TransportTuple* tuple)
{ {
MS_TRACE(); MS_TRACE();
// Must be a Binding method. // Must be a Binding method.
if (msg->GetMethod() != RTC::STUNMessage::Method::Binding) if (msg->GetMethod() != RTC::StunMessage::Method::Binding)
{ {
if (msg->GetClass() == RTC::STUNMessage::Class::Request) if (msg->GetClass() == RTC::StunMessage::Class::Request)
{ {
MS_DEBUG("unknown method %#.3x in STUN Request => 400", (unsigned int)msg->GetMethod()); MS_DEBUG("unknown method %#.3x in STUN Request => 400", (unsigned int)msg->GetMethod());
// Reply 400. // Reply 400.
RTC::STUNMessage* response = msg->CreateErrorResponse(400); RTC::StunMessage* response = msg->CreateErrorResponse(400);
response->Serialize(); response->Serialize();
this->listener->onOutgoingSTUNMessage(this, response, tuple); this->listener->onOutgoingStunMessage(this, response, tuple);
delete response; delete response;
} }
else else
...@@ -50,16 +50,16 @@ namespace RTC ...@@ -50,16 +50,16 @@ namespace RTC
} }
// Must use FINGERPRINT (optional for ICE STUN indications). // Must use FINGERPRINT (optional for ICE STUN indications).
if (!msg->HasFingerprint() && msg->GetClass() != RTC::STUNMessage::Class::Indication) if (!msg->HasFingerprint() && msg->GetClass() != RTC::StunMessage::Class::Indication)
{ {
if (msg->GetClass() == RTC::STUNMessage::Class::Request) if (msg->GetClass() == RTC::StunMessage::Class::Request)
{ {
MS_DEBUG("STUN Binding Request without FINGERPRINT => 400"); MS_DEBUG("STUN Binding Request without FINGERPRINT => 400");
// Reply 400. // Reply 400.
RTC::STUNMessage* response = msg->CreateErrorResponse(400); RTC::StunMessage* response = msg->CreateErrorResponse(400);
response->Serialize(); response->Serialize();
this->listener->onOutgoingSTUNMessage(this, response, tuple); this->listener->onOutgoingStunMessage(this, response, tuple);
delete response; delete response;
} }
else else
...@@ -72,7 +72,7 @@ namespace RTC ...@@ -72,7 +72,7 @@ namespace RTC
switch (msg->GetClass()) switch (msg->GetClass())
{ {
case RTC::STUNMessage::Class::Request: case RTC::StunMessage::Class::Request:
{ {
// USERNAME, MESSAGE-INTEGRITY and PRIORITY are required. // USERNAME, MESSAGE-INTEGRITY and PRIORITY are required.
if (!msg->HasMessageIntegrity() || !msg->GetPriority() || msg->GetUsername().empty()) if (!msg->HasMessageIntegrity() || !msg->GetPriority() || msg->GetUsername().empty())
...@@ -80,9 +80,9 @@ namespace RTC ...@@ -80,9 +80,9 @@ namespace RTC
MS_DEBUG("mising required attributes in STUN Binding Request => 400"); MS_DEBUG("mising required attributes in STUN Binding Request => 400");
// Reply 400. // Reply 400.
RTC::STUNMessage* response = msg->CreateErrorResponse(400); RTC::StunMessage* response = msg->CreateErrorResponse(400);
response->Serialize(); response->Serialize();
this->listener->onOutgoingSTUNMessage(this, response, tuple); this->listener->onOutgoingStunMessage(this, response, tuple);
delete response; delete response;
return; return;
...@@ -91,30 +91,30 @@ namespace RTC ...@@ -91,30 +91,30 @@ namespace RTC
// Check authentication. // Check authentication.
switch (msg->CheckAuthentication(this->usernameFragment, this->password)) switch (msg->CheckAuthentication(this->usernameFragment, this->password))
{ {
case RTC::STUNMessage::Authentication::OK: case RTC::StunMessage::Authentication::OK:
break; break;
case RTC::STUNMessage::Authentication::Unauthorized: case RTC::StunMessage::Authentication::Unauthorized:
{ {
MS_DEBUG("wrong authentication in STUN Binding Request => 401"); MS_DEBUG("wrong authentication in STUN Binding Request => 401");
// Reply 401. // Reply 401.
RTC::STUNMessage* response = msg->CreateErrorResponse(401); RTC::StunMessage* response = msg->CreateErrorResponse(401);
response->Serialize(); response->Serialize();
this->listener->onOutgoingSTUNMessage(this, response, tuple); this->listener->onOutgoingStunMessage(this, response, tuple);
delete response; delete response;
return; return;
} }
case RTC::STUNMessage::Authentication::BadRequest: case RTC::StunMessage::Authentication::BadRequest:
{ {
MS_DEBUG("cannot check authentication in STUN Binding Request => 400"); MS_DEBUG("cannot check authentication in STUN Binding Request => 400");
// Reply 400. // Reply 400.
RTC::STUNMessage* response = msg->CreateErrorResponse(400); RTC::StunMessage* response = msg->CreateErrorResponse(400);
response->Serialize(); response->Serialize();
this->listener->onOutgoingSTUNMessage(this, response, tuple); this->listener->onOutgoingStunMessage(this, response, tuple);
delete response; delete response;
return; return;
...@@ -127,9 +127,9 @@ namespace RTC ...@@ -127,9 +127,9 @@ namespace RTC
MS_DEBUG("peer indicates ICE-CONTROLLED in STUN Binding Request => 487"); MS_DEBUG("peer indicates ICE-CONTROLLED in STUN Binding Request => 487");
// Reply 487 (Role Conflict). // Reply 487 (Role Conflict).
RTC::STUNMessage* response = msg->CreateErrorResponse(487); RTC::StunMessage* response = msg->CreateErrorResponse(487);
response->Serialize(); response->Serialize();
this->listener->onOutgoingSTUNMessage(this, response, tuple); this->listener->onOutgoingStunMessage(this, response, tuple);
delete response; delete response;
return; return;
...@@ -138,7 +138,7 @@ namespace RTC ...@@ -138,7 +138,7 @@ namespace RTC
MS_DEBUG("processing STUN Binding Request [Priority:%" PRIu32 ", UseCandidate:%s]", (uint32_t)msg->GetPriority(), msg->HasUseCandidate() ? "true" : "false"); MS_DEBUG("processing STUN Binding Request [Priority:%" PRIu32 ", UseCandidate:%s]", (uint32_t)msg->GetPriority(), msg->HasUseCandidate() ? "true" : "false");
// Create a success response. // Create a success response.
RTC::STUNMessage* response = msg->CreateSuccessResponse(); RTC::StunMessage* response = msg->CreateSuccessResponse();
// Add XOR-MAPPED-ADDRESS. // Add XOR-MAPPED-ADDRESS.
response->SetXorMappedAddress(tuple->GetRemoteAddress()); response->SetXorMappedAddress(tuple->GetRemoteAddress());
...@@ -148,7 +148,7 @@ namespace RTC ...@@ -148,7 +148,7 @@ namespace RTC
// Send back. // Send back.
response->Serialize(); response->Serialize();
this->listener->onOutgoingSTUNMessage(this, response, tuple); this->listener->onOutgoingStunMessage(this, response, tuple);
delete response; delete response;
// Handle the tuple. // Handle the tuple.
...@@ -157,21 +157,21 @@ namespace RTC ...@@ -157,21 +157,21 @@ namespace RTC
break; break;
} }
case RTC::STUNMessage::Class::Indication: case RTC::StunMessage::Class::Indication:
{ {
MS_DEBUG("STUN Binding Indication processed"); MS_DEBUG("STUN Binding Indication processed");
break; break;
} }
case RTC::STUNMessage::Class::SuccessResponse: case RTC::StunMessage::Class::SuccessResponse:
{ {
MS_DEBUG("STUN Binding Success Response processed"); MS_DEBUG("STUN Binding Success Response processed");
break; break;
} }
case RTC::STUNMessage::Class::ErrorResponse: case RTC::StunMessage::Class::ErrorResponse:
{ {
MS_DEBUG("STUN Binding Error Response processed"); MS_DEBUG("STUN Binding Error Response processed");
...@@ -180,7 +180,7 @@ namespace RTC ...@@ -180,7 +180,7 @@ namespace RTC
} }
} }
bool ICEServer::IsValidTuple(RTC::TransportTuple* tuple) bool IceServer::IsValidTuple(RTC::TransportTuple* tuple)
{ {
MS_TRACE(); MS_TRACE();
...@@ -191,7 +191,7 @@ namespace RTC ...@@ -191,7 +191,7 @@ namespace RTC
} }
void ICEServer::RemoveTuple(RTC::TransportTuple* tuple) void IceServer::RemoveTuple(RTC::TransportTuple* tuple)
{ {
auto it = this->tuples.begin(); auto it = this->tuples.begin();
RTC::TransportTuple* removed_tuple = nullptr; RTC::TransportTuple* removed_tuple = nullptr;
...@@ -237,12 +237,12 @@ namespace RTC ...@@ -237,12 +237,12 @@ namespace RTC
this->state = IceState::DISCONNECTED; this->state = IceState::DISCONNECTED;
// Notify the listener. // Notify the listener.
this->listener->onICEDisconnected(this); this->listener->onIceDisconnected(this);
} }
} }
} }
void ICEServer::ForceSelectedTuple(RTC::TransportTuple* tuple) void IceServer::ForceSelectedTuple(RTC::TransportTuple* tuple)
{ {
MS_TRACE(); MS_TRACE();
...@@ -256,7 +256,7 @@ namespace RTC ...@@ -256,7 +256,7 @@ namespace RTC
SetSelectedTuple(stored_tuple); SetSelectedTuple(stored_tuple);
} }
void ICEServer::HandleTuple(RTC::TransportTuple* tuple, bool has_use_candidate) void IceServer::HandleTuple(RTC::TransportTuple* tuple, bool has_use_candidate)
{ {
MS_TRACE(); MS_TRACE();
...@@ -284,7 +284,7 @@ namespace RTC ...@@ -284,7 +284,7 @@ namespace RTC
this->state = IceState::CONNECTED; this->state = IceState::CONNECTED;
// Notify the listener. // Notify the listener.
this->listener->onICEConnected(this); this->listener->onIceConnected(this);
} }
else else
{ {
...@@ -300,7 +300,7 @@ namespace RTC ...@@ -300,7 +300,7 @@ namespace RTC
this->state = IceState::COMPLETED; this->state = IceState::COMPLETED;
// Notify the listener. // Notify the listener.
this->listener->onICECompleted(this); this->listener->onIceCompleted(this);
} }
break; break;
...@@ -328,7 +328,7 @@ namespace RTC ...@@ -328,7 +328,7 @@ namespace RTC
this->state = IceState::CONNECTED; this->state = IceState::CONNECTED;
// Notify the listener. // Notify the listener.
this->listener->onICEConnected(this); this->listener->onIceConnected(this);
} }
else else
{ {
...@@ -344,7 +344,7 @@ namespace RTC ...@@ -344,7 +344,7 @@ namespace RTC
this->state = IceState::COMPLETED; this->state = IceState::COMPLETED;
// Notify the listener. // Notify the listener.
this->listener->onICECompleted(this); this->listener->onIceCompleted(this);
} }
break; break;
...@@ -381,7 +381,7 @@ namespace RTC ...@@ -381,7 +381,7 @@ namespace RTC
this->state = IceState::COMPLETED; this->state = IceState::COMPLETED;
// Notify the listener. // Notify the listener.
this->listener->onICECompleted(this); this->listener->onIceCompleted(this);
} }
break; break;
...@@ -419,7 +419,7 @@ namespace RTC ...@@ -419,7 +419,7 @@ namespace RTC
} }
inline inline
RTC::TransportTuple* ICEServer::AddTuple(RTC::TransportTuple* tuple) RTC::TransportTuple* IceServer::AddTuple(RTC::TransportTuple* tuple)
{ {
MS_TRACE(); MS_TRACE();
...@@ -438,7 +438,7 @@ namespace RTC ...@@ -438,7 +438,7 @@ namespace RTC
} }
inline inline
RTC::TransportTuple* ICEServer::HasTuple(RTC::TransportTuple* tuple) RTC::TransportTuple* IceServer::HasTuple(RTC::TransportTuple* tuple)
{ {
MS_TRACE(); MS_TRACE();
...@@ -464,7 +464,7 @@ namespace RTC ...@@ -464,7 +464,7 @@ namespace RTC
} }
inline inline
void ICEServer::SetSelectedTuple(RTC::TransportTuple* stored_tuple) void IceServer::SetSelectedTuple(RTC::TransportTuple* stored_tuple)
{ {
MS_TRACE(); MS_TRACE();
...@@ -475,6 +475,6 @@ namespace RTC ...@@ -475,6 +475,6 @@ namespace RTC
this->selectedTuple = stored_tuple; this->selectedTuple = stored_tuple;
// Notify the listener. // Notify the listener.
this->listener->onICESelectedTuple(this, this->selectedTuple); this->listener->onIceSelectedTuple(this, this->selectedTuple);
} }
} }
...@@ -236,7 +236,7 @@ namespace RTC ...@@ -236,7 +236,7 @@ namespace RTC
MS_DEBUG("RtpReceiver created [rtpReceiverId:%" PRIu32 "]", rtpReceiverId); MS_DEBUG("RtpReceiver created [rtpReceiverId:%" PRIu32 "]", rtpReceiverId);
// RTC::Transport inherits from RTC::RtpListener, but the API of // RTC::Transport inherits from RTC::RtpListener, but the API of
// RTC:RtpReceiver requires RTP::RtpListener. // RTC:RtpReceiver requires RTC::RtpListener.
RTC::RtpListener* rtpListener = transport; RTC::RtpListener* rtpListener = transport;
// Set the RtpListener. // Set the RtpListener.
......
#define MS_CLASS "RTC::RTCPPacket" #define MS_CLASS "RTC::RtcpPacket"
#include "RTC/RTCPPacket.h" #include "RTC/RtcpPacket.h"
#include "Logger.h" #include "Logger.h"
namespace RTC namespace RTC
{ {
/* Class methods. */ /* Class methods. */
RTCPPacket* RTCPPacket::Parse(const uint8_t* data, size_t len) RtcpPacket* RtcpPacket::Parse(const uint8_t* data, size_t len)
{ {
MS_TRACE(); MS_TRACE();
if (!RTCPPacket::IsRTCP(data, len)) if (!RtcpPacket::IsRtcp(data, len))
return nullptr; return nullptr;
// TODO: Do it. // TODO: Do it.
...@@ -19,12 +19,12 @@ namespace RTC ...@@ -19,12 +19,12 @@ namespace RTC
// Get the header. // Get the header.
CommonHeader* header = (CommonHeader*)data; CommonHeader* header = (CommonHeader*)data;
return new RTCPPacket(header, data, len); return new RtcpPacket(header, data, len);
} }
/* Instance methods. */ /* Instance methods. */
RTCPPacket::RTCPPacket(CommonHeader* header, const uint8_t* raw, size_t length) : RtcpPacket::RtcpPacket(CommonHeader* header, const uint8_t* raw, size_t length) :
header(header), header(header),
raw((uint8_t*)raw), raw((uint8_t*)raw),
length(length) length(length)
...@@ -32,7 +32,7 @@ namespace RTC ...@@ -32,7 +32,7 @@ namespace RTC
MS_TRACE(); MS_TRACE();
} }
RTCPPacket::~RTCPPacket() RtcpPacket::~RtcpPacket()
{ {
MS_TRACE(); MS_TRACE();
} }
......
...@@ -108,7 +108,7 @@ namespace RTC ...@@ -108,7 +108,7 @@ namespace RTC
} }
} }
RTC::RtpReceiver* RtpListener::GetRtpReceiver(RTC::RTPPacket* packet) RTC::RtpReceiver* RtpListener::GetRtpReceiver(RTC::RtpPacket* packet)
{ {
MS_TRACE(); MS_TRACE();
...@@ -116,7 +116,7 @@ namespace RTC ...@@ -116,7 +116,7 @@ namespace RTC
// Check the SSRC table. // Check the SSRC table.
auto it = this->ssrcTable.find(packet->GetSSRC()); auto it = this->ssrcTable.find(packet->GetSsrc());
if (it == this->ssrcTable.end()) if (it == this->ssrcTable.end())
{ {
......
#define MS_CLASS "RTC::RTPPacket" #define MS_CLASS "RTC::RtpPacket"
#include "RTC/RTPPacket.h" #include "RTC/RtpPacket.h"
#include "Utils.h" #include "Utils.h"
#include "Logger.h" #include "Logger.h"
#include <cstring> // std::memcmp(), std::memcpy() #include <cstring> // std::memcmp(), std::memcpy()
...@@ -9,11 +9,11 @@ namespace RTC ...@@ -9,11 +9,11 @@ namespace RTC
{ {
/* Class methods. */ /* Class methods. */
RTPPacket* RTPPacket::Parse(const uint8_t* data, size_t len) RtpPacket* RtpPacket::Parse(const uint8_t* data, size_t len)
{ {
MS_TRACE(); MS_TRACE();
if (!RTPPacket::IsRTP(data, len)) if (!RtpPacket::IsRtp(data, len))
return nullptr; return nullptr;
// Get the header. // Get the header.
...@@ -109,12 +109,12 @@ namespace RTC ...@@ -109,12 +109,12 @@ namespace RTC
MS_ASSERT(len == sizeof(Header) + csrc_list_size + (extensionHeader ? 4 + extension_value_size : 0) + payloadLength + (size_t)payloadPadding, "packet's computed length does not match received length"); MS_ASSERT(len == sizeof(Header) + csrc_list_size + (extensionHeader ? 4 + extension_value_size : 0) + payloadLength + (size_t)payloadPadding, "packet's computed length does not match received length");
return new RTPPacket(header, extensionHeader, payload, payloadLength, payloadPadding, data, len); return new RtpPacket(header, extensionHeader, payload, payloadLength, payloadPadding, data, len);
} }
/* Instance methods. */ /* Instance methods. */
RTPPacket::RTPPacket(Header* header, ExtensionHeader* extensionHeader, const uint8_t* payload, size_t payloadLength, uint8_t payloadPadding, const uint8_t* raw, size_t length) : RtpPacket::RtpPacket(Header* header, ExtensionHeader* extensionHeader, const uint8_t* payload, size_t payloadLength, uint8_t payloadPadding, const uint8_t* raw, size_t length) :
header(header), header(header),
extensionHeader(extensionHeader), extensionHeader(extensionHeader),
payload((uint8_t*)payload), payload((uint8_t*)payload),
...@@ -129,7 +129,7 @@ namespace RTC ...@@ -129,7 +129,7 @@ namespace RTC
this->csrcList = (uint8_t*)raw + sizeof(Header); this->csrcList = (uint8_t*)raw + sizeof(Header);
} }
RTPPacket::~RTPPacket() RtpPacket::~RtpPacket()
{ {
MS_TRACE(); MS_TRACE();
...@@ -137,14 +137,14 @@ namespace RTC ...@@ -137,14 +137,14 @@ namespace RTC
delete this->raw; delete this->raw;
} }
void RTPPacket::Dump() void RtpPacket::Dump()
{ {
MS_TRACE(); MS_TRACE();
if (!Logger::HasDebugLevel()) if (!Logger::HasDebugLevel())
return; return;
MS_DEBUG("<RTPPacket>"); MS_DEBUG("<RtpPacket>");
MS_DEBUG("padding: %s", this->header->padding ? "true" : "false"); MS_DEBUG("padding: %s", this->header->padding ? "true" : "false");
MS_DEBUG("extension: %s", HasExtensionHeader() ? "true" : "false"); MS_DEBUG("extension: %s", HasExtensionHeader() ? "true" : "false");
if (HasExtensionHeader()) if (HasExtensionHeader())
...@@ -157,12 +157,12 @@ namespace RTC ...@@ -157,12 +157,12 @@ namespace RTC
MS_DEBUG("payload type: %" PRIu8, GetPayloadType()); MS_DEBUG("payload type: %" PRIu8, GetPayloadType());
MS_DEBUG("sequence number: %" PRIu16, GetSequenceNumber()); MS_DEBUG("sequence number: %" PRIu16, GetSequenceNumber());
MS_DEBUG("timestamp: %" PRIu32, GetTimestamp()); MS_DEBUG("timestamp: %" PRIu32, GetTimestamp());
MS_DEBUG("SSRC: %" PRIu32, GetSSRC()); MS_DEBUG("SSRC: %" PRIu32, GetSsrc());
MS_DEBUG("payload size: %zu bytes", GetPayloadLength()); MS_DEBUG("payload size: %zu bytes", GetPayloadLength());
MS_DEBUG("</RTPPacket>"); MS_DEBUG("</RtpPacket>");
} }
void RTPPacket::Serialize() void RtpPacket::Serialize()
{ {
MS_TRACE(); MS_TRACE();
......
#define MS_CLASS "RTC::RtpParameters" #define MS_CLASS "RTC::RtpParameters"
#include "RTC/RtpParameters.h" #include "RTC/RtpParameters.h"
// #include "Utils.h" // TODO: let's see
#include "MediaSoupError.h" #include "MediaSoupError.h"
#include "Logger.h" #include "Logger.h"
......
#define MS_CLASS "RTC::SRTPSession" #define MS_CLASS "RTC::SrtpSession"
#include "RTC/SRTPSession.h" #include "RTC/SrtpSession.h"
#include "MediaSoupError.h" #include "MediaSoupError.h"
#include "Logger.h" #include "Logger.h"
#include <cstring> // std::memset(), std::memcpy() #include <cstring> // std::memset(), std::memcpy()
...@@ -12,24 +12,24 @@ namespace RTC ...@@ -12,24 +12,24 @@ namespace RTC
{ {
/* Class variables. */ /* Class variables. */
uint8_t SRTPSession::encryptBuffer[MS_ENCRYPT_BUFFER_SIZE]; uint8_t SrtpSession::encryptBuffer[MS_ENCRYPT_BUFFER_SIZE];
/* Class methods. */ /* Class methods. */
void SRTPSession::ClassInit() void SrtpSession::ClassInit()
{ {
/* Set libsrtp event handler. */ /* Set libsrtp event handler. */
// srtp_err_status_t err; // srtp_err_status_t err;
// err = srtp_install_event_handler((srtp_event_handler_func_t*)onSRTPEvent); // err = srtp_install_event_handler((srtp_event_handler_func_t*)onSrtpEvent);
// if (DepLibSRTP::IsError(err)) // if (DepLibSRTP::IsError(err))
// { // {
// MS_THROW_ERROR("srtp_install_event_handler() failed: %s", DepLibSRTP::GetErrorString(err)); // MS_THROW_ERROR("srtp_install_event_handler() failed: %s", DepLibSRTP::GetErrorString(err));
// } // }
} }
// void SRTPSession::onSRTPEvent(srtp_event_data_t* data) // void SrtpSession::onSrtpEvent(srtp_event_data_t* data)
// { // {
// MS_TRACE(); // MS_TRACE();
...@@ -57,7 +57,7 @@ namespace RTC ...@@ -57,7 +57,7 @@ namespace RTC
/* Instance methods. */ /* Instance methods. */
SRTPSession::SRTPSession(Type type, Profile profile, uint8_t* key, size_t key_len) SrtpSession::SrtpSession(Type type, Profile profile, uint8_t* key, size_t key_len)
{ {
MS_TRACE(); MS_TRACE();
...@@ -92,7 +92,7 @@ namespace RTC ...@@ -92,7 +92,7 @@ namespace RTC
policy.ssrc.type = ssrc_any_outbound; policy.ssrc.type = ssrc_any_outbound;
break; break;
default: default:
MS_ABORT("unknown SRTPSession::Type"); MS_ABORT("unknown SrtpSession::Type");
} }
policy.ssrc.value = 0; policy.ssrc.value = 0;
policy.key = key; policy.key = key;
...@@ -108,7 +108,7 @@ namespace RTC ...@@ -108,7 +108,7 @@ namespace RTC
} }
} }
SRTPSession::~SRTPSession() SrtpSession::~SrtpSession()
{ {
MS_TRACE(); MS_TRACE();
...@@ -126,7 +126,7 @@ namespace RTC ...@@ -126,7 +126,7 @@ namespace RTC
// TODO: It must not memcpy it but instead the provided packet must already be // TODO: It must not memcpy it but instead the provided packet must already be
// allocated into a buffer. // allocated into a buffer.
bool SRTPSession::EncryptRTP(const uint8_t** data, size_t* len) bool SrtpSession::EncryptRtp(const uint8_t** data, size_t* len)
{ {
MS_TRACE(); MS_TRACE();
...@@ -139,9 +139,9 @@ namespace RTC ...@@ -139,9 +139,9 @@ namespace RTC
return false; return false;
} }
std::memcpy(SRTPSession::encryptBuffer, *data, *len); std::memcpy(SrtpSession::encryptBuffer, *data, *len);
this->lastError = srtp_protect(this->session, (void*)SRTPSession::encryptBuffer, (int*)len); this->lastError = srtp_protect(this->session, (void*)SrtpSession::encryptBuffer, (int*)len);
if (DepLibSRTP::IsError(this->lastError)) if (DepLibSRTP::IsError(this->lastError))
{ {
MS_DEBUG("srtp_protect() failed: %s", DepLibSRTP::GetErrorString(this->lastError)); MS_DEBUG("srtp_protect() failed: %s", DepLibSRTP::GetErrorString(this->lastError));
...@@ -150,12 +150,12 @@ namespace RTC ...@@ -150,12 +150,12 @@ namespace RTC
} }
// Update the given data pointer. // Update the given data pointer.
*data = (const uint8_t*)SRTPSession::encryptBuffer; *data = (const uint8_t*)SrtpSession::encryptBuffer;
return true; return true;
} }
bool SRTPSession::DecryptSRTP(const uint8_t* data, size_t* len) bool SrtpSession::DecryptSrtp(const uint8_t* data, size_t* len)
{ {
MS_TRACE(); MS_TRACE();
...@@ -170,7 +170,7 @@ namespace RTC ...@@ -170,7 +170,7 @@ namespace RTC
return true; return true;
} }
bool SRTPSession::EncryptRTCP(const uint8_t** data, size_t* len) bool SrtpSession::EncryptRtcp(const uint8_t** data, size_t* len)
{ {
MS_TRACE(); MS_TRACE();
...@@ -183,9 +183,9 @@ namespace RTC ...@@ -183,9 +183,9 @@ namespace RTC
return false; return false;
} }
std::memcpy(SRTPSession::encryptBuffer, *data, *len); std::memcpy(SrtpSession::encryptBuffer, *data, *len);
this->lastError = srtp_protect_rtcp(this->session, (void*)SRTPSession::encryptBuffer, (int*)len); this->lastError = srtp_protect_rtcp(this->session, (void*)SrtpSession::encryptBuffer, (int*)len);
if (DepLibSRTP::IsError(this->lastError)) if (DepLibSRTP::IsError(this->lastError))
{ {
MS_DEBUG("srtp_protect_rtcp() failed: %s", DepLibSRTP::GetErrorString(this->lastError)); MS_DEBUG("srtp_protect_rtcp() failed: %s", DepLibSRTP::GetErrorString(this->lastError));
...@@ -194,12 +194,12 @@ namespace RTC ...@@ -194,12 +194,12 @@ namespace RTC
} }
// Update the given data pointer. // Update the given data pointer.
*data = (const uint8_t*)SRTPSession::encryptBuffer; *data = (const uint8_t*)SrtpSession::encryptBuffer;
return true; return true;
} }
bool SRTPSession::DecryptSRTCP(const uint8_t* data, size_t* len) bool SrtpSession::DecryptSrtcp(const uint8_t* data, size_t* len)
{ {
MS_TRACE(); MS_TRACE();
...@@ -214,7 +214,7 @@ namespace RTC ...@@ -214,7 +214,7 @@ namespace RTC
return true; return true;
} }
void SRTPSession::Close() void SrtpSession::Close()
{ {
MS_TRACE(); MS_TRACE();
......
#define MS_CLASS "RTC::STUNMessage" #define MS_CLASS "RTC::StunMessage"
#include "RTC/STUNMessage.h" #include "RTC/StunMessage.h"
#include "Utils.h" #include "Utils.h"
#include "Logger.h" #include "Logger.h"
#include <cstdio> // std::snprintf() #include <cstdio> // std::snprintf()
...@@ -10,15 +10,15 @@ namespace RTC ...@@ -10,15 +10,15 @@ namespace RTC
{ {
/* Class variables. */ /* Class variables. */
const uint8_t STUNMessage::magicCookie[] = {0x21, 0x12, 0xA4, 0x42}; const uint8_t StunMessage::magicCookie[] = {0x21, 0x12, 0xA4, 0x42};
/* Class methods. */ /* Class methods. */
STUNMessage* STUNMessage::Parse(const uint8_t* data, size_t len) StunMessage* StunMessage::Parse(const uint8_t* data, size_t len)
{ {
MS_TRACE(); MS_TRACE();
if (!STUNMessage::IsSTUN(data, len)) if (!StunMessage::IsStun(data, len))
return nullptr; return nullptr;
/* /*
...@@ -60,8 +60,8 @@ namespace RTC ...@@ -60,8 +60,8 @@ namespace RTC
// Get STUN class. // Get STUN class.
uint16_t msg_class = ((data[0] & 0x01) << 1) | ((data[1] & 0x10) >> 4); uint16_t msg_class = ((data[0] & 0x01) << 1) | ((data[1] & 0x10) >> 4);
// Create a new STUNMessage (data + 8 points to the received TransactionID field). // Create a new StunMessage (data + 8 points to the received TransactionID field).
STUNMessage* msg = new STUNMessage((Class)msg_class, (Method)msg_method, data + 8, data, len); StunMessage* msg = new StunMessage((Class)msg_class, (Method)msg_method, data + 8, data, len);
/* /*
STUN Attributes STUN Attributes
...@@ -201,7 +201,7 @@ namespace RTC ...@@ -201,7 +201,7 @@ namespace RTC
/* Instance methods. */ /* Instance methods. */
STUNMessage::STUNMessage(Class klass, Method method, const uint8_t* transactionId, const uint8_t* raw, size_t length) : StunMessage::StunMessage(Class klass, Method method, const uint8_t* transactionId, const uint8_t* raw, size_t length) :
klass(klass), klass(klass),
method(method), method(method),
transactionId(transactionId), transactionId(transactionId),
...@@ -211,7 +211,7 @@ namespace RTC ...@@ -211,7 +211,7 @@ namespace RTC
MS_TRACE(); MS_TRACE();
} }
STUNMessage::~STUNMessage() StunMessage::~StunMessage()
{ {
MS_TRACE(); MS_TRACE();
...@@ -219,14 +219,14 @@ namespace RTC ...@@ -219,14 +219,14 @@ namespace RTC
delete this->raw; delete this->raw;
} }
void STUNMessage::Dump() void StunMessage::Dump()
{ {
MS_TRACE(); MS_TRACE();
if (!Logger::HasDebugLevel()) if (!Logger::HasDebugLevel())
return; return;
MS_DEBUG("<STUNMessage>"); MS_DEBUG("<StunMessage>");
std::string klass; std::string klass;
switch (this->klass) switch (this->klass)
{ {
...@@ -279,10 +279,10 @@ namespace RTC ...@@ -279,10 +279,10 @@ namespace RTC
} }
if (this->hasFingerprint) if (this->hasFingerprint)
MS_DEBUG("fingerprint"); MS_DEBUG("fingerprint");
MS_DEBUG("</STUNMessage>"); MS_DEBUG("</StunMessage>");
} }
STUNMessage::Authentication STUNMessage::CheckAuthentication(const std::string &local_username, const std::string &local_password) StunMessage::Authentication StunMessage::CheckAuthentication(const std::string &local_username, const std::string &local_password)
{ {
MS_TRACE(); MS_TRACE();
...@@ -341,29 +341,29 @@ namespace RTC ...@@ -341,29 +341,29 @@ namespace RTC
return result; return result;
} }
STUNMessage* STUNMessage::CreateSuccessResponse() StunMessage* StunMessage::CreateSuccessResponse()
{ {
MS_TRACE(); MS_TRACE();
MS_ASSERT(this->klass == Class::Request, "attempt to create a success response for a non Request STUN message"); MS_ASSERT(this->klass == Class::Request, "attempt to create a success response for a non Request STUN message");
return new STUNMessage(Class::SuccessResponse, this->method, this->transactionId, nullptr, 0); return new StunMessage(Class::SuccessResponse, this->method, this->transactionId, nullptr, 0);
} }
STUNMessage* STUNMessage::CreateErrorResponse(uint16_t errorCode) StunMessage* StunMessage::CreateErrorResponse(uint16_t errorCode)
{ {
MS_TRACE(); MS_TRACE();
MS_ASSERT(this->klass == Class::Request, "attempt to create an error response for a non Request STUN message"); MS_ASSERT(this->klass == Class::Request, "attempt to create an error response for a non Request STUN message");
STUNMessage* response = new STUNMessage(Class::ErrorResponse, this->method, this->transactionId, nullptr, 0); StunMessage* response = new StunMessage(Class::ErrorResponse, this->method, this->transactionId, nullptr, 0);
response->SetErrorCode(errorCode); response->SetErrorCode(errorCode);
return response; return response;
} }
void STUNMessage::Authenticate(const std::string &password) void StunMessage::Authenticate(const std::string &password)
{ {
// Just for Request, Indication and SuccessResponse messages. // Just for Request, Indication and SuccessResponse messages.
if (this->klass == Class::ErrorResponse) if (this->klass == Class::ErrorResponse)
...@@ -376,7 +376,7 @@ namespace RTC ...@@ -376,7 +376,7 @@ namespace RTC
this->password = password; this->password = password;
} }
void STUNMessage::Serialize() void StunMessage::Serialize()
{ {
MS_TRACE(); MS_TRACE();
...@@ -389,7 +389,7 @@ namespace RTC ...@@ -389,7 +389,7 @@ namespace RTC
// Some useful variables. // Some useful variables.
uint16_t username_padded_len = 0; uint16_t username_padded_len = 0;
uint16_t xor_mapped_address_padded_len = 0; uint16_t xor_mapped_address_padded_len = 0;
bool add_xor_mapped_address = (this->xorMappedAddress && this->method == STUNMessage::Method::Binding && this->klass == Class::SuccessResponse); bool add_xor_mapped_address = (this->xorMappedAddress && this->method == StunMessage::Method::Binding && this->klass == Class::SuccessResponse);
bool add_error_code = (this->errorCode && this->klass == Class::ErrorResponse); bool add_error_code = (this->errorCode && this->klass == Class::ErrorResponse);
bool add_message_integrity = (this->klass != Class::ErrorResponse && !this->password.empty()); bool add_message_integrity = (this->klass != Class::ErrorResponse && !this->password.empty());
bool add_fingerprint = true; // Do always. bool add_fingerprint = true; // Do always.
...@@ -459,7 +459,7 @@ namespace RTC ...@@ -459,7 +459,7 @@ namespace RTC
Utils::Byte::Set2Bytes(this->raw, 2, (uint16_t)this->length - 20); Utils::Byte::Set2Bytes(this->raw, 2, (uint16_t)this->length - 20);
// Set magic cookie. // Set magic cookie.
std::memcpy(this->raw + 4, STUNMessage::magicCookie, 4); std::memcpy(this->raw + 4, StunMessage::magicCookie, 4);
// Set TransactionId field. // Set TransactionId field.
std::memcpy(this->raw + 8, this->transactionId, 12); std::memcpy(this->raw + 8, this->transactionId, 12);
...@@ -529,14 +529,14 @@ namespace RTC ...@@ -529,14 +529,14 @@ namespace RTC
attr_value[1] = 0x01; attr_value[1] = 0x01;
// Set port and XOR it. // Set port and XOR it.
std::memcpy(attr_value + 2, &((const sockaddr_in*)(this->xorMappedAddress))->sin_port, 2); std::memcpy(attr_value + 2, &((const sockaddr_in*)(this->xorMappedAddress))->sin_port, 2);
attr_value[2] ^= STUNMessage::magicCookie[0]; attr_value[2] ^= StunMessage::magicCookie[0];
attr_value[3] ^= STUNMessage::magicCookie[1]; attr_value[3] ^= StunMessage::magicCookie[1];
// Set address and XOR it. // Set address and XOR it.
std::memcpy(attr_value + 4, &((const sockaddr_in*)this->xorMappedAddress)->sin_addr.s_addr, 4); std::memcpy(attr_value + 4, &((const sockaddr_in*)this->xorMappedAddress)->sin_addr.s_addr, 4);
attr_value[4] ^= STUNMessage::magicCookie[0]; attr_value[4] ^= StunMessage::magicCookie[0];
attr_value[5] ^= STUNMessage::magicCookie[1]; attr_value[5] ^= StunMessage::magicCookie[1];
attr_value[6] ^= STUNMessage::magicCookie[2]; attr_value[6] ^= StunMessage::magicCookie[2];
attr_value[7] ^= STUNMessage::magicCookie[3]; attr_value[7] ^= StunMessage::magicCookie[3];
pos += 4 + 8; pos += 4 + 8;
break; break;
...@@ -549,14 +549,14 @@ namespace RTC ...@@ -549,14 +549,14 @@ namespace RTC
attr_value[1] = 0x02; attr_value[1] = 0x02;
// Set port and XOR it. // Set port and XOR it.
std::memcpy(attr_value + 2, &((const sockaddr_in6*)(this->xorMappedAddress))->sin6_port, 2); std::memcpy(attr_value + 2, &((const sockaddr_in6*)(this->xorMappedAddress))->sin6_port, 2);
attr_value[2] ^= STUNMessage::magicCookie[0]; attr_value[2] ^= StunMessage::magicCookie[0];
attr_value[3] ^= STUNMessage::magicCookie[1]; attr_value[3] ^= StunMessage::magicCookie[1];
// Set address and XOR it. // Set address and XOR it.
std::memcpy(attr_value + 4, &((const sockaddr_in6*)this->xorMappedAddress)->sin6_addr.s6_addr, 16); std::memcpy(attr_value + 4, &((const sockaddr_in6*)this->xorMappedAddress)->sin6_addr.s6_addr, 16);
attr_value[4] ^= STUNMessage::magicCookie[0]; attr_value[4] ^= StunMessage::magicCookie[0];
attr_value[5] ^= STUNMessage::magicCookie[1]; attr_value[5] ^= StunMessage::magicCookie[1];
attr_value[6] ^= STUNMessage::magicCookie[2]; attr_value[6] ^= StunMessage::magicCookie[2];
attr_value[7] ^= STUNMessage::magicCookie[3]; attr_value[7] ^= StunMessage::magicCookie[3];
attr_value[8] ^= this->transactionId[0]; attr_value[8] ^= this->transactionId[0];
attr_value[9] ^= this->transactionId[1]; attr_value[9] ^= this->transactionId[1];
attr_value[10] ^= this->transactionId[2]; attr_value[10] ^= this->transactionId[2];
......
#define MS_CLASS "RTC::TCPConnection" #define MS_CLASS "RTC::TcpConnection"
#include "RTC/TCPConnection.h" #include "RTC/TcpConnection.h"
#include "Utils.h" #include "Utils.h"
#include "Logger.h" #include "Logger.h"
#include <cstring> // std::memmove() #include <cstring> // std::memmove()
...@@ -9,19 +9,19 @@ namespace RTC ...@@ -9,19 +9,19 @@ namespace RTC
{ {
/* Instance methods. */ /* Instance methods. */
TCPConnection::TCPConnection(Listener* listener, size_t bufferSize) : TcpConnection::TcpConnection(Listener* listener, size_t bufferSize) :
::TCPConnection(bufferSize), ::TcpConnection(bufferSize),
listener(listener) listener(listener)
{ {
MS_TRACE(); MS_TRACE();
} }
TCPConnection::~TCPConnection() TcpConnection::~TcpConnection()
{ {
MS_TRACE(); MS_TRACE();
} }
void TCPConnection::userOnTCPConnectionRead() void TcpConnection::userOnTcpConnectionRead()
{ {
MS_TRACE(); MS_TRACE();
...@@ -139,7 +139,7 @@ namespace RTC ...@@ -139,7 +139,7 @@ namespace RTC
} }
} }
void TCPConnection::Send(const uint8_t* data, size_t len) void TcpConnection::Send(const uint8_t* data, size_t len)
{ {
MS_TRACE(); MS_TRACE();
......
#define MS_CLASS "RTC::TCPServer" #define MS_CLASS "RTC::TcpServer"
#include "RTC/TCPServer.h" #include "RTC/TcpServer.h"
#include "RTC/STUNMessage.h"
#include "RTC/RTPPacket.h"
#include "Settings.h" #include "Settings.h"
#include "Utils.h" #include "Utils.h"
#include "DepLibUV.h" #include "DepLibUV.h"
...@@ -25,16 +23,16 @@ namespace RTC ...@@ -25,16 +23,16 @@ namespace RTC
{ {
/* Class variables. */ /* Class variables. */
struct sockaddr_storage TCPServer::sockaddrStorageIPv4; struct sockaddr_storage TcpServer::sockaddrStorageIPv4;
struct sockaddr_storage TCPServer::sockaddrStorageIPv6; struct sockaddr_storage TcpServer::sockaddrStorageIPv6;
uint16_t TCPServer::minPort; uint16_t TcpServer::minPort;
uint16_t TCPServer::maxPort; uint16_t TcpServer::maxPort;
std::unordered_map<uint16_t, bool> TCPServer::availableIPv4Ports; std::unordered_map<uint16_t, bool> TcpServer::availableIPv4Ports;
std::unordered_map<uint16_t, bool> TCPServer::availableIPv6Ports; std::unordered_map<uint16_t, bool> TcpServer::availableIPv6Ports;
/* Class methods. */ /* Class methods. */
void TCPServer::ClassInit() void TcpServer::ClassInit()
{ {
MS_TRACE(); MS_TRACE();
...@@ -42,31 +40,31 @@ namespace RTC ...@@ -42,31 +40,31 @@ namespace RTC
if (!Settings::configuration.rtcListenIPv4.empty()) if (!Settings::configuration.rtcListenIPv4.empty())
{ {
err = uv_ip4_addr(Settings::configuration.rtcListenIPv4.c_str(), 0, (struct sockaddr_in*)&RTC::TCPServer::sockaddrStorageIPv4); err = uv_ip4_addr(Settings::configuration.rtcListenIPv4.c_str(), 0, (struct sockaddr_in*)&RTC::TcpServer::sockaddrStorageIPv4);
if (err) if (err)
MS_ABORT("uv_ipv4_addr() failed: %s", uv_strerror(err)); MS_ABORT("uv_ipv4_addr() failed: %s", uv_strerror(err));
} }
if (!Settings::configuration.rtcListenIPv6.empty()) if (!Settings::configuration.rtcListenIPv6.empty())
{ {
err = uv_ip6_addr(Settings::configuration.rtcListenIPv6.c_str(), 0, (struct sockaddr_in6*)&RTC::TCPServer::sockaddrStorageIPv6); err = uv_ip6_addr(Settings::configuration.rtcListenIPv6.c_str(), 0, (struct sockaddr_in6*)&RTC::TcpServer::sockaddrStorageIPv6);
if (err) if (err)
MS_ABORT("uv_ipv6_addr() failed: %s", uv_strerror(err)); MS_ABORT("uv_ipv6_addr() failed: %s", uv_strerror(err));
} }
TCPServer::minPort = Settings::configuration.rtcMinPort; TcpServer::minPort = Settings::configuration.rtcMinPort;
TCPServer::maxPort = Settings::configuration.rtcMaxPort; TcpServer::maxPort = Settings::configuration.rtcMaxPort;
uint16_t i = RTC::TCPServer::minPort; uint16_t i = RTC::TcpServer::minPort;
do do
{ {
RTC::TCPServer::availableIPv4Ports[i] = true; RTC::TcpServer::availableIPv4Ports[i] = true;
RTC::TCPServer::availableIPv6Ports[i] = true; RTC::TcpServer::availableIPv6Ports[i] = true;
} }
while (i++ != RTC::TCPServer::maxPort); while (i++ != RTC::TcpServer::maxPort);
} }
uv_tcp_t* TCPServer::GetRandomPort(int address_family) uv_tcp_t* TcpServer::GetRandomPort(int address_family)
{ {
MS_TRACE(); MS_TRACE();
...@@ -89,14 +87,14 @@ namespace RTC ...@@ -89,14 +87,14 @@ namespace RTC
switch (address_family) switch (address_family)
{ {
case AF_INET: case AF_INET:
available_ports = &RTC::TCPServer::availableIPv4Ports; available_ports = &RTC::TcpServer::availableIPv4Ports;
bind_addr = RTC::TCPServer::sockaddrStorageIPv4; bind_addr = RTC::TcpServer::sockaddrStorageIPv4;
listen_ip = Settings::configuration.rtcListenIPv4.c_str(); listen_ip = Settings::configuration.rtcListenIPv4.c_str();
break; break;
case AF_INET6: case AF_INET6:
available_ports = &RTC::TCPServer::availableIPv6Ports; available_ports = &RTC::TcpServer::availableIPv6Ports;
bind_addr = RTC::TCPServer::sockaddrStorageIPv6; bind_addr = RTC::TcpServer::sockaddrStorageIPv6;
listen_ip = Settings::configuration.rtcListenIPv6.c_str(); listen_ip = Settings::configuration.rtcListenIPv6.c_str();
// Don't also bind into IPv4 when listening in IPv6. // Don't also bind into IPv4 when listening in IPv6.
flags |= UV_TCP_IPV6ONLY; flags |= UV_TCP_IPV6ONLY;
...@@ -108,7 +106,7 @@ namespace RTC ...@@ -108,7 +106,7 @@ namespace RTC
} }
// Choose a random first port to start from. // Choose a random first port to start from.
initial_port = (uint16_t)Utils::Crypto::GetRandomUInt((uint32_t)RTC::TCPServer::minPort, (uint32_t)RTC::TCPServer::maxPort); initial_port = (uint16_t)Utils::Crypto::GetRandomUInt((uint32_t)RTC::TcpServer::minPort, (uint32_t)RTC::TcpServer::maxPort);
iterating_port = initial_port; iterating_port = initial_port;
...@@ -119,10 +117,10 @@ namespace RTC ...@@ -119,10 +117,10 @@ namespace RTC
attempt++; attempt++;
// Increase the iterate port) within the range of RTC TCP ports. // Increase the iterate port) within the range of RTC TCP ports.
if (iterating_port < RTC::TCPServer::maxPort) if (iterating_port < RTC::TcpServer::maxPort)
iterating_port += 1; iterating_port += 1;
else else
iterating_port = RTC::TCPServer::minPort; iterating_port = RTC::TcpServer::minPort;
// Check whether the chosen port is available. // Check whether the chosen port is available.
if (!(*available_ports)[iterating_port]) if (!(*available_ports)[iterating_port])
...@@ -204,26 +202,26 @@ namespace RTC ...@@ -204,26 +202,26 @@ namespace RTC
/* Instance methods. */ /* Instance methods. */
TCPServer::TCPServer(Listener* listener, RTC::TCPConnection::Listener* connListener, int address_family) : TcpServer::TcpServer(Listener* listener, RTC::TcpConnection::Listener* connListener, int address_family) :
// Provide the parent class constructor with a UDP uv handle. // Provide the parent class constructor with a UDP uv handle.
// NOTE: This may throw a MediaSoupError exception if the address family is not available // NOTE: This may throw a MediaSoupError exception if the address family is not available
// or there are no available ports. // or there are no available ports.
::TCPServer::TCPServer(GetRandomPort(address_family), 256), ::TcpServer::TcpServer(GetRandomPort(address_family), 256),
listener(listener), listener(listener),
connListener(connListener) connListener(connListener)
{ {
MS_TRACE(); MS_TRACE();
} }
void TCPServer::userOnTCPConnectionAlloc(::TCPConnection** connection) void TcpServer::userOnTcpConnectionAlloc(::TcpConnection** connection)
{ {
MS_TRACE(); MS_TRACE();
// Allocate a new RTC::TCPConnection for the TCPServer to handle it. // Allocate a new RTC::TcpConnection for the TcpServer to handle it.
*connection = new RTC::TCPConnection(this->connListener, 65536); *connection = new RTC::TcpConnection(this->connListener, 65536);
} }
void TCPServer::userOnNewTCPConnection(::TCPConnection* connection) void TcpServer::userOnNewTcpConnection(::TcpConnection* connection)
{ {
MS_TRACE(); MS_TRACE();
...@@ -232,7 +230,7 @@ namespace RTC ...@@ -232,7 +230,7 @@ namespace RTC
connection->Close(); connection->Close();
} }
void TCPServer::userOnTCPConnectionClosed(::TCPConnection* connection, bool is_closed_by_peer) void TcpServer::userOnTcpConnectionClosed(::TcpConnection* connection, bool is_closed_by_peer)
{ {
MS_TRACE(); MS_TRACE();
...@@ -240,17 +238,17 @@ namespace RTC ...@@ -240,17 +238,17 @@ namespace RTC
// NOTE: Don't do it if closing (since at this point the listener is already freed). // NOTE: Don't do it if closing (since at this point the listener is already freed).
// At the end, this is just called if the connection was remotely closed. // At the end, this is just called if the connection was remotely closed.
if (!IsClosing()) if (!IsClosing())
this->listener->onRTCTCPConnectionClosed(this, static_cast<RTC::TCPConnection*>(connection), is_closed_by_peer); this->listener->onRtcTcpConnectionClosed(this, static_cast<RTC::TcpConnection*>(connection), is_closed_by_peer);
} }
void TCPServer::userOnTCPServerClosed() void TcpServer::userOnTcpServerClosed()
{ {
MS_TRACE(); MS_TRACE();
// Mark the port as available again. // Mark the port as available again.
if (this->localAddr.ss_family == AF_INET) if (this->localAddr.ss_family == AF_INET)
RTC::TCPServer::availableIPv4Ports[this->localPort] = true; RTC::TcpServer::availableIPv4Ports[this->localPort] = true;
else if (this->localAddr.ss_family == AF_INET6) else if (this->localAddr.ss_family == AF_INET6)
RTC::TCPServer::availableIPv6Ports[this->localPort] = true; RTC::TcpServer::availableIPv6Ports[this->localPort] = true;
} }
} }
#define MS_CLASS "RTC::UDPSocket" #define MS_CLASS "RTC::UdpSocket"
#include "RTC/UDPSocket.h" #include "RTC/UdpSocket.h"
#include "Settings.h" #include "Settings.h"
#include "Utils.h" #include "Utils.h"
#include "DepLibUV.h" #include "DepLibUV.h"
...@@ -22,16 +22,16 @@ namespace RTC ...@@ -22,16 +22,16 @@ namespace RTC
{ {
/* Class variables. */ /* Class variables. */
struct sockaddr_storage UDPSocket::sockaddrStorageIPv4; struct sockaddr_storage UdpSocket::sockaddrStorageIPv4;
struct sockaddr_storage UDPSocket::sockaddrStorageIPv6; struct sockaddr_storage UdpSocket::sockaddrStorageIPv6;
uint16_t UDPSocket::minPort; uint16_t UdpSocket::minPort;
uint16_t UDPSocket::maxPort; uint16_t UdpSocket::maxPort;
std::unordered_map<uint16_t, bool> UDPSocket::availableIPv4Ports; std::unordered_map<uint16_t, bool> UdpSocket::availableIPv4Ports;
std::unordered_map<uint16_t, bool> UDPSocket::availableIPv6Ports; std::unordered_map<uint16_t, bool> UdpSocket::availableIPv6Ports;
/* Class methods. */ /* Class methods. */
void UDPSocket::ClassInit() void UdpSocket::ClassInit()
{ {
MS_TRACE(); MS_TRACE();
...@@ -39,31 +39,31 @@ namespace RTC ...@@ -39,31 +39,31 @@ namespace RTC
if (Settings::configuration.hasIPv4) if (Settings::configuration.hasIPv4)
{ {
err = uv_ip4_addr(Settings::configuration.rtcListenIPv4.c_str(), 0, (struct sockaddr_in*)&RTC::UDPSocket::sockaddrStorageIPv4); err = uv_ip4_addr(Settings::configuration.rtcListenIPv4.c_str(), 0, (struct sockaddr_in*)&RTC::UdpSocket::sockaddrStorageIPv4);
if (err) if (err)
MS_ABORT("uv_ipv4_addr() failed: %s", uv_strerror(err)); MS_ABORT("uv_ipv4_addr() failed: %s", uv_strerror(err));
} }
if (Settings::configuration.hasIPv6) if (Settings::configuration.hasIPv6)
{ {
err = uv_ip6_addr(Settings::configuration.rtcListenIPv6.c_str(), 0, (struct sockaddr_in6*)&RTC::UDPSocket::sockaddrStorageIPv6); err = uv_ip6_addr(Settings::configuration.rtcListenIPv6.c_str(), 0, (struct sockaddr_in6*)&RTC::UdpSocket::sockaddrStorageIPv6);
if (err) if (err)
MS_ABORT("uv_ipv6_addr() failed: %s", uv_strerror(err)); MS_ABORT("uv_ipv6_addr() failed: %s", uv_strerror(err));
} }
UDPSocket::minPort = Settings::configuration.rtcMinPort; UdpSocket::minPort = Settings::configuration.rtcMinPort;
UDPSocket::maxPort = Settings::configuration.rtcMaxPort; UdpSocket::maxPort = Settings::configuration.rtcMaxPort;
uint16_t i = RTC::UDPSocket::minPort; uint16_t i = RTC::UdpSocket::minPort;
do do
{ {
RTC::UDPSocket::availableIPv4Ports[i] = true; RTC::UdpSocket::availableIPv4Ports[i] = true;
RTC::UDPSocket::availableIPv6Ports[i] = true; RTC::UdpSocket::availableIPv6Ports[i] = true;
} }
while (i++ != RTC::UDPSocket::maxPort); while (i++ != RTC::UdpSocket::maxPort);
} }
uv_udp_t* UDPSocket::GetRandomPort(int address_family) uv_udp_t* UdpSocket::GetRandomPort(int address_family)
{ {
MS_TRACE(); MS_TRACE();
...@@ -86,14 +86,14 @@ namespace RTC ...@@ -86,14 +86,14 @@ namespace RTC
switch (address_family) switch (address_family)
{ {
case AF_INET: case AF_INET:
available_ports = &RTC::UDPSocket::availableIPv4Ports; available_ports = &RTC::UdpSocket::availableIPv4Ports;
bind_addr = RTC::UDPSocket::sockaddrStorageIPv4; bind_addr = RTC::UdpSocket::sockaddrStorageIPv4;
listen_ip = Settings::configuration.rtcListenIPv4.c_str(); listen_ip = Settings::configuration.rtcListenIPv4.c_str();
break; break;
case AF_INET6: case AF_INET6:
available_ports = &RTC::UDPSocket::availableIPv6Ports; available_ports = &RTC::UdpSocket::availableIPv6Ports;
bind_addr = RTC::UDPSocket::sockaddrStorageIPv6; bind_addr = RTC::UdpSocket::sockaddrStorageIPv6;
listen_ip = Settings::configuration.rtcListenIPv6.c_str(); listen_ip = Settings::configuration.rtcListenIPv6.c_str();
// Don't also bind into IPv4 when listening in IPv6. // Don't also bind into IPv4 when listening in IPv6.
flags |= UV_UDP_IPV6ONLY; flags |= UV_UDP_IPV6ONLY;
...@@ -105,7 +105,7 @@ namespace RTC ...@@ -105,7 +105,7 @@ namespace RTC
} }
// Choose a random port to start from. // Choose a random port to start from.
initial_port = (uint16_t)Utils::Crypto::GetRandomUInt((uint32_t)RTC::UDPSocket::minPort, (uint32_t)RTC::UDPSocket::maxPort); initial_port = (uint16_t)Utils::Crypto::GetRandomUInt((uint32_t)RTC::UdpSocket::minPort, (uint32_t)RTC::UdpSocket::maxPort);
iterating_port = initial_port; iterating_port = initial_port;
...@@ -116,10 +116,10 @@ namespace RTC ...@@ -116,10 +116,10 @@ namespace RTC
attempt++; attempt++;
// Increase the iterate port within the range of RTC UDP ports. // Increase the iterate port within the range of RTC UDP ports.
if (iterating_port < RTC::UDPSocket::maxPort) if (iterating_port < RTC::UdpSocket::maxPort)
iterating_port++; iterating_port++;
else else
iterating_port = RTC::UDPSocket::minPort; iterating_port = RTC::UdpSocket::minPort;
// Check whether the chosen port is available. // Check whether the chosen port is available.
if (!(*available_ports)[iterating_port]) if (!(*available_ports)[iterating_port])
...@@ -200,17 +200,17 @@ namespace RTC ...@@ -200,17 +200,17 @@ namespace RTC
/* Instance methods. */ /* Instance methods. */
UDPSocket::UDPSocket(Listener* listener, int address_family) : UdpSocket::UdpSocket(Listener* listener, int address_family) :
// Provide the parent class constructor with a UDP uv handle. // Provide the parent class constructor with a UDP uv handle.
// NOTE: This may throw a MediaSoupError exception if the address family is not available // NOTE: This may throw a MediaSoupError exception if the address family is not available
// or there are no available ports. // or there are no available ports.
::UDPSocket::UDPSocket(GetRandomPort(address_family)), ::UdpSocket::UdpSocket(GetRandomPort(address_family)),
listener(listener) listener(listener)
{ {
MS_TRACE(); MS_TRACE();
} }
void UDPSocket::userOnUDPDatagramRecv(const uint8_t* data, size_t len, const struct sockaddr* addr) void UdpSocket::userOnUdpDatagramRecv(const uint8_t* data, size_t len, const struct sockaddr* addr)
{ {
MS_TRACE(); MS_TRACE();
...@@ -236,14 +236,14 @@ namespace RTC ...@@ -236,14 +236,14 @@ namespace RTC
this->listener->onPacketRecv(this, data, len, addr); this->listener->onPacketRecv(this, data, len, addr);
} }
void UDPSocket::userOnUDPSocketClosed() void UdpSocket::userOnUdpSocketClosed()
{ {
MS_TRACE(); MS_TRACE();
// Mark the port as available again. // Mark the port as available again.
if (this->localAddr.ss_family == AF_INET) if (this->localAddr.ss_family == AF_INET)
RTC::UDPSocket::availableIPv4Ports[this->localPort] = true; RTC::UdpSocket::availableIPv4Ports[this->localPort] = true;
else if (this->localAddr.ss_family == AF_INET6) else if (this->localAddr.ss_family == AF_INET6)
RTC::UDPSocket::availableIPv6Ports[this->localPort] = true; RTC::UdpSocket::availableIPv6Ports[this->localPort] = true;
} }
} }
#define MS_CLASS "TCPConnection" #define MS_CLASS "TcpConnection"
#include "handles/TCPConnection.h" #include "handles/TcpConnection.h"
#include "Utils.h" #include "Utils.h"
#include "DepLibUV.h" #include "DepLibUV.h"
#include "MediaSoupError.h" #include "MediaSoupError.h"
...@@ -13,25 +13,25 @@ ...@@ -13,25 +13,25 @@
static inline static inline
void on_alloc(uv_handle_t* handle, size_t suggested_size, uv_buf_t* buf) void on_alloc(uv_handle_t* handle, size_t suggested_size, uv_buf_t* buf)
{ {
static_cast<TCPConnection*>(handle->data)->onUvReadAlloc(suggested_size, buf); static_cast<TcpConnection*>(handle->data)->onUvReadAlloc(suggested_size, buf);
} }
static inline static inline
void on_read(uv_stream_t* handle, ssize_t nread, const uv_buf_t* buf) void on_read(uv_stream_t* handle, ssize_t nread, const uv_buf_t* buf)
{ {
static_cast<TCPConnection*>(handle->data)->onUvRead(nread, buf); static_cast<TcpConnection*>(handle->data)->onUvRead(nread, buf);
} }
static inline static inline
void on_write(uv_write_t* req, int status) void on_write(uv_write_t* req, int status)
{ {
TCPConnection::UvWriteData* write_data = static_cast<TCPConnection::UvWriteData*>(req->data); TcpConnection::UvWriteData* write_data = static_cast<TcpConnection::UvWriteData*>(req->data);
TCPConnection* connection = write_data->connection; TcpConnection* connection = write_data->connection;
// Delete the UvWriteData struct (which includes the uv_req_t and the store char[]). // Delete the UvWriteData struct (which includes the uv_req_t and the store char[]).
std::free(write_data); std::free(write_data);
// Just notify the TCPConnection when error. // Just notify the TcpConnection when error.
if (status) if (status)
connection->onUvWriteError(status); connection->onUvWriteError(status);
} }
...@@ -39,18 +39,18 @@ void on_write(uv_write_t* req, int status) ...@@ -39,18 +39,18 @@ void on_write(uv_write_t* req, int status)
static inline static inline
void on_shutdown(uv_shutdown_t* req, int status) void on_shutdown(uv_shutdown_t* req, int status)
{ {
static_cast<TCPConnection*>(req->data)->onUvShutdown(req, status); static_cast<TcpConnection*>(req->data)->onUvShutdown(req, status);
} }
static inline static inline
void on_close(uv_handle_t* handle) void on_close(uv_handle_t* handle)
{ {
static_cast<TCPConnection*>(handle->data)->onUvClosed(); static_cast<TcpConnection*>(handle->data)->onUvClosed();
} }
/* Instance methods. */ /* Instance methods. */
TCPConnection::TCPConnection(size_t bufferSize) : TcpConnection::TcpConnection(size_t bufferSize) :
bufferSize(bufferSize) bufferSize(bufferSize)
{ {
MS_TRACE(); MS_TRACE();
...@@ -61,7 +61,7 @@ TCPConnection::TCPConnection(size_t bufferSize) : ...@@ -61,7 +61,7 @@ TCPConnection::TCPConnection(size_t 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() TcpConnection::~TcpConnection()
{ {
MS_TRACE(); MS_TRACE();
...@@ -71,7 +71,7 @@ TCPConnection::~TCPConnection() ...@@ -71,7 +71,7 @@ TCPConnection::~TCPConnection()
delete[] this->buffer; delete[] this->buffer;
} }
void TCPConnection::Setup(Listener* listener, struct sockaddr_storage* localAddr, const std::string &localIP, uint16_t localPort) void TcpConnection::Setup(Listener* listener, struct sockaddr_storage* localAddr, const std::string &localIP, uint16_t localPort)
{ {
MS_TRACE(); MS_TRACE();
...@@ -95,7 +95,7 @@ void TCPConnection::Setup(Listener* listener, struct sockaddr_storage* localAddr ...@@ -95,7 +95,7 @@ void TCPConnection::Setup(Listener* listener, struct sockaddr_storage* localAddr
this->localPort = localPort; this->localPort = localPort;
} }
void TCPConnection::Close() void TcpConnection::Close()
{ {
MS_TRACE(); MS_TRACE();
...@@ -129,15 +129,15 @@ void TCPConnection::Close() ...@@ -129,15 +129,15 @@ void TCPConnection::Close()
} }
} }
void TCPConnection::Dump() void TcpConnection::Dump()
{ {
MS_DEBUG("[TCP, local:%s :%" PRIu16 ", remote:%s :%" PRIu16 ", status:%s]", MS_DEBUG("[Tcp, local:%s :%" PRIu16 ", remote:%s :%" PRIu16 ", status:%s]",
this->localIP.c_str(), (uint16_t)this->localPort, this->localIP.c_str(), (uint16_t)this->localPort,
this->peerIP.c_str(), (uint16_t)this->peerPort, this->peerIP.c_str(), (uint16_t)this->peerPort,
(!this->isClosing) ? "open" : "closed"); (!this->isClosing) ? "open" : "closed");
} }
void TCPConnection::Start() void TcpConnection::Start()
{ {
MS_TRACE(); MS_TRACE();
...@@ -155,7 +155,7 @@ void TCPConnection::Start() ...@@ -155,7 +155,7 @@ 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) void TcpConnection::Write(const uint8_t* data, size_t len)
{ {
MS_TRACE(); MS_TRACE();
...@@ -213,7 +213,7 @@ void TCPConnection::Write(const uint8_t* data, size_t len) ...@@ -213,7 +213,7 @@ void TCPConnection::Write(const uint8_t* data, size_t len)
MS_ABORT("uv_write() failed: %s", uv_strerror(err)); MS_ABORT("uv_write() failed: %s", uv_strerror(err));
} }
void TCPConnection::Write(const uint8_t* data1, size_t len1, const uint8_t* data2, size_t len2) void TcpConnection::Write(const uint8_t* data1, size_t len1, const uint8_t* data2, size_t len2)
{ {
MS_TRACE(); MS_TRACE();
...@@ -283,7 +283,7 @@ void TCPConnection::Write(const uint8_t* data1, size_t len1, const uint8_t* data ...@@ -283,7 +283,7 @@ void TCPConnection::Write(const uint8_t* data1, size_t len1, const uint8_t* data
MS_ABORT("uv_write() failed: %s", uv_strerror(err)); MS_ABORT("uv_write() failed: %s", uv_strerror(err));
} }
bool TCPConnection::SetPeerAddress() bool TcpConnection::SetPeerAddress()
{ {
MS_TRACE(); MS_TRACE();
...@@ -305,7 +305,7 @@ bool TCPConnection::SetPeerAddress() ...@@ -305,7 +305,7 @@ bool TCPConnection::SetPeerAddress()
} }
inline inline
void TCPConnection::onUvReadAlloc(size_t suggested_size, uv_buf_t* buf) void TcpConnection::onUvReadAlloc(size_t suggested_size, uv_buf_t* buf)
{ {
MS_TRACE(); MS_TRACE();
...@@ -329,7 +329,7 @@ void TCPConnection::onUvReadAlloc(size_t suggested_size, uv_buf_t* buf) ...@@ -329,7 +329,7 @@ void TCPConnection::onUvReadAlloc(size_t suggested_size, uv_buf_t* buf)
} }
inline inline
void TCPConnection::onUvRead(ssize_t nread, const uv_buf_t* buf) void TcpConnection::onUvRead(ssize_t nread, const uv_buf_t* buf)
{ {
MS_TRACE(); MS_TRACE();
...@@ -346,7 +346,7 @@ void TCPConnection::onUvRead(ssize_t nread, const uv_buf_t* buf) ...@@ -346,7 +346,7 @@ void TCPConnection::onUvRead(ssize_t nread, const uv_buf_t* buf)
this->bufferDataLen += (size_t)nread; this->bufferDataLen += (size_t)nread;
// Notify the subclass. // Notify the subclass.
userOnTCPConnectionRead(); userOnTcpConnectionRead();
} }
// Client disconneted. // Client disconneted.
else if (nread == UV_EOF || nread == UV_ECONNRESET) else if (nread == UV_EOF || nread == UV_ECONNRESET)
...@@ -371,7 +371,7 @@ void TCPConnection::onUvRead(ssize_t nread, const uv_buf_t* buf) ...@@ -371,7 +371,7 @@ void TCPConnection::onUvRead(ssize_t nread, const uv_buf_t* buf)
} }
inline inline
void TCPConnection::onUvWriteError(int error) void TcpConnection::onUvWriteError(int error)
{ {
MS_TRACE(); MS_TRACE();
...@@ -393,7 +393,7 @@ void TCPConnection::onUvWriteError(int error) ...@@ -393,7 +393,7 @@ void TCPConnection::onUvWriteError(int error)
} }
inline inline
void TCPConnection::onUvShutdown(uv_shutdown_t* req, int status) void TcpConnection::onUvShutdown(uv_shutdown_t* req, int status)
{ {
MS_TRACE(); MS_TRACE();
...@@ -409,12 +409,12 @@ void TCPConnection::onUvShutdown(uv_shutdown_t* req, int status) ...@@ -409,12 +409,12 @@ void TCPConnection::onUvShutdown(uv_shutdown_t* req, int status)
} }
inline inline
void TCPConnection::onUvClosed() void TcpConnection::onUvClosed()
{ {
MS_TRACE(); MS_TRACE();
// Notify the listener. // Notify the listener.
this->listener->onTCPConnectionClosed(this, this->isClosedByPeer); this->listener->onTcpConnectionClosed(this, this->isClosedByPeer);
// And delete this. // And delete this.
delete this; delete this;
......
#define MS_CLASS "TCPServer" #define MS_CLASS "TcpServer"
#include "handles/TCPServer.h" #include "handles/TcpServer.h"
#include "Utils.h" #include "Utils.h"
#include "DepLibUV.h" #include "DepLibUV.h"
#include "MediaSoupError.h" #include "MediaSoupError.h"
...@@ -11,13 +11,13 @@ ...@@ -11,13 +11,13 @@
static inline static inline
void on_connection(uv_stream_t* handle, int status) void on_connection(uv_stream_t* handle, int status)
{ {
static_cast<TCPServer*>(handle->data)->onUvConnection(status); static_cast<TcpServer*>(handle->data)->onUvConnection(status);
} }
static inline static inline
void on_close(uv_handle_t* handle) void on_close(uv_handle_t* handle)
{ {
static_cast<TCPServer*>(handle->data)->onUvClosed(); static_cast<TcpServer*>(handle->data)->onUvClosed();
} }
static inline static inline
...@@ -28,7 +28,7 @@ void on_error_close(uv_handle_t* handle) ...@@ -28,7 +28,7 @@ void on_error_close(uv_handle_t* handle)
/* Instance methods. */ /* Instance methods. */
TCPServer::TCPServer(const std::string &ip, uint16_t port, int backlog) TcpServer::TcpServer(const std::string &ip, uint16_t port, int backlog)
{ {
MS_TRACE(); MS_TRACE();
...@@ -92,7 +92,7 @@ TCPServer::TCPServer(const std::string &ip, uint16_t port, int backlog) ...@@ -92,7 +92,7 @@ TCPServer::TCPServer(const std::string &ip, uint16_t port, int backlog)
} }
} }
TCPServer::TCPServer(uv_tcp_t* uvHandle, int backlog) : TcpServer::TcpServer(uv_tcp_t* uvHandle, int backlog) :
uvHandle(uvHandle) uvHandle(uvHandle)
{ {
MS_TRACE(); MS_TRACE();
...@@ -116,7 +116,7 @@ TCPServer::TCPServer(uv_tcp_t* uvHandle, int backlog) : ...@@ -116,7 +116,7 @@ TCPServer::TCPServer(uv_tcp_t* uvHandle, int backlog) :
} }
} }
TCPServer::~TCPServer() TcpServer::~TcpServer()
{ {
MS_TRACE(); MS_TRACE();
...@@ -124,7 +124,7 @@ TCPServer::~TCPServer() ...@@ -124,7 +124,7 @@ TCPServer::~TCPServer()
delete this->uvHandle; delete this->uvHandle;
} }
void TCPServer::Close() void TcpServer::Close()
{ {
MS_TRACE(); MS_TRACE();
...@@ -145,13 +145,13 @@ void TCPServer::Close() ...@@ -145,13 +145,13 @@ void TCPServer::Close()
for (auto it = this->connections.begin(); it != this->connections.end(); ++it) for (auto it = this->connections.begin(); it != this->connections.end(); ++it)
{ {
TCPConnection* connection = *it; TcpConnection* connection = *it;
connection->Close(); connection->Close();
} }
} }
} }
void TCPServer::Dump() void TcpServer::Dump()
{ {
MS_DEBUG("[TCP, local:%s :%" PRIu16 ", status:%s, connections:%zu]", MS_DEBUG("[TCP, local:%s :%" PRIu16 ", status:%s, connections:%zu]",
this->localIP.c_str(), (uint16_t)this->localPort, this->localIP.c_str(), (uint16_t)this->localPort,
...@@ -159,28 +159,28 @@ void TCPServer::Dump() ...@@ -159,28 +159,28 @@ void TCPServer::Dump()
this->connections.size()); this->connections.size());
} }
const struct sockaddr* TCPServer::GetLocalAddress() const struct sockaddr* TcpServer::GetLocalAddress()
{ {
MS_TRACE(); MS_TRACE();
return (const struct sockaddr*)&this->localAddr; return (const struct sockaddr*)&this->localAddr;
} }
const std::string& TCPServer::GetLocalIP() const std::string& TcpServer::GetLocalIP()
{ {
MS_TRACE(); MS_TRACE();
return this->localIP; return this->localIP;
} }
uint16_t TCPServer::GetLocalPort() uint16_t TcpServer::GetLocalPort()
{ {
MS_TRACE(); MS_TRACE();
return this->localPort; return this->localPort;
} }
bool TCPServer::SetLocalAddress() bool TcpServer::SetLocalAddress()
{ {
MS_TRACE(); MS_TRACE();
...@@ -202,7 +202,7 @@ bool TCPServer::SetLocalAddress() ...@@ -202,7 +202,7 @@ bool TCPServer::SetLocalAddress()
} }
inline inline
void TCPServer::onUvConnection(int status) void TcpServer::onUvConnection(int status)
{ {
MS_TRACE(); MS_TRACE();
...@@ -219,9 +219,9 @@ void TCPServer::onUvConnection(int status) ...@@ -219,9 +219,9 @@ void TCPServer::onUvConnection(int status)
} }
// Notify the subclass so it provides an allocated derived class of TCPConnection. // Notify the subclass so it provides an allocated derived class of TCPConnection.
TCPConnection* connection = nullptr; TcpConnection* connection = nullptr;
userOnTCPConnectionAlloc(&connection); userOnTcpConnectionAlloc(&connection);
MS_ASSERT(connection != nullptr, "TCPConnection pointer was not allocated by the user"); MS_ASSERT(connection != nullptr, "TcpConnection pointer was not allocated by the user");
try try
{ {
...@@ -238,7 +238,7 @@ void TCPServer::onUvConnection(int status) ...@@ -238,7 +238,7 @@ void TCPServer::onUvConnection(int status)
if (err) if (err)
MS_ABORT("uv_accept() failed: %s", uv_strerror(err)); MS_ABORT("uv_accept() failed: %s", uv_strerror(err));
// Insert the TCPConnection in the set. // Insert the TcpConnection in the set.
this->connections.insert(connection); this->connections.insert(connection);
// Start receiving data. // Start receiving data.
...@@ -249,56 +249,55 @@ void TCPServer::onUvConnection(int status) ...@@ -249,56 +249,55 @@ void TCPServer::onUvConnection(int status)
catch (const MediaSoupError &error) catch (const MediaSoupError &error)
{ {
MS_ERROR("cannot run the TCP connection, closing the connection: %s", error.what()); MS_ERROR("cannot run the TCP connection, closing the connection: %s", error.what());
connection->Close(); connection->Close();
// NOTE: Don't return here so the user won't be notified about a "onclose" for a TCP connection
// for which there was not a previous "onnew" event.
}
MS_DEBUG("new TCP connection:"); // NOTE: Don't return here so the user won't be notified about a TCP connection
connection->Dump(); // closure for which there was not a previous creation event.
}
// Notify the subclass. // Notify the subclass.
userOnNewTCPConnection(connection); userOnNewTcpConnection(connection);
} }
inline inline
void TCPServer::onUvClosed() void TcpServer::onUvClosed()
{ {
MS_TRACE(); MS_TRACE();
// Motify the subclass. // Motify the subclass.
userOnTCPServerClosed(); userOnTcpServerClosed();
// And delete this. // And delete this.
delete this; delete this;
} }
inline inline
void TCPServer::onTCPConnectionClosed(TCPConnection* connection, bool is_closed_by_peer) void TcpServer::onTcpConnectionClosed(TcpConnection* connection, bool is_closed_by_peer)
{ {
MS_TRACE(); MS_TRACE();
// NOTE: // NOTE:
// Worst scenario is that in which this is the latest connection, // Worst scenario is that in which this is the latest connection,
// which is remotely closed (no TCPServer.Close() was called) and the user // which is remotely closed (no TcpServer.Close() was called) and the user
// call TCPServer.Close() on userOnTCPConnectionClosed() callback, so Close() // call TcpServer.Close() on userOnTcpConnectionClosed() callback, so Close()
// is called with zero connections and calls uv_close(), but then // is called with zero connections and calls uv_close(), but then
// onTCPConnectionClosed() continues and finds that isClosing is true and // onTcpConnectionClosed() continues and finds that isClosing is true and
// there are zero connections, so calls uv_close() again and get a crash. // there are zero connections, so calls uv_close() again and get a crash.
// //
// SOLUTION: // SOLUTION:
// Check isClosing value *before* onTCPConnectionClosed() callback. // Check isClosing value *before* onTcpConnectionClosed() callback.
bool wasClosing = this->isClosing; bool wasClosing = this->isClosing;
MS_DEBUG("TCP connection closed:"); MS_DEBUG("TCP connection closed:");
connection->Dump(); connection->Dump();
// Remove the TCPConnection from the set. // Remove the TcpConnection from the set.
this->connections.erase(connection); this->connections.erase(connection);
// Notify the subclass. // Notify the subclass.
userOnTCPConnectionClosed(connection, is_closed_by_peer); userOnTcpConnectionClosed(connection, is_closed_by_peer);
// Check if the server was closing connections, and if this is the last // Check if the server was closing connections, and if this is the last
// connection then close the server now. // connection then close the server now.
......
#define MS_CLASS "UDPSocket" #define MS_CLASS "UdpSocket"
#include "handles/UDPSocket.h" #include "handles/UdpSocket.h"
#include "Utils.h" #include "Utils.h"
#include "DepLibUV.h" #include "DepLibUV.h"
#include "MediaSoupError.h" #include "MediaSoupError.h"
...@@ -13,25 +13,25 @@ ...@@ -13,25 +13,25 @@
static inline static inline
void on_alloc(uv_handle_t* handle, size_t suggested_size, uv_buf_t* buf) void on_alloc(uv_handle_t* handle, size_t suggested_size, uv_buf_t* buf)
{ {
static_cast<UDPSocket*>(handle->data)->onUvRecvAlloc(suggested_size, buf); static_cast<UdpSocket*>(handle->data)->onUvRecvAlloc(suggested_size, buf);
} }
static inline static inline
void on_recv(uv_udp_t* handle, ssize_t nread, const uv_buf_t* buf, const struct sockaddr* addr, unsigned int flags) void on_recv(uv_udp_t* handle, ssize_t nread, const uv_buf_t* buf, const struct sockaddr* addr, unsigned int flags)
{ {
static_cast<UDPSocket*>(handle->data)->onUvRecv(nread, buf, addr, flags); static_cast<UdpSocket*>(handle->data)->onUvRecv(nread, buf, addr, flags);
} }
static inline static inline
void on_send(uv_udp_send_t* req, int status) void on_send(uv_udp_send_t* req, int status)
{ {
UDPSocket::UvSendData* send_data = static_cast<UDPSocket::UvSendData*>(req->data); UdpSocket::UvSendData* send_data = static_cast<UdpSocket::UvSendData*>(req->data);
UDPSocket* socket = send_data->socket; UdpSocket* socket = send_data->socket;
// Delete the UvSendData struct (which includes the uv_req_t and the store char[]). // Delete the UvSendData struct (which includes the uv_req_t and the store char[]).
std::free(send_data); std::free(send_data);
// Just notify the UDPSocket when error. // Just notify the UdpSocket when error.
if (status) if (status)
socket->onUvSendError(status); socket->onUvSendError(status);
} }
...@@ -39,7 +39,7 @@ void on_send(uv_udp_send_t* req, int status) ...@@ -39,7 +39,7 @@ void on_send(uv_udp_send_t* req, int status)
static inline static inline
void on_close(uv_handle_t* handle) void on_close(uv_handle_t* handle)
{ {
static_cast<UDPSocket*>(handle->data)->onUvClosed(); static_cast<UdpSocket*>(handle->data)->onUvClosed();
} }
static inline static inline
...@@ -50,11 +50,11 @@ void on_error_close(uv_handle_t* handle) ...@@ -50,11 +50,11 @@ void on_error_close(uv_handle_t* handle)
/* Class variables. */ /* Class variables. */
uint8_t UDPSocket::readBuffer[MS_READ_BUFFER_SIZE]; uint8_t UdpSocket::readBuffer[MS_READ_BUFFER_SIZE];
/* Instance methods. */ /* Instance methods. */
UDPSocket::UDPSocket(const std::string &ip, uint16_t port) UdpSocket::UdpSocket(const std::string &ip, uint16_t port)
{ {
MS_TRACE(); MS_TRACE();
...@@ -118,7 +118,7 @@ UDPSocket::UDPSocket(const std::string &ip, uint16_t port) ...@@ -118,7 +118,7 @@ UDPSocket::UDPSocket(const std::string &ip, uint16_t port)
} }
} }
UDPSocket::UDPSocket(uv_udp_t* uvHandle) : UdpSocket::UdpSocket(uv_udp_t* uvHandle) :
uvHandle(uvHandle) uvHandle(uvHandle)
{ {
MS_TRACE(); MS_TRACE();
...@@ -142,7 +142,7 @@ UDPSocket::UDPSocket(uv_udp_t* uvHandle) : ...@@ -142,7 +142,7 @@ UDPSocket::UDPSocket(uv_udp_t* uvHandle) :
} }
} }
UDPSocket::~UDPSocket() UdpSocket::~UdpSocket()
{ {
MS_TRACE(); MS_TRACE();
...@@ -150,7 +150,7 @@ UDPSocket::~UDPSocket() ...@@ -150,7 +150,7 @@ UDPSocket::~UDPSocket()
delete this->uvHandle; delete this->uvHandle;
} }
void UDPSocket::Close() void UdpSocket::Close()
{ {
MS_TRACE(); MS_TRACE();
...@@ -169,14 +169,14 @@ void UDPSocket::Close() ...@@ -169,14 +169,14 @@ void UDPSocket::Close()
uv_close((uv_handle_t*)this->uvHandle, (uv_close_cb)on_close); uv_close((uv_handle_t*)this->uvHandle, (uv_close_cb)on_close);
} }
void UDPSocket::Dump() void UdpSocket::Dump()
{ {
MS_DEBUG("[UDP, local:%s :%" PRIu16 ", status:%s]", MS_DEBUG("[UDP, local:%s :%" PRIu16 ", status:%s]",
this->localIP.c_str(), (uint16_t)this->localPort, this->localIP.c_str(), (uint16_t)this->localPort,
(!this->isClosing) ? "open" : "closed"); (!this->isClosing) ? "open" : "closed");
} }
void UDPSocket::Send(const uint8_t* data, size_t len, const struct sockaddr* addr) void UdpSocket::Send(const uint8_t* data, size_t len, const struct sockaddr* addr)
{ {
MS_TRACE(); MS_TRACE();
...@@ -239,7 +239,7 @@ void UDPSocket::Send(const uint8_t* data, size_t len, const struct sockaddr* add ...@@ -239,7 +239,7 @@ void UDPSocket::Send(const uint8_t* data, size_t len, const struct sockaddr* add
} }
} }
void UDPSocket::Send(const uint8_t* data, size_t len, const std::string &ip, uint16_t port) void UdpSocket::Send(const uint8_t* data, size_t len, const std::string &ip, uint16_t port)
{ {
MS_TRACE(); MS_TRACE();
...@@ -276,7 +276,7 @@ void UDPSocket::Send(const uint8_t* data, size_t len, const std::string &ip, uin ...@@ -276,7 +276,7 @@ void UDPSocket::Send(const uint8_t* data, size_t len, const std::string &ip, uin
Send(data, len, (struct sockaddr*)&addr); Send(data, len, (struct sockaddr*)&addr);
} }
bool UDPSocket::SetLocalAddress() bool UdpSocket::SetLocalAddress()
{ {
MS_TRACE(); MS_TRACE();
...@@ -298,18 +298,18 @@ bool UDPSocket::SetLocalAddress() ...@@ -298,18 +298,18 @@ bool UDPSocket::SetLocalAddress()
} }
inline inline
void UDPSocket::onUvRecvAlloc(size_t suggested_size, uv_buf_t* buf) void UdpSocket::onUvRecvAlloc(size_t suggested_size, uv_buf_t* buf)
{ {
MS_TRACE(); MS_TRACE();
// Tell UV to write into the static buffer. // Tell UV to write into the static buffer.
buf->base = (char *)UDPSocket::readBuffer; buf->base = (char *)UdpSocket::readBuffer;
// Give UV all the buffer space. // Give UV all the buffer space.
buf->len = MS_READ_BUFFER_SIZE; buf->len = MS_READ_BUFFER_SIZE;
} }
inline inline
void UDPSocket::onUvRecv(ssize_t nread, const uv_buf_t* buf, const struct sockaddr* addr, unsigned int flags) void UdpSocket::onUvRecv(ssize_t nread, const uv_buf_t* buf, const struct sockaddr* addr, unsigned int flags)
{ {
MS_TRACE(); MS_TRACE();
...@@ -333,7 +333,7 @@ void UDPSocket::onUvRecv(ssize_t nread, const uv_buf_t* buf, const struct sockad ...@@ -333,7 +333,7 @@ void UDPSocket::onUvRecv(ssize_t nread, const uv_buf_t* buf, const struct sockad
if (nread > 0) if (nread > 0)
{ {
// Notify the subclass. // Notify the subclass.
userOnUDPDatagramRecv((uint8_t*)buf->base, nread, addr); userOnUdpDatagramRecv((uint8_t*)buf->base, nread, addr);
} }
// Some error. // Some error.
...@@ -344,7 +344,7 @@ void UDPSocket::onUvRecv(ssize_t nread, const uv_buf_t* buf, const struct sockad ...@@ -344,7 +344,7 @@ void UDPSocket::onUvRecv(ssize_t nread, const uv_buf_t* buf, const struct sockad
} }
inline inline
void UDPSocket::onUvSendError(int error) void UdpSocket::onUvSendError(int error)
{ {
MS_TRACE(); MS_TRACE();
...@@ -355,12 +355,12 @@ void UDPSocket::onUvSendError(int error) ...@@ -355,12 +355,12 @@ void UDPSocket::onUvSendError(int error)
} }
inline inline
void UDPSocket::onUvClosed() void UdpSocket::onUvClosed()
{ {
MS_TRACE(); MS_TRACE();
// Notify the subclass. // Notify the subclass.
userOnUDPSocketClosed(); userOnUdpSocketClosed();
// And delete this. // And delete this.
delete this; delete this;
......
...@@ -8,10 +8,10 @@ ...@@ -8,10 +8,10 @@
#include "DepUsrSCTP.h" #include "DepUsrSCTP.h"
#include "Utils.h" #include "Utils.h"
#include "Channel/UnixStreamSocket.h" #include "Channel/UnixStreamSocket.h"
#include "RTC/UDPSocket.h" #include "RTC/UdpSocket.h"
#include "RTC/TCPServer.h" #include "RTC/TcpServer.h"
#include "RTC/DTLSTransport.h" #include "RTC/DtlsTransport.h"
#include "RTC/SRTPSession.h" #include "RTC/SrtpSession.h"
#include "Loop.h" #include "Loop.h"
#include "MediaSoupError.h" #include "MediaSoupError.h"
#include "Logger.h" #include "Logger.h"
...@@ -115,10 +115,10 @@ void init() ...@@ -115,10 +115,10 @@ void init()
DepOpenSSL::ClassInit(); DepOpenSSL::ClassInit();
DepLibSRTP::ClassInit(); DepLibSRTP::ClassInit();
DepUsrSCTP::ClassInit(); DepUsrSCTP::ClassInit();
RTC::UDPSocket::ClassInit(); RTC::UdpSocket::ClassInit();
RTC::TCPServer::ClassInit(); RTC::TcpServer::ClassInit();
RTC::DTLSTransport::ClassInit(); RTC::DtlsTransport::ClassInit();
RTC::SRTPSession::ClassInit(); RTC::SrtpSession::ClassInit();
Utils::Crypto::ClassInit(); Utils::Crypto::ClassInit();
} }
...@@ -163,7 +163,7 @@ void destroy() ...@@ -163,7 +163,7 @@ void destroy()
DepOpenSSL::ClassDestroy(); DepOpenSSL::ClassDestroy();
DepLibSRTP::ClassDestroy(); DepLibSRTP::ClassDestroy();
DepUsrSCTP::ClassDestroy(); DepUsrSCTP::ClassDestroy();
RTC::DTLSTransport::ClassDestroy(); RTC::DtlsTransport::ClassDestroy();
Utils::Crypto::ClassDestroy(); Utils::Crypto::ClassDestroy();
} }
......
Markdown 格式
0% 或
您添加了 0 人 到此讨论。请谨慎行事。
请先完成此评论的编辑!
请 注册 或者 后发表评论