blob: 2797c881fe4e3139e4b3d809b2825b2bb3ef79ae [file] [log] [blame]
henrike@webrtc.org28e20752013-07-10 00:45:36 +00001/*
kjellanderb24317b2016-02-10 07:54:43 -08002 * Copyright 2012 The WebRTC project authors. All Rights Reserved.
henrike@webrtc.org28e20752013-07-10 00:45:36 +00003 *
kjellanderb24317b2016-02-10 07:54:43 -08004 * 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:36 +00009 */
10
deadbeefb10f32f2017-02-08 01:38:21 -080011// 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:36 +000013
Steve Anton10542f22019-01-11 09:11:00 -080014#ifndef API_JSEP_SESSION_DESCRIPTION_H_
15#define API_JSEP_SESSION_DESCRIPTION_H_
henrike@webrtc.org28e20752013-07-10 00:45:36 +000016
kwibergd1fe2812016-04-27 06:47:29 -070017#include <memory>
henrike@webrtc.org28e20752013-07-10 00:45:36 +000018#include <string>
19#include <vector>
20
Steve Anton6fe1fba2018-12-11 10:15:23 -080021#include "absl/strings/string_view.h"
Patrik Höglunde2d6a062017-10-05 14:53:33 +020022#include "api/candidate.h"
Mirko Bonadei92ea95e2017-09-15 06:47:31 +020023#include "api/jsep.h"
Steve Anton10542f22019-01-11 09:11:00 -080024#include "api/jsep_ice_candidate.h"
25#include "rtc_base/constructor_magic.h"
henrike@webrtc.org28e20752013-07-10 00:45:36 +000026
27namespace cricket {
28class SessionDescription;
29}
30
31namespace webrtc {
32
deadbeefb10f32f2017-02-08 01:38:21 -080033// Implementation of SessionDescriptionInterface.
henrike@webrtc.org28e20752013-07-10 00:45:36 +000034class JsepSessionDescription : public SessionDescriptionInterface {
35 public:
Steve Anton88f2cb92017-12-05 12:47:32 -080036 explicit JsepSessionDescription(SdpType type);
37 // TODO(steveanton): Remove this once callers have switched to SdpType.
henrike@webrtc.org28e20752013-07-10 00:45:36 +000038 explicit JsepSessionDescription(const std::string& type);
Steve Anton6fe1fba2018-12-11 10:15:23 -080039 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.org28e20752013-07-10 00:45:36 +000044 virtual ~JsepSessionDescription();
45
henrike@webrtc.org28e20752013-07-10 00:45:36 +000046 // Takes ownership of |description|.
Harald Alvestrand4d7160e2019-04-12 07:01:29 +020047 bool Initialize(std::unique_ptr<cricket::SessionDescription> description,
48 const std::string& session_id,
49 const std::string& session_version);
50 // Backwards compatible version. To be deprecated.
henrike@webrtc.org28e20752013-07-10 00:45:36 +000051 bool Initialize(cricket::SessionDescription* description,
Yves Gerey665174f2018-06-19 15:03:05 +020052 const std::string& session_id,
53 const std::string& session_version);
henrike@webrtc.org28e20752013-07-10 00:45:36 +000054
55 virtual cricket::SessionDescription* description() {
56 return description_.get();
57 }
58 virtual const cricket::SessionDescription* description() const {
59 return description_.get();
60 }
Yves Gerey665174f2018-06-19 15:03:05 +020061 virtual std::string session_id() const { return session_id_; }
62 virtual std::string session_version() const { return session_version_; }
Steve Anton88f2cb92017-12-05 12:47:32 -080063 virtual SdpType GetType() const { return type_; }
64 virtual std::string type() const { return SdpTypeToString(type_); }
deadbeefb10f32f2017-02-08 01:38:21 -080065 // Allows changing the type. Used for testing.
henrike@webrtc.org28e20752013-07-10 00:45:36 +000066 virtual bool AddCandidate(const IceCandidateInterface* candidate);
Honghai Zhang7fb69db2016-03-14 11:59:18 -070067 virtual size_t RemoveCandidates(
68 const std::vector<cricket::Candidate>& candidates);
henrike@webrtc.org28e20752013-07-10 00:45:36 +000069 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
henrike@webrtc.org28e20752013-07-10 00:45:36 +000074 static const int kDefaultVideoCodecId;
henrike@webrtc.org28e20752013-07-10 00:45:36 +000075 static const char kDefaultVideoCodecName[];
henrike@webrtc.org28e20752013-07-10 00:45:36 +000076
77 private:
kwibergd1fe2812016-04-27 06:47:29 -070078 std::unique_ptr<cricket::SessionDescription> description_;
henrike@webrtc.org28e20752013-07-10 00:45:36 +000079 std::string session_id_;
80 std::string session_version_;
Steve Anton88f2cb92017-12-05 12:47:32 -080081 SdpType type_;
henrike@webrtc.org28e20752013-07-10 00:45:36 +000082 std::vector<JsepCandidateCollection> candidate_collection_;
83
84 bool GetMediasectionIndex(const IceCandidateInterface* candidate,
85 size_t* index);
Honghai Zhang7fb69db2016-03-14 11:59:18 -070086 int GetMediasectionIndex(const cricket::Candidate& candidate);
henrike@webrtc.org28e20752013-07-10 00:45:36 +000087
henrikg3c089d72015-09-16 05:37:44 -070088 RTC_DISALLOW_COPY_AND_ASSIGN(JsepSessionDescription);
henrike@webrtc.org28e20752013-07-10 00:45:36 +000089};
90
91} // namespace webrtc
92
Steve Anton10542f22019-01-11 09:11:00 -080093#endif // API_JSEP_SESSION_DESCRIPTION_H_