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

Unified Diff: webrtc/test/rtcp_packet_parser.h

Issue 1810913002: [test][rtcp] Added function for parsing single rtcp packet in tests. (Closed) Base URL: https://chromium.googlesource.com/external/webrtc.git@master
Patch Set: Created 4 years, 9 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
« no previous file with comments | « no previous file | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: webrtc/test/rtcp_packet_parser.h
diff --git a/webrtc/test/rtcp_packet_parser.h b/webrtc/test/rtcp_packet_parser.h
index cc890b4f2ffed6504804f1a4bd1d61b9dc81abd3..562b4ed511cdf548d9a6efacdad501c3c43b7420 100644
--- a/webrtc/test/rtcp_packet_parser.h
+++ b/webrtc/test/rtcp_packet_parser.h
@@ -16,11 +16,32 @@
#include <string>
#include <vector>
+#include "webrtc/base/buffer.h"
+#include "webrtc/base/checks.h"
+#include "webrtc/modules/rtp_rtcp/source/rtcp_packet/common_header.h"
#include "webrtc/modules/rtp_rtcp/source/rtcp_utility.h"
#include "webrtc/typedefs.h"
namespace webrtc {
namespace test {
+// Parse RTCP packet of given type. Assumes RTCP header is valid and that there
+// is excatly one packet of correct type in the buffer.
+template <typename Packet>
+bool ParseSinglePacket(const uint8_t* buffer, size_t size, Packet* packet) {
+ rtcp::CommonHeader header;
+ RTC_CHECK(header.Parse(buffer, size));
+ RTC_CHECK_EQ(static_cast<ptrdiff_t>(size), header.NextPacket() - buffer);
+ return packet->Parse(header);
+}
+// Same function, but takes raw buffer as single argument instead of pair.
+template <size_t N, typename Packet>
+bool ParseSinglePacket(const uint8_t(&buffer)[N], Packet* packet) {
+ return ParseSinglePacket(buffer, N, packet);
+}
+template <typename Packet>
+bool ParseSinglePacket(const rtc::Buffer& buffer, Packet* packet) {
+ return ParseSinglePacket(buffer.data(), buffer.size(), packet);
+}
class RtcpPacketParser;
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698