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