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