| OLD | NEW |
| 1 /* | 1 /* |
| 2 * Copyright 2012 The WebRTC project authors. All Rights Reserved. | 2 * Copyright 2012 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 16 matching lines...) Expand all Loading... |
| 27 #include "webrtc/base/sslstreamadapter.h" | 27 #include "webrtc/base/sslstreamadapter.h" |
| 28 #include "webrtc/base/stringutils.h" | 28 #include "webrtc/base/stringutils.h" |
| 29 #include "webrtc/base/thread.h" | 29 #include "webrtc/base/thread.h" |
| 30 #include "webrtc/base/virtualsocketserver.h" | 30 #include "webrtc/base/virtualsocketserver.h" |
| 31 #include "webrtc/logging/rtc_event_log/rtc_event_log.h" | 31 #include "webrtc/logging/rtc_event_log/rtc_event_log.h" |
| 32 #include "webrtc/media/base/fakemediaengine.h" | 32 #include "webrtc/media/base/fakemediaengine.h" |
| 33 #include "webrtc/media/base/fakevideorenderer.h" | 33 #include "webrtc/media/base/fakevideorenderer.h" |
| 34 #include "webrtc/media/base/mediachannel.h" | 34 #include "webrtc/media/base/mediachannel.h" |
| 35 #include "webrtc/media/engine/fakewebrtccall.h" | 35 #include "webrtc/media/engine/fakewebrtccall.h" |
| 36 #include "webrtc/media/sctp/sctptransportinternal.h" | 36 #include "webrtc/media/sctp/sctptransportinternal.h" |
| 37 #include "webrtc/p2p/base/packettransportinterface.h" | 37 #include "webrtc/p2p/base/packettransportinternal.h" |
| 38 #include "webrtc/p2p/base/stunserver.h" | 38 #include "webrtc/p2p/base/stunserver.h" |
| 39 #include "webrtc/p2p/base/teststunserver.h" | 39 #include "webrtc/p2p/base/teststunserver.h" |
| 40 #include "webrtc/p2p/base/testturnserver.h" | 40 #include "webrtc/p2p/base/testturnserver.h" |
| 41 #include "webrtc/p2p/client/basicportallocator.h" | 41 #include "webrtc/p2p/client/basicportallocator.h" |
| 42 #include "webrtc/pc/audiotrack.h" | 42 #include "webrtc/pc/audiotrack.h" |
| 43 #include "webrtc/pc/channelmanager.h" | 43 #include "webrtc/pc/channelmanager.h" |
| 44 #include "webrtc/pc/fakemediacontroller.h" | 44 #include "webrtc/pc/fakemediacontroller.h" |
| 45 #include "webrtc/pc/mediasession.h" | 45 #include "webrtc/pc/mediasession.h" |
| 46 #include "webrtc/pc/peerconnection.h" | 46 #include "webrtc/pc/peerconnection.h" |
| 47 #include "webrtc/pc/sctputils.h" | 47 #include "webrtc/pc/sctputils.h" |
| (...skipping 157 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 205 std::vector<PeerConnectionInterface::IceConnectionState> | 205 std::vector<PeerConnectionInterface::IceConnectionState> |
| 206 ice_connection_state_history_; | 206 ice_connection_state_history_; |
| 207 size_t num_candidates_removed_ = 0; | 207 size_t num_candidates_removed_ = 0; |
| 208 }; | 208 }; |
| 209 | 209 |
| 210 // Used for tests in this file to verify that WebRtcSession responds to signals | 210 // Used for tests in this file to verify that WebRtcSession responds to signals |
| 211 // from the SctpTransport correctly, and calls Start with the correct | 211 // from the SctpTransport correctly, and calls Start with the correct |
| 212 // local/remote ports. | 212 // local/remote ports. |
| 213 class FakeSctpTransport : public cricket::SctpTransportInternal { | 213 class FakeSctpTransport : public cricket::SctpTransportInternal { |
| 214 public: | 214 public: |
| 215 void SetTransportChannel(rtc::PacketTransportInterface* channel) override {} | 215 void SetTransportChannel(rtc::PacketTransportInternal* channel) override {} |
| 216 bool Start(int local_port, int remote_port) override { | 216 bool Start(int local_port, int remote_port) override { |
| 217 local_port_ = local_port; | 217 local_port_ = local_port; |
| 218 remote_port_ = remote_port; | 218 remote_port_ = remote_port; |
| 219 return true; | 219 return true; |
| 220 } | 220 } |
| 221 bool OpenStream(int sid) override { return true; } | 221 bool OpenStream(int sid) override { return true; } |
| 222 bool ResetStream(int sid) override { return true; } | 222 bool ResetStream(int sid) override { return true; } |
| 223 bool SendData(const cricket::SendDataParams& params, | 223 bool SendData(const cricket::SendDataParams& params, |
| 224 const rtc::CopyOnWriteBuffer& payload, | 224 const rtc::CopyOnWriteBuffer& payload, |
| 225 cricket::SendDataResult* result = nullptr) override { | 225 cricket::SendDataResult* result = nullptr) override { |
| 226 return true; | 226 return true; |
| 227 } | 227 } |
| 228 bool ReadyToSendData() override { return true; } | 228 bool ReadyToSendData() override { return true; } |
| 229 void set_debug_name_for_testing(const char* debug_name) override {} | 229 void set_debug_name_for_testing(const char* debug_name) override {} |
| 230 | 230 |
| 231 int local_port() const { return local_port_; } | 231 int local_port() const { return local_port_; } |
| 232 int remote_port() const { return remote_port_; } | 232 int remote_port() const { return remote_port_; } |
| 233 | 233 |
| 234 private: | 234 private: |
| 235 int local_port_ = -1; | 235 int local_port_ = -1; |
| 236 int remote_port_ = -1; | 236 int remote_port_ = -1; |
| 237 }; | 237 }; |
| 238 | 238 |
| 239 class FakeSctpTransportFactory : public cricket::SctpTransportInternalFactory { | 239 class FakeSctpTransportFactory : public cricket::SctpTransportInternalFactory { |
| 240 public: | 240 public: |
| 241 std::unique_ptr<cricket::SctpTransportInternal> CreateSctpTransport( | 241 std::unique_ptr<cricket::SctpTransportInternal> CreateSctpTransport( |
| 242 rtc::PacketTransportInterface*) override { | 242 rtc::PacketTransportInternal*) override { |
| 243 last_fake_sctp_transport_ = new FakeSctpTransport(); | 243 last_fake_sctp_transport_ = new FakeSctpTransport(); |
| 244 return std::unique_ptr<cricket::SctpTransportInternal>( | 244 return std::unique_ptr<cricket::SctpTransportInternal>( |
| 245 last_fake_sctp_transport_); | 245 last_fake_sctp_transport_); |
| 246 } | 246 } |
| 247 | 247 |
| 248 FakeSctpTransport* last_fake_sctp_transport() { | 248 FakeSctpTransport* last_fake_sctp_transport() { |
| 249 return last_fake_sctp_transport_; | 249 return last_fake_sctp_transport_; |
| 250 } | 250 } |
| 251 | 251 |
| 252 private: | 252 private: |
| (...skipping 17 matching lines...) Expand all Loading... |
| 270 signaling_thread, | 270 signaling_thread, |
| 271 port_allocator, | 271 port_allocator, |
| 272 std::move(transport_controller), | 272 std::move(transport_controller), |
| 273 std::move(sctp_factory)) { | 273 std::move(sctp_factory)) { |
| 274 RegisterIceObserver(ice_observer); | 274 RegisterIceObserver(ice_observer); |
| 275 } | 275 } |
| 276 virtual ~WebRtcSessionForTest() {} | 276 virtual ~WebRtcSessionForTest() {} |
| 277 | 277 |
| 278 // Note that these methods are only safe to use if the signaling thread | 278 // Note that these methods are only safe to use if the signaling thread |
| 279 // is the same as the worker thread | 279 // is the same as the worker thread |
| 280 rtc::PacketTransportInterface* voice_rtp_transport_channel() { | 280 rtc::PacketTransportInternal* voice_rtp_transport_channel() { |
| 281 return rtp_transport_channel(voice_channel()); | 281 return rtp_transport_channel(voice_channel()); |
| 282 } | 282 } |
| 283 | 283 |
| 284 rtc::PacketTransportInterface* voice_rtcp_transport_channel() { | 284 rtc::PacketTransportInternal* voice_rtcp_transport_channel() { |
| 285 return rtcp_transport_channel(voice_channel()); | 285 return rtcp_transport_channel(voice_channel()); |
| 286 } | 286 } |
| 287 | 287 |
| 288 rtc::PacketTransportInterface* video_rtp_transport_channel() { | 288 rtc::PacketTransportInternal* video_rtp_transport_channel() { |
| 289 return rtp_transport_channel(video_channel()); | 289 return rtp_transport_channel(video_channel()); |
| 290 } | 290 } |
| 291 | 291 |
| 292 rtc::PacketTransportInterface* video_rtcp_transport_channel() { | 292 rtc::PacketTransportInternal* video_rtcp_transport_channel() { |
| 293 return rtcp_transport_channel(video_channel()); | 293 return rtcp_transport_channel(video_channel()); |
| 294 } | 294 } |
| 295 | 295 |
| 296 private: | 296 private: |
| 297 rtc::PacketTransportInterface* rtp_transport_channel( | 297 rtc::PacketTransportInternal* rtp_transport_channel( |
| 298 cricket::BaseChannel* ch) { | 298 cricket::BaseChannel* ch) { |
| 299 if (!ch) { | 299 if (!ch) { |
| 300 return nullptr; | 300 return nullptr; |
| 301 } | 301 } |
| 302 return ch->rtp_dtls_transport(); | 302 return ch->rtp_dtls_transport(); |
| 303 } | 303 } |
| 304 | 304 |
| 305 rtc::PacketTransportInterface* rtcp_transport_channel( | 305 rtc::PacketTransportInternal* rtcp_transport_channel( |
| 306 cricket::BaseChannel* ch) { | 306 cricket::BaseChannel* ch) { |
| 307 if (!ch) { | 307 if (!ch) { |
| 308 return nullptr; | 308 return nullptr; |
| 309 } | 309 } |
| 310 return ch->rtcp_dtls_transport(); | 310 return ch->rtcp_dtls_transport(); |
| 311 } | 311 } |
| 312 }; | 312 }; |
| 313 | 313 |
| 314 class WebRtcSessionCreateSDPObserverForTest | 314 class WebRtcSessionCreateSDPObserverForTest |
| 315 : public rtc::RefCountedObject<CreateSessionDescriptionObserver> { | 315 : public rtc::RefCountedObject<CreateSessionDescriptionObserver> { |
| (...skipping 48 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 364 | 364 |
| 365 class WebRtcSessionTest | 365 class WebRtcSessionTest |
| 366 : public testing::TestWithParam<RTCCertificateGenerationMethod>, | 366 : public testing::TestWithParam<RTCCertificateGenerationMethod>, |
| 367 public sigslot::has_slots<> { | 367 public sigslot::has_slots<> { |
| 368 protected: | 368 protected: |
| 369 // TODO Investigate why ChannelManager crashes, if it's created | 369 // TODO Investigate why ChannelManager crashes, if it's created |
| 370 // after stun_server. | 370 // after stun_server. |
| 371 WebRtcSessionTest() | 371 WebRtcSessionTest() |
| 372 : media_engine_(new cricket::FakeMediaEngine()), | 372 : media_engine_(new cricket::FakeMediaEngine()), |
| 373 data_engine_(new cricket::FakeDataEngine()), | 373 data_engine_(new cricket::FakeDataEngine()), |
| 374 channel_manager_(new cricket::ChannelManager(media_engine_, | 374 channel_manager_(new cricket::ChannelManager( |
| 375 data_engine_, | 375 std::unique_ptr<cricket::MediaEngineInterface>(media_engine_), |
| 376 rtc::Thread::Current())), | 376 std::unique_ptr<cricket::DataEngineInterface>(data_engine_), |
| 377 rtc::Thread::Current())), |
| 377 fake_call_(webrtc::Call::Config(&event_log_)), | 378 fake_call_(webrtc::Call::Config(&event_log_)), |
| 378 media_controller_( | 379 media_controller_( |
| 379 webrtc::MediaControllerInterface::Create(cricket::MediaConfig(), | 380 webrtc::MediaControllerInterface::Create(cricket::MediaConfig(), |
| 380 rtc::Thread::Current(), | 381 rtc::Thread::Current(), |
| 381 channel_manager_.get(), | 382 channel_manager_.get(), |
| 382 &event_log_)), | 383 &event_log_)), |
| 383 tdesc_factory_(new cricket::TransportDescriptionFactory()), | 384 tdesc_factory_(new cricket::TransportDescriptionFactory()), |
| 384 desc_factory_( | 385 desc_factory_( |
| 385 new cricket::MediaSessionDescriptionFactory(channel_manager_.get(), | 386 new cricket::MediaSessionDescriptionFactory(channel_manager_.get(), |
| 386 tdesc_factory_.get())), | 387 tdesc_factory_.get())), |
| (...skipping 1139 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1526 cricket::RelayCredentials credentials(kTurnUsername, kTurnPassword); | 1527 cricket::RelayCredentials credentials(kTurnUsername, kTurnPassword); |
| 1527 turn_server.credentials = credentials; | 1528 turn_server.credentials = credentials; |
| 1528 turn_server.ports.push_back( | 1529 turn_server.ports.push_back( |
| 1529 cricket::ProtocolAddress(kTurnUdpIntAddr, cricket::PROTO_UDP)); | 1530 cricket::ProtocolAddress(kTurnUdpIntAddr, cricket::PROTO_UDP)); |
| 1530 allocator_->AddTurnServer(turn_server); | 1531 allocator_->AddTurnServer(turn_server); |
| 1531 allocator_->set_step_delay(cricket::kMinimumStepDelay); | 1532 allocator_->set_step_delay(cricket::kMinimumStepDelay); |
| 1532 allocator_->set_flags(cricket::PORTALLOCATOR_DISABLE_TCP); | 1533 allocator_->set_flags(cricket::PORTALLOCATOR_DISABLE_TCP); |
| 1533 } | 1534 } |
| 1534 | 1535 |
| 1535 webrtc::RtcEventLogNullImpl event_log_; | 1536 webrtc::RtcEventLogNullImpl event_log_; |
| 1537 // |media_engine_| and |data_engine_| are actually owned by |
| 1538 // |channel_manager_|. |
| 1536 cricket::FakeMediaEngine* media_engine_; | 1539 cricket::FakeMediaEngine* media_engine_; |
| 1537 cricket::FakeDataEngine* data_engine_; | 1540 cricket::FakeDataEngine* data_engine_; |
| 1538 // Actually owned by session_. | 1541 // Actually owned by session_. |
| 1539 FakeSctpTransportFactory* fake_sctp_transport_factory_ = nullptr; | 1542 FakeSctpTransportFactory* fake_sctp_transport_factory_ = nullptr; |
| 1540 std::unique_ptr<cricket::ChannelManager> channel_manager_; | 1543 std::unique_ptr<cricket::ChannelManager> channel_manager_; |
| 1541 cricket::FakeCall fake_call_; | 1544 cricket::FakeCall fake_call_; |
| 1542 std::unique_ptr<webrtc::MediaControllerInterface> media_controller_; | 1545 std::unique_ptr<webrtc::MediaControllerInterface> media_controller_; |
| 1543 std::unique_ptr<cricket::TransportDescriptionFactory> tdesc_factory_; | 1546 std::unique_ptr<cricket::TransportDescriptionFactory> tdesc_factory_; |
| 1544 std::unique_ptr<cricket::MediaSessionDescriptionFactory> desc_factory_; | 1547 std::unique_ptr<cricket::MediaSessionDescriptionFactory> desc_factory_; |
| 1545 std::unique_ptr<rtc::PhysicalSocketServer> pss_; | 1548 std::unique_ptr<rtc::PhysicalSocketServer> pss_; |
| (...skipping 920 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2466 &sdp); | 2469 &sdp); |
| 2467 | 2470 |
| 2468 SessionDescriptionInterface* modified_offer = | 2471 SessionDescriptionInterface* modified_offer = |
| 2469 CreateSessionDescription(JsepSessionDescription::kOffer, sdp, NULL); | 2472 CreateSessionDescription(JsepSessionDescription::kOffer, sdp, NULL); |
| 2470 | 2473 |
| 2471 SetRemoteDescriptionWithoutError(modified_offer); | 2474 SetRemoteDescriptionWithoutError(modified_offer); |
| 2472 | 2475 |
| 2473 SessionDescriptionInterface* answer = CreateAnswer(); | 2476 SessionDescriptionInterface* answer = CreateAnswer(); |
| 2474 SetLocalDescriptionWithoutError(answer); | 2477 SetLocalDescriptionWithoutError(answer); |
| 2475 | 2478 |
| 2476 rtc::PacketTransportInterface* voice_transport_channel = | 2479 rtc::PacketTransportInternal* voice_transport_channel = |
| 2477 session_->voice_rtp_transport_channel(); | 2480 session_->voice_rtp_transport_channel(); |
| 2478 EXPECT_TRUE(voice_transport_channel != NULL); | 2481 EXPECT_TRUE(voice_transport_channel != NULL); |
| 2479 EXPECT_EQ(voice_transport_channel->debug_name(), | 2482 EXPECT_EQ(voice_transport_channel->debug_name(), |
| 2480 "audio_content_name " + | 2483 "audio_content_name " + |
| 2481 std::to_string(cricket::ICE_CANDIDATE_COMPONENT_RTP)); | 2484 std::to_string(cricket::ICE_CANDIDATE_COMPONENT_RTP)); |
| 2482 rtc::PacketTransportInterface* video_transport_channel = | 2485 rtc::PacketTransportInternal* video_transport_channel = |
| 2483 session_->video_rtp_transport_channel(); | 2486 session_->video_rtp_transport_channel(); |
| 2484 ASSERT_TRUE(video_transport_channel != NULL); | 2487 ASSERT_TRUE(video_transport_channel != NULL); |
| 2485 EXPECT_EQ(video_transport_channel->debug_name(), | 2488 EXPECT_EQ(video_transport_channel->debug_name(), |
| 2486 "video_content_name " + | 2489 "video_content_name " + |
| 2487 std::to_string(cricket::ICE_CANDIDATE_COMPONENT_RTP)); | 2490 std::to_string(cricket::ICE_CANDIDATE_COMPONENT_RTP)); |
| 2488 EXPECT_TRUE((video_channel_ = media_engine_->GetVideoChannel(0)) != NULL); | 2491 EXPECT_TRUE((video_channel_ = media_engine_->GetVideoChannel(0)) != NULL); |
| 2489 EXPECT_TRUE((voice_channel_ = media_engine_->GetVoiceChannel(0)) != NULL); | 2492 EXPECT_TRUE((voice_channel_ = media_engine_->GetVoiceChannel(0)) != NULL); |
| 2490 } | 2493 } |
| 2491 | 2494 |
| 2492 // Test that an offer contains the correct media content descriptions based on | 2495 // Test that an offer contains the correct media content descriptions based on |
| (...skipping 1916 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 4409 } | 4412 } |
| 4410 | 4413 |
| 4411 // TODO(bemasc): Add a TestIceStatesBundle with BUNDLE enabled. That test | 4414 // TODO(bemasc): Add a TestIceStatesBundle with BUNDLE enabled. That test |
| 4412 // currently fails because upon disconnection and reconnection OnIceComplete is | 4415 // currently fails because upon disconnection and reconnection OnIceComplete is |
| 4413 // called more than once without returning to IceGatheringGathering. | 4416 // called more than once without returning to IceGatheringGathering. |
| 4414 | 4417 |
| 4415 INSTANTIATE_TEST_CASE_P(WebRtcSessionTests, | 4418 INSTANTIATE_TEST_CASE_P(WebRtcSessionTests, |
| 4416 WebRtcSessionTest, | 4419 WebRtcSessionTest, |
| 4417 testing::Values(ALREADY_GENERATED, | 4420 testing::Values(ALREADY_GENERATED, |
| 4418 DTLS_IDENTITY_STORE)); | 4421 DTLS_IDENTITY_STORE)); |
| OLD | NEW |