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