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

RtpPacket: Properly remove padding when RTX decoding or encoding.

上级 abb70a0c
# TODO in mediasoup v2 (server-side) # TODO in mediasoup v2 (server-side)
* `RtpPacket::RtxEncode()` should remove the original padding (also the header flag by using `SetPayloadPaddingFlag(false)`), then set the RTX payload, then check whether padding is required and, if so, set the padding flag and bytes.
- Similar stuff (inverse) with `RtxDecode()`.
- NOTE: Nobody does this. Also, it's dangerous since after `RtxDecode()` it may happen that N bytes of padding are needed, but those exceed the original RTX packet size.
* In `RtpStreamSend::StorePacket()` we should remove old packets (as `NackGenerator` does). * In `RtpStreamSend::StorePacket()` we should remove old packets (as `NackGenerator` does).
* Remove `producer.on('rtprawpacket')` and, instead, create a special `RtpConsumer` or something like that. * Remove `producer.on('rtprawpacket')` and, instead, create a special `RtpConsumer` or something like that.
......
...@@ -102,7 +102,7 @@ namespace RTC ...@@ -102,7 +102,7 @@ namespace RTC
return nullptr; return nullptr;
} }
if (payloadLength < static_cast<size_t>(payloadPadding)) if (payloadLength < size_t{ payloadPadding })
{ {
MS_WARN_TAG( MS_WARN_TAG(
rtp, rtp,
...@@ -116,7 +116,7 @@ namespace RTC ...@@ -116,7 +116,7 @@ namespace RTC
MS_ASSERT( MS_ASSERT(
len == sizeof(Header) + csrcListSize + (extensionHeader ? 4 + extensionValueSize : 0) + len == sizeof(Header) + csrcListSize + (extensionHeader ? 4 + extensionValueSize : 0) +
payloadLength + static_cast<size_t>(payloadPadding), payloadLength + size_t{ payloadPadding },
"packet's computed size does not match received size"); "packet's computed size does not match received size");
auto packet = new RtpPacket(header, extensionHeader, payload, payloadLength, payloadPadding, len); auto packet = new RtpPacket(header, extensionHeader, payload, payloadLength, payloadPadding, len);
...@@ -356,12 +356,17 @@ namespace RTC ...@@ -356,12 +356,17 @@ namespace RTC
// Fix the payload length. // Fix the payload length.
this->payloadLength += 2; this->payloadLength += 2;
// Remove padding.
SetPayloadPaddingFlag(false);
this->payloadPadding = 0u;
// Fix the packet size. // Fix the packet size.
this->size += 2; this->size += 2;
// Remove padding if present.
if (this->payloadPadding != 0u)
{
SetPayloadPaddingFlag(false);
this->size -= size_t{ this->payloadPadding };
this->payloadPadding = 0u;
}
} }
bool RtpPacket::RtxDecode(uint8_t payloadType, uint32_t ssrc) bool RtpPacket::RtxDecode(uint8_t payloadType, uint32_t ssrc)
...@@ -388,13 +393,18 @@ namespace RTC ...@@ -388,13 +393,18 @@ namespace RTC
// Fix the payload length. // Fix the payload length.
this->payloadLength -= 2; this->payloadLength -= 2;
// Remove padding.
SetPayloadPaddingFlag(false);
this->payloadPadding = 0u;
// Fix the packet size. // Fix the packet size.
this->size -= 2; this->size -= 2;
// Remove padding if present.
if (this->payloadPadding != 0u)
{
SetPayloadPaddingFlag(false);
this->size -= size_t{ this->payloadPadding };
this->payloadPadding = 0u;
}
return true; return true;
} }
......
Markdown 格式
0% 或
您添加了 0 人 到此讨论。请谨慎行事。
请先完成此评论的编辑!
请 注册 或者 后发表评论