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