henrike@webrtc.org | 28e2075 | 2013-07-10 00:45:36 +0000 | [diff] [blame] | 1 | /* |
kjellander | b24317b | 2016-02-10 07:54:43 -0800 | [diff] [blame] | 2 | * Copyright 2012 The WebRTC project authors. All Rights Reserved. |
henrike@webrtc.org | 28e2075 | 2013-07-10 00:45:36 +0000 | [diff] [blame] | 3 | * |
kjellander | b24317b | 2016-02-10 07:54:43 -0800 | [diff] [blame] | 4 | * 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.org | 28e2075 | 2013-07-10 00:45:36 +0000 | [diff] [blame] | 9 | */ |
| 10 | |
| 11 | // Implements the SessionDescriptionInterface. |
| 12 | |
Henrik Kjellander | 15583c1 | 2016-02-10 10:53:12 +0100 | [diff] [blame] | 13 | #ifndef WEBRTC_API_JSEPSESSIONDESCRIPTION_H_ |
| 14 | #define WEBRTC_API_JSEPSESSIONDESCRIPTION_H_ |
henrike@webrtc.org | 28e2075 | 2013-07-10 00:45:36 +0000 | [diff] [blame] | 15 | |
kwiberg | d1fe281 | 2016-04-27 06:47:29 -0700 | [diff] [blame] | 16 | #include <memory> |
henrike@webrtc.org | 28e2075 | 2013-07-10 00:45:36 +0000 | [diff] [blame] | 17 | #include <string> |
| 18 | #include <vector> |
| 19 | |
Henrik Kjellander | 15583c1 | 2016-02-10 10:53:12 +0100 | [diff] [blame] | 20 | #include "webrtc/api/jsep.h" |
| 21 | #include "webrtc/api/jsepicecandidate.h" |
kwiberg | 4485ffb | 2016-04-26 08:14:39 -0700 | [diff] [blame] | 22 | #include "webrtc/base/constructormagic.h" |
Honghai Zhang | 7fb69db | 2016-03-14 11:59:18 -0700 | [diff] [blame] | 23 | #include "webrtc/p2p/base/candidate.h" |
henrike@webrtc.org | 28e2075 | 2013-07-10 00:45:36 +0000 | [diff] [blame] | 24 | |
| 25 | namespace cricket { |
| 26 | class SessionDescription; |
| 27 | } |
| 28 | |
| 29 | namespace webrtc { |
| 30 | |
| 31 | class JsepSessionDescription : public SessionDescriptionInterface { |
| 32 | public: |
| 33 | explicit JsepSessionDescription(const std::string& type); |
| 34 | virtual ~JsepSessionDescription(); |
| 35 | |
| 36 | // |error| can be NULL if don't care about the failure reason. |
| 37 | bool Initialize(const std::string& sdp, SdpParseError* error); |
| 38 | |
| 39 | // Takes ownership of |description|. |
| 40 | bool Initialize(cricket::SessionDescription* description, |
| 41 | const std::string& session_id, |
| 42 | const std::string& session_version); |
| 43 | |
| 44 | virtual cricket::SessionDescription* description() { |
| 45 | return description_.get(); |
| 46 | } |
| 47 | virtual const cricket::SessionDescription* description() const { |
| 48 | return description_.get(); |
| 49 | } |
| 50 | virtual std::string session_id() const { |
| 51 | return session_id_; |
| 52 | } |
| 53 | virtual std::string session_version() const { |
| 54 | return session_version_; |
| 55 | } |
| 56 | virtual std::string type() const { |
| 57 | return type_; |
| 58 | } |
| 59 | // Allow changing the type. Used for testing. |
| 60 | void set_type(const std::string& type) { type_ = type; } |
| 61 | virtual bool AddCandidate(const IceCandidateInterface* candidate); |
Honghai Zhang | 7fb69db | 2016-03-14 11:59:18 -0700 | [diff] [blame] | 62 | virtual size_t RemoveCandidates( |
| 63 | const std::vector<cricket::Candidate>& candidates); |
henrike@webrtc.org | 28e2075 | 2013-07-10 00:45:36 +0000 | [diff] [blame] | 64 | virtual size_t number_of_mediasections() const; |
| 65 | virtual const IceCandidateCollection* candidates( |
| 66 | size_t mediasection_index) const; |
| 67 | virtual bool ToString(std::string* out) const; |
| 68 | |
henrike@webrtc.org | 28e2075 | 2013-07-10 00:45:36 +0000 | [diff] [blame] | 69 | static const int kDefaultVideoCodecId; |
henrike@webrtc.org | 28e2075 | 2013-07-10 00:45:36 +0000 | [diff] [blame] | 70 | static const char kDefaultVideoCodecName[]; |
henrike@webrtc.org | 28e2075 | 2013-07-10 00:45:36 +0000 | [diff] [blame] | 71 | |
| 72 | private: |
kwiberg | d1fe281 | 2016-04-27 06:47:29 -0700 | [diff] [blame] | 73 | std::unique_ptr<cricket::SessionDescription> description_; |
henrike@webrtc.org | 28e2075 | 2013-07-10 00:45:36 +0000 | [diff] [blame] | 74 | std::string session_id_; |
| 75 | std::string session_version_; |
| 76 | std::string type_; |
| 77 | std::vector<JsepCandidateCollection> candidate_collection_; |
| 78 | |
| 79 | bool GetMediasectionIndex(const IceCandidateInterface* candidate, |
| 80 | size_t* index); |
Honghai Zhang | 7fb69db | 2016-03-14 11:59:18 -0700 | [diff] [blame] | 81 | int GetMediasectionIndex(const cricket::Candidate& candidate); |
henrike@webrtc.org | 28e2075 | 2013-07-10 00:45:36 +0000 | [diff] [blame] | 82 | |
henrikg | 3c089d7 | 2015-09-16 05:37:44 -0700 | [diff] [blame] | 83 | RTC_DISALLOW_COPY_AND_ASSIGN(JsepSessionDescription); |
henrike@webrtc.org | 28e2075 | 2013-07-10 00:45:36 +0000 | [diff] [blame] | 84 | }; |
| 85 | |
| 86 | } // namespace webrtc |
| 87 | |
Henrik Kjellander | 15583c1 | 2016-02-10 10:53:12 +0100 | [diff] [blame] | 88 | #endif // WEBRTC_API_JSEPSESSIONDESCRIPTION_H_ |