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

Side by Side Diff: webrtc/modules/rtp_rtcp/source/rtp_header_extensions.cc

Issue 2805023002: Add read support of RtpStreamId/RepairedRtpStreamId header extensions. (Closed)
Patch Set: RtpStreamId::Parse return false on empty rsid Created 3 years, 8 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) 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 10
(...skipping 197 matching lines...) Expand 10 before | Expand all | Expand 10 after
208 RTC_DCHECK_LE(0, playout_delay.min_ms); 208 RTC_DCHECK_LE(0, playout_delay.min_ms);
209 RTC_DCHECK_LE(playout_delay.min_ms, playout_delay.max_ms); 209 RTC_DCHECK_LE(playout_delay.min_ms, playout_delay.max_ms);
210 RTC_DCHECK_LE(playout_delay.max_ms, kMaxMs); 210 RTC_DCHECK_LE(playout_delay.max_ms, kMaxMs);
211 // Convert MS to value to be sent on extension header. 211 // Convert MS to value to be sent on extension header.
212 uint32_t min_delay = playout_delay.min_ms / kGranularityMs; 212 uint32_t min_delay = playout_delay.min_ms / kGranularityMs;
213 uint32_t max_delay = playout_delay.max_ms / kGranularityMs; 213 uint32_t max_delay = playout_delay.max_ms / kGranularityMs;
214 ByteWriter<uint32_t, 3>::WriteBigEndian(data, (min_delay << 12) | max_delay); 214 ByteWriter<uint32_t, 3>::WriteBigEndian(data, (min_delay << 12) | max_delay);
215 return true; 215 return true;
216 } 216 }
217 217
218 // RtpStreamId.
219 constexpr RTPExtensionType RtpStreamId::kId;
220 constexpr uint8_t RtpStreamId::kValueSizeBytes;
221 constexpr const char* RtpStreamId::kUri;
222
223 bool RtpStreamId::Parse(rtc::ArrayView<const uint8_t> data, StreamId* rsid) {
224 if (data.empty() || data[0] == 0) // Valid rsid can't be empty.
225 return false;
226 rsid->Set(data);
227 RTC_DCHECK(!rsid->empty());
228 return true;
229 }
230
231 bool RtpStreamId::Parse(rtc::ArrayView<const uint8_t> data, std::string* rsid) {
nisse-webrtc 2017/04/11 10:42:53 Are the Parse methods with a std::string result fo
danilchap 2017/04/11 12:51:26 no, std::string is for users of the rtp::Packet, S
nisse-webrtc 2017/04/11 13:34:49 Ok.
232 if (data.empty() || data[0] == 0) // Valid rsid can't be empty.
233 return false;
234 const char* str = reinterpret_cast<const char*>(data.data());
235 // If there is a \0 character in the middle of the |data|, treat it as end of
236 // the string. Well-formed rsid shouldn't contain it.
237 rsid->assign(str, strnlen(str, data.size()));
238 RTC_DCHECK(!rsid->empty());
239 return true;
240 }
241
242 // RepairedRtpStreamId.
243 constexpr RTPExtensionType RepairedRtpStreamId::kId;
244 constexpr uint8_t RepairedRtpStreamId::kValueSizeBytes;
245 constexpr const char* RepairedRtpStreamId::kUri;
246
247 // RtpStreamId and RepairedRtpStreamId use the same format to store rsid.
248 bool RepairedRtpStreamId::Parse(rtc::ArrayView<const uint8_t> data,
249 StreamId* rsid) {
250 return RtpStreamId::Parse(data, rsid);
251 }
252
253 bool RepairedRtpStreamId::Parse(rtc::ArrayView<const uint8_t> data,
254 std::string* rsid) {
255 return RtpStreamId::Parse(data, rsid);
256 }
257
218 } // namespace webrtc 258 } // namespace webrtc
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698