1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. 2 // Use of this source code is governed by a BSD-style license that can be 3 // found in the LICENSE file. 4 5 #ifndef JINGLE_GLUE_UTILS_H_ 6 #define JINGLE_GLUE_UTILS_H_ 7 8 #include <string> 9 10 #include "third_party/webrtc/rtc_base/ip_address.h" 11 12 namespace net { 13 class IPAddress; 14 class IPEndPoint; 15 } // namespace net 16 17 namespace rtc { 18 class SocketAddress; 19 } // namespace rtc 20 21 namespace cricket { 22 class Candidate; 23 } // namespace cricket 24 25 namespace jingle_glue { 26 27 // Chromium and libjingle represent socket addresses differently. The 28 // following two functions are used to convert addresses from one 29 // representation to another. 30 bool IPEndPointToSocketAddress(const net::IPEndPoint& ip_endpoint, 31 rtc::SocketAddress* address); 32 bool SocketAddressToIPEndPoint(const rtc::SocketAddress& address, 33 net::IPEndPoint* ip_endpoint); 34 35 rtc::IPAddress NetIPAddressToRtcIPAddress(const net::IPAddress& ip_address); 36 37 net::IPAddress RtcIPAddressToNetIPAddress(const rtc::IPAddress& ip_address); 38 39 // Helper functions to serialize and deserialize P2P candidates. 40 std::string SerializeP2PCandidate(const cricket::Candidate& candidate); 41 bool DeserializeP2PCandidate(const std::string& address, 42 cricket::Candidate* candidate); 43 44 } // namespace jingle_glue 45 46 #endif // JINGLE_GLUE_UTILS_H_ 47