candidate.hpp 1.8 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162
  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. #ifndef RTC_CANDIDATE_H
  19. #define RTC_CANDIDATE_H
  20. #include "include.hpp"
  21. #include <string>
  22. namespace rtc {
  23. enum class CandidateType { Host = 0, ServerReflexive, PeerReflexive, Relayed };
  24. enum class CandidateTransportType { Udp = 0, TcpActive, TcpPassive, TcpSo };
  25. struct CandidateInfo {
  26. string address;
  27. int port;
  28. CandidateType type;
  29. CandidateTransportType transportType;
  30. };
  31. class Candidate {
  32. public:
  33. Candidate(string candidate, string mid = "");
  34. enum class ResolveMode { Simple, Lookup };
  35. bool resolve(ResolveMode mode = ResolveMode::Simple);
  36. bool isResolved() const;
  37. string candidate() const;
  38. string mid() const;
  39. operator string() const;
  40. private:
  41. string mCandidate;
  42. string mMid;
  43. bool mIsResolved;
  44. };
  45. } // namespace rtc
  46. std::ostream &operator<<(std::ostream &out, const rtc::Candidate &candidate);
  47. std::ostream &operator<<(std::ostream &out, const rtc::CandidateType &type);
  48. std::ostream &operator<<(std::ostream &out, const rtc::CandidateTransportType &transportType);
  49. #endif