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

RtpProbationGenerator: fix memory corruption issue

上级 e2e6f14e
...@@ -165,8 +165,8 @@ namespace RTC ...@@ -165,8 +165,8 @@ namespace RTC
bool UpdateMid(const std::string& mid); bool UpdateMid(const std::string& mid);
bool ReadRid(std::string& rid) const; bool ReadRid(std::string& rid) const;
bool ReadAbsSendTime(uint32_t& absSendtime) const; bool ReadAbsSendTime(uint32_t& absSendtime) const;
bool ReadTransportWideCc01(uint16_t& wideSeqNumber) const;
bool UpdateAbsSendTime(uint64_t ms); bool UpdateAbsSendTime(uint64_t ms);
bool ReadTransportWideCc01(uint16_t& wideSeqNumber) const;
bool UpdateTransportWideCc01(uint16_t wideSeqNumber); bool UpdateTransportWideCc01(uint16_t wideSeqNumber);
bool ReadFrameMarking(RtpPacket::FrameMarking** frameMarking, uint8_t& length) const; bool ReadFrameMarking(RtpPacket::FrameMarking** frameMarking, uint8_t& length) const;
bool ReadSsrcAudioLevel(uint8_t& volume, bool& voice) const; bool ReadSsrcAudioLevel(uint8_t& volume, bool& voice) const;
...@@ -438,30 +438,30 @@ namespace RTC ...@@ -438,30 +438,30 @@ namespace RTC
return true; return true;
} }
inline bool RtpPacket::ReadTransportWideCc01(uint16_t& wideSeqNumber) const inline bool RtpPacket::UpdateAbsSendTime(uint64_t ms)
{ {
uint8_t extenLen; uint8_t extenLen;
uint8_t* extenValue = GetExtension(this->transportWideCc01ExtensionId, extenLen); uint8_t* extenValue = GetExtension(this->absSendTimeExtensionId, extenLen);
if (!extenValue || extenLen != 2u) if (!extenValue || extenLen != 3u)
return false; return false;
wideSeqNumber = Utils::Byte::Get2Bytes(extenValue, 0); auto absSendTime = Utils::Time::TimeMsToAbsSendTime(ms);
Utils::Byte::Set3Bytes(extenValue, 0, absSendTime);
return true; return true;
} }
inline bool RtpPacket::UpdateAbsSendTime(uint64_t ms) inline bool RtpPacket::ReadTransportWideCc01(uint16_t& wideSeqNumber) const
{ {
uint8_t extenLen; uint8_t extenLen;
uint8_t* extenValue = GetExtension(this->absSendTimeExtensionId, extenLen); uint8_t* extenValue = GetExtension(this->transportWideCc01ExtensionId, extenLen);
if (!extenValue || extenLen != 3u) if (!extenValue || extenLen != 2u)
return false; return false;
auto absSendTime = Utils::Time::TimeMsToAbsSendTime(ms); wideSeqNumber = Utils::Byte::Get2Bytes(extenValue, 0);
Utils::Byte::Set3Bytes(extenValue, 0, absSendTime);
return true; return true;
} }
......
...@@ -15,19 +15,24 @@ namespace RTC ...@@ -15,19 +15,24 @@ namespace RTC
// clang-format off // clang-format off
// Probation RTP header. // Probation RTP header.
// Caution: This must have an exact size for the RTP extensions to be added
// and must align extensions to 4 bytes.
static uint8_t ProbationPacketHeader[] = static uint8_t ProbationPacketHeader[] =
{ {
0b10010000, 0b01111111, 0, 0, // PayloadType: 127, Sequence Number: 0 0b10010000, 0b01111111, 0, 0, // PayloadType: 127, Sequence Number: 0
0, 0, 0, 0, // Timestamp: 0 0, 0, 0, 0, // Timestamp: 0
0, 0, 0, 0, // SSRC: 0 0, 0, 0, 0, // SSRC: 0
0xBE, 0xDE, 0, 2, // Header Extension (One-Byte Extensions) 0xBE, 0xDE, 0, 4, // Header Extension (One-Byte Extensions)
0, 0, 0, 0, // Space for abs-send-time extension. 0, 0, 0, 0, // Space for MID extension
0, 0, 0, 0 // Space for transport-wide-cc-01 extension. 0, 0, 0, 0,
0,
0, 0, 0, 0, // Space for abs-send-time extension
0, 0, 0 // Space for transport-wide-cc-01 extension
}; };
// clang-format on // clang-format on
static constexpr size_t MaxProbationPacketSize{ 1400u }; static constexpr size_t MaxProbationPacketSize{ 1400u };
static const std::string MidValue{ "probator" }; static const std::string MidValue{ "probator" }; // 8 bytes, same as RTC::MidMaxLength.
/* Instance methods. */ /* Instance methods. */
......
Markdown 格式
0% 或
您添加了 0 人 到此讨论。请谨慎行事。
请先完成此评论的编辑!
请 注册 或者 后发表评论