Steve Anton | 4ab68ee | 2017-12-19 14:26:11 -0800 | [diff] [blame] | 1 | /* |
| 2 | * Copyright 2004 The WebRTC Project Authors. All rights reserved. |
| 3 | * |
| 4 | * 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. |
| 9 | */ |
| 10 | |
| 11 | #ifndef PC_SESSIONDESCRIPTION_H_ |
| 12 | #define PC_SESSIONDESCRIPTION_H_ |
| 13 | |
| 14 | #include <string> |
| 15 | #include <vector> |
| 16 | |
Steve Anton | afd8e8c | 2017-12-19 16:35:35 -0800 | [diff] [blame] | 17 | #include "api/cryptoparams.h" |
| 18 | #include "api/rtpparameters.h" |
| 19 | #include "api/rtptransceiverinterface.h" |
| 20 | #include "media/base/codec.h" |
| 21 | #include "media/base/mediachannel.h" |
| 22 | #include "media/base/streamparams.h" |
Steve Anton | 4ab68ee | 2017-12-19 14:26:11 -0800 | [diff] [blame] | 23 | #include "p2p/base/transportinfo.h" |
| 24 | #include "rtc_base/constructormagic.h" |
| 25 | |
| 26 | namespace cricket { |
| 27 | |
Steve Anton | afd8e8c | 2017-12-19 16:35:35 -0800 | [diff] [blame] | 28 | typedef std::vector<AudioCodec> AudioCodecs; |
| 29 | typedef std::vector<VideoCodec> VideoCodecs; |
| 30 | typedef std::vector<DataCodec> DataCodecs; |
| 31 | typedef std::vector<CryptoParams> CryptoParamsVec; |
| 32 | typedef std::vector<webrtc::RtpExtension> RtpHeaderExtensions; |
| 33 | |
| 34 | // RTC4585 RTP/AVPF |
| 35 | extern const char kMediaProtocolAvpf[]; |
| 36 | // RFC5124 RTP/SAVPF |
| 37 | extern const char kMediaProtocolSavpf[]; |
| 38 | |
| 39 | extern const char kMediaProtocolDtlsSavpf[]; |
| 40 | |
| 41 | extern const char kMediaProtocolRtpPrefix[]; |
| 42 | |
| 43 | extern const char kMediaProtocolSctp[]; |
| 44 | extern const char kMediaProtocolDtlsSctp[]; |
| 45 | extern const char kMediaProtocolUdpDtlsSctp[]; |
| 46 | extern const char kMediaProtocolTcpDtlsSctp[]; |
| 47 | |
| 48 | // Options to control how session descriptions are generated. |
| 49 | const int kAutoBandwidth = -1; |
| 50 | |
Steve Anton | 5adfafd | 2017-12-20 16:34:00 -0800 | [diff] [blame] | 51 | class AudioContentDescription; |
| 52 | class VideoContentDescription; |
| 53 | class DataContentDescription; |
Steve Anton | 4ab68ee | 2017-12-19 14:26:11 -0800 | [diff] [blame] | 54 | |
Steve Anton | 5adfafd | 2017-12-20 16:34:00 -0800 | [diff] [blame] | 55 | // Describes a session description media section. There are subclasses for each |
| 56 | // media type (audio, video, data) that will have additional information. |
| 57 | class MediaContentDescription { |
Steve Anton | afd8e8c | 2017-12-19 16:35:35 -0800 | [diff] [blame] | 58 | public: |
Steve Anton | 5adfafd | 2017-12-20 16:34:00 -0800 | [diff] [blame] | 59 | MediaContentDescription() = default; |
| 60 | virtual ~MediaContentDescription() = default; |
Steve Anton | afd8e8c | 2017-12-19 16:35:35 -0800 | [diff] [blame] | 61 | |
| 62 | virtual MediaType type() const = 0; |
Steve Anton | 5adfafd | 2017-12-20 16:34:00 -0800 | [diff] [blame] | 63 | |
| 64 | // Try to cast this media description to an AudioContentDescription. Returns |
| 65 | // nullptr if the cast fails. |
| 66 | virtual AudioContentDescription* as_audio() { return nullptr; } |
| 67 | virtual const AudioContentDescription* as_audio() const { return nullptr; } |
| 68 | |
| 69 | // Try to cast this media description to a VideoContentDescription. Returns |
| 70 | // nullptr if the cast fails. |
| 71 | virtual VideoContentDescription* as_video() { return nullptr; } |
| 72 | virtual const VideoContentDescription* as_video() const { return nullptr; } |
| 73 | |
| 74 | // Try to cast this media description to a DataContentDescription. Returns |
| 75 | // nullptr if the cast fails. |
| 76 | virtual DataContentDescription* as_data() { return nullptr; } |
| 77 | virtual const DataContentDescription* as_data() const { return nullptr; } |
| 78 | |
Steve Anton | afd8e8c | 2017-12-19 16:35:35 -0800 | [diff] [blame] | 79 | virtual bool has_codecs() const = 0; |
| 80 | |
Steve Anton | 5adfafd | 2017-12-20 16:34:00 -0800 | [diff] [blame] | 81 | virtual MediaContentDescription* Copy() const = 0; |
| 82 | |
Steve Anton | afd8e8c | 2017-12-19 16:35:35 -0800 | [diff] [blame] | 83 | // |protocol| is the expected media transport protocol, such as RTP/AVPF, |
| 84 | // RTP/SAVPF or SCTP/DTLS. |
| 85 | std::string protocol() const { return protocol_; } |
| 86 | void set_protocol(const std::string& protocol) { protocol_ = protocol; } |
| 87 | |
| 88 | webrtc::RtpTransceiverDirection direction() const { return direction_; } |
| 89 | void set_direction(webrtc::RtpTransceiverDirection direction) { |
| 90 | direction_ = direction; |
| 91 | } |
| 92 | |
| 93 | bool rtcp_mux() const { return rtcp_mux_; } |
| 94 | void set_rtcp_mux(bool mux) { rtcp_mux_ = mux; } |
| 95 | |
| 96 | bool rtcp_reduced_size() const { return rtcp_reduced_size_; } |
| 97 | void set_rtcp_reduced_size(bool reduced_size) { |
| 98 | rtcp_reduced_size_ = reduced_size; |
| 99 | } |
| 100 | |
| 101 | int bandwidth() const { return bandwidth_; } |
| 102 | void set_bandwidth(int bandwidth) { bandwidth_ = bandwidth; } |
| 103 | |
| 104 | const std::vector<CryptoParams>& cryptos() const { return cryptos_; } |
| 105 | void AddCrypto(const CryptoParams& params) { cryptos_.push_back(params); } |
| 106 | void set_cryptos(const std::vector<CryptoParams>& cryptos) { |
| 107 | cryptos_ = cryptos; |
| 108 | } |
| 109 | |
| 110 | const RtpHeaderExtensions& rtp_header_extensions() const { |
| 111 | return rtp_header_extensions_; |
| 112 | } |
| 113 | void set_rtp_header_extensions(const RtpHeaderExtensions& extensions) { |
| 114 | rtp_header_extensions_ = extensions; |
| 115 | rtp_header_extensions_set_ = true; |
| 116 | } |
| 117 | void AddRtpHeaderExtension(const webrtc::RtpExtension& ext) { |
| 118 | rtp_header_extensions_.push_back(ext); |
| 119 | rtp_header_extensions_set_ = true; |
| 120 | } |
| 121 | void AddRtpHeaderExtension(const cricket::RtpHeaderExtension& ext) { |
| 122 | webrtc::RtpExtension webrtc_extension; |
| 123 | webrtc_extension.uri = ext.uri; |
| 124 | webrtc_extension.id = ext.id; |
| 125 | rtp_header_extensions_.push_back(webrtc_extension); |
| 126 | rtp_header_extensions_set_ = true; |
| 127 | } |
| 128 | void ClearRtpHeaderExtensions() { |
| 129 | rtp_header_extensions_.clear(); |
| 130 | rtp_header_extensions_set_ = true; |
| 131 | } |
| 132 | // We can't always tell if an empty list of header extensions is |
| 133 | // because the other side doesn't support them, or just isn't hooked up to |
| 134 | // signal them. For now we assume an empty list means no signaling, but |
| 135 | // provide the ClearRtpHeaderExtensions method to allow "no support" to be |
| 136 | // clearly indicated (i.e. when derived from other information). |
| 137 | bool rtp_header_extensions_set() const { return rtp_header_extensions_set_; } |
| 138 | const StreamParamsVec& streams() const { return streams_; } |
| 139 | // TODO(pthatcher): Remove this by giving mediamessage.cc access |
| 140 | // to MediaContentDescription |
| 141 | StreamParamsVec& mutable_streams() { return streams_; } |
| 142 | void AddStream(const StreamParams& stream) { streams_.push_back(stream); } |
| 143 | // Legacy streams have an ssrc, but nothing else. |
| 144 | void AddLegacyStream(uint32_t ssrc) { |
| 145 | streams_.push_back(StreamParams::CreateLegacy(ssrc)); |
| 146 | } |
| 147 | void AddLegacyStream(uint32_t ssrc, uint32_t fid_ssrc) { |
| 148 | StreamParams sp = StreamParams::CreateLegacy(ssrc); |
| 149 | sp.AddFidSsrc(ssrc, fid_ssrc); |
| 150 | streams_.push_back(sp); |
| 151 | } |
| 152 | // Sets the CNAME of all StreamParams if it have not been set. |
| 153 | void SetCnameIfEmpty(const std::string& cname) { |
| 154 | for (cricket::StreamParamsVec::iterator it = streams_.begin(); |
| 155 | it != streams_.end(); ++it) { |
| 156 | if (it->cname.empty()) |
| 157 | it->cname = cname; |
| 158 | } |
| 159 | } |
| 160 | uint32_t first_ssrc() const { |
| 161 | if (streams_.empty()) { |
| 162 | return 0; |
| 163 | } |
| 164 | return streams_[0].first_ssrc(); |
| 165 | } |
| 166 | bool has_ssrcs() const { |
| 167 | if (streams_.empty()) { |
| 168 | return false; |
| 169 | } |
| 170 | return streams_[0].has_ssrcs(); |
| 171 | } |
| 172 | |
| 173 | void set_conference_mode(bool enable) { conference_mode_ = enable; } |
| 174 | bool conference_mode() const { return conference_mode_; } |
| 175 | |
| 176 | // https://tools.ietf.org/html/rfc4566#section-5.7 |
| 177 | // May be present at the media or session level of SDP. If present at both |
| 178 | // levels, the media-level attribute overwrites the session-level one. |
| 179 | void set_connection_address(const rtc::SocketAddress& address) { |
| 180 | connection_address_ = address; |
| 181 | } |
| 182 | const rtc::SocketAddress& connection_address() const { |
| 183 | return connection_address_; |
| 184 | } |
| 185 | |
| 186 | protected: |
| 187 | bool rtcp_mux_ = false; |
| 188 | bool rtcp_reduced_size_ = false; |
| 189 | int bandwidth_ = kAutoBandwidth; |
| 190 | std::string protocol_; |
| 191 | std::vector<CryptoParams> cryptos_; |
| 192 | std::vector<webrtc::RtpExtension> rtp_header_extensions_; |
| 193 | bool rtp_header_extensions_set_ = false; |
| 194 | StreamParamsVec streams_; |
| 195 | bool conference_mode_ = false; |
| 196 | webrtc::RtpTransceiverDirection direction_ = |
| 197 | webrtc::RtpTransceiverDirection::kSendRecv; |
| 198 | rtc::SocketAddress connection_address_; |
| 199 | }; |
| 200 | |
Steve Anton | 5adfafd | 2017-12-20 16:34:00 -0800 | [diff] [blame] | 201 | // TODO(bugs.webrtc.org/8620): Remove this alias once downstream projects have |
| 202 | // updated. |
| 203 | using ContentDescription = MediaContentDescription; |
| 204 | |
Steve Anton | afd8e8c | 2017-12-19 16:35:35 -0800 | [diff] [blame] | 205 | template <class C> |
| 206 | class MediaContentDescriptionImpl : public MediaContentDescription { |
| 207 | public: |
| 208 | typedef C CodecType; |
| 209 | |
| 210 | // Codecs should be in preference order (most preferred codec first). |
| 211 | const std::vector<C>& codecs() const { return codecs_; } |
| 212 | void set_codecs(const std::vector<C>& codecs) { codecs_ = codecs; } |
| 213 | virtual bool has_codecs() const { return !codecs_.empty(); } |
| 214 | bool HasCodec(int id) { |
| 215 | bool found = false; |
| 216 | for (typename std::vector<C>::iterator iter = codecs_.begin(); |
| 217 | iter != codecs_.end(); ++iter) { |
| 218 | if (iter->id == id) { |
| 219 | found = true; |
| 220 | break; |
| 221 | } |
| 222 | } |
| 223 | return found; |
| 224 | } |
| 225 | void AddCodec(const C& codec) { codecs_.push_back(codec); } |
| 226 | void AddOrReplaceCodec(const C& codec) { |
| 227 | for (typename std::vector<C>::iterator iter = codecs_.begin(); |
| 228 | iter != codecs_.end(); ++iter) { |
| 229 | if (iter->id == codec.id) { |
| 230 | *iter = codec; |
| 231 | return; |
| 232 | } |
| 233 | } |
| 234 | AddCodec(codec); |
| 235 | } |
| 236 | void AddCodecs(const std::vector<C>& codecs) { |
| 237 | typename std::vector<C>::const_iterator codec; |
| 238 | for (codec = codecs.begin(); codec != codecs.end(); ++codec) { |
| 239 | AddCodec(*codec); |
| 240 | } |
| 241 | } |
| 242 | |
| 243 | private: |
| 244 | std::vector<C> codecs_; |
| 245 | }; |
| 246 | |
| 247 | class AudioContentDescription : public MediaContentDescriptionImpl<AudioCodec> { |
| 248 | public: |
| 249 | AudioContentDescription() {} |
| 250 | |
Steve Anton | b1c1de1 | 2017-12-21 15:14:30 -0800 | [diff] [blame] | 251 | virtual AudioContentDescription* Copy() const { |
Steve Anton | afd8e8c | 2017-12-19 16:35:35 -0800 | [diff] [blame] | 252 | return new AudioContentDescription(*this); |
| 253 | } |
| 254 | virtual MediaType type() const { return MEDIA_TYPE_AUDIO; } |
Steve Anton | 5adfafd | 2017-12-20 16:34:00 -0800 | [diff] [blame] | 255 | virtual AudioContentDescription* as_audio() { return this; } |
| 256 | virtual const AudioContentDescription* as_audio() const { return this; } |
Steve Anton | afd8e8c | 2017-12-19 16:35:35 -0800 | [diff] [blame] | 257 | }; |
| 258 | |
| 259 | class VideoContentDescription : public MediaContentDescriptionImpl<VideoCodec> { |
| 260 | public: |
Steve Anton | b1c1de1 | 2017-12-21 15:14:30 -0800 | [diff] [blame] | 261 | virtual VideoContentDescription* Copy() const { |
Steve Anton | afd8e8c | 2017-12-19 16:35:35 -0800 | [diff] [blame] | 262 | return new VideoContentDescription(*this); |
| 263 | } |
| 264 | virtual MediaType type() const { return MEDIA_TYPE_VIDEO; } |
Steve Anton | 5adfafd | 2017-12-20 16:34:00 -0800 | [diff] [blame] | 265 | virtual VideoContentDescription* as_video() { return this; } |
| 266 | virtual const VideoContentDescription* as_video() const { return this; } |
Steve Anton | afd8e8c | 2017-12-19 16:35:35 -0800 | [diff] [blame] | 267 | }; |
| 268 | |
| 269 | class DataContentDescription : public MediaContentDescriptionImpl<DataCodec> { |
| 270 | public: |
| 271 | DataContentDescription() {} |
| 272 | |
Steve Anton | b1c1de1 | 2017-12-21 15:14:30 -0800 | [diff] [blame] | 273 | virtual DataContentDescription* Copy() const { |
Steve Anton | afd8e8c | 2017-12-19 16:35:35 -0800 | [diff] [blame] | 274 | return new DataContentDescription(*this); |
| 275 | } |
| 276 | virtual MediaType type() const { return MEDIA_TYPE_DATA; } |
Steve Anton | 5adfafd | 2017-12-20 16:34:00 -0800 | [diff] [blame] | 277 | virtual DataContentDescription* as_data() { return this; } |
| 278 | virtual const DataContentDescription* as_data() const { return this; } |
Steve Anton | afd8e8c | 2017-12-19 16:35:35 -0800 | [diff] [blame] | 279 | |
| 280 | bool use_sctpmap() const { return use_sctpmap_; } |
| 281 | void set_use_sctpmap(bool enable) { use_sctpmap_ = enable; } |
| 282 | |
| 283 | private: |
| 284 | bool use_sctpmap_ = true; |
| 285 | }; |
| 286 | |
Steve Anton | 5adfafd | 2017-12-20 16:34:00 -0800 | [diff] [blame] | 287 | // Protocol used for encoding media. This is the "top level" protocol that may |
| 288 | // be wrapped by zero or many transport protocols (UDP, ICE, etc.). |
| 289 | enum class MediaProtocolType { |
| 290 | kRtp, // Section will use the RTP protocol (e.g., for audio or video). |
| 291 | // https://tools.ietf.org/html/rfc3550 |
| 292 | kSctp // Section will use the SCTP protocol (e.g., for a data channel). |
| 293 | // https://tools.ietf.org/html/rfc4960 |
| 294 | }; |
| 295 | |
| 296 | // TODO(bugs.webrtc.org/8620): Remove once downstream projects have updated. |
| 297 | constexpr MediaProtocolType NS_JINGLE_RTP = MediaProtocolType::kRtp; |
| 298 | constexpr MediaProtocolType NS_JINGLE_DRAFT_SCTP = MediaProtocolType::kSctp; |
| 299 | |
| 300 | // Represents a session description section. Most information about the section |
| 301 | // is stored in the description, which is a subclass of MediaContentDescription. |
Steve Anton | 4ab68ee | 2017-12-19 14:26:11 -0800 | [diff] [blame] | 302 | struct ContentInfo { |
Steve Anton | b1c1de1 | 2017-12-21 15:14:30 -0800 | [diff] [blame] | 303 | friend class SessionDescription; |
| 304 | |
Steve Anton | 5adfafd | 2017-12-20 16:34:00 -0800 | [diff] [blame] | 305 | explicit ContentInfo(MediaProtocolType type) : type(type) {} |
| 306 | |
| 307 | // Alias for |name|. |
| 308 | std::string mid() const { return name; } |
| 309 | void set_mid(const std::string& mid) { this->name = mid; } |
| 310 | |
| 311 | // Alias for |description|. |
| 312 | MediaContentDescription* media_description() { return description; } |
| 313 | const MediaContentDescription* media_description() const { |
| 314 | return description; |
| 315 | } |
Steve Anton | 8171211 | 2018-01-05 11:27:54 -0800 | [diff] [blame] | 316 | void set_media_description(MediaContentDescription* desc) { |
| 317 | description = desc; |
Steve Anton | 5adfafd | 2017-12-20 16:34:00 -0800 | [diff] [blame] | 318 | } |
| 319 | |
Steve Anton | 8171211 | 2018-01-05 11:27:54 -0800 | [diff] [blame] | 320 | // TODO(bugs.webrtc.org/8620): Rename this to mid. |
Steve Anton | 4ab68ee | 2017-12-19 14:26:11 -0800 | [diff] [blame] | 321 | std::string name; |
Steve Anton | 5adfafd | 2017-12-20 16:34:00 -0800 | [diff] [blame] | 322 | MediaProtocolType type; |
Steve Anton | 4ab68ee | 2017-12-19 14:26:11 -0800 | [diff] [blame] | 323 | bool rejected = false; |
| 324 | bool bundle_only = false; |
Steve Anton | 8171211 | 2018-01-05 11:27:54 -0800 | [diff] [blame] | 325 | // TODO(bugs.webrtc.org/8620): Switch to the getter and setter, and make this |
| 326 | // private. |
Steve Anton | b1c1de1 | 2017-12-21 15:14:30 -0800 | [diff] [blame] | 327 | MediaContentDescription* description = nullptr; |
Steve Anton | 4ab68ee | 2017-12-19 14:26:11 -0800 | [diff] [blame] | 328 | }; |
| 329 | |
| 330 | typedef std::vector<std::string> ContentNames; |
| 331 | |
| 332 | // This class provides a mechanism to aggregate different media contents into a |
| 333 | // group. This group can also be shared with the peers in a pre-defined format. |
| 334 | // GroupInfo should be populated only with the |content_name| of the |
| 335 | // MediaDescription. |
| 336 | class ContentGroup { |
| 337 | public: |
| 338 | explicit ContentGroup(const std::string& semantics); |
| 339 | ContentGroup(const ContentGroup&); |
| 340 | ContentGroup(ContentGroup&&); |
| 341 | ContentGroup& operator=(const ContentGroup&); |
| 342 | ContentGroup& operator=(ContentGroup&&); |
| 343 | ~ContentGroup(); |
| 344 | |
| 345 | const std::string& semantics() const { return semantics_; } |
| 346 | const ContentNames& content_names() const { return content_names_; } |
| 347 | |
| 348 | const std::string* FirstContentName() const; |
| 349 | bool HasContentName(const std::string& content_name) const; |
| 350 | void AddContentName(const std::string& content_name); |
| 351 | bool RemoveContentName(const std::string& content_name); |
| 352 | |
| 353 | private: |
| 354 | std::string semantics_; |
| 355 | ContentNames content_names_; |
| 356 | }; |
| 357 | |
| 358 | typedef std::vector<ContentInfo> ContentInfos; |
| 359 | typedef std::vector<ContentGroup> ContentGroups; |
| 360 | |
| 361 | const ContentInfo* FindContentInfoByName(const ContentInfos& contents, |
| 362 | const std::string& name); |
| 363 | const ContentInfo* FindContentInfoByType(const ContentInfos& contents, |
| 364 | const std::string& type); |
| 365 | |
Steve Anton | e831b8c | 2018-02-01 12:22:16 -0800 | [diff] [blame] | 366 | // Determines how the MSID will be signaled in the SDP. These can be used as |
| 367 | // flags to indicate both or none. |
| 368 | enum MsidSignaling { |
| 369 | // Signal MSID with one a=msid line in the media section. |
| 370 | kMsidSignalingMediaSection = 0x1, |
| 371 | // Signal MSID with a=ssrc: msid lines in the media section. |
| 372 | kMsidSignalingSsrcAttribute = 0x2 |
| 373 | }; |
| 374 | |
Steve Anton | 4ab68ee | 2017-12-19 14:26:11 -0800 | [diff] [blame] | 375 | // Describes a collection of contents, each with its own name and |
| 376 | // type. Analogous to a <jingle> or <session> stanza. Assumes that |
| 377 | // contents are unique be name, but doesn't enforce that. |
| 378 | class SessionDescription { |
| 379 | public: |
| 380 | SessionDescription(); |
| 381 | explicit SessionDescription(const ContentInfos& contents); |
| 382 | SessionDescription(const ContentInfos& contents, const ContentGroups& groups); |
| 383 | SessionDescription(const ContentInfos& contents, |
| 384 | const TransportInfos& transports, |
| 385 | const ContentGroups& groups); |
| 386 | ~SessionDescription(); |
| 387 | |
| 388 | SessionDescription* Copy() const; |
| 389 | |
| 390 | // Content accessors. |
| 391 | const ContentInfos& contents() const { return contents_; } |
| 392 | ContentInfos& contents() { return contents_; } |
| 393 | const ContentInfo* GetContentByName(const std::string& name) const; |
| 394 | ContentInfo* GetContentByName(const std::string& name); |
Steve Anton | b1c1de1 | 2017-12-21 15:14:30 -0800 | [diff] [blame] | 395 | const MediaContentDescription* GetContentDescriptionByName( |
Steve Anton | 4ab68ee | 2017-12-19 14:26:11 -0800 | [diff] [blame] | 396 | const std::string& name) const; |
Steve Anton | b1c1de1 | 2017-12-21 15:14:30 -0800 | [diff] [blame] | 397 | MediaContentDescription* GetContentDescriptionByName(const std::string& name); |
Steve Anton | 5adfafd | 2017-12-20 16:34:00 -0800 | [diff] [blame] | 398 | const ContentInfo* FirstContentByType(MediaProtocolType type) const; |
Steve Anton | 4ab68ee | 2017-12-19 14:26:11 -0800 | [diff] [blame] | 399 | const ContentInfo* FirstContent() const; |
| 400 | |
| 401 | // Content mutators. |
| 402 | // Adds a content to this description. Takes ownership of ContentDescription*. |
| 403 | void AddContent(const std::string& name, |
Steve Anton | 5adfafd | 2017-12-20 16:34:00 -0800 | [diff] [blame] | 404 | MediaProtocolType type, |
Steve Anton | b1c1de1 | 2017-12-21 15:14:30 -0800 | [diff] [blame] | 405 | MediaContentDescription* description); |
Steve Anton | 4ab68ee | 2017-12-19 14:26:11 -0800 | [diff] [blame] | 406 | void AddContent(const std::string& name, |
Steve Anton | 5adfafd | 2017-12-20 16:34:00 -0800 | [diff] [blame] | 407 | MediaProtocolType type, |
Steve Anton | 4ab68ee | 2017-12-19 14:26:11 -0800 | [diff] [blame] | 408 | bool rejected, |
Steve Anton | b1c1de1 | 2017-12-21 15:14:30 -0800 | [diff] [blame] | 409 | MediaContentDescription* description); |
Steve Anton | 4ab68ee | 2017-12-19 14:26:11 -0800 | [diff] [blame] | 410 | void AddContent(const std::string& name, |
Steve Anton | 5adfafd | 2017-12-20 16:34:00 -0800 | [diff] [blame] | 411 | MediaProtocolType type, |
Steve Anton | 4ab68ee | 2017-12-19 14:26:11 -0800 | [diff] [blame] | 412 | bool rejected, |
| 413 | bool bundle_only, |
Steve Anton | b1c1de1 | 2017-12-21 15:14:30 -0800 | [diff] [blame] | 414 | MediaContentDescription* description); |
Steve Anton | 4ab68ee | 2017-12-19 14:26:11 -0800 | [diff] [blame] | 415 | bool RemoveContentByName(const std::string& name); |
| 416 | |
| 417 | // Transport accessors. |
| 418 | const TransportInfos& transport_infos() const { return transport_infos_; } |
| 419 | TransportInfos& transport_infos() { return transport_infos_; } |
| 420 | const TransportInfo* GetTransportInfoByName(const std::string& name) const; |
| 421 | TransportInfo* GetTransportInfoByName(const std::string& name); |
| 422 | const TransportDescription* GetTransportDescriptionByName( |
| 423 | const std::string& name) const { |
| 424 | const TransportInfo* tinfo = GetTransportInfoByName(name); |
| 425 | return tinfo ? &tinfo->description : NULL; |
| 426 | } |
| 427 | |
| 428 | // Transport mutators. |
| 429 | void set_transport_infos(const TransportInfos& transport_infos) { |
| 430 | transport_infos_ = transport_infos; |
| 431 | } |
| 432 | // Adds a TransportInfo to this description. |
| 433 | // Returns false if a TransportInfo with the same name already exists. |
| 434 | bool AddTransportInfo(const TransportInfo& transport_info); |
| 435 | bool RemoveTransportInfoByName(const std::string& name); |
| 436 | |
| 437 | // Group accessors. |
| 438 | const ContentGroups& groups() const { return content_groups_; } |
| 439 | const ContentGroup* GetGroupByName(const std::string& name) const; |
| 440 | bool HasGroup(const std::string& name) const; |
| 441 | |
| 442 | // Group mutators. |
| 443 | void AddGroup(const ContentGroup& group) { content_groups_.push_back(group); } |
| 444 | // Remove the first group with the same semantics specified by |name|. |
| 445 | void RemoveGroupByName(const std::string& name); |
| 446 | |
| 447 | // Global attributes. |
| 448 | void set_msid_supported(bool supported) { msid_supported_ = supported; } |
| 449 | bool msid_supported() const { return msid_supported_; } |
| 450 | |
Steve Anton | e831b8c | 2018-02-01 12:22:16 -0800 | [diff] [blame] | 451 | // Determines how the MSIDs were/will be signaled. Flag value composed of |
| 452 | // MsidSignaling bits (see enum above). |
| 453 | void set_msid_signaling(int msid_signaling) { |
| 454 | msid_signaling_ = msid_signaling; |
| 455 | } |
| 456 | int msid_signaling() const { return msid_signaling_; } |
| 457 | |
Steve Anton | 4ab68ee | 2017-12-19 14:26:11 -0800 | [diff] [blame] | 458 | private: |
| 459 | SessionDescription(const SessionDescription&); |
| 460 | |
| 461 | ContentInfos contents_; |
| 462 | TransportInfos transport_infos_; |
| 463 | ContentGroups content_groups_; |
| 464 | bool msid_supported_ = true; |
Steve Anton | e831b8c | 2018-02-01 12:22:16 -0800 | [diff] [blame] | 465 | // Default to what Plan B would do. |
| 466 | // TODO(bugs.webrtc.org/8530): Change default to kMsidSignalingMediaSection. |
| 467 | int msid_signaling_ = kMsidSignalingSsrcAttribute; |
Steve Anton | 4ab68ee | 2017-12-19 14:26:11 -0800 | [diff] [blame] | 468 | }; |
| 469 | |
Steve Anton | b1c1de1 | 2017-12-21 15:14:30 -0800 | [diff] [blame] | 470 | // Indicates whether a session description was sent by the local client or |
| 471 | // received from the remote client. |
Steve Anton | 4ab68ee | 2017-12-19 14:26:11 -0800 | [diff] [blame] | 472 | enum ContentSource { CS_LOCAL, CS_REMOTE }; |
| 473 | |
| 474 | } // namespace cricket |
| 475 | |
| 476 | #endif // PC_SESSIONDESCRIPTION_H_ |