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