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