1*d9f75844SAndroid Build Coastguard Worker /* 2*d9f75844SAndroid Build Coastguard Worker * Copyright 2012 The WebRTC project authors. All Rights Reserved. 3*d9f75844SAndroid Build Coastguard Worker * 4*d9f75844SAndroid Build Coastguard Worker * Use of this source code is governed by a BSD-style license 5*d9f75844SAndroid Build Coastguard Worker * that can be found in the LICENSE file in the root of the source 6*d9f75844SAndroid Build Coastguard Worker * tree. An additional intellectual property rights grant can be found 7*d9f75844SAndroid Build Coastguard Worker * in the file PATENTS. All contributing project authors may 8*d9f75844SAndroid Build Coastguard Worker * be found in the AUTHORS file in the root of the source tree. 9*d9f75844SAndroid Build Coastguard Worker */ 10*d9f75844SAndroid Build Coastguard Worker 11*d9f75844SAndroid Build Coastguard Worker // TODO(deadbeef): Move this out of api/; it's an implementation detail and 12*d9f75844SAndroid Build Coastguard Worker // shouldn't be used externally. 13*d9f75844SAndroid Build Coastguard Worker 14*d9f75844SAndroid Build Coastguard Worker #ifndef API_JSEP_SESSION_DESCRIPTION_H_ 15*d9f75844SAndroid Build Coastguard Worker #define API_JSEP_SESSION_DESCRIPTION_H_ 16*d9f75844SAndroid Build Coastguard Worker 17*d9f75844SAndroid Build Coastguard Worker #include <memory> 18*d9f75844SAndroid Build Coastguard Worker #include <string> 19*d9f75844SAndroid Build Coastguard Worker #include <vector> 20*d9f75844SAndroid Build Coastguard Worker 21*d9f75844SAndroid Build Coastguard Worker #include "absl/strings/string_view.h" 22*d9f75844SAndroid Build Coastguard Worker #include "api/candidate.h" 23*d9f75844SAndroid Build Coastguard Worker #include "api/jsep.h" 24*d9f75844SAndroid Build Coastguard Worker #include "api/jsep_ice_candidate.h" 25*d9f75844SAndroid Build Coastguard Worker 26*d9f75844SAndroid Build Coastguard Worker namespace cricket { 27*d9f75844SAndroid Build Coastguard Worker class SessionDescription; 28*d9f75844SAndroid Build Coastguard Worker } 29*d9f75844SAndroid Build Coastguard Worker 30*d9f75844SAndroid Build Coastguard Worker namespace webrtc { 31*d9f75844SAndroid Build Coastguard Worker 32*d9f75844SAndroid Build Coastguard Worker // Implementation of SessionDescriptionInterface. 33*d9f75844SAndroid Build Coastguard Worker class JsepSessionDescription : public SessionDescriptionInterface { 34*d9f75844SAndroid Build Coastguard Worker public: 35*d9f75844SAndroid Build Coastguard Worker explicit JsepSessionDescription(SdpType type); 36*d9f75844SAndroid Build Coastguard Worker // TODO(steveanton): Remove this once callers have switched to SdpType. 37*d9f75844SAndroid Build Coastguard Worker explicit JsepSessionDescription(const std::string& type); 38*d9f75844SAndroid Build Coastguard Worker JsepSessionDescription( 39*d9f75844SAndroid Build Coastguard Worker SdpType type, 40*d9f75844SAndroid Build Coastguard Worker std::unique_ptr<cricket::SessionDescription> description, 41*d9f75844SAndroid Build Coastguard Worker absl::string_view session_id, 42*d9f75844SAndroid Build Coastguard Worker absl::string_view session_version); 43*d9f75844SAndroid Build Coastguard Worker virtual ~JsepSessionDescription(); 44*d9f75844SAndroid Build Coastguard Worker 45*d9f75844SAndroid Build Coastguard Worker JsepSessionDescription(const JsepSessionDescription&) = delete; 46*d9f75844SAndroid Build Coastguard Worker JsepSessionDescription& operator=(const JsepSessionDescription&) = delete; 47*d9f75844SAndroid Build Coastguard Worker 48*d9f75844SAndroid Build Coastguard Worker // Takes ownership of `description`. 49*d9f75844SAndroid Build Coastguard Worker bool Initialize(std::unique_ptr<cricket::SessionDescription> description, 50*d9f75844SAndroid Build Coastguard Worker const std::string& session_id, 51*d9f75844SAndroid Build Coastguard Worker const std::string& session_version); 52*d9f75844SAndroid Build Coastguard Worker 53*d9f75844SAndroid Build Coastguard Worker virtual std::unique_ptr<SessionDescriptionInterface> Clone() const; 54*d9f75844SAndroid Build Coastguard Worker description()55*d9f75844SAndroid Build Coastguard Worker virtual cricket::SessionDescription* description() { 56*d9f75844SAndroid Build Coastguard Worker return description_.get(); 57*d9f75844SAndroid Build Coastguard Worker } description()58*d9f75844SAndroid Build Coastguard Worker virtual const cricket::SessionDescription* description() const { 59*d9f75844SAndroid Build Coastguard Worker return description_.get(); 60*d9f75844SAndroid Build Coastguard Worker } session_id()61*d9f75844SAndroid Build Coastguard Worker virtual std::string session_id() const { return session_id_; } session_version()62*d9f75844SAndroid Build Coastguard Worker virtual std::string session_version() const { return session_version_; } GetType()63*d9f75844SAndroid Build Coastguard Worker virtual SdpType GetType() const { return type_; } type()64*d9f75844SAndroid Build Coastguard Worker virtual std::string type() const { return SdpTypeToString(type_); } 65*d9f75844SAndroid Build Coastguard Worker // Allows changing the type. Used for testing. 66*d9f75844SAndroid Build Coastguard Worker virtual bool AddCandidate(const IceCandidateInterface* candidate); 67*d9f75844SAndroid Build Coastguard Worker virtual size_t RemoveCandidates( 68*d9f75844SAndroid Build Coastguard Worker const std::vector<cricket::Candidate>& candidates); 69*d9f75844SAndroid Build Coastguard Worker virtual size_t number_of_mediasections() const; 70*d9f75844SAndroid Build Coastguard Worker virtual const IceCandidateCollection* candidates( 71*d9f75844SAndroid Build Coastguard Worker size_t mediasection_index) const; 72*d9f75844SAndroid Build Coastguard Worker virtual bool ToString(std::string* out) const; 73*d9f75844SAndroid Build Coastguard Worker 74*d9f75844SAndroid Build Coastguard Worker static const int kDefaultVideoCodecId; 75*d9f75844SAndroid Build Coastguard Worker static const char kDefaultVideoCodecName[]; 76*d9f75844SAndroid Build Coastguard Worker 77*d9f75844SAndroid Build Coastguard Worker private: 78*d9f75844SAndroid Build Coastguard Worker std::unique_ptr<cricket::SessionDescription> description_; 79*d9f75844SAndroid Build Coastguard Worker std::string session_id_; 80*d9f75844SAndroid Build Coastguard Worker std::string session_version_; 81*d9f75844SAndroid Build Coastguard Worker SdpType type_; 82*d9f75844SAndroid Build Coastguard Worker std::vector<JsepCandidateCollection> candidate_collection_; 83*d9f75844SAndroid Build Coastguard Worker 84*d9f75844SAndroid Build Coastguard Worker bool GetMediasectionIndex(const IceCandidateInterface* candidate, 85*d9f75844SAndroid Build Coastguard Worker size_t* index); 86*d9f75844SAndroid Build Coastguard Worker int GetMediasectionIndex(const cricket::Candidate& candidate); 87*d9f75844SAndroid Build Coastguard Worker }; 88*d9f75844SAndroid Build Coastguard Worker 89*d9f75844SAndroid Build Coastguard Worker } // namespace webrtc 90*d9f75844SAndroid Build Coastguard Worker 91*d9f75844SAndroid Build Coastguard Worker #endif // API_JSEP_SESSION_DESCRIPTION_H_ 92