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