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

Code cleanup

上级 ddbe7e09
...@@ -66,8 +66,7 @@ namespace RTC ...@@ -66,8 +66,7 @@ namespace RTC
std::unordered_map<uint8_t, uint8_t> mapPayloadTypes; std::unordered_map<uint8_t, uint8_t> mapPayloadTypes;
// Whether this RtpSender is valid according to Peer capabilities. // Whether this RtpSender is valid according to Peer capabilities.
bool available = false; bool available = false;
// Sender Report holding the RTP stats.
// Sender Report holding the RTP stats
std::auto_ptr<RTC::RTCP::SenderReport> senderReport; std::auto_ptr<RTC::RTCP::SenderReport> senderReport;
std::auto_ptr<RTC::RTCP::SdesChunk> sdesChunk; std::auto_ptr<RTC::RTCP::SdesChunk> sdesChunk;
}; };
......
...@@ -695,9 +695,10 @@ namespace RTC ...@@ -695,9 +695,10 @@ namespace RTC
// Tell all the peers but the one in the argument to generate and send their RTCP. // Tell all the peers but the one in the argument to generate and send their RTCP.
for (auto it = this->peers.begin(); it != this->peers.end(); it++) for (auto it = this->peers.begin(); it != this->peers.end(); it++)
{ {
if (it->second != peer) { auto current_peer = it->second;
it->second->SendRtcp();
} if (current_peer != peer)
current_peer->SendRtcp();
} }
} }
} }
...@@ -132,39 +132,62 @@ namespace RTC ...@@ -132,39 +132,62 @@ namespace RTC
switch (attr_type) switch (attr_type)
{ {
case Attribute::Username: case Attribute::Username:
{
msg->SetUsername((const char*)attr_value_pos, (size_t)attr_length); msg->SetUsername((const char*)attr_value_pos, (size_t)attr_length);
break; break;
}
case Attribute::Priority: case Attribute::Priority:
{
msg->SetPriority(Utils::Byte::Get4Bytes(attr_value_pos, 0)); msg->SetPriority(Utils::Byte::Get4Bytes(attr_value_pos, 0));
break; break;
}
case Attribute::IceControlling: case Attribute::IceControlling:
{
msg->SetIceControlling(Utils::Byte::Get8Bytes(attr_value_pos, 0)); msg->SetIceControlling(Utils::Byte::Get8Bytes(attr_value_pos, 0));
break; break;
}
case Attribute::IceControlled: case Attribute::IceControlled:
{
msg->SetIceControlled(Utils::Byte::Get8Bytes(attr_value_pos, 0)); msg->SetIceControlled(Utils::Byte::Get8Bytes(attr_value_pos, 0));
break; break;
}
case Attribute::UseCandidate: case Attribute::UseCandidate:
{
msg->SetUseCandidate(); msg->SetUseCandidate();
break; break;
}
case Attribute::MessageIntegrity: case Attribute::MessageIntegrity:
{
has_message_integrity = true; has_message_integrity = true;
msg->SetMessageIntegrity(attr_value_pos); msg->SetMessageIntegrity(attr_value_pos);
break; break;
}
case Attribute::Fingerprint: case Attribute::Fingerprint:
{
has_fingerprint = true; has_fingerprint = true;
fingerprint_attr_pos = pos; fingerprint_attr_pos = pos;
fingerprint = Utils::Byte::Get4Bytes(attr_value_pos, 0); fingerprint = Utils::Byte::Get4Bytes(attr_value_pos, 0);
msg->SetFingerprint(); msg->SetFingerprint();
break; break;
case Attribute::ErrorCode: { }
case Attribute::ErrorCode:
{
uint8_t error_class = Utils::Byte::Get1Byte(attr_value_pos, 2); uint8_t error_class = Utils::Byte::Get1Byte(attr_value_pos, 2);
uint8_t error_number = Utils::Byte::Get1Byte(attr_value_pos, 3); uint8_t error_number = Utils::Byte::Get1Byte(attr_value_pos, 3);
uint16_t error_code = (uint16_t)(error_class * 100 + error_number); uint16_t error_code = (uint16_t)(error_class * 100 + error_number);
msg->SetErrorCode(error_code); msg->SetErrorCode(error_code);
break; break;
} }
default: default:
break; ;
} }
// Set next attribute position. // Set next attribute position.
...@@ -415,21 +438,30 @@ namespace RTC ...@@ -415,21 +438,30 @@ namespace RTC
if (this->hasUseCandidate) if (this->hasUseCandidate)
this->length += 4; this->length += 4;
if (add_xor_mapped_address) { if (add_xor_mapped_address)
switch (this->xorMappedAddress->sa_family) { {
switch (this->xorMappedAddress->sa_family)
{
case AF_INET: case AF_INET:
{
xor_mapped_address_padded_len = 8; xor_mapped_address_padded_len = 8;
this->length += 4 + 8; this->length += 4 + 8;
break; break;
}
case AF_INET6: case AF_INET6:
{
xor_mapped_address_padded_len = 20; xor_mapped_address_padded_len = 20;
this->length += 4 + 20; this->length += 4 + 20;
break; break;
}
default: default:
{
MS_ERROR("invalid inet family in XOR-MAPPED-ADDRESS attribute"); MS_ERROR("invalid inet family in XOR-MAPPED-ADDRESS attribute");
add_xor_mapped_address = false; add_xor_mapped_address = false;
break; }
} }
} }
...@@ -522,7 +554,8 @@ namespace RTC ...@@ -522,7 +554,8 @@ namespace RTC
uint8_t* attr_value = this->raw + pos + 4; uint8_t* attr_value = this->raw + pos + 4;
switch (this->xorMappedAddress->sa_family) switch (this->xorMappedAddress->sa_family)
{ {
case AF_INET: { case AF_INET:
{
// Set first byte to 0. // Set first byte to 0.
attr_value[0] = 0; attr_value[0] = 0;
// Set inet family. // Set inet family.
...@@ -539,6 +572,7 @@ namespace RTC ...@@ -539,6 +572,7 @@ namespace RTC
attr_value[7] ^= StunMessage::magicCookie[3]; attr_value[7] ^= StunMessage::magicCookie[3];
pos += 4 + 8; pos += 4 + 8;
break; break;
} }
case AF_INET6: case AF_INET6:
...@@ -571,6 +605,7 @@ namespace RTC ...@@ -571,6 +605,7 @@ namespace RTC
attr_value[19] ^= this->transactionId[11]; attr_value[19] ^= this->transactionId[11];
pos += 4 + 20; pos += 4 + 20;
break; break;
} }
} }
......
...@@ -128,9 +128,8 @@ namespace RTC ...@@ -128,9 +128,8 @@ namespace RTC
MS_DEBUG_DEV("port in use, trying again [port:%" PRIu16 ", attempt:%" PRIu16 "]", iterating_port, attempt); MS_DEBUG_DEV("port in use, trying again [port:%" PRIu16 ", attempt:%" PRIu16 "]", iterating_port, attempt);
// If we have tried all the ports in the range raise an error. // If we have tried all the ports in the range raise an error.
if (iterating_port == initial_port) { if (iterating_port == initial_port)
MS_THROW_ERROR("no more available ports for IP '%s'", listen_ip); MS_THROW_ERROR("no more available ports for IP '%s'", listen_ip);
}
continue; continue;
} }
......
...@@ -134,7 +134,8 @@ void UnixStreamSocket::Close() ...@@ -134,7 +134,8 @@ void UnixStreamSocket::Close()
MS_ABORT("uv_shutdown() failed: %s", uv_strerror(err)); MS_ABORT("uv_shutdown() failed: %s", uv_strerror(err));
} }
// Otherwise directly close the socket. // Otherwise directly close the socket.
else { else
{
uv_close((uv_handle_t*)this->uvHandle, (uv_close_cb)on_close); uv_close((uv_handle_t*)this->uvHandle, (uv_close_cb)on_close);
} }
} }
......
Markdown 格式
0% 或
您添加了 0 人 到此讨论。请谨慎行事。
请先完成此评论的编辑!
请 注册 或者 后发表评论