| 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 |
| 11 | // TODO(deadbeef): Move this out of api/; it's an implementation detail and |
| 12 | // shouldn't be used externally. |
| 13 |
| 14 | #ifndef API_JSEP_SESSION_DESCRIPTION_H_ |
| 15 | #define API_JSEP_SESSION_DESCRIPTION_H_ |
| 16 |
| 17 | #include <memory> |
| 18 | #include <string> |
| 19 | #include <vector> |
| 20 |
| 21 | #include "absl/strings/string_view.h" |
| 22 | #include "api/candidate.h" |
| 23 | #include "api/jsep.h" |
| 24 | #include "api/jsep_ice_candidate.h" |
| 25 |
| 26 | namespace cricket { |
| 27 | class SessionDescription; |
| 28 | } |
| 29 |
| 30 | namespace webrtc { |
| 31 |
| 32 | // Implementation of SessionDescriptionInterface. |
| 33 | class JsepSessionDescription : public SessionDescriptionInterface { |
| 34 | public: |
| 35 | explicit JsepSessionDescription(SdpType type); |
| 36 | // TODO(steveanton): Remove this once callers have switched to SdpType. |
| 37 | explicit JsepSessionDescription(const std::string& type); |
| 38 | JsepSessionDescription( |
| 39 | SdpType type, |
| 40 | std::unique_ptr<cricket::SessionDescription> description, |
| 41 | absl::string_view session_id, |
| 42 | absl::string_view session_version); |
| 43 | virtual ~JsepSessionDescription(); |
| 44 |
| 45 | JsepSessionDescription(const JsepSessionDescription&) = delete; |
| 46 | JsepSessionDescription& operator=(const JsepSessionDescription&) = delete; |
| 47 |
| 48 | // Takes ownership of `description`. |
| 49 | bool Initialize(std::unique_ptr<cricket::SessionDescription> description, |
| 50 | const std::string& session_id, |
| 51 | const std::string& session_version); |
| 52 |
| 53 | virtual std::unique_ptr<SessionDescriptionInterface> Clone() const; |
| 54 |
| 55 | virtual cricket::SessionDescription* description() { |
| 56 | return description_.get(); |
| 57 | } |
| 58 | virtual const cricket::SessionDescription* description() const { |
| 59 | return description_.get(); |
| 60 | } |
| 61 | virtual std::string session_id() const { return session_id_; } |
| 62 | virtual std::string session_version() const { return session_version_; } |
| 63 | virtual SdpType GetType() const { return type_; } |
| 64 | virtual std::string type() const { return SdpTypeToString(type_); } |
| 65 | // Allows changing the type. Used for testing. |
| 66 | virtual bool AddCandidate(const IceCandidateInterface* candidate); |
| 67 | virtual size_t RemoveCandidates( |
| 68 | const std::vector<cricket::Candidate>& candidates); |
| 69 | virtual size_t number_of_mediasections() const; |
| 70 | virtual const IceCandidateCollection* candidates( |
| 71 | size_t mediasection_index) const; |
| 72 | virtual bool ToString(std::string* out) const; |
| 73 |
| 74 | private: |
| 75 | std::unique_ptr<cricket::SessionDescription> description_; |
| 76 | std::string session_id_; |
| 77 | std::string session_version_; |
| 78 | SdpType type_; |
| 79 | std::vector<JsepCandidateCollection> candidate_collection_; |
| 80 |
| 81 | bool GetMediasectionIndex(const IceCandidateInterface* candidate, |
| 82 | size_t* index); |
| 83 | int GetMediasectionIndex(const cricket::Candidate& candidate); |
| 84 | }; |
| 85 |
| 86 | } // namespace webrtc |
| 87 |
| 88 | #endif // API_JSEP_SESSION_DESCRIPTION_H_ |
| 89 |