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

codecs cpp: add proper curly braces always

上级 64e4d89b
...@@ -17,7 +17,9 @@ namespace RTC ...@@ -17,7 +17,9 @@ namespace RTC
MS_TRACE(); MS_TRACE();
if (len < 2) if (len < 2)
{
return nullptr; return nullptr;
}
std::unique_ptr<PayloadDescriptor> payloadDescriptor(new PayloadDescriptor()); std::unique_ptr<PayloadDescriptor> payloadDescriptor(new PayloadDescriptor());
...@@ -48,7 +50,9 @@ namespace RTC ...@@ -48,7 +50,9 @@ namespace RTC
// Detect key frame. // Detect key frame.
if (frameMarking->start && frameMarking->independent) if (frameMarking->start && frameMarking->independent)
{
payloadDescriptor->isKeyFrame = true; payloadDescriptor->isKeyFrame = true;
}
} }
// NOTE: Unfortunately libwebrtc produces wrong Frame-Marking (without i=1 in // NOTE: Unfortunately libwebrtc produces wrong Frame-Marking (without i=1 in
...@@ -95,7 +99,9 @@ namespace RTC ...@@ -95,7 +99,9 @@ namespace RTC
// Check if there is room for the indicated NAL unit size. // Check if there is room for the indicated NAL unit size.
if (len < (naluSize + sizeof(naluSize))) if (len < (naluSize + sizeof(naluSize)))
{
break; break;
}
offset += naluSize + sizeof(naluSize); offset += naluSize + sizeof(naluSize);
len -= naluSize + sizeof(naluSize); len -= naluSize + sizeof(naluSize);
...@@ -113,7 +119,9 @@ namespace RTC ...@@ -113,7 +119,9 @@ namespace RTC
uint8_t startBit = *(data + 1) & 0x80; uint8_t startBit = *(data + 1) & 0x80;
if (subnal == 7 && startBit == 128) if (subnal == 7 && startBit == 128)
{
payloadDescriptor->isKeyFrame = true; payloadDescriptor->isKeyFrame = true;
}
break; break;
} }
...@@ -138,7 +146,9 @@ namespace RTC ...@@ -138,7 +146,9 @@ namespace RTC
PayloadDescriptor* payloadDescriptor = H264::Parse(data, len, frameMarking, frameMarkingLen); PayloadDescriptor* payloadDescriptor = H264::Parse(data, len, frameMarking, frameMarkingLen);
if (!payloadDescriptor) if (!payloadDescriptor)
{
return; return;
}
auto* payloadDescriptorHandler = new PayloadDescriptorHandler(payloadDescriptor); auto* payloadDescriptorHandler = new PayloadDescriptorHandler(payloadDescriptor);
...@@ -231,7 +241,9 @@ namespace RTC ...@@ -231,7 +241,9 @@ namespace RTC
} }
if (context->GetCurrentTemporalLayer() > context->GetTargetTemporalLayer()) if (context->GetCurrentTemporalLayer() > context->GetTargetTemporalLayer())
{
context->SetCurrentTemporalLayer(context->GetTargetTemporalLayer()); context->SetCurrentTemporalLayer(context->GetTargetTemporalLayer());
}
return true; return true;
} }
......
...@@ -20,7 +20,9 @@ namespace RTC ...@@ -20,7 +20,9 @@ namespace RTC
MS_TRACE(); MS_TRACE();
if (len < 1) if (len < 1)
{
return nullptr; return nullptr;
}
std::unique_ptr<PayloadDescriptor> payloadDescriptor(new PayloadDescriptor()); std::unique_ptr<PayloadDescriptor> payloadDescriptor(new PayloadDescriptor());
...@@ -39,7 +41,9 @@ namespace RTC ...@@ -39,7 +41,9 @@ namespace RTC
else else
{ {
if (len < ++offset + 1) if (len < ++offset + 1)
{
return nullptr; return nullptr;
}
byte = data[offset]; byte = data[offset];
...@@ -52,14 +56,18 @@ namespace RTC ...@@ -52,14 +56,18 @@ namespace RTC
if (payloadDescriptor->i) if (payloadDescriptor->i)
{ {
if (len < ++offset + 1) if (len < ++offset + 1)
{
return nullptr; return nullptr;
}
byte = data[offset]; byte = data[offset];
if ((byte >> 7) & 0x01) if ((byte >> 7) & 0x01)
{ {
if (len < ++offset + 1) if (len < ++offset + 1)
{
return nullptr; return nullptr;
}
payloadDescriptor->hasTwoBytesPictureId = true; payloadDescriptor->hasTwoBytesPictureId = true;
payloadDescriptor->pictureId = (byte & 0x7F) << 8; payloadDescriptor->pictureId = (byte & 0x7F) << 8;
...@@ -77,7 +85,9 @@ namespace RTC ...@@ -77,7 +85,9 @@ namespace RTC
if (payloadDescriptor->l) if (payloadDescriptor->l)
{ {
if (len < ++offset + 1) if (len < ++offset + 1)
{
return nullptr; return nullptr;
}
payloadDescriptor->hasTl0PictureIndex = true; payloadDescriptor->hasTl0PictureIndex = true;
payloadDescriptor->tl0PictureIndex = data[offset]; payloadDescriptor->tl0PictureIndex = data[offset];
...@@ -86,7 +96,9 @@ namespace RTC ...@@ -86,7 +96,9 @@ namespace RTC
if (payloadDescriptor->t || payloadDescriptor->k) if (payloadDescriptor->t || payloadDescriptor->k)
{ {
if (len < ++offset + 1) if (len < ++offset + 1)
{
return nullptr; return nullptr;
}
byte = data[offset]; byte = data[offset];
...@@ -126,7 +138,9 @@ namespace RTC ...@@ -126,7 +138,9 @@ namespace RTC
PayloadDescriptor* payloadDescriptor = VP8::Parse(data, len, frameMarking, frameMarkingLen); PayloadDescriptor* payloadDescriptor = VP8::Parse(data, len, frameMarking, frameMarkingLen);
if (!payloadDescriptor) if (!payloadDescriptor)
{
return; return;
}
auto* payloadDescriptorHandler = new PayloadDescriptorHandler(payloadDescriptor); auto* payloadDescriptorHandler = new PayloadDescriptorHandler(payloadDescriptor);
...@@ -180,7 +194,9 @@ namespace RTC ...@@ -180,7 +194,9 @@ namespace RTC
// Nothing to do. // Nothing to do.
if (!this->extended) if (!this->extended)
{
return; return;
}
data += 2; data += 2;
...@@ -200,12 +216,16 @@ namespace RTC ...@@ -200,12 +216,16 @@ namespace RTC
data++; data++;
if (pictureId > 127) if (pictureId > 127)
{
MS_DEBUG_TAG(rtp, "casting pictureId value to one byte"); MS_DEBUG_TAG(rtp, "casting pictureId value to one byte");
}
} }
} }
if (this->l) if (this->l)
{
*data = tl0PictureIndex; *data = tl0PictureIndex;
}
} }
void VP8::PayloadDescriptor::Restore(uint8_t* data) const void VP8::PayloadDescriptor::Restore(uint8_t* data) const
...@@ -337,7 +357,9 @@ namespace RTC ...@@ -337,7 +357,9 @@ namespace RTC
} }
if (context->GetCurrentTemporalLayer() > context->GetTargetTemporalLayer()) if (context->GetCurrentTemporalLayer() > context->GetTargetTemporalLayer())
{
context->SetCurrentTemporalLayer(context->GetTargetTemporalLayer()); context->SetCurrentTemporalLayer(context->GetTargetTemporalLayer());
}
// clang-format off // clang-format off
if ( if (
......
...@@ -19,7 +19,9 @@ namespace RTC ...@@ -19,7 +19,9 @@ namespace RTC
MS_TRACE(); MS_TRACE();
if (len < 1) if (len < 1)
{
return nullptr; return nullptr;
}
std::unique_ptr<PayloadDescriptor> payloadDescriptor(new PayloadDescriptor()); std::unique_ptr<PayloadDescriptor> payloadDescriptor(new PayloadDescriptor());
...@@ -37,14 +39,18 @@ namespace RTC ...@@ -37,14 +39,18 @@ namespace RTC
if (payloadDescriptor->i) if (payloadDescriptor->i)
{ {
if (len < ++offset + 1) if (len < ++offset + 1)
{
return nullptr; return nullptr;
}
byte = data[offset]; byte = data[offset];
if (byte >> 7 & 0x01) if (byte >> 7 & 0x01)
{ {
if (len < ++offset + 1) if (len < ++offset + 1)
{
return nullptr; return nullptr;
}
payloadDescriptor->pictureId = (byte & 0x7F) << 8; payloadDescriptor->pictureId = (byte & 0x7F) << 8;
payloadDescriptor->pictureId += data[offset]; payloadDescriptor->pictureId += data[offset];
...@@ -62,7 +68,9 @@ namespace RTC ...@@ -62,7 +68,9 @@ namespace RTC
if (payloadDescriptor->l) if (payloadDescriptor->l)
{ {
if (len < ++offset + 1) if (len < ++offset + 1)
{
return nullptr; return nullptr;
}
byte = data[offset]; byte = data[offset];
...@@ -74,7 +82,9 @@ namespace RTC ...@@ -74,7 +82,9 @@ namespace RTC
payloadDescriptor->hasTlIndex = true; payloadDescriptor->hasTlIndex = true;
if (len < ++offset + 1) if (len < ++offset + 1)
{
return nullptr; return nullptr;
}
// Read TL0PICIDX if flexible mode is unset. // Read TL0PICIDX if flexible mode is unset.
if (!payloadDescriptor->f) if (!payloadDescriptor->f)
...@@ -113,7 +123,9 @@ namespace RTC ...@@ -113,7 +123,9 @@ namespace RTC
PayloadDescriptor* payloadDescriptor = VP9::Parse(data, len, frameMarking, frameMarkingLen); PayloadDescriptor* payloadDescriptor = VP9::Parse(data, len, frameMarking, frameMarkingLen);
if (!payloadDescriptor) if (!payloadDescriptor)
{
return; return;
}
if (payloadDescriptor->isKeyFrame) if (payloadDescriptor->isKeyFrame)
{ {
...@@ -285,10 +297,15 @@ namespace RTC ...@@ -285,10 +297,15 @@ namespace RTC
// * higher than current one // * higher than current one
// * different than the current one when KSVC is enabled and this is not a keyframe // * different than the current one when KSVC is enabled and this is not a keyframe
// (interframe p bit = 1) // (interframe p bit = 1)
// clang-format off
if ( if (
!isOldPacket && !isOldPacket &&
(packetSpatialLayer > tmpSpatialLayer || (
(context->IsKSvc() && this->payloadDescriptor->p && packetSpatialLayer != tmpSpatialLayer))) packetSpatialLayer > tmpSpatialLayer ||
(context->IsKSvc() && this->payloadDescriptor->p && packetSpatialLayer != tmpSpatialLayer)
)
)
// clang-format on
{ {
return false; return false;
} }
...@@ -345,12 +362,16 @@ namespace RTC ...@@ -345,12 +362,16 @@ namespace RTC
// Filter temporal layers higher than current one. // Filter temporal layers higher than current one.
if (packetTemporalLayer > tmpTemporalLayer) if (packetTemporalLayer > tmpTemporalLayer)
{
return false; return false;
}
} }
// Set marker bit if needed. // Set marker bit if needed.
if (packetSpatialLayer == tmpSpatialLayer && this->payloadDescriptor->e) if (packetSpatialLayer == tmpSpatialLayer && this->payloadDescriptor->e)
{
marker = true; marker = true;
}
// Update the pictureId manager. // Update the pictureId manager.
if (this->payloadDescriptor->hasPictureId) if (this->payloadDescriptor->hasPictureId)
...@@ -362,11 +383,15 @@ namespace RTC ...@@ -362,11 +383,15 @@ namespace RTC
// Update current spatial layer if needed. // Update current spatial layer if needed.
if (tmpSpatialLayer != context->GetCurrentSpatialLayer()) if (tmpSpatialLayer != context->GetCurrentSpatialLayer())
{
context->SetCurrentSpatialLayer(tmpSpatialLayer); context->SetCurrentSpatialLayer(tmpSpatialLayer);
}
// Update current temporal layer if needed. // Update current temporal layer if needed.
if (tmpTemporalLayer != context->GetCurrentTemporalLayer()) if (tmpTemporalLayer != context->GetCurrentTemporalLayer())
{
context->SetCurrentTemporalLayer(tmpTemporalLayer); context->SetCurrentTemporalLayer(tmpTemporalLayer);
}
return true; return true;
} }
......
Markdown 格式
0% 或
您添加了 0 人 到此讨论。请谨慎行事。
请先完成此评论的编辑!
请 注册 或者 后发表评论