| 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 1840 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2110 | 2110 |
| 2111 // override to add NULL parameter | 2111 // override to add NULL parameter |
| 2112 template <> | 2112 template <> |
| 2113 cricket::VideoChannel* ChannelTest<VideoTraits>::CreateChannel( | 2113 cricket::VideoChannel* ChannelTest<VideoTraits>::CreateChannel( |
| 2114 rtc::Thread* worker_thread, | 2114 rtc::Thread* worker_thread, |
| 2115 rtc::Thread* network_thread, | 2115 rtc::Thread* network_thread, |
| 2116 cricket::MediaEngineInterface* engine, | 2116 cricket::MediaEngineInterface* engine, |
| 2117 cricket::FakeVideoMediaChannel* ch, | 2117 cricket::FakeVideoMediaChannel* ch, |
| 2118 cricket::DtlsTransportInternal* fake_rtp_dtls_transport, | 2118 cricket::DtlsTransportInternal* fake_rtp_dtls_transport, |
| 2119 cricket::DtlsTransportInternal* fake_rtcp_dtls_transport, | 2119 cricket::DtlsTransportInternal* fake_rtcp_dtls_transport, |
| 2120 rtc::PacketTransportInterface* fake_rtp_packet_transport, | 2120 rtc::PacketTransportInternal* fake_rtp_packet_transport, |
| 2121 rtc::PacketTransportInterface* fake_rtcp_packet_transport, | 2121 rtc::PacketTransportInternal* fake_rtcp_packet_transport, |
| 2122 int flags) { | 2122 int flags) { |
| 2123 rtc::Thread* signaling_thread = rtc::Thread::Current(); | 2123 rtc::Thread* signaling_thread = rtc::Thread::Current(); |
| 2124 cricket::VideoChannel* channel = new cricket::VideoChannel( | 2124 cricket::VideoChannel* channel = new cricket::VideoChannel( |
| 2125 worker_thread, network_thread, signaling_thread, ch, cricket::CN_VIDEO, | 2125 worker_thread, network_thread, signaling_thread, ch, cricket::CN_VIDEO, |
| 2126 (flags & RTCP_MUX_REQUIRED) != 0, (flags & SECURE) != 0); | 2126 (flags & RTCP_MUX_REQUIRED) != 0, (flags & SECURE) != 0); |
| 2127 rtc::CryptoOptions crypto_options; | 2127 rtc::CryptoOptions crypto_options; |
| 2128 crypto_options.enable_gcm_crypto_suites = (flags & GCM_CIPHER) != 0; | 2128 crypto_options.enable_gcm_crypto_suites = (flags & GCM_CIPHER) != 0; |
| 2129 channel->SetCryptoOptions(crypto_options); | 2129 channel->SetCryptoOptions(crypto_options); |
| 2130 if (!channel->NeedsRtcpTransport()) { | 2130 if (!channel->NeedsRtcpTransport()) { |
| 2131 fake_rtcp_dtls_transport = nullptr; | 2131 fake_rtcp_dtls_transport = nullptr; |
| (...skipping 1216 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 3348 | 3348 |
| 3349 // Override to avoid engine channel parameter. | 3349 // Override to avoid engine channel parameter. |
| 3350 template <> | 3350 template <> |
| 3351 cricket::RtpDataChannel* ChannelTest<DataTraits>::CreateChannel( | 3351 cricket::RtpDataChannel* ChannelTest<DataTraits>::CreateChannel( |
| 3352 rtc::Thread* worker_thread, | 3352 rtc::Thread* worker_thread, |
| 3353 rtc::Thread* network_thread, | 3353 rtc::Thread* network_thread, |
| 3354 cricket::MediaEngineInterface* engine, | 3354 cricket::MediaEngineInterface* engine, |
| 3355 cricket::FakeDataMediaChannel* ch, | 3355 cricket::FakeDataMediaChannel* ch, |
| 3356 cricket::DtlsTransportInternal* fake_rtp_dtls_transport, | 3356 cricket::DtlsTransportInternal* fake_rtp_dtls_transport, |
| 3357 cricket::DtlsTransportInternal* fake_rtcp_dtls_transport, | 3357 cricket::DtlsTransportInternal* fake_rtcp_dtls_transport, |
| 3358 rtc::PacketTransportInterface* fake_rtp_packet_transport, | 3358 rtc::PacketTransportInternal* fake_rtp_packet_transport, |
| 3359 rtc::PacketTransportInterface* fake_rtcp_packet_transport, | 3359 rtc::PacketTransportInternal* fake_rtcp_packet_transport, |
| 3360 int flags) { | 3360 int flags) { |
| 3361 rtc::Thread* signaling_thread = rtc::Thread::Current(); | 3361 rtc::Thread* signaling_thread = rtc::Thread::Current(); |
| 3362 cricket::RtpDataChannel* channel = new cricket::RtpDataChannel( | 3362 cricket::RtpDataChannel* channel = new cricket::RtpDataChannel( |
| 3363 worker_thread, network_thread, signaling_thread, ch, cricket::CN_DATA, | 3363 worker_thread, network_thread, signaling_thread, ch, cricket::CN_DATA, |
| 3364 (flags & RTCP_MUX_REQUIRED) != 0, (flags & SECURE) != 0); | 3364 (flags & RTCP_MUX_REQUIRED) != 0, (flags & SECURE) != 0); |
| 3365 rtc::CryptoOptions crypto_options; | 3365 rtc::CryptoOptions crypto_options; |
| 3366 crypto_options.enable_gcm_crypto_suites = (flags & GCM_CIPHER) != 0; | 3366 crypto_options.enable_gcm_crypto_suites = (flags & GCM_CIPHER) != 0; |
| 3367 channel->SetCryptoOptions(crypto_options); | 3367 channel->SetCryptoOptions(crypto_options); |
| 3368 if (!channel->NeedsRtcpTransport()) { | 3368 if (!channel->NeedsRtcpTransport()) { |
| 3369 fake_rtcp_dtls_transport = nullptr; | 3369 fake_rtcp_dtls_transport = nullptr; |
| (...skipping 383 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 3753 cricket::FakeDtlsTransport new_rtp_transport( | 3753 cricket::FakeDtlsTransport new_rtp_transport( |
| 3754 "bar", cricket::ICE_CANDIDATE_COMPONENT_RTP); | 3754 "bar", cricket::ICE_CANDIDATE_COMPONENT_RTP); |
| 3755 cricket::FakeDtlsTransport new_rtcp_transport( | 3755 cricket::FakeDtlsTransport new_rtcp_transport( |
| 3756 "baz", cricket::ICE_CANDIDATE_COMPONENT_RTCP); | 3756 "baz", cricket::ICE_CANDIDATE_COMPONENT_RTCP); |
| 3757 EXPECT_DEATH( | 3757 EXPECT_DEATH( |
| 3758 voice_channel_.SetTransports(&new_rtp_transport, &new_rtcp_transport), | 3758 voice_channel_.SetTransports(&new_rtp_transport, &new_rtcp_transport), |
| 3759 ""); | 3759 ""); |
| 3760 } | 3760 } |
| 3761 | 3761 |
| 3762 // Not expected to support going from DtlsTransportInternal to | 3762 // Not expected to support going from DtlsTransportInternal to |
| 3763 // PacketTransportInterface. | 3763 // PacketTransportInternal. |
| 3764 TEST_F(BaseChannelDeathTest, SetTransportsDtlsToNonDtls) { | 3764 TEST_F(BaseChannelDeathTest, SetTransportsDtlsToNonDtls) { |
| 3765 ASSERT_TRUE(voice_channel_.Init_w( | 3765 ASSERT_TRUE(voice_channel_.Init_w( |
| 3766 &fake_rtp_dtls_transport_, &fake_rtcp_dtls_transport_, | 3766 &fake_rtp_dtls_transport_, &fake_rtcp_dtls_transport_, |
| 3767 &fake_rtp_dtls_transport_, &fake_rtcp_dtls_transport_)); | 3767 &fake_rtp_dtls_transport_, &fake_rtcp_dtls_transport_)); |
| 3768 EXPECT_DEATH( | 3768 EXPECT_DEATH( |
| 3769 voice_channel_.SetTransports(static_cast<rtc::PacketTransportInterface*>( | 3769 voice_channel_.SetTransports( |
| 3770 &fake_rtp_dtls_transport_), | 3770 static_cast<rtc::PacketTransportInternal*>(&fake_rtp_dtls_transport_), |
| 3771 static_cast<rtc::PacketTransportInterface*>( | 3771 static_cast<rtc::PacketTransportInternal*>( |
| 3772 &fake_rtp_dtls_transport_)), | 3772 &fake_rtp_dtls_transport_)), |
| 3773 ""); | 3773 ""); |
| 3774 } | 3774 } |
| 3775 | 3775 |
| 3776 // Not expected to support going from PacketTransportInterface to | 3776 // Not expected to support going from PacketTransportInternal to |
| 3777 // DtlsTransportInternal. | 3777 // DtlsTransportInternal. |
| 3778 TEST_F(BaseChannelDeathTest, SetTransportsNonDtlsToDtls) { | 3778 TEST_F(BaseChannelDeathTest, SetTransportsNonDtlsToDtls) { |
| 3779 ASSERT_TRUE(voice_channel_.Init_w(nullptr, nullptr, &fake_rtp_dtls_transport_, | 3779 ASSERT_TRUE(voice_channel_.Init_w(nullptr, nullptr, &fake_rtp_dtls_transport_, |
| 3780 &fake_rtcp_dtls_transport_)); | 3780 &fake_rtcp_dtls_transport_)); |
| 3781 EXPECT_DEATH(voice_channel_.SetTransports(&fake_rtp_dtls_transport_, | 3781 EXPECT_DEATH(voice_channel_.SetTransports(&fake_rtp_dtls_transport_, |
| 3782 &fake_rtp_dtls_transport_), | 3782 &fake_rtp_dtls_transport_), |
| 3783 ""); | 3783 ""); |
| 3784 } | 3784 } |
| 3785 | 3785 |
| 3786 #endif // RTC_DCHECK_IS_ON && GTEST_HAS_DEATH_TEST && !defined(WEBRTC_ANDROID) | 3786 #endif // RTC_DCHECK_IS_ON && GTEST_HAS_DEATH_TEST && !defined(WEBRTC_ANDROID) |
| 3787 | 3787 |
| 3788 // TODO(pthatcher): TestSetReceiver? | 3788 // TODO(pthatcher): TestSetReceiver? |
| OLD | NEW |