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

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

Issue 1555683002: [Draft] RTCP Parser sketched. (Closed) Base URL: https://chromium.googlesource.com/external/webrtc.git@master
Patch Set: fix RtcpParser* tests Created 4 years, 4 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/sample_rtcp_parser2.h
diff --git a/webrtc/modules/rtp_rtcp/source/sample_rtcp_parser2.h b/webrtc/modules/rtp_rtcp/source/sample_rtcp_parser2.h
new file mode 100644
index 0000000000000000000000000000000000000000..d26fa9e6ab2b4fa96440e714c78a820248b1bc6d
--- /dev/null
+++ b/webrtc/modules/rtp_rtcp/source/sample_rtcp_parser2.h
@@ -0,0 +1,80 @@
+/*
+ * Copyright (c) 2016 The WebRTC project authors. All Rights Reserved.
+ *
+ * Use of this source code is governed by a BSD-style license
+ * that can be found in the LICENSE file in the root of the source
+ * tree. An additional intellectual property rights grant can be found
+ * in the file PATENTS. All contributing project authors may
+ * be found in the AUTHORS file in the root of the source tree.
+ *
+ */
+
+#ifndef WEBRTC_MODULES_RTP_RTCP_SOURCE_SAMPLE_RTCP_PARSER2_H_
+#define WEBRTC_MODULES_RTP_RTCP_SOURCE_SAMPLE_RTCP_PARSER2_H_
+
+#include "webrtc/modules/rtp_rtcp/source/rtcp_packet/app.h"
+#include "webrtc/modules/rtp_rtcp/source/rtcp_packet/bye.h"
+#include "webrtc/modules/rtp_rtcp/source/rtcp_packet/parsing_container.h"
+#include "webrtc/modules/rtp_rtcp/source/rtcp_packet/pli.h"
+
+namespace webrtc {
+namespace rtcp {
+/* Parser that rely on ParsingContainer that wraps CommonHeader in it. */
+
+class Parser2 {
+ public:
+ void Parse(const uint8_t* buffer, size_t length) {
+ for (const auto& header : ParsingContainer(buffer, length)) {
+ ParseIndividual(header);
+ }
+ }
+
+ protected:
+ virtual ~Parser2() {}
+ virtual void HandleApp(const App&) {}
+ virtual void HandleBye(const Bye&) {}
+ virtual void HandlePli(const Pli&) {}
+ virtual void HandleUnknown(const CommonHeader&) {}
+ virtual void HandleInvalid() {}
+
+ private:
+ inline void HandleParsed(const App& app) { HandleApp(app); }
+ inline void HandleParsed(const Bye& bye) { HandleBye(bye); }
+ inline void HandleParsed(const Pli& pli) { HandlePli(pli); }
+
+ template <typename TypedPacket>
+ void HandleUnparsed(const CommonHeader& packet) {
+ TypedPacket parsed;
+ if (!parsed.Parse(packet))
+ HandleInvalid();
+ else
+ HandleParsed(parsed);
+ }
+
+ void ParseIndividual(const CommonHeader& header) {
+ switch (header.type()) {
+ case App::kPacketType:
+ HandleUnparsed<App>(header);
+ break;
+ case Bye::kPacketType:
+ HandleUnparsed<Bye>(header);
+ break;
+ case Psfb::kPacketType:
+ switch (header.fmt()) {
+ case Pli::kFeedbackMessageType:
+ HandleUnparsed<Pli>(header);
+ break;
+ default:
+ HandleUnknown(header);
+ break;
+ }
+ break;
+ default:
+ HandleUnknown(header);
+ break;
+ }
+ }
+};
+} // namespace rtcp
+} // namespace webrtc
+#endif // WEBRTC_MODULES_RTP_RTCP_SOURCE_SAMPLE_RTCP_PARSER2_H_
« no previous file with comments | « webrtc/modules/rtp_rtcp/source/sample_rtcp_parser1.h ('k') | webrtc/modules/rtp_rtcp/source/sample_rtcp_parser4.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698