blob: 691046f31c98fb8da9ea7ac191ae8f5d5909c7d7 [file] [log] [blame]
Steve Anton4ab68ee2017-12-19 14:26:11 -08001/*
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
Yves Gerey3e707812018-11-28 16:47:49 +010014#include <stddef.h>
15#include <stdint.h>
16#include <iosfwd>
Steve Anton4ab68ee2017-12-19 14:26:11 -080017#include <string>
18#include <vector>
19
Steve Antonafd8e8c2017-12-19 16:35:35 -080020#include "api/cryptoparams.h"
Yves Gerey3e707812018-11-28 16:47:49 +010021#include "api/mediatypes.h"
Steve Antonafd8e8c2017-12-19 16:35:35 -080022#include "api/rtpparameters.h"
23#include "api/rtptransceiverinterface.h"
Steve Antonafd8e8c2017-12-19 16:35:35 -080024#include "media/base/mediachannel.h"
25#include "media/base/streamparams.h"
Yves Gerey3e707812018-11-28 16:47:49 +010026#include "p2p/base/transportdescription.h"
Steve Anton4ab68ee2017-12-19 14:26:11 -080027#include "p2p/base/transportinfo.h"
Yves Gerey3e707812018-11-28 16:47:49 +010028#include "rtc_base/socketaddress.h"
Steve Anton4ab68ee2017-12-19 14:26:11 -080029
30namespace cricket {
31
Steve Antonafd8e8c2017-12-19 16:35:35 -080032typedef std::vector<AudioCodec> AudioCodecs;
33typedef std::vector<VideoCodec> VideoCodecs;
34typedef std::vector<DataCodec> DataCodecs;
35typedef std::vector<CryptoParams> CryptoParamsVec;
36typedef std::vector<webrtc::RtpExtension> RtpHeaderExtensions;
37
38// RTC4585 RTP/AVPF
39extern const char kMediaProtocolAvpf[];
40// RFC5124 RTP/SAVPF
41extern const char kMediaProtocolSavpf[];
42
43extern const char kMediaProtocolDtlsSavpf[];
44
45extern const char kMediaProtocolRtpPrefix[];
46
47extern const char kMediaProtocolSctp[];
48extern const char kMediaProtocolDtlsSctp[];
49extern const char kMediaProtocolUdpDtlsSctp[];
50extern const char kMediaProtocolTcpDtlsSctp[];
51
52// Options to control how session descriptions are generated.
53const int kAutoBandwidth = -1;
54
Steve Anton5adfafd2017-12-20 16:34:00 -080055class AudioContentDescription;
Steve Anton5adfafd2017-12-20 16:34:00 -080056class DataContentDescription;
Yves Gerey3e707812018-11-28 16:47:49 +010057class VideoContentDescription;
Steve Anton4ab68ee2017-12-19 14:26:11 -080058
Steve Anton5adfafd2017-12-20 16:34:00 -080059// Describes a session description media section. There are subclasses for each
60// media type (audio, video, data) that will have additional information.
61class MediaContentDescription {
Steve Antonafd8e8c2017-12-19 16:35:35 -080062 public:
Steve Anton5adfafd2017-12-20 16:34:00 -080063 MediaContentDescription() = default;
64 virtual ~MediaContentDescription() = default;
Steve Antonafd8e8c2017-12-19 16:35:35 -080065
66 virtual MediaType type() const = 0;
Steve Anton5adfafd2017-12-20 16:34:00 -080067
68 // Try to cast this media description to an AudioContentDescription. Returns
69 // nullptr if the cast fails.
70 virtual AudioContentDescription* as_audio() { return nullptr; }
71 virtual const AudioContentDescription* as_audio() const { return nullptr; }
72
73 // Try to cast this media description to a VideoContentDescription. Returns
74 // nullptr if the cast fails.
75 virtual VideoContentDescription* as_video() { return nullptr; }
76 virtual const VideoContentDescription* as_video() const { return nullptr; }
77
78 // Try to cast this media description to a DataContentDescription. Returns
79 // nullptr if the cast fails.
80 virtual DataContentDescription* as_data() { return nullptr; }
81 virtual const DataContentDescription* as_data() const { return nullptr; }
82
Steve Antonafd8e8c2017-12-19 16:35:35 -080083 virtual bool has_codecs() const = 0;
84
Steve Anton5adfafd2017-12-20 16:34:00 -080085 virtual MediaContentDescription* Copy() const = 0;
86
Steve Antonafd8e8c2017-12-19 16:35:35 -080087 // |protocol| is the expected media transport protocol, such as RTP/AVPF,
88 // RTP/SAVPF or SCTP/DTLS.
89 std::string protocol() const { return protocol_; }
90 void set_protocol(const std::string& protocol) { protocol_ = protocol; }
91
92 webrtc::RtpTransceiverDirection direction() const { return direction_; }
93 void set_direction(webrtc::RtpTransceiverDirection direction) {
94 direction_ = direction;
95 }
96
97 bool rtcp_mux() const { return rtcp_mux_; }
98 void set_rtcp_mux(bool mux) { rtcp_mux_ = mux; }
99
100 bool rtcp_reduced_size() const { return rtcp_reduced_size_; }
101 void set_rtcp_reduced_size(bool reduced_size) {
102 rtcp_reduced_size_ = reduced_size;
103 }
104
105 int bandwidth() const { return bandwidth_; }
106 void set_bandwidth(int bandwidth) { bandwidth_ = bandwidth; }
107
108 const std::vector<CryptoParams>& cryptos() const { return cryptos_; }
109 void AddCrypto(const CryptoParams& params) { cryptos_.push_back(params); }
110 void set_cryptos(const std::vector<CryptoParams>& cryptos) {
111 cryptos_ = cryptos;
112 }
113
114 const RtpHeaderExtensions& rtp_header_extensions() const {
115 return rtp_header_extensions_;
116 }
117 void set_rtp_header_extensions(const RtpHeaderExtensions& extensions) {
118 rtp_header_extensions_ = extensions;
119 rtp_header_extensions_set_ = true;
120 }
121 void AddRtpHeaderExtension(const webrtc::RtpExtension& ext) {
122 rtp_header_extensions_.push_back(ext);
123 rtp_header_extensions_set_ = true;
124 }
125 void AddRtpHeaderExtension(const cricket::RtpHeaderExtension& ext) {
126 webrtc::RtpExtension webrtc_extension;
127 webrtc_extension.uri = ext.uri;
128 webrtc_extension.id = ext.id;
129 rtp_header_extensions_.push_back(webrtc_extension);
130 rtp_header_extensions_set_ = true;
131 }
132 void ClearRtpHeaderExtensions() {
133 rtp_header_extensions_.clear();
134 rtp_header_extensions_set_ = true;
135 }
136 // We can't always tell if an empty list of header extensions is
137 // because the other side doesn't support them, or just isn't hooked up to
138 // signal them. For now we assume an empty list means no signaling, but
139 // provide the ClearRtpHeaderExtensions method to allow "no support" to be
140 // clearly indicated (i.e. when derived from other information).
141 bool rtp_header_extensions_set() const { return rtp_header_extensions_set_; }
142 const StreamParamsVec& streams() const { return streams_; }
143 // TODO(pthatcher): Remove this by giving mediamessage.cc access
144 // to MediaContentDescription
145 StreamParamsVec& mutable_streams() { return streams_; }
146 void AddStream(const StreamParams& stream) { streams_.push_back(stream); }
147 // Legacy streams have an ssrc, but nothing else.
148 void AddLegacyStream(uint32_t ssrc) {
149 streams_.push_back(StreamParams::CreateLegacy(ssrc));
150 }
151 void AddLegacyStream(uint32_t ssrc, uint32_t fid_ssrc) {
152 StreamParams sp = StreamParams::CreateLegacy(ssrc);
153 sp.AddFidSsrc(ssrc, fid_ssrc);
154 streams_.push_back(sp);
155 }
156 // Sets the CNAME of all StreamParams if it have not been set.
157 void SetCnameIfEmpty(const std::string& cname) {
158 for (cricket::StreamParamsVec::iterator it = streams_.begin();
159 it != streams_.end(); ++it) {
160 if (it->cname.empty())
161 it->cname = cname;
162 }
163 }
164 uint32_t first_ssrc() const {
165 if (streams_.empty()) {
166 return 0;
167 }
168 return streams_[0].first_ssrc();
169 }
170 bool has_ssrcs() const {
171 if (streams_.empty()) {
172 return false;
173 }
174 return streams_[0].has_ssrcs();
175 }
176
177 void set_conference_mode(bool enable) { conference_mode_ = enable; }
178 bool conference_mode() const { return conference_mode_; }
179
180 // https://tools.ietf.org/html/rfc4566#section-5.7
181 // May be present at the media or session level of SDP. If present at both
182 // levels, the media-level attribute overwrites the session-level one.
183 void set_connection_address(const rtc::SocketAddress& address) {
184 connection_address_ = address;
185 }
186 const rtc::SocketAddress& connection_address() const {
187 return connection_address_;
188 }
189
Johannes Kron0854eb62018-10-10 22:33:20 +0200190 // Determines if it's allowed to mix one- and two-byte rtp header extensions
191 // within the same rtp stream.
Johannes Kron9581bc42018-10-23 10:17:39 +0200192 enum ExtmapAllowMixed { kNo, kSession, kMedia };
193 void set_extmap_allow_mixed_enum(ExtmapAllowMixed new_extmap_allow_mixed) {
Johannes Kron9ac3c912018-10-12 10:54:26 +0200194 if (new_extmap_allow_mixed == kMedia &&
Johannes Kron9581bc42018-10-23 10:17:39 +0200195 extmap_allow_mixed_enum_ == kSession) {
Johannes Kron0854eb62018-10-10 22:33:20 +0200196 // Do not downgrade from session level to media level.
197 return;
198 }
Johannes Kron9581bc42018-10-23 10:17:39 +0200199 extmap_allow_mixed_enum_ = new_extmap_allow_mixed;
Johannes Kron0854eb62018-10-10 22:33:20 +0200200 }
Johannes Kron9581bc42018-10-23 10:17:39 +0200201 ExtmapAllowMixed extmap_allow_mixed_enum() const {
202 return extmap_allow_mixed_enum_;
Johannes Kron9ac3c912018-10-12 10:54:26 +0200203 }
Johannes Kron9581bc42018-10-23 10:17:39 +0200204 bool extmap_allow_mixed() const { return extmap_allow_mixed_enum_ != kNo; }
Johannes Kron0854eb62018-10-10 22:33:20 +0200205
Steve Antonafd8e8c2017-12-19 16:35:35 -0800206 protected:
207 bool rtcp_mux_ = false;
208 bool rtcp_reduced_size_ = false;
209 int bandwidth_ = kAutoBandwidth;
210 std::string protocol_;
211 std::vector<CryptoParams> cryptos_;
212 std::vector<webrtc::RtpExtension> rtp_header_extensions_;
213 bool rtp_header_extensions_set_ = false;
214 StreamParamsVec streams_;
215 bool conference_mode_ = false;
216 webrtc::RtpTransceiverDirection direction_ =
217 webrtc::RtpTransceiverDirection::kSendRecv;
218 rtc::SocketAddress connection_address_;
Johannes Kron0854eb62018-10-10 22:33:20 +0200219 // Mixed one- and two-byte header not included in offer on media level or
220 // session level, but we will respond that we support it. The plan is to add
221 // it to our offer on session level. See todo in SessionDescription.
Johannes Kron9581bc42018-10-23 10:17:39 +0200222 ExtmapAllowMixed extmap_allow_mixed_enum_ = kNo;
Steve Antonafd8e8c2017-12-19 16:35:35 -0800223};
224
Steve Anton5adfafd2017-12-20 16:34:00 -0800225// TODO(bugs.webrtc.org/8620): Remove this alias once downstream projects have
226// updated.
227using ContentDescription = MediaContentDescription;
228
Steve Antonafd8e8c2017-12-19 16:35:35 -0800229template <class C>
230class MediaContentDescriptionImpl : public MediaContentDescription {
231 public:
232 typedef C CodecType;
233
234 // Codecs should be in preference order (most preferred codec first).
235 const std::vector<C>& codecs() const { return codecs_; }
236 void set_codecs(const std::vector<C>& codecs) { codecs_ = codecs; }
237 virtual bool has_codecs() const { return !codecs_.empty(); }
238 bool HasCodec(int id) {
239 bool found = false;
240 for (typename std::vector<C>::iterator iter = codecs_.begin();
241 iter != codecs_.end(); ++iter) {
242 if (iter->id == id) {
243 found = true;
244 break;
245 }
246 }
247 return found;
248 }
249 void AddCodec(const C& codec) { codecs_.push_back(codec); }
250 void AddOrReplaceCodec(const C& codec) {
251 for (typename std::vector<C>::iterator iter = codecs_.begin();
252 iter != codecs_.end(); ++iter) {
253 if (iter->id == codec.id) {
254 *iter = codec;
255 return;
256 }
257 }
258 AddCodec(codec);
259 }
260 void AddCodecs(const std::vector<C>& codecs) {
261 typename std::vector<C>::const_iterator codec;
262 for (codec = codecs.begin(); codec != codecs.end(); ++codec) {
263 AddCodec(*codec);
264 }
265 }
266
267 private:
268 std::vector<C> codecs_;
269};
270
271class AudioContentDescription : public MediaContentDescriptionImpl<AudioCodec> {
272 public:
273 AudioContentDescription() {}
274
Steve Antonb1c1de12017-12-21 15:14:30 -0800275 virtual AudioContentDescription* Copy() const {
Steve Antonafd8e8c2017-12-19 16:35:35 -0800276 return new AudioContentDescription(*this);
277 }
278 virtual MediaType type() const { return MEDIA_TYPE_AUDIO; }
Steve Anton5adfafd2017-12-20 16:34:00 -0800279 virtual AudioContentDescription* as_audio() { return this; }
280 virtual const AudioContentDescription* as_audio() const { return this; }
Steve Antonafd8e8c2017-12-19 16:35:35 -0800281};
282
283class VideoContentDescription : public MediaContentDescriptionImpl<VideoCodec> {
284 public:
Steve Antonb1c1de12017-12-21 15:14:30 -0800285 virtual VideoContentDescription* Copy() const {
Steve Antonafd8e8c2017-12-19 16:35:35 -0800286 return new VideoContentDescription(*this);
287 }
288 virtual MediaType type() const { return MEDIA_TYPE_VIDEO; }
Steve Anton5adfafd2017-12-20 16:34:00 -0800289 virtual VideoContentDescription* as_video() { return this; }
290 virtual const VideoContentDescription* as_video() const { return this; }
Steve Antonafd8e8c2017-12-19 16:35:35 -0800291};
292
293class DataContentDescription : public MediaContentDescriptionImpl<DataCodec> {
294 public:
295 DataContentDescription() {}
296
Steve Antonb1c1de12017-12-21 15:14:30 -0800297 virtual DataContentDescription* Copy() const {
Steve Antonafd8e8c2017-12-19 16:35:35 -0800298 return new DataContentDescription(*this);
299 }
300 virtual MediaType type() const { return MEDIA_TYPE_DATA; }
Steve Anton5adfafd2017-12-20 16:34:00 -0800301 virtual DataContentDescription* as_data() { return this; }
302 virtual const DataContentDescription* as_data() const { return this; }
Steve Antonafd8e8c2017-12-19 16:35:35 -0800303
304 bool use_sctpmap() const { return use_sctpmap_; }
305 void set_use_sctpmap(bool enable) { use_sctpmap_ = enable; }
306
307 private:
308 bool use_sctpmap_ = true;
309};
310
Steve Anton5adfafd2017-12-20 16:34:00 -0800311// Protocol used for encoding media. This is the "top level" protocol that may
312// be wrapped by zero or many transport protocols (UDP, ICE, etc.).
313enum class MediaProtocolType {
314 kRtp, // Section will use the RTP protocol (e.g., for audio or video).
315 // https://tools.ietf.org/html/rfc3550
316 kSctp // Section will use the SCTP protocol (e.g., for a data channel).
317 // https://tools.ietf.org/html/rfc4960
318};
319
320// TODO(bugs.webrtc.org/8620): Remove once downstream projects have updated.
321constexpr MediaProtocolType NS_JINGLE_RTP = MediaProtocolType::kRtp;
322constexpr MediaProtocolType NS_JINGLE_DRAFT_SCTP = MediaProtocolType::kSctp;
323
324// Represents a session description section. Most information about the section
325// is stored in the description, which is a subclass of MediaContentDescription.
Steve Anton4ab68ee2017-12-19 14:26:11 -0800326struct ContentInfo {
Steve Antonb1c1de12017-12-21 15:14:30 -0800327 friend class SessionDescription;
328
Steve Anton5adfafd2017-12-20 16:34:00 -0800329 explicit ContentInfo(MediaProtocolType type) : type(type) {}
330
331 // Alias for |name|.
332 std::string mid() const { return name; }
333 void set_mid(const std::string& mid) { this->name = mid; }
334
335 // Alias for |description|.
336 MediaContentDescription* media_description() { return description; }
337 const MediaContentDescription* media_description() const {
338 return description;
339 }
Steve Anton81712112018-01-05 11:27:54 -0800340 void set_media_description(MediaContentDescription* desc) {
341 description = desc;
Steve Anton5adfafd2017-12-20 16:34:00 -0800342 }
343
Steve Anton81712112018-01-05 11:27:54 -0800344 // TODO(bugs.webrtc.org/8620): Rename this to mid.
Steve Anton4ab68ee2017-12-19 14:26:11 -0800345 std::string name;
Steve Anton5adfafd2017-12-20 16:34:00 -0800346 MediaProtocolType type;
Steve Anton4ab68ee2017-12-19 14:26:11 -0800347 bool rejected = false;
348 bool bundle_only = false;
Steve Anton81712112018-01-05 11:27:54 -0800349 // TODO(bugs.webrtc.org/8620): Switch to the getter and setter, and make this
350 // private.
Steve Antonb1c1de12017-12-21 15:14:30 -0800351 MediaContentDescription* description = nullptr;
Steve Anton4ab68ee2017-12-19 14:26:11 -0800352};
353
354typedef std::vector<std::string> ContentNames;
355
356// This class provides a mechanism to aggregate different media contents into a
357// group. This group can also be shared with the peers in a pre-defined format.
358// GroupInfo should be populated only with the |content_name| of the
359// MediaDescription.
360class ContentGroup {
361 public:
362 explicit ContentGroup(const std::string& semantics);
363 ContentGroup(const ContentGroup&);
364 ContentGroup(ContentGroup&&);
365 ContentGroup& operator=(const ContentGroup&);
366 ContentGroup& operator=(ContentGroup&&);
367 ~ContentGroup();
368
369 const std::string& semantics() const { return semantics_; }
370 const ContentNames& content_names() const { return content_names_; }
371
372 const std::string* FirstContentName() const;
373 bool HasContentName(const std::string& content_name) const;
374 void AddContentName(const std::string& content_name);
375 bool RemoveContentName(const std::string& content_name);
376
377 private:
378 std::string semantics_;
379 ContentNames content_names_;
380};
381
382typedef std::vector<ContentInfo> ContentInfos;
383typedef std::vector<ContentGroup> ContentGroups;
384
385const ContentInfo* FindContentInfoByName(const ContentInfos& contents,
386 const std::string& name);
387const ContentInfo* FindContentInfoByType(const ContentInfos& contents,
388 const std::string& type);
389
Steve Antone831b8c2018-02-01 12:22:16 -0800390// Determines how the MSID will be signaled in the SDP. These can be used as
391// flags to indicate both or none.
392enum MsidSignaling {
393 // Signal MSID with one a=msid line in the media section.
394 kMsidSignalingMediaSection = 0x1,
395 // Signal MSID with a=ssrc: msid lines in the media section.
396 kMsidSignalingSsrcAttribute = 0x2
397};
398
Steve Anton4ab68ee2017-12-19 14:26:11 -0800399// Describes a collection of contents, each with its own name and
400// type. Analogous to a <jingle> or <session> stanza. Assumes that
401// contents are unique be name, but doesn't enforce that.
402class SessionDescription {
403 public:
404 SessionDescription();
Steve Anton4ab68ee2017-12-19 14:26:11 -0800405 ~SessionDescription();
406
407 SessionDescription* Copy() const;
408
409 // Content accessors.
410 const ContentInfos& contents() const { return contents_; }
411 ContentInfos& contents() { return contents_; }
412 const ContentInfo* GetContentByName(const std::string& name) const;
413 ContentInfo* GetContentByName(const std::string& name);
Steve Antonb1c1de12017-12-21 15:14:30 -0800414 const MediaContentDescription* GetContentDescriptionByName(
Steve Anton4ab68ee2017-12-19 14:26:11 -0800415 const std::string& name) const;
Steve Antonb1c1de12017-12-21 15:14:30 -0800416 MediaContentDescription* GetContentDescriptionByName(const std::string& name);
Steve Anton5adfafd2017-12-20 16:34:00 -0800417 const ContentInfo* FirstContentByType(MediaProtocolType type) const;
Steve Anton4ab68ee2017-12-19 14:26:11 -0800418 const ContentInfo* FirstContent() const;
419
420 // Content mutators.
421 // Adds a content to this description. Takes ownership of ContentDescription*.
422 void AddContent(const std::string& name,
Steve Anton5adfafd2017-12-20 16:34:00 -0800423 MediaProtocolType type,
Steve Antonb1c1de12017-12-21 15:14:30 -0800424 MediaContentDescription* description);
Steve Anton4ab68ee2017-12-19 14:26:11 -0800425 void AddContent(const std::string& name,
Steve Anton5adfafd2017-12-20 16:34:00 -0800426 MediaProtocolType type,
Steve Anton4ab68ee2017-12-19 14:26:11 -0800427 bool rejected,
Steve Antonb1c1de12017-12-21 15:14:30 -0800428 MediaContentDescription* description);
Steve Anton4ab68ee2017-12-19 14:26:11 -0800429 void AddContent(const std::string& name,
Steve Anton5adfafd2017-12-20 16:34:00 -0800430 MediaProtocolType type,
Steve Anton4ab68ee2017-12-19 14:26:11 -0800431 bool rejected,
432 bool bundle_only,
Steve Antonb1c1de12017-12-21 15:14:30 -0800433 MediaContentDescription* description);
Johannes Kron9ac3c912018-10-12 10:54:26 +0200434 void AddContent(ContentInfo* content);
435
Steve Anton4ab68ee2017-12-19 14:26:11 -0800436 bool RemoveContentByName(const std::string& name);
437
438 // Transport accessors.
439 const TransportInfos& transport_infos() const { return transport_infos_; }
440 TransportInfos& transport_infos() { return transport_infos_; }
441 const TransportInfo* GetTransportInfoByName(const std::string& name) const;
442 TransportInfo* GetTransportInfoByName(const std::string& name);
443 const TransportDescription* GetTransportDescriptionByName(
444 const std::string& name) const {
445 const TransportInfo* tinfo = GetTransportInfoByName(name);
446 return tinfo ? &tinfo->description : NULL;
447 }
448
449 // Transport mutators.
450 void set_transport_infos(const TransportInfos& transport_infos) {
451 transport_infos_ = transport_infos;
452 }
453 // Adds a TransportInfo to this description.
454 // Returns false if a TransportInfo with the same name already exists.
455 bool AddTransportInfo(const TransportInfo& transport_info);
456 bool RemoveTransportInfoByName(const std::string& name);
457
458 // Group accessors.
459 const ContentGroups& groups() const { return content_groups_; }
460 const ContentGroup* GetGroupByName(const std::string& name) const;
461 bool HasGroup(const std::string& name) const;
462
463 // Group mutators.
464 void AddGroup(const ContentGroup& group) { content_groups_.push_back(group); }
465 // Remove the first group with the same semantics specified by |name|.
466 void RemoveGroupByName(const std::string& name);
467
468 // Global attributes.
469 void set_msid_supported(bool supported) { msid_supported_ = supported; }
470 bool msid_supported() const { return msid_supported_; }
471
Steve Antone831b8c2018-02-01 12:22:16 -0800472 // Determines how the MSIDs were/will be signaled. Flag value composed of
473 // MsidSignaling bits (see enum above).
474 void set_msid_signaling(int msid_signaling) {
475 msid_signaling_ = msid_signaling;
476 }
477 int msid_signaling() const { return msid_signaling_; }
478
Johannes Kron0854eb62018-10-10 22:33:20 +0200479 // Determines if it's allowed to mix one- and two-byte rtp header extensions
480 // within the same rtp stream.
Johannes Kron9581bc42018-10-23 10:17:39 +0200481 void set_extmap_allow_mixed(bool supported) {
482 extmap_allow_mixed_ = supported;
483 MediaContentDescription::ExtmapAllowMixed media_level_setting =
Johannes Kron0854eb62018-10-10 22:33:20 +0200484 supported ? MediaContentDescription::kSession
485 : MediaContentDescription::kNo;
486 for (auto& content : contents_) {
Johannes Kron9ac3c912018-10-12 10:54:26 +0200487 // Do not set to kNo if the current setting is kMedia.
Johannes Kron9581bc42018-10-23 10:17:39 +0200488 if (supported || content.media_description()->extmap_allow_mixed_enum() !=
489 MediaContentDescription::kMedia) {
490 content.media_description()->set_extmap_allow_mixed_enum(
Johannes Kron9ac3c912018-10-12 10:54:26 +0200491 media_level_setting);
492 }
Johannes Kron0854eb62018-10-10 22:33:20 +0200493 }
494 }
Johannes Kron9581bc42018-10-23 10:17:39 +0200495 bool extmap_allow_mixed() const { return extmap_allow_mixed_; }
Johannes Kron0854eb62018-10-10 22:33:20 +0200496
Steve Anton4ab68ee2017-12-19 14:26:11 -0800497 private:
498 SessionDescription(const SessionDescription&);
499
500 ContentInfos contents_;
501 TransportInfos transport_infos_;
502 ContentGroups content_groups_;
503 bool msid_supported_ = true;
Steve Antone831b8c2018-02-01 12:22:16 -0800504 // Default to what Plan B would do.
505 // TODO(bugs.webrtc.org/8530): Change default to kMsidSignalingMediaSection.
506 int msid_signaling_ = kMsidSignalingSsrcAttribute;
Johannes Kron89f874e2018-11-12 10:25:48 +0100507 // TODO(webrtc:9985): Activate mixed one- and two-byte header extension in
508 // offer at session level. It's currently not included in offer by default
509 // because clients prior to https://bugs.webrtc.org/9712 cannot parse this
510 // correctly. If it's included in offer to us we will respond that we support
511 // it.
Johannes Kron9581bc42018-10-23 10:17:39 +0200512 bool extmap_allow_mixed_ = false;
Steve Anton4ab68ee2017-12-19 14:26:11 -0800513};
514
Steve Antonb1c1de12017-12-21 15:14:30 -0800515// Indicates whether a session description was sent by the local client or
516// received from the remote client.
Steve Anton4ab68ee2017-12-19 14:26:11 -0800517enum ContentSource { CS_LOCAL, CS_REMOTE };
518
519} // namespace cricket
520
521#endif // PC_SESSIONDESCRIPTION_H_