blob: 8f2ab5ff57aaa0d95d2214bcfc1b509aecfeae63 [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
kwibergd1fe2812016-04-27 06:47:29 -070016#include <memory>
henrike@webrtc.org28e20752013-07-10 00:45:36 +000017#include <string>
18#include <vector>
19
Henrik Kjellander15583c12016-02-10 10:53:12 +010020#include "webrtc/api/jsep.h"
21#include "webrtc/api/jsepicecandidate.h"
kwiberg4485ffb2016-04-26 08:14:39 -070022#include "webrtc/base/constructormagic.h"
Honghai Zhang7fb69db2016-03-14 11:59:18 -070023#include "webrtc/p2p/base/candidate.h"
henrike@webrtc.org28e20752013-07-10 00:45:36 +000024
25namespace cricket {
26class SessionDescription;
27}
28
29namespace webrtc {
30
31class 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 Zhang7fb69db2016-03-14 11:59:18 -070062 virtual size_t RemoveCandidates(
63 const std::vector<cricket::Candidate>& candidates);
henrike@webrtc.org28e20752013-07-10 00:45:36 +000064 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.org28e20752013-07-10 00:45:36 +000069 static const int kDefaultVideoCodecId;
henrike@webrtc.org28e20752013-07-10 00:45:36 +000070 static const char kDefaultVideoCodecName[];
henrike@webrtc.org28e20752013-07-10 00:45:36 +000071
72 private:
kwibergd1fe2812016-04-27 06:47:29 -070073 std::unique_ptr<cricket::SessionDescription> description_;
henrike@webrtc.org28e20752013-07-10 00:45:36 +000074 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 Zhang7fb69db2016-03-14 11:59:18 -070081 int GetMediasectionIndex(const cricket::Candidate& candidate);
henrike@webrtc.org28e20752013-07-10 00:45:36 +000082
henrikg3c089d72015-09-16 05:37:44 -070083 RTC_DISALLOW_COPY_AND_ASSIGN(JsepSessionDescription);
henrike@webrtc.org28e20752013-07-10 00:45:36 +000084};
85
86} // namespace webrtc
87
Henrik Kjellander15583c12016-02-10 10:53:12 +010088#endif // WEBRTC_API_JSEPSESSIONDESCRIPTION_H_