configuration.cpp 1.6 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546
  1. /**
  2. * Copyright (c) 2019 Paul-Louis Ageneau
  3. *
  4. * This library is free software; you can redistribute it and/or
  5. * modify it under the terms of the GNU Lesser General Public
  6. * License as published by the Free Software Foundation; either
  7. * version 2.1 of the License, or (at your option) any later version.
  8. *
  9. * This library is distributed in the hope that it will be useful,
  10. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  11. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
  12. * Lesser General Public License for more details.
  13. *
  14. * You should have received a copy of the GNU Lesser General Public
  15. * License along with this library; if not, write to the Free Software
  16. * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
  17. */
  18. #include "configuration.hpp"
  19. namespace rtc {
  20. using std::to_string;
  21. IceServer::IceServer(const string &host) : type(Type::Stun) {
  22. if (size_t pos = host.rfind(':'); pos != string::npos) {
  23. hostname = host.substr(0, pos);
  24. service = host.substr(pos + 1);
  25. } else {
  26. hostname = host;
  27. service = "3478"; // STUN UDP port
  28. }
  29. }
  30. IceServer::IceServer(const string &hostname_, uint16_t port_)
  31. : IceServer(hostname_, to_string(port_)) {}
  32. IceServer::IceServer(const string &hostname_, const string &service_)
  33. : hostname(hostname_), service(service_), type(Type::Stun) {}
  34. IceServer::IceServer(const string &hostname_, const string &service_, Type type_, string username_,
  35. string password_, RelayType relayType_)
  36. : hostname(hostname_), service(service_), type(type_), username(username_), password(password_),
  37. relayType(relayType_) {}
  38. } // namespace rtc