Refactor to remove direct memory dependency on kMaxId

When two-byte header extensions are enabled, kMaxId will change from 15
to 255. This CL is a refactor to remove the direct dependency between
memory allocation and kMaxId.

Bug: webrtc:7990
Change-Id: I38974a9c705eb6a0fdba9038a7d909861587d98d
Reviewed-on: https://webrtc-review.googlesource.com/101580
Commit-Queue: Johannes Kron <kron@webrtc.org>
Reviewed-by: Danil Chapovalov <danilchap@webrtc.org>
Cr-Commit-Position: refs/heads/master@{#24801}
This commit is contained in:
Johannes Kron
2018-09-24 14:50:48 +02:00
committed by Commit Bot
parent 3a9731ff2f
commit c5744b8b21
5 changed files with 89 additions and 58 deletions

View File

@ -44,11 +44,7 @@ class RtpHeaderExtensionMap {
return GetId(type) != kInvalidId;
}
// Return kInvalidType if not found.
RTPExtensionType GetType(int id) const {
RTC_DCHECK_GE(id, kMinId);
RTC_DCHECK_LE(id, kMaxId);
return types_[id];
}
RTPExtensionType GetType(int id) const;
// Return kInvalidId if not found.
uint8_t GetId(RTPExtensionType type) const {
RTC_DCHECK_GT(type, kRtpExtensionNone);
@ -70,7 +66,6 @@ class RtpHeaderExtensionMap {
static constexpr int kMaxId = 14;
bool Register(int id, RTPExtensionType type, const char* uri);
RTPExtensionType types_[kMaxId + 1];
uint8_t ids_[kRtpExtensionNumberOfExtensions];
};