Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(340)

Side by Side Diff: talk/app/webrtc/portallocatorfactory.cc

Issue 1520963002: Removing webrtc::PortAllocatorFactoryInterface. (Closed) Base URL: https://chromium.googlesource.com/external/webrtc.git@master
Patch Set: Using new CreatePeerConnection method in objc wrapper. Created 5 years ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
1 /* 1 /*
2 * libjingle 2 * libjingle
3 * Copyright 2004--2011 Google Inc. 3 * Copyright 2011 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 // TODO(deadbeef): Remove this file once chromium build files no longer
28 // reference it.
27 29
28 #include "talk/app/webrtc/portallocatorfactory.h" 30 #include "talk/app/webrtc/portallocatorfactory.h"
29
30 #include "webrtc/p2p/base/basicpacketsocketfactory.h"
31 #include "webrtc/p2p/client/basicportallocator.h"
32 #include "webrtc/base/logging.h"
33 #include "webrtc/base/network.h"
34 #include "webrtc/base/thread.h"
35
36 namespace webrtc {
37
38 using rtc::scoped_ptr;
39
40 rtc::scoped_refptr<PortAllocatorFactoryInterface>
41 PortAllocatorFactory::Create(
42 rtc::Thread* worker_thread) {
43 rtc::RefCountedObject<PortAllocatorFactory>* allocator =
44 new rtc::RefCountedObject<PortAllocatorFactory>(worker_thread);
45 return allocator;
46 }
47
48 PortAllocatorFactory::PortAllocatorFactory(rtc::Thread* worker_thread)
49 : network_manager_(new rtc::BasicNetworkManager()),
50 socket_factory_(new rtc::BasicPacketSocketFactory(worker_thread)) {
51 }
52
53 PortAllocatorFactory::~PortAllocatorFactory() {}
54
55 void PortAllocatorFactory::SetNetworkIgnoreMask(int network_ignore_mask) {
56 network_manager_->set_network_ignore_mask(network_ignore_mask);
57 }
58
59 cricket::PortAllocator* PortAllocatorFactory::CreatePortAllocator(
60 const std::vector<StunConfiguration>& stun,
61 const std::vector<TurnConfiguration>& turn) {
62 cricket::ServerAddresses stun_hosts;
63 typedef std::vector<StunConfiguration>::const_iterator StunIt;
64 for (StunIt stun_it = stun.begin(); stun_it != stun.end(); ++stun_it) {
65 stun_hosts.insert(stun_it->server);
66 }
67
68 scoped_ptr<cricket::BasicPortAllocator> allocator(
69 new cricket::BasicPortAllocator(
70 network_manager_.get(), socket_factory_.get(), stun_hosts));
71
72 for (size_t i = 0; i < turn.size(); ++i) {
73 cricket::RelayCredentials credentials(turn[i].username, turn[i].password);
74 cricket::RelayServerConfig turn_server(cricket::RELAY_TURN);
75 cricket::ProtocolType protocol;
76 if (cricket::StringToProto(turn[i].transport_type.c_str(), &protocol)) {
77 turn_server.ports.push_back(
78 cricket::ProtocolAddress(turn[i].server, protocol, turn[i].secure));
79 turn_server.credentials = credentials;
80 // First in the list gets highest priority.
81 turn_server.priority = static_cast<int>(turn.size() - i - 1);
82 allocator->AddTurnServer(turn_server);
83 } else {
84 LOG(LS_WARNING) << "Ignoring TURN server " << turn[i].server << ". "
85 << "Reason= Incorrect " << turn[i].transport_type
86 << " transport parameter.";
87 }
88 }
89 return allocator.release();
90 }
91
92 } // namespace webrtc
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698