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

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

Issue 2943693003: Create RtcpDemuxer (Closed)
Patch Set: Get rid of ArrayView in rtp_rtcp_demuxer_helper_unittest.cc, too. 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
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) {
danilchap 2017/06/19 13:31:56 CorrectOutput are probably redundant words. ParseR
eladalon 2017/06/19 14:35:17 I'll go with ParseRtcpPacketSenderSsrc_ByePacket,
32 webrtc::rtcp::Bye rtcp_packet;
33 rtcp_packet.SetSenderSsrc(kSsrc);
34 rtc::Buffer raw_packet = rtcp_packet.Build();
35
36 rtc::Optional<uint32_t> ssrc = ParseRtcpPacketSenderSsrc(raw_packet);
37 EXPECT_TRUE(ssrc);
danilchap 2017/06/19 13:31:56 if you'll keep it, use ASSERT_TRUE may be (to be a
eladalon 2017/06/19 14:35:17 I prefer without the .has_true(), as that's what's
danilchap 2017/06/19 16:24:54 .has_value was added only recently, that's one of
eladalon 2017/06/19 19:13:48 Acknowledged.
38 EXPECT_EQ(*ssrc, kSsrc);
danilchap 2017/06/19 13:31:56 you may replace these two EXPECTs with single one:
eladalon 2017/06/19 14:35:17 1. Still need to assert before. 2. I'm used to rel
danilchap 2017/06/19 16:24:54 1. No 2. std::optional<T> allowed to be compared t
eladalon 2017/06/19 19:13:48 I see now that it prints "empty optional" when com
39 }
40
41 TEST(RtpRtcpDemuxerHelperTest, ParseRtcpPacketSenderSsrc_CorrectOutputForPsfb) {
42 webrtc::rtcp::Pli rtcp_packet; // Psfb is abstract; use a subclass.
43 rtcp_packet.SetSenderSsrc(kSsrc);
44 rtc::Buffer raw_packet = rtcp_packet.Build();
45
46 rtc::Optional<uint32_t> ssrc = ParseRtcpPacketSenderSsrc(raw_packet);
47 EXPECT_TRUE(ssrc);
48 EXPECT_EQ(*ssrc, kSsrc);
49 }
50
51 TEST(RtpRtcpDemuxerHelperTest,
52 ParseRtcpPacketSenderSsrc_CorrectOutputForReceiverReport) {
53 webrtc::rtcp::ReceiverReport rtcp_packet;
54 rtcp_packet.SetSenderSsrc(kSsrc);
55 rtc::Buffer raw_packet = rtcp_packet.Build();
56
57 rtc::Optional<uint32_t> ssrc = ParseRtcpPacketSenderSsrc(raw_packet);
58 EXPECT_TRUE(ssrc);
59 EXPECT_EQ(*ssrc, kSsrc);
60 }
61
62 TEST(RtpRtcpDemuxerHelperTest,
63 ParseRtcpPacketSenderSsrc_CorrectOutputForRtpfb) {
64 // Rtpfb is abstract; use a subclass.
65 webrtc::rtcp::RapidResyncRequest rtcp_packet;
66 rtcp_packet.SetSenderSsrc(kSsrc);
67 rtc::Buffer raw_packet = rtcp_packet.Build();
68
69 rtc::Optional<uint32_t> ssrc = ParseRtcpPacketSenderSsrc(raw_packet);
70 EXPECT_TRUE(ssrc);
71 EXPECT_EQ(*ssrc, kSsrc);
72 }
73
74 TEST(RtpRtcpDemuxerHelperTest,
75 ParseRtcpPacketSenderSsrc_CorrectOutputForSenderReport) {
76 webrtc::rtcp::SenderReport rtcp_packet;
77 rtcp_packet.SetSenderSsrc(kSsrc);
78 rtc::Buffer raw_packet = rtcp_packet.Build();
79
80 rtc::Optional<uint32_t> ssrc = ParseRtcpPacketSenderSsrc(raw_packet);
81 EXPECT_TRUE(ssrc);
82 EXPECT_EQ(*ssrc, kSsrc);
83 }
84
85 TEST(RtpRtcpDemuxerHelperTest, ParseRtcpPacketSenderSsrc_BadRtcpPacket) {
86 uint8_t garbage[100];
87 memset(&garbage[0], 0, arraysize(garbage));
88
89 rtc::Optional<uint32_t> ssrc = ParseRtcpPacketSenderSsrc(garbage);
90 EXPECT_FALSE(ssrc);
91 }
92
93 TEST(RtpRtcpDemuxerHelperTest,
94 ParseRtcpPacketSenderSsrc_RtcpMessageWithoutSenderSsrc) {
95 webrtc::rtcp::ExtendedJitterReport rtcp_packet; // Has no sender SSRC.
96 rtc::Buffer raw_packet = rtcp_packet.Build();
97
98 rtc::Optional<uint32_t> ssrc = ParseRtcpPacketSenderSsrc(raw_packet);
99 EXPECT_FALSE(ssrc);
100 }
101
102 } // namespace webrtc
OLDNEW
« webrtc/call/rtp_rtcp_demuxer_helper.cc ('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