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> |
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 | c24a218 | 2022-02-23 13:44:59 +0000 | [diff] [blame^] | 20 | #include <type_traits> |
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" |
Harald Alvestrand | 0d01841 | 2021-11-04 13:52:31 +0000 | [diff] [blame] | 25 | #include "api/crypto_params.h" |
Steve Anton | 10542f2 | 2019-01-11 09:11:00 -0800 | [diff] [blame] | 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; |
Harald Alvestrand | 0d01841 | 2021-11-04 13:52:31 +0000 | [diff] [blame] | 47 | typedef std::vector<CryptoParams> CryptoParamsVec; |
Steve Anton | afd8e8c | 2017-12-19 16:35:35 -0800 | [diff] [blame] | 48 | typedef std::vector<webrtc::RtpExtension> RtpHeaderExtensions; |
| 49 | |
Steve Anton | afd8e8c | 2017-12-19 16:35:35 -0800 | [diff] [blame] | 50 | // Options to control how session descriptions are generated. |
| 51 | const int kAutoBandwidth = -1; |
| 52 | |
Steve Anton | 5adfafd | 2017-12-20 16:34:00 -0800 | [diff] [blame] | 53 | class AudioContentDescription; |
Steve Anton | 46afbf9 | 2019-05-10 11:15:18 -0700 | [diff] [blame] | 54 | class VideoContentDescription; |
Harald Alvestrand | 5fc28b1 | 2019-05-13 13:36:16 +0200 | [diff] [blame] | 55 | class SctpDataContentDescription; |
Philipp Hancke | 4e8c115 | 2020-10-13 12:43:15 +0200 | [diff] [blame] | 56 | class UnsupportedContentDescription; |
Steve Anton | 4ab68ee | 2017-12-19 14:26:11 -0800 | [diff] [blame] | 57 | |
Steve Anton | 5adfafd | 2017-12-20 16:34:00 -0800 | [diff] [blame] | 58 | // Describes a session description media section. There are subclasses for each |
| 59 | // media type (audio, video, data) that will have additional information. |
| 60 | class MediaContentDescription { |
Steve Anton | afd8e8c | 2017-12-19 16:35:35 -0800 | [diff] [blame] | 61 | public: |
Steve Anton | 5adfafd | 2017-12-20 16:34:00 -0800 | [diff] [blame] | 62 | MediaContentDescription() = default; |
| 63 | virtual ~MediaContentDescription() = default; |
Steve Anton | afd8e8c | 2017-12-19 16:35:35 -0800 | [diff] [blame] | 64 | |
| 65 | virtual MediaType type() const = 0; |
Steve Anton | 5adfafd | 2017-12-20 16:34:00 -0800 | [diff] [blame] | 66 | |
| 67 | // Try to cast this media description to an AudioContentDescription. Returns |
| 68 | // nullptr if the cast fails. |
| 69 | virtual AudioContentDescription* as_audio() { return nullptr; } |
| 70 | virtual const AudioContentDescription* as_audio() const { return nullptr; } |
| 71 | |
| 72 | // Try to cast this media description to a VideoContentDescription. Returns |
| 73 | // nullptr if the cast fails. |
| 74 | virtual VideoContentDescription* as_video() { return nullptr; } |
| 75 | virtual const VideoContentDescription* as_video() const { return nullptr; } |
| 76 | |
Harald Alvestrand | 5fc28b1 | 2019-05-13 13:36:16 +0200 | [diff] [blame] | 77 | virtual SctpDataContentDescription* as_sctp() { return nullptr; } |
| 78 | virtual const SctpDataContentDescription* as_sctp() const { return nullptr; } |
| 79 | |
Philipp Hancke | 4e8c115 | 2020-10-13 12:43:15 +0200 | [diff] [blame] | 80 | virtual UnsupportedContentDescription* as_unsupported() { return nullptr; } |
| 81 | virtual const UnsupportedContentDescription* as_unsupported() const { |
| 82 | return nullptr; |
| 83 | } |
| 84 | |
Steve Anton | afd8e8c | 2017-12-19 16:35:35 -0800 | [diff] [blame] | 85 | virtual bool has_codecs() const = 0; |
| 86 | |
Harald Alvestrand | 0fb07f8 | 2020-02-27 20:21:37 +0100 | [diff] [blame] | 87 | // Copy operator that returns an unique_ptr. |
| 88 | // Not a virtual function. |
| 89 | // If a type-specific variant of Clone() is desired, override it, or |
| 90 | // simply use std::make_unique<typename>(*this) instead of Clone(). |
| 91 | std::unique_ptr<MediaContentDescription> Clone() const { |
| 92 | return absl::WrapUnique(CloneInternal()); |
Harald Alvestrand | 1716d39 | 2019-06-03 20:35:45 +0200 | [diff] [blame] | 93 | } |
Steve Anton | 5adfafd | 2017-12-20 16:34:00 -0800 | [diff] [blame] | 94 | |
Artem Titov | 880fa81 | 2021-07-30 22:30:23 +0200 | [diff] [blame] | 95 | // `protocol` is the expected media transport protocol, such as RTP/AVPF, |
Steve Anton | afd8e8c | 2017-12-19 16:35:35 -0800 | [diff] [blame] | 96 | // RTP/SAVPF or SCTP/DTLS. |
Harald Alvestrand | 5fc28b1 | 2019-05-13 13:36:16 +0200 | [diff] [blame] | 97 | virtual std::string protocol() const { return protocol_; } |
| 98 | virtual void set_protocol(const std::string& protocol) { |
| 99 | protocol_ = protocol; |
| 100 | } |
Steve Anton | afd8e8c | 2017-12-19 16:35:35 -0800 | [diff] [blame] | 101 | |
Harald Alvestrand | 5fc28b1 | 2019-05-13 13:36:16 +0200 | [diff] [blame] | 102 | virtual webrtc::RtpTransceiverDirection direction() const { |
| 103 | return direction_; |
| 104 | } |
| 105 | virtual void set_direction(webrtc::RtpTransceiverDirection direction) { |
Steve Anton | afd8e8c | 2017-12-19 16:35:35 -0800 | [diff] [blame] | 106 | direction_ = direction; |
| 107 | } |
| 108 | |
Harald Alvestrand | 5fc28b1 | 2019-05-13 13:36:16 +0200 | [diff] [blame] | 109 | virtual bool rtcp_mux() const { return rtcp_mux_; } |
| 110 | virtual void set_rtcp_mux(bool mux) { rtcp_mux_ = mux; } |
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 bool rtcp_reduced_size() const { return rtcp_reduced_size_; } |
| 113 | virtual void set_rtcp_reduced_size(bool reduced_size) { |
Steve Anton | afd8e8c | 2017-12-19 16:35:35 -0800 | [diff] [blame] | 114 | rtcp_reduced_size_ = reduced_size; |
| 115 | } |
| 116 | |
Sebastian Jansson | 97321b6 | 2019-07-24 14:01:18 +0200 | [diff] [blame] | 117 | // Indicates support for the remote network estimate packet type. This |
| 118 | // functionality is experimental and subject to change without notice. |
Sebastian Jansson | e1795f4 | 2019-07-24 11:38:03 +0200 | [diff] [blame] | 119 | virtual bool remote_estimate() const { return remote_estimate_; } |
| 120 | virtual void set_remote_estimate(bool remote_estimate) { |
| 121 | remote_estimate_ = remote_estimate; |
| 122 | } |
| 123 | |
Harald Alvestrand | 5fc28b1 | 2019-05-13 13:36:16 +0200 | [diff] [blame] | 124 | virtual int bandwidth() const { return bandwidth_; } |
| 125 | virtual void set_bandwidth(int bandwidth) { bandwidth_ = bandwidth; } |
Taylor Brandstetter | ee8c246 | 2020-07-27 15:52:02 -0700 | [diff] [blame] | 126 | virtual std::string bandwidth_type() const { return bandwidth_type_; } |
| 127 | virtual void set_bandwidth_type(std::string bandwidth_type) { |
| 128 | bandwidth_type_ = bandwidth_type; |
| 129 | } |
Steve Anton | afd8e8c | 2017-12-19 16:35:35 -0800 | [diff] [blame] | 130 | |
Harald Alvestrand | 0d01841 | 2021-11-04 13:52:31 +0000 | [diff] [blame] | 131 | virtual const std::vector<CryptoParams>& cryptos() const { return cryptos_; } |
| 132 | virtual void AddCrypto(const CryptoParams& params) { |
| 133 | cryptos_.push_back(params); |
| 134 | } |
| 135 | virtual void set_cryptos(const std::vector<CryptoParams>& cryptos) { |
| 136 | cryptos_ = cryptos; |
| 137 | } |
| 138 | |
Lennart Grahl | 0d0ed76 | 2021-05-17 16:06:37 +0200 | [diff] [blame] | 139 | // List of RTP header extensions. URIs are **NOT** guaranteed to be unique |
| 140 | // as they can appear twice when both encrypted and non-encrypted extensions |
| 141 | // are present. |
| 142 | // Use RtpExtension::FindHeaderExtensionByUri for finding and |
| 143 | // RtpExtension::DeduplicateHeaderExtensions for filtering. |
Harald Alvestrand | 5fc28b1 | 2019-05-13 13:36:16 +0200 | [diff] [blame] | 144 | virtual const RtpHeaderExtensions& rtp_header_extensions() const { |
Steve Anton | afd8e8c | 2017-12-19 16:35:35 -0800 | [diff] [blame] | 145 | return rtp_header_extensions_; |
| 146 | } |
Harald Alvestrand | 5fc28b1 | 2019-05-13 13:36:16 +0200 | [diff] [blame] | 147 | virtual void set_rtp_header_extensions( |
| 148 | const RtpHeaderExtensions& extensions) { |
Steve Anton | afd8e8c | 2017-12-19 16:35:35 -0800 | [diff] [blame] | 149 | rtp_header_extensions_ = extensions; |
| 150 | rtp_header_extensions_set_ = true; |
| 151 | } |
Harald Alvestrand | 5fc28b1 | 2019-05-13 13:36:16 +0200 | [diff] [blame] | 152 | virtual void AddRtpHeaderExtension(const webrtc::RtpExtension& ext) { |
Steve Anton | afd8e8c | 2017-12-19 16:35:35 -0800 | [diff] [blame] | 153 | rtp_header_extensions_.push_back(ext); |
| 154 | rtp_header_extensions_set_ = true; |
| 155 | } |
Harald Alvestrand | 5fc28b1 | 2019-05-13 13:36:16 +0200 | [diff] [blame] | 156 | virtual void ClearRtpHeaderExtensions() { |
Steve Anton | afd8e8c | 2017-12-19 16:35:35 -0800 | [diff] [blame] | 157 | rtp_header_extensions_.clear(); |
| 158 | rtp_header_extensions_set_ = true; |
| 159 | } |
| 160 | // We can't always tell if an empty list of header extensions is |
| 161 | // because the other side doesn't support them, or just isn't hooked up to |
| 162 | // signal them. For now we assume an empty list means no signaling, but |
| 163 | // provide the ClearRtpHeaderExtensions method to allow "no support" to be |
| 164 | // clearly indicated (i.e. when derived from other information). |
Harald Alvestrand | 5fc28b1 | 2019-05-13 13:36:16 +0200 | [diff] [blame] | 165 | virtual bool rtp_header_extensions_set() const { |
| 166 | return rtp_header_extensions_set_; |
| 167 | } |
| 168 | virtual const StreamParamsVec& streams() const { return send_streams_; } |
Steve Anton | afd8e8c | 2017-12-19 16:35:35 -0800 | [diff] [blame] | 169 | // TODO(pthatcher): Remove this by giving mediamessage.cc access |
| 170 | // to MediaContentDescription |
Harald Alvestrand | 5fc28b1 | 2019-05-13 13:36:16 +0200 | [diff] [blame] | 171 | virtual StreamParamsVec& mutable_streams() { return send_streams_; } |
| 172 | virtual void AddStream(const StreamParams& stream) { |
Amit Hilbuch | c57d573 | 2018-12-11 15:30:11 -0800 | [diff] [blame] | 173 | send_streams_.push_back(stream); |
| 174 | } |
Steve Anton | afd8e8c | 2017-12-19 16:35:35 -0800 | [diff] [blame] | 175 | // Legacy streams have an ssrc, but nothing else. |
| 176 | void AddLegacyStream(uint32_t ssrc) { |
Harald Alvestrand | 5fc28b1 | 2019-05-13 13:36:16 +0200 | [diff] [blame] | 177 | AddStream(StreamParams::CreateLegacy(ssrc)); |
Steve Anton | afd8e8c | 2017-12-19 16:35:35 -0800 | [diff] [blame] | 178 | } |
| 179 | void AddLegacyStream(uint32_t ssrc, uint32_t fid_ssrc) { |
| 180 | StreamParams sp = StreamParams::CreateLegacy(ssrc); |
| 181 | sp.AddFidSsrc(ssrc, fid_ssrc); |
Harald Alvestrand | 5fc28b1 | 2019-05-13 13:36:16 +0200 | [diff] [blame] | 182 | AddStream(sp); |
Steve Anton | afd8e8c | 2017-12-19 16:35:35 -0800 | [diff] [blame] | 183 | } |
Amit Hilbuch | c57d573 | 2018-12-11 15:30:11 -0800 | [diff] [blame] | 184 | |
Steve Anton | afd8e8c | 2017-12-19 16:35:35 -0800 | [diff] [blame] | 185 | // Sets the CNAME of all StreamParams if it have not been set. |
Harald Alvestrand | 5fc28b1 | 2019-05-13 13:36:16 +0200 | [diff] [blame] | 186 | virtual void SetCnameIfEmpty(const std::string& cname) { |
Amit Hilbuch | c57d573 | 2018-12-11 15:30:11 -0800 | [diff] [blame] | 187 | for (cricket::StreamParamsVec::iterator it = send_streams_.begin(); |
| 188 | it != send_streams_.end(); ++it) { |
Steve Anton | afd8e8c | 2017-12-19 16:35:35 -0800 | [diff] [blame] | 189 | if (it->cname.empty()) |
| 190 | it->cname = cname; |
| 191 | } |
| 192 | } |
Harald Alvestrand | 5fc28b1 | 2019-05-13 13:36:16 +0200 | [diff] [blame] | 193 | virtual uint32_t first_ssrc() const { |
Amit Hilbuch | c57d573 | 2018-12-11 15:30:11 -0800 | [diff] [blame] | 194 | if (send_streams_.empty()) { |
Steve Anton | afd8e8c | 2017-12-19 16:35:35 -0800 | [diff] [blame] | 195 | return 0; |
| 196 | } |
Amit Hilbuch | c57d573 | 2018-12-11 15:30:11 -0800 | [diff] [blame] | 197 | return send_streams_[0].first_ssrc(); |
Steve Anton | afd8e8c | 2017-12-19 16:35:35 -0800 | [diff] [blame] | 198 | } |
Harald Alvestrand | 5fc28b1 | 2019-05-13 13:36:16 +0200 | [diff] [blame] | 199 | virtual bool has_ssrcs() const { |
Amit Hilbuch | c57d573 | 2018-12-11 15:30:11 -0800 | [diff] [blame] | 200 | if (send_streams_.empty()) { |
Steve Anton | afd8e8c | 2017-12-19 16:35:35 -0800 | [diff] [blame] | 201 | return false; |
| 202 | } |
Amit Hilbuch | c57d573 | 2018-12-11 15:30:11 -0800 | [diff] [blame] | 203 | return send_streams_[0].has_ssrcs(); |
Steve Anton | afd8e8c | 2017-12-19 16:35:35 -0800 | [diff] [blame] | 204 | } |
| 205 | |
Harald Alvestrand | 5fc28b1 | 2019-05-13 13:36:16 +0200 | [diff] [blame] | 206 | virtual void set_conference_mode(bool enable) { conference_mode_ = enable; } |
| 207 | virtual bool conference_mode() const { return conference_mode_; } |
Steve Anton | afd8e8c | 2017-12-19 16:35:35 -0800 | [diff] [blame] | 208 | |
| 209 | // https://tools.ietf.org/html/rfc4566#section-5.7 |
| 210 | // May be present at the media or session level of SDP. If present at both |
| 211 | // levels, the media-level attribute overwrites the session-level one. |
Harald Alvestrand | 5fc28b1 | 2019-05-13 13:36:16 +0200 | [diff] [blame] | 212 | virtual void set_connection_address(const rtc::SocketAddress& address) { |
Steve Anton | afd8e8c | 2017-12-19 16:35:35 -0800 | [diff] [blame] | 213 | connection_address_ = address; |
| 214 | } |
Harald Alvestrand | 5fc28b1 | 2019-05-13 13:36:16 +0200 | [diff] [blame] | 215 | virtual const rtc::SocketAddress& connection_address() const { |
Steve Anton | afd8e8c | 2017-12-19 16:35:35 -0800 | [diff] [blame] | 216 | return connection_address_; |
| 217 | } |
| 218 | |
Johannes Kron | 0854eb6 | 2018-10-10 22:33:20 +0200 | [diff] [blame] | 219 | // Determines if it's allowed to mix one- and two-byte rtp header extensions |
| 220 | // within the same rtp stream. |
Johannes Kron | 9581bc4 | 2018-10-23 10:17:39 +0200 | [diff] [blame] | 221 | enum ExtmapAllowMixed { kNo, kSession, kMedia }; |
Harald Alvestrand | 5fc28b1 | 2019-05-13 13:36:16 +0200 | [diff] [blame] | 222 | virtual void set_extmap_allow_mixed_enum( |
| 223 | ExtmapAllowMixed new_extmap_allow_mixed) { |
Johannes Kron | 9ac3c91 | 2018-10-12 10:54:26 +0200 | [diff] [blame] | 224 | if (new_extmap_allow_mixed == kMedia && |
Johannes Kron | 9581bc4 | 2018-10-23 10:17:39 +0200 | [diff] [blame] | 225 | extmap_allow_mixed_enum_ == kSession) { |
Johannes Kron | 0854eb6 | 2018-10-10 22:33:20 +0200 | [diff] [blame] | 226 | // Do not downgrade from session level to media level. |
| 227 | return; |
| 228 | } |
Johannes Kron | 9581bc4 | 2018-10-23 10:17:39 +0200 | [diff] [blame] | 229 | extmap_allow_mixed_enum_ = new_extmap_allow_mixed; |
Johannes Kron | 0854eb6 | 2018-10-10 22:33:20 +0200 | [diff] [blame] | 230 | } |
Harald Alvestrand | 5fc28b1 | 2019-05-13 13:36:16 +0200 | [diff] [blame] | 231 | virtual ExtmapAllowMixed extmap_allow_mixed_enum() const { |
Johannes Kron | 9581bc4 | 2018-10-23 10:17:39 +0200 | [diff] [blame] | 232 | return extmap_allow_mixed_enum_; |
Johannes Kron | 9ac3c91 | 2018-10-12 10:54:26 +0200 | [diff] [blame] | 233 | } |
Harald Alvestrand | 5fc28b1 | 2019-05-13 13:36:16 +0200 | [diff] [blame] | 234 | virtual bool extmap_allow_mixed() const { |
| 235 | return extmap_allow_mixed_enum_ != kNo; |
| 236 | } |
Johannes Kron | 0854eb6 | 2018-10-10 22:33:20 +0200 | [diff] [blame] | 237 | |
Amit Hilbuch | a201204 | 2018-12-03 11:35:05 -0800 | [diff] [blame] | 238 | // Simulcast functionality. |
| 239 | virtual bool HasSimulcast() const { return !simulcast_.empty(); } |
| 240 | virtual SimulcastDescription& simulcast_description() { return simulcast_; } |
| 241 | virtual const SimulcastDescription& simulcast_description() const { |
| 242 | return simulcast_; |
| 243 | } |
| 244 | virtual void set_simulcast_description( |
| 245 | const SimulcastDescription& simulcast) { |
| 246 | simulcast_ = simulcast; |
| 247 | } |
Florent Castelli | b60141b | 2019-07-03 12:47:54 +0200 | [diff] [blame] | 248 | virtual const std::vector<RidDescription>& receive_rids() const { |
| 249 | return receive_rids_; |
| 250 | } |
| 251 | virtual void set_receive_rids(const std::vector<RidDescription>& rids) { |
| 252 | receive_rids_ = rids; |
| 253 | } |
Amit Hilbuch | a201204 | 2018-12-03 11:35:05 -0800 | [diff] [blame] | 254 | |
Steve Anton | afd8e8c | 2017-12-19 16:35:35 -0800 | [diff] [blame] | 255 | protected: |
| 256 | bool rtcp_mux_ = false; |
| 257 | bool rtcp_reduced_size_ = false; |
Sebastian Jansson | e1795f4 | 2019-07-24 11:38:03 +0200 | [diff] [blame] | 258 | bool remote_estimate_ = false; |
Steve Anton | afd8e8c | 2017-12-19 16:35:35 -0800 | [diff] [blame] | 259 | int bandwidth_ = kAutoBandwidth; |
Taylor Brandstetter | ee8c246 | 2020-07-27 15:52:02 -0700 | [diff] [blame] | 260 | std::string bandwidth_type_ = kApplicationSpecificBandwidth; |
Steve Anton | afd8e8c | 2017-12-19 16:35:35 -0800 | [diff] [blame] | 261 | std::string protocol_; |
Harald Alvestrand | 0d01841 | 2021-11-04 13:52:31 +0000 | [diff] [blame] | 262 | std::vector<CryptoParams> cryptos_; |
Steve Anton | afd8e8c | 2017-12-19 16:35:35 -0800 | [diff] [blame] | 263 | std::vector<webrtc::RtpExtension> rtp_header_extensions_; |
| 264 | bool rtp_header_extensions_set_ = false; |
Amit Hilbuch | c57d573 | 2018-12-11 15:30:11 -0800 | [diff] [blame] | 265 | StreamParamsVec send_streams_; |
Steve Anton | afd8e8c | 2017-12-19 16:35:35 -0800 | [diff] [blame] | 266 | bool conference_mode_ = false; |
| 267 | webrtc::RtpTransceiverDirection direction_ = |
| 268 | webrtc::RtpTransceiverDirection::kSendRecv; |
| 269 | rtc::SocketAddress connection_address_; |
Emil Lundmark | 801c999 | 2021-01-19 13:06:32 +0100 | [diff] [blame] | 270 | ExtmapAllowMixed extmap_allow_mixed_enum_ = kMedia; |
Amit Hilbuch | a201204 | 2018-12-03 11:35:05 -0800 | [diff] [blame] | 271 | |
| 272 | SimulcastDescription simulcast_; |
Florent Castelli | b60141b | 2019-07-03 12:47:54 +0200 | [diff] [blame] | 273 | std::vector<RidDescription> receive_rids_; |
Bjorn A Mellem | 8e1343a | 2019-09-30 15:12:47 -0700 | [diff] [blame] | 274 | |
Harald Alvestrand | 0fb07f8 | 2020-02-27 20:21:37 +0100 | [diff] [blame] | 275 | private: |
| 276 | // Copy function that returns a raw pointer. Caller will assert ownership. |
| 277 | // Should only be called by the Clone() function. Must be implemented |
| 278 | // by each final subclass. |
| 279 | virtual MediaContentDescription* CloneInternal() const = 0; |
Steve Anton | afd8e8c | 2017-12-19 16:35:35 -0800 | [diff] [blame] | 280 | }; |
| 281 | |
| 282 | template <class C> |
| 283 | class MediaContentDescriptionImpl : public MediaContentDescription { |
| 284 | public: |
Harald Alvestrand | 5fc28b1 | 2019-05-13 13:36:16 +0200 | [diff] [blame] | 285 | void set_protocol(const std::string& protocol) override { |
| 286 | RTC_DCHECK(IsRtpProtocol(protocol)); |
| 287 | protocol_ = protocol; |
| 288 | } |
| 289 | |
Steve Anton | afd8e8c | 2017-12-19 16:35:35 -0800 | [diff] [blame] | 290 | typedef C CodecType; |
| 291 | |
| 292 | // Codecs should be in preference order (most preferred codec first). |
Harald Alvestrand | 5fc28b1 | 2019-05-13 13:36:16 +0200 | [diff] [blame] | 293 | virtual const std::vector<C>& codecs() const { return codecs_; } |
| 294 | virtual void set_codecs(const std::vector<C>& codecs) { codecs_ = codecs; } |
| 295 | bool has_codecs() const override { return !codecs_.empty(); } |
| 296 | virtual bool HasCodec(int id) { |
Steve Anton | afd8e8c | 2017-12-19 16:35:35 -0800 | [diff] [blame] | 297 | bool found = false; |
| 298 | for (typename std::vector<C>::iterator iter = codecs_.begin(); |
| 299 | iter != codecs_.end(); ++iter) { |
| 300 | if (iter->id == id) { |
| 301 | found = true; |
| 302 | break; |
| 303 | } |
| 304 | } |
| 305 | return found; |
| 306 | } |
Harald Alvestrand | 5fc28b1 | 2019-05-13 13:36:16 +0200 | [diff] [blame] | 307 | virtual void AddCodec(const C& codec) { codecs_.push_back(codec); } |
| 308 | virtual void AddOrReplaceCodec(const C& codec) { |
Steve Anton | afd8e8c | 2017-12-19 16:35:35 -0800 | [diff] [blame] | 309 | for (typename std::vector<C>::iterator iter = codecs_.begin(); |
| 310 | iter != codecs_.end(); ++iter) { |
| 311 | if (iter->id == codec.id) { |
| 312 | *iter = codec; |
| 313 | return; |
| 314 | } |
| 315 | } |
| 316 | AddCodec(codec); |
| 317 | } |
Harald Alvestrand | 5fc28b1 | 2019-05-13 13:36:16 +0200 | [diff] [blame] | 318 | virtual void AddCodecs(const std::vector<C>& codecs) { |
Steve Anton | afd8e8c | 2017-12-19 16:35:35 -0800 | [diff] [blame] | 319 | typename std::vector<C>::const_iterator codec; |
| 320 | for (codec = codecs.begin(); codec != codecs.end(); ++codec) { |
| 321 | AddCodec(*codec); |
| 322 | } |
| 323 | } |
| 324 | |
| 325 | private: |
| 326 | std::vector<C> codecs_; |
| 327 | }; |
| 328 | |
| 329 | class AudioContentDescription : public MediaContentDescriptionImpl<AudioCodec> { |
| 330 | public: |
| 331 | AudioContentDescription() {} |
| 332 | |
Steve Anton | afd8e8c | 2017-12-19 16:35:35 -0800 | [diff] [blame] | 333 | virtual MediaType type() const { return MEDIA_TYPE_AUDIO; } |
Steve Anton | 5adfafd | 2017-12-20 16:34:00 -0800 | [diff] [blame] | 334 | virtual AudioContentDescription* as_audio() { return this; } |
| 335 | virtual const AudioContentDescription* as_audio() const { return this; } |
Harald Alvestrand | 0fb07f8 | 2020-02-27 20:21:37 +0100 | [diff] [blame] | 336 | |
| 337 | private: |
| 338 | virtual AudioContentDescription* CloneInternal() const { |
| 339 | return new AudioContentDescription(*this); |
| 340 | } |
Steve Anton | afd8e8c | 2017-12-19 16:35:35 -0800 | [diff] [blame] | 341 | }; |
| 342 | |
| 343 | class VideoContentDescription : public MediaContentDescriptionImpl<VideoCodec> { |
| 344 | public: |
Steve Anton | afd8e8c | 2017-12-19 16:35:35 -0800 | [diff] [blame] | 345 | virtual MediaType type() const { return MEDIA_TYPE_VIDEO; } |
Steve Anton | 5adfafd | 2017-12-20 16:34:00 -0800 | [diff] [blame] | 346 | virtual VideoContentDescription* as_video() { return this; } |
| 347 | virtual const VideoContentDescription* as_video() const { return this; } |
Harald Alvestrand | 0fb07f8 | 2020-02-27 20:21:37 +0100 | [diff] [blame] | 348 | |
| 349 | private: |
| 350 | virtual VideoContentDescription* CloneInternal() const { |
| 351 | return new VideoContentDescription(*this); |
| 352 | } |
Steve Anton | afd8e8c | 2017-12-19 16:35:35 -0800 | [diff] [blame] | 353 | }; |
| 354 | |
Harald Alvestrand | 5fc28b1 | 2019-05-13 13:36:16 +0200 | [diff] [blame] | 355 | class SctpDataContentDescription : public MediaContentDescription { |
| 356 | public: |
| 357 | SctpDataContentDescription() {} |
| 358 | SctpDataContentDescription(const SctpDataContentDescription& o) |
| 359 | : MediaContentDescription(o), |
| 360 | use_sctpmap_(o.use_sctpmap_), |
| 361 | port_(o.port_), |
Harald Alvestrand | c5effc2 | 2019-06-11 11:46:59 +0200 | [diff] [blame] | 362 | max_message_size_(o.max_message_size_) {} |
Harald Alvestrand | 5fc28b1 | 2019-05-13 13:36:16 +0200 | [diff] [blame] | 363 | MediaType type() const override { return MEDIA_TYPE_DATA; } |
| 364 | SctpDataContentDescription* as_sctp() override { return this; } |
| 365 | const SctpDataContentDescription* as_sctp() const override { return this; } |
Harald Alvestrand | 5fc28b1 | 2019-05-13 13:36:16 +0200 | [diff] [blame] | 366 | |
| 367 | bool has_codecs() const override { return false; } |
| 368 | void set_protocol(const std::string& protocol) override { |
| 369 | RTC_DCHECK(IsSctpProtocol(protocol)); |
| 370 | protocol_ = protocol; |
| 371 | } |
Steve Anton | afd8e8c | 2017-12-19 16:35:35 -0800 | [diff] [blame] | 372 | |
| 373 | bool use_sctpmap() const { return use_sctpmap_; } |
| 374 | void set_use_sctpmap(bool enable) { use_sctpmap_ = enable; } |
Harald Alvestrand | 5fc28b1 | 2019-05-13 13:36:16 +0200 | [diff] [blame] | 375 | int port() const { return port_; } |
| 376 | void set_port(int port) { port_ = port; } |
| 377 | int max_message_size() const { return max_message_size_; } |
| 378 | void set_max_message_size(int max_message_size) { |
| 379 | max_message_size_ = max_message_size; |
| 380 | } |
Steve Anton | afd8e8c | 2017-12-19 16:35:35 -0800 | [diff] [blame] | 381 | |
| 382 | private: |
Harald Alvestrand | 0fb07f8 | 2020-02-27 20:21:37 +0100 | [diff] [blame] | 383 | SctpDataContentDescription* CloneInternal() const override { |
| 384 | return new SctpDataContentDescription(*this); |
| 385 | } |
Harald Alvestrand | 5fc28b1 | 2019-05-13 13:36:16 +0200 | [diff] [blame] | 386 | bool use_sctpmap_ = true; // Note: "true" is no longer conformant. |
| 387 | // Defaults should be constants imported from SCTP. Quick hack. |
| 388 | int port_ = 5000; |
Harald Alvestrand | fbb45bd | 2019-05-15 08:07:47 +0200 | [diff] [blame] | 389 | // draft-ietf-mmusic-sdp-sctp-23: Max message size default is 64K |
| 390 | int max_message_size_ = 64 * 1024; |
Steve Anton | afd8e8c | 2017-12-19 16:35:35 -0800 | [diff] [blame] | 391 | }; |
| 392 | |
Philipp Hancke | 4e8c115 | 2020-10-13 12:43:15 +0200 | [diff] [blame] | 393 | class UnsupportedContentDescription : public MediaContentDescription { |
| 394 | public: |
| 395 | explicit UnsupportedContentDescription(const std::string& media_type) |
| 396 | : media_type_(media_type) {} |
| 397 | MediaType type() const override { return MEDIA_TYPE_UNSUPPORTED; } |
| 398 | |
| 399 | UnsupportedContentDescription* as_unsupported() override { return this; } |
| 400 | const UnsupportedContentDescription* as_unsupported() const override { |
| 401 | return this; |
| 402 | } |
| 403 | |
| 404 | bool has_codecs() const override { return false; } |
| 405 | const std::string& media_type() const { return media_type_; } |
| 406 | |
| 407 | private: |
| 408 | UnsupportedContentDescription* CloneInternal() const override { |
| 409 | return new UnsupportedContentDescription(*this); |
| 410 | } |
| 411 | |
| 412 | std::string media_type_; |
| 413 | }; |
| 414 | |
Steve Anton | 5adfafd | 2017-12-20 16:34:00 -0800 | [diff] [blame] | 415 | // Protocol used for encoding media. This is the "top level" protocol that may |
| 416 | // be wrapped by zero or many transport protocols (UDP, ICE, etc.). |
| 417 | enum class MediaProtocolType { |
Philipp Hancke | 4e8c115 | 2020-10-13 12:43:15 +0200 | [diff] [blame] | 418 | kRtp, // Section will use the RTP protocol (e.g., for audio or video). |
| 419 | // https://tools.ietf.org/html/rfc3550 |
| 420 | kSctp, // Section will use the SCTP protocol (e.g., for a data channel). |
| 421 | // https://tools.ietf.org/html/rfc4960 |
| 422 | kOther // Section will use another top protocol which is not |
| 423 | // explicitly supported. |
Steve Anton | 5adfafd | 2017-12-20 16:34:00 -0800 | [diff] [blame] | 424 | }; |
| 425 | |
Steve Anton | 5adfafd | 2017-12-20 16:34:00 -0800 | [diff] [blame] | 426 | // Represents a session description section. Most information about the section |
| 427 | // is stored in the description, which is a subclass of MediaContentDescription. |
Harald Alvestrand | 1716d39 | 2019-06-03 20:35:45 +0200 | [diff] [blame] | 428 | // Owns the description. |
Mirko Bonadei | 35214fc | 2019-09-23 14:54:28 +0200 | [diff] [blame] | 429 | class RTC_EXPORT ContentInfo { |
Harald Alvestrand | 1716d39 | 2019-06-03 20:35:45 +0200 | [diff] [blame] | 430 | public: |
Steve Anton | 5adfafd | 2017-12-20 16:34:00 -0800 | [diff] [blame] | 431 | explicit ContentInfo(MediaProtocolType type) : type(type) {} |
Harald Alvestrand | 1716d39 | 2019-06-03 20:35:45 +0200 | [diff] [blame] | 432 | ~ContentInfo(); |
| 433 | // Copy |
| 434 | ContentInfo(const ContentInfo& o); |
| 435 | ContentInfo& operator=(const ContentInfo& o); |
| 436 | ContentInfo(ContentInfo&& o) = default; |
| 437 | ContentInfo& operator=(ContentInfo&& o) = default; |
Steve Anton | 5adfafd | 2017-12-20 16:34:00 -0800 | [diff] [blame] | 438 | |
Artem Titov | 880fa81 | 2021-07-30 22:30:23 +0200 | [diff] [blame] | 439 | // Alias for `name`. |
Steve Anton | 5adfafd | 2017-12-20 16:34:00 -0800 | [diff] [blame] | 440 | std::string mid() const { return name; } |
| 441 | void set_mid(const std::string& mid) { this->name = mid; } |
| 442 | |
Artem Titov | 880fa81 | 2021-07-30 22:30:23 +0200 | [diff] [blame] | 443 | // Alias for `description`. |
Harald Alvestrand | 1716d39 | 2019-06-03 20:35:45 +0200 | [diff] [blame] | 444 | MediaContentDescription* media_description(); |
| 445 | const MediaContentDescription* media_description() const; |
| 446 | |
| 447 | void set_media_description(std::unique_ptr<MediaContentDescription> desc) { |
| 448 | description_ = std::move(desc); |
Steve Anton | 5adfafd | 2017-12-20 16:34:00 -0800 | [diff] [blame] | 449 | } |
| 450 | |
Steve Anton | 8171211 | 2018-01-05 11:27:54 -0800 | [diff] [blame] | 451 | // TODO(bugs.webrtc.org/8620): Rename this to mid. |
Steve Anton | 4ab68ee | 2017-12-19 14:26:11 -0800 | [diff] [blame] | 452 | std::string name; |
Steve Anton | 5adfafd | 2017-12-20 16:34:00 -0800 | [diff] [blame] | 453 | MediaProtocolType type; |
Steve Anton | 4ab68ee | 2017-12-19 14:26:11 -0800 | [diff] [blame] | 454 | bool rejected = false; |
| 455 | bool bundle_only = false; |
Harald Alvestrand | 1716d39 | 2019-06-03 20:35:45 +0200 | [diff] [blame] | 456 | |
| 457 | private: |
| 458 | friend class SessionDescription; |
| 459 | std::unique_ptr<MediaContentDescription> description_; |
Steve Anton | 4ab68ee | 2017-12-19 14:26:11 -0800 | [diff] [blame] | 460 | }; |
| 461 | |
| 462 | typedef std::vector<std::string> ContentNames; |
| 463 | |
| 464 | // This class provides a mechanism to aggregate different media contents into a |
| 465 | // group. This group can also be shared with the peers in a pre-defined format. |
Artem Titov | 880fa81 | 2021-07-30 22:30:23 +0200 | [diff] [blame] | 466 | // GroupInfo should be populated only with the `content_name` of the |
Steve Anton | 4ab68ee | 2017-12-19 14:26:11 -0800 | [diff] [blame] | 467 | // MediaDescription. |
| 468 | class ContentGroup { |
| 469 | public: |
| 470 | explicit ContentGroup(const std::string& semantics); |
| 471 | ContentGroup(const ContentGroup&); |
| 472 | ContentGroup(ContentGroup&&); |
| 473 | ContentGroup& operator=(const ContentGroup&); |
| 474 | ContentGroup& operator=(ContentGroup&&); |
| 475 | ~ContentGroup(); |
| 476 | |
| 477 | const std::string& semantics() const { return semantics_; } |
| 478 | const ContentNames& content_names() const { return content_names_; } |
| 479 | |
| 480 | const std::string* FirstContentName() const; |
| 481 | bool HasContentName(const std::string& content_name) const; |
| 482 | void AddContentName(const std::string& content_name); |
| 483 | bool RemoveContentName(const std::string& content_name); |
Harald Alvestrand | 7a2db8a | 2021-06-14 15:41:30 +0000 | [diff] [blame] | 484 | // for debugging |
| 485 | std::string ToString() const; |
Steve Anton | 4ab68ee | 2017-12-19 14:26:11 -0800 | [diff] [blame] | 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); } |
Artem Titov | 880fa81 | 2021-07-30 22:30:23 +0200 | [diff] [blame] | 576 | // Remove the first group with the same semantics specified by `name`. |
Steve Anton | 4ab68ee | 2017-12-19 14:26:11 -0800 | [diff] [blame] | 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_ |