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 | |
Steve Anton | 10542f2 | 2019-01-11 09:11:00 -0800 | [diff] [blame] | 11 | #ifndef PC_SESSION_DESCRIPTION_H_ |
| 12 | #define PC_SESSION_DESCRIPTION_H_ |
Steve Anton | 4ab68ee | 2017-12-19 14:26:11 -0800 | [diff] [blame] | 13 | |
Yves Gerey | 3e70781 | 2018-11-28 16:47:49 +0100 | [diff] [blame] | 14 | #include <stddef.h> |
| 15 | #include <stdint.h> |
Jonas Olsson | a4d8737 | 2019-07-05 19:08:33 +0200 | [diff] [blame] | 16 | |
Harald Alvestrand | 5761e7b | 2021-01-29 14:45:08 +0000 | [diff] [blame] | 17 | #include <algorithm> |
Yves Gerey | 3e70781 | 2018-11-28 16:47:49 +0100 | [diff] [blame] | 18 | #include <iosfwd> |
Harald Alvestrand | 4d7160e | 2019-04-12 07:01:29 +0200 | [diff] [blame] | 19 | #include <memory> |
Steve Anton | 4ab68ee | 2017-12-19 14:26:11 -0800 | [diff] [blame] | 20 | #include <string> |
Harald Alvestrand | 1716d39 | 2019-06-03 20:35:45 +0200 | [diff] [blame] | 21 | #include <utility> |
Steve Anton | 4ab68ee | 2017-12-19 14:26:11 -0800 | [diff] [blame] | 22 | #include <vector> |
| 23 | |
Harald Alvestrand | 5fc28b1 | 2019-05-13 13:36:16 +0200 | [diff] [blame] | 24 | #include "absl/memory/memory.h" |
Steve Anton | 10542f2 | 2019-01-11 09:11:00 -0800 | [diff] [blame] | 25 | #include "api/crypto_params.h" |
| 26 | #include "api/media_types.h" |
| 27 | #include "api/rtp_parameters.h" |
Harald Alvestrand | 5761e7b | 2021-01-29 14:45:08 +0000 | [diff] [blame] | 28 | #include "api/rtp_transceiver_direction.h" |
Steve Anton | 10542f2 | 2019-01-11 09:11:00 -0800 | [diff] [blame] | 29 | #include "api/rtp_transceiver_interface.h" |
Harald Alvestrand | 5761e7b | 2021-01-29 14:45:08 +0000 | [diff] [blame] | 30 | #include "media/base/codec.h" |
Steve Anton | 10542f2 | 2019-01-11 09:11:00 -0800 | [diff] [blame] | 31 | #include "media/base/media_channel.h" |
Taylor Brandstetter | ee8c246 | 2020-07-27 15:52:02 -0700 | [diff] [blame] | 32 | #include "media/base/media_constants.h" |
Harald Alvestrand | 5761e7b | 2021-01-29 14:45:08 +0000 | [diff] [blame] | 33 | #include "media/base/rid_description.h" |
Steve Anton | 10542f2 | 2019-01-11 09:11:00 -0800 | [diff] [blame] | 34 | #include "media/base/stream_params.h" |
| 35 | #include "p2p/base/transport_description.h" |
| 36 | #include "p2p/base/transport_info.h" |
Harald Alvestrand | 5fc28b1 | 2019-05-13 13:36:16 +0200 | [diff] [blame] | 37 | #include "pc/media_protocol_names.h" |
Steve Anton | 10542f2 | 2019-01-11 09:11:00 -0800 | [diff] [blame] | 38 | #include "pc/simulcast_description.h" |
Harald Alvestrand | 5761e7b | 2021-01-29 14:45:08 +0000 | [diff] [blame] | 39 | #include "rtc_base/checks.h" |
Steve Anton | 10542f2 | 2019-01-11 09:11:00 -0800 | [diff] [blame] | 40 | #include "rtc_base/socket_address.h" |
Mirko Bonadei | 35214fc | 2019-09-23 14:54:28 +0200 | [diff] [blame] | 41 | #include "rtc_base/system/rtc_export.h" |
Steve Anton | 4ab68ee | 2017-12-19 14:26:11 -0800 | [diff] [blame] | 42 | |
| 43 | namespace cricket { |
| 44 | |
Steve Anton | afd8e8c | 2017-12-19 16:35:35 -0800 | [diff] [blame] | 45 | typedef std::vector<AudioCodec> AudioCodecs; |
| 46 | typedef std::vector<VideoCodec> VideoCodecs; |
Steve Anton | afd8e8c | 2017-12-19 16:35:35 -0800 | [diff] [blame] | 47 | typedef std::vector<CryptoParams> CryptoParamsVec; |
| 48 | typedef std::vector<webrtc::RtpExtension> RtpHeaderExtensions; |
| 49 | |
| 50 | // RTC4585 RTP/AVPF |
| 51 | extern const char kMediaProtocolAvpf[]; |
| 52 | // RFC5124 RTP/SAVPF |
| 53 | extern const char kMediaProtocolSavpf[]; |
| 54 | |
| 55 | extern const char kMediaProtocolDtlsSavpf[]; |
| 56 | |
Steve Anton | afd8e8c | 2017-12-19 16:35:35 -0800 | [diff] [blame] | 57 | // Options to control how session descriptions are generated. |
| 58 | const int kAutoBandwidth = -1; |
| 59 | |
Steve Anton | 5adfafd | 2017-12-20 16:34:00 -0800 | [diff] [blame] | 60 | class AudioContentDescription; |
Steve Anton | 46afbf9 | 2019-05-10 11:15:18 -0700 | [diff] [blame] | 61 | class VideoContentDescription; |
Harald Alvestrand | 5fc28b1 | 2019-05-13 13:36:16 +0200 | [diff] [blame] | 62 | class SctpDataContentDescription; |
Philipp Hancke | 4e8c115 | 2020-10-13 12:43:15 +0200 | [diff] [blame] | 63 | class UnsupportedContentDescription; |
Steve Anton | 4ab68ee | 2017-12-19 14:26:11 -0800 | [diff] [blame] | 64 | |
Steve Anton | 5adfafd | 2017-12-20 16:34:00 -0800 | [diff] [blame] | 65 | // Describes a session description media section. There are subclasses for each |
| 66 | // media type (audio, video, data) that will have additional information. |
| 67 | class MediaContentDescription { |
Steve Anton | afd8e8c | 2017-12-19 16:35:35 -0800 | [diff] [blame] | 68 | public: |
Steve Anton | 5adfafd | 2017-12-20 16:34:00 -0800 | [diff] [blame] | 69 | MediaContentDescription() = default; |
| 70 | virtual ~MediaContentDescription() = default; |
Steve Anton | afd8e8c | 2017-12-19 16:35:35 -0800 | [diff] [blame] | 71 | |
| 72 | virtual MediaType type() const = 0; |
Steve Anton | 5adfafd | 2017-12-20 16:34:00 -0800 | [diff] [blame] | 73 | |
| 74 | // Try to cast this media description to an AudioContentDescription. Returns |
| 75 | // nullptr if the cast fails. |
| 76 | virtual AudioContentDescription* as_audio() { return nullptr; } |
| 77 | virtual const AudioContentDescription* as_audio() const { return nullptr; } |
| 78 | |
| 79 | // Try to cast this media description to a VideoContentDescription. Returns |
| 80 | // nullptr if the cast fails. |
| 81 | virtual VideoContentDescription* as_video() { return nullptr; } |
| 82 | virtual const VideoContentDescription* as_video() const { return nullptr; } |
| 83 | |
Harald Alvestrand | 5fc28b1 | 2019-05-13 13:36:16 +0200 | [diff] [blame] | 84 | virtual SctpDataContentDescription* as_sctp() { return nullptr; } |
| 85 | virtual const SctpDataContentDescription* as_sctp() const { return nullptr; } |
| 86 | |
Philipp Hancke | 4e8c115 | 2020-10-13 12:43:15 +0200 | [diff] [blame] | 87 | virtual UnsupportedContentDescription* as_unsupported() { return nullptr; } |
| 88 | virtual const UnsupportedContentDescription* as_unsupported() const { |
| 89 | return nullptr; |
| 90 | } |
| 91 | |
Steve Anton | afd8e8c | 2017-12-19 16:35:35 -0800 | [diff] [blame] | 92 | virtual bool has_codecs() const = 0; |
| 93 | |
Harald Alvestrand | 0fb07f8 | 2020-02-27 20:21:37 +0100 | [diff] [blame] | 94 | // Copy operator that returns an unique_ptr. |
| 95 | // Not a virtual function. |
| 96 | // If a type-specific variant of Clone() is desired, override it, or |
| 97 | // simply use std::make_unique<typename>(*this) instead of Clone(). |
| 98 | std::unique_ptr<MediaContentDescription> Clone() const { |
| 99 | return absl::WrapUnique(CloneInternal()); |
Harald Alvestrand | 1716d39 | 2019-06-03 20:35:45 +0200 | [diff] [blame] | 100 | } |
Steve Anton | 5adfafd | 2017-12-20 16:34:00 -0800 | [diff] [blame] | 101 | |
Steve Anton | afd8e8c | 2017-12-19 16:35:35 -0800 | [diff] [blame] | 102 | // |protocol| is the expected media transport protocol, such as RTP/AVPF, |
| 103 | // RTP/SAVPF or SCTP/DTLS. |
Harald Alvestrand | 5fc28b1 | 2019-05-13 13:36:16 +0200 | [diff] [blame] | 104 | virtual std::string protocol() const { return protocol_; } |
| 105 | virtual void set_protocol(const std::string& protocol) { |
| 106 | protocol_ = protocol; |
| 107 | } |
Steve Anton | afd8e8c | 2017-12-19 16:35:35 -0800 | [diff] [blame] | 108 | |
Harald Alvestrand | 5fc28b1 | 2019-05-13 13:36:16 +0200 | [diff] [blame] | 109 | virtual webrtc::RtpTransceiverDirection direction() const { |
| 110 | return direction_; |
| 111 | } |
| 112 | virtual void set_direction(webrtc::RtpTransceiverDirection direction) { |
Steve Anton | afd8e8c | 2017-12-19 16:35:35 -0800 | [diff] [blame] | 113 | direction_ = direction; |
| 114 | } |
| 115 | |
Harald Alvestrand | 5fc28b1 | 2019-05-13 13:36:16 +0200 | [diff] [blame] | 116 | virtual bool rtcp_mux() const { return rtcp_mux_; } |
| 117 | virtual void set_rtcp_mux(bool mux) { rtcp_mux_ = mux; } |
Steve Anton | afd8e8c | 2017-12-19 16:35:35 -0800 | [diff] [blame] | 118 | |
Harald Alvestrand | 5fc28b1 | 2019-05-13 13:36:16 +0200 | [diff] [blame] | 119 | virtual bool rtcp_reduced_size() const { return rtcp_reduced_size_; } |
| 120 | virtual void set_rtcp_reduced_size(bool reduced_size) { |
Steve Anton | afd8e8c | 2017-12-19 16:35:35 -0800 | [diff] [blame] | 121 | rtcp_reduced_size_ = reduced_size; |
| 122 | } |
| 123 | |
Sebastian Jansson | 97321b6 | 2019-07-24 14:01:18 +0200 | [diff] [blame] | 124 | // Indicates support for the remote network estimate packet type. This |
| 125 | // functionality is experimental and subject to change without notice. |
Sebastian Jansson | e1795f4 | 2019-07-24 11:38:03 +0200 | [diff] [blame] | 126 | virtual bool remote_estimate() const { return remote_estimate_; } |
| 127 | virtual void set_remote_estimate(bool remote_estimate) { |
| 128 | remote_estimate_ = remote_estimate; |
| 129 | } |
| 130 | |
Harald Alvestrand | 5fc28b1 | 2019-05-13 13:36:16 +0200 | [diff] [blame] | 131 | virtual int bandwidth() const { return bandwidth_; } |
| 132 | virtual void set_bandwidth(int bandwidth) { bandwidth_ = bandwidth; } |
Taylor Brandstetter | ee8c246 | 2020-07-27 15:52:02 -0700 | [diff] [blame] | 133 | virtual std::string bandwidth_type() const { return bandwidth_type_; } |
| 134 | virtual void set_bandwidth_type(std::string bandwidth_type) { |
| 135 | bandwidth_type_ = bandwidth_type; |
| 136 | } |
Steve Anton | afd8e8c | 2017-12-19 16:35:35 -0800 | [diff] [blame] | 137 | |
Harald Alvestrand | 5fc28b1 | 2019-05-13 13:36:16 +0200 | [diff] [blame] | 138 | virtual const std::vector<CryptoParams>& cryptos() const { return cryptos_; } |
| 139 | virtual void AddCrypto(const CryptoParams& params) { |
| 140 | cryptos_.push_back(params); |
| 141 | } |
| 142 | virtual void set_cryptos(const std::vector<CryptoParams>& cryptos) { |
Steve Anton | afd8e8c | 2017-12-19 16:35:35 -0800 | [diff] [blame] | 143 | cryptos_ = cryptos; |
| 144 | } |
| 145 | |
Lennart Grahl | 0d0ed76 | 2021-05-17 16:06:37 +0200 | [diff] [blame] | 146 | // List of RTP header extensions. URIs are **NOT** guaranteed to be unique |
| 147 | // as they can appear twice when both encrypted and non-encrypted extensions |
| 148 | // are present. |
| 149 | // Use RtpExtension::FindHeaderExtensionByUri for finding and |
| 150 | // RtpExtension::DeduplicateHeaderExtensions for filtering. |
Harald Alvestrand | 5fc28b1 | 2019-05-13 13:36:16 +0200 | [diff] [blame] | 151 | virtual const RtpHeaderExtensions& rtp_header_extensions() const { |
Steve Anton | afd8e8c | 2017-12-19 16:35:35 -0800 | [diff] [blame] | 152 | return rtp_header_extensions_; |
| 153 | } |
Harald Alvestrand | 5fc28b1 | 2019-05-13 13:36:16 +0200 | [diff] [blame] | 154 | virtual void set_rtp_header_extensions( |
| 155 | const RtpHeaderExtensions& extensions) { |
Steve Anton | afd8e8c | 2017-12-19 16:35:35 -0800 | [diff] [blame] | 156 | rtp_header_extensions_ = extensions; |
| 157 | rtp_header_extensions_set_ = true; |
| 158 | } |
Harald Alvestrand | 5fc28b1 | 2019-05-13 13:36:16 +0200 | [diff] [blame] | 159 | virtual void AddRtpHeaderExtension(const webrtc::RtpExtension& ext) { |
Steve Anton | afd8e8c | 2017-12-19 16:35:35 -0800 | [diff] [blame] | 160 | rtp_header_extensions_.push_back(ext); |
| 161 | rtp_header_extensions_set_ = true; |
| 162 | } |
Harald Alvestrand | 5fc28b1 | 2019-05-13 13:36:16 +0200 | [diff] [blame] | 163 | virtual void ClearRtpHeaderExtensions() { |
Steve Anton | afd8e8c | 2017-12-19 16:35:35 -0800 | [diff] [blame] | 164 | rtp_header_extensions_.clear(); |
| 165 | rtp_header_extensions_set_ = true; |
| 166 | } |
| 167 | // We can't always tell if an empty list of header extensions is |
| 168 | // because the other side doesn't support them, or just isn't hooked up to |
| 169 | // signal them. For now we assume an empty list means no signaling, but |
| 170 | // provide the ClearRtpHeaderExtensions method to allow "no support" to be |
| 171 | // clearly indicated (i.e. when derived from other information). |
Harald Alvestrand | 5fc28b1 | 2019-05-13 13:36:16 +0200 | [diff] [blame] | 172 | virtual bool rtp_header_extensions_set() const { |
| 173 | return rtp_header_extensions_set_; |
| 174 | } |
| 175 | virtual const StreamParamsVec& streams() const { return send_streams_; } |
Steve Anton | afd8e8c | 2017-12-19 16:35:35 -0800 | [diff] [blame] | 176 | // TODO(pthatcher): Remove this by giving mediamessage.cc access |
| 177 | // to MediaContentDescription |
Harald Alvestrand | 5fc28b1 | 2019-05-13 13:36:16 +0200 | [diff] [blame] | 178 | virtual StreamParamsVec& mutable_streams() { return send_streams_; } |
| 179 | virtual void AddStream(const StreamParams& stream) { |
Amit Hilbuch | c57d573 | 2018-12-11 15:30:11 -0800 | [diff] [blame] | 180 | send_streams_.push_back(stream); |
| 181 | } |
Steve Anton | afd8e8c | 2017-12-19 16:35:35 -0800 | [diff] [blame] | 182 | // Legacy streams have an ssrc, but nothing else. |
| 183 | void AddLegacyStream(uint32_t ssrc) { |
Harald Alvestrand | 5fc28b1 | 2019-05-13 13:36:16 +0200 | [diff] [blame] | 184 | AddStream(StreamParams::CreateLegacy(ssrc)); |
Steve Anton | afd8e8c | 2017-12-19 16:35:35 -0800 | [diff] [blame] | 185 | } |
| 186 | void AddLegacyStream(uint32_t ssrc, uint32_t fid_ssrc) { |
| 187 | StreamParams sp = StreamParams::CreateLegacy(ssrc); |
| 188 | sp.AddFidSsrc(ssrc, fid_ssrc); |
Harald Alvestrand | 5fc28b1 | 2019-05-13 13:36:16 +0200 | [diff] [blame] | 189 | AddStream(sp); |
Steve Anton | afd8e8c | 2017-12-19 16:35:35 -0800 | [diff] [blame] | 190 | } |
Amit Hilbuch | c57d573 | 2018-12-11 15:30:11 -0800 | [diff] [blame] | 191 | |
Steve Anton | afd8e8c | 2017-12-19 16:35:35 -0800 | [diff] [blame] | 192 | // Sets the CNAME of all StreamParams if it have not been set. |
Harald Alvestrand | 5fc28b1 | 2019-05-13 13:36:16 +0200 | [diff] [blame] | 193 | virtual void SetCnameIfEmpty(const std::string& cname) { |
Amit Hilbuch | c57d573 | 2018-12-11 15:30:11 -0800 | [diff] [blame] | 194 | for (cricket::StreamParamsVec::iterator it = send_streams_.begin(); |
| 195 | it != send_streams_.end(); ++it) { |
Steve Anton | afd8e8c | 2017-12-19 16:35:35 -0800 | [diff] [blame] | 196 | if (it->cname.empty()) |
| 197 | it->cname = cname; |
| 198 | } |
| 199 | } |
Harald Alvestrand | 5fc28b1 | 2019-05-13 13:36:16 +0200 | [diff] [blame] | 200 | virtual uint32_t first_ssrc() const { |
Amit Hilbuch | c57d573 | 2018-12-11 15:30:11 -0800 | [diff] [blame] | 201 | if (send_streams_.empty()) { |
Steve Anton | afd8e8c | 2017-12-19 16:35:35 -0800 | [diff] [blame] | 202 | return 0; |
| 203 | } |
Amit Hilbuch | c57d573 | 2018-12-11 15:30:11 -0800 | [diff] [blame] | 204 | return send_streams_[0].first_ssrc(); |
Steve Anton | afd8e8c | 2017-12-19 16:35:35 -0800 | [diff] [blame] | 205 | } |
Harald Alvestrand | 5fc28b1 | 2019-05-13 13:36:16 +0200 | [diff] [blame] | 206 | virtual bool has_ssrcs() const { |
Amit Hilbuch | c57d573 | 2018-12-11 15:30:11 -0800 | [diff] [blame] | 207 | if (send_streams_.empty()) { |
Steve Anton | afd8e8c | 2017-12-19 16:35:35 -0800 | [diff] [blame] | 208 | return false; |
| 209 | } |
Amit Hilbuch | c57d573 | 2018-12-11 15:30:11 -0800 | [diff] [blame] | 210 | return send_streams_[0].has_ssrcs(); |
Steve Anton | afd8e8c | 2017-12-19 16:35:35 -0800 | [diff] [blame] | 211 | } |
| 212 | |
Harald Alvestrand | 5fc28b1 | 2019-05-13 13:36:16 +0200 | [diff] [blame] | 213 | virtual void set_conference_mode(bool enable) { conference_mode_ = enable; } |
| 214 | virtual bool conference_mode() const { return conference_mode_; } |
Steve Anton | afd8e8c | 2017-12-19 16:35:35 -0800 | [diff] [blame] | 215 | |
| 216 | // https://tools.ietf.org/html/rfc4566#section-5.7 |
| 217 | // May be present at the media or session level of SDP. If present at both |
| 218 | // levels, the media-level attribute overwrites the session-level one. |
Harald Alvestrand | 5fc28b1 | 2019-05-13 13:36:16 +0200 | [diff] [blame] | 219 | virtual void set_connection_address(const rtc::SocketAddress& address) { |
Steve Anton | afd8e8c | 2017-12-19 16:35:35 -0800 | [diff] [blame] | 220 | connection_address_ = address; |
| 221 | } |
Harald Alvestrand | 5fc28b1 | 2019-05-13 13:36:16 +0200 | [diff] [blame] | 222 | virtual const rtc::SocketAddress& connection_address() const { |
Steve Anton | afd8e8c | 2017-12-19 16:35:35 -0800 | [diff] [blame] | 223 | return connection_address_; |
| 224 | } |
| 225 | |
Johannes Kron | 0854eb6 | 2018-10-10 22:33:20 +0200 | [diff] [blame] | 226 | // Determines if it's allowed to mix one- and two-byte rtp header extensions |
| 227 | // within the same rtp stream. |
Johannes Kron | 9581bc4 | 2018-10-23 10:17:39 +0200 | [diff] [blame] | 228 | enum ExtmapAllowMixed { kNo, kSession, kMedia }; |
Harald Alvestrand | 5fc28b1 | 2019-05-13 13:36:16 +0200 | [diff] [blame] | 229 | virtual void set_extmap_allow_mixed_enum( |
| 230 | ExtmapAllowMixed new_extmap_allow_mixed) { |
Johannes Kron | 9ac3c91 | 2018-10-12 10:54:26 +0200 | [diff] [blame] | 231 | if (new_extmap_allow_mixed == kMedia && |
Johannes Kron | 9581bc4 | 2018-10-23 10:17:39 +0200 | [diff] [blame] | 232 | extmap_allow_mixed_enum_ == kSession) { |
Johannes Kron | 0854eb6 | 2018-10-10 22:33:20 +0200 | [diff] [blame] | 233 | // Do not downgrade from session level to media level. |
| 234 | return; |
| 235 | } |
Johannes Kron | 9581bc4 | 2018-10-23 10:17:39 +0200 | [diff] [blame] | 236 | extmap_allow_mixed_enum_ = new_extmap_allow_mixed; |
Johannes Kron | 0854eb6 | 2018-10-10 22:33:20 +0200 | [diff] [blame] | 237 | } |
Harald Alvestrand | 5fc28b1 | 2019-05-13 13:36:16 +0200 | [diff] [blame] | 238 | virtual ExtmapAllowMixed extmap_allow_mixed_enum() const { |
Johannes Kron | 9581bc4 | 2018-10-23 10:17:39 +0200 | [diff] [blame] | 239 | return extmap_allow_mixed_enum_; |
Johannes Kron | 9ac3c91 | 2018-10-12 10:54:26 +0200 | [diff] [blame] | 240 | } |
Harald Alvestrand | 5fc28b1 | 2019-05-13 13:36:16 +0200 | [diff] [blame] | 241 | virtual bool extmap_allow_mixed() const { |
| 242 | return extmap_allow_mixed_enum_ != kNo; |
| 243 | } |
Johannes Kron | 0854eb6 | 2018-10-10 22:33:20 +0200 | [diff] [blame] | 244 | |
Amit Hilbuch | a201204 | 2018-12-03 11:35:05 -0800 | [diff] [blame] | 245 | // Simulcast functionality. |
| 246 | virtual bool HasSimulcast() const { return !simulcast_.empty(); } |
| 247 | virtual SimulcastDescription& simulcast_description() { return simulcast_; } |
| 248 | virtual const SimulcastDescription& simulcast_description() const { |
| 249 | return simulcast_; |
| 250 | } |
| 251 | virtual void set_simulcast_description( |
| 252 | const SimulcastDescription& simulcast) { |
| 253 | simulcast_ = simulcast; |
| 254 | } |
Florent Castelli | b60141b | 2019-07-03 12:47:54 +0200 | [diff] [blame] | 255 | virtual const std::vector<RidDescription>& receive_rids() const { |
| 256 | return receive_rids_; |
| 257 | } |
| 258 | virtual void set_receive_rids(const std::vector<RidDescription>& rids) { |
| 259 | receive_rids_ = rids; |
| 260 | } |
Amit Hilbuch | a201204 | 2018-12-03 11:35:05 -0800 | [diff] [blame] | 261 | |
Steve Anton | afd8e8c | 2017-12-19 16:35:35 -0800 | [diff] [blame] | 262 | protected: |
| 263 | bool rtcp_mux_ = false; |
| 264 | bool rtcp_reduced_size_ = false; |
Sebastian Jansson | e1795f4 | 2019-07-24 11:38:03 +0200 | [diff] [blame] | 265 | bool remote_estimate_ = false; |
Steve Anton | afd8e8c | 2017-12-19 16:35:35 -0800 | [diff] [blame] | 266 | int bandwidth_ = kAutoBandwidth; |
Taylor Brandstetter | ee8c246 | 2020-07-27 15:52:02 -0700 | [diff] [blame] | 267 | std::string bandwidth_type_ = kApplicationSpecificBandwidth; |
Steve Anton | afd8e8c | 2017-12-19 16:35:35 -0800 | [diff] [blame] | 268 | std::string protocol_; |
| 269 | std::vector<CryptoParams> cryptos_; |
| 270 | std::vector<webrtc::RtpExtension> rtp_header_extensions_; |
| 271 | bool rtp_header_extensions_set_ = false; |
Amit Hilbuch | c57d573 | 2018-12-11 15:30:11 -0800 | [diff] [blame] | 272 | StreamParamsVec send_streams_; |
Steve Anton | afd8e8c | 2017-12-19 16:35:35 -0800 | [diff] [blame] | 273 | bool conference_mode_ = false; |
| 274 | webrtc::RtpTransceiverDirection direction_ = |
| 275 | webrtc::RtpTransceiverDirection::kSendRecv; |
| 276 | rtc::SocketAddress connection_address_; |
Emil Lundmark | 801c999 | 2021-01-19 13:06:32 +0100 | [diff] [blame] | 277 | ExtmapAllowMixed extmap_allow_mixed_enum_ = kMedia; |
Amit Hilbuch | a201204 | 2018-12-03 11:35:05 -0800 | [diff] [blame] | 278 | |
| 279 | SimulcastDescription simulcast_; |
Florent Castelli | b60141b | 2019-07-03 12:47:54 +0200 | [diff] [blame] | 280 | std::vector<RidDescription> receive_rids_; |
Bjorn A Mellem | 8e1343a | 2019-09-30 15:12:47 -0700 | [diff] [blame] | 281 | |
Harald Alvestrand | 0fb07f8 | 2020-02-27 20:21:37 +0100 | [diff] [blame] | 282 | private: |
| 283 | // Copy function that returns a raw pointer. Caller will assert ownership. |
| 284 | // Should only be called by the Clone() function. Must be implemented |
| 285 | // by each final subclass. |
| 286 | virtual MediaContentDescription* CloneInternal() const = 0; |
Steve Anton | afd8e8c | 2017-12-19 16:35:35 -0800 | [diff] [blame] | 287 | }; |
| 288 | |
| 289 | template <class C> |
| 290 | class MediaContentDescriptionImpl : public MediaContentDescription { |
| 291 | public: |
Harald Alvestrand | 5fc28b1 | 2019-05-13 13:36:16 +0200 | [diff] [blame] | 292 | void set_protocol(const std::string& protocol) override { |
| 293 | RTC_DCHECK(IsRtpProtocol(protocol)); |
| 294 | protocol_ = protocol; |
| 295 | } |
| 296 | |
Steve Anton | afd8e8c | 2017-12-19 16:35:35 -0800 | [diff] [blame] | 297 | typedef C CodecType; |
| 298 | |
| 299 | // Codecs should be in preference order (most preferred codec first). |
Harald Alvestrand | 5fc28b1 | 2019-05-13 13:36:16 +0200 | [diff] [blame] | 300 | virtual const std::vector<C>& codecs() const { return codecs_; } |
| 301 | virtual void set_codecs(const std::vector<C>& codecs) { codecs_ = codecs; } |
| 302 | bool has_codecs() const override { return !codecs_.empty(); } |
| 303 | virtual bool HasCodec(int id) { |
Steve Anton | afd8e8c | 2017-12-19 16:35:35 -0800 | [diff] [blame] | 304 | bool found = false; |
| 305 | for (typename std::vector<C>::iterator iter = codecs_.begin(); |
| 306 | iter != codecs_.end(); ++iter) { |
| 307 | if (iter->id == id) { |
| 308 | found = true; |
| 309 | break; |
| 310 | } |
| 311 | } |
| 312 | return found; |
| 313 | } |
Harald Alvestrand | 5fc28b1 | 2019-05-13 13:36:16 +0200 | [diff] [blame] | 314 | virtual void AddCodec(const C& codec) { codecs_.push_back(codec); } |
| 315 | virtual void AddOrReplaceCodec(const C& codec) { |
Steve Anton | afd8e8c | 2017-12-19 16:35:35 -0800 | [diff] [blame] | 316 | for (typename std::vector<C>::iterator iter = codecs_.begin(); |
| 317 | iter != codecs_.end(); ++iter) { |
| 318 | if (iter->id == codec.id) { |
| 319 | *iter = codec; |
| 320 | return; |
| 321 | } |
| 322 | } |
| 323 | AddCodec(codec); |
| 324 | } |
Harald Alvestrand | 5fc28b1 | 2019-05-13 13:36:16 +0200 | [diff] [blame] | 325 | virtual void AddCodecs(const std::vector<C>& codecs) { |
Steve Anton | afd8e8c | 2017-12-19 16:35:35 -0800 | [diff] [blame] | 326 | typename std::vector<C>::const_iterator codec; |
| 327 | for (codec = codecs.begin(); codec != codecs.end(); ++codec) { |
| 328 | AddCodec(*codec); |
| 329 | } |
| 330 | } |
| 331 | |
| 332 | private: |
| 333 | std::vector<C> codecs_; |
| 334 | }; |
| 335 | |
| 336 | class AudioContentDescription : public MediaContentDescriptionImpl<AudioCodec> { |
| 337 | public: |
| 338 | AudioContentDescription() {} |
| 339 | |
Steve Anton | afd8e8c | 2017-12-19 16:35:35 -0800 | [diff] [blame] | 340 | virtual MediaType type() const { return MEDIA_TYPE_AUDIO; } |
Steve Anton | 5adfafd | 2017-12-20 16:34:00 -0800 | [diff] [blame] | 341 | virtual AudioContentDescription* as_audio() { return this; } |
| 342 | virtual const AudioContentDescription* as_audio() const { return this; } |
Harald Alvestrand | 0fb07f8 | 2020-02-27 20:21:37 +0100 | [diff] [blame] | 343 | |
| 344 | private: |
| 345 | virtual AudioContentDescription* CloneInternal() const { |
| 346 | return new AudioContentDescription(*this); |
| 347 | } |
Steve Anton | afd8e8c | 2017-12-19 16:35:35 -0800 | [diff] [blame] | 348 | }; |
| 349 | |
| 350 | class VideoContentDescription : public MediaContentDescriptionImpl<VideoCodec> { |
| 351 | public: |
Steve Anton | afd8e8c | 2017-12-19 16:35:35 -0800 | [diff] [blame] | 352 | virtual MediaType type() const { return MEDIA_TYPE_VIDEO; } |
Steve Anton | 5adfafd | 2017-12-20 16:34:00 -0800 | [diff] [blame] | 353 | virtual VideoContentDescription* as_video() { return this; } |
| 354 | virtual const VideoContentDescription* as_video() const { return this; } |
Harald Alvestrand | 0fb07f8 | 2020-02-27 20:21:37 +0100 | [diff] [blame] | 355 | |
| 356 | private: |
| 357 | virtual VideoContentDescription* CloneInternal() const { |
| 358 | return new VideoContentDescription(*this); |
| 359 | } |
Steve Anton | afd8e8c | 2017-12-19 16:35:35 -0800 | [diff] [blame] | 360 | }; |
| 361 | |
Harald Alvestrand | 5fc28b1 | 2019-05-13 13:36:16 +0200 | [diff] [blame] | 362 | class SctpDataContentDescription : public MediaContentDescription { |
| 363 | public: |
| 364 | SctpDataContentDescription() {} |
| 365 | SctpDataContentDescription(const SctpDataContentDescription& o) |
| 366 | : MediaContentDescription(o), |
| 367 | use_sctpmap_(o.use_sctpmap_), |
| 368 | port_(o.port_), |
Harald Alvestrand | c5effc2 | 2019-06-11 11:46:59 +0200 | [diff] [blame] | 369 | max_message_size_(o.max_message_size_) {} |
Harald Alvestrand | 5fc28b1 | 2019-05-13 13:36:16 +0200 | [diff] [blame] | 370 | MediaType type() const override { return MEDIA_TYPE_DATA; } |
| 371 | SctpDataContentDescription* as_sctp() override { return this; } |
| 372 | const SctpDataContentDescription* as_sctp() const override { return this; } |
Harald Alvestrand | 5fc28b1 | 2019-05-13 13:36:16 +0200 | [diff] [blame] | 373 | |
| 374 | bool has_codecs() const override { return false; } |
| 375 | void set_protocol(const std::string& protocol) override { |
| 376 | RTC_DCHECK(IsSctpProtocol(protocol)); |
| 377 | protocol_ = protocol; |
| 378 | } |
Steve Anton | afd8e8c | 2017-12-19 16:35:35 -0800 | [diff] [blame] | 379 | |
| 380 | bool use_sctpmap() const { return use_sctpmap_; } |
| 381 | void set_use_sctpmap(bool enable) { use_sctpmap_ = enable; } |
Harald Alvestrand | 5fc28b1 | 2019-05-13 13:36:16 +0200 | [diff] [blame] | 382 | int port() const { return port_; } |
| 383 | void set_port(int port) { port_ = port; } |
| 384 | int max_message_size() const { return max_message_size_; } |
| 385 | void set_max_message_size(int max_message_size) { |
| 386 | max_message_size_ = max_message_size; |
| 387 | } |
Steve Anton | afd8e8c | 2017-12-19 16:35:35 -0800 | [diff] [blame] | 388 | |
| 389 | private: |
Harald Alvestrand | 0fb07f8 | 2020-02-27 20:21:37 +0100 | [diff] [blame] | 390 | SctpDataContentDescription* CloneInternal() const override { |
| 391 | return new SctpDataContentDescription(*this); |
| 392 | } |
Harald Alvestrand | 5fc28b1 | 2019-05-13 13:36:16 +0200 | [diff] [blame] | 393 | bool use_sctpmap_ = true; // Note: "true" is no longer conformant. |
| 394 | // Defaults should be constants imported from SCTP. Quick hack. |
| 395 | int port_ = 5000; |
Harald Alvestrand | fbb45bd | 2019-05-15 08:07:47 +0200 | [diff] [blame] | 396 | // draft-ietf-mmusic-sdp-sctp-23: Max message size default is 64K |
| 397 | int max_message_size_ = 64 * 1024; |
Steve Anton | afd8e8c | 2017-12-19 16:35:35 -0800 | [diff] [blame] | 398 | }; |
| 399 | |
Philipp Hancke | 4e8c115 | 2020-10-13 12:43:15 +0200 | [diff] [blame] | 400 | class UnsupportedContentDescription : public MediaContentDescription { |
| 401 | public: |
| 402 | explicit UnsupportedContentDescription(const std::string& media_type) |
| 403 | : media_type_(media_type) {} |
| 404 | MediaType type() const override { return MEDIA_TYPE_UNSUPPORTED; } |
| 405 | |
| 406 | UnsupportedContentDescription* as_unsupported() override { return this; } |
| 407 | const UnsupportedContentDescription* as_unsupported() const override { |
| 408 | return this; |
| 409 | } |
| 410 | |
| 411 | bool has_codecs() const override { return false; } |
| 412 | const std::string& media_type() const { return media_type_; } |
| 413 | |
| 414 | private: |
| 415 | UnsupportedContentDescription* CloneInternal() const override { |
| 416 | return new UnsupportedContentDescription(*this); |
| 417 | } |
| 418 | |
| 419 | std::string media_type_; |
| 420 | }; |
| 421 | |
Steve Anton | 5adfafd | 2017-12-20 16:34:00 -0800 | [diff] [blame] | 422 | // Protocol used for encoding media. This is the "top level" protocol that may |
| 423 | // be wrapped by zero or many transport protocols (UDP, ICE, etc.). |
| 424 | enum class MediaProtocolType { |
Philipp Hancke | 4e8c115 | 2020-10-13 12:43:15 +0200 | [diff] [blame] | 425 | kRtp, // Section will use the RTP protocol (e.g., for audio or video). |
| 426 | // https://tools.ietf.org/html/rfc3550 |
| 427 | kSctp, // Section will use the SCTP protocol (e.g., for a data channel). |
| 428 | // https://tools.ietf.org/html/rfc4960 |
| 429 | kOther // Section will use another top protocol which is not |
| 430 | // explicitly supported. |
Steve Anton | 5adfafd | 2017-12-20 16:34:00 -0800 | [diff] [blame] | 431 | }; |
| 432 | |
Steve Anton | 5adfafd | 2017-12-20 16:34:00 -0800 | [diff] [blame] | 433 | // Represents a session description section. Most information about the section |
| 434 | // is stored in the description, which is a subclass of MediaContentDescription. |
Harald Alvestrand | 1716d39 | 2019-06-03 20:35:45 +0200 | [diff] [blame] | 435 | // Owns the description. |
Mirko Bonadei | 35214fc | 2019-09-23 14:54:28 +0200 | [diff] [blame] | 436 | class RTC_EXPORT ContentInfo { |
Harald Alvestrand | 1716d39 | 2019-06-03 20:35:45 +0200 | [diff] [blame] | 437 | public: |
Steve Anton | 5adfafd | 2017-12-20 16:34:00 -0800 | [diff] [blame] | 438 | explicit ContentInfo(MediaProtocolType type) : type(type) {} |
Harald Alvestrand | 1716d39 | 2019-06-03 20:35:45 +0200 | [diff] [blame] | 439 | ~ContentInfo(); |
| 440 | // Copy |
| 441 | ContentInfo(const ContentInfo& o); |
| 442 | ContentInfo& operator=(const ContentInfo& o); |
| 443 | ContentInfo(ContentInfo&& o) = default; |
| 444 | ContentInfo& operator=(ContentInfo&& o) = default; |
Steve Anton | 5adfafd | 2017-12-20 16:34:00 -0800 | [diff] [blame] | 445 | |
| 446 | // Alias for |name|. |
| 447 | std::string mid() const { return name; } |
| 448 | void set_mid(const std::string& mid) { this->name = mid; } |
| 449 | |
| 450 | // Alias for |description|. |
Harald Alvestrand | 1716d39 | 2019-06-03 20:35:45 +0200 | [diff] [blame] | 451 | MediaContentDescription* media_description(); |
| 452 | const MediaContentDescription* media_description() const; |
| 453 | |
| 454 | void set_media_description(std::unique_ptr<MediaContentDescription> desc) { |
| 455 | description_ = std::move(desc); |
Steve Anton | 5adfafd | 2017-12-20 16:34:00 -0800 | [diff] [blame] | 456 | } |
| 457 | |
Steve Anton | 8171211 | 2018-01-05 11:27:54 -0800 | [diff] [blame] | 458 | // TODO(bugs.webrtc.org/8620): Rename this to mid. |
Steve Anton | 4ab68ee | 2017-12-19 14:26:11 -0800 | [diff] [blame] | 459 | std::string name; |
Steve Anton | 5adfafd | 2017-12-20 16:34:00 -0800 | [diff] [blame] | 460 | MediaProtocolType type; |
Steve Anton | 4ab68ee | 2017-12-19 14:26:11 -0800 | [diff] [blame] | 461 | bool rejected = false; |
| 462 | bool bundle_only = false; |
Harald Alvestrand | 1716d39 | 2019-06-03 20:35:45 +0200 | [diff] [blame] | 463 | |
| 464 | private: |
| 465 | friend class SessionDescription; |
| 466 | std::unique_ptr<MediaContentDescription> description_; |
Steve Anton | 4ab68ee | 2017-12-19 14:26:11 -0800 | [diff] [blame] | 467 | }; |
| 468 | |
| 469 | typedef std::vector<std::string> ContentNames; |
| 470 | |
| 471 | // This class provides a mechanism to aggregate different media contents into a |
| 472 | // group. This group can also be shared with the peers in a pre-defined format. |
| 473 | // GroupInfo should be populated only with the |content_name| of the |
| 474 | // MediaDescription. |
| 475 | class ContentGroup { |
| 476 | public: |
| 477 | explicit ContentGroup(const std::string& semantics); |
| 478 | ContentGroup(const ContentGroup&); |
| 479 | ContentGroup(ContentGroup&&); |
| 480 | ContentGroup& operator=(const ContentGroup&); |
| 481 | ContentGroup& operator=(ContentGroup&&); |
| 482 | ~ContentGroup(); |
| 483 | |
| 484 | const std::string& semantics() const { return semantics_; } |
| 485 | const ContentNames& content_names() const { return content_names_; } |
| 486 | |
| 487 | const std::string* FirstContentName() const; |
| 488 | bool HasContentName(const std::string& content_name) const; |
| 489 | void AddContentName(const std::string& content_name); |
| 490 | bool RemoveContentName(const std::string& content_name); |
Harald Alvestrand | 7a2db8a | 2021-06-14 15:41:30 +0000 | [diff] [blame^] | 491 | // for debugging |
| 492 | std::string ToString() const; |
Steve Anton | 4ab68ee | 2017-12-19 14:26:11 -0800 | [diff] [blame] | 493 | |
| 494 | private: |
| 495 | std::string semantics_; |
| 496 | ContentNames content_names_; |
| 497 | }; |
| 498 | |
| 499 | typedef std::vector<ContentInfo> ContentInfos; |
| 500 | typedef std::vector<ContentGroup> ContentGroups; |
| 501 | |
| 502 | const ContentInfo* FindContentInfoByName(const ContentInfos& contents, |
| 503 | const std::string& name); |
| 504 | const ContentInfo* FindContentInfoByType(const ContentInfos& contents, |
| 505 | const std::string& type); |
| 506 | |
Steve Anton | e831b8c | 2018-02-01 12:22:16 -0800 | [diff] [blame] | 507 | // Determines how the MSID will be signaled in the SDP. These can be used as |
| 508 | // flags to indicate both or none. |
| 509 | enum MsidSignaling { |
| 510 | // Signal MSID with one a=msid line in the media section. |
| 511 | kMsidSignalingMediaSection = 0x1, |
| 512 | // Signal MSID with a=ssrc: msid lines in the media section. |
| 513 | kMsidSignalingSsrcAttribute = 0x2 |
| 514 | }; |
| 515 | |
Steve Anton | 4ab68ee | 2017-12-19 14:26:11 -0800 | [diff] [blame] | 516 | // Describes a collection of contents, each with its own name and |
| 517 | // type. Analogous to a <jingle> or <session> stanza. Assumes that |
| 518 | // contents are unique be name, but doesn't enforce that. |
| 519 | class SessionDescription { |
| 520 | public: |
| 521 | SessionDescription(); |
Steve Anton | 4ab68ee | 2017-12-19 14:26:11 -0800 | [diff] [blame] | 522 | ~SessionDescription(); |
| 523 | |
Harald Alvestrand | 4d7160e | 2019-04-12 07:01:29 +0200 | [diff] [blame] | 524 | std::unique_ptr<SessionDescription> Clone() const; |
Steve Anton | 4ab68ee | 2017-12-19 14:26:11 -0800 | [diff] [blame] | 525 | |
| 526 | // Content accessors. |
| 527 | const ContentInfos& contents() const { return contents_; } |
| 528 | ContentInfos& contents() { return contents_; } |
| 529 | const ContentInfo* GetContentByName(const std::string& name) const; |
| 530 | ContentInfo* GetContentByName(const std::string& name); |
Steve Anton | b1c1de1 | 2017-12-21 15:14:30 -0800 | [diff] [blame] | 531 | const MediaContentDescription* GetContentDescriptionByName( |
Steve Anton | 4ab68ee | 2017-12-19 14:26:11 -0800 | [diff] [blame] | 532 | const std::string& name) const; |
Steve Anton | b1c1de1 | 2017-12-21 15:14:30 -0800 | [diff] [blame] | 533 | MediaContentDescription* GetContentDescriptionByName(const std::string& name); |
Steve Anton | 5adfafd | 2017-12-20 16:34:00 -0800 | [diff] [blame] | 534 | const ContentInfo* FirstContentByType(MediaProtocolType type) const; |
Steve Anton | 4ab68ee | 2017-12-19 14:26:11 -0800 | [diff] [blame] | 535 | const ContentInfo* FirstContent() const; |
| 536 | |
| 537 | // Content mutators. |
| 538 | // Adds a content to this description. Takes ownership of ContentDescription*. |
| 539 | void AddContent(const std::string& name, |
Steve Anton | 5adfafd | 2017-12-20 16:34:00 -0800 | [diff] [blame] | 540 | MediaProtocolType type, |
Harald Alvestrand | 1716d39 | 2019-06-03 20:35:45 +0200 | [diff] [blame] | 541 | std::unique_ptr<MediaContentDescription> description); |
Steve Anton | 4ab68ee | 2017-12-19 14:26:11 -0800 | [diff] [blame] | 542 | void AddContent(const std::string& name, |
Steve Anton | 5adfafd | 2017-12-20 16:34:00 -0800 | [diff] [blame] | 543 | MediaProtocolType type, |
Steve Anton | 4ab68ee | 2017-12-19 14:26:11 -0800 | [diff] [blame] | 544 | bool rejected, |
Harald Alvestrand | 1716d39 | 2019-06-03 20:35:45 +0200 | [diff] [blame] | 545 | std::unique_ptr<MediaContentDescription> description); |
Steve Anton | 4ab68ee | 2017-12-19 14:26:11 -0800 | [diff] [blame] | 546 | void AddContent(const std::string& name, |
Steve Anton | 5adfafd | 2017-12-20 16:34:00 -0800 | [diff] [blame] | 547 | MediaProtocolType type, |
Steve Anton | 4ab68ee | 2017-12-19 14:26:11 -0800 | [diff] [blame] | 548 | bool rejected, |
| 549 | bool bundle_only, |
Harald Alvestrand | 1716d39 | 2019-06-03 20:35:45 +0200 | [diff] [blame] | 550 | std::unique_ptr<MediaContentDescription> description); |
| 551 | void AddContent(ContentInfo&& content); |
Johannes Kron | 9ac3c91 | 2018-10-12 10:54:26 +0200 | [diff] [blame] | 552 | |
Steve Anton | 4ab68ee | 2017-12-19 14:26:11 -0800 | [diff] [blame] | 553 | bool RemoveContentByName(const std::string& name); |
| 554 | |
| 555 | // Transport accessors. |
| 556 | const TransportInfos& transport_infos() const { return transport_infos_; } |
| 557 | TransportInfos& transport_infos() { return transport_infos_; } |
| 558 | const TransportInfo* GetTransportInfoByName(const std::string& name) const; |
| 559 | TransportInfo* GetTransportInfoByName(const std::string& name); |
| 560 | const TransportDescription* GetTransportDescriptionByName( |
| 561 | const std::string& name) const { |
| 562 | const TransportInfo* tinfo = GetTransportInfoByName(name); |
| 563 | return tinfo ? &tinfo->description : NULL; |
| 564 | } |
| 565 | |
| 566 | // Transport mutators. |
| 567 | void set_transport_infos(const TransportInfos& transport_infos) { |
| 568 | transport_infos_ = transport_infos; |
| 569 | } |
| 570 | // Adds a TransportInfo to this description. |
Steve Anton | 06817cd | 2018-12-18 15:55:30 -0800 | [diff] [blame] | 571 | void AddTransportInfo(const TransportInfo& transport_info); |
Steve Anton | 4ab68ee | 2017-12-19 14:26:11 -0800 | [diff] [blame] | 572 | bool RemoveTransportInfoByName(const std::string& name); |
| 573 | |
| 574 | // Group accessors. |
| 575 | const ContentGroups& groups() const { return content_groups_; } |
| 576 | const ContentGroup* GetGroupByName(const std::string& name) const; |
Henrik Boström | f8187e0 | 2021-04-26 21:04:26 +0200 | [diff] [blame] | 577 | std::vector<const ContentGroup*> GetGroupsByName( |
| 578 | const std::string& name) const; |
Steve Anton | 4ab68ee | 2017-12-19 14:26:11 -0800 | [diff] [blame] | 579 | bool HasGroup(const std::string& name) const; |
| 580 | |
| 581 | // Group mutators. |
| 582 | void AddGroup(const ContentGroup& group) { content_groups_.push_back(group); } |
| 583 | // Remove the first group with the same semantics specified by |name|. |
| 584 | void RemoveGroupByName(const std::string& name); |
| 585 | |
| 586 | // Global attributes. |
| 587 | void set_msid_supported(bool supported) { msid_supported_ = supported; } |
| 588 | bool msid_supported() const { return msid_supported_; } |
| 589 | |
Steve Anton | e831b8c | 2018-02-01 12:22:16 -0800 | [diff] [blame] | 590 | // Determines how the MSIDs were/will be signaled. Flag value composed of |
| 591 | // MsidSignaling bits (see enum above). |
| 592 | void set_msid_signaling(int msid_signaling) { |
| 593 | msid_signaling_ = msid_signaling; |
| 594 | } |
| 595 | int msid_signaling() const { return msid_signaling_; } |
| 596 | |
Johannes Kron | 0854eb6 | 2018-10-10 22:33:20 +0200 | [diff] [blame] | 597 | // Determines if it's allowed to mix one- and two-byte rtp header extensions |
| 598 | // within the same rtp stream. |
Johannes Kron | 9581bc4 | 2018-10-23 10:17:39 +0200 | [diff] [blame] | 599 | void set_extmap_allow_mixed(bool supported) { |
| 600 | extmap_allow_mixed_ = supported; |
| 601 | MediaContentDescription::ExtmapAllowMixed media_level_setting = |
Johannes Kron | 0854eb6 | 2018-10-10 22:33:20 +0200 | [diff] [blame] | 602 | supported ? MediaContentDescription::kSession |
| 603 | : MediaContentDescription::kNo; |
| 604 | for (auto& content : contents_) { |
Johannes Kron | 9ac3c91 | 2018-10-12 10:54:26 +0200 | [diff] [blame] | 605 | // Do not set to kNo if the current setting is kMedia. |
Johannes Kron | 9581bc4 | 2018-10-23 10:17:39 +0200 | [diff] [blame] | 606 | if (supported || content.media_description()->extmap_allow_mixed_enum() != |
| 607 | MediaContentDescription::kMedia) { |
| 608 | content.media_description()->set_extmap_allow_mixed_enum( |
Johannes Kron | 9ac3c91 | 2018-10-12 10:54:26 +0200 | [diff] [blame] | 609 | media_level_setting); |
| 610 | } |
Johannes Kron | 0854eb6 | 2018-10-10 22:33:20 +0200 | [diff] [blame] | 611 | } |
| 612 | } |
Johannes Kron | 9581bc4 | 2018-10-23 10:17:39 +0200 | [diff] [blame] | 613 | bool extmap_allow_mixed() const { return extmap_allow_mixed_; } |
Johannes Kron | 0854eb6 | 2018-10-10 22:33:20 +0200 | [diff] [blame] | 614 | |
Steve Anton | 4ab68ee | 2017-12-19 14:26:11 -0800 | [diff] [blame] | 615 | private: |
| 616 | SessionDescription(const SessionDescription&); |
| 617 | |
| 618 | ContentInfos contents_; |
| 619 | TransportInfos transport_infos_; |
| 620 | ContentGroups content_groups_; |
| 621 | bool msid_supported_ = true; |
Steve Anton | e831b8c | 2018-02-01 12:22:16 -0800 | [diff] [blame] | 622 | // Default to what Plan B would do. |
| 623 | // TODO(bugs.webrtc.org/8530): Change default to kMsidSignalingMediaSection. |
| 624 | int msid_signaling_ = kMsidSignalingSsrcAttribute; |
Emil Lundmark | 801c999 | 2021-01-19 13:06:32 +0100 | [diff] [blame] | 625 | bool extmap_allow_mixed_ = true; |
Steve Anton | 4ab68ee | 2017-12-19 14:26:11 -0800 | [diff] [blame] | 626 | }; |
| 627 | |
Steve Anton | b1c1de1 | 2017-12-21 15:14:30 -0800 | [diff] [blame] | 628 | // Indicates whether a session description was sent by the local client or |
| 629 | // received from the remote client. |
Steve Anton | 4ab68ee | 2017-12-19 14:26:11 -0800 | [diff] [blame] | 630 | enum ContentSource { CS_LOCAL, CS_REMOTE }; |
| 631 | |
| 632 | } // namespace cricket |
| 633 | |
Steve Anton | 10542f2 | 2019-01-11 09:11:00 -0800 | [diff] [blame] | 634 | #endif // PC_SESSION_DESCRIPTION_H_ |