blob: cb234b09ca0d4d754f017fe0800a14bbf54cbaaa [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
Henrik Kjellander15583c12016-02-10 10:53:12 +010014#ifndef WEBRTC_API_JSEPSESSIONDESCRIPTION_H_
15#define WEBRTC_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
Henrik Kjellander15583c12016-02-10 10:53:12 +010021#include "webrtc/api/jsep.h"
22#include "webrtc/api/jsepicecandidate.h"
Honghai Zhang7fb69db2016-03-14 11:59:18 -070023#include "webrtc/p2p/base/candidate.h"
Edward Lemurc20978e2017-07-06 19:44:34 +020024#include "webrtc/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
deadbeef8d60a942017-02-27 14:47:33 -080038 // |error| may be null.
henrike@webrtc.org28e20752013-07-10 00:45:36 +000039 bool Initialize(const std::string& sdp, SdpParseError* error);
40
41 // Takes ownership of |description|.
deadbeefb10f32f2017-02-08 01:38:21 -080042 // TODO(deadbeef): Make this use an std::unique_ptr<>, so ownership logic is
43 // more clear.
henrike@webrtc.org28e20752013-07-10 00:45:36 +000044 bool Initialize(cricket::SessionDescription* description,
45 const std::string& session_id,
46 const std::string& session_version);
47
48 virtual cricket::SessionDescription* description() {
49 return description_.get();
50 }
51 virtual const cricket::SessionDescription* description() const {
52 return description_.get();
53 }
54 virtual std::string session_id() const {
55 return session_id_;
56 }
57 virtual std::string session_version() const {
58 return session_version_;
59 }
60 virtual std::string type() const {
61 return type_;
62 }
deadbeefb10f32f2017-02-08 01:38:21 -080063 // Allows changing the type. Used for testing.
henrike@webrtc.org28e20752013-07-10 00:45:36 +000064 void set_type(const std::string& type) { type_ = type; }
65 virtual bool AddCandidate(const IceCandidateInterface* candidate);
Honghai Zhang7fb69db2016-03-14 11:59:18 -070066 virtual size_t RemoveCandidates(
67 const std::vector<cricket::Candidate>& candidates);
henrike@webrtc.org28e20752013-07-10 00:45:36 +000068 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:36 +000073 static const int kDefaultVideoCodecId;
henrike@webrtc.org28e20752013-07-10 00:45:36 +000074 static const char kDefaultVideoCodecName[];
henrike@webrtc.org28e20752013-07-10 00:45:36 +000075
76 private:
kwibergd1fe2812016-04-27 06:47:29 -070077 std::unique_ptr<cricket::SessionDescription> description_;
henrike@webrtc.org28e20752013-07-10 00:45:36 +000078 std::string session_id_;
79 std::string session_version_;
80 std::string type_;
81 std::vector<JsepCandidateCollection> candidate_collection_;
82
83 bool GetMediasectionIndex(const IceCandidateInterface* candidate,
84 size_t* index);
Honghai Zhang7fb69db2016-03-14 11:59:18 -070085 int GetMediasectionIndex(const cricket::Candidate& candidate);
henrike@webrtc.org28e20752013-07-10 00:45:36 +000086
henrikg3c089d72015-09-16 05:37:44 -070087 RTC_DISALLOW_COPY_AND_ASSIGN(JsepSessionDescription);
henrike@webrtc.org28e20752013-07-10 00:45:36 +000088};
89
90} // namespace webrtc
91
Henrik Kjellander15583c12016-02-10 10:53:12 +010092#endif // WEBRTC_API_JSEPSESSIONDESCRIPTION_H_