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

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

Issue 2943693003: Create RtcpDemuxer (Closed)
Patch Set: . 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/extended_reports.h"
20 #include "webrtc/modules/rtp_rtcp/source/rtcp_packet/pli.h"
21 #include "webrtc/modules/rtp_rtcp/source/rtcp_packet/rapid_resync_request.h"
22 #include "webrtc/modules/rtp_rtcp/source/rtcp_packet/receiver_report.h"
23 #include "webrtc/modules/rtp_rtcp/source/rtcp_packet/sender_report.h"
24 #include "webrtc/test/gtest.h"
25
26 namespace webrtc {
27
28 namespace {
29 constexpr uint32_t kSsrc = 8374;
30 } // namespace
31
32 TEST(RtpRtcpDemuxerHelperTest, ParseRtcpPacketSenderSsrc_ByePacket) {
33 webrtc::rtcp::Bye rtcp_packet;
34 rtcp_packet.SetSenderSsrc(kSsrc);
35 rtc::Buffer raw_packet = rtcp_packet.Build();
36
37 rtc::Optional<uint32_t> ssrc = ParseRtcpPacketSenderSsrc(raw_packet);
38 EXPECT_EQ(ssrc, kSsrc);
39 }
40
41 TEST(RtpRtcpDemuxerHelperTest,
42 ParseRtcpPacketSenderSsrc_ExtendedReportsPacket) {
43 webrtc::rtcp::ExtendedReports rtcp_packet;
44 rtcp_packet.SetSenderSsrc(kSsrc);
45 rtc::Buffer raw_packet = rtcp_packet.Build();
46
47 rtc::Optional<uint32_t> ssrc = ParseRtcpPacketSenderSsrc(raw_packet);
48 EXPECT_EQ(ssrc, kSsrc);
49 }
50
51 TEST(RtpRtcpDemuxerHelperTest, ParseRtcpPacketSenderSsrc_PsfbPacket) {
52 webrtc::rtcp::Pli rtcp_packet; // Psfb is abstract; use a subclass.
53 rtcp_packet.SetSenderSsrc(kSsrc);
54 rtc::Buffer raw_packet = rtcp_packet.Build();
55
56 rtc::Optional<uint32_t> ssrc = ParseRtcpPacketSenderSsrc(raw_packet);
57 EXPECT_EQ(ssrc, kSsrc);
58 }
59
60 TEST(RtpRtcpDemuxerHelperTest, ParseRtcpPacketSenderSsrc_ReceiverReportPacket) {
61 webrtc::rtcp::ReceiverReport rtcp_packet;
62 rtcp_packet.SetSenderSsrc(kSsrc);
63 rtc::Buffer raw_packet = rtcp_packet.Build();
64
65 rtc::Optional<uint32_t> ssrc = ParseRtcpPacketSenderSsrc(raw_packet);
66 EXPECT_EQ(ssrc, kSsrc);
67 }
68
69 TEST(RtpRtcpDemuxerHelperTest, ParseRtcpPacketSenderSsrc_RtpfbPacket) {
70 // Rtpfb is abstract; use a subclass.
71 webrtc::rtcp::RapidResyncRequest rtcp_packet;
72 rtcp_packet.SetSenderSsrc(kSsrc);
73 rtc::Buffer raw_packet = rtcp_packet.Build();
74
75 rtc::Optional<uint32_t> ssrc = ParseRtcpPacketSenderSsrc(raw_packet);
76 EXPECT_EQ(ssrc, kSsrc);
77 }
78
79 TEST(RtpRtcpDemuxerHelperTest, ParseRtcpPacketSenderSsrc_SenderReportPacket) {
80 webrtc::rtcp::SenderReport rtcp_packet;
81 rtcp_packet.SetSenderSsrc(kSsrc);
82 rtc::Buffer raw_packet = rtcp_packet.Build();
83
84 rtc::Optional<uint32_t> ssrc = ParseRtcpPacketSenderSsrc(raw_packet);
85 EXPECT_EQ(ssrc, kSsrc);
86 }
87
88 TEST(RtpRtcpDemuxerHelperTest, ParseRtcpPacketSenderSsrc_BadRtcpPacket) {
89 uint8_t garbage[100];
90 memset(&garbage[0], 0, arraysize(garbage));
91
92 rtc::Optional<uint32_t> ssrc = ParseRtcpPacketSenderSsrc(garbage);
93 EXPECT_FALSE(ssrc);
94 }
95
96 TEST(RtpRtcpDemuxerHelperTest,
97 ParseRtcpPacketSenderSsrc_RtcpMessageWithoutSenderSsrc) {
98 webrtc::rtcp::ExtendedJitterReport rtcp_packet; // Has no sender SSRC.
99 rtc::Buffer raw_packet = rtcp_packet.Build();
100
101 rtc::Optional<uint32_t> ssrc = ParseRtcpPacketSenderSsrc(raw_packet);
102 EXPECT_FALSE(ssrc);
103 }
104
105 } // namespace webrtc
OLDNEW
« webrtc/call/rtp_rtcp_demuxer_helper.h ('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