OpenTera WebRTC API (C++) 1.2.5
IceServer.h
1 #ifndef OPENTERA_WEBRTC_NATIVE_CLIENT_UTILS_ICE_SERVER_H
2 #define OPENTERA_WEBRTC_NATIVE_CLIENT_UTILS_ICE_SERVER_H
3 
4 #include <api/peer_connection_interface.h>
5 
6 #include <string>
7 #include <vector>
8 
9 namespace opentera
10 {
14  class IceServer
15  {
16  std::vector<std::string> m_urls;
17  std::string m_username;
18  std::string m_credential;
19 
20  public:
21  explicit IceServer(std::string url);
22  IceServer(std::string url, std::string username, std::string credential);
23  explicit IceServer(std::vector<std::string> urls);
24  IceServer(std::vector<std::string> urls, std::string username, std::string credential);
25  virtual ~IceServer() = default;
26 
27  const std::vector<std::string>& urls() const;
28  const std::string& username() const;
29  const std::string& credential() const;
30 
31  explicit operator webrtc::PeerConnectionInterface::IceServer() const;
32 
33  static bool fetchFromServer(
34  const std::string& url,
35  const std::string& password,
36  std::vector<IceServer>& iceServers,
37  bool verifyCertificate = true);
38  static bool fromJson(const std::string& json, std::vector<IceServer>& iceServers);
39  };
40 
45  inline const std::vector<std::string>& IceServer::urls() const { return m_urls; }
46 
51  inline const std::string& IceServer::username() const { return m_username; }
52 
57  inline const std::string& IceServer::credential() const { return m_credential; }
58 
59  inline IceServer::operator webrtc::PeerConnectionInterface::IceServer() const
60  {
61  webrtc::PeerConnectionInterface::IceServer iceServer;
62  iceServer.urls = m_urls;
63  iceServer.username = m_username;
64  iceServer.password = m_credential;
65  return iceServer;
66  }
67 }
68 
69 #endif
Represents an ice server configuration.
Definition: IceServer.h:15
const std::string & username() const
Returns the ice server username.
Definition: IceServer.h:51
static bool fetchFromServer(const std::string &url, const std::string &password, std::vector< IceServer > &iceServers, bool verifyCertificate=true)
Fetches the ice servers from the signaling server.
Definition: IceServer.cpp:61
static bool fromJson(const std::string &json, std::vector< IceServer > &iceServers)
Gets ice servers from a JSON.
Definition: IceServer.cpp:133
const std::vector< std::string > & urls() const
Returns the ice server urls.
Definition: IceServer.h:45
const std::string & credential() const
Returns the ice server credential.
Definition: IceServer.h:57
IceServer(std::string url)
Creates an ice server configuration with the specified value.
Definition: IceServer.cpp:15