blob: 9a0d8732044104990006588dd293cc1d23c68b61 [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
11// Implements the SessionDescriptionInterface.
12
Henrik Kjellander15583c12016-02-10 10:53:12 +010013#ifndef WEBRTC_API_JSEPSESSIONDESCRIPTION_H_
14#define WEBRTC_API_JSEPSESSIONDESCRIPTION_H_
henrike@webrtc.org28e20752013-07-10 00:45:36 +000015
16#include <string>
17#include <vector>
18
Henrik Kjellander15583c12016-02-10 10:53:12 +010019#include "webrtc/api/jsep.h"
20#include "webrtc/api/jsepicecandidate.h"
buildbot@webrtc.orgd4e598d2014-07-29 17:36:52 +000021#include "webrtc/base/scoped_ptr.h"
Honghai Zhang7fb69db2016-03-14 11:59:18 -070022#include "webrtc/p2p/base/candidate.h"
henrike@webrtc.org28e20752013-07-10 00:45:36 +000023
24namespace cricket {
25class SessionDescription;
26}
27
28namespace webrtc {
29
30class JsepSessionDescription : public SessionDescriptionInterface {
31 public:
32 explicit JsepSessionDescription(const std::string& type);
33 virtual ~JsepSessionDescription();
34
35 // |error| can be NULL if don't care about the failure reason.
36 bool Initialize(const std::string& sdp, SdpParseError* error);
37
38 // Takes ownership of |description|.
39 bool Initialize(cricket::SessionDescription* description,
40 const std::string& session_id,
41 const std::string& session_version);
42
43 virtual cricket::SessionDescription* description() {
44 return description_.get();
45 }
46 virtual const cricket::SessionDescription* description() const {
47 return description_.get();
48 }
49 virtual std::string session_id() const {
50 return session_id_;
51 }
52 virtual std::string session_version() const {
53 return session_version_;
54 }
55 virtual std::string type() const {
56 return type_;
57 }
58 // Allow changing the type. Used for testing.
59 void set_type(const std::string& type) { type_ = type; }
60 virtual bool AddCandidate(const IceCandidateInterface* candidate);
Honghai Zhang7fb69db2016-03-14 11:59:18 -070061 virtual size_t RemoveCandidates(
62 const std::vector<cricket::Candidate>& candidates);
henrike@webrtc.org28e20752013-07-10 00:45:36 +000063 virtual size_t number_of_mediasections() const;
64 virtual const IceCandidateCollection* candidates(
65 size_t mediasection_index) const;
66 virtual bool ToString(std::string* out) const;
67
68 // Default video encoder settings. The resolution is the max resolution.
69 // TODO(perkj): Implement proper negotiation of video resolution.
70 static const int kDefaultVideoCodecId;
71 static const int kDefaultVideoCodecFramerate;
72 static const char kDefaultVideoCodecName[];
73 static const int kMaxVideoCodecWidth;
74 static const int kMaxVideoCodecHeight;
75 static const int kDefaultVideoCodecPreference;
76
77 private:
buildbot@webrtc.orgd4e598d2014-07-29 17:36:52 +000078 rtc::scoped_ptr<cricket::SessionDescription> description_;
henrike@webrtc.org28e20752013-07-10 00:45:36 +000079 std::string session_id_;
80 std::string session_version_;
81 std::string type_;
82 std::vector<JsepCandidateCollection> candidate_collection_;
83
84 bool GetMediasectionIndex(const IceCandidateInterface* candidate,
85 size_t* index);
Honghai Zhang7fb69db2016-03-14 11:59:18 -070086 int GetMediasectionIndex(const cricket::Candidate& candidate);
henrike@webrtc.org28e20752013-07-10 00:45:36 +000087
henrikg3c089d72015-09-16 05:37:44 -070088 RTC_DISALLOW_COPY_AND_ASSIGN(JsepSessionDescription);
henrike@webrtc.org28e20752013-07-10 00:45:36 +000089};
90
91} // namespace webrtc
92
Henrik Kjellander15583c12016-02-10 10:53:12 +010093#endif // WEBRTC_API_JSEPSESSIONDESCRIPTION_H_