description.hpp 2.0 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374
  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, Role role);
  33. Type type() const;
  34. string typeString() const;
  35. Role role() const;
  36. string roleString() const;
  37. string mid() const;
  38. std::optional<string> fingerprint() const;
  39. std::optional<uint16_t> sctpPort() const;
  40. void setFingerprint(string fingerprint);
  41. void setSctpPort(uint16_t port);
  42. void addCandidate(std::optional<Candidate> candidate);
  43. operator string() const;
  44. private:
  45. Type mType;
  46. Role mRole;
  47. string mSessionId;
  48. string mMid;
  49. string mIceUfrag, mIcePwd;
  50. std::optional<string> mFingerprint;
  51. std::optional<uint16_t> mSctpPort;
  52. std::vector<Candidate> mCandidates;
  53. bool mTrickle;
  54. static Type stringToType(const string &typeString);
  55. static string typeToString(Type type);
  56. static string roleToString(Role role);
  57. };
  58. } // namespace rtc
  59. std::ostream &operator<<(std::ostream &out, const rtc::Description &description);
  60. #endif