description.hpp 2.4 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485
  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_DESCRIPTION_H
  19. #define RTC_DESCRIPTION_H
  20. #include "candidate.hpp"
  21. #include "include.hpp"
  22. #include <iostream>
  23. #include <map>
  24. #include <optional>
  25. #include <vector>
  26. namespace rtc {
  27. class Description {
  28. public:
  29. enum class Type { Unspec = 0, Offer = 1, Answer = 2 };
  30. enum class Role { ActPass = 0, Passive = 1, Active = 2 };
  31. Description(const string &sdp, const string &typeString = "");
  32. Description(const string &sdp, Type type);
  33. Description(const string &sdp, Type type, Role role);
  34. Type type() const;
  35. string typeString() const;
  36. Role role() const;
  37. string roleString() const;
  38. string mid() const;
  39. std::optional<string> fingerprint() const;
  40. std::optional<uint16_t> sctpPort() const;
  41. std::optional<size_t> maxMessageSize() const;
  42. bool trickleEnabled() const;
  43. void hintType(Type type);
  44. void setFingerprint(string fingerprint);
  45. void setSctpPort(uint16_t port);
  46. void setMaxMessageSize(size_t size);
  47. void addCandidate(Candidate candidate);
  48. void endCandidates();
  49. std::vector<Candidate> extractCandidates();
  50. operator string() const;
  51. string generateSdp(const string &eol) const;
  52. private:
  53. Type mType;
  54. Role mRole;
  55. string mSessionId;
  56. string mMid;
  57. string mIceUfrag, mIcePwd;
  58. std::optional<string> mFingerprint;
  59. std::optional<uint16_t> mSctpPort;
  60. std::optional<size_t> mMaxMessageSize;
  61. std::vector<Candidate> mCandidates;
  62. bool mTrickle;
  63. static Type stringToType(const string &typeString);
  64. static string typeToString(Type type);
  65. static string roleToString(Role role);
  66. };
  67. } // namespace rtc
  68. std::ostream &operator<<(std::ostream &out, const rtc::Description &description);
  69. #endif