Steve Anton | 4ab68ee | 2017-12-19 14:26:11 -0800 | [diff] [blame] | 1 | /* |
| 2 | * Copyright 2004 The WebRTC Project Authors. All rights reserved. |
| 3 | * |
| 4 | * Use of this source code is governed by a BSD-style license |
| 5 | * that can be found in the LICENSE file in the root of the source |
| 6 | * tree. An additional intellectual property rights grant can be found |
| 7 | * in the file PATENTS. All contributing project authors may |
| 8 | * be found in the AUTHORS file in the root of the source tree. |
| 9 | */ |
| 10 | |
Steve Anton | 10542f2 | 2019-01-11 09:11:00 -0800 | [diff] [blame] | 11 | #ifndef PC_SESSION_DESCRIPTION_H_ |
| 12 | #define PC_SESSION_DESCRIPTION_H_ |
Steve Anton | 4ab68ee | 2017-12-19 14:26:11 -0800 | [diff] [blame] | 13 | |
Yves Gerey | 3e70781 | 2018-11-28 16:47:49 +0100 | [diff] [blame] | 14 | #include <stddef.h> |
| 15 | #include <stdint.h> |
Jonas Olsson | a4d8737 | 2019-07-05 19:08:33 +0200 | [diff] [blame] | 16 | |
Harald Alvestrand | 5761e7b | 2021-01-29 14:45:08 +0000 | [diff] [blame] | 17 | #include <algorithm> |
Yves Gerey | 3e70781 | 2018-11-28 16:47:49 +0100 | [diff] [blame] | 18 | #include <iosfwd> |
Harald Alvestrand | 4d7160e | 2019-04-12 07:01:29 +0200 | [diff] [blame] | 19 | #include <memory> |
Steve Anton | 4ab68ee | 2017-12-19 14:26:11 -0800 | [diff] [blame] | 20 | #include <string> |
Harald Alvestrand | 1716d39 | 2019-06-03 20:35:45 +0200 | [diff] [blame] | 21 | #include <utility> |
Steve Anton | 4ab68ee | 2017-12-19 14:26:11 -0800 | [diff] [blame] | 22 | #include <vector> |
| 23 | |
Harald Alvestrand | 5fc28b1 | 2019-05-13 13:36:16 +0200 | [diff] [blame] | 24 | #include "absl/memory/memory.h" |
Steve Anton | 10542f2 | 2019-01-11 09:11:00 -0800 | [diff] [blame] | 25 | #include "api/media_types.h" |
| 26 | #include "api/rtp_parameters.h" |
Harald Alvestrand | 5761e7b | 2021-01-29 14:45:08 +0000 | [diff] [blame] | 27 | #include "api/rtp_transceiver_direction.h" |
Steve Anton | 10542f2 | 2019-01-11 09:11:00 -0800 | [diff] [blame] | 28 | #include "api/rtp_transceiver_interface.h" |
Harald Alvestrand | 5761e7b | 2021-01-29 14:45:08 +0000 | [diff] [blame] | 29 | #include "media/base/codec.h" |
Steve Anton | 10542f2 | 2019-01-11 09:11:00 -0800 | [diff] [blame] | 30 | #include "media/base/media_channel.h" |
Taylor Brandstetter | ee8c246 | 2020-07-27 15:52:02 -0700 | [diff] [blame] | 31 | #include "media/base/media_constants.h" |
Harald Alvestrand | 5761e7b | 2021-01-29 14:45:08 +0000 | [diff] [blame] | 32 | #include "media/base/rid_description.h" |
Steve Anton | 10542f2 | 2019-01-11 09:11:00 -0800 | [diff] [blame] | 33 | #include "media/base/stream_params.h" |
| 34 | #include "p2p/base/transport_description.h" |
| 35 | #include "p2p/base/transport_info.h" |
Harald Alvestrand | 5fc28b1 | 2019-05-13 13:36:16 +0200 | [diff] [blame] | 36 | #include "pc/media_protocol_names.h" |
Steve Anton | 10542f2 | 2019-01-11 09:11:00 -0800 | [diff] [blame] | 37 | #include "pc/simulcast_description.h" |
Harald Alvestrand | 5761e7b | 2021-01-29 14:45:08 +0000 | [diff] [blame] | 38 | #include "rtc_base/checks.h" |
Steve Anton | 10542f2 | 2019-01-11 09:11:00 -0800 | [diff] [blame] | 39 | #include "rtc_base/socket_address.h" |
Mirko Bonadei | 35214fc | 2019-09-23 14:54:28 +0200 | [diff] [blame] | 40 | #include "rtc_base/system/rtc_export.h" |
Steve Anton | 4ab68ee | 2017-12-19 14:26:11 -0800 | [diff] [blame] | 41 | |
| 42 | namespace cricket { |
| 43 | |
Steve Anton | afd8e8c | 2017-12-19 16:35:35 -0800 | [diff] [blame] | 44 | typedef std::vector<AudioCodec> AudioCodecs; |
| 45 | typedef std::vector<VideoCodec> VideoCodecs; |
Steve Anton | afd8e8c | 2017-12-19 16:35:35 -0800 | [diff] [blame] | 46 | typedef std::vector<webrtc::RtpExtension> RtpHeaderExtensions; |
| 47 | |
Steve Anton | afd8e8c | 2017-12-19 16:35:35 -0800 | [diff] [blame] | 48 | // Options to control how session descriptions are generated. |
| 49 | const int kAutoBandwidth = -1; |
| 50 | |
Steve Anton | 5adfafd | 2017-12-20 16:34:00 -0800 | [diff] [blame] | 51 | class AudioContentDescription; |
Steve Anton | 46afbf9 | 2019-05-10 11:15:18 -0700 | [diff] [blame] | 52 | class VideoContentDescription; |
Harald Alvestrand | 5fc28b1 | 2019-05-13 13:36:16 +0200 | [diff] [blame] | 53 | class SctpDataContentDescription; |
Philipp Hancke | 4e8c115 | 2020-10-13 12:43:15 +0200 | [diff] [blame] | 54 | class UnsupportedContentDescription; |
Steve Anton | 4ab68ee | 2017-12-19 14:26:11 -0800 | [diff] [blame] | 55 | |
Steve Anton | 5adfafd | 2017-12-20 16:34:00 -0800 | [diff] [blame] | 56 | // Describes a session description media section. There are subclasses for each |
| 57 | // media type (audio, video, data) that will have additional information. |
| 58 | class MediaContentDescription { |
Steve Anton | afd8e8c | 2017-12-19 16:35:35 -0800 | [diff] [blame] | 59 | public: |
Steve Anton | 5adfafd | 2017-12-20 16:34:00 -0800 | [diff] [blame] | 60 | MediaContentDescription() = default; |
| 61 | virtual ~MediaContentDescription() = default; |
Steve Anton | afd8e8c | 2017-12-19 16:35:35 -0800 | [diff] [blame] | 62 | |
| 63 | virtual MediaType type() const = 0; |
Steve Anton | 5adfafd | 2017-12-20 16:34:00 -0800 | [diff] [blame] | 64 | |
| 65 | // Try to cast this media description to an AudioContentDescription. Returns |
| 66 | // nullptr if the cast fails. |
| 67 | virtual AudioContentDescription* as_audio() { return nullptr; } |
| 68 | virtual const AudioContentDescription* as_audio() const { return nullptr; } |
| 69 | |
| 70 | // Try to cast this media description to a VideoContentDescription. Returns |
| 71 | // nullptr if the cast fails. |
| 72 | virtual VideoContentDescription* as_video() { return nullptr; } |
| 73 | virtual const VideoContentDescription* as_video() const { return nullptr; } |
| 74 | |
Harald Alvestrand | 5fc28b1 | 2019-05-13 13:36:16 +0200 | [diff] [blame] | 75 | virtual SctpDataContentDescription* as_sctp() { return nullptr; } |
| 76 | virtual const SctpDataContentDescription* as_sctp() const { return nullptr; } |
| 77 | |
Philipp Hancke | 4e8c115 | 2020-10-13 12:43:15 +0200 | [diff] [blame] | 78 | virtual UnsupportedContentDescription* as_unsupported() { return nullptr; } |
| 79 | virtual const UnsupportedContentDescription* as_unsupported() const { |
| 80 | return nullptr; |
| 81 | } |
| 82 | |
Steve Anton | afd8e8c | 2017-12-19 16:35:35 -0800 | [diff] [blame] | 83 | virtual bool has_codecs() const = 0; |
| 84 | |
Harald Alvestrand | 0fb07f8 | 2020-02-27 20:21:37 +0100 | [diff] [blame] | 85 | // Copy operator that returns an unique_ptr. |
| 86 | // Not a virtual function. |
| 87 | // If a type-specific variant of Clone() is desired, override it, or |
| 88 | // simply use std::make_unique<typename>(*this) instead of Clone(). |
| 89 | std::unique_ptr<MediaContentDescription> Clone() const { |
| 90 | return absl::WrapUnique(CloneInternal()); |
Harald Alvestrand | 1716d39 | 2019-06-03 20:35:45 +0200 | [diff] [blame] | 91 | } |
Steve Anton | 5adfafd | 2017-12-20 16:34:00 -0800 | [diff] [blame] | 92 | |
Artem Titov | 880fa81 | 2021-07-30 22:30:23 +0200 | [diff] [blame] | 93 | // `protocol` is the expected media transport protocol, such as RTP/AVPF, |
Steve Anton | afd8e8c | 2017-12-19 16:35:35 -0800 | [diff] [blame] | 94 | // RTP/SAVPF or SCTP/DTLS. |
Harald Alvestrand | 5fc28b1 | 2019-05-13 13:36:16 +0200 | [diff] [blame] | 95 | virtual std::string protocol() const { return protocol_; } |
| 96 | virtual void set_protocol(const std::string& protocol) { |
| 97 | protocol_ = protocol; |
| 98 | } |
Steve Anton | afd8e8c | 2017-12-19 16:35:35 -0800 | [diff] [blame] | 99 | |
Harald Alvestrand | 5fc28b1 | 2019-05-13 13:36:16 +0200 | [diff] [blame] | 100 | virtual webrtc::RtpTransceiverDirection direction() const { |
| 101 | return direction_; |
| 102 | } |
| 103 | virtual void set_direction(webrtc::RtpTransceiverDirection direction) { |
Steve Anton | afd8e8c | 2017-12-19 16:35:35 -0800 | [diff] [blame] | 104 | direction_ = direction; |
| 105 | } |
| 106 | |
Harald Alvestrand | 5fc28b1 | 2019-05-13 13:36:16 +0200 | [diff] [blame] | 107 | virtual bool rtcp_mux() const { return rtcp_mux_; } |
| 108 | virtual void set_rtcp_mux(bool mux) { rtcp_mux_ = mux; } |
Steve Anton | afd8e8c | 2017-12-19 16:35:35 -0800 | [diff] [blame] | 109 | |
Harald Alvestrand | 5fc28b1 | 2019-05-13 13:36:16 +0200 | [diff] [blame] | 110 | virtual bool rtcp_reduced_size() const { return rtcp_reduced_size_; } |
| 111 | virtual void set_rtcp_reduced_size(bool reduced_size) { |
Steve Anton | afd8e8c | 2017-12-19 16:35:35 -0800 | [diff] [blame] | 112 | rtcp_reduced_size_ = reduced_size; |
| 113 | } |
| 114 | |
Sebastian Jansson | 97321b6 | 2019-07-24 14:01:18 +0200 | [diff] [blame] | 115 | // Indicates support for the remote network estimate packet type. This |
| 116 | // functionality is experimental and subject to change without notice. |
Sebastian Jansson | e1795f4 | 2019-07-24 11:38:03 +0200 | [diff] [blame] | 117 | virtual bool remote_estimate() const { return remote_estimate_; } |
| 118 | virtual void set_remote_estimate(bool remote_estimate) { |
| 119 | remote_estimate_ = remote_estimate; |
| 120 | } |
| 121 | |
Harald Alvestrand | 5fc28b1 | 2019-05-13 13:36:16 +0200 | [diff] [blame] | 122 | virtual int bandwidth() const { return bandwidth_; } |
| 123 | virtual void set_bandwidth(int bandwidth) { bandwidth_ = bandwidth; } |
Taylor Brandstetter | ee8c246 | 2020-07-27 15:52:02 -0700 | [diff] [blame] | 124 | virtual std::string bandwidth_type() const { return bandwidth_type_; } |
| 125 | virtual void set_bandwidth_type(std::string bandwidth_type) { |
| 126 | bandwidth_type_ = bandwidth_type; |
| 127 | } |
Steve Anton | afd8e8c | 2017-12-19 16:35:35 -0800 | [diff] [blame] | 128 | |
Lennart Grahl | 0d0ed76 | 2021-05-17 16:06:37 +0200 | [diff] [blame] | 129 | // List of RTP header extensions. URIs are **NOT** guaranteed to be unique |
| 130 | // as they can appear twice when both encrypted and non-encrypted extensions |
| 131 | // are present. |
| 132 | // Use RtpExtension::FindHeaderExtensionByUri for finding and |
| 133 | // RtpExtension::DeduplicateHeaderExtensions for filtering. |
Harald Alvestrand | 5fc28b1 | 2019-05-13 13:36:16 +0200 | [diff] [blame] | 134 | virtual const RtpHeaderExtensions& rtp_header_extensions() const { |
Steve Anton | afd8e8c | 2017-12-19 16:35:35 -0800 | [diff] [blame] | 135 | return rtp_header_extensions_; |
| 136 | } |
Harald Alvestrand | 5fc28b1 | 2019-05-13 13:36:16 +0200 | [diff] [blame] | 137 | virtual void set_rtp_header_extensions( |
| 138 | const RtpHeaderExtensions& extensions) { |
Steve Anton | afd8e8c | 2017-12-19 16:35:35 -0800 | [diff] [blame] | 139 | rtp_header_extensions_ = extensions; |
| 140 | rtp_header_extensions_set_ = true; |
| 141 | } |
Harald Alvestrand | 5fc28b1 | 2019-05-13 13:36:16 +0200 | [diff] [blame] | 142 | virtual void AddRtpHeaderExtension(const webrtc::RtpExtension& ext) { |
Steve Anton | afd8e8c | 2017-12-19 16:35:35 -0800 | [diff] [blame] | 143 | rtp_header_extensions_.push_back(ext); |
| 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; |
Sebastian Jansson | e1795f4 | 2019-07-24 11:38:03 +0200 | [diff] [blame] | 248 | bool remote_estimate_ = false; |
Steve Anton | afd8e8c | 2017-12-19 16:35:35 -0800 | [diff] [blame] | 249 | int bandwidth_ = kAutoBandwidth; |
Taylor Brandstetter | ee8c246 | 2020-07-27 15:52:02 -0700 | [diff] [blame] | 250 | std::string bandwidth_type_ = kApplicationSpecificBandwidth; |
Steve Anton | afd8e8c | 2017-12-19 16:35:35 -0800 | [diff] [blame] | 251 | std::string protocol_; |
Steve Anton | afd8e8c | 2017-12-19 16:35:35 -0800 | [diff] [blame] | 252 | std::vector<webrtc::RtpExtension> rtp_header_extensions_; |
| 253 | bool rtp_header_extensions_set_ = false; |
Amit Hilbuch | c57d573 | 2018-12-11 15:30:11 -0800 | [diff] [blame] | 254 | StreamParamsVec send_streams_; |
Steve Anton | afd8e8c | 2017-12-19 16:35:35 -0800 | [diff] [blame] | 255 | bool conference_mode_ = false; |
| 256 | webrtc::RtpTransceiverDirection direction_ = |
| 257 | webrtc::RtpTransceiverDirection::kSendRecv; |
| 258 | rtc::SocketAddress connection_address_; |
Emil Lundmark | 801c999 | 2021-01-19 13:06:32 +0100 | [diff] [blame] | 259 | ExtmapAllowMixed extmap_allow_mixed_enum_ = kMedia; |
Amit Hilbuch | a201204 | 2018-12-03 11:35:05 -0800 | [diff] [blame] | 260 | |
| 261 | SimulcastDescription simulcast_; |
Florent Castelli | b60141b | 2019-07-03 12:47:54 +0200 | [diff] [blame] | 262 | std::vector<RidDescription> receive_rids_; |
Bjorn A Mellem | 8e1343a | 2019-09-30 15:12:47 -0700 | [diff] [blame] | 263 | |
Harald Alvestrand | 0fb07f8 | 2020-02-27 20:21:37 +0100 | [diff] [blame] | 264 | private: |
| 265 | // Copy function that returns a raw pointer. Caller will assert ownership. |
| 266 | // Should only be called by the Clone() function. Must be implemented |
| 267 | // by each final subclass. |
| 268 | virtual MediaContentDescription* CloneInternal() const = 0; |
Steve Anton | afd8e8c | 2017-12-19 16:35:35 -0800 | [diff] [blame] | 269 | }; |
| 270 | |
| 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 | afd8e8c | 2017-12-19 16:35:35 -0800 | [diff] [blame] | 322 | virtual MediaType type() const { return MEDIA_TYPE_AUDIO; } |
Steve Anton | 5adfafd | 2017-12-20 16:34:00 -0800 | [diff] [blame] | 323 | virtual AudioContentDescription* as_audio() { return this; } |
| 324 | virtual const AudioContentDescription* as_audio() const { return this; } |
Harald Alvestrand | 0fb07f8 | 2020-02-27 20:21:37 +0100 | [diff] [blame] | 325 | |
| 326 | private: |
| 327 | virtual AudioContentDescription* CloneInternal() const { |
| 328 | return new AudioContentDescription(*this); |
| 329 | } |
Steve Anton | afd8e8c | 2017-12-19 16:35:35 -0800 | [diff] [blame] | 330 | }; |
| 331 | |
| 332 | class VideoContentDescription : public MediaContentDescriptionImpl<VideoCodec> { |
| 333 | public: |
Steve Anton | afd8e8c | 2017-12-19 16:35:35 -0800 | [diff] [blame] | 334 | virtual MediaType type() const { return MEDIA_TYPE_VIDEO; } |
Steve Anton | 5adfafd | 2017-12-20 16:34:00 -0800 | [diff] [blame] | 335 | virtual VideoContentDescription* as_video() { return this; } |
| 336 | virtual const VideoContentDescription* as_video() const { return this; } |
Harald Alvestrand | 0fb07f8 | 2020-02-27 20:21:37 +0100 | [diff] [blame] | 337 | |
| 338 | private: |
| 339 | virtual VideoContentDescription* CloneInternal() const { |
| 340 | return new VideoContentDescription(*this); |
| 341 | } |
Steve Anton | afd8e8c | 2017-12-19 16:35:35 -0800 | [diff] [blame] | 342 | }; |
| 343 | |
Harald Alvestrand | 5fc28b1 | 2019-05-13 13:36:16 +0200 | [diff] [blame] | 344 | class SctpDataContentDescription : public MediaContentDescription { |
| 345 | public: |
| 346 | SctpDataContentDescription() {} |
| 347 | SctpDataContentDescription(const SctpDataContentDescription& o) |
| 348 | : MediaContentDescription(o), |
| 349 | use_sctpmap_(o.use_sctpmap_), |
| 350 | port_(o.port_), |
Harald Alvestrand | c5effc2 | 2019-06-11 11:46:59 +0200 | [diff] [blame] | 351 | max_message_size_(o.max_message_size_) {} |
Harald Alvestrand | 5fc28b1 | 2019-05-13 13:36:16 +0200 | [diff] [blame] | 352 | MediaType type() const override { return MEDIA_TYPE_DATA; } |
| 353 | SctpDataContentDescription* as_sctp() override { return this; } |
| 354 | const SctpDataContentDescription* as_sctp() const override { return this; } |
Harald Alvestrand | 5fc28b1 | 2019-05-13 13:36:16 +0200 | [diff] [blame] | 355 | |
| 356 | bool has_codecs() const override { return false; } |
| 357 | void set_protocol(const std::string& protocol) override { |
| 358 | RTC_DCHECK(IsSctpProtocol(protocol)); |
| 359 | protocol_ = protocol; |
| 360 | } |
Steve Anton | afd8e8c | 2017-12-19 16:35:35 -0800 | [diff] [blame] | 361 | |
| 362 | bool use_sctpmap() const { return use_sctpmap_; } |
| 363 | void set_use_sctpmap(bool enable) { use_sctpmap_ = enable; } |
Harald Alvestrand | 5fc28b1 | 2019-05-13 13:36:16 +0200 | [diff] [blame] | 364 | int port() const { return port_; } |
| 365 | void set_port(int port) { port_ = port; } |
| 366 | int max_message_size() const { return max_message_size_; } |
| 367 | void set_max_message_size(int max_message_size) { |
| 368 | max_message_size_ = max_message_size; |
| 369 | } |
Steve Anton | afd8e8c | 2017-12-19 16:35:35 -0800 | [diff] [blame] | 370 | |
| 371 | private: |
Harald Alvestrand | 0fb07f8 | 2020-02-27 20:21:37 +0100 | [diff] [blame] | 372 | SctpDataContentDescription* CloneInternal() const override { |
| 373 | return new SctpDataContentDescription(*this); |
| 374 | } |
Harald Alvestrand | 5fc28b1 | 2019-05-13 13:36:16 +0200 | [diff] [blame] | 375 | bool use_sctpmap_ = true; // Note: "true" is no longer conformant. |
| 376 | // Defaults should be constants imported from SCTP. Quick hack. |
| 377 | int port_ = 5000; |
Harald Alvestrand | fbb45bd | 2019-05-15 08:07:47 +0200 | [diff] [blame] | 378 | // draft-ietf-mmusic-sdp-sctp-23: Max message size default is 64K |
| 379 | int max_message_size_ = 64 * 1024; |
Steve Anton | afd8e8c | 2017-12-19 16:35:35 -0800 | [diff] [blame] | 380 | }; |
| 381 | |
Philipp Hancke | 4e8c115 | 2020-10-13 12:43:15 +0200 | [diff] [blame] | 382 | class UnsupportedContentDescription : public MediaContentDescription { |
| 383 | public: |
| 384 | explicit UnsupportedContentDescription(const std::string& media_type) |
| 385 | : media_type_(media_type) {} |
| 386 | MediaType type() const override { return MEDIA_TYPE_UNSUPPORTED; } |
| 387 | |
| 388 | UnsupportedContentDescription* as_unsupported() override { return this; } |
| 389 | const UnsupportedContentDescription* as_unsupported() const override { |
| 390 | return this; |
| 391 | } |
| 392 | |
| 393 | bool has_codecs() const override { return false; } |
| 394 | const std::string& media_type() const { return media_type_; } |
| 395 | |
| 396 | private: |
| 397 | UnsupportedContentDescription* CloneInternal() const override { |
| 398 | return new UnsupportedContentDescription(*this); |
| 399 | } |
| 400 | |
| 401 | std::string media_type_; |
| 402 | }; |
| 403 | |
Steve Anton | 5adfafd | 2017-12-20 16:34:00 -0800 | [diff] [blame] | 404 | // Protocol used for encoding media. This is the "top level" protocol that may |
| 405 | // be wrapped by zero or many transport protocols (UDP, ICE, etc.). |
| 406 | enum class MediaProtocolType { |
Philipp Hancke | 4e8c115 | 2020-10-13 12:43:15 +0200 | [diff] [blame] | 407 | kRtp, // Section will use the RTP protocol (e.g., for audio or video). |
| 408 | // https://tools.ietf.org/html/rfc3550 |
| 409 | kSctp, // Section will use the SCTP protocol (e.g., for a data channel). |
| 410 | // https://tools.ietf.org/html/rfc4960 |
| 411 | kOther // Section will use another top protocol which is not |
| 412 | // explicitly supported. |
Steve Anton | 5adfafd | 2017-12-20 16:34:00 -0800 | [diff] [blame] | 413 | }; |
| 414 | |
Steve Anton | 5adfafd | 2017-12-20 16:34:00 -0800 | [diff] [blame] | 415 | // Represents a session description section. Most information about the section |
| 416 | // is stored in the description, which is a subclass of MediaContentDescription. |
Harald Alvestrand | 1716d39 | 2019-06-03 20:35:45 +0200 | [diff] [blame] | 417 | // Owns the description. |
Mirko Bonadei | 35214fc | 2019-09-23 14:54:28 +0200 | [diff] [blame] | 418 | class RTC_EXPORT ContentInfo { |
Harald Alvestrand | 1716d39 | 2019-06-03 20:35:45 +0200 | [diff] [blame] | 419 | public: |
Steve Anton | 5adfafd | 2017-12-20 16:34:00 -0800 | [diff] [blame] | 420 | explicit ContentInfo(MediaProtocolType type) : type(type) {} |
Harald Alvestrand | 1716d39 | 2019-06-03 20:35:45 +0200 | [diff] [blame] | 421 | ~ContentInfo(); |
| 422 | // Copy |
| 423 | ContentInfo(const ContentInfo& o); |
| 424 | ContentInfo& operator=(const ContentInfo& o); |
| 425 | ContentInfo(ContentInfo&& o) = default; |
| 426 | ContentInfo& operator=(ContentInfo&& o) = default; |
Steve Anton | 5adfafd | 2017-12-20 16:34:00 -0800 | [diff] [blame] | 427 | |
Artem Titov | 880fa81 | 2021-07-30 22:30:23 +0200 | [diff] [blame] | 428 | // Alias for `name`. |
Steve Anton | 5adfafd | 2017-12-20 16:34:00 -0800 | [diff] [blame] | 429 | std::string mid() const { return name; } |
| 430 | void set_mid(const std::string& mid) { this->name = mid; } |
| 431 | |
Artem Titov | 880fa81 | 2021-07-30 22:30:23 +0200 | [diff] [blame] | 432 | // Alias for `description`. |
Harald Alvestrand | 1716d39 | 2019-06-03 20:35:45 +0200 | [diff] [blame] | 433 | MediaContentDescription* media_description(); |
| 434 | const MediaContentDescription* media_description() const; |
| 435 | |
| 436 | void set_media_description(std::unique_ptr<MediaContentDescription> desc) { |
| 437 | description_ = std::move(desc); |
Steve Anton | 5adfafd | 2017-12-20 16:34:00 -0800 | [diff] [blame] | 438 | } |
| 439 | |
Steve Anton | 8171211 | 2018-01-05 11:27:54 -0800 | [diff] [blame] | 440 | // TODO(bugs.webrtc.org/8620): Rename this to mid. |
Steve Anton | 4ab68ee | 2017-12-19 14:26:11 -0800 | [diff] [blame] | 441 | std::string name; |
Steve Anton | 5adfafd | 2017-12-20 16:34:00 -0800 | [diff] [blame] | 442 | MediaProtocolType type; |
Steve Anton | 4ab68ee | 2017-12-19 14:26:11 -0800 | [diff] [blame] | 443 | bool rejected = false; |
| 444 | bool bundle_only = false; |
Harald Alvestrand | 1716d39 | 2019-06-03 20:35:45 +0200 | [diff] [blame] | 445 | |
| 446 | private: |
| 447 | friend class SessionDescription; |
| 448 | std::unique_ptr<MediaContentDescription> description_; |
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. |
Artem Titov | 880fa81 | 2021-07-30 22:30:23 +0200 | [diff] [blame] | 455 | // GroupInfo should be populated only with the `content_name` of the |
Steve Anton | 4ab68ee | 2017-12-19 14:26:11 -0800 | [diff] [blame] | 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); |
Harald Alvestrand | 7a2db8a | 2021-06-14 15:41:30 +0000 | [diff] [blame] | 473 | // for debugging |
| 474 | std::string ToString() const; |
Steve Anton | 4ab68ee | 2017-12-19 14:26:11 -0800 | [diff] [blame] | 475 | |
| 476 | private: |
| 477 | std::string semantics_; |
| 478 | ContentNames content_names_; |
| 479 | }; |
| 480 | |
| 481 | typedef std::vector<ContentInfo> ContentInfos; |
| 482 | typedef std::vector<ContentGroup> ContentGroups; |
| 483 | |
| 484 | const ContentInfo* FindContentInfoByName(const ContentInfos& contents, |
| 485 | const std::string& name); |
| 486 | const ContentInfo* FindContentInfoByType(const ContentInfos& contents, |
| 487 | const std::string& type); |
| 488 | |
Steve Anton | e831b8c | 2018-02-01 12:22:16 -0800 | [diff] [blame] | 489 | // Determines how the MSID will be signaled in the SDP. These can be used as |
| 490 | // flags to indicate both or none. |
| 491 | enum MsidSignaling { |
| 492 | // Signal MSID with one a=msid line in the media section. |
| 493 | kMsidSignalingMediaSection = 0x1, |
| 494 | // Signal MSID with a=ssrc: msid lines in the media section. |
| 495 | kMsidSignalingSsrcAttribute = 0x2 |
| 496 | }; |
| 497 | |
Steve Anton | 4ab68ee | 2017-12-19 14:26:11 -0800 | [diff] [blame] | 498 | // Describes a collection of contents, each with its own name and |
| 499 | // type. Analogous to a <jingle> or <session> stanza. Assumes that |
| 500 | // contents are unique be name, but doesn't enforce that. |
| 501 | class SessionDescription { |
| 502 | public: |
| 503 | SessionDescription(); |
Steve Anton | 4ab68ee | 2017-12-19 14:26:11 -0800 | [diff] [blame] | 504 | ~SessionDescription(); |
| 505 | |
Harald Alvestrand | 4d7160e | 2019-04-12 07:01:29 +0200 | [diff] [blame] | 506 | std::unique_ptr<SessionDescription> Clone() const; |
Steve Anton | 4ab68ee | 2017-12-19 14:26:11 -0800 | [diff] [blame] | 507 | |
| 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); |
Johannes Kron | 9ac3c91 | 2018-10-12 10:54:26 +0200 | [diff] [blame] | 534 | |
Steve Anton | 4ab68ee | 2017-12-19 14:26:11 -0800 | [diff] [blame] | 535 | bool RemoveContentByName(const std::string& name); |
| 536 | |
| 537 | // Transport accessors. |
| 538 | const TransportInfos& transport_infos() const { return transport_infos_; } |
| 539 | TransportInfos& transport_infos() { return transport_infos_; } |
| 540 | const TransportInfo* GetTransportInfoByName(const std::string& name) const; |
| 541 | TransportInfo* GetTransportInfoByName(const std::string& name); |
| 542 | const TransportDescription* GetTransportDescriptionByName( |
| 543 | const std::string& name) const { |
| 544 | const TransportInfo* tinfo = GetTransportInfoByName(name); |
| 545 | return tinfo ? &tinfo->description : NULL; |
| 546 | } |
| 547 | |
| 548 | // Transport mutators. |
| 549 | void set_transport_infos(const TransportInfos& transport_infos) { |
| 550 | transport_infos_ = transport_infos; |
| 551 | } |
| 552 | // Adds a TransportInfo to this description. |
Steve Anton | 06817cd | 2018-12-18 15:55:30 -0800 | [diff] [blame] | 553 | void AddTransportInfo(const TransportInfo& transport_info); |
Steve Anton | 4ab68ee | 2017-12-19 14:26:11 -0800 | [diff] [blame] | 554 | bool RemoveTransportInfoByName(const std::string& name); |
| 555 | |
| 556 | // Group accessors. |
| 557 | const ContentGroups& groups() const { return content_groups_; } |
| 558 | const ContentGroup* GetGroupByName(const std::string& name) const; |
Henrik Boström | f8187e0 | 2021-04-26 21:04:26 +0200 | [diff] [blame] | 559 | std::vector<const ContentGroup*> GetGroupsByName( |
| 560 | const std::string& name) const; |
Steve Anton | 4ab68ee | 2017-12-19 14:26:11 -0800 | [diff] [blame] | 561 | bool HasGroup(const std::string& name) const; |
| 562 | |
| 563 | // Group mutators. |
| 564 | void AddGroup(const ContentGroup& group) { content_groups_.push_back(group); } |
Artem Titov | 880fa81 | 2021-07-30 22:30:23 +0200 | [diff] [blame] | 565 | // Remove the first group with the same semantics specified by `name`. |
Steve Anton | 4ab68ee | 2017-12-19 14:26:11 -0800 | [diff] [blame] | 566 | void RemoveGroupByName(const std::string& name); |
| 567 | |
| 568 | // Global attributes. |
| 569 | void set_msid_supported(bool supported) { msid_supported_ = supported; } |
| 570 | bool msid_supported() const { return msid_supported_; } |
| 571 | |
Steve Anton | e831b8c | 2018-02-01 12:22:16 -0800 | [diff] [blame] | 572 | // Determines how the MSIDs were/will be signaled. Flag value composed of |
| 573 | // MsidSignaling bits (see enum above). |
| 574 | void set_msid_signaling(int msid_signaling) { |
| 575 | msid_signaling_ = msid_signaling; |
| 576 | } |
| 577 | int msid_signaling() const { return msid_signaling_; } |
| 578 | |
Johannes Kron | 0854eb6 | 2018-10-10 22:33:20 +0200 | [diff] [blame] | 579 | // Determines if it's allowed to mix one- and two-byte rtp header extensions |
| 580 | // within the same rtp stream. |
Johannes Kron | 9581bc4 | 2018-10-23 10:17:39 +0200 | [diff] [blame] | 581 | void set_extmap_allow_mixed(bool supported) { |
| 582 | extmap_allow_mixed_ = supported; |
| 583 | MediaContentDescription::ExtmapAllowMixed media_level_setting = |
Johannes Kron | 0854eb6 | 2018-10-10 22:33:20 +0200 | [diff] [blame] | 584 | supported ? MediaContentDescription::kSession |
| 585 | : MediaContentDescription::kNo; |
| 586 | for (auto& content : contents_) { |
Johannes Kron | 9ac3c91 | 2018-10-12 10:54:26 +0200 | [diff] [blame] | 587 | // Do not set to kNo if the current setting is kMedia. |
Johannes Kron | 9581bc4 | 2018-10-23 10:17:39 +0200 | [diff] [blame] | 588 | if (supported || content.media_description()->extmap_allow_mixed_enum() != |
| 589 | MediaContentDescription::kMedia) { |
| 590 | content.media_description()->set_extmap_allow_mixed_enum( |
Johannes Kron | 9ac3c91 | 2018-10-12 10:54:26 +0200 | [diff] [blame] | 591 | media_level_setting); |
| 592 | } |
Johannes Kron | 0854eb6 | 2018-10-10 22:33:20 +0200 | [diff] [blame] | 593 | } |
| 594 | } |
Johannes Kron | 9581bc4 | 2018-10-23 10:17:39 +0200 | [diff] [blame] | 595 | bool extmap_allow_mixed() const { return extmap_allow_mixed_; } |
Johannes Kron | 0854eb6 | 2018-10-10 22:33:20 +0200 | [diff] [blame] | 596 | |
Steve Anton | 4ab68ee | 2017-12-19 14:26:11 -0800 | [diff] [blame] | 597 | private: |
| 598 | SessionDescription(const SessionDescription&); |
| 599 | |
| 600 | ContentInfos contents_; |
| 601 | TransportInfos transport_infos_; |
| 602 | ContentGroups content_groups_; |
| 603 | bool msid_supported_ = true; |
Steve Anton | e831b8c | 2018-02-01 12:22:16 -0800 | [diff] [blame] | 604 | // Default to what Plan B would do. |
| 605 | // TODO(bugs.webrtc.org/8530): Change default to kMsidSignalingMediaSection. |
| 606 | int msid_signaling_ = kMsidSignalingSsrcAttribute; |
Emil Lundmark | 801c999 | 2021-01-19 13:06:32 +0100 | [diff] [blame] | 607 | bool extmap_allow_mixed_ = true; |
Steve Anton | 4ab68ee | 2017-12-19 14:26:11 -0800 | [diff] [blame] | 608 | }; |
| 609 | |
Steve Anton | b1c1de1 | 2017-12-21 15:14:30 -0800 | [diff] [blame] | 610 | // Indicates whether a session description was sent by the local client or |
| 611 | // received from the remote client. |
Steve Anton | 4ab68ee | 2017-12-19 14:26:11 -0800 | [diff] [blame] | 612 | enum ContentSource { CS_LOCAL, CS_REMOTE }; |
| 613 | |
| 614 | } // namespace cricket |
| 615 | |
Steve Anton | 10542f2 | 2019-01-11 09:11:00 -0800 | [diff] [blame] | 616 | #endif // PC_SESSION_DESCRIPTION_H_ |