jsep_session_description.h 3.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990
  1. /*
  2. * Copyright 2012 The WebRTC project authors. All Rights Reserved.
  3. *
  4. * Use of this source code is governed by a BSD-style license
  5. * that can be found in the LICENSE file in the root of the source
  6. * tree. An additional intellectual property rights grant can be found
  7. * in the file PATENTS. All contributing project authors may
  8. * be found in the AUTHORS file in the root of the source tree.
  9. */
  10. // TODO(deadbeef): Move this out of api/; it's an implementation detail and
  11. // shouldn't be used externally.
  12. #ifndef API_JSEP_SESSION_DESCRIPTION_H_
  13. #define API_JSEP_SESSION_DESCRIPTION_H_
  14. #include <memory>
  15. #include <string>
  16. #include <vector>
  17. #include "absl/strings/string_view.h"
  18. #include "api/candidate.h"
  19. #include "api/jsep.h"
  20. #include "api/jsep_ice_candidate.h"
  21. #include "rtc_base/constructor_magic.h"
  22. #include "rtc_base/deprecation.h"
  23. namespace cricket {
  24. class SessionDescription;
  25. }
  26. namespace webrtc {
  27. // Implementation of SessionDescriptionInterface.
  28. class JsepSessionDescription : public SessionDescriptionInterface {
  29. public:
  30. explicit JsepSessionDescription(SdpType type);
  31. // TODO(steveanton): Remove this once callers have switched to SdpType.
  32. explicit JsepSessionDescription(const std::string& type);
  33. JsepSessionDescription(
  34. SdpType type,
  35. std::unique_ptr<cricket::SessionDescription> description,
  36. absl::string_view session_id,
  37. absl::string_view session_version);
  38. virtual ~JsepSessionDescription();
  39. // Takes ownership of |description|.
  40. bool Initialize(std::unique_ptr<cricket::SessionDescription> description,
  41. const std::string& session_id,
  42. const std::string& session_version);
  43. virtual cricket::SessionDescription* description() {
  44. return description_.get();
  45. }
  46. virtual const cricket::SessionDescription* description() const {
  47. return description_.get();
  48. }
  49. virtual std::string session_id() const { return session_id_; }
  50. virtual std::string session_version() const { return session_version_; }
  51. virtual SdpType GetType() const { return type_; }
  52. virtual std::string type() const { return SdpTypeToString(type_); }
  53. // Allows changing the type. Used for testing.
  54. virtual bool AddCandidate(const IceCandidateInterface* candidate);
  55. virtual size_t RemoveCandidates(
  56. const std::vector<cricket::Candidate>& candidates);
  57. virtual size_t number_of_mediasections() const;
  58. virtual const IceCandidateCollection* candidates(
  59. size_t mediasection_index) const;
  60. virtual bool ToString(std::string* out) const;
  61. static const int kDefaultVideoCodecId;
  62. static const char kDefaultVideoCodecName[];
  63. private:
  64. std::unique_ptr<cricket::SessionDescription> description_;
  65. std::string session_id_;
  66. std::string session_version_;
  67. SdpType type_;
  68. std::vector<JsepCandidateCollection> candidate_collection_;
  69. bool GetMediasectionIndex(const IceCandidateInterface* candidate,
  70. size_t* index);
  71. int GetMediasectionIndex(const cricket::Candidate& candidate);
  72. RTC_DISALLOW_COPY_AND_ASSIGN(JsepSessionDescription);
  73. };
  74. } // namespace webrtc
  75. #endif // API_JSEP_SESSION_DESCRIPTION_H_