blob: 244ee1921277656b64e9361f7f1db1bd87964b13 [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"
henrike@webrtc.org28e20752013-07-10 00:45:36 +000022
23namespace cricket {
24class SessionDescription;
25}
26
27namespace webrtc {
28
29class JsepSessionDescription : public SessionDescriptionInterface {
30 public:
31 explicit JsepSessionDescription(const std::string& type);
32 virtual ~JsepSessionDescription();
33
34 // |error| can be NULL if don't care about the failure reason.
35 bool Initialize(const std::string& sdp, SdpParseError* error);
36
37 // Takes ownership of |description|.
38 bool Initialize(cricket::SessionDescription* description,
39 const std::string& session_id,
40 const std::string& session_version);
41
42 virtual cricket::SessionDescription* description() {
43 return description_.get();
44 }
45 virtual const cricket::SessionDescription* description() const {
46 return description_.get();
47 }
48 virtual std::string session_id() const {
49 return session_id_;
50 }
51 virtual std::string session_version() const {
52 return session_version_;
53 }
54 virtual std::string type() const {
55 return type_;
56 }
57 // Allow changing the type. Used for testing.
58 void set_type(const std::string& type) { type_ = type; }
59 virtual bool AddCandidate(const IceCandidateInterface* candidate);
60 virtual size_t number_of_mediasections() const;
61 virtual const IceCandidateCollection* candidates(
62 size_t mediasection_index) const;
63 virtual bool ToString(std::string* out) const;
64
65 // Default video encoder settings. The resolution is the max resolution.
66 // TODO(perkj): Implement proper negotiation of video resolution.
67 static const int kDefaultVideoCodecId;
68 static const int kDefaultVideoCodecFramerate;
69 static const char kDefaultVideoCodecName[];
70 static const int kMaxVideoCodecWidth;
71 static const int kMaxVideoCodecHeight;
72 static const int kDefaultVideoCodecPreference;
73
74 private:
buildbot@webrtc.orgd4e598d2014-07-29 17:36:52 +000075 rtc::scoped_ptr<cricket::SessionDescription> description_;
henrike@webrtc.org28e20752013-07-10 00:45:36 +000076 std::string session_id_;
77 std::string session_version_;
78 std::string type_;
79 std::vector<JsepCandidateCollection> candidate_collection_;
80
81 bool GetMediasectionIndex(const IceCandidateInterface* candidate,
82 size_t* index);
83
henrikg3c089d72015-09-16 05:37:44 -070084 RTC_DISALLOW_COPY_AND_ASSIGN(JsepSessionDescription);
henrike@webrtc.org28e20752013-07-10 00:45:36 +000085};
86
87} // namespace webrtc
88
Henrik Kjellander15583c12016-02-10 10:53:12 +010089#endif // WEBRTC_API_JSEPSESSIONDESCRIPTION_H_