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

Unified Diff: webrtc/modules/rtp_rtcp/source/rtp_packet.h

Issue 2801733002: Move rtp header extension length check from Packet::FindExtension to ExtensionT::Parse (Closed)
Patch Set: 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_packet.h
diff --git a/webrtc/modules/rtp_rtcp/source/rtp_packet.h b/webrtc/modules/rtp_rtcp/source/rtp_packet.h
index 072456dd5b550dee04216c6f9157c7c02afbbdd8..ca189dbe0d23bbe0c8f9da3dacf7649425aed235 100644
--- a/webrtc/modules/rtp_rtcp/source/rtp_packet.h
+++ b/webrtc/modules/rtp_rtcp/source/rtp_packet.h
@@ -142,13 +142,9 @@ class Packet {
// but does not touch packet own buffer, leaving packet in invalid state.
bool ParseBuffer(const uint8_t* buffer, size_t size);
- // Find an extension based on the type field of the parameter.
- // If found, length field would be validated, the offset field will be set
- // and true returned,
- // otherwise the parameter will be unchanged and false is returned.
- bool FindExtension(ExtensionType type,
- uint8_t length,
- uint16_t* offset) const;
+ // Find an extension |type|.
+ // Returns view of the raw extension or empty view on failure.
+ rtc::ArrayView<const uint8_t> FindExtension(ExtensionType type) const;
// Find or allocate an extension |type|. Returns view of size |length|
// to write raw extension to or an empty view on failure.
@@ -174,16 +170,15 @@ class Packet {
template <typename Extension>
bool Packet::HasExtension() const {
- uint16_t offset = 0;
- return FindExtension(Extension::kId, Extension::kValueSizeBytes, &offset);
+ return !FindExtension(Extension::kId).empty();
}
template <typename Extension, typename... Values>
bool Packet::GetExtension(Values... values) const {
- uint16_t offset = 0;
- if (!FindExtension(Extension::kId, Extension::kValueSizeBytes, &offset))
+ auto raw = FindExtension(Extension::kId);
+ if (raw.empty())
return false;
- return Extension::Parse(data() + offset, values...);
+ return Extension::Parse(raw, values...);
}
template <typename Extension, typename... Values>
« no previous file with comments | « webrtc/modules/rtp_rtcp/source/rtp_header_extensions.cc ('k') | webrtc/modules/rtp_rtcp/source/rtp_packet.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698