Cleanup rtp utils in media/base
Remove unused functions GetRtpHeader/GetRtpHeaderLength Replace usage of SetRtpHeader with webrtc::RtpPacket Move SetRtpSsrc next to the only place it is used. Bug: None Change-Id: I3ecc244b1a2bdb2d68e0dbdb34dd60160a3101f8 Reviewed-on: https://webrtc-review.googlesource.com/c/src/+/225547 Reviewed-by: Erik Språng <sprang@webrtc.org> Commit-Queue: Danil Chapovalov <danilchap@webrtc.org> Cr-Commit-Position: refs/heads/master@{#34447}
This commit is contained in:
committed by
WebRTC LUCI CQ
parent
e09a174746
commit
fb1a0f0e1f
@ -25,8 +25,6 @@
|
||||
|
||||
namespace cricket {
|
||||
|
||||
static const uint8_t kRtpVersion = 2;
|
||||
static const size_t kRtpFlagsOffset = 0;
|
||||
static const size_t kRtpPayloadTypeOffset = 1;
|
||||
static const size_t kRtpSeqNumOffset = 2;
|
||||
static const size_t kRtpTimestampOffset = 4;
|
||||
@ -120,8 +118,6 @@ void UpdateRtpAuthTag(uint8_t* rtp,
|
||||
memcpy(auth_tag, output, tag_length);
|
||||
}
|
||||
|
||||
} // namespace
|
||||
|
||||
bool GetUint8(const void* data, size_t offset, int* value) {
|
||||
if (!data || !value) {
|
||||
return false;
|
||||
@ -147,36 +143,7 @@ bool GetUint32(const void* data, size_t offset, uint32_t* value) {
|
||||
return true;
|
||||
}
|
||||
|
||||
bool SetUint8(void* data, size_t offset, uint8_t value) {
|
||||
if (!data) {
|
||||
return false;
|
||||
}
|
||||
rtc::Set8(data, offset, value);
|
||||
return true;
|
||||
}
|
||||
|
||||
bool SetUint16(void* data, size_t offset, uint16_t value) {
|
||||
if (!data) {
|
||||
return false;
|
||||
}
|
||||
rtc::SetBE16(static_cast<uint8_t*>(data) + offset, value);
|
||||
return true;
|
||||
}
|
||||
|
||||
bool SetUint32(void* data, size_t offset, uint32_t value) {
|
||||
if (!data) {
|
||||
return false;
|
||||
}
|
||||
rtc::SetBE32(static_cast<uint8_t*>(data) + offset, value);
|
||||
return true;
|
||||
}
|
||||
|
||||
bool GetRtpFlags(const void* data, size_t len, int* value) {
|
||||
if (len < kMinRtpPacketLen) {
|
||||
return false;
|
||||
}
|
||||
return GetUint8(data, kRtpFlagsOffset, value);
|
||||
}
|
||||
} // namespace
|
||||
|
||||
bool GetRtpPayloadType(const void* data, size_t len, int* value) {
|
||||
if (len < kMinRtpPacketLen) {
|
||||
@ -210,34 +177,6 @@ bool GetRtpSsrc(const void* data, size_t len, uint32_t* value) {
|
||||
return GetUint32(data, kRtpSsrcOffset, value);
|
||||
}
|
||||
|
||||
bool GetRtpHeaderLen(const void* data, size_t len, size_t* value) {
|
||||
if (!data || len < kMinRtpPacketLen || !value)
|
||||
return false;
|
||||
const uint8_t* header = static_cast<const uint8_t*>(data);
|
||||
// Get base header size + length of CSRCs (not counting extension yet).
|
||||
size_t header_size = kMinRtpPacketLen + (header[0] & 0xF) * sizeof(uint32_t);
|
||||
if (len < header_size)
|
||||
return false;
|
||||
// If there's an extension, read and add in the extension size.
|
||||
if (header[0] & 0x10) {
|
||||
if (len < header_size + sizeof(uint32_t))
|
||||
return false;
|
||||
header_size +=
|
||||
((rtc::GetBE16(header + header_size + 2) + 1) * sizeof(uint32_t));
|
||||
if (len < header_size)
|
||||
return false;
|
||||
}
|
||||
*value = header_size;
|
||||
return true;
|
||||
}
|
||||
|
||||
bool GetRtpHeader(const void* data, size_t len, RtpHeader* header) {
|
||||
return (GetRtpPayloadType(data, len, &(header->payload_type)) &&
|
||||
GetRtpSeqNum(data, len, &(header->seq_num)) &&
|
||||
GetRtpTimestamp(data, len, &(header->timestamp)) &&
|
||||
GetRtpSsrc(data, len, &(header->ssrc)));
|
||||
}
|
||||
|
||||
bool GetRtcpType(const void* data, size_t len, int* value) {
|
||||
if (len < kMinRtcpPacketLen) {
|
||||
return false;
|
||||
@ -262,24 +201,6 @@ bool GetRtcpSsrc(const void* data, size_t len, uint32_t* value) {
|
||||
return true;
|
||||
}
|
||||
|
||||
bool SetRtpSsrc(void* data, size_t len, uint32_t value) {
|
||||
return SetUint32(data, kRtpSsrcOffset, value);
|
||||
}
|
||||
|
||||
// Assumes version 2, no padding, no extensions, no csrcs.
|
||||
bool SetRtpHeader(void* data, size_t len, const RtpHeader& header) {
|
||||
if (!IsValidRtpPayloadType(header.payload_type) || header.seq_num < 0 ||
|
||||
header.seq_num > static_cast<int>(UINT16_MAX)) {
|
||||
return false;
|
||||
}
|
||||
return (SetUint8(data, kRtpFlagsOffset, kRtpVersion << 6) &&
|
||||
SetUint8(data, kRtpPayloadTypeOffset, header.payload_type & 0x7F) &&
|
||||
SetUint16(data, kRtpSeqNumOffset,
|
||||
static_cast<uint16_t>(header.seq_num)) &&
|
||||
SetUint32(data, kRtpTimestampOffset, header.timestamp) &&
|
||||
SetRtpSsrc(data, len, header.ssrc));
|
||||
}
|
||||
|
||||
bool IsValidRtpPayloadType(int payload_type) {
|
||||
return payload_type >= 0 && payload_type <= 127;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user