| 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 |  | 
| deadbeef | b10f32f | 2017-02-08 01:38:21 -0800 | [diff] [blame] | 11 | // TODO(deadbeef): Move this out of api/; it's an implementation detail and | 
 | 12 | // shouldn't be used externally. | 
| henrike@webrtc.org | 28e2075 | 2013-07-10 00:45:36 +0000 | [diff] [blame] | 13 |  | 
| Mirko Bonadei | 92ea95e | 2017-09-15 06:47:31 +0200 | [diff] [blame] | 14 | #ifndef API_JSEPSESSIONDESCRIPTION_H_ | 
 | 15 | #define API_JSEPSESSIONDESCRIPTION_H_ | 
| henrike@webrtc.org | 28e2075 | 2013-07-10 00:45:36 +0000 | [diff] [blame] | 16 |  | 
| kwiberg | d1fe281 | 2016-04-27 06:47:29 -0700 | [diff] [blame] | 17 | #include <memory> | 
| henrike@webrtc.org | 28e2075 | 2013-07-10 00:45:36 +0000 | [diff] [blame] | 18 | #include <string> | 
 | 19 | #include <vector> | 
 | 20 |  | 
| Patrik Höglund | e2d6a06 | 2017-10-05 14:53:33 +0200 | [diff] [blame] | 21 | #include "api/candidate.h" | 
| Mirko Bonadei | 92ea95e | 2017-09-15 06:47:31 +0200 | [diff] [blame] | 22 | #include "api/jsep.h" | 
 | 23 | #include "api/jsepicecandidate.h" | 
| Mirko Bonadei | 92ea95e | 2017-09-15 06:47:31 +0200 | [diff] [blame] | 24 | #include "rtc_base/constructormagic.h" | 
| henrike@webrtc.org | 28e2075 | 2013-07-10 00:45:36 +0000 | [diff] [blame] | 25 |  | 
 | 26 | namespace cricket { | 
 | 27 | class SessionDescription; | 
 | 28 | } | 
 | 29 |  | 
 | 30 | namespace webrtc { | 
 | 31 |  | 
| deadbeef | b10f32f | 2017-02-08 01:38:21 -0800 | [diff] [blame] | 32 | // Implementation of SessionDescriptionInterface. | 
| henrike@webrtc.org | 28e2075 | 2013-07-10 00:45:36 +0000 | [diff] [blame] | 33 | class JsepSessionDescription : public SessionDescriptionInterface { | 
 | 34 |  public: | 
| Steve Anton | 88f2cb9 | 2017-12-05 12:47:32 -0800 | [diff] [blame] | 35 |   explicit JsepSessionDescription(SdpType type); | 
 | 36 |   // TODO(steveanton): Remove this once callers have switched to SdpType. | 
| henrike@webrtc.org | 28e2075 | 2013-07-10 00:45:36 +0000 | [diff] [blame] | 37 |   explicit JsepSessionDescription(const std::string& type); | 
 | 38 |   virtual ~JsepSessionDescription(); | 
 | 39 |  | 
| henrike@webrtc.org | 28e2075 | 2013-07-10 00:45:36 +0000 | [diff] [blame] | 40 |   // Takes ownership of |description|. | 
| deadbeef | b10f32f | 2017-02-08 01:38:21 -0800 | [diff] [blame] | 41 |   // TODO(deadbeef): Make this use an std::unique_ptr<>, so ownership logic is | 
 | 42 |   // more clear. | 
| henrike@webrtc.org | 28e2075 | 2013-07-10 00:45:36 +0000 | [diff] [blame] | 43 |   bool Initialize(cricket::SessionDescription* description, | 
 | 44 |       const std::string& session_id, | 
 | 45 |       const std::string& session_version); | 
 | 46 |  | 
 | 47 |   virtual cricket::SessionDescription* description() { | 
 | 48 |     return description_.get(); | 
 | 49 |   } | 
 | 50 |   virtual const cricket::SessionDescription* description() const { | 
 | 51 |     return description_.get(); | 
 | 52 |   } | 
 | 53 |   virtual std::string session_id() const { | 
 | 54 |     return session_id_; | 
 | 55 |   } | 
 | 56 |   virtual std::string session_version() const { | 
 | 57 |     return session_version_; | 
 | 58 |   } | 
| Steve Anton | 88f2cb9 | 2017-12-05 12:47:32 -0800 | [diff] [blame] | 59 |   virtual SdpType GetType() const { return type_; } | 
 | 60 |   virtual std::string type() const { return SdpTypeToString(type_); } | 
| deadbeef | b10f32f | 2017-02-08 01:38:21 -0800 | [diff] [blame] | 61 |   // Allows changing the type. Used for testing. | 
| henrike@webrtc.org | 28e2075 | 2013-07-10 00:45:36 +0000 | [diff] [blame] | 62 |   virtual bool AddCandidate(const IceCandidateInterface* candidate); | 
| Honghai Zhang | 7fb69db | 2016-03-14 11:59:18 -0700 | [diff] [blame] | 63 |   virtual size_t RemoveCandidates( | 
 | 64 |       const std::vector<cricket::Candidate>& candidates); | 
| henrike@webrtc.org | 28e2075 | 2013-07-10 00:45:36 +0000 | [diff] [blame] | 65 |   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.org | 28e2075 | 2013-07-10 00:45:36 +0000 | [diff] [blame] | 70 |   static const int kDefaultVideoCodecId; | 
| henrike@webrtc.org | 28e2075 | 2013-07-10 00:45:36 +0000 | [diff] [blame] | 71 |   static const char kDefaultVideoCodecName[]; | 
| henrike@webrtc.org | 28e2075 | 2013-07-10 00:45:36 +0000 | [diff] [blame] | 72 |  | 
 | 73 |  private: | 
| kwiberg | d1fe281 | 2016-04-27 06:47:29 -0700 | [diff] [blame] | 74 |   std::unique_ptr<cricket::SessionDescription> description_; | 
| henrike@webrtc.org | 28e2075 | 2013-07-10 00:45:36 +0000 | [diff] [blame] | 75 |   std::string session_id_; | 
 | 76 |   std::string session_version_; | 
| Steve Anton | 88f2cb9 | 2017-12-05 12:47:32 -0800 | [diff] [blame] | 77 |   SdpType type_; | 
| henrike@webrtc.org | 28e2075 | 2013-07-10 00:45:36 +0000 | [diff] [blame] | 78 |   std::vector<JsepCandidateCollection> candidate_collection_; | 
 | 79 |  | 
 | 80 |   bool GetMediasectionIndex(const IceCandidateInterface* candidate, | 
 | 81 |                             size_t* index); | 
| Honghai Zhang | 7fb69db | 2016-03-14 11:59:18 -0700 | [diff] [blame] | 82 |   int GetMediasectionIndex(const cricket::Candidate& candidate); | 
| henrike@webrtc.org | 28e2075 | 2013-07-10 00:45:36 +0000 | [diff] [blame] | 83 |  | 
| henrikg | 3c089d7 | 2015-09-16 05:37:44 -0700 | [diff] [blame] | 84 |   RTC_DISALLOW_COPY_AND_ASSIGN(JsepSessionDescription); | 
| henrike@webrtc.org | 28e2075 | 2013-07-10 00:45:36 +0000 | [diff] [blame] | 85 | }; | 
 | 86 |  | 
 | 87 | }  // namespace webrtc | 
 | 88 |  | 
| Mirko Bonadei | 92ea95e | 2017-09-15 06:47:31 +0200 | [diff] [blame] | 89 | #endif  // API_JSEPSESSIONDESCRIPTION_H_ |