OLD | NEW |
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. |
2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
4 | 4 |
5 #include "jingle/glue/utils.h" | 5 #include "jingle/glue/utils.h" |
6 | 6 |
7 #include "base/json/json_reader.h" | 7 #include "base/json/json_reader.h" |
8 #include "base/json/json_writer.h" | 8 #include "base/json/json_writer.h" |
9 #include "base/logging.h" | 9 #include "base/logging.h" |
10 #include "base/memory/scoped_ptr.h" | 10 #include "base/memory/scoped_ptr.h" |
11 #include "base/values.h" | 11 #include "base/values.h" |
12 #include "net/base/ip_endpoint.h" | 12 #include "net/base/ip_endpoint.h" |
13 #include "net/base/net_util.h" | 13 #include "net/base/net_util.h" |
14 #include "third_party/libjingle/source/talk/base/byteorder.h" | |
15 #include "third_party/libjingle/source/talk/base/socketaddress.h" | |
16 #include "third_party/libjingle/source/talk/p2p/base/candidate.h" | 14 #include "third_party/libjingle/source/talk/p2p/base/candidate.h" |
| 15 #include "third_party/webrtc/base/byteorder.h" |
| 16 #include "third_party/webrtc/base/socketaddress.h" |
17 | 17 |
18 namespace jingle_glue { | 18 namespace jingle_glue { |
19 | 19 |
20 bool IPEndPointToSocketAddress(const net::IPEndPoint& ip_endpoint, | 20 bool IPEndPointToSocketAddress(const net::IPEndPoint& ip_endpoint, |
21 talk_base::SocketAddress* address) { | 21 rtc::SocketAddress* address) { |
22 sockaddr_storage addr; | 22 sockaddr_storage addr; |
23 socklen_t len = sizeof(addr); | 23 socklen_t len = sizeof(addr); |
24 return ip_endpoint.ToSockAddr(reinterpret_cast<sockaddr*>(&addr), &len) && | 24 return ip_endpoint.ToSockAddr(reinterpret_cast<sockaddr*>(&addr), &len) && |
25 talk_base::SocketAddressFromSockAddrStorage(addr, address); | 25 rtc::SocketAddressFromSockAddrStorage(addr, address); |
26 } | 26 } |
27 | 27 |
28 bool SocketAddressToIPEndPoint(const talk_base::SocketAddress& address, | 28 bool SocketAddressToIPEndPoint(const rtc::SocketAddress& address, |
29 net::IPEndPoint* ip_endpoint) { | 29 net::IPEndPoint* ip_endpoint) { |
30 sockaddr_storage addr; | 30 sockaddr_storage addr; |
31 int size = address.ToSockAddrStorage(&addr); | 31 int size = address.ToSockAddrStorage(&addr); |
32 return (size > 0) && | 32 return (size > 0) && |
33 ip_endpoint->FromSockAddr(reinterpret_cast<sockaddr*>(&addr), size); | 33 ip_endpoint->FromSockAddr(reinterpret_cast<sockaddr*>(&addr), size); |
34 } | 34 } |
35 | 35 |
36 std::string SerializeP2PCandidate(const cricket::Candidate& candidate) { | 36 std::string SerializeP2PCandidate(const cricket::Candidate& candidate) { |
37 // TODO(sergeyu): Use SDP to format candidates? | 37 // TODO(sergeyu): Use SDP to format candidates? |
38 base::DictionaryValue value; | 38 base::DictionaryValue value; |
(...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
74 !dic_value->GetInteger("port", &port) || | 74 !dic_value->GetInteger("port", &port) || |
75 !dic_value->GetString("type", &type) || | 75 !dic_value->GetString("type", &type) || |
76 !dic_value->GetString("protocol", &protocol) || | 76 !dic_value->GetString("protocol", &protocol) || |
77 !dic_value->GetString("username", &username) || | 77 !dic_value->GetString("username", &username) || |
78 !dic_value->GetString("password", &password) || | 78 !dic_value->GetString("password", &password) || |
79 !dic_value->GetDouble("preference", &preference) || | 79 !dic_value->GetDouble("preference", &preference) || |
80 !dic_value->GetInteger("generation", &generation)) { | 80 !dic_value->GetInteger("generation", &generation)) { |
81 return false; | 81 return false; |
82 } | 82 } |
83 | 83 |
84 candidate->set_address(talk_base::SocketAddress(ip, port)); | 84 candidate->set_address(rtc::SocketAddress(ip, port)); |
85 candidate->set_type(type); | 85 candidate->set_type(type); |
86 candidate->set_protocol(protocol); | 86 candidate->set_protocol(protocol); |
87 candidate->set_username(username); | 87 candidate->set_username(username); |
88 candidate->set_password(password); | 88 candidate->set_password(password); |
89 candidate->set_preference(static_cast<float>(preference)); | 89 candidate->set_preference(static_cast<float>(preference)); |
90 candidate->set_generation(generation); | 90 candidate->set_generation(generation); |
91 | 91 |
92 return true; | 92 return true; |
93 } | 93 } |
94 | 94 |
95 } // namespace jingle_glue | 95 } // namespace jingle_glue |
OLD | NEW |