OLD | NEW |
1 /* | 1 /* |
2 * libjingle | 2 * libjingle |
3 * Copyright 2013 Google Inc. | 3 * Copyright 2013 Google Inc. |
4 * | 4 * |
5 * Redistribution and use in source and binary forms, with or without | 5 * Redistribution and use in source and binary forms, with or without |
6 * modification, are permitted provided that the following conditions are met: | 6 * modification, are permitted provided that the following conditions are met: |
7 * | 7 * |
8 * 1. Redistributions of source code must retain the above copyright notice, | 8 * 1. Redistributions of source code must retain the above copyright notice, |
9 * this list of conditions and the following disclaimer. | 9 * this list of conditions and the following disclaimer. |
10 * 2. Redistributions in binary form must reproduce the above copyright notice, | 10 * 2. Redistributions in binary form must reproduce the above copyright notice, |
11 * this list of conditions and the following disclaimer in the documentation | 11 * this list of conditions and the following disclaimer in the documentation |
12 * and/or other materials provided with the distribution. | 12 * and/or other materials provided with the distribution. |
13 * 3. The name of the author may not be used to endorse or promote products | 13 * 3. The name of the author may not be used to endorse or promote products |
14 * derived from this software without specific prior written permission. | 14 * derived from this software without specific prior written permission. |
15 * | 15 * |
16 * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR IMPLIED | 16 * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR IMPLIED |
17 * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF | 17 * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF |
18 * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO | 18 * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO |
19 * EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, | 19 * EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, |
20 * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, | 20 * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, |
21 * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; | 21 * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; |
22 * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, | 22 * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, |
23 * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR | 23 * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR |
24 * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF | 24 * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF |
25 * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. | 25 * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. |
26 */ | 26 */ |
27 | 27 |
28 #include <utility> | 28 #include <utility> |
29 | 29 |
30 #include "talk/app/webrtc/fakeportallocatorfactory.h" | |
31 #include "talk/app/webrtc/test/fakedtlsidentitystore.h" | 30 #include "talk/app/webrtc/test/fakedtlsidentitystore.h" |
32 #include "talk/app/webrtc/test/fakeperiodicvideocapturer.h" | 31 #include "talk/app/webrtc/test/fakeperiodicvideocapturer.h" |
33 #include "talk/app/webrtc/test/mockpeerconnectionobservers.h" | 32 #include "talk/app/webrtc/test/mockpeerconnectionobservers.h" |
34 #include "talk/app/webrtc/test/peerconnectiontestwrapper.h" | 33 #include "talk/app/webrtc/test/peerconnectiontestwrapper.h" |
35 #include "talk/app/webrtc/videosourceinterface.h" | 34 #include "talk/app/webrtc/videosourceinterface.h" |
36 #include "webrtc/base/gunit.h" | 35 #include "webrtc/base/gunit.h" |
| 36 #include "webrtc/p2p/client/fakeportallocator.h" |
37 | 37 |
38 static const char kStreamLabelBase[] = "stream_label"; | 38 static const char kStreamLabelBase[] = "stream_label"; |
39 static const char kVideoTrackLabelBase[] = "video_track"; | 39 static const char kVideoTrackLabelBase[] = "video_track"; |
40 static const char kAudioTrackLabelBase[] = "audio_track"; | 40 static const char kAudioTrackLabelBase[] = "audio_track"; |
41 static const int kMaxWait = 10000; | 41 static const int kMaxWait = 10000; |
42 static const int kTestAudioFrameCount = 3; | 42 static const int kTestAudioFrameCount = 3; |
43 static const int kTestVideoFrameCount = 3; | 43 static const int kTestVideoFrameCount = 3; |
44 | 44 |
45 using webrtc::FakeConstraints; | 45 using webrtc::FakeConstraints; |
46 using webrtc::FakeVideoTrackRenderer; | 46 using webrtc::FakeVideoTrackRenderer; |
(...skipping 18 matching lines...) Expand all Loading... |
65 caller, &PeerConnectionTestWrapper::ReceiveAnswerSdp); | 65 caller, &PeerConnectionTestWrapper::ReceiveAnswerSdp); |
66 } | 66 } |
67 | 67 |
68 PeerConnectionTestWrapper::PeerConnectionTestWrapper(const std::string& name) | 68 PeerConnectionTestWrapper::PeerConnectionTestWrapper(const std::string& name) |
69 : name_(name) {} | 69 : name_(name) {} |
70 | 70 |
71 PeerConnectionTestWrapper::~PeerConnectionTestWrapper() {} | 71 PeerConnectionTestWrapper::~PeerConnectionTestWrapper() {} |
72 | 72 |
73 bool PeerConnectionTestWrapper::CreatePc( | 73 bool PeerConnectionTestWrapper::CreatePc( |
74 const MediaConstraintsInterface* constraints) { | 74 const MediaConstraintsInterface* constraints) { |
75 allocator_factory_ = webrtc::FakePortAllocatorFactory::Create(); | 75 rtc::scoped_ptr<cricket::PortAllocator> port_allocator( |
76 if (!allocator_factory_) { | 76 new cricket::FakePortAllocator(rtc::Thread::Current(), nullptr)); |
77 return false; | |
78 } | |
79 | 77 |
80 fake_audio_capture_module_ = FakeAudioCaptureModule::Create(); | 78 fake_audio_capture_module_ = FakeAudioCaptureModule::Create(); |
81 if (fake_audio_capture_module_ == NULL) { | 79 if (fake_audio_capture_module_ == NULL) { |
82 return false; | 80 return false; |
83 } | 81 } |
84 | 82 |
85 peer_connection_factory_ = webrtc::CreatePeerConnectionFactory( | 83 peer_connection_factory_ = webrtc::CreatePeerConnectionFactory( |
86 rtc::Thread::Current(), rtc::Thread::Current(), | 84 rtc::Thread::Current(), rtc::Thread::Current(), |
87 fake_audio_capture_module_, NULL, NULL); | 85 fake_audio_capture_module_, NULL, NULL); |
88 if (!peer_connection_factory_) { | 86 if (!peer_connection_factory_) { |
89 return false; | 87 return false; |
90 } | 88 } |
91 | 89 |
92 // CreatePeerConnection with IceServers. | 90 // CreatePeerConnection with RTCConfiguration. |
93 webrtc::PeerConnectionInterface::IceServers ice_servers; | 91 webrtc::PeerConnectionInterface::RTCConfiguration config; |
94 webrtc::PeerConnectionInterface::IceServer ice_server; | 92 webrtc::PeerConnectionInterface::IceServer ice_server; |
95 ice_server.uri = "stun:stun.l.google.com:19302"; | 93 ice_server.uri = "stun:stun.l.google.com:19302"; |
96 ice_servers.push_back(ice_server); | 94 config.servers.push_back(ice_server); |
97 rtc::scoped_ptr<webrtc::DtlsIdentityStoreInterface> dtls_identity_store( | 95 rtc::scoped_ptr<webrtc::DtlsIdentityStoreInterface> dtls_identity_store( |
98 rtc::SSLStreamAdapter::HaveDtlsSrtp() ? | 96 rtc::SSLStreamAdapter::HaveDtlsSrtp() ? |
99 new FakeDtlsIdentityStore() : nullptr); | 97 new FakeDtlsIdentityStore() : nullptr); |
100 peer_connection_ = peer_connection_factory_->CreatePeerConnection( | 98 peer_connection_ = peer_connection_factory_->CreatePeerConnection( |
101 ice_servers, constraints, allocator_factory_.get(), | 99 config, constraints, std::move(port_allocator), |
102 std::move(dtls_identity_store), this); | 100 std::move(dtls_identity_store), this); |
103 | 101 |
104 return peer_connection_.get() != NULL; | 102 return peer_connection_.get() != NULL; |
105 } | 103 } |
106 | 104 |
107 rtc::scoped_refptr<webrtc::DataChannelInterface> | 105 rtc::scoped_refptr<webrtc::DataChannelInterface> |
108 PeerConnectionTestWrapper::CreateDataChannel( | 106 PeerConnectionTestWrapper::CreateDataChannel( |
109 const std::string& label, | 107 const std::string& label, |
110 const webrtc::DataChannelInit& init) { | 108 const webrtc::DataChannelInit& init) { |
111 return peer_connection_->CreateDataChannel(label, &init); | 109 return peer_connection_->CreateDataChannel(label, &init); |
(...skipping 178 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
290 peer_connection_factory_->CreateVideoSource( | 288 peer_connection_factory_->CreateVideoSource( |
291 new webrtc::FakePeriodicVideoCapturer(), &constraints); | 289 new webrtc::FakePeriodicVideoCapturer(), &constraints); |
292 std::string videotrack_label = label + kVideoTrackLabelBase; | 290 std::string videotrack_label = label + kVideoTrackLabelBase; |
293 rtc::scoped_refptr<webrtc::VideoTrackInterface> video_track( | 291 rtc::scoped_refptr<webrtc::VideoTrackInterface> video_track( |
294 peer_connection_factory_->CreateVideoTrack(videotrack_label, source)); | 292 peer_connection_factory_->CreateVideoTrack(videotrack_label, source)); |
295 | 293 |
296 stream->AddTrack(video_track); | 294 stream->AddTrack(video_track); |
297 } | 295 } |
298 return stream; | 296 return stream; |
299 } | 297 } |
OLD | NEW |