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

Unified 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 side-by-side diff with in-line comments
Download patch
Index: webrtc/modules/rtp_rtcp/source/rtp_header_extensions.cc
diff --git a/webrtc/modules/rtp_rtcp/source/rtp_header_extensions.cc b/webrtc/modules/rtp_rtcp/source/rtp_header_extensions.cc
index 1b311e64190cd80eb146ddba3628ac67a503d30d..aebe80253da232043a026a476bcae2fbe6595d86 100644
--- a/webrtc/modules/rtp_rtcp/source/rtp_header_extensions.cc
+++ b/webrtc/modules/rtp_rtcp/source/rtp_header_extensions.cc
@@ -215,4 +215,44 @@ bool PlayoutDelayLimits::Write(uint8_t* data,
return true;
}
+// RtpStreamId.
+constexpr RTPExtensionType RtpStreamId::kId;
+constexpr uint8_t RtpStreamId::kValueSizeBytes;
+constexpr const char* RtpStreamId::kUri;
+
+bool RtpStreamId::Parse(rtc::ArrayView<const uint8_t> data, StreamId* rsid) {
+ if (data.empty() || data[0] == 0) // Valid rsid can't be empty.
+ return false;
+ rsid->Set(data);
+ RTC_DCHECK(!rsid->empty());
+ return true;
+}
+
+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.
+ if (data.empty() || data[0] == 0) // Valid rsid can't be empty.
+ return false;
+ const char* str = reinterpret_cast<const char*>(data.data());
+ // If there is a \0 character in the middle of the |data|, treat it as end of
+ // the string. Well-formed rsid shouldn't contain it.
+ rsid->assign(str, strnlen(str, data.size()));
+ RTC_DCHECK(!rsid->empty());
+ return true;
+}
+
+// RepairedRtpStreamId.
+constexpr RTPExtensionType RepairedRtpStreamId::kId;
+constexpr uint8_t RepairedRtpStreamId::kValueSizeBytes;
+constexpr const char* RepairedRtpStreamId::kUri;
+
+// RtpStreamId and RepairedRtpStreamId use the same format to store rsid.
+bool RepairedRtpStreamId::Parse(rtc::ArrayView<const uint8_t> data,
+ StreamId* rsid) {
+ return RtpStreamId::Parse(data, rsid);
+}
+
+bool RepairedRtpStreamId::Parse(rtc::ArrayView<const uint8_t> data,
+ std::string* rsid) {
+ return RtpStreamId::Parse(data, rsid);
+}
+
} // namespace webrtc

Powered by Google App Engine
This is Rietveld 408576698