blob: e13d85e71cb60a22bc0820b0b8c5bf890e5e788f [file] [log] [blame]
henrike@webrtc.org28e20752013-07-10 00:45:361/*
kjellanderb24317b2016-02-10 15:54:432 * Copyright 2012 The WebRTC project authors. All Rights Reserved.
henrike@webrtc.org28e20752013-07-10 00:45:363 *
kjellanderb24317b2016-02-10 15:54:434 * 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.org28e20752013-07-10 00:45:369 */
10
deadbeefb10f32f2017-02-08 09:38:2111// TODO(deadbeef): Move this out of api/; it's an implementation detail and
12// shouldn't be used externally.
henrike@webrtc.org28e20752013-07-10 00:45:3613
Steve Anton10542f22019-01-11 17:11:0014#ifndef API_JSEP_SESSION_DESCRIPTION_H_
15#define API_JSEP_SESSION_DESCRIPTION_H_
henrike@webrtc.org28e20752013-07-10 00:45:3616
kwibergd1fe2812016-04-27 13:47:2917#include <memory>
henrike@webrtc.org28e20752013-07-10 00:45:3618#include <string>
19#include <vector>
20
Steve Anton6fe1fba2018-12-11 18:15:2321#include "absl/strings/string_view.h"
Patrik Höglunde2d6a062017-10-05 12:53:3322#include "api/candidate.h"
Mirko Bonadei92ea95e2017-09-15 04:47:3123#include "api/jsep.h"
Steve Anton10542f22019-01-11 17:11:0024#include "api/jsep_ice_candidate.h"
25#include "rtc_base/constructor_magic.h"
Harald Alvestrand8da35a62019-05-10 07:31:0426#include "rtc_base/deprecation.h"
henrike@webrtc.org28e20752013-07-10 00:45:3627
28namespace cricket {
29class SessionDescription;
30}
31
32namespace webrtc {
33
deadbeefb10f32f2017-02-08 09:38:2134// Implementation of SessionDescriptionInterface.
henrike@webrtc.org28e20752013-07-10 00:45:3635class JsepSessionDescription : public SessionDescriptionInterface {
36 public:
Steve Anton88f2cb92017-12-05 20:47:3237 explicit JsepSessionDescription(SdpType type);
38 // TODO(steveanton): Remove this once callers have switched to SdpType.
henrike@webrtc.org28e20752013-07-10 00:45:3639 explicit JsepSessionDescription(const std::string& type);
Steve Anton6fe1fba2018-12-11 18:15:2340 JsepSessionDescription(
41 SdpType type,
42 std::unique_ptr<cricket::SessionDescription> description,
43 absl::string_view session_id,
44 absl::string_view session_version);
henrike@webrtc.org28e20752013-07-10 00:45:3645 virtual ~JsepSessionDescription();
46
henrike@webrtc.org28e20752013-07-10 00:45:3647 // Takes ownership of |description|.
Harald Alvestrand4d7160e2019-04-12 05:01:2948 bool Initialize(std::unique_ptr<cricket::SessionDescription> description,
49 const std::string& session_id,
50 const std::string& session_version);
henrike@webrtc.org28e20752013-07-10 00:45:3651
Harald Alvestrandc908f1c2020-12-17 19:28:2952 virtual std::unique_ptr<SessionDescriptionInterface> Clone() const;
Harald Alvestrand0e7b3a92020-12-15 15:18:2853
henrike@webrtc.org28e20752013-07-10 00:45:3654 virtual cricket::SessionDescription* description() {
55 return description_.get();
56 }
57 virtual const cricket::SessionDescription* description() const {
58 return description_.get();
59 }
Yves Gerey665174f2018-06-19 13:03:0560 virtual std::string session_id() const { return session_id_; }
61 virtual std::string session_version() const { return session_version_; }
Steve Anton88f2cb92017-12-05 20:47:3262 virtual SdpType GetType() const { return type_; }
63 virtual std::string type() const { return SdpTypeToString(type_); }
deadbeefb10f32f2017-02-08 09:38:2164 // Allows changing the type. Used for testing.
henrike@webrtc.org28e20752013-07-10 00:45:3665 virtual bool AddCandidate(const IceCandidateInterface* candidate);
Honghai Zhang7fb69db2016-03-14 18:59:1866 virtual size_t RemoveCandidates(
67 const std::vector<cricket::Candidate>& candidates);
henrike@webrtc.org28e20752013-07-10 00:45:3668 virtual size_t number_of_mediasections() const;
69 virtual const IceCandidateCollection* candidates(
70 size_t mediasection_index) const;
71 virtual bool ToString(std::string* out) const;
72
henrike@webrtc.org28e20752013-07-10 00:45:3673 static const int kDefaultVideoCodecId;
henrike@webrtc.org28e20752013-07-10 00:45:3674 static const char kDefaultVideoCodecName[];
henrike@webrtc.org28e20752013-07-10 00:45:3675
76 private:
kwibergd1fe2812016-04-27 13:47:2977 std::unique_ptr<cricket::SessionDescription> description_;
henrike@webrtc.org28e20752013-07-10 00:45:3678 std::string session_id_;
79 std::string session_version_;
Steve Anton88f2cb92017-12-05 20:47:3280 SdpType type_;
henrike@webrtc.org28e20752013-07-10 00:45:3681 std::vector<JsepCandidateCollection> candidate_collection_;
82
83 bool GetMediasectionIndex(const IceCandidateInterface* candidate,
84 size_t* index);
Honghai Zhang7fb69db2016-03-14 18:59:1885 int GetMediasectionIndex(const cricket::Candidate& candidate);
henrike@webrtc.org28e20752013-07-10 00:45:3686
henrikg3c089d72015-09-16 12:37:4487 RTC_DISALLOW_COPY_AND_ASSIGN(JsepSessionDescription);
henrike@webrtc.org28e20752013-07-10 00:45:3688};
89
90} // namespace webrtc
91
Steve Anton10542f22019-01-11 17:11:0092#endif // API_JSEP_SESSION_DESCRIPTION_H_