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

Side by Side Diff: webrtc/pc/rtptransport_unittest.cc

Issue 2981013002: Introduce RtpTransportInternal and SrtpTransport. (Closed)
Patch Set: Created 3 years, 5 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
1 /* 1 /*
2 * Copyright 2017 The WebRTC project authors. All Rights Reserved. 2 * Copyright 2017 The WebRTC project authors. All Rights Reserved.
3 * 3 *
4 * Use of this source code is governed by a BSD-style license 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 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 6 * tree. An additional intellectual property rights grant can be found
7 * in the file PATENTS. All contributing project authors may 7 * in the file PATENTS. All contributing project authors may
8 * be found in the AUTHORS file in the root of the source tree. 8 * be found in the AUTHORS file in the root of the source tree.
9 */ 9 */
10 10
11 #include <string> 11 #include <string>
12 12
13 #include "webrtc/p2p/base/fakepackettransport.h" 13 #include "webrtc/p2p/base/fakepackettransport.h"
14 #include "webrtc/pc/rtptransport.h" 14 #include "webrtc/pc/rtptransport.h"
15 #include "webrtc/pc/rtptransporttestutil.h"
15 #include "webrtc/rtc_base/gunit.h" 16 #include "webrtc/rtc_base/gunit.h"
16 17
17 namespace webrtc { 18 namespace webrtc {
18 19
19 constexpr bool kMuxDisabled = false; 20 constexpr bool kMuxDisabled = false;
20 constexpr bool kMuxEnabled = true; 21 constexpr bool kMuxEnabled = true;
21 22
22 TEST(RtpTransportTest, SetRtcpParametersCantDisableRtcpMux) { 23 TEST(RtpTransportTest, SetRtcpParametersCantDisableRtcpMux) {
23 RtpTransport transport(kMuxDisabled); 24 RtpTransport transport(kMuxDisabled);
24 RtcpParameters params; 25 RtcpParameters params;
(...skipping 119 matching lines...) Expand 10 before | Expand all | Expand 10 after
144 145
145 // State does not change, so we should not signal. 146 // State does not change, so we should not signal.
146 transport.SetRtcpMuxEnabled(true); 147 transport.SetRtcpMuxEnabled(true);
147 EXPECT_EQ(observer.count(), 1); 148 EXPECT_EQ(observer.count(), 1);
148 149
149 // State changes, so we should signal. 150 // State changes, so we should signal.
150 transport.SetRtcpMuxEnabled(false); 151 transport.SetRtcpMuxEnabled(false);
151 EXPECT_EQ(observer.count(), 2); 152 EXPECT_EQ(observer.count(), 2);
152 } 153 }
153 154
154 class SignalPacketReceivedCounter : public sigslot::has_slots<> {
155 public:
156 explicit SignalPacketReceivedCounter(RtpTransport* transport) {
157 transport->SignalPacketReceived.connect(
158 this, &SignalPacketReceivedCounter::OnPacketReceived);
159 }
160 int rtcp_count() const { return rtcp_count_; }
161 int rtp_count() const { return rtp_count_; }
162
163 private:
164 void OnPacketReceived(bool rtcp,
165 rtc::CopyOnWriteBuffer*,
166 const rtc::PacketTime&) {
167 if (rtcp) {
168 ++rtcp_count_;
169 } else {
170 ++rtp_count_;
171 }
172 }
173 int rtcp_count_ = 0;
174 int rtp_count_ = 0;
175 };
176
177 // Test that SignalPacketReceived fires with rtcp=true when a RTCP packet is 155 // Test that SignalPacketReceived fires with rtcp=true when a RTCP packet is
178 // received. 156 // received.
179 TEST(RtpTransportTest, SignalDemuxedRtcp) { 157 TEST(RtpTransportTest, SignalDemuxedRtcp) {
180 RtpTransport transport(kMuxDisabled); 158 RtpTransport transport(kMuxDisabled);
181 SignalPacketReceivedCounter observer(&transport); 159 SignalPacketReceivedCounter observer(&transport);
182 rtc::FakePacketTransport fake_rtp("fake_rtp"); 160 rtc::FakePacketTransport fake_rtp("fake_rtp");
183 fake_rtp.SetDestination(&fake_rtp, true); 161 fake_rtp.SetDestination(&fake_rtp, true);
184 transport.SetRtpPacketTransport(&fake_rtp); 162 transport.SetRtpPacketTransport(&fake_rtp);
185 163
186 // An rtcp packet. 164 // An rtcp packet.
(...skipping 40 matching lines...) Expand 10 before | Expand all | Expand 10 after
227 205
228 const rtc::PacketOptions options; 206 const rtc::PacketOptions options;
229 const int flags = 0; 207 const int flags = 0;
230 rtc::Buffer rtp_data(kRtpData, kRtpLen); 208 rtc::Buffer rtp_data(kRtpData, kRtpLen);
231 fake_rtp.SendPacket(rtp_data.data<char>(), kRtpLen, options, flags); 209 fake_rtp.SendPacket(rtp_data.data<char>(), kRtpLen, options, flags);
232 EXPECT_EQ(0, observer.rtp_count()); 210 EXPECT_EQ(0, observer.rtp_count());
233 EXPECT_EQ(0, observer.rtcp_count()); 211 EXPECT_EQ(0, observer.rtcp_count());
234 } 212 }
235 213
236 } // namespace webrtc 214 } // namespace webrtc
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698