henrike@webrtc.org | 28e2075 | 2013-07-10 00:45:36 | [diff] [blame] | 1 | /* |
kjellander | 65c7f67 | 2016-02-12 08:05:01 | [diff] [blame] | 2 | * Copyright 2004 The WebRTC project authors. All Rights Reserved. |
henrike@webrtc.org | 28e2075 | 2013-07-10 00:45:36 | [diff] [blame] | 3 | * |
kjellander | 65c7f67 | 2016-02-12 08:05:01 | [diff] [blame] | 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. |
henrike@webrtc.org | 28e2075 | 2013-07-10 00:45:36 | [diff] [blame] | 9 | */ |
| 10 | |
| 11 | // Types and classes used in media session descriptions. |
| 12 | |
Steve Anton | 10542f2 | 2019-01-11 17:11:00 | [diff] [blame] | 13 | #ifndef PC_MEDIA_SESSION_H_ |
| 14 | #define PC_MEDIA_SESSION_H_ |
henrike@webrtc.org | 28e2075 | 2013-07-10 00:45:36 | [diff] [blame] | 15 | |
deadbeef | 0ed85b2 | 2016-02-24 01:24:52 | [diff] [blame] | 16 | #include <map> |
Steve Anton | 1a9d3c3 | 2018-12-11 01:18:54 | [diff] [blame] | 17 | #include <memory> |
henrike@webrtc.org | 28e2075 | 2013-07-10 00:45:36 | [diff] [blame] | 18 | #include <string> |
| 19 | #include <vector> |
henrike@webrtc.org | 28e2075 | 2013-07-10 00:45:36 | [diff] [blame] | 20 | |
Harald Alvestrand | 5761e7b | 2021-01-29 14:45:08 | [diff] [blame] | 21 | #include "api/crypto/crypto_options.h" |
Jonas Oreland | e62c2f2 | 2022-03-29 09:04:48 | [diff] [blame] | 22 | #include "api/field_trials_view.h" |
Steve Anton | 10542f2 | 2019-01-11 17:11:00 | [diff] [blame] | 23 | #include "api/media_types.h" |
Harald Alvestrand | 5761e7b | 2021-01-29 14:45:08 | [diff] [blame] | 24 | #include "api/rtp_parameters.h" |
| 25 | #include "api/rtp_transceiver_direction.h" |
Steve Anton | 10542f2 | 2019-01-11 17:11:00 | [diff] [blame] | 26 | #include "media/base/media_constants.h" |
Harald Alvestrand | 5761e7b | 2021-01-29 14:45:08 | [diff] [blame] | 27 | #include "media/base/rid_description.h" |
| 28 | #include "media/base/stream_params.h" |
Steve Anton | 10542f2 | 2019-01-11 17:11:00 | [diff] [blame] | 29 | #include "p2p/base/ice_credentials_iterator.h" |
Harald Alvestrand | 5761e7b | 2021-01-29 14:45:08 | [diff] [blame] | 30 | #include "p2p/base/transport_description.h" |
Steve Anton | 10542f2 | 2019-01-11 17:11:00 | [diff] [blame] | 31 | #include "p2p/base/transport_description_factory.h" |
Harald Alvestrand | 5761e7b | 2021-01-29 14:45:08 | [diff] [blame] | 32 | #include "p2p/base/transport_info.h" |
Steve Anton | 10542f2 | 2019-01-11 17:11:00 | [diff] [blame] | 33 | #include "pc/jsep_transport.h" |
Harald Alvestrand | 5fc28b1 | 2019-05-13 11:36:16 | [diff] [blame] | 34 | #include "pc/media_protocol_names.h" |
Steve Anton | 10542f2 | 2019-01-11 17:11:00 | [diff] [blame] | 35 | #include "pc/session_description.h" |
Harald Alvestrand | 5761e7b | 2021-01-29 14:45:08 | [diff] [blame] | 36 | #include "pc/simulcast_description.h" |
Amit Hilbuch | bcd39d4 | 2019-01-26 01:13:56 | [diff] [blame] | 37 | #include "rtc_base/unique_id_generator.h" |
henrike@webrtc.org | 28e2075 | 2013-07-10 00:45:36 | [diff] [blame] | 38 | |
Jonas Oreland | ed99dae | 2022-03-09 08:28:10 | [diff] [blame] | 39 | namespace webrtc { |
| 40 | |
| 41 | // Forward declaration due to circular dependecy. |
| 42 | class ConnectionContext; |
| 43 | |
| 44 | } // namespace webrtc |
| 45 | |
henrike@webrtc.org | 28e2075 | 2013-07-10 00:45:36 | [diff] [blame] | 46 | namespace cricket { |
| 47 | |
| 48 | class ChannelManager; |
henrike@webrtc.org | 28e2075 | 2013-07-10 00:45:36 | [diff] [blame] | 49 | |
zhihuang | 8f65cdf | 2016-05-07 01:40:30 | [diff] [blame] | 50 | // Default RTCP CNAME for unit tests. |
| 51 | const char kDefaultRtcpCname[] = "DefaultRtcpCname"; |
| 52 | |
zhihuang | 1c378ed | 2017-08-17 21:10:50 | [diff] [blame] | 53 | // Options for an RtpSender contained with an media description/"m=" section. |
Amit Hilbuch | c63ddb2 | 2019-01-02 18:13:58 | [diff] [blame] | 54 | // Note: Spec-compliant Simulcast and legacy simulcast are mutually exclusive. |
zhihuang | 1c378ed | 2017-08-17 21:10:50 | [diff] [blame] | 55 | struct SenderOptions { |
| 56 | std::string track_id; |
Steve Anton | 8ffb9c3 | 2017-08-31 22:45:38 | [diff] [blame] | 57 | std::vector<std::string> stream_ids; |
Amit Hilbuch | c63ddb2 | 2019-01-02 18:13:58 | [diff] [blame] | 58 | // Use RIDs and Simulcast Layers to indicate spec-compliant Simulcast. |
| 59 | std::vector<RidDescription> rids; |
| 60 | SimulcastLayerList simulcast_layers; |
Artem Titov | 880fa81 | 2021-07-30 20:30:23 | [diff] [blame] | 61 | // Use `num_sim_layers` to indicate legacy simulcast. |
zhihuang | 1c378ed | 2017-08-17 21:10:50 | [diff] [blame] | 62 | int num_sim_layers; |
| 63 | }; |
jiayl@webrtc.org | 742922b | 2014-10-07 21:32:43 | [diff] [blame] | 64 | |
zhihuang | 1c378ed | 2017-08-17 21:10:50 | [diff] [blame] | 65 | // Options for an individual media description/"m=" section. |
| 66 | struct MediaDescriptionOptions { |
| 67 | MediaDescriptionOptions(MediaType type, |
| 68 | const std::string& mid, |
Steve Anton | 1d03a75 | 2017-11-27 22:30:09 | [diff] [blame] | 69 | webrtc::RtpTransceiverDirection direction, |
zhihuang | 1c378ed | 2017-08-17 21:10:50 | [diff] [blame] | 70 | bool stopped) |
| 71 | : type(type), mid(mid), direction(direction), stopped(stopped) {} |
zhihuang | a77e6bb | 2017-08-15 01:17:48 | [diff] [blame] | 72 | |
zhihuang | 1c378ed | 2017-08-17 21:10:50 | [diff] [blame] | 73 | // TODO(deadbeef): When we don't support Plan B, there will only be one |
| 74 | // sender per media description and this can be simplified. |
| 75 | void AddAudioSender(const std::string& track_id, |
Steve Anton | 8ffb9c3 | 2017-08-31 22:45:38 | [diff] [blame] | 76 | const std::vector<std::string>& stream_ids); |
zhihuang | 1c378ed | 2017-08-17 21:10:50 | [diff] [blame] | 77 | void AddVideoSender(const std::string& track_id, |
Steve Anton | 8ffb9c3 | 2017-08-31 22:45:38 | [diff] [blame] | 78 | const std::vector<std::string>& stream_ids, |
Amit Hilbuch | c63ddb2 | 2019-01-02 18:13:58 | [diff] [blame] | 79 | const std::vector<RidDescription>& rids, |
| 80 | const SimulcastLayerList& simulcast_layers, |
olka | 3c74766 | 2017-08-17 13:50:32 | [diff] [blame] | 81 | int num_sim_layers); |
zhihuang | a77e6bb | 2017-08-15 01:17:48 | [diff] [blame] | 82 | |
zhihuang | 1c378ed | 2017-08-17 21:10:50 | [diff] [blame] | 83 | MediaType type; |
| 84 | std::string mid; |
Steve Anton | 1d03a75 | 2017-11-27 22:30:09 | [diff] [blame] | 85 | webrtc::RtpTransceiverDirection direction; |
zhihuang | 1c378ed | 2017-08-17 21:10:50 | [diff] [blame] | 86 | bool stopped; |
| 87 | TransportOptions transport_options; |
| 88 | // Note: There's no equivalent "RtpReceiverOptions" because only send |
| 89 | // stream information goes in the local descriptions. |
| 90 | std::vector<SenderOptions> sender_options; |
Florent Castelli | 2d9d82e | 2019-04-23 17:25:51 | [diff] [blame] | 91 | std::vector<webrtc::RtpCodecCapability> codec_preferences; |
Markus Handell | 755c65d | 2020-06-23 23:06:10 | [diff] [blame] | 92 | std::vector<webrtc::RtpHeaderExtensionCapability> header_extensions; |
zhihuang | 1c378ed | 2017-08-17 21:10:50 | [diff] [blame] | 93 | |
| 94 | private: |
Artem Titov | 880fa81 | 2021-07-30 20:30:23 | [diff] [blame] | 95 | // Doesn't DCHECK on `type`. |
zhihuang | 1c378ed | 2017-08-17 21:10:50 | [diff] [blame] | 96 | void AddSenderInternal(const std::string& track_id, |
Steve Anton | 8ffb9c3 | 2017-08-31 22:45:38 | [diff] [blame] | 97 | const std::vector<std::string>& stream_ids, |
Amit Hilbuch | c63ddb2 | 2019-01-02 18:13:58 | [diff] [blame] | 98 | const std::vector<RidDescription>& rids, |
| 99 | const SimulcastLayerList& simulcast_layers, |
olka | 3c74766 | 2017-08-17 13:50:32 | [diff] [blame] | 100 | int num_sim_layers); |
zhihuang | 1c378ed | 2017-08-17 21:10:50 | [diff] [blame] | 101 | }; |
olka | 3c74766 | 2017-08-17 13:50:32 | [diff] [blame] | 102 | |
zhihuang | 1c378ed | 2017-08-17 21:10:50 | [diff] [blame] | 103 | // Provides a mechanism for describing how m= sections should be generated. |
| 104 | // The m= section with index X will use media_description_options[X]. There |
| 105 | // must be an option for each existing section if creating an answer, or a |
| 106 | // subsequent offer. |
| 107 | struct MediaSessionOptions { |
| 108 | MediaSessionOptions() {} |
olka | 3c74766 | 2017-08-17 13:50:32 | [diff] [blame] | 109 | |
zhihuang | 1c378ed | 2017-08-17 21:10:50 | [diff] [blame] | 110 | bool has_audio() const { return HasMediaDescription(MEDIA_TYPE_AUDIO); } |
| 111 | bool has_video() const { return HasMediaDescription(MEDIA_TYPE_VIDEO); } |
| 112 | bool has_data() const { return HasMediaDescription(MEDIA_TYPE_DATA); } |
| 113 | |
| 114 | bool HasMediaDescription(MediaType type) const; |
| 115 | |
zhihuang | 1c378ed | 2017-08-17 21:10:50 | [diff] [blame] | 116 | bool vad_enabled = true; // When disabled, removes all CN codecs from SDP. |
| 117 | bool rtcp_mux_enabled = true; |
| 118 | bool bundle_enabled = false; |
Johannes Kron | 89f874e | 2018-11-12 09:25:48 | [diff] [blame] | 119 | bool offer_extmap_allow_mixed = false; |
Mirta Dvornicic | 479a3c0 | 2019-06-04 13:38:50 | [diff] [blame] | 120 | bool raw_packetization_for_video = false; |
zhihuang | 1c378ed | 2017-08-17 21:10:50 | [diff] [blame] | 121 | std::string rtcp_cname = kDefaultRtcpCname; |
Benjamin Wright | a54daf1 | 2018-10-11 22:33:17 | [diff] [blame] | 122 | webrtc::CryptoOptions crypto_options; |
zhihuang | 1c378ed | 2017-08-17 21:10:50 | [diff] [blame] | 123 | // List of media description options in the same order that the media |
| 124 | // descriptions will be generated. |
| 125 | std::vector<MediaDescriptionOptions> media_description_options; |
Jonas Oreland | 1cd39fa | 2018-10-11 05:47:12 | [diff] [blame] | 126 | std::vector<IceParameters> pooled_ice_credentials; |
Piotr (Peter) Slatala | b1ae10b | 2019-03-01 19:14:05 | [diff] [blame] | 127 | |
Harald Alvestrand | 4aa1192 | 2019-05-14 20:00:01 | [diff] [blame] | 128 | // Use the draft-ietf-mmusic-sctp-sdp-03 obsolete syntax for SCTP |
| 129 | // datachannels. |
| 130 | // Default is true for backwards compatibility with clients that use |
| 131 | // this internal interface. |
| 132 | bool use_obsolete_sctp_sdp = true; |
henrike@webrtc.org | 28e2075 | 2013-07-10 00:45:36 | [diff] [blame] | 133 | }; |
| 134 | |
henrike@webrtc.org | 28e2075 | 2013-07-10 00:45:36 | [diff] [blame] | 135 | // Creates media session descriptions according to the supplied codecs and |
| 136 | // other fields, as well as the supplied per-call options. |
| 137 | // When creating answers, performs the appropriate negotiation |
| 138 | // of the various fields to determine the proper result. |
| 139 | class MediaSessionDescriptionFactory { |
| 140 | public: |
Amit Hilbuch | bcd39d4 | 2019-01-26 01:13:56 | [diff] [blame] | 141 | // Simple constructor that does not set any configuration for the factory. |
| 142 | // When using this constructor, the methods below can be used to set the |
| 143 | // configuration. |
| 144 | // The TransportDescriptionFactory and the UniqueRandomIdGenerator are not |
| 145 | // owned by MediaSessionDescriptionFactory, so they must be kept alive by the |
| 146 | // user of this class. |
| 147 | MediaSessionDescriptionFactory(const TransportDescriptionFactory* factory, |
| 148 | rtc::UniqueRandomIdGenerator* ssrc_generator); |
henrike@webrtc.org | 28e2075 | 2013-07-10 00:45:36 | [diff] [blame] | 149 | // This helper automatically sets up the factory to get its configuration |
| 150 | // from the specified ChannelManager. |
| 151 | MediaSessionDescriptionFactory(ChannelManager* cmanager, |
Tomas Gunnarsson | 5411b17 | 2022-01-24 07:45:26 | [diff] [blame] | 152 | const TransportDescriptionFactory* factory); |
henrike@webrtc.org | 28e2075 | 2013-07-10 00:45:36 | [diff] [blame] | 153 | |
ossu | dedfd28 | 2016-06-14 14:12:39 | [diff] [blame] | 154 | const AudioCodecs& audio_sendrecv_codecs() const; |
ossu | 075af92 | 2016-06-14 10:29:38 | [diff] [blame] | 155 | const AudioCodecs& audio_send_codecs() const; |
| 156 | const AudioCodecs& audio_recv_codecs() const; |
| 157 | void set_audio_codecs(const AudioCodecs& send_codecs, |
| 158 | const AudioCodecs& recv_codecs); |
Johannes Kron | 3e98368 | 2020-03-29 20:17:00 | [diff] [blame] | 159 | const VideoCodecs& video_sendrecv_codecs() const; |
| 160 | const VideoCodecs& video_send_codecs() const; |
| 161 | const VideoCodecs& video_recv_codecs() const; |
| 162 | void set_video_codecs(const VideoCodecs& send_codecs, |
| 163 | const VideoCodecs& recv_codecs); |
Markus Handell | 755c65d | 2020-06-23 23:06:10 | [diff] [blame] | 164 | RtpHeaderExtensions filtered_rtp_header_extensions( |
| 165 | RtpHeaderExtensions extensions) const; |
Harald Alvestrand | 0d01841 | 2021-11-04 13:52:31 | [diff] [blame] | 166 | SecurePolicy secure() const { return secure_; } |
| 167 | void set_secure(SecurePolicy s) { secure_ = s; } |
henrike@webrtc.org | 28e2075 | 2013-07-10 00:45:36 | [diff] [blame] | 168 | |
jbauch | 5869f50 | 2017-06-29 19:31:36 | [diff] [blame] | 169 | void set_enable_encrypted_rtp_header_extensions(bool enable) { |
| 170 | enable_encrypted_rtp_header_extensions_ = enable; |
| 171 | } |
| 172 | |
Steve Anton | 8f66ddb | 2018-12-11 00:08:05 | [diff] [blame] | 173 | void set_is_unified_plan(bool is_unified_plan) { |
| 174 | is_unified_plan_ = is_unified_plan; |
| 175 | } |
| 176 | |
Steve Anton | 6fe1fba | 2018-12-11 18:15:23 | [diff] [blame] | 177 | std::unique_ptr<SessionDescription> CreateOffer( |
henrike@webrtc.org | 28e2075 | 2013-07-10 00:45:36 | [diff] [blame] | 178 | const MediaSessionOptions& options, |
| 179 | const SessionDescription* current_description) const; |
Steve Anton | 6fe1fba | 2018-12-11 18:15:23 | [diff] [blame] | 180 | std::unique_ptr<SessionDescription> CreateAnswer( |
zstein | 4b2e082 | 2017-02-18 03:48:38 | [diff] [blame] | 181 | const SessionDescription* offer, |
| 182 | const MediaSessionOptions& options, |
| 183 | const SessionDescription* current_description) const; |
henrike@webrtc.org | 28e2075 | 2013-07-10 00:45:36 | [diff] [blame] | 184 | |
| 185 | private: |
Markus Handell | 755c65d | 2020-06-23 23:06:10 | [diff] [blame] | 186 | struct AudioVideoRtpHeaderExtensions { |
| 187 | RtpHeaderExtensions audio; |
| 188 | RtpHeaderExtensions video; |
| 189 | }; |
| 190 | |
ossu | 075af92 | 2016-06-14 10:29:38 | [diff] [blame] | 191 | const AudioCodecs& GetAudioCodecsForOffer( |
Steve Anton | 1d03a75 | 2017-11-27 22:30:09 | [diff] [blame] | 192 | const webrtc::RtpTransceiverDirection& direction) const; |
ossu | 075af92 | 2016-06-14 10:29:38 | [diff] [blame] | 193 | const AudioCodecs& GetAudioCodecsForAnswer( |
Steve Anton | 1d03a75 | 2017-11-27 22:30:09 | [diff] [blame] | 194 | const webrtc::RtpTransceiverDirection& offer, |
| 195 | const webrtc::RtpTransceiverDirection& answer) const; |
Johannes Kron | 3e98368 | 2020-03-29 20:17:00 | [diff] [blame] | 196 | const VideoCodecs& GetVideoCodecsForOffer( |
| 197 | const webrtc::RtpTransceiverDirection& direction) const; |
| 198 | const VideoCodecs& GetVideoCodecsForAnswer( |
| 199 | const webrtc::RtpTransceiverDirection& offer, |
| 200 | const webrtc::RtpTransceiverDirection& answer) const; |
Steve Anton | 5c72e71 | 2018-12-10 22:25:30 | [diff] [blame] | 201 | void GetCodecsForOffer( |
| 202 | const std::vector<const ContentInfo*>& current_active_contents, |
| 203 | AudioCodecs* audio_codecs, |
Harald Alvestrand | 7af57c6 | 2021-04-16 11:12:14 | [diff] [blame] | 204 | VideoCodecs* video_codecs) const; |
Steve Anton | 5c72e71 | 2018-12-10 22:25:30 | [diff] [blame] | 205 | void GetCodecsForAnswer( |
| 206 | const std::vector<const ContentInfo*>& current_active_contents, |
| 207 | const SessionDescription& remote_offer, |
| 208 | AudioCodecs* audio_codecs, |
Harald Alvestrand | 7af57c6 | 2021-04-16 11:12:14 | [diff] [blame] | 209 | VideoCodecs* video_codecs) const; |
Markus Handell | 755c65d | 2020-06-23 23:06:10 | [diff] [blame] | 210 | AudioVideoRtpHeaderExtensions GetOfferedRtpHeaderExtensionsWithIds( |
Steve Anton | 5c72e71 | 2018-12-10 22:25:30 | [diff] [blame] | 211 | const std::vector<const ContentInfo*>& current_active_contents, |
Johannes Kron | 746dd0d | 2019-06-20 13:37:52 | [diff] [blame] | 212 | bool extmap_allow_mixed, |
Markus Handell | 755c65d | 2020-06-23 23:06:10 | [diff] [blame] | 213 | const std::vector<MediaDescriptionOptions>& media_description_options) |
| 214 | const; |
Yves Gerey | 665174f | 2018-06-19 13:03:05 | [diff] [blame] | 215 | bool AddTransportOffer(const std::string& content_name, |
| 216 | const TransportOptions& transport_options, |
| 217 | const SessionDescription* current_desc, |
Jonas Oreland | 1cd39fa | 2018-10-11 05:47:12 | [diff] [blame] | 218 | SessionDescription* offer, |
| 219 | IceCredentialsIterator* ice_credentials) const; |
henrike@webrtc.org | 28e2075 | 2013-07-10 00:45:36 | [diff] [blame] | 220 | |
Steve Anton | 1a9d3c3 | 2018-12-11 01:18:54 | [diff] [blame] | 221 | std::unique_ptr<TransportDescription> CreateTransportAnswer( |
henrike@webrtc.org | 28e2075 | 2013-07-10 00:45:36 | [diff] [blame] | 222 | const std::string& content_name, |
| 223 | const SessionDescription* offer_desc, |
| 224 | const TransportOptions& transport_options, |
deadbeef | b789253 | 2017-02-23 03:35:18 | [diff] [blame] | 225 | const SessionDescription* current_desc, |
Jonas Oreland | 1cd39fa | 2018-10-11 05:47:12 | [diff] [blame] | 226 | bool require_transport_attributes, |
| 227 | IceCredentialsIterator* ice_credentials) const; |
henrike@webrtc.org | 28e2075 | 2013-07-10 00:45:36 | [diff] [blame] | 228 | |
Yves Gerey | 665174f | 2018-06-19 13:03:05 | [diff] [blame] | 229 | bool AddTransportAnswer(const std::string& content_name, |
| 230 | const TransportDescription& transport_desc, |
| 231 | SessionDescription* answer_desc) const; |
henrike@webrtc.org | 28e2075 | 2013-07-10 00:45:36 | [diff] [blame] | 232 | |
jiayl@webrtc.org | e7d47a1 | 2014-08-05 19:19:05 | [diff] [blame] | 233 | // Helpers for adding media contents to the SessionDescription. Returns true |
| 234 | // it succeeds or the media content is not needed, or false if there is any |
| 235 | // error. |
| 236 | |
| 237 | bool AddAudioContentForOffer( |
zhihuang | 1c378ed | 2017-08-17 21:10:50 | [diff] [blame] | 238 | const MediaDescriptionOptions& media_description_options, |
| 239 | const MediaSessionOptions& session_options, |
| 240 | const ContentInfo* current_content, |
jiayl@webrtc.org | e7d47a1 | 2014-08-05 19:19:05 | [diff] [blame] | 241 | const SessionDescription* current_description, |
| 242 | const RtpHeaderExtensions& audio_rtp_extensions, |
| 243 | const AudioCodecs& audio_codecs, |
| 244 | StreamParamsVec* current_streams, |
Jonas Oreland | 1cd39fa | 2018-10-11 05:47:12 | [diff] [blame] | 245 | SessionDescription* desc, |
| 246 | IceCredentialsIterator* ice_credentials) const; |
jiayl@webrtc.org | e7d47a1 | 2014-08-05 19:19:05 | [diff] [blame] | 247 | |
| 248 | bool AddVideoContentForOffer( |
zhihuang | 1c378ed | 2017-08-17 21:10:50 | [diff] [blame] | 249 | const MediaDescriptionOptions& media_description_options, |
| 250 | const MediaSessionOptions& session_options, |
| 251 | const ContentInfo* current_content, |
jiayl@webrtc.org | e7d47a1 | 2014-08-05 19:19:05 | [diff] [blame] | 252 | const SessionDescription* current_description, |
| 253 | const RtpHeaderExtensions& video_rtp_extensions, |
| 254 | const VideoCodecs& video_codecs, |
| 255 | StreamParamsVec* current_streams, |
Jonas Oreland | 1cd39fa | 2018-10-11 05:47:12 | [diff] [blame] | 256 | SessionDescription* desc, |
| 257 | IceCredentialsIterator* ice_credentials) const; |
jiayl@webrtc.org | e7d47a1 | 2014-08-05 19:19:05 | [diff] [blame] | 258 | |
| 259 | bool AddDataContentForOffer( |
zhihuang | 1c378ed | 2017-08-17 21:10:50 | [diff] [blame] | 260 | const MediaDescriptionOptions& media_description_options, |
| 261 | const MediaSessionOptions& session_options, |
| 262 | const ContentInfo* current_content, |
jiayl@webrtc.org | e7d47a1 | 2014-08-05 19:19:05 | [diff] [blame] | 263 | const SessionDescription* current_description, |
jiayl@webrtc.org | e7d47a1 | 2014-08-05 19:19:05 | [diff] [blame] | 264 | StreamParamsVec* current_streams, |
Jonas Oreland | 1cd39fa | 2018-10-11 05:47:12 | [diff] [blame] | 265 | SessionDescription* desc, |
| 266 | IceCredentialsIterator* ice_credentials) const; |
jiayl@webrtc.org | e7d47a1 | 2014-08-05 19:19:05 | [diff] [blame] | 267 | |
Philipp Hancke | 4e8c115 | 2020-10-13 10:43:15 | [diff] [blame] | 268 | bool AddUnsupportedContentForOffer( |
| 269 | const MediaDescriptionOptions& media_description_options, |
| 270 | const MediaSessionOptions& session_options, |
| 271 | const ContentInfo* current_content, |
| 272 | const SessionDescription* current_description, |
| 273 | SessionDescription* desc, |
| 274 | IceCredentialsIterator* ice_credentials) const; |
| 275 | |
zhihuang | 1c378ed | 2017-08-17 21:10:50 | [diff] [blame] | 276 | bool AddAudioContentForAnswer( |
| 277 | const MediaDescriptionOptions& media_description_options, |
| 278 | const MediaSessionOptions& session_options, |
| 279 | const ContentInfo* offer_content, |
| 280 | const SessionDescription* offer_description, |
| 281 | const ContentInfo* current_content, |
| 282 | const SessionDescription* current_description, |
| 283 | const TransportInfo* bundle_transport, |
| 284 | const AudioCodecs& audio_codecs, |
Markus Handell | 755c65d | 2020-06-23 23:06:10 | [diff] [blame] | 285 | const RtpHeaderExtensions& default_audio_rtp_header_extensions, |
zhihuang | 1c378ed | 2017-08-17 21:10:50 | [diff] [blame] | 286 | StreamParamsVec* current_streams, |
Jonas Oreland | 1cd39fa | 2018-10-11 05:47:12 | [diff] [blame] | 287 | SessionDescription* answer, |
| 288 | IceCredentialsIterator* ice_credentials) const; |
jiayl@webrtc.org | e7d47a1 | 2014-08-05 19:19:05 | [diff] [blame] | 289 | |
zhihuang | 1c378ed | 2017-08-17 21:10:50 | [diff] [blame] | 290 | bool AddVideoContentForAnswer( |
| 291 | const MediaDescriptionOptions& media_description_options, |
| 292 | const MediaSessionOptions& session_options, |
| 293 | const ContentInfo* offer_content, |
| 294 | const SessionDescription* offer_description, |
| 295 | const ContentInfo* current_content, |
| 296 | const SessionDescription* current_description, |
| 297 | const TransportInfo* bundle_transport, |
| 298 | const VideoCodecs& video_codecs, |
Markus Handell | 755c65d | 2020-06-23 23:06:10 | [diff] [blame] | 299 | const RtpHeaderExtensions& default_video_rtp_header_extensions, |
zhihuang | 1c378ed | 2017-08-17 21:10:50 | [diff] [blame] | 300 | StreamParamsVec* current_streams, |
Jonas Oreland | 1cd39fa | 2018-10-11 05:47:12 | [diff] [blame] | 301 | SessionDescription* answer, |
| 302 | IceCredentialsIterator* ice_credentials) const; |
jiayl@webrtc.org | e7d47a1 | 2014-08-05 19:19:05 | [diff] [blame] | 303 | |
zhihuang | 1c378ed | 2017-08-17 21:10:50 | [diff] [blame] | 304 | bool AddDataContentForAnswer( |
| 305 | const MediaDescriptionOptions& media_description_options, |
| 306 | const MediaSessionOptions& session_options, |
| 307 | const ContentInfo* offer_content, |
| 308 | const SessionDescription* offer_description, |
| 309 | const ContentInfo* current_content, |
| 310 | const SessionDescription* current_description, |
| 311 | const TransportInfo* bundle_transport, |
zhihuang | 1c378ed | 2017-08-17 21:10:50 | [diff] [blame] | 312 | StreamParamsVec* current_streams, |
Jonas Oreland | 1cd39fa | 2018-10-11 05:47:12 | [diff] [blame] | 313 | SessionDescription* answer, |
| 314 | IceCredentialsIterator* ice_credentials) const; |
zhihuang | 1c378ed | 2017-08-17 21:10:50 | [diff] [blame] | 315 | |
Philipp Hancke | 4e8c115 | 2020-10-13 10:43:15 | [diff] [blame] | 316 | bool AddUnsupportedContentForAnswer( |
| 317 | const MediaDescriptionOptions& media_description_options, |
| 318 | const MediaSessionOptions& session_options, |
| 319 | const ContentInfo* offer_content, |
| 320 | const SessionDescription* offer_description, |
| 321 | const ContentInfo* current_content, |
| 322 | const SessionDescription* current_description, |
| 323 | const TransportInfo* bundle_transport, |
| 324 | SessionDescription* answer, |
| 325 | IceCredentialsIterator* ice_credentials) const; |
| 326 | |
zhihuang | 1c378ed | 2017-08-17 21:10:50 | [diff] [blame] | 327 | void ComputeAudioCodecsIntersectionAndUnion(); |
jiayl@webrtc.org | e7d47a1 | 2014-08-05 19:19:05 | [diff] [blame] | 328 | |
Johannes Kron | 3e98368 | 2020-03-29 20:17:00 | [diff] [blame] | 329 | void ComputeVideoCodecsIntersectionAndUnion(); |
| 330 | |
Steve Anton | 8f66ddb | 2018-12-11 00:08:05 | [diff] [blame] | 331 | bool is_unified_plan_ = false; |
ossu | 075af92 | 2016-06-14 10:29:38 | [diff] [blame] | 332 | AudioCodecs audio_send_codecs_; |
| 333 | AudioCodecs audio_recv_codecs_; |
zhihuang | 1c378ed | 2017-08-17 21:10:50 | [diff] [blame] | 334 | // Intersection of send and recv. |
ossu | 075af92 | 2016-06-14 10:29:38 | [diff] [blame] | 335 | AudioCodecs audio_sendrecv_codecs_; |
zhihuang | 1c378ed | 2017-08-17 21:10:50 | [diff] [blame] | 336 | // Union of send and recv. |
| 337 | AudioCodecs all_audio_codecs_; |
Johannes Kron | 3e98368 | 2020-03-29 20:17:00 | [diff] [blame] | 338 | VideoCodecs video_send_codecs_; |
| 339 | VideoCodecs video_recv_codecs_; |
| 340 | // Intersection of send and recv. |
| 341 | VideoCodecs video_sendrecv_codecs_; |
| 342 | // Union of send and recv. |
| 343 | VideoCodecs all_video_codecs_; |
Artem Titov | c6c02ef | 2022-05-09 08:30:09 | [diff] [blame] | 344 | // This object is not owned by the channel so it must outlive it. |
| 345 | rtc::UniqueRandomIdGenerator* const ssrc_generator_; |
jbauch | 5869f50 | 2017-06-29 19:31:36 | [diff] [blame] | 346 | bool enable_encrypted_rtp_header_extensions_ = false; |
Harald Alvestrand | 0d01841 | 2021-11-04 13:52:31 | [diff] [blame] | 347 | // TODO(zhihuang): Rename secure_ to sdec_policy_; rename the related getter |
| 348 | // and setter. |
| 349 | SecurePolicy secure_ = SEC_DISABLED; |
henrike@webrtc.org | 28e2075 | 2013-07-10 00:45:36 | [diff] [blame] | 350 | const TransportDescriptionFactory* transport_desc_factory_; |
| 351 | }; |
| 352 | |
| 353 | // Convenience functions. |
| 354 | bool IsMediaContent(const ContentInfo* content); |
| 355 | bool IsAudioContent(const ContentInfo* content); |
| 356 | bool IsVideoContent(const ContentInfo* content); |
| 357 | bool IsDataContent(const ContentInfo* content); |
Philipp Hancke | 4e8c115 | 2020-10-13 10:43:15 | [diff] [blame] | 358 | bool IsUnsupportedContent(const ContentInfo* content); |
deadbeef | 0ed85b2 | 2016-02-24 01:24:52 | [diff] [blame] | 359 | const ContentInfo* GetFirstMediaContent(const ContentInfos& contents, |
| 360 | MediaType media_type); |
henrike@webrtc.org | 28e2075 | 2013-07-10 00:45:36 | [diff] [blame] | 361 | const ContentInfo* GetFirstAudioContent(const ContentInfos& contents); |
| 362 | const ContentInfo* GetFirstVideoContent(const ContentInfos& contents); |
| 363 | const ContentInfo* GetFirstDataContent(const ContentInfos& contents); |
Steve Anton | ad7bffc | 2018-01-22 18:21:56 | [diff] [blame] | 364 | const ContentInfo* GetFirstMediaContent(const SessionDescription* sdesc, |
| 365 | MediaType media_type); |
henrike@webrtc.org | 28e2075 | 2013-07-10 00:45:36 | [diff] [blame] | 366 | const ContentInfo* GetFirstAudioContent(const SessionDescription* sdesc); |
| 367 | const ContentInfo* GetFirstVideoContent(const SessionDescription* sdesc); |
| 368 | const ContentInfo* GetFirstDataContent(const SessionDescription* sdesc); |
| 369 | const AudioContentDescription* GetFirstAudioContentDescription( |
| 370 | const SessionDescription* sdesc); |
| 371 | const VideoContentDescription* GetFirstVideoContentDescription( |
| 372 | const SessionDescription* sdesc); |
Harald Alvestrand | 5fc28b1 | 2019-05-13 11:36:16 | [diff] [blame] | 373 | const SctpDataContentDescription* GetFirstSctpDataContentDescription( |
| 374 | const SessionDescription* sdesc); |
Taylor Brandstetter | dc4eb8c | 2016-05-12 15:14:50 | [diff] [blame] | 375 | // Non-const versions of the above functions. |
| 376 | // Useful when modifying an existing description. |
Steve Anton | 36b29d1 | 2017-10-30 16:57:42 | [diff] [blame] | 377 | ContentInfo* GetFirstMediaContent(ContentInfos* contents, MediaType media_type); |
| 378 | ContentInfo* GetFirstAudioContent(ContentInfos* contents); |
| 379 | ContentInfo* GetFirstVideoContent(ContentInfos* contents); |
| 380 | ContentInfo* GetFirstDataContent(ContentInfos* contents); |
Steve Anton | ad7bffc | 2018-01-22 18:21:56 | [diff] [blame] | 381 | ContentInfo* GetFirstMediaContent(SessionDescription* sdesc, |
| 382 | MediaType media_type); |
Taylor Brandstetter | dc4eb8c | 2016-05-12 15:14:50 | [diff] [blame] | 383 | ContentInfo* GetFirstAudioContent(SessionDescription* sdesc); |
| 384 | ContentInfo* GetFirstVideoContent(SessionDescription* sdesc); |
| 385 | ContentInfo* GetFirstDataContent(SessionDescription* sdesc); |
| 386 | AudioContentDescription* GetFirstAudioContentDescription( |
| 387 | SessionDescription* sdesc); |
| 388 | VideoContentDescription* GetFirstVideoContentDescription( |
| 389 | SessionDescription* sdesc); |
Harald Alvestrand | 5fc28b1 | 2019-05-13 11:36:16 | [diff] [blame] | 390 | SctpDataContentDescription* GetFirstSctpDataContentDescription( |
| 391 | SessionDescription* sdesc); |
henrike@webrtc.org | 28e2075 | 2013-07-10 00:45:36 | [diff] [blame] | 392 | |
Harald Alvestrand | 0d01841 | 2021-11-04 13:52:31 | [diff] [blame] | 393 | // Helper functions to return crypto suites used for SDES. |
| 394 | void GetSupportedAudioSdesCryptoSuites( |
| 395 | const webrtc::CryptoOptions& crypto_options, |
| 396 | std::vector<int>* crypto_suites); |
| 397 | void GetSupportedVideoSdesCryptoSuites( |
| 398 | const webrtc::CryptoOptions& crypto_options, |
| 399 | std::vector<int>* crypto_suites); |
| 400 | void GetSupportedDataSdesCryptoSuites( |
| 401 | const webrtc::CryptoOptions& crypto_options, |
| 402 | std::vector<int>* crypto_suites); |
| 403 | void GetSupportedAudioSdesCryptoSuiteNames( |
| 404 | const webrtc::CryptoOptions& crypto_options, |
| 405 | std::vector<std::string>* crypto_suite_names); |
| 406 | void GetSupportedVideoSdesCryptoSuiteNames( |
| 407 | const webrtc::CryptoOptions& crypto_options, |
| 408 | std::vector<std::string>* crypto_suite_names); |
| 409 | void GetSupportedDataSdesCryptoSuiteNames( |
| 410 | const webrtc::CryptoOptions& crypto_options, |
| 411 | std::vector<std::string>* crypto_suite_names); |
| 412 | |
henrike@webrtc.org | 28e2075 | 2013-07-10 00:45:36 | [diff] [blame] | 413 | } // namespace cricket |
| 414 | |
Steve Anton | 10542f2 | 2019-01-11 17:11:00 | [diff] [blame] | 415 | #endif // PC_MEDIA_SESSION_H_ |