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

C++ and classes cleanup.

Add IceServer::ForceSendingTuple() for bad clients (Firefox).
上级 ca4cf925
......@@ -17,6 +17,16 @@ namespace RTC
class DTLSTransport :
public Timer::Listener
{
public:
enum class DtlsState
{
NEW = 1,
CONNECTING,
CONNECTED,
FAILED,
CLOSED
};
public:
enum class Role
{
......@@ -63,15 +73,12 @@ namespace RTC
// and remote fingerprint verification). Outgoing media can now flow through.
// NOTE: The caller MUST NOT call any method during this callback.
virtual void onDTLSConnected(DTLSTransport* dtlsTransport, RTC::SRTPSession::SRTPProfile srtp_profile, MS_BYTE* srtp_local_key, size_t srtp_local_key_len, MS_BYTE* srtp_remote_key, size_t srtp_remote_key_len) = 0;
// The DTLS connection has been closed due to receipt of a close_notify alert.
// NOTE: The caller MUST NOT call Close() during this callback.
virtual void onDTLSDisconnected(DTLSTransport* dtlsTransport) = 0;
// 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).
// NOTE: The caller MUST NOT call Close() during this callback.
virtual void onDTLSFailed(DTLSTransport* dtlsTransport) = 0;
// The DTLS connection has been closed intentionally via Close().
// NOTE: The caller MUST NOT call any method during this callback.
// The DTLS connection has been closed due to receipt of a close_notify alert.
// NOTE: The caller MUST NOT call Close() during this callback.
virtual void onDTLSClosed(DTLSTransport* dtlsTransport) = 0;
// Need to send DTLS data to the peer.
// NOTE: The caller MUST NOT call Close() during this callback.
......@@ -114,10 +121,12 @@ namespace RTC
void Run(Role localRole);
void SetRemoteFingerprint(Fingerprint fingerprint);
void ProcessDTLSData(const MS_BYTE* data, size_t len);
DtlsState GetState();
Role GetLocalRole();
void SendApplicationData(const MS_BYTE* data, size_t len);
private:
bool IsRunning();
void Reset();
bool CheckStatus(int return_code);
void SendPendingOutgoingDTLSData();
......@@ -144,12 +153,11 @@ namespace RTC
BIO* sslBioToNetwork = nullptr; // The BIO in which ssl writes.
Timer* timer = nullptr;
// Others.
DtlsState state = DtlsState::NEW;
Role localRole = Role::NONE;
Fingerprint remoteFingerprint = { FingerprintAlgorithm::NONE, "" };
bool running = false;
bool handshakeDone = false;
bool handshakeDoneNow = false;
bool connected = false;
};
/* Inline static methods. */
......@@ -195,6 +203,28 @@ namespace RTC
/* Inline instance methods. */
inline
bool DTLSTransport::IsRunning()
{
switch (this->state)
{
case DtlsState::NEW:
return false;
case DtlsState::CONNECTING:
case DtlsState::CONNECTED:
return true;
case DtlsState::FAILED:
case DtlsState::CLOSED:
return false;
}
}
inline
DTLSTransport::DtlsState DTLSTransport::GetState()
{
return this->state;
}
inline
DTLSTransport::Role DTLSTransport::GetLocalRole()
{
......
......@@ -11,6 +11,13 @@ namespace RTC
{
class IceServer
{
public:
enum class IceComponent
{
RTP = 1,
RTCP = 2
};
public:
enum class IceState
{
......@@ -34,14 +41,18 @@ namespace RTC
};
public:
IceServer(Listener* listener, const std::string& usernameFragment, const std::string password);
IceServer(Listener* listener, IceServer::IceComponent iceComponent, const std::string& usernameFragment, const std::string password);
void Close();
void ProcessSTUNMessage(RTC::STUNMessage* msg, RTC::TransportTuple* tuple);
IceComponent GetComponent();
std::string& GetUsernameFragment();
std::string& GetPassword();
IceState GetState();
bool IsValidTuple(RTC::TransportTuple* tuple);
// This should be just called in 'connected' or completed' state
// and the given tuple must be an already valid tuple.
void ForceSelectedTuple(RTC::TransportTuple* tuple);
private:
void HandleTuple(RTC::TransportTuple* tuple, bool has_use_candidate);
......@@ -63,6 +74,7 @@ namespace RTC
// Passed by argument.
Listener* listener = nullptr;
// Others.
IceComponent iceComponent;
std::string usernameFragment;
std::string password;
IceState state = IceState::NEW;
......@@ -72,6 +84,12 @@ namespace RTC
/* Inline methods. */
inline
IceServer::IceComponent IceServer::GetComponent()
{
return this->iceComponent;
}
inline
std::string& IceServer::GetUsernameFragment()
{
......
......@@ -24,23 +24,6 @@ namespace RTC
public RTC::IceServer::Listener,
public RTC::DTLSTransport::Listener
{
public:
enum class IceComponent
{
RTP = 1,
RTCP = 2
};
private:
enum class DtlsTransportState
{
NEW = 1,
CONNECTING,
CONNECTED,
CLOSED,
FAILED
};
public:
class Listener
{
......@@ -63,7 +46,7 @@ namespace RTC
Transport* CreateAssociatedTransport(unsigned int transportId);
private:
void Terminate();
void ClosePorts();
bool IsAlive();
void MayRunDTLSTransport();
......@@ -103,7 +86,6 @@ namespace RTC
public:
virtual void onDTLSConnecting(DTLSTransport* dtlsTransport) override;
virtual void onDTLSConnected(DTLSTransport* dtlsTransport, RTC::SRTPSession::SRTPProfile srtp_profile, MS_BYTE* srtp_local_key, size_t srtp_local_key_len, MS_BYTE* srtp_remote_key, size_t srtp_remote_key_len) override;
virtual void onDTLSDisconnected(DTLSTransport* dtlsTransport) override;
virtual void onDTLSFailed(DTLSTransport* dtlsTransport) override;
virtual void onDTLSClosed(DTLSTransport* dtlsTransport) override;
virtual void onOutgoingDTLSData(RTC::DTLSTransport* dtlsTransport, const MS_BYTE* data, size_t len) override;
......@@ -132,11 +114,9 @@ namespace RTC
// Others.
bool allocated = false;
// Others (ICE).
RTC::Transport::IceComponent iceComponent;
std::vector<IceCandidate> iceLocalCandidates;
RTC::TransportTuple* selectedTuple = nullptr;
// Others (DTLS).
DtlsTransportState dtlsState = DtlsTransportState::NEW;
bool remoteDtlsParametersGiven = false;
RTC::DTLSTransport::Role dtlsLocalRole = RTC::DTLSTransport::Role::AUTO;
};
......@@ -146,8 +126,8 @@ namespace RTC
inline
bool Transport::IsAlive()
{
if (this->dtlsState == DtlsTransportState::CLOSED ||
this->dtlsState == DtlsTransportState::FAILED)
if (this->dtlsTransport->GetState() == DTLSTransport::DtlsState::FAILED ||
this->dtlsTransport->GetState() == DTLSTransport::DtlsState::CLOSED)
{
return false;
}
......
......@@ -542,7 +542,7 @@ namespace RTC
{
MS_TRACE();
if (this->running)
if (IsRunning())
{
// Send close alert to the peer.
SSL_shutdown(this->ssl);
......@@ -552,9 +552,6 @@ namespace RTC
// Close the DTLS timer.
this->timer->Close();
// Notify the listener.
this->listener->onDTLSClosed(this);
delete this;
}
......@@ -564,9 +561,9 @@ namespace RTC
MS_DEBUG("[role:%s, running:%s, handshake done:%s, connected:%s]",
(this->localRole == Role::SERVER ? "server" : (this->localRole == Role::CLIENT ? "client" : "none")),
this->running ? "yes" : "no",
IsRunning() ? "yes" : "no",
this->handshakeDone ? "yes" : "no",
this->connected ? "yes" : "no");
this->state == DtlsState::CONNECTED ? "yes" : "no");
}
void DTLSTransport::Run(Role localRole)
......@@ -594,10 +591,9 @@ namespace RTC
// Update local role.
this->localRole = localRole;
// Set running flag.
this->running = true;
// Notify the listener.
// Set state and notify the listener.
this->state = DtlsState::CONNECTING;
this->listener->onDTLSConnecting(this);
switch (this->localRole)
......@@ -632,7 +628,7 @@ namespace RTC
// The remote fingerpring may have been set after DTLS handshake was done,
// so we may need to process it now.
if (this->handshakeDone && !this->connected)
if (this->handshakeDone && this->state != DtlsState::CONNECTED)
{
MS_DEBUG("handshake already done, processing it right now");
......@@ -647,7 +643,7 @@ namespace RTC
int written;
int read;
if (!this->running)
if (!IsRunning())
{
MS_ERROR("cannot process data while not running");
......@@ -694,7 +690,7 @@ namespace RTC
MS_TRACE();
// We cannot send data to the peer if its remote fingerprint is not validated.
if (!this->connected)
if (this->state != DtlsState::CONNECTED)
{
MS_ERROR("cannot send application data while DTLS is not fully connected");
......@@ -732,7 +728,7 @@ namespace RTC
int ret;
if (!this->running)
if (!IsRunning())
return;
MS_DEBUG("resetting DTLS transport");
......@@ -746,10 +742,9 @@ namespace RTC
SSL_shutdown(this->ssl);
this->localRole = Role::NONE;
this->running = false;
this->state = DtlsState::NEW;
this->handshakeDone = false;
this->handshakeDoneNow = false;
this->connected = false;
// Reset SSL status.
// NOTE: For this to properly work, SSL_shutdown() must be called before.
......@@ -766,6 +761,7 @@ namespace RTC
MS_TRACE();
int err;
bool was_handshake_done = this->handshakeDone;
err = SSL_get_error(this->ssl, return_code);
switch (err)
......@@ -805,28 +801,22 @@ namespace RTC
// Stop the timer.
this->timer->Stop();
// Process the handshake.
ProcessHandshake();
// Process the handshake just once (ignore if DTLS renegotiation).
if (!was_handshake_done)
ProcessHandshake();
}
// Check if the peer sent close alert or a fatal error happened.
else if ((SSL_get_shutdown(this->ssl) & SSL_RECEIVED_SHUTDOWN) || err == SSL_ERROR_SSL || err == SSL_ERROR_SYSCALL)
{
bool was_connected = this->connected;
this->localRole = Role::NONE;
this->running = false;
this->handshakeDone = false;
this->handshakeDoneNow = false;
this->connected = false;
if (was_connected)
if (this->state == DtlsState::CONNECTED)
{
MS_DEBUG("disconnected");
Reset();
// Notify to the listener.
this->listener->onDTLSDisconnected(this);
// Set state and notify the listener.
this->state = DtlsState::CLOSED;
this->listener->onDTLSClosed(this);
}
else
{
......@@ -834,7 +824,8 @@ namespace RTC
Reset();
// Notify to the listener.
// Set state and notify the listener.
this->state = DtlsState::FAILED;
this->listener->onDTLSFailed(this);
}
......@@ -902,7 +893,8 @@ namespace RTC
Reset();
// Notify to the listener.
// Set state and notify the listener.
this->state = DtlsState::FAILED;
this->listener->onDTLSFailed(this);
return false;
......@@ -930,14 +922,13 @@ namespace RTC
{
Reset();
// Notify to the listener.
// Set state and notify the listener.
this->state = DtlsState::FAILED;
this->listener->onDTLSFailed(this);
return;
}
this->connected = true;
// Get the negotiated SRTP profile.
RTC::SRTPSession::SRTPProfile srtp_profile;
srtp_profile = GetNegotiatedSRTPProfile();
......@@ -955,7 +946,8 @@ namespace RTC
Reset();
// Notify to the listener.
// Set state and notify the listener.
this->state = DtlsState::FAILED;
this->listener->onDTLSFailed(this);
}
}
......@@ -1074,7 +1066,8 @@ namespace RTC
std::memcpy(srtp_remote_master_key, srtp_remote_key, MS_SRTP_MASTER_KEY_LENGTH);
std::memcpy(srtp_remote_master_key + MS_SRTP_MASTER_KEY_LENGTH, srtp_remote_salt, MS_SRTP_MASTER_SALT_LENGTH);
// Notify the listener with the SRTP key material.
// Set state and notify the listener.
this->state = DtlsState::CONNECTED;
this->listener->onDTLSConnected(this, srtp_profile, srtp_local_master_key, MS_SRTP_MASTER_LENGTH, srtp_remote_master_key, MS_SRTP_MASTER_LENGTH);
}
......
......@@ -7,8 +7,9 @@ namespace RTC
{
/* Instance methods. */
IceServer::IceServer(Listener* listener, const std::string& usernameFragment, const std::string password) :
IceServer::IceServer(Listener* listener, IceServer::IceComponent iceComponent, const std::string& usernameFragment, const std::string password) :
listener(listener),
iceComponent(iceComponent),
usernameFragment(usernameFragment),
password(password)
{
......@@ -190,6 +191,30 @@ namespace RTC
return false;
}
void IceServer::ForceSelectedTuple(RTC::TransportTuple* tuple)
{
MS_TRACE();
MS_ASSERT(this->state != IceState::NEW, "cannot force the selected tuple if not in 'connecting' or 'connected' state is 'new' but there is selected tuple");
// TODO: Remove as this assert is reduntant.
MS_ASSERT(this->selectedTuple != nullptr, "cannot force the selected tuple if there was not a selected tuple");
auto stored_tuple = HasTuple(tuple);
MS_ASSERT(stored_tuple, "cannot force the selected tuple if the given tuple was not already a valid tuple");
// If the given tuple was already the selected tuple do nothing.
if (stored_tuple == this->selectedTuple)
return;
// Mark it as selected tuple.
SetSelectedTuple(stored_tuple);
// Notify the listener.
this->listener->onICESelectedTuple(this, stored_tuple);
}
void IceServer::HandleTuple(RTC::TransportTuple* tuple, bool has_use_candidate)
{
MS_TRACE();
......@@ -314,6 +339,7 @@ namespace RTC
}
}
inline
RTC::TransportTuple* IceServer::AddTuple(RTC::TransportTuple* tuple)
{
MS_TRACE();
......@@ -332,6 +358,7 @@ namespace RTC
return stored_tuple;
}
inline
RTC::TransportTuple* IceServer::HasTuple(RTC::TransportTuple* tuple)
{
MS_TRACE();
......@@ -357,6 +384,7 @@ namespace RTC
return nullptr;
}
inline
void IceServer::SetSelectedTuple(RTC::TransportTuple* stored_tuple)
{
MS_TRACE();
......
......@@ -50,10 +50,9 @@ namespace RTC
// RTP transport.
if (!rtpTransport)
{
this->iceComponent = IceComponent::RTP;
// Create a ICE server.
this->iceServer = new RTC::IceServer(this,
IceServer::IceComponent::RTP,
Utils::Crypto::GetRandomString(16),
Utils::Crypto::GetRandomString(32));
......@@ -66,10 +65,9 @@ namespace RTC
// RTCP transport associated to a given RTP transport.
else
{
this->iceComponent = IceComponent::RTCP;
// Create a ICE server.
this->iceServer = new RTC::IceServer(this,
IceServer::IceComponent::RTCP,
rtpTransport->GetIceUsernameFragment(),
rtpTransport->GetIcePassword());
......@@ -84,7 +82,7 @@ namespace RTC
{
unsigned long priority;
if (this->iceComponent == IceComponent::RTP)
if (this->iceServer->GetComponent() == IceServer::IceComponent::RTP)
priority = ICE_CANDIDATE_PRIORITY_IPV4_UDP_RTP;
else
priority = ICE_CANDIDATE_PRIORITY_IPV4_UDP_RTCP;
......@@ -109,7 +107,7 @@ namespace RTC
{
unsigned long priority;
if (this->iceComponent == IceComponent::RTP)
if (this->iceServer->GetComponent() == IceServer::IceComponent::RTP)
priority = ICE_CANDIDATE_PRIORITY_IPV6_UDP_RTP;
else
priority = ICE_CANDIDATE_PRIORITY_IPV6_UDP_RTCP;
......@@ -134,7 +132,7 @@ namespace RTC
{
unsigned long priority;
if (this->iceComponent == IceComponent::RTP)
if (this->iceServer->GetComponent() == IceServer::IceComponent::RTP)
priority = ICE_CANDIDATE_PRIORITY_IPV4_TCP_RTP;
else
priority = ICE_CANDIDATE_PRIORITY_IPV4_TCP_RTCP;
......@@ -159,7 +157,7 @@ namespace RTC
{
unsigned long priority;
if (this->iceComponent == IceComponent::RTP)
if (this->iceServer->GetComponent() == IceServer::IceComponent::RTP)
priority = ICE_CANDIDATE_PRIORITY_IPV6_TCP_RTP;
else
priority = ICE_CANDIDATE_PRIORITY_IPV6_TCP_RTCP;
......@@ -203,16 +201,32 @@ namespace RTC
{
MS_TRACE();
// Close all the servers.
Terminate();
if (this->iceServer)
{
this->iceServer->Close();
this->iceServer = nullptr;
}
// And also close the DTLSTransport.
if (this->dtlsTransport)
{
this->dtlsTransport->Close();
this->dtlsTransport = nullptr;
}
ClosePorts();
// if (this->srtpRecvSession)
// {
// this->srtpRecvSession->Close();
// this->srtpRecvSession = nullptr;
// }
// if (this->srtpSendSession)
// {
// this->srtpSendSession->Close();
// this->srtpSendSession = nullptr;
// }
// If this was allocated (it did not throw in the constructor) notify the
// listener and delete it.
if (this->allocated)
......@@ -229,12 +243,12 @@ namespace RTC
MS_TRACE();
static const Json::StaticString k_iceComponent("iceComponent");
static const Json::StaticString v_RTP("RTP");
static const Json::StaticString v_RTCP("RTCP");
static const Json::StaticString k_iceLocalParameters("iceLocalParameters");
static const Json::StaticString k_usernameFragment("usernameFragment");
static const Json::StaticString k_password("password");
static const Json::StaticString k_iceLocalCandidates("iceLocalCandidates");
static const Json::StaticString v_RTP("RTP");
static const Json::StaticString v_RTCP("RTCP");
static const Json::StaticString k_dtlsLocalParameters("dtlsLocalParameters");
static const Json::StaticString k_fingerprints("fingerprints");
static const Json::StaticString k_role("role");
......@@ -251,7 +265,7 @@ namespace RTC
Json::Value data;
// Add `iceComponent`.
if (this->iceComponent == IceComponent::RTP)
if (this->iceServer->GetComponent() == IceServer::IceComponent::RTP)
data[k_iceComponent] = v_RTP;
else
data[k_iceComponent] = v_RTCP;
......@@ -287,23 +301,23 @@ namespace RTC
}
// Add `dtlsState`.
switch (this->dtlsState)
switch (this->dtlsTransport->GetState())
{
case DtlsTransportState::NEW:
case DTLSTransport::DtlsState::NEW:
data[k_dtlsState] = v_new;
break;
case DtlsTransportState::CONNECTING:
case DTLSTransport::DtlsState::CONNECTING:
data[k_dtlsState] = v_connecting;
break;
case DtlsTransportState::CONNECTED:
case DTLSTransport::DtlsState::CONNECTED:
data[k_dtlsState] = v_connected;
break;
case DtlsTransportState::CLOSED:
data[k_dtlsState] = v_closed;
break;
case DtlsTransportState::FAILED:
case DTLSTransport::DtlsState::FAILED:
data[k_dtlsState] = v_failed;
break;
case DTLSTransport::DtlsState::CLOSED:
data[k_dtlsState] = v_closed;
break;
}
return data;
......@@ -453,29 +467,11 @@ namespace RTC
}
}
// This closes all the server but not the DTLSTransport.
void Transport::Terminate()
// This closes all the UDP/TCP servers.
void Transport::ClosePorts()
{
MS_TRACE();
if (this->iceServer)
{
this->iceServer->Close();
this->iceServer = nullptr;
}
// if (this->srtpRecvSession)
// {
// this->srtpRecvSession->Close();
// this->srtpRecvSession = nullptr;
// }
// if (this->srtpSendSession)
// {
// this->srtpSendSession->Close();
// this->srtpSendSession = nullptr;
// }
for (auto socket : this->udpSockets)
socket->Close();
this->udpSockets.clear();
......@@ -494,7 +490,7 @@ namespace RTC
if (!IsAlive())
MS_THROW_ERROR("cannot call CreateAssociatedTransport() on a non alive Transport");
if (this->iceComponent != IceComponent::RTP)
if (this->iceServer->GetComponent() != IceServer::IceComponent::RTP)
MS_THROW_ERROR("cannot call CreateAssociatedTransport() on a RTCP Transport");
return new RTC::Transport(this->listener, this->notifier, transportId, nullData, this);
......@@ -586,9 +582,12 @@ namespace RTC
return;
}
// Trick for clients performing aggressive ICE regardless we are ICE-Lite.
this->iceServer->ForceSelectedTuple(tuple);
// Check that DTLS status is 'connecting' or 'connected'.
if (this->dtlsState == DtlsTransportState::CONNECTING ||
this->dtlsState == DtlsTransportState::CONNECTED)
if (this->dtlsTransport->GetState() == DTLSTransport::DtlsState::CONNECTING ||
this->dtlsTransport->GetState() == DTLSTransport::DtlsState::CONNECTED)
{
MS_DEBUG("DTLS data received, passing it to the DTLS transport");
......@@ -596,7 +595,7 @@ namespace RTC
}
else
{
MS_DEBUG("DTLSTransport is not connecting or conneted, ignoring received DTLS data");
MS_DEBUG("DTLSTransport is not 'connecting' or 'conneted', ignoring received DTLS data");
return;
}
......@@ -607,6 +606,16 @@ namespace RTC
{
MS_TRACE();
if (!this->iceServer->IsValidTuple(tuple))
{
MS_DEBUG("ignoring RTP data coming from an invalid tuple");
return;
}
// Trick for clients performing aggressive ICE regardless we are ICE-Lite.
this->iceServer->ForceSelectedTuple(tuple);
// TODO
}
......@@ -615,6 +624,16 @@ namespace RTC
{
MS_TRACE();
if (!this->iceServer->IsValidTuple(tuple))
{
MS_DEBUG("ignoring RTCP data coming from an invalid tuple");
return;
}
// Trick for clients performing aggressive ICE regardless we are ICE-Lite.
this->iceServer->ForceSelectedTuple(tuple);
// TODO
}
......@@ -776,8 +795,6 @@ namespace RTC
MS_DEBUG("DTLS connecting");
this->dtlsState = DtlsTransportState::CONNECTING;
// Notify.
eventData[k_dtlsState] = v_connecting;
this->notifier->Emit(this->transportId, "dtlsstatechange", eventData);
......@@ -794,8 +811,6 @@ namespace RTC
MS_DEBUG("DTLS connected");
this->dtlsState = DtlsTransportState::CONNECTED;
// TODO
// SetLocalSRTPKey(srtp_profile, srtp_local_key, srtp_local_key_len);
// SetRemoteSRTPKey(srtp_profile, srtp_remote_key, srtp_remote_key_len);
......@@ -805,29 +820,22 @@ namespace RTC
this->notifier->Emit(this->transportId, "dtlsstatechange", eventData);
}
void Transport::onDTLSDisconnected(RTC::DTLSTransport* dtlsTransport)
void Transport::onDTLSClosed(RTC::DTLSTransport* dtlsTransport)
{
MS_TRACE();
static const Json::StaticString k_dtlsState("dtlsState");
static const Json::StaticString v_closed("closed");
DtlsTransportState previousDtlsState = this->dtlsState;
Json::Value eventData;
MS_DEBUG("DTLS remotely disconnected");
this->dtlsState = DtlsTransportState::CLOSED;
// Call Terminate() so all the servers are closed.
Terminate();
ClosePorts();
// Notify.
if (previousDtlsState != DtlsTransportState::CLOSED)
{
eventData[k_dtlsState] = v_closed;
this->notifier->Emit(this->transportId, "dtlsstatechange", eventData);
}
eventData[k_dtlsState] = v_closed;
this->notifier->Emit(this->transportId, "dtlsstatechange", eventData);
}
void Transport::onDTLSFailed(RTC::DTLSTransport* dtlsTransport)
......@@ -841,41 +849,13 @@ namespace RTC
MS_DEBUG("DTLS failed");
this->dtlsState = DtlsTransportState::FAILED;
// Call Terminate() so all the servers are closed.
Terminate();
ClosePorts();
// Notify.
eventData[k_dtlsState] = v_failed;
this->notifier->Emit(this->transportId, "dtlsstatechange", eventData);
}
void Transport::onDTLSClosed(RTC::DTLSTransport* dtlsTransport)
{
MS_TRACE();
static const Json::StaticString k_dtlsState("dtlsState");
static const Json::StaticString v_closed("closed");
DtlsTransportState previousDtlsState = this->dtlsState;
Json::Value eventData;
MS_DEBUG("DTLS closed");
this->dtlsState = DtlsTransportState::CLOSED;
// NOTE: This is just called when calling Close() so don't call
// Terminate() here (not needed).
// Notify.
if (previousDtlsState != DtlsTransportState::CLOSED)
{
eventData[k_dtlsState] = v_closed;
this->notifier->Emit(this->transportId, "dtlsstatechange", eventData);
}
}
void Transport::onOutgoingDTLSData(RTC::DTLSTransport* dtlsTransport, const MS_BYTE* data, size_t len)
{
MS_TRACE();
......
Markdown 格式
0% 或
您添加了 0 人 到此讨论。请谨慎行事。
请先完成此评论的编辑!
请 注册 或者 后发表评论