| 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 155 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 203 std::vector<PeerConnectionInterface::IceConnectionState> | 203 std::vector<PeerConnectionInterface::IceConnectionState> |
| 204 ice_connection_state_history_; | 204 ice_connection_state_history_; |
| 205 size_t num_candidates_removed_ = 0; | 205 size_t num_candidates_removed_ = 0; |
| 206 }; | 206 }; |
| 207 | 207 |
| 208 // Used for tests in this file to verify that WebRtcSession responds to signals | 208 // Used for tests in this file to verify that WebRtcSession responds to signals |
| 209 // from the SctpTransport correctly, and calls Start with the correct | 209 // from the SctpTransport correctly, and calls Start with the correct |
| 210 // local/remote ports. | 210 // local/remote ports. |
| 211 class FakeSctpTransport : public cricket::SctpTransportInternal { | 211 class FakeSctpTransport : public cricket::SctpTransportInternal { |
| 212 public: | 212 public: |
| 213 void SetTransportChannel(rtc::PacketTransportInterface* channel) override {} | 213 void SetTransportChannel(rtc::PacketTransportInternal* channel) override {} |
| 214 bool Start(int local_port, int remote_port) override { | 214 bool Start(int local_port, int remote_port) override { |
| 215 local_port_ = local_port; | 215 local_port_ = local_port; |
| 216 remote_port_ = remote_port; | 216 remote_port_ = remote_port; |
| 217 return true; | 217 return true; |
| 218 } | 218 } |
| 219 bool OpenStream(int sid) override { return true; } | 219 bool OpenStream(int sid) override { return true; } |
| 220 bool ResetStream(int sid) override { return true; } | 220 bool ResetStream(int sid) override { return true; } |
| 221 bool SendData(const cricket::SendDataParams& params, | 221 bool SendData(const cricket::SendDataParams& params, |
| 222 const rtc::CopyOnWriteBuffer& payload, | 222 const rtc::CopyOnWriteBuffer& payload, |
| 223 cricket::SendDataResult* result = nullptr) override { | 223 cricket::SendDataResult* result = nullptr) override { |
| 224 return true; | 224 return true; |
| 225 } | 225 } |
| 226 bool ReadyToSendData() override { return true; } | 226 bool ReadyToSendData() override { return true; } |
| 227 void set_debug_name_for_testing(const char* debug_name) override {} | 227 void set_debug_name_for_testing(const char* debug_name) override {} |
| 228 | 228 |
| 229 int local_port() const { return local_port_; } | 229 int local_port() const { return local_port_; } |
| 230 int remote_port() const { return remote_port_; } | 230 int remote_port() const { return remote_port_; } |
| 231 | 231 |
| 232 private: | 232 private: |
| 233 int local_port_ = -1; | 233 int local_port_ = -1; |
| 234 int remote_port_ = -1; | 234 int remote_port_ = -1; |
| 235 }; | 235 }; |
| 236 | 236 |
| 237 class FakeSctpTransportFactory : public cricket::SctpTransportInternalFactory { | 237 class FakeSctpTransportFactory : public cricket::SctpTransportInternalFactory { |
| 238 public: | 238 public: |
| 239 std::unique_ptr<cricket::SctpTransportInternal> CreateSctpTransport( | 239 std::unique_ptr<cricket::SctpTransportInternal> CreateSctpTransport( |
| 240 rtc::PacketTransportInterface*) override { | 240 rtc::PacketTransportInternal*) override { |
| 241 last_fake_sctp_transport_ = new FakeSctpTransport(); | 241 last_fake_sctp_transport_ = new FakeSctpTransport(); |
| 242 return std::unique_ptr<cricket::SctpTransportInternal>( | 242 return std::unique_ptr<cricket::SctpTransportInternal>( |
| 243 last_fake_sctp_transport_); | 243 last_fake_sctp_transport_); |
| 244 } | 244 } |
| 245 | 245 |
| 246 FakeSctpTransport* last_fake_sctp_transport() { | 246 FakeSctpTransport* last_fake_sctp_transport() { |
| 247 return last_fake_sctp_transport_; | 247 return last_fake_sctp_transport_; |
| 248 } | 248 } |
| 249 | 249 |
| 250 private: | 250 private: |
| (...skipping 17 matching lines...) Expand all Loading... |
| 268 signaling_thread, | 268 signaling_thread, |
| 269 port_allocator, | 269 port_allocator, |
| 270 std::move(transport_controller), | 270 std::move(transport_controller), |
| 271 std::move(sctp_factory)) { | 271 std::move(sctp_factory)) { |
| 272 RegisterIceObserver(ice_observer); | 272 RegisterIceObserver(ice_observer); |
| 273 } | 273 } |
| 274 virtual ~WebRtcSessionForTest() {} | 274 virtual ~WebRtcSessionForTest() {} |
| 275 | 275 |
| 276 // Note that these methods are only safe to use if the signaling thread | 276 // Note that these methods are only safe to use if the signaling thread |
| 277 // is the same as the worker thread | 277 // is the same as the worker thread |
| 278 rtc::PacketTransportInterface* voice_rtp_transport_channel() { | 278 rtc::PacketTransportInternal* voice_rtp_transport_channel() { |
| 279 return rtp_transport_channel(voice_channel()); | 279 return rtp_transport_channel(voice_channel()); |
| 280 } | 280 } |
| 281 | 281 |
| 282 rtc::PacketTransportInterface* voice_rtcp_transport_channel() { | 282 rtc::PacketTransportInternal* voice_rtcp_transport_channel() { |
| 283 return rtcp_transport_channel(voice_channel()); | 283 return rtcp_transport_channel(voice_channel()); |
| 284 } | 284 } |
| 285 | 285 |
| 286 rtc::PacketTransportInterface* video_rtp_transport_channel() { | 286 rtc::PacketTransportInternal* video_rtp_transport_channel() { |
| 287 return rtp_transport_channel(video_channel()); | 287 return rtp_transport_channel(video_channel()); |
| 288 } | 288 } |
| 289 | 289 |
| 290 rtc::PacketTransportInterface* video_rtcp_transport_channel() { | 290 rtc::PacketTransportInternal* video_rtcp_transport_channel() { |
| 291 return rtcp_transport_channel(video_channel()); | 291 return rtcp_transport_channel(video_channel()); |
| 292 } | 292 } |
| 293 | 293 |
| 294 private: | 294 private: |
| 295 rtc::PacketTransportInterface* rtp_transport_channel( | 295 rtc::PacketTransportInternal* rtp_transport_channel( |
| 296 cricket::BaseChannel* ch) { | 296 cricket::BaseChannel* ch) { |
| 297 if (!ch) { | 297 if (!ch) { |
| 298 return nullptr; | 298 return nullptr; |
| 299 } | 299 } |
| 300 return ch->rtp_dtls_transport(); | 300 return ch->rtp_dtls_transport(); |
| 301 } | 301 } |
| 302 | 302 |
| 303 rtc::PacketTransportInterface* rtcp_transport_channel( | 303 rtc::PacketTransportInternal* rtcp_transport_channel( |
| 304 cricket::BaseChannel* ch) { | 304 cricket::BaseChannel* ch) { |
| 305 if (!ch) { | 305 if (!ch) { |
| 306 return nullptr; | 306 return nullptr; |
| 307 } | 307 } |
| 308 return ch->rtcp_dtls_transport(); | 308 return ch->rtcp_dtls_transport(); |
| 309 } | 309 } |
| 310 }; | 310 }; |
| 311 | 311 |
| 312 class WebRtcSessionCreateSDPObserverForTest | 312 class WebRtcSessionCreateSDPObserverForTest |
| 313 : public rtc::RefCountedObject<CreateSessionDescriptionObserver> { | 313 : public rtc::RefCountedObject<CreateSessionDescriptionObserver> { |
| (...skipping 2123 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2437 &sdp); | 2437 &sdp); |
| 2438 | 2438 |
| 2439 SessionDescriptionInterface* modified_offer = | 2439 SessionDescriptionInterface* modified_offer = |
| 2440 CreateSessionDescription(JsepSessionDescription::kOffer, sdp, NULL); | 2440 CreateSessionDescription(JsepSessionDescription::kOffer, sdp, NULL); |
| 2441 | 2441 |
| 2442 SetRemoteDescriptionWithoutError(modified_offer); | 2442 SetRemoteDescriptionWithoutError(modified_offer); |
| 2443 | 2443 |
| 2444 SessionDescriptionInterface* answer = CreateAnswer(); | 2444 SessionDescriptionInterface* answer = CreateAnswer(); |
| 2445 SetLocalDescriptionWithoutError(answer); | 2445 SetLocalDescriptionWithoutError(answer); |
| 2446 | 2446 |
| 2447 rtc::PacketTransportInterface* voice_transport_channel = | 2447 rtc::PacketTransportInternal* voice_transport_channel = |
| 2448 session_->voice_rtp_transport_channel(); | 2448 session_->voice_rtp_transport_channel(); |
| 2449 EXPECT_TRUE(voice_transport_channel != NULL); | 2449 EXPECT_TRUE(voice_transport_channel != NULL); |
| 2450 EXPECT_EQ(voice_transport_channel->debug_name(), | 2450 EXPECT_EQ(voice_transport_channel->debug_name(), |
| 2451 "audio_content_name " + | 2451 "audio_content_name " + |
| 2452 std::to_string(cricket::ICE_CANDIDATE_COMPONENT_RTP)); | 2452 std::to_string(cricket::ICE_CANDIDATE_COMPONENT_RTP)); |
| 2453 rtc::PacketTransportInterface* video_transport_channel = | 2453 rtc::PacketTransportInternal* video_transport_channel = |
| 2454 session_->video_rtp_transport_channel(); | 2454 session_->video_rtp_transport_channel(); |
| 2455 ASSERT_TRUE(video_transport_channel != NULL); | 2455 ASSERT_TRUE(video_transport_channel != NULL); |
| 2456 EXPECT_EQ(video_transport_channel->debug_name(), | 2456 EXPECT_EQ(video_transport_channel->debug_name(), |
| 2457 "video_content_name " + | 2457 "video_content_name " + |
| 2458 std::to_string(cricket::ICE_CANDIDATE_COMPONENT_RTP)); | 2458 std::to_string(cricket::ICE_CANDIDATE_COMPONENT_RTP)); |
| 2459 EXPECT_TRUE((video_channel_ = media_engine_->GetVideoChannel(0)) != NULL); | 2459 EXPECT_TRUE((video_channel_ = media_engine_->GetVideoChannel(0)) != NULL); |
| 2460 EXPECT_TRUE((voice_channel_ = media_engine_->GetVoiceChannel(0)) != NULL); | 2460 EXPECT_TRUE((voice_channel_ = media_engine_->GetVoiceChannel(0)) != NULL); |
| 2461 } | 2461 } |
| 2462 | 2462 |
| 2463 // Test that an offer contains the correct media content descriptions based on | 2463 // Test that an offer contains the correct media content descriptions based on |
| (...skipping 1875 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 4339 } | 4339 } |
| 4340 | 4340 |
| 4341 // TODO(bemasc): Add a TestIceStatesBundle with BUNDLE enabled. That test | 4341 // TODO(bemasc): Add a TestIceStatesBundle with BUNDLE enabled. That test |
| 4342 // currently fails because upon disconnection and reconnection OnIceComplete is | 4342 // currently fails because upon disconnection and reconnection OnIceComplete is |
| 4343 // called more than once without returning to IceGatheringGathering. | 4343 // called more than once without returning to IceGatheringGathering. |
| 4344 | 4344 |
| 4345 INSTANTIATE_TEST_CASE_P(WebRtcSessionTests, | 4345 INSTANTIATE_TEST_CASE_P(WebRtcSessionTests, |
| 4346 WebRtcSessionTest, | 4346 WebRtcSessionTest, |
| 4347 testing::Values(ALREADY_GENERATED, | 4347 testing::Values(ALREADY_GENERATED, |
| 4348 DTLS_IDENTITY_STORE)); | 4348 DTLS_IDENTITY_STORE)); |
| OLD | NEW |