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

Unified Diff: webrtc/modules/rtp_rtcp/source/rtcp_packet/app.cc

Issue 1998633002: [rtcp] App::Parse updated not to use RTCPUtility, (Closed) Base URL: https://chromium.googlesource.com/external/webrtc.git@master
Patch Set: Created 4 years, 7 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/rtcp_packet/app.cc
diff --git a/webrtc/modules/rtp_rtcp/source/rtcp_packet/app.cc b/webrtc/modules/rtp_rtcp/source/rtcp_packet/app.cc
index a1ad8d6427992a06b12c727b8a135416d1d47622..58d7334d052e5916f74d7159fa77c023430ad46c 100644
--- a/webrtc/modules/rtp_rtcp/source/rtcp_packet/app.cc
+++ b/webrtc/modules/rtp_rtcp/source/rtcp_packet/app.cc
@@ -13,12 +13,12 @@
#include "webrtc/base/checks.h"
#include "webrtc/base/logging.h"
#include "webrtc/modules/rtp_rtcp/source/byte_io.h"
-
-using webrtc::RTCPUtility::RtcpCommonHeader;
+#include "webrtc/modules/rtp_rtcp/source/rtcp_packet/common_header.h"
namespace webrtc {
namespace rtcp {
-
+constexpr uint8_t App::kPacketType;
+constexpr size_t App::kMaxDataSize;
// Application-Defined packet (APP) (RFC 3550).
//
// 0 1 2 3
@@ -32,13 +32,17 @@ namespace rtcp {
// +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
// 8 | application-dependent data ...
// +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
-bool App::Parse(const RtcpCommonHeader& header, const uint8_t* payload) {
- RTC_DCHECK(header.packet_type == kPacketType);
-
- sub_type_ = header.count_or_format;
- ssrc_ = ByteReader<uint32_t>::ReadBigEndian(&payload[0]);
- name_ = ByteReader<uint32_t>::ReadBigEndian(&payload[4]);
- data_.SetData(&payload[8], header.payload_size_bytes - 8);
+bool App::Parse(const CommonHeader& packet) {
+ RTC_DCHECK_EQ(packet.type(), kPacketType);
+ if (packet.payload_size_bytes() < kAppBaseLength) {
åsapersson 2016/07/26 09:58:15 is payload_size_bytes multiple of 4 here or should
danilchap 2016/07/26 11:37:02 Good point. It is possible to create a packet wher
+ LOG(LS_WARNING) << "Packet is too small to be a valid APP packet";
+ return false;
+ }
+ sub_type_ = packet.fmt();
+ ssrc_ = ByteReader<uint32_t>::ReadBigEndian(&packet.payload()[0]);
+ name_ = ByteReader<uint32_t>::ReadBigEndian(&packet.payload()[4]);
+ data_.SetData(packet.payload() + kAppBaseLength,
+ packet.payload_size_bytes() - kAppBaseLength);
return true;
}
@@ -49,10 +53,10 @@ void App::WithSubType(uint8_t subtype) {
void App::WithData(const uint8_t* data, size_t data_length) {
RTC_DCHECK(data);
- RTC_DCHECK_EQ(0u, data_length % 4) << "Data must be 32 bits aligned.";
- RTC_DCHECK(data_length <= kMaxDataSize) << "App data size << " << data_length
- << "exceed maximum of "
- << kMaxDataSize << " bytes.";
+ RTC_DCHECK_EQ(data_length % 4, 0u) << "Data must be 32 bits aligned.";
+ RTC_DCHECK_LE(data_length, kMaxDataSize) << "App data size " << data_length
+ << " exceed maximum of "
+ << kMaxDataSize << " bytes.";
data_.SetData(data, data_length);
}

Powered by Google App Engine
This is Rietveld 408576698