OLD | NEW |
1 /* | 1 /* |
2 * Copyright 2009 The WebRTC project authors. All Rights Reserved. | 2 * Copyright 2009 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 |
(...skipping 80 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
91 template<class T> | 91 template<class T> |
92 class ChannelTest : public testing::Test, public sigslot::has_slots<> { | 92 class ChannelTest : public testing::Test, public sigslot::has_slots<> { |
93 public: | 93 public: |
94 enum Flags { | 94 enum Flags { |
95 RTCP_MUX = 0x1, | 95 RTCP_MUX = 0x1, |
96 RTCP_MUX_REQUIRED = 0x2, | 96 RTCP_MUX_REQUIRED = 0x2, |
97 SECURE = 0x4, | 97 SECURE = 0x4, |
98 SSRC_MUX = 0x8, | 98 SSRC_MUX = 0x8, |
99 DTLS = 0x10, | 99 DTLS = 0x10, |
100 GCM_CIPHER = 0x20, | 100 GCM_CIPHER = 0x20, |
101 // Use BaseChannel with PacketTransportInterface rather than | 101 // Use BaseChannel with PacketTransportInternal rather than |
102 // DtlsTransportInternal. | 102 // DtlsTransportInternal. |
103 RAW_PACKET_TRANSPORT = 0x40, | 103 RAW_PACKET_TRANSPORT = 0x40, |
104 }; | 104 }; |
105 | 105 |
106 ChannelTest(bool verify_playout, | 106 ChannelTest(bool verify_playout, |
107 rtc::ArrayView<const uint8_t> rtp_data, | 107 rtc::ArrayView<const uint8_t> rtp_data, |
108 rtc::ArrayView<const uint8_t> rtcp_data, | 108 rtc::ArrayView<const uint8_t> rtcp_data, |
109 NetworkIsWorker network_is_worker) | 109 NetworkIsWorker network_is_worker) |
110 : verify_playout_(verify_playout), | 110 : verify_playout_(verify_playout), |
111 rtp_packet_(rtp_data.data(), rtp_data.size()), | 111 rtp_packet_(rtp_data.data(), rtp_data.size()), |
(...skipping 24 matching lines...) Expand all Loading... |
136 } | 136 } |
137 // Make sure RTCP_MUX_REQUIRED isn't set without RTCP_MUX. | 137 // Make sure RTCP_MUX_REQUIRED isn't set without RTCP_MUX. |
138 RTC_DCHECK_NE(RTCP_MUX_REQUIRED, flags1 & (RTCP_MUX | RTCP_MUX_REQUIRED)); | 138 RTC_DCHECK_NE(RTCP_MUX_REQUIRED, flags1 & (RTCP_MUX | RTCP_MUX_REQUIRED)); |
139 RTC_DCHECK_NE(RTCP_MUX_REQUIRED, flags2 & (RTCP_MUX | RTCP_MUX_REQUIRED)); | 139 RTC_DCHECK_NE(RTCP_MUX_REQUIRED, flags2 & (RTCP_MUX | RTCP_MUX_REQUIRED)); |
140 // Make sure if using raw packet transports, they're used for both | 140 // Make sure if using raw packet transports, they're used for both |
141 // channels. | 141 // channels. |
142 RTC_DCHECK_EQ(flags1 & RAW_PACKET_TRANSPORT, flags2 & RAW_PACKET_TRANSPORT); | 142 RTC_DCHECK_EQ(flags1 & RAW_PACKET_TRANSPORT, flags2 & RAW_PACKET_TRANSPORT); |
143 rtc::Thread* worker_thread = rtc::Thread::Current(); | 143 rtc::Thread* worker_thread = rtc::Thread::Current(); |
144 media_channel1_ = ch1; | 144 media_channel1_ = ch1; |
145 media_channel2_ = ch2; | 145 media_channel2_ = ch2; |
146 rtc::PacketTransportInterface* rtp1 = nullptr; | 146 rtc::PacketTransportInternal* rtp1 = nullptr; |
147 rtc::PacketTransportInterface* rtcp1 = nullptr; | 147 rtc::PacketTransportInternal* rtcp1 = nullptr; |
148 rtc::PacketTransportInterface* rtp2 = nullptr; | 148 rtc::PacketTransportInternal* rtp2 = nullptr; |
149 rtc::PacketTransportInterface* rtcp2 = nullptr; | 149 rtc::PacketTransportInternal* rtcp2 = nullptr; |
150 // Based on flags, create fake DTLS or raw packet transports. | 150 // Based on flags, create fake DTLS or raw packet transports. |
151 if (flags1 & RAW_PACKET_TRANSPORT) { | 151 if (flags1 & RAW_PACKET_TRANSPORT) { |
152 fake_rtp_packet_transport1_.reset( | 152 fake_rtp_packet_transport1_.reset( |
153 new rtc::FakePacketTransport("channel1_rtp")); | 153 new rtc::FakePacketTransport("channel1_rtp")); |
154 rtp1 = fake_rtp_packet_transport1_.get(); | 154 rtp1 = fake_rtp_packet_transport1_.get(); |
155 if (!(flags1 & RTCP_MUX_REQUIRED)) { | 155 if (!(flags1 & RTCP_MUX_REQUIRED)) { |
156 fake_rtcp_packet_transport1_.reset( | 156 fake_rtcp_packet_transport1_.reset( |
157 new rtc::FakePacketTransport("channel1_rtcp")); | 157 new rtc::FakePacketTransport("channel1_rtcp")); |
158 rtcp1 = fake_rtcp_packet_transport1_.get(); | 158 rtcp1 = fake_rtcp_packet_transport1_.get(); |
159 } | 159 } |
(...skipping 88 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
248 AddLegacyStreamInContent(kSsrc2, flags2, &remote_media_content2_); | 248 AddLegacyStreamInContent(kSsrc2, flags2, &remote_media_content2_); |
249 } | 249 } |
250 } | 250 } |
251 typename T::Channel* CreateChannel( | 251 typename T::Channel* CreateChannel( |
252 rtc::Thread* worker_thread, | 252 rtc::Thread* worker_thread, |
253 rtc::Thread* network_thread, | 253 rtc::Thread* network_thread, |
254 cricket::MediaEngineInterface* engine, | 254 cricket::MediaEngineInterface* engine, |
255 typename T::MediaChannel* ch, | 255 typename T::MediaChannel* ch, |
256 cricket::DtlsTransportInternal* fake_rtp_dtls_transport, | 256 cricket::DtlsTransportInternal* fake_rtp_dtls_transport, |
257 cricket::DtlsTransportInternal* fake_rtcp_dtls_transport, | 257 cricket::DtlsTransportInternal* fake_rtcp_dtls_transport, |
258 rtc::PacketTransportInterface* fake_rtp_packet_transport, | 258 rtc::PacketTransportInternal* fake_rtp_packet_transport, |
259 rtc::PacketTransportInterface* fake_rtcp_packet_transport, | 259 rtc::PacketTransportInternal* fake_rtcp_packet_transport, |
260 int flags) { | 260 int flags) { |
261 rtc::Thread* signaling_thread = rtc::Thread::Current(); | 261 rtc::Thread* signaling_thread = rtc::Thread::Current(); |
262 typename T::Channel* channel = new typename T::Channel( | 262 typename T::Channel* channel = new typename T::Channel( |
263 worker_thread, network_thread, signaling_thread, engine, ch, | 263 worker_thread, network_thread, signaling_thread, engine, ch, |
264 cricket::CN_AUDIO, (flags & RTCP_MUX_REQUIRED) != 0, | 264 cricket::CN_AUDIO, (flags & RTCP_MUX_REQUIRED) != 0, |
265 (flags & SECURE) != 0); | 265 (flags & SECURE) != 0); |
266 rtc::CryptoOptions crypto_options; | 266 rtc::CryptoOptions crypto_options; |
267 crypto_options.enable_gcm_crypto_suites = (flags & GCM_CIPHER) != 0; | 267 crypto_options.enable_gcm_crypto_suites = (flags & GCM_CIPHER) != 0; |
268 channel->SetCryptoOptions(crypto_options); | 268 channel->SetCryptoOptions(crypto_options); |
269 if (!channel->NeedsRtcpTransport()) { | 269 if (!channel->NeedsRtcpTransport()) { |
(...skipping 1835 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2105 | 2105 |
2106 // override to add NULL parameter | 2106 // override to add NULL parameter |
2107 template <> | 2107 template <> |
2108 cricket::VideoChannel* ChannelTest<VideoTraits>::CreateChannel( | 2108 cricket::VideoChannel* ChannelTest<VideoTraits>::CreateChannel( |
2109 rtc::Thread* worker_thread, | 2109 rtc::Thread* worker_thread, |
2110 rtc::Thread* network_thread, | 2110 rtc::Thread* network_thread, |
2111 cricket::MediaEngineInterface* engine, | 2111 cricket::MediaEngineInterface* engine, |
2112 cricket::FakeVideoMediaChannel* ch, | 2112 cricket::FakeVideoMediaChannel* ch, |
2113 cricket::DtlsTransportInternal* fake_rtp_dtls_transport, | 2113 cricket::DtlsTransportInternal* fake_rtp_dtls_transport, |
2114 cricket::DtlsTransportInternal* fake_rtcp_dtls_transport, | 2114 cricket::DtlsTransportInternal* fake_rtcp_dtls_transport, |
2115 rtc::PacketTransportInterface* fake_rtp_packet_transport, | 2115 rtc::PacketTransportInternal* fake_rtp_packet_transport, |
2116 rtc::PacketTransportInterface* fake_rtcp_packet_transport, | 2116 rtc::PacketTransportInternal* fake_rtcp_packet_transport, |
2117 int flags) { | 2117 int flags) { |
2118 rtc::Thread* signaling_thread = rtc::Thread::Current(); | 2118 rtc::Thread* signaling_thread = rtc::Thread::Current(); |
2119 cricket::VideoChannel* channel = new cricket::VideoChannel( | 2119 cricket::VideoChannel* channel = new cricket::VideoChannel( |
2120 worker_thread, network_thread, signaling_thread, ch, cricket::CN_VIDEO, | 2120 worker_thread, network_thread, signaling_thread, ch, cricket::CN_VIDEO, |
2121 (flags & RTCP_MUX_REQUIRED) != 0, (flags & SECURE) != 0); | 2121 (flags & RTCP_MUX_REQUIRED) != 0, (flags & SECURE) != 0); |
2122 rtc::CryptoOptions crypto_options; | 2122 rtc::CryptoOptions crypto_options; |
2123 crypto_options.enable_gcm_crypto_suites = (flags & GCM_CIPHER) != 0; | 2123 crypto_options.enable_gcm_crypto_suites = (flags & GCM_CIPHER) != 0; |
2124 channel->SetCryptoOptions(crypto_options); | 2124 channel->SetCryptoOptions(crypto_options); |
2125 if (!channel->NeedsRtcpTransport()) { | 2125 if (!channel->NeedsRtcpTransport()) { |
2126 fake_rtcp_dtls_transport = nullptr; | 2126 fake_rtcp_dtls_transport = nullptr; |
(...skipping 1216 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
3343 | 3343 |
3344 // Override to avoid engine channel parameter. | 3344 // Override to avoid engine channel parameter. |
3345 template <> | 3345 template <> |
3346 cricket::RtpDataChannel* ChannelTest<DataTraits>::CreateChannel( | 3346 cricket::RtpDataChannel* ChannelTest<DataTraits>::CreateChannel( |
3347 rtc::Thread* worker_thread, | 3347 rtc::Thread* worker_thread, |
3348 rtc::Thread* network_thread, | 3348 rtc::Thread* network_thread, |
3349 cricket::MediaEngineInterface* engine, | 3349 cricket::MediaEngineInterface* engine, |
3350 cricket::FakeDataMediaChannel* ch, | 3350 cricket::FakeDataMediaChannel* ch, |
3351 cricket::DtlsTransportInternal* fake_rtp_dtls_transport, | 3351 cricket::DtlsTransportInternal* fake_rtp_dtls_transport, |
3352 cricket::DtlsTransportInternal* fake_rtcp_dtls_transport, | 3352 cricket::DtlsTransportInternal* fake_rtcp_dtls_transport, |
3353 rtc::PacketTransportInterface* fake_rtp_packet_transport, | 3353 rtc::PacketTransportInternal* fake_rtp_packet_transport, |
3354 rtc::PacketTransportInterface* fake_rtcp_packet_transport, | 3354 rtc::PacketTransportInternal* fake_rtcp_packet_transport, |
3355 int flags) { | 3355 int flags) { |
3356 rtc::Thread* signaling_thread = rtc::Thread::Current(); | 3356 rtc::Thread* signaling_thread = rtc::Thread::Current(); |
3357 cricket::RtpDataChannel* channel = new cricket::RtpDataChannel( | 3357 cricket::RtpDataChannel* channel = new cricket::RtpDataChannel( |
3358 worker_thread, network_thread, signaling_thread, ch, cricket::CN_DATA, | 3358 worker_thread, network_thread, signaling_thread, ch, cricket::CN_DATA, |
3359 (flags & RTCP_MUX_REQUIRED) != 0, (flags & SECURE) != 0); | 3359 (flags & RTCP_MUX_REQUIRED) != 0, (flags & SECURE) != 0); |
3360 rtc::CryptoOptions crypto_options; | 3360 rtc::CryptoOptions crypto_options; |
3361 crypto_options.enable_gcm_crypto_suites = (flags & GCM_CIPHER) != 0; | 3361 crypto_options.enable_gcm_crypto_suites = (flags & GCM_CIPHER) != 0; |
3362 channel->SetCryptoOptions(crypto_options); | 3362 channel->SetCryptoOptions(crypto_options); |
3363 if (!channel->NeedsRtcpTransport()) { | 3363 if (!channel->NeedsRtcpTransport()) { |
3364 fake_rtcp_dtls_transport = nullptr; | 3364 fake_rtcp_dtls_transport = nullptr; |
(...skipping 383 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
3748 cricket::FakeDtlsTransport new_rtp_transport( | 3748 cricket::FakeDtlsTransport new_rtp_transport( |
3749 "bar", cricket::ICE_CANDIDATE_COMPONENT_RTP); | 3749 "bar", cricket::ICE_CANDIDATE_COMPONENT_RTP); |
3750 cricket::FakeDtlsTransport new_rtcp_transport( | 3750 cricket::FakeDtlsTransport new_rtcp_transport( |
3751 "baz", cricket::ICE_CANDIDATE_COMPONENT_RTCP); | 3751 "baz", cricket::ICE_CANDIDATE_COMPONENT_RTCP); |
3752 EXPECT_DEATH( | 3752 EXPECT_DEATH( |
3753 voice_channel_.SetTransports(&new_rtp_transport, &new_rtcp_transport), | 3753 voice_channel_.SetTransports(&new_rtp_transport, &new_rtcp_transport), |
3754 ""); | 3754 ""); |
3755 } | 3755 } |
3756 | 3756 |
3757 // Not expected to support going from DtlsTransportInternal to | 3757 // Not expected to support going from DtlsTransportInternal to |
3758 // PacketTransportInterface. | 3758 // PacketTransportInternal. |
3759 TEST_F(BaseChannelDeathTest, SetTransportsDtlsToNonDtls) { | 3759 TEST_F(BaseChannelDeathTest, SetTransportsDtlsToNonDtls) { |
3760 ASSERT_TRUE(voice_channel_.Init_w( | 3760 ASSERT_TRUE(voice_channel_.Init_w( |
3761 &fake_rtp_dtls_transport_, &fake_rtcp_dtls_transport_, | 3761 &fake_rtp_dtls_transport_, &fake_rtcp_dtls_transport_, |
3762 &fake_rtp_dtls_transport_, &fake_rtcp_dtls_transport_)); | 3762 &fake_rtp_dtls_transport_, &fake_rtcp_dtls_transport_)); |
3763 EXPECT_DEATH( | 3763 EXPECT_DEATH( |
3764 voice_channel_.SetTransports(static_cast<rtc::PacketTransportInterface*>( | 3764 voice_channel_.SetTransports( |
3765 &fake_rtp_dtls_transport_), | 3765 static_cast<rtc::PacketTransportInternal*>(&fake_rtp_dtls_transport_), |
3766 static_cast<rtc::PacketTransportInterface*>( | 3766 static_cast<rtc::PacketTransportInternal*>( |
3767 &fake_rtp_dtls_transport_)), | 3767 &fake_rtp_dtls_transport_)), |
3768 ""); | 3768 ""); |
3769 } | 3769 } |
3770 | 3770 |
3771 // Not expected to support going from PacketTransportInterface to | 3771 // Not expected to support going from PacketTransportInternal to |
3772 // DtlsTransportInternal. | 3772 // DtlsTransportInternal. |
3773 TEST_F(BaseChannelDeathTest, SetTransportsNonDtlsToDtls) { | 3773 TEST_F(BaseChannelDeathTest, SetTransportsNonDtlsToDtls) { |
3774 ASSERT_TRUE(voice_channel_.Init_w(nullptr, nullptr, &fake_rtp_dtls_transport_, | 3774 ASSERT_TRUE(voice_channel_.Init_w(nullptr, nullptr, &fake_rtp_dtls_transport_, |
3775 &fake_rtcp_dtls_transport_)); | 3775 &fake_rtcp_dtls_transport_)); |
3776 EXPECT_DEATH(voice_channel_.SetTransports(&fake_rtp_dtls_transport_, | 3776 EXPECT_DEATH(voice_channel_.SetTransports(&fake_rtp_dtls_transport_, |
3777 &fake_rtp_dtls_transport_), | 3777 &fake_rtp_dtls_transport_), |
3778 ""); | 3778 ""); |
3779 } | 3779 } |
3780 | 3780 |
3781 #endif // RTC_DCHECK_IS_ON && GTEST_HAS_DEATH_TEST && !defined(WEBRTC_ANDROID) | 3781 #endif // RTC_DCHECK_IS_ON && GTEST_HAS_DEATH_TEST && !defined(WEBRTC_ANDROID) |
3782 | 3782 |
3783 // TODO(pthatcher): TestSetReceiver? | 3783 // TODO(pthatcher): TestSetReceiver? |
OLD | NEW |