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 "talk/app/webrtc/fakeportallocatorfactory.h" | |
29 #include "talk/app/webrtc/test/fakedtlsidentitystore.h" | 28 #include "talk/app/webrtc/test/fakedtlsidentitystore.h" |
30 #include "talk/app/webrtc/test/fakeperiodicvideocapturer.h" | 29 #include "talk/app/webrtc/test/fakeperiodicvideocapturer.h" |
31 #include "talk/app/webrtc/test/mockpeerconnectionobservers.h" | 30 #include "talk/app/webrtc/test/mockpeerconnectionobservers.h" |
32 #include "talk/app/webrtc/test/peerconnectiontestwrapper.h" | 31 #include "talk/app/webrtc/test/peerconnectiontestwrapper.h" |
33 #include "talk/app/webrtc/videosourceinterface.h" | 32 #include "talk/app/webrtc/videosourceinterface.h" |
34 #include "webrtc/base/gunit.h" | 33 #include "webrtc/base/gunit.h" |
| 34 #include "webrtc/p2p/client/fakeportallocator.h" |
35 | 35 |
36 static const char kStreamLabelBase[] = "stream_label"; | 36 static const char kStreamLabelBase[] = "stream_label"; |
37 static const char kVideoTrackLabelBase[] = "video_track"; | 37 static const char kVideoTrackLabelBase[] = "video_track"; |
38 static const char kAudioTrackLabelBase[] = "audio_track"; | 38 static const char kAudioTrackLabelBase[] = "audio_track"; |
39 static const int kMaxWait = 10000; | 39 static const int kMaxWait = 10000; |
40 static const int kTestAudioFrameCount = 3; | 40 static const int kTestAudioFrameCount = 3; |
41 static const int kTestVideoFrameCount = 3; | 41 static const int kTestVideoFrameCount = 3; |
42 | 42 |
43 using webrtc::FakeConstraints; | 43 using webrtc::FakeConstraints; |
44 using webrtc::FakeVideoTrackRenderer; | 44 using webrtc::FakeVideoTrackRenderer; |
(...skipping 18 matching lines...) Expand all Loading... |
63 caller, &PeerConnectionTestWrapper::ReceiveAnswerSdp); | 63 caller, &PeerConnectionTestWrapper::ReceiveAnswerSdp); |
64 } | 64 } |
65 | 65 |
66 PeerConnectionTestWrapper::PeerConnectionTestWrapper(const std::string& name) | 66 PeerConnectionTestWrapper::PeerConnectionTestWrapper(const std::string& name) |
67 : name_(name) {} | 67 : name_(name) {} |
68 | 68 |
69 PeerConnectionTestWrapper::~PeerConnectionTestWrapper() {} | 69 PeerConnectionTestWrapper::~PeerConnectionTestWrapper() {} |
70 | 70 |
71 bool PeerConnectionTestWrapper::CreatePc( | 71 bool PeerConnectionTestWrapper::CreatePc( |
72 const MediaConstraintsInterface* constraints) { | 72 const MediaConstraintsInterface* constraints) { |
73 allocator_factory_ = webrtc::FakePortAllocatorFactory::Create(); | 73 rtc::scoped_ptr<cricket::PortAllocator> port_allocator( |
74 if (!allocator_factory_) { | 74 new cricket::FakePortAllocator(rtc::Thread::Current(), nullptr)); |
75 return false; | |
76 } | |
77 | 75 |
78 fake_audio_capture_module_ = FakeAudioCaptureModule::Create(); | 76 fake_audio_capture_module_ = FakeAudioCaptureModule::Create(); |
79 if (fake_audio_capture_module_ == NULL) { | 77 if (fake_audio_capture_module_ == NULL) { |
80 return false; | 78 return false; |
81 } | 79 } |
82 | 80 |
83 peer_connection_factory_ = webrtc::CreatePeerConnectionFactory( | 81 peer_connection_factory_ = webrtc::CreatePeerConnectionFactory( |
84 rtc::Thread::Current(), rtc::Thread::Current(), | 82 rtc::Thread::Current(), rtc::Thread::Current(), |
85 fake_audio_capture_module_, NULL, NULL); | 83 fake_audio_capture_module_, NULL, NULL); |
86 if (!peer_connection_factory_) { | 84 if (!peer_connection_factory_) { |
87 return false; | 85 return false; |
88 } | 86 } |
89 | 87 |
90 // CreatePeerConnection with IceServers. | 88 // CreatePeerConnection with RTCConfiguration. |
91 webrtc::PeerConnectionInterface::IceServers ice_servers; | 89 webrtc::PeerConnectionInterface::RTCConfiguration config; |
92 webrtc::PeerConnectionInterface::IceServer ice_server; | 90 webrtc::PeerConnectionInterface::IceServer ice_server; |
93 ice_server.uri = "stun:stun.l.google.com:19302"; | 91 ice_server.uri = "stun:stun.l.google.com:19302"; |
94 ice_servers.push_back(ice_server); | 92 config.servers.push_back(ice_server); |
95 rtc::scoped_ptr<webrtc::DtlsIdentityStoreInterface> dtls_identity_store( | 93 rtc::scoped_ptr<webrtc::DtlsIdentityStoreInterface> dtls_identity_store( |
96 rtc::SSLStreamAdapter::HaveDtlsSrtp() ? | 94 rtc::SSLStreamAdapter::HaveDtlsSrtp() ? |
97 new FakeDtlsIdentityStore() : nullptr); | 95 new FakeDtlsIdentityStore() : nullptr); |
98 peer_connection_ = peer_connection_factory_->CreatePeerConnection( | 96 peer_connection_ = peer_connection_factory_->CreatePeerConnection( |
99 ice_servers, constraints, allocator_factory_.get(), | 97 config, constraints, std::move(port_allocator), |
100 dtls_identity_store.Pass(), this); | 98 std::move(dtls_identity_store), this); |
101 | 99 |
102 return peer_connection_.get() != NULL; | 100 return peer_connection_.get() != NULL; |
103 } | 101 } |
104 | 102 |
105 rtc::scoped_refptr<webrtc::DataChannelInterface> | 103 rtc::scoped_refptr<webrtc::DataChannelInterface> |
106 PeerConnectionTestWrapper::CreateDataChannel( | 104 PeerConnectionTestWrapper::CreateDataChannel( |
107 const std::string& label, | 105 const std::string& label, |
108 const webrtc::DataChannelInit& init) { | 106 const webrtc::DataChannelInit& init) { |
109 return peer_connection_->CreateDataChannel(label, &init); | 107 return peer_connection_->CreateDataChannel(label, &init); |
110 } | 108 } |
(...skipping 177 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
288 peer_connection_factory_->CreateVideoSource( | 286 peer_connection_factory_->CreateVideoSource( |
289 new webrtc::FakePeriodicVideoCapturer(), &constraints); | 287 new webrtc::FakePeriodicVideoCapturer(), &constraints); |
290 std::string videotrack_label = label + kVideoTrackLabelBase; | 288 std::string videotrack_label = label + kVideoTrackLabelBase; |
291 rtc::scoped_refptr<webrtc::VideoTrackInterface> video_track( | 289 rtc::scoped_refptr<webrtc::VideoTrackInterface> video_track( |
292 peer_connection_factory_->CreateVideoTrack(videotrack_label, source)); | 290 peer_connection_factory_->CreateVideoTrack(videotrack_label, source)); |
293 | 291 |
294 stream->AddTrack(video_track); | 292 stream->AddTrack(video_track); |
295 } | 293 } |
296 return stream; | 294 return stream; |
297 } | 295 } |
OLD | NEW |