OLD | NEW |
1 /* | 1 /* |
2 * Copyright (c) 2016 The WebRTC project authors. All Rights Reserved. | 2 * Copyright (c) 2016 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 #ifndef WEBRTC_MODULES_RTP_RTCP_SOURCE_RTP_HEADER_EXTENSIONS_H_ | 10 #ifndef WEBRTC_MODULES_RTP_RTCP_SOURCE_RTP_HEADER_EXTENSIONS_H_ |
(...skipping 10 matching lines...) Expand all Loading... |
21 namespace webrtc { | 21 namespace webrtc { |
22 | 22 |
23 class AbsoluteSendTime { | 23 class AbsoluteSendTime { |
24 public: | 24 public: |
25 static constexpr RTPExtensionType kId = kRtpExtensionAbsoluteSendTime; | 25 static constexpr RTPExtensionType kId = kRtpExtensionAbsoluteSendTime; |
26 static constexpr uint8_t kValueSizeBytes = 3; | 26 static constexpr uint8_t kValueSizeBytes = 3; |
27 static constexpr const char* kUri = | 27 static constexpr const char* kUri = |
28 "http://www.webrtc.org/experiments/rtp-hdrext/abs-send-time"; | 28 "http://www.webrtc.org/experiments/rtp-hdrext/abs-send-time"; |
29 | 29 |
30 static bool Parse(rtc::ArrayView<const uint8_t> data, uint32_t* time_24bits); | 30 static bool Parse(rtc::ArrayView<const uint8_t> data, uint32_t* time_24bits); |
| 31 static size_t ValueSize(int64_t time_ms) { return kValueSizeBytes; } |
31 static bool Write(uint8_t* data, int64_t time_ms); | 32 static bool Write(uint8_t* data, int64_t time_ms); |
32 | 33 |
33 static constexpr uint32_t MsTo24Bits(int64_t time_ms) { | 34 static constexpr uint32_t MsTo24Bits(int64_t time_ms) { |
34 return static_cast<uint32_t>(((time_ms << 18) + 500) / 1000) & 0x00FFFFFF; | 35 return static_cast<uint32_t>(((time_ms << 18) + 500) / 1000) & 0x00FFFFFF; |
35 } | 36 } |
36 }; | 37 }; |
37 | 38 |
38 class AudioLevel { | 39 class AudioLevel { |
39 public: | 40 public: |
40 static constexpr RTPExtensionType kId = kRtpExtensionAudioLevel; | 41 static constexpr RTPExtensionType kId = kRtpExtensionAudioLevel; |
41 static constexpr uint8_t kValueSizeBytes = 1; | 42 static constexpr uint8_t kValueSizeBytes = 1; |
42 static constexpr const char* kUri = | 43 static constexpr const char* kUri = |
43 "urn:ietf:params:rtp-hdrext:ssrc-audio-level"; | 44 "urn:ietf:params:rtp-hdrext:ssrc-audio-level"; |
44 | 45 |
45 static bool Parse(rtc::ArrayView<const uint8_t> data, | 46 static bool Parse(rtc::ArrayView<const uint8_t> data, |
46 bool* voice_activity, | 47 bool* voice_activity, |
47 uint8_t* audio_level); | 48 uint8_t* audio_level); |
| 49 static size_t ValueSize(bool voice_activity, uint8_t audio_level) { |
| 50 return kValueSizeBytes; |
| 51 } |
48 static bool Write(uint8_t* data, bool voice_activity, uint8_t audio_level); | 52 static bool Write(uint8_t* data, bool voice_activity, uint8_t audio_level); |
49 }; | 53 }; |
50 | 54 |
51 class TransmissionOffset { | 55 class TransmissionOffset { |
52 public: | 56 public: |
53 static constexpr RTPExtensionType kId = kRtpExtensionTransmissionTimeOffset; | 57 static constexpr RTPExtensionType kId = kRtpExtensionTransmissionTimeOffset; |
54 static constexpr uint8_t kValueSizeBytes = 3; | 58 static constexpr uint8_t kValueSizeBytes = 3; |
55 static constexpr const char* kUri = "urn:ietf:params:rtp-hdrext:toffset"; | 59 static constexpr const char* kUri = "urn:ietf:params:rtp-hdrext:toffset"; |
56 | 60 |
57 static bool Parse(rtc::ArrayView<const uint8_t> data, int32_t* rtp_time); | 61 static bool Parse(rtc::ArrayView<const uint8_t> data, int32_t* rtp_time); |
| 62 static size_t ValueSize(int32_t rtp_time) { return kValueSizeBytes; } |
58 static bool Write(uint8_t* data, int32_t rtp_time); | 63 static bool Write(uint8_t* data, int32_t rtp_time); |
59 }; | 64 }; |
60 | 65 |
61 class TransportSequenceNumber { | 66 class TransportSequenceNumber { |
62 public: | 67 public: |
63 static constexpr RTPExtensionType kId = kRtpExtensionTransportSequenceNumber; | 68 static constexpr RTPExtensionType kId = kRtpExtensionTransportSequenceNumber; |
64 static constexpr uint8_t kValueSizeBytes = 2; | 69 static constexpr uint8_t kValueSizeBytes = 2; |
65 static constexpr const char* kUri = | 70 static constexpr const char* kUri = |
66 "http://www.ietf.org/id/" | 71 "http://www.ietf.org/id/" |
67 "draft-holmer-rmcat-transport-wide-cc-extensions-01"; | 72 "draft-holmer-rmcat-transport-wide-cc-extensions-01"; |
68 static bool Parse(rtc::ArrayView<const uint8_t> data, uint16_t* value); | 73 static bool Parse(rtc::ArrayView<const uint8_t> data, uint16_t* value); |
| 74 static size_t ValueSize(uint16_t value) { return kValueSizeBytes; } |
69 static bool Write(uint8_t* data, uint16_t value); | 75 static bool Write(uint8_t* data, uint16_t value); |
70 }; | 76 }; |
71 | 77 |
72 class VideoOrientation { | 78 class VideoOrientation { |
73 public: | 79 public: |
74 static constexpr RTPExtensionType kId = kRtpExtensionVideoRotation; | 80 static constexpr RTPExtensionType kId = kRtpExtensionVideoRotation; |
75 static constexpr uint8_t kValueSizeBytes = 1; | 81 static constexpr uint8_t kValueSizeBytes = 1; |
76 static constexpr const char* kUri = "urn:3gpp:video-orientation"; | 82 static constexpr const char* kUri = "urn:3gpp:video-orientation"; |
77 | 83 |
78 static bool Parse(rtc::ArrayView<const uint8_t> data, VideoRotation* value); | 84 static bool Parse(rtc::ArrayView<const uint8_t> data, VideoRotation* value); |
| 85 static size_t ValueSize(VideoRotation) { return kValueSizeBytes; } |
79 static bool Write(uint8_t* data, VideoRotation value); | 86 static bool Write(uint8_t* data, VideoRotation value); |
80 static bool Parse(rtc::ArrayView<const uint8_t> data, uint8_t* value); | 87 static bool Parse(rtc::ArrayView<const uint8_t> data, uint8_t* value); |
| 88 static size_t ValueSize(uint8_t value) { return kValueSizeBytes; } |
81 static bool Write(uint8_t* data, uint8_t value); | 89 static bool Write(uint8_t* data, uint8_t value); |
82 }; | 90 }; |
83 | 91 |
84 class PlayoutDelayLimits { | 92 class PlayoutDelayLimits { |
85 public: | 93 public: |
86 static constexpr RTPExtensionType kId = kRtpExtensionPlayoutDelay; | 94 static constexpr RTPExtensionType kId = kRtpExtensionPlayoutDelay; |
87 static constexpr uint8_t kValueSizeBytes = 3; | 95 static constexpr uint8_t kValueSizeBytes = 3; |
88 static constexpr const char* kUri = | 96 static constexpr const char* kUri = |
89 "http://www.webrtc.org/experiments/rtp-hdrext/playout-delay"; | 97 "http://www.webrtc.org/experiments/rtp-hdrext/playout-delay"; |
90 | 98 |
91 // Playout delay in milliseconds. A playout delay limit (min or max) | 99 // Playout delay in milliseconds. A playout delay limit (min or max) |
92 // has 12 bits allocated. This allows a range of 0-4095 values which | 100 // has 12 bits allocated. This allows a range of 0-4095 values which |
93 // translates to a range of 0-40950 in milliseconds. | 101 // translates to a range of 0-40950 in milliseconds. |
94 static constexpr int kGranularityMs = 10; | 102 static constexpr int kGranularityMs = 10; |
95 // Maximum playout delay value in milliseconds. | 103 // Maximum playout delay value in milliseconds. |
96 static constexpr int kMaxMs = 0xfff * kGranularityMs; // 40950. | 104 static constexpr int kMaxMs = 0xfff * kGranularityMs; // 40950. |
97 | 105 |
98 static bool Parse(rtc::ArrayView<const uint8_t> data, | 106 static bool Parse(rtc::ArrayView<const uint8_t> data, |
99 PlayoutDelay* playout_delay); | 107 PlayoutDelay* playout_delay); |
| 108 static size_t ValueSize(const PlayoutDelay&) { |
| 109 return kValueSizeBytes; |
| 110 } |
100 static bool Write(uint8_t* data, const PlayoutDelay& playout_delay); | 111 static bool Write(uint8_t* data, const PlayoutDelay& playout_delay); |
101 }; | 112 }; |
102 | 113 |
103 class VideoContentTypeExtension { | 114 class VideoContentTypeExtension { |
104 public: | 115 public: |
105 static constexpr RTPExtensionType kId = kRtpExtensionVideoContentType; | 116 static constexpr RTPExtensionType kId = kRtpExtensionVideoContentType; |
106 static constexpr uint8_t kValueSizeBytes = 1; | 117 static constexpr uint8_t kValueSizeBytes = 1; |
107 static constexpr const char* kUri = | 118 static constexpr const char* kUri = |
108 "http://www.webrtc.org/experiments/rtp-hdrext/video-content-type"; | 119 "http://www.webrtc.org/experiments/rtp-hdrext/video-content-type"; |
109 | 120 |
110 static bool Parse(rtc::ArrayView<const uint8_t> data, | 121 static bool Parse(rtc::ArrayView<const uint8_t> data, |
111 VideoContentType* content_type); | 122 VideoContentType* content_type); |
| 123 static size_t ValueSize(VideoContentType) { |
| 124 return kValueSizeBytes; |
| 125 } |
112 static bool Write(uint8_t* data, VideoContentType content_type); | 126 static bool Write(uint8_t* data, VideoContentType content_type); |
113 }; | 127 }; |
114 | 128 |
115 class RtpStreamId { | 129 class RtpStreamId { |
116 public: | 130 public: |
117 static constexpr RTPExtensionType kId = kRtpExtensionRtpStreamId; | 131 static constexpr RTPExtensionType kId = kRtpExtensionRtpStreamId; |
118 // TODO(danilchap): Implement write support of dynamic size extension that | 132 // TODO(danilchap): Implement write support of dynamic size extension that |
119 // allows to remove the ValueSize constant. | 133 // allows to remove the ValueSize constant. |
120 static constexpr uint8_t kValueSizeBytes = 1; | 134 static constexpr uint8_t kValueSizeBytes = 1; |
121 static constexpr const char* kUri = | 135 static constexpr const char* kUri = |
122 "urn:ietf:params:rtp-hdrext:sdes:rtp-stream-id"; | 136 "urn:ietf:params:rtp-hdrext:sdes:rtp-stream-id"; |
123 | 137 |
124 static bool Parse(rtc::ArrayView<const uint8_t> data, StreamId* rid); | 138 static bool Parse(rtc::ArrayView<const uint8_t> data, StreamId* rsid); |
125 static bool Parse(rtc::ArrayView<const uint8_t> data, std::string* rid); | 139 static size_t ValueSize(const StreamId& rsid) { return rsid.size(); } |
| 140 static bool Write(uint8_t* data, const StreamId& rsid); |
| 141 |
| 142 static bool Parse(rtc::ArrayView<const uint8_t> data, std::string* rsid); |
| 143 static size_t ValueSize(const std::string& rsid) { return rsid.size(); } |
| 144 static bool Write(uint8_t* data, const std::string& rsid); |
126 }; | 145 }; |
127 | 146 |
128 class RepairedRtpStreamId { | 147 class RepairedRtpStreamId { |
129 public: | 148 public: |
130 static constexpr RTPExtensionType kId = kRtpExtensionRepairedRtpStreamId; | 149 static constexpr RTPExtensionType kId = kRtpExtensionRepairedRtpStreamId; |
131 // TODO(danilchap): Implement write support of dynamic size extension that | 150 // TODO(danilchap): Implement write support of dynamic size extension that |
132 // allows to remove the ValueSize constant. | 151 // allows to remove the ValueSize constant. |
133 static constexpr uint8_t kValueSizeBytes = 1; | 152 static constexpr uint8_t kValueSizeBytes = 1; |
134 static constexpr const char* kUri = | 153 static constexpr const char* kUri = |
135 "urn:ietf:params:rtp-hdrext:sdes:repaired-rtp-stream-id"; | 154 "urn:ietf:params:rtp-hdrext:sdes:repaired-rtp-stream-id"; |
136 | 155 |
137 static bool Parse(rtc::ArrayView<const uint8_t> data, StreamId* rid); | 156 static bool Parse(rtc::ArrayView<const uint8_t> data, StreamId* rsid); |
138 static bool Parse(rtc::ArrayView<const uint8_t> data, std::string* rid); | 157 static size_t ValueSize(const StreamId& rsid); |
| 158 static bool Write(uint8_t* data, const StreamId& rsid); |
| 159 |
| 160 static bool Parse(rtc::ArrayView<const uint8_t> data, std::string* rsid); |
| 161 static size_t ValueSize(const std::string& rsid); |
| 162 static bool Write(uint8_t* data, const std::string& rsid); |
139 }; | 163 }; |
140 | 164 |
141 } // namespace webrtc | 165 } // namespace webrtc |
142 #endif // WEBRTC_MODULES_RTP_RTCP_SOURCE_RTP_HEADER_EXTENSIONS_H_ | 166 #endif // WEBRTC_MODULES_RTP_RTCP_SOURCE_RTP_HEADER_EXTENSIONS_H_ |
OLD | NEW |