| OLD | NEW |
| 1 /* | 1 /* |
| 2 * Copyright 2013 The WebRTC project authors. All Rights Reserved. | 2 * Copyright 2013 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 37 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 48 } | 48 } |
| 49 | 49 |
| 50 PeerConnectionTestWrapper::PeerConnectionTestWrapper(const std::string& name, | 50 PeerConnectionTestWrapper::PeerConnectionTestWrapper(const std::string& name, |
| 51 rtc::Thread* worker_thread) | 51 rtc::Thread* worker_thread) |
| 52 : name_(name), worker_thread_(worker_thread) {} | 52 : name_(name), worker_thread_(worker_thread) {} |
| 53 | 53 |
| 54 PeerConnectionTestWrapper::~PeerConnectionTestWrapper() {} | 54 PeerConnectionTestWrapper::~PeerConnectionTestWrapper() {} |
| 55 | 55 |
| 56 bool PeerConnectionTestWrapper::CreatePc( | 56 bool PeerConnectionTestWrapper::CreatePc( |
| 57 const MediaConstraintsInterface* constraints) { | 57 const MediaConstraintsInterface* constraints) { |
| 58 rtc::scoped_ptr<cricket::PortAllocator> port_allocator( | 58 std::unique_ptr<cricket::PortAllocator> port_allocator( |
| 59 new cricket::FakePortAllocator(worker_thread_, nullptr)); | 59 new cricket::FakePortAllocator(worker_thread_, nullptr)); |
| 60 | 60 |
| 61 fake_audio_capture_module_ = FakeAudioCaptureModule::Create(); | 61 fake_audio_capture_module_ = FakeAudioCaptureModule::Create(); |
| 62 if (fake_audio_capture_module_ == NULL) { | 62 if (fake_audio_capture_module_ == NULL) { |
| 63 return false; | 63 return false; |
| 64 } | 64 } |
| 65 | 65 |
| 66 peer_connection_factory_ = webrtc::CreatePeerConnectionFactory( | 66 peer_connection_factory_ = webrtc::CreatePeerConnectionFactory( |
| 67 worker_thread_, rtc::Thread::Current(), fake_audio_capture_module_, NULL, | 67 worker_thread_, rtc::Thread::Current(), fake_audio_capture_module_, NULL, |
| 68 NULL); | 68 NULL); |
| 69 if (!peer_connection_factory_) { | 69 if (!peer_connection_factory_) { |
| 70 return false; | 70 return false; |
| 71 } | 71 } |
| 72 | 72 |
| 73 // CreatePeerConnection with RTCConfiguration. | 73 // CreatePeerConnection with RTCConfiguration. |
| 74 webrtc::PeerConnectionInterface::RTCConfiguration config; | 74 webrtc::PeerConnectionInterface::RTCConfiguration config; |
| 75 webrtc::PeerConnectionInterface::IceServer ice_server; | 75 webrtc::PeerConnectionInterface::IceServer ice_server; |
| 76 ice_server.uri = "stun:stun.l.google.com:19302"; | 76 ice_server.uri = "stun:stun.l.google.com:19302"; |
| 77 config.servers.push_back(ice_server); | 77 config.servers.push_back(ice_server); |
| 78 rtc::scoped_ptr<webrtc::DtlsIdentityStoreInterface> dtls_identity_store( | 78 std::unique_ptr<webrtc::DtlsIdentityStoreInterface> dtls_identity_store( |
| 79 rtc::SSLStreamAdapter::HaveDtlsSrtp() ? | 79 rtc::SSLStreamAdapter::HaveDtlsSrtp() ? new FakeDtlsIdentityStore() |
| 80 new FakeDtlsIdentityStore() : nullptr); | 80 : nullptr); |
| 81 peer_connection_ = peer_connection_factory_->CreatePeerConnection( | 81 peer_connection_ = peer_connection_factory_->CreatePeerConnection( |
| 82 config, constraints, std::move(port_allocator), | 82 config, constraints, std::move(port_allocator), |
| 83 std::move(dtls_identity_store), this); | 83 std::move(dtls_identity_store), this); |
| 84 | 84 |
| 85 return peer_connection_.get() != NULL; | 85 return peer_connection_.get() != NULL; |
| 86 } | 86 } |
| 87 | 87 |
| 88 rtc::scoped_refptr<webrtc::DataChannelInterface> | 88 rtc::scoped_refptr<webrtc::DataChannelInterface> |
| 89 PeerConnectionTestWrapper::CreateDataChannel( | 89 PeerConnectionTestWrapper::CreateDataChannel( |
| 90 const std::string& label, | 90 const std::string& label, |
| (...skipping 20 matching lines...) Expand all Loading... |
| 111 sdp); | 111 sdp); |
| 112 } | 112 } |
| 113 | 113 |
| 114 void PeerConnectionTestWrapper::OnDataChannel( | 114 void PeerConnectionTestWrapper::OnDataChannel( |
| 115 webrtc::DataChannelInterface* data_channel) { | 115 webrtc::DataChannelInterface* data_channel) { |
| 116 SignalOnDataChannel(data_channel); | 116 SignalOnDataChannel(data_channel); |
| 117 } | 117 } |
| 118 | 118 |
| 119 void PeerConnectionTestWrapper::OnSuccess(SessionDescriptionInterface* desc) { | 119 void PeerConnectionTestWrapper::OnSuccess(SessionDescriptionInterface* desc) { |
| 120 // This callback should take the ownership of |desc|. | 120 // This callback should take the ownership of |desc|. |
| 121 rtc::scoped_ptr<SessionDescriptionInterface> owned_desc(desc); | 121 std::unique_ptr<SessionDescriptionInterface> owned_desc(desc); |
| 122 std::string sdp; | 122 std::string sdp; |
| 123 EXPECT_TRUE(desc->ToString(&sdp)); | 123 EXPECT_TRUE(desc->ToString(&sdp)); |
| 124 | 124 |
| 125 LOG(LS_INFO) << "PeerConnectionTestWrapper " << name_ | 125 LOG(LS_INFO) << "PeerConnectionTestWrapper " << name_ |
| 126 << ": " << desc->type() << " sdp created: " << sdp; | 126 << ": " << desc->type() << " sdp created: " << sdp; |
| 127 | 127 |
| 128 // Give the user a chance to modify sdp for testing. | 128 // Give the user a chance to modify sdp for testing. |
| 129 SignalOnSdpCreated(&sdp); | 129 SignalOnSdpCreated(&sdp); |
| 130 | 130 |
| 131 SetLocalDescription(desc->type(), sdp); | 131 SetLocalDescription(desc->type(), sdp); |
| (...skipping 44 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 176 rtc::scoped_refptr<MockSetSessionDescriptionObserver> | 176 rtc::scoped_refptr<MockSetSessionDescriptionObserver> |
| 177 observer(new rtc::RefCountedObject< | 177 observer(new rtc::RefCountedObject< |
| 178 MockSetSessionDescriptionObserver>()); | 178 MockSetSessionDescriptionObserver>()); |
| 179 peer_connection_->SetRemoteDescription( | 179 peer_connection_->SetRemoteDescription( |
| 180 observer, webrtc::CreateSessionDescription(type, sdp, NULL)); | 180 observer, webrtc::CreateSessionDescription(type, sdp, NULL)); |
| 181 } | 181 } |
| 182 | 182 |
| 183 void PeerConnectionTestWrapper::AddIceCandidate(const std::string& sdp_mid, | 183 void PeerConnectionTestWrapper::AddIceCandidate(const std::string& sdp_mid, |
| 184 int sdp_mline_index, | 184 int sdp_mline_index, |
| 185 const std::string& candidate) { | 185 const std::string& candidate) { |
| 186 rtc::scoped_ptr<webrtc::IceCandidateInterface> owned_candidate( | 186 std::unique_ptr<webrtc::IceCandidateInterface> owned_candidate( |
| 187 webrtc::CreateIceCandidate(sdp_mid, sdp_mline_index, candidate, NULL)); | 187 webrtc::CreateIceCandidate(sdp_mid, sdp_mline_index, candidate, NULL)); |
| 188 EXPECT_TRUE(peer_connection_->AddIceCandidate(owned_candidate.get())); | 188 EXPECT_TRUE(peer_connection_->AddIceCandidate(owned_candidate.get())); |
| 189 } | 189 } |
| 190 | 190 |
| 191 void PeerConnectionTestWrapper::WaitForCallEstablished() { | 191 void PeerConnectionTestWrapper::WaitForCallEstablished() { |
| 192 WaitForConnection(); | 192 WaitForConnection(); |
| 193 WaitForAudio(); | 193 WaitForAudio(); |
| 194 WaitForVideo(); | 194 WaitForVideo(); |
| 195 } | 195 } |
| 196 | 196 |
| (...skipping 74 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 271 peer_connection_factory_->CreateVideoSource( | 271 peer_connection_factory_->CreateVideoSource( |
| 272 new webrtc::FakePeriodicVideoCapturer(), &constraints); | 272 new webrtc::FakePeriodicVideoCapturer(), &constraints); |
| 273 std::string videotrack_label = label + kVideoTrackLabelBase; | 273 std::string videotrack_label = label + kVideoTrackLabelBase; |
| 274 rtc::scoped_refptr<webrtc::VideoTrackInterface> video_track( | 274 rtc::scoped_refptr<webrtc::VideoTrackInterface> video_track( |
| 275 peer_connection_factory_->CreateVideoTrack(videotrack_label, source)); | 275 peer_connection_factory_->CreateVideoTrack(videotrack_label, source)); |
| 276 | 276 |
| 277 stream->AddTrack(video_track); | 277 stream->AddTrack(video_track); |
| 278 } | 278 } |
| 279 return stream; | 279 return stream; |
| 280 } | 280 } |
| OLD | NEW |