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