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

Code cleanup

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