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

Side by Side 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 unified diff | Download patch
OLDNEW
(Empty)
1 /*
2 * Copyright (c) 2016 The WebRTC project authors. All Rights Reserved.
3 *
4 * Use of this source code is governed by a BSD-style license
5 * that can be found in the LICENSE file in the root of the source
6 * tree. An additional intellectual property rights grant can be found
7 * in the file PATENTS. All contributing project authors may
8 * be found in the AUTHORS file in the root of the source tree.
9 *
10 */
11
12 #ifndef WEBRTC_MODULES_RTP_RTCP_SOURCE_SAMPLE_RTCP_PARSER2_H_
13 #define WEBRTC_MODULES_RTP_RTCP_SOURCE_SAMPLE_RTCP_PARSER2_H_
14
15 #include "webrtc/modules/rtp_rtcp/source/rtcp_packet/app.h"
16 #include "webrtc/modules/rtp_rtcp/source/rtcp_packet/bye.h"
17 #include "webrtc/modules/rtp_rtcp/source/rtcp_packet/parsing_container.h"
18 #include "webrtc/modules/rtp_rtcp/source/rtcp_packet/pli.h"
19
20 namespace webrtc {
21 namespace rtcp {
22 /* Parser that rely on ParsingContainer that wraps CommonHeader in it. */
23
24 class Parser2 {
25 public:
26 void Parse(const uint8_t* buffer, size_t length) {
27 for (const auto& header : ParsingContainer(buffer, length)) {
28 ParseIndividual(header);
29 }
30 }
31
32 protected:
33 virtual ~Parser2() {}
34 virtual void HandleApp(const App&) {}
35 virtual void HandleBye(const Bye&) {}
36 virtual void HandlePli(const Pli&) {}
37 virtual void HandleUnknown(const CommonHeader&) {}
38 virtual void HandleInvalid() {}
39
40 private:
41 inline void HandleParsed(const App& app) { HandleApp(app); }
42 inline void HandleParsed(const Bye& bye) { HandleBye(bye); }
43 inline void HandleParsed(const Pli& pli) { HandlePli(pli); }
44
45 template <typename TypedPacket>
46 void HandleUnparsed(const CommonHeader& packet) {
47 TypedPacket parsed;
48 if (!parsed.Parse(packet))
49 HandleInvalid();
50 else
51 HandleParsed(parsed);
52 }
53
54 void ParseIndividual(const CommonHeader& header) {
55 switch (header.type()) {
56 case App::kPacketType:
57 HandleUnparsed<App>(header);
58 break;
59 case Bye::kPacketType:
60 HandleUnparsed<Bye>(header);
61 break;
62 case Psfb::kPacketType:
63 switch (header.fmt()) {
64 case Pli::kFeedbackMessageType:
65 HandleUnparsed<Pli>(header);
66 break;
67 default:
68 HandleUnknown(header);
69 break;
70 }
71 break;
72 default:
73 HandleUnknown(header);
74 break;
75 }
76 }
77 };
78 } // namespace rtcp
79 } // namespace webrtc
80 #endif // WEBRTC_MODULES_RTP_RTCP_SOURCE_SAMPLE_RTCP_PARSER2_H_
OLDNEW
« 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