blob: 6b115ee2e9034a77bb9416fd0b89f95cde2aed14 [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
Mirko Bonadei92ea95e2017-09-15 06:47:31 +020014#ifndef API_JSEPSESSIONDESCRIPTION_H_
15#define API_JSEPSESSIONDESCRIPTION_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
Patrik Höglunde2d6a062017-10-05 14:53:33 +020021#include "api/candidate.h"
Mirko Bonadei92ea95e2017-09-15 06:47:31 +020022#include "api/jsep.h"
23#include "api/jsepicecandidate.h"
Mirko Bonadei92ea95e2017-09-15 06:47:31 +020024#include "rtc_base/constructormagic.h"
henrike@webrtc.org28e20752013-07-10 00:45:36 +000025
26namespace cricket {
27class SessionDescription;
28}
29
30namespace webrtc {
31
deadbeefb10f32f2017-02-08 01:38:21 -080032// Implementation of SessionDescriptionInterface.
henrike@webrtc.org28e20752013-07-10 00:45:36 +000033class JsepSessionDescription : public SessionDescriptionInterface {
34 public:
35 explicit JsepSessionDescription(const std::string& type);
36 virtual ~JsepSessionDescription();
37
henrike@webrtc.org28e20752013-07-10 00:45:36 +000038 // Takes ownership of |description|.
deadbeefb10f32f2017-02-08 01:38:21 -080039 // TODO(deadbeef): Make this use an std::unique_ptr<>, so ownership logic is
40 // more clear.
henrike@webrtc.org28e20752013-07-10 00:45:36 +000041 bool Initialize(cricket::SessionDescription* description,
42 const std::string& session_id,
43 const std::string& session_version);
44
45 virtual cricket::SessionDescription* description() {
46 return description_.get();
47 }
48 virtual const cricket::SessionDescription* description() const {
49 return description_.get();
50 }
51 virtual std::string session_id() const {
52 return session_id_;
53 }
54 virtual std::string session_version() const {
55 return session_version_;
56 }
57 virtual std::string type() const {
58 return type_;
59 }
deadbeefb10f32f2017-02-08 01:38:21 -080060 // Allows changing the type. Used for testing.
henrike@webrtc.org28e20752013-07-10 00:45:36 +000061 void set_type(const std::string& type) { type_ = type; }
62 virtual bool AddCandidate(const IceCandidateInterface* candidate);
Honghai Zhang7fb69db2016-03-14 11:59:18 -070063 virtual size_t RemoveCandidates(
64 const std::vector<cricket::Candidate>& candidates);
henrike@webrtc.org28e20752013-07-10 00:45:36 +000065 virtual size_t number_of_mediasections() const;
66 virtual const IceCandidateCollection* candidates(
67 size_t mediasection_index) const;
68 virtual bool ToString(std::string* out) const;
69
henrike@webrtc.org28e20752013-07-10 00:45:36 +000070 static const int kDefaultVideoCodecId;
henrike@webrtc.org28e20752013-07-10 00:45:36 +000071 static const char kDefaultVideoCodecName[];
henrike@webrtc.org28e20752013-07-10 00:45:36 +000072
73 private:
kwibergd1fe2812016-04-27 06:47:29 -070074 std::unique_ptr<cricket::SessionDescription> description_;
henrike@webrtc.org28e20752013-07-10 00:45:36 +000075 std::string session_id_;
76 std::string session_version_;
77 std::string type_;
78 std::vector<JsepCandidateCollection> candidate_collection_;
79
80 bool GetMediasectionIndex(const IceCandidateInterface* candidate,
81 size_t* index);
Honghai Zhang7fb69db2016-03-14 11:59:18 -070082 int GetMediasectionIndex(const cricket::Candidate& candidate);
henrike@webrtc.org28e20752013-07-10 00:45:36 +000083
henrikg3c089d72015-09-16 05:37:44 -070084 RTC_DISALLOW_COPY_AND_ASSIGN(JsepSessionDescription);
henrike@webrtc.org28e20752013-07-10 00:45:36 +000085};
86
87} // namespace webrtc
88
Mirko Bonadei92ea95e2017-09-15 06:47:31 +020089#endif // API_JSEPSESSIONDESCRIPTION_H_