Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

RtpPacket: optimize UpdateMid() #920

Merged
merged 1 commit into from
Sep 30, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion worker/include/RTC/RtpPacket.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -315,7 +315,7 @@ namespace RTC
return true;
}

bool UpdateMid(const std::string& mid);
void UpdateMid(const std::string& mid);

bool ReadRid(std::string& rid) const
{
Expand Down
16 changes: 8 additions & 8 deletions worker/src/RTC/RtpPacket.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -533,33 +533,33 @@ namespace RTC
MS_ASSERT(ptr == this->payload, "wrong ptr calculation");
}

bool RtpPacket::UpdateMid(const std::string& mid)
void RtpPacket::UpdateMid(const std::string& mid)
{
MS_TRACE();

uint8_t extenLen;
uint8_t* extenValue = GetExtension(this->midExtensionId, extenLen);

if (!extenValue)
return false;
return;

size_t midLen = mid.length();

// Here we assume that there is MidMaxLength available bytes, even if now
// they are padding bytes.
if (mid.size() > RTC::MidMaxLength)
if (midLen > RTC::MidMaxLength)
{
MS_ERROR(
"no enough space for MID value [MidMaxLength:%" PRIu8 ", mid:'%s']",
RTC::MidMaxLength,
mid.c_str());

return false;
return;
}

std::memcpy(extenValue, mid.c_str(), mid.size());

SetExtensionLength(this->midExtensionId, mid.size());
std::memcpy(extenValue, mid.c_str(), midLen);

return true;
SetExtensionLength(this->midExtensionId, midLen);
}

/**
Expand Down