henrike@webrtc.org | 28e2075 | 2013-07-10 00:45:36 +0000 | [diff] [blame] | 1 | /* |
| 2 | * libjingle |
jlmiller@webrtc.org | 5f93d0a | 2015-01-20 21:36:13 +0000 | [diff] [blame] | 3 | * Copyright 2012 Google Inc. |
henrike@webrtc.org | 28e2075 | 2013-07-10 00:45:36 +0000 | [diff] [blame] | 4 | * |
| 5 | * Redistribution and use in source and binary forms, with or without |
| 6 | * modification, are permitted provided that the following conditions are met: |
| 7 | * |
| 8 | * 1. Redistributions of source code must retain the above copyright notice, |
| 9 | * this list of conditions and the following disclaimer. |
| 10 | * 2. Redistributions in binary form must reproduce the above copyright notice, |
| 11 | * this list of conditions and the following disclaimer in the documentation |
| 12 | * and/or other materials provided with the distribution. |
| 13 | * 3. The name of the author may not be used to endorse or promote products |
| 14 | * derived from this software without specific prior written permission. |
| 15 | * |
| 16 | * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR IMPLIED |
| 17 | * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF |
| 18 | * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO |
| 19 | * EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, |
| 20 | * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, |
| 21 | * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; |
| 22 | * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, |
| 23 | * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR |
| 24 | * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF |
| 25 | * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. |
| 26 | */ |
| 27 | |
| 28 | // Implements the SessionDescriptionInterface. |
| 29 | |
Henrik Kjellander | 15583c1 | 2016-02-10 10:53:12 +0100 | [diff] [blame^] | 30 | #ifndef WEBRTC_API_JSEPSESSIONDESCRIPTION_H_ |
| 31 | #define WEBRTC_API_JSEPSESSIONDESCRIPTION_H_ |
henrike@webrtc.org | 28e2075 | 2013-07-10 00:45:36 +0000 | [diff] [blame] | 32 | |
| 33 | #include <string> |
| 34 | #include <vector> |
| 35 | |
Henrik Kjellander | 15583c1 | 2016-02-10 10:53:12 +0100 | [diff] [blame^] | 36 | #include "webrtc/api/jsep.h" |
| 37 | #include "webrtc/api/jsepicecandidate.h" |
buildbot@webrtc.org | d4e598d | 2014-07-29 17:36:52 +0000 | [diff] [blame] | 38 | #include "webrtc/base/scoped_ptr.h" |
henrike@webrtc.org | 28e2075 | 2013-07-10 00:45:36 +0000 | [diff] [blame] | 39 | |
| 40 | namespace cricket { |
| 41 | class SessionDescription; |
| 42 | } |
| 43 | |
| 44 | namespace webrtc { |
| 45 | |
| 46 | class JsepSessionDescription : public SessionDescriptionInterface { |
| 47 | public: |
| 48 | explicit JsepSessionDescription(const std::string& type); |
| 49 | virtual ~JsepSessionDescription(); |
| 50 | |
| 51 | // |error| can be NULL if don't care about the failure reason. |
| 52 | bool Initialize(const std::string& sdp, SdpParseError* error); |
| 53 | |
| 54 | // Takes ownership of |description|. |
| 55 | bool Initialize(cricket::SessionDescription* description, |
| 56 | const std::string& session_id, |
| 57 | const std::string& session_version); |
| 58 | |
| 59 | virtual cricket::SessionDescription* description() { |
| 60 | return description_.get(); |
| 61 | } |
| 62 | virtual const cricket::SessionDescription* description() const { |
| 63 | return description_.get(); |
| 64 | } |
| 65 | virtual std::string session_id() const { |
| 66 | return session_id_; |
| 67 | } |
| 68 | virtual std::string session_version() const { |
| 69 | return session_version_; |
| 70 | } |
| 71 | virtual std::string type() const { |
| 72 | return type_; |
| 73 | } |
| 74 | // Allow changing the type. Used for testing. |
| 75 | void set_type(const std::string& type) { type_ = type; } |
| 76 | virtual bool AddCandidate(const IceCandidateInterface* candidate); |
| 77 | virtual size_t number_of_mediasections() const; |
| 78 | virtual const IceCandidateCollection* candidates( |
| 79 | size_t mediasection_index) const; |
| 80 | virtual bool ToString(std::string* out) const; |
| 81 | |
| 82 | // Default video encoder settings. The resolution is the max resolution. |
| 83 | // TODO(perkj): Implement proper negotiation of video resolution. |
| 84 | static const int kDefaultVideoCodecId; |
| 85 | static const int kDefaultVideoCodecFramerate; |
| 86 | static const char kDefaultVideoCodecName[]; |
| 87 | static const int kMaxVideoCodecWidth; |
| 88 | static const int kMaxVideoCodecHeight; |
| 89 | static const int kDefaultVideoCodecPreference; |
| 90 | |
| 91 | private: |
buildbot@webrtc.org | d4e598d | 2014-07-29 17:36:52 +0000 | [diff] [blame] | 92 | rtc::scoped_ptr<cricket::SessionDescription> description_; |
henrike@webrtc.org | 28e2075 | 2013-07-10 00:45:36 +0000 | [diff] [blame] | 93 | std::string session_id_; |
| 94 | std::string session_version_; |
| 95 | std::string type_; |
| 96 | std::vector<JsepCandidateCollection> candidate_collection_; |
| 97 | |
| 98 | bool GetMediasectionIndex(const IceCandidateInterface* candidate, |
| 99 | size_t* index); |
| 100 | |
henrikg | 3c089d7 | 2015-09-16 05:37:44 -0700 | [diff] [blame] | 101 | RTC_DISALLOW_COPY_AND_ASSIGN(JsepSessionDescription); |
henrike@webrtc.org | 28e2075 | 2013-07-10 00:45:36 +0000 | [diff] [blame] | 102 | }; |
| 103 | |
| 104 | } // namespace webrtc |
| 105 | |
Henrik Kjellander | 15583c1 | 2016-02-10 10:53:12 +0100 | [diff] [blame^] | 106 | #endif // WEBRTC_API_JSEPSESSIONDESCRIPTION_H_ |