description.hpp 2.2 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980
  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. std::optional<size_t> maxMessageSize() const;
  41. void setFingerprint(string fingerprint);
  42. void setSctpPort(uint16_t port);
  43. void setMaxMessageSize(size_t size);
  44. void addCandidate(Candidate candidate);
  45. void endCandidates();
  46. std::vector<Candidate> extractCandidates();
  47. operator string() const;
  48. private:
  49. Type mType;
  50. Role mRole;
  51. string mSessionId;
  52. string mMid;
  53. string mIceUfrag, mIcePwd;
  54. std::optional<string> mFingerprint;
  55. std::optional<uint16_t> mSctpPort;
  56. std::optional<size_t> mMaxMessageSize;
  57. std::vector<Candidate> mCandidates;
  58. bool mTrickle;
  59. static Type stringToType(const string &typeString);
  60. static string typeToString(Type type);
  61. static string roleToString(Role role);
  62. };
  63. } // namespace rtc
  64. std::ostream &operator<<(std::ostream &out, const rtc::Description &description);
  65. #endif