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

Side by Side Diff: webrtc/call/rtp_rtcp_demuxer_helper_unittest.cc

Issue 2943693003: Create RtcpDemuxer (Closed)
Patch Set: CR response and some cleanup. Created 3 years, 6 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
« webrtc/call/BUILD.gn ('K') | « webrtc/call/rtp_rtcp_demuxer_helper.cc ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
(Empty)
1 /*
2 * Copyright (c) 2017 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 #include <cstdio>
12
13 #include "webrtc/call/rtp_rtcp_demuxer_helper.h"
14
15 #include "webrtc/base/arraysize.h"
16 #include "webrtc/base/buffer.h"
17 #include "webrtc/modules/rtp_rtcp/source/rtcp_packet/bye.h"
18 #include "webrtc/modules/rtp_rtcp/source/rtcp_packet/extended_jitter_report.h"
19 #include "webrtc/modules/rtp_rtcp/source/rtcp_packet/pli.h"
20 #include "webrtc/modules/rtp_rtcp/source/rtcp_packet/rapid_resync_request.h"
21 #include "webrtc/modules/rtp_rtcp/source/rtcp_packet/receiver_report.h"
22 #include "webrtc/modules/rtp_rtcp/source/rtcp_packet/sender_report.h"
23 #include "webrtc/test/gtest.h"
24
25 namespace webrtc {
26
27 namespace {
28 constexpr uint32_t kSsrc = 8374;
29 } // namespace
30
31 TEST(RtpRtcpDemuxerHelperTest, ParseRtcpPacketSenderSsrc_CorrectOutputForBye) {
32 webrtc::rtcp::Bye rtcp_packet;
33 rtcp_packet.SetSenderSsrc(kSsrc);
34
35 rtc::Buffer buffer = rtcp_packet.Build();
36 rtc::ArrayView<const uint8_t> array =
37 rtc::ArrayView<const uint8_t>(buffer.data(), buffer.size());
38
39 rtc::Optional<uint32_t> ssrc = ParseRtcpPacketSenderSsrc(array);
40 EXPECT_TRUE(ssrc);
41 EXPECT_EQ(*ssrc, kSsrc);
42 }
43
44 TEST(RtpRtcpDemuxerHelperTest, ParseRtcpPacketSenderSsrc_CorrectOutputForPsfb) {
45 webrtc::rtcp::Pli rtcp_packet; // Psfb is abstract; use a subclass.
46 rtcp_packet.SetSenderSsrc(kSsrc);
47
48 rtc::Buffer buffer = rtcp_packet.Build();
49 rtc::ArrayView<const uint8_t> array =
50 rtc::ArrayView<const uint8_t>(buffer.data(), buffer.size());
51
52 rtc::Optional<uint32_t> ssrc = ParseRtcpPacketSenderSsrc(array);
53 EXPECT_TRUE(ssrc);
54 EXPECT_EQ(*ssrc, kSsrc);
55 }
56
57 TEST(RtpRtcpDemuxerHelperTest,
58 ParseRtcpPacketSenderSsrc_CorrectOutputForReceiverReport) {
59 webrtc::rtcp::ReceiverReport rtcp_packet;
60 rtcp_packet.SetSenderSsrc(kSsrc);
61
62 rtc::Buffer buffer = rtcp_packet.Build();
63 rtc::ArrayView<const uint8_t> array =
64 rtc::ArrayView<const uint8_t>(buffer.data(), buffer.size());
65
66 rtc::Optional<uint32_t> ssrc = ParseRtcpPacketSenderSsrc(array);
67 EXPECT_TRUE(ssrc);
68 EXPECT_EQ(*ssrc, kSsrc);
69 }
70
71 TEST(RtpRtcpDemuxerHelperTest,
72 ParseRtcpPacketSenderSsrc_CorrectOutputForRtpfb) {
73 // Rtpfb is abstract; use a subclass.
74 webrtc::rtcp::RapidResyncRequest rtcp_packet;
75 rtcp_packet.SetSenderSsrc(kSsrc);
76
77 rtc::Buffer buffer = rtcp_packet.Build();
78 rtc::ArrayView<const uint8_t> array =
79 rtc::ArrayView<const uint8_t>(buffer.data(), buffer.size());
80
81 rtc::Optional<uint32_t> ssrc = ParseRtcpPacketSenderSsrc(array);
82 EXPECT_TRUE(ssrc);
83 EXPECT_EQ(*ssrc, kSsrc);
84 }
85
86 TEST(RtpRtcpDemuxerHelperTest,
87 ParseRtcpPacketSenderSsrc_CorrectOutputForSenderReport) {
88 webrtc::rtcp::SenderReport rtcp_packet;
89 rtcp_packet.SetSenderSsrc(kSsrc);
90
91 rtc::Buffer buffer = rtcp_packet.Build();
92 rtc::ArrayView<const uint8_t> array =
93 rtc::ArrayView<const uint8_t>(buffer.data(), buffer.size());
94
95 rtc::Optional<uint32_t> ssrc = ParseRtcpPacketSenderSsrc(array);
96 EXPECT_TRUE(ssrc);
97 EXPECT_EQ(*ssrc, kSsrc);
98 }
99
100 TEST(RtpRtcpDemuxerHelperTest, ParseRtcpPacketSenderSsrc_BadRtcpPacket) {
101 uint8_t garbage[100];
102 memset(&garbage[0], 0, arraysize(garbage));
103
104 rtc::Optional<uint32_t> ssrc = ParseRtcpPacketSenderSsrc(garbage);
105 EXPECT_FALSE(ssrc);
106 }
107
108 TEST(RtpRtcpDemuxerHelperTest,
109 ParseRtcpPacketSenderSsrc_RtcpMessageWithoutSenderSsrc) {
110 webrtc::rtcp::ExtendedJitterReport rtcp_packet; // Has no sender SSRC.
111
112 rtc::Buffer buffer = rtcp_packet.Build();
113 rtc::ArrayView<const uint8_t> array =
114 rtc::ArrayView<const uint8_t>(buffer.data(), buffer.size());
115
116 rtc::Optional<uint32_t> ssrc = ParseRtcpPacketSenderSsrc(array);
117 EXPECT_FALSE(ssrc);
118 }
119
120 } // namespace webrtc
OLDNEW
« webrtc/call/BUILD.gn ('K') | « webrtc/call/rtp_rtcp_demuxer_helper.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698