blob: d70829e0fbe9493c65bbd78175f7714a5c3ca6a0 [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
Mirko Bonadei92ea95e2017-09-15 04:47:3114#ifndef API_JSEPSESSIONDESCRIPTION_H_
15#define API_JSEPSESSIONDESCRIPTION_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
Patrik Höglunde2d6a062017-10-05 12:53:3321#include "api/candidate.h"
Mirko Bonadei92ea95e2017-09-15 04:47:3122#include "api/jsep.h"
23#include "api/jsepicecandidate.h"
Mirko Bonadei92ea95e2017-09-15 04:47:3124#include "rtc_base/constructormagic.h"
henrike@webrtc.org28e20752013-07-10 00:45:3625
26namespace cricket {
27class SessionDescription;
28}
29
30namespace webrtc {
31
deadbeefb10f32f2017-02-08 09:38:2132// Implementation of SessionDescriptionInterface.
henrike@webrtc.org28e20752013-07-10 00:45:3633class JsepSessionDescription : public SessionDescriptionInterface {
34 public:
Steve Anton88f2cb92017-12-05 20:47:3235 explicit JsepSessionDescription(SdpType type);
36 // TODO(steveanton): Remove this once callers have switched to SdpType.
henrike@webrtc.org28e20752013-07-10 00:45:3637 explicit JsepSessionDescription(const std::string& type);
38 virtual ~JsepSessionDescription();
39
henrike@webrtc.org28e20752013-07-10 00:45:3640 // Takes ownership of |description|.
deadbeefb10f32f2017-02-08 09:38:2141 // TODO(deadbeef): Make this use an std::unique_ptr<>, so ownership logic is
42 // more clear.
henrike@webrtc.org28e20752013-07-10 00:45:3643 bool Initialize(cricket::SessionDescription* description,
Yves Gerey665174f2018-06-19 13:03:0544 const std::string& session_id,
45 const std::string& session_version);
henrike@webrtc.org28e20752013-07-10 00:45:3646
47 virtual cricket::SessionDescription* description() {
48 return description_.get();
49 }
50 virtual const cricket::SessionDescription* description() const {
51 return description_.get();
52 }
Yves Gerey665174f2018-06-19 13:03:0553 virtual std::string session_id() const { return session_id_; }
54 virtual std::string session_version() const { return session_version_; }
Steve Anton88f2cb92017-12-05 20:47:3255 virtual SdpType GetType() const { return type_; }
56 virtual std::string type() const { return SdpTypeToString(type_); }
deadbeefb10f32f2017-02-08 09:38:2157 // Allows changing the type. Used for testing.
henrike@webrtc.org28e20752013-07-10 00:45:3658 virtual bool AddCandidate(const IceCandidateInterface* candidate);
Honghai Zhang7fb69db2016-03-14 18:59:1859 virtual size_t RemoveCandidates(
60 const std::vector<cricket::Candidate>& candidates);
henrike@webrtc.org28e20752013-07-10 00:45:3661 virtual size_t number_of_mediasections() const;
62 virtual const IceCandidateCollection* candidates(
63 size_t mediasection_index) const;
64 virtual bool ToString(std::string* out) const;
65
henrike@webrtc.org28e20752013-07-10 00:45:3666 static const int kDefaultVideoCodecId;
henrike@webrtc.org28e20752013-07-10 00:45:3667 static const char kDefaultVideoCodecName[];
henrike@webrtc.org28e20752013-07-10 00:45:3668
69 private:
kwibergd1fe2812016-04-27 13:47:2970 std::unique_ptr<cricket::SessionDescription> description_;
henrike@webrtc.org28e20752013-07-10 00:45:3671 std::string session_id_;
72 std::string session_version_;
Steve Anton88f2cb92017-12-05 20:47:3273 SdpType type_;
henrike@webrtc.org28e20752013-07-10 00:45:3674 std::vector<JsepCandidateCollection> candidate_collection_;
75
76 bool GetMediasectionIndex(const IceCandidateInterface* candidate,
77 size_t* index);
Honghai Zhang7fb69db2016-03-14 18:59:1878 int GetMediasectionIndex(const cricket::Candidate& candidate);
henrike@webrtc.org28e20752013-07-10 00:45:3679
henrikg3c089d72015-09-16 12:37:4480 RTC_DISALLOW_COPY_AND_ASSIGN(JsepSessionDescription);
henrike@webrtc.org28e20752013-07-10 00:45:3681};
82
83} // namespace webrtc
84
Mirko Bonadei92ea95e2017-09-15 04:47:3185#endif // API_JSEPSESSIONDESCRIPTION_H_