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

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

Issue 1175263002: Add packetization and coding/decoding of feedback message format. (Closed) Base URL: https://chromium.googlesource.com/external/webrtc.git@master
Patch Set: Updated parsing to match new spec Created 5 years, 5 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/byte_io.h
diff --git a/webrtc/modules/rtp_rtcp/source/byte_io.h b/webrtc/modules/rtp_rtcp/source/byte_io.h
index 2617806dd941205c813a0b0c535f949429a6c97e..c0d519ba4a658749fb5510aca63113c137b92bb7 100644
--- a/webrtc/modules/rtp_rtcp/source/byte_io.h
+++ b/webrtc/modules/rtp_rtcp/source/byte_io.h
@@ -50,6 +50,7 @@ template<typename T, unsigned int B = sizeof(T),
class ByteReader {
public:
static T ReadBigEndian(const uint8_t* data) {
+ static_assert(B <= sizeof(T), "Target size too large");
if (is_signed && B < sizeof(T)) {
return SignExtend(InternalReadBigEndian(data));
}
@@ -57,6 +58,7 @@ class ByteReader {
}
static T ReadLittleEndian(const uint8_t* data) {
+ static_assert(B <= sizeof(T), "Target size too large");
if (is_signed && B < sizeof(T)) {
return SignExtend(InternalReadLittleEndian(data));
}
@@ -106,12 +108,14 @@ template<typename T, unsigned int B = sizeof(T)>
class ByteWriter {
public:
static void WriteBigEndian(uint8_t* data, T val) {
+ static_assert(B <= sizeof(T), "Target size too large");
for (unsigned int i = 0; i < B; ++i) {
data[i] = val >> ((B - 1 - i) * 8);
}
}
static void WriteLittleEndian(uint8_t* data, T val) {
+ static_assert(B <= sizeof(T), "Target size too large");
for (unsigned int i = 0; i < B; ++i) {
data[i] = val >> (i * 8);
}

Powered by Google App Engine
This is Rietveld 408576698