Chromium Code Reviews| OLD | NEW |
|---|---|
| 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/pc/rtptransporttestutil.h" |
| 16 #include "webrtc/rtc_base/gunit.h" | 16 #include "webrtc/rtc_base/gunit.h" |
| 17 | 17 |
| 18 namespace webrtc { | 18 namespace webrtc { |
| 19 | 19 |
| 20 constexpr bool kMuxDisabled = false; | 20 constexpr bool kMuxDisabled = false; |
| 21 constexpr bool kMuxEnabled = true; | 21 constexpr bool kMuxEnabled = true; |
| 22 | 22 |
| 23 TEST(RtpTransportTest, SetRtcpParametersCantDisableRtcpMux) { | 23 TEST(RtpTransportTest, SetRtcpParametersCantDisableRtcpMux) { |
| 24 RtpTransport transport(kMuxDisabled); | 24 RtpTransport transport(kMuxDisabled); |
| 25 RtcpParameters params; | 25 RtpTransportParameters params; |
| 26 transport.SetRtcpParameters(params); | 26 transport.SetParameters(params); |
| 27 params.mux = false; | 27 params.rtcp.mux = false; |
| 28 EXPECT_FALSE(transport.SetRtcpParameters(params).ok()); | 28 EXPECT_FALSE(transport.SetParameters(params).ok()); |
| 29 } | 29 } |
| 30 | 30 |
| 31 TEST(RtpTransportTest, SetRtcpParametersEmptyCnameUsesExisting) { | 31 TEST(RtpTransportTest, SetRtcpParametersEmptyCnameUsesExisting) { |
| 32 static const char kName[] = "name"; | 32 static const char kName[] = "name"; |
| 33 RtpTransport transport(kMuxDisabled); | 33 RtpTransport transport(kMuxDisabled); |
| 34 RtcpParameters params_with_name; | 34 RtpTransportParameters params_with_name; |
| 35 params_with_name.cname = kName; | 35 params_with_name.rtcp.cname = kName; |
| 36 transport.SetRtcpParameters(params_with_name); | 36 transport.SetParameters(params_with_name); |
| 37 EXPECT_EQ(transport.GetRtcpParameters().cname, kName); | 37 EXPECT_EQ(transport.GetParameters().rtcp.cname, kName); |
| 38 | 38 |
| 39 RtcpParameters params_without_name; | 39 RtpTransportParameters params_without_name; |
| 40 transport.SetRtcpParameters(params_without_name); | 40 transport.SetParameters(params_without_name); |
| 41 EXPECT_EQ(transport.GetRtcpParameters().cname, kName); | 41 EXPECT_EQ(transport.GetParameters().rtcp.cname, kName); |
| 42 } | |
| 43 | |
| 44 TEST(RtpTransportTest, SetRtpTransportKeepAliveNotSupported) { | |
|
Taylor Brandstetter
2017/08/03 01:18:04
Can you add a comment explaining that this is a li
sprang_webrtc
2017/08/03 13:08:14
Done.
| |
| 45 RtpTransport transport(kMuxDisabled); | |
| 46 RtpTransportParameters params; | |
| 47 params.keepalive.timeout_interval_ms = 1; | |
| 48 auto result = transport.SetParameters(params); | |
| 49 EXPECT_FALSE(result.ok()); | |
| 50 EXPECT_EQ(RTCErrorType::INVALID_MODIFICATION, result.type()); | |
| 42 } | 51 } |
| 43 | 52 |
| 44 class SignalObserver : public sigslot::has_slots<> { | 53 class SignalObserver : public sigslot::has_slots<> { |
| 45 public: | 54 public: |
| 46 explicit SignalObserver(RtpTransport* transport) { | 55 explicit SignalObserver(RtpTransport* transport) { |
| 47 transport->SignalReadyToSend.connect(this, &SignalObserver::OnReadyToSend); | 56 transport->SignalReadyToSend.connect(this, &SignalObserver::OnReadyToSend); |
| 48 } | 57 } |
| 49 bool ready() const { return ready_; } | 58 bool ready() const { return ready_; } |
| 50 void OnReadyToSend(bool ready) { ready_ = ready; } | 59 void OnReadyToSend(bool ready) { ready_ = ready; } |
| 51 | 60 |
| (...skipping 153 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 205 | 214 |
| 206 const rtc::PacketOptions options; | 215 const rtc::PacketOptions options; |
| 207 const int flags = 0; | 216 const int flags = 0; |
| 208 rtc::Buffer rtp_data(kRtpData, kRtpLen); | 217 rtc::Buffer rtp_data(kRtpData, kRtpLen); |
| 209 fake_rtp.SendPacket(rtp_data.data<char>(), kRtpLen, options, flags); | 218 fake_rtp.SendPacket(rtp_data.data<char>(), kRtpLen, options, flags); |
| 210 EXPECT_EQ(0, observer.rtp_count()); | 219 EXPECT_EQ(0, observer.rtp_count()); |
| 211 EXPECT_EQ(0, observer.rtcp_count()); | 220 EXPECT_EQ(0, observer.rtcp_count()); |
| 212 } | 221 } |
| 213 | 222 |
| 214 } // namespace webrtc | 223 } // namespace webrtc |
| OLD | NEW |