Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(143)

Side by Side Diff: webrtc/modules/rtp_rtcp/source/rtp_header_extension.h

Issue 2867713003: Remove hardcoded kValueSizeBytes values from variable-length header extensions. (Closed)
Patch Set: Patch 1 Created 3 years, 7 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
1 /* 1 /*
2 * Copyright (c) 2012 The WebRTC project authors. All Rights Reserved. 2 * Copyright (c) 2012 The WebRTC project authors. All Rights Reserved.
3 * 3 *
4 * Use of this source code is governed by a BSD-style license 4 * Use of this source code is governed by a BSD-style license
5 * that can be found in the LICENSE file in the root of the source 5 * that can be found in the LICENSE file in the root of the source
6 * tree. An additional intellectual property rights grant can be found 6 * tree. An additional intellectual property rights grant can be found
7 * in the file PATENTS. All contributing project authors may 7 * in the file PATENTS. All contributing project authors may
8 * be found in the AUTHORS file in the root of the source tree. 8 * be found in the AUTHORS file in the root of the source tree.
9 */ 9 */
10 10
(...skipping 13 matching lines...) Expand all
24 class RtpHeaderExtensionMap { 24 class RtpHeaderExtensionMap {
25 public: 25 public:
26 static constexpr RTPExtensionType kInvalidType = kRtpExtensionNone; 26 static constexpr RTPExtensionType kInvalidType = kRtpExtensionNone;
27 static constexpr uint8_t kInvalidId = 0; 27 static constexpr uint8_t kInvalidId = 0;
28 28
29 RtpHeaderExtensionMap(); 29 RtpHeaderExtensionMap();
30 explicit RtpHeaderExtensionMap(rtc::ArrayView<const RtpExtension> extensions); 30 explicit RtpHeaderExtensionMap(rtc::ArrayView<const RtpExtension> extensions);
31 31
32 template <typename Extension> 32 template <typename Extension>
33 bool Register(uint8_t id) { 33 bool Register(uint8_t id) {
34 return Register(id, Extension::kId, Extension::kValueSizeBytes, 34 return Register(id, Extension::kId, Extension::kUri);
35 Extension::kUri);
36 } 35 }
37 bool RegisterByType(uint8_t id, RTPExtensionType type); 36 bool RegisterByType(uint8_t id, RTPExtensionType type);
38 bool RegisterByUri(uint8_t id, const std::string& uri); 37 bool RegisterByUri(uint8_t id, const std::string& uri);
39 38
40 bool IsRegistered(RTPExtensionType type) const { 39 bool IsRegistered(RTPExtensionType type) const {
41 return GetId(type) != kInvalidId; 40 return GetId(type) != kInvalidId;
42 } 41 }
43 // Return kInvalidType if not found. 42 // Return kInvalidType if not found.
44 RTPExtensionType GetType(uint8_t id) const { 43 RTPExtensionType GetType(uint8_t id) const {
45 RTC_DCHECK_GE(id, kMinId); 44 RTC_DCHECK_GE(id, kMinId);
46 RTC_DCHECK_LE(id, kMaxId); 45 RTC_DCHECK_LE(id, kMaxId);
47 return types_[id]; 46 return types_[id];
48 } 47 }
49 // Return kInvalidId if not found. 48 // Return kInvalidId if not found.
50 uint8_t GetId(RTPExtensionType type) const { 49 uint8_t GetId(RTPExtensionType type) const {
51 RTC_DCHECK_GT(type, kRtpExtensionNone); 50 RTC_DCHECK_GT(type, kRtpExtensionNone);
52 RTC_DCHECK_LT(type, kRtpExtensionNumberOfExtensions); 51 RTC_DCHECK_LT(type, kRtpExtensionNumberOfExtensions);
53 return ids_[type]; 52 return ids_[type];
54 } 53 }
55 54
56 size_t GetTotalLengthInBytes() const; 55 size_t GetTotalLengthInBytes(
56 rtc::ArrayView<const RtpExtensionSize> extensions) const;
57 57
58 // TODO(danilchap): Remove use of the functions below. 58 // TODO(danilchap): Remove use of the functions below.
59 int32_t Register(RTPExtensionType type, uint8_t id) { 59 int32_t Register(RTPExtensionType type, uint8_t id) {
60 return RegisterByType(id, type) ? 0 : -1; 60 return RegisterByType(id, type) ? 0 : -1;
61 } 61 }
62 int32_t Deregister(RTPExtensionType type); 62 int32_t Deregister(RTPExtensionType type);
63 63
64 private: 64 private:
65 static constexpr uint8_t kMinId = 1; 65 static constexpr uint8_t kMinId = 1;
66 static constexpr uint8_t kMaxId = 14; 66 static constexpr uint8_t kMaxId = 14;
67 bool Register(uint8_t id, 67 bool Register(uint8_t id, RTPExtensionType type, const char* uri);
68 RTPExtensionType type,
69 size_t value_size,
70 const char* uri);
71 68
72 size_t total_values_size_bytes_ = 0;
73 RTPExtensionType types_[kMaxId + 1]; 69 RTPExtensionType types_[kMaxId + 1];
74 uint8_t ids_[kRtpExtensionNumberOfExtensions]; 70 uint8_t ids_[kRtpExtensionNumberOfExtensions];
75 }; 71 };
76 72
77 } // namespace webrtc 73 } // namespace webrtc
78 74
79 #endif // WEBRTC_MODULES_RTP_RTCP_SOURCE_RTP_HEADER_EXTENSION_H_ 75 #endif // WEBRTC_MODULES_RTP_RTCP_SOURCE_RTP_HEADER_EXTENSION_H_
80
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698