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