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