henrike@webrtc.org | 28e2075 | 2013-07-10 00:45:36 | [diff] [blame] | 1 | /* |
kjellander | b24317b | 2016-02-10 15:54:43 | [diff] [blame] | 2 | * Copyright 2012 The WebRTC project authors. All Rights Reserved. |
henrike@webrtc.org | 28e2075 | 2013-07-10 00:45:36 | [diff] [blame] | 3 | * |
kjellander | b24317b | 2016-02-10 15:54:43 | [diff] [blame] | 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. |
henrike@webrtc.org | 28e2075 | 2013-07-10 00:45:36 | [diff] [blame] | 9 | */ |
| 10 | |
deadbeef | b10f32f | 2017-02-08 09:38:21 | [diff] [blame] | 11 | // TODO(deadbeef): Move this out of api/; it's an implementation detail and |
| 12 | // shouldn't be used externally. |
henrike@webrtc.org | 28e2075 | 2013-07-10 00:45:36 | [diff] [blame] | 13 | |
Steve Anton | 10542f2 | 2019-01-11 17:11:00 | [diff] [blame] | 14 | #ifndef API_JSEP_SESSION_DESCRIPTION_H_ |
| 15 | #define API_JSEP_SESSION_DESCRIPTION_H_ |
henrike@webrtc.org | 28e2075 | 2013-07-10 00:45:36 | [diff] [blame] | 16 | |
Dor Hen | 28ce65c | 2024-09-04 11:55:22 | [diff] [blame] | 17 | #include <cstddef> |
kwiberg | d1fe281 | 2016-04-27 13:47:29 | [diff] [blame] | 18 | #include <memory> |
henrike@webrtc.org | 28e2075 | 2013-07-10 00:45:36 | [diff] [blame] | 19 | #include <string> |
| 20 | #include <vector> |
| 21 | |
Steve Anton | 6fe1fba | 2018-12-11 18:15:23 | [diff] [blame] | 22 | #include "absl/strings/string_view.h" |
Patrik Höglund | e2d6a06 | 2017-10-05 12:53:33 | [diff] [blame] | 23 | #include "api/candidate.h" |
Mirko Bonadei | 92ea95e | 2017-09-15 04:47:31 | [diff] [blame] | 24 | #include "api/jsep.h" |
Steve Anton | 10542f2 | 2019-01-11 17:11:00 | [diff] [blame] | 25 | #include "api/jsep_ice_candidate.h" |
henrike@webrtc.org | 28e2075 | 2013-07-10 00:45:36 | [diff] [blame] | 26 | |
| 27 | namespace cricket { |
| 28 | class SessionDescription; |
| 29 | } |
| 30 | |
| 31 | namespace webrtc { |
| 32 | |
deadbeef | b10f32f | 2017-02-08 09:38:21 | [diff] [blame] | 33 | // Implementation of SessionDescriptionInterface. |
henrike@webrtc.org | 28e2075 | 2013-07-10 00:45:36 | [diff] [blame] | 34 | class JsepSessionDescription : public SessionDescriptionInterface { |
| 35 | public: |
Steve Anton | 88f2cb9 | 2017-12-05 20:47:32 | [diff] [blame] | 36 | explicit JsepSessionDescription(SdpType type); |
| 37 | // TODO(steveanton): Remove this once callers have switched to SdpType. |
henrike@webrtc.org | 28e2075 | 2013-07-10 00:45:36 | [diff] [blame] | 38 | explicit JsepSessionDescription(const std::string& type); |
Steve Anton | 6fe1fba | 2018-12-11 18:15:23 | [diff] [blame] | 39 | JsepSessionDescription( |
| 40 | SdpType type, |
| 41 | std::unique_ptr<cricket::SessionDescription> description, |
| 42 | absl::string_view session_id, |
| 43 | absl::string_view session_version); |
henrike@webrtc.org | 28e2075 | 2013-07-10 00:45:36 | [diff] [blame] | 44 | virtual ~JsepSessionDescription(); |
| 45 | |
Byoungchan Lee | c065e73 | 2022-01-18 00:35:48 | [diff] [blame] | 46 | JsepSessionDescription(const JsepSessionDescription&) = delete; |
| 47 | JsepSessionDescription& operator=(const JsepSessionDescription&) = delete; |
| 48 | |
Artem Titov | 0e61fdd | 2021-07-25 19:50:14 | [diff] [blame] | 49 | // Takes ownership of `description`. |
Harald Alvestrand | 4d7160e | 2019-04-12 05:01:29 | [diff] [blame] | 50 | bool Initialize(std::unique_ptr<cricket::SessionDescription> description, |
| 51 | const std::string& session_id, |
| 52 | const std::string& session_version); |
henrike@webrtc.org | 28e2075 | 2013-07-10 00:45:36 | [diff] [blame] | 53 | |
Harald Alvestrand | c908f1c | 2020-12-17 19:28:29 | [diff] [blame] | 54 | virtual std::unique_ptr<SessionDescriptionInterface> Clone() const; |
Harald Alvestrand | 0e7b3a9 | 2020-12-15 15:18:28 | [diff] [blame] | 55 | |
henrike@webrtc.org | 28e2075 | 2013-07-10 00:45:36 | [diff] [blame] | 56 | virtual cricket::SessionDescription* description() { |
| 57 | return description_.get(); |
| 58 | } |
| 59 | virtual const cricket::SessionDescription* description() const { |
| 60 | return description_.get(); |
| 61 | } |
Yves Gerey | 665174f | 2018-06-19 13:03:05 | [diff] [blame] | 62 | virtual std::string session_id() const { return session_id_; } |
| 63 | virtual std::string session_version() const { return session_version_; } |
Steve Anton | 88f2cb9 | 2017-12-05 20:47:32 | [diff] [blame] | 64 | virtual SdpType GetType() const { return type_; } |
| 65 | virtual std::string type() const { return SdpTypeToString(type_); } |
deadbeef | b10f32f | 2017-02-08 09:38:21 | [diff] [blame] | 66 | // Allows changing the type. Used for testing. |
henrike@webrtc.org | 28e2075 | 2013-07-10 00:45:36 | [diff] [blame] | 67 | virtual bool AddCandidate(const IceCandidateInterface* candidate); |
Honghai Zhang | 7fb69db | 2016-03-14 18:59:18 | [diff] [blame] | 68 | virtual size_t RemoveCandidates( |
| 69 | const std::vector<cricket::Candidate>& candidates); |
henrike@webrtc.org | 28e2075 | 2013-07-10 00:45:36 | [diff] [blame] | 70 | virtual size_t number_of_mediasections() const; |
| 71 | virtual const IceCandidateCollection* candidates( |
| 72 | size_t mediasection_index) const; |
| 73 | virtual bool ToString(std::string* out) const; |
| 74 | |
henrike@webrtc.org | 28e2075 | 2013-07-10 00:45:36 | [diff] [blame] | 75 | private: |
kwiberg | d1fe281 | 2016-04-27 13:47:29 | [diff] [blame] | 76 | std::unique_ptr<cricket::SessionDescription> description_; |
henrike@webrtc.org | 28e2075 | 2013-07-10 00:45:36 | [diff] [blame] | 77 | std::string session_id_; |
| 78 | std::string session_version_; |
Steve Anton | 88f2cb9 | 2017-12-05 20:47:32 | [diff] [blame] | 79 | SdpType type_; |
henrike@webrtc.org | 28e2075 | 2013-07-10 00:45:36 | [diff] [blame] | 80 | std::vector<JsepCandidateCollection> candidate_collection_; |
| 81 | |
| 82 | bool GetMediasectionIndex(const IceCandidateInterface* candidate, |
| 83 | size_t* index); |
Honghai Zhang | 7fb69db | 2016-03-14 18:59:18 | [diff] [blame] | 84 | int GetMediasectionIndex(const cricket::Candidate& candidate); |
henrike@webrtc.org | 28e2075 | 2013-07-10 00:45:36 | [diff] [blame] | 85 | }; |
| 86 | |
| 87 | } // namespace webrtc |
| 88 | |
Steve Anton | 10542f2 | 2019-01-11 17:11:00 | [diff] [blame] | 89 | #endif // API_JSEP_SESSION_DESCRIPTION_H_ |