Add support for sending RTP two-byte header extensions.

Automatic detection if one-byte header or two-byte header should be used based
on extension ID and extension length.

Bug: webrtc:7990
Change-Id: I9fc848ecc59458d1ca97bace0e57ea04d3d0ced6
Reviewed-on: https://webrtc-review.googlesource.com/c/103422
Commit-Queue: Johannes Kron <kron@webrtc.org>
Reviewed-by: Erik Språng <sprang@webrtc.org>
Reviewed-by: Seth Hampson <shampson@webrtc.org>
Reviewed-by: Danil Chapovalov <danilchap@webrtc.org>
Cr-Commit-Position: refs/heads/master@{#25004}
This commit is contained in:
Johannes Kron
2018-10-05 10:00:46 +02:00
committed by Commit Bot
parent 7880be1799
commit 78cdde3df6
9 changed files with 217 additions and 23 deletions

View File

@ -143,6 +143,12 @@ class RtpPacket {
// Returns empty arrayview on failure.
rtc::ArrayView<uint8_t> AllocateRawExtension(int id, size_t length);
// Promotes existing one-byte header extensions to two-byte header extensions
// by rewriting the data and updates the corresponding extension offsets.
void PromoteToTwoByteHeaderExtension();
uint16_t SetExtensionLengthMaybeAddZeroPadding(size_t extensions_offset);
// Find or allocate an extension |type|. Returns view of size |length|
// to write raw extension to or an empty view on failure.
rtc::ArrayView<uint8_t> AllocateExtension(ExtensionType type, size_t length);
@ -187,8 +193,6 @@ rtc::ArrayView<const uint8_t> RtpPacket::GetRawExtension() const {
template <typename Extension, typename... Values>
bool RtpPacket::SetExtension(Values... values) {
const size_t value_size = Extension::ValueSize(values...);
if (value_size == 0 || value_size > 16)
return false;
auto buffer = AllocateExtension(Extension::kId, value_size);
if (buffer.empty())
return false;