henrike@webrtc.org | 28e2075 | 2013-07-10 00:45:36 +0000 | [diff] [blame] | 1 | /* |
kjellander | 65c7f67 | 2016-02-12 00:05:01 -0800 | [diff] [blame] | 2 | * Copyright 2004 The WebRTC project authors. All Rights Reserved. |
henrike@webrtc.org | 28e2075 | 2013-07-10 00:45:36 +0000 | [diff] [blame] | 3 | * |
kjellander | 65c7f67 | 2016-02-12 00:05:01 -0800 | [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 +0000 | [diff] [blame] | 9 | */ |
| 10 | |
| 11 | // Types and classes used in media session descriptions. |
| 12 | |
Steve Anton | 10542f2 | 2019-01-11 09:11:00 -0800 | [diff] [blame] | 13 | #ifndef PC_MEDIA_SESSION_H_ |
| 14 | #define PC_MEDIA_SESSION_H_ |
henrike@webrtc.org | 28e2075 | 2013-07-10 00:45:36 +0000 | [diff] [blame] | 15 | |
deadbeef | 0ed85b2 | 2016-02-23 17:24:52 -0800 | [diff] [blame] | 16 | #include <map> |
Steve Anton | 1a9d3c3 | 2018-12-10 17:18:54 -0800 | [diff] [blame] | 17 | #include <memory> |
henrike@webrtc.org | 28e2075 | 2013-07-10 00:45:36 +0000 | [diff] [blame] | 18 | #include <string> |
| 19 | #include <vector> |
henrike@webrtc.org | 28e2075 | 2013-07-10 00:45:36 +0000 | [diff] [blame] | 20 | |
Steve Anton | 10542f2 | 2019-01-11 09:11:00 -0800 | [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 13:36:16 +0200 | [diff] [blame] | 27 | #include "pc/media_protocol_names.h" |
Steve Anton | 10542f2 | 2019-01-11 09:11:00 -0800 | [diff] [blame] | 28 | #include "pc/session_description.h" |
Amit Hilbuch | bcd39d4 | 2019-01-25 17:13:56 -0800 | [diff] [blame] | 29 | #include "rtc_base/unique_id_generator.h" |
henrike@webrtc.org | 28e2075 | 2013-07-10 00:45:36 +0000 | [diff] [blame] | 30 | |
| 31 | namespace cricket { |
| 32 | |
| 33 | class ChannelManager; |
henrike@webrtc.org | 28e2075 | 2013-07-10 00:45:36 +0000 | [diff] [blame] | 34 | |
zhihuang | 8f65cdf | 2016-05-06 18:40:30 -0700 | [diff] [blame] | 35 | // Default RTCP CNAME for unit tests. |
| 36 | const char kDefaultRtcpCname[] = "DefaultRtcpCname"; |
| 37 | |
zhihuang | 1c378ed | 2017-08-17 14:10:50 -0700 | [diff] [blame] | 38 | // Options for an RtpSender contained with an media description/"m=" section. |
Amit Hilbuch | c63ddb2 | 2019-01-02 10:13:58 -0800 | [diff] [blame] | 39 | // Note: Spec-compliant Simulcast and legacy simulcast are mutually exclusive. |
zhihuang | 1c378ed | 2017-08-17 14:10:50 -0700 | [diff] [blame] | 40 | struct SenderOptions { |
| 41 | std::string track_id; |
Steve Anton | 8ffb9c3 | 2017-08-31 15:45:38 -0700 | [diff] [blame] | 42 | std::vector<std::string> stream_ids; |
Amit Hilbuch | c63ddb2 | 2019-01-02 10:13:58 -0800 | [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 14:10:50 -0700 | [diff] [blame] | 47 | int num_sim_layers; |
| 48 | }; |
jiayl@webrtc.org | 742922b | 2014-10-07 21:32:43 +0000 | [diff] [blame] | 49 | |
zhihuang | 1c378ed | 2017-08-17 14:10:50 -0700 | [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 14:30:09 -0800 | [diff] [blame] | 54 | webrtc::RtpTransceiverDirection direction, |
zhihuang | 1c378ed | 2017-08-17 14:10:50 -0700 | [diff] [blame] | 55 | bool stopped) |
| 56 | : type(type), mid(mid), direction(direction), stopped(stopped) {} |
zhihuang | a77e6bb | 2017-08-14 18:17:48 -0700 | [diff] [blame] | 57 | |
zhihuang | 1c378ed | 2017-08-17 14:10:50 -0700 | [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 15:45:38 -0700 | [diff] [blame] | 61 | const std::vector<std::string>& stream_ids); |
zhihuang | 1c378ed | 2017-08-17 14:10:50 -0700 | [diff] [blame] | 62 | void AddVideoSender(const std::string& track_id, |
Steve Anton | 8ffb9c3 | 2017-08-31 15:45:38 -0700 | [diff] [blame] | 63 | const std::vector<std::string>& stream_ids, |
Amit Hilbuch | c63ddb2 | 2019-01-02 10:13:58 -0800 | [diff] [blame] | 64 | const std::vector<RidDescription>& rids, |
| 65 | const SimulcastLayerList& simulcast_layers, |
olka | 3c74766 | 2017-08-17 06:50:32 -0700 | [diff] [blame] | 66 | int num_sim_layers); |
zhihuang | a77e6bb | 2017-08-14 18:17:48 -0700 | [diff] [blame] | 67 | |
zhihuang | 1c378ed | 2017-08-17 14:10:50 -0700 | [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 06:50:32 -0700 | [diff] [blame] | 71 | |
zhihuang | 1c378ed | 2017-08-17 14:10:50 -0700 | [diff] [blame] | 72 | MediaType type; |
| 73 | std::string mid; |
Steve Anton | 1d03a75 | 2017-11-27 14:30:09 -0800 | [diff] [blame] | 74 | webrtc::RtpTransceiverDirection direction; |
zhihuang | 1c378ed | 2017-08-17 14:10:50 -0700 | [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 19:25:51 +0200 | [diff] [blame] | 80 | std::vector<webrtc::RtpCodecCapability> codec_preferences; |
zhihuang | 1c378ed | 2017-08-17 14:10:50 -0700 | [diff] [blame] | 81 | |
| 82 | private: |
| 83 | // Doesn't DCHECK on |type|. |
| 84 | void AddSenderInternal(const std::string& track_id, |
Steve Anton | 8ffb9c3 | 2017-08-31 15:45:38 -0700 | [diff] [blame] | 85 | const std::vector<std::string>& stream_ids, |
Amit Hilbuch | c63ddb2 | 2019-01-02 10:13:58 -0800 | [diff] [blame] | 86 | const std::vector<RidDescription>& rids, |
| 87 | const SimulcastLayerList& simulcast_layers, |
olka | 3c74766 | 2017-08-17 06:50:32 -0700 | [diff] [blame] | 88 | int num_sim_layers); |
zhihuang | 1c378ed | 2017-08-17 14:10:50 -0700 | [diff] [blame] | 89 | }; |
olka | 3c74766 | 2017-08-17 06:50:32 -0700 | [diff] [blame] | 90 | |
zhihuang | 1c378ed | 2017-08-17 14:10:50 -0700 | [diff] [blame] | 91 | // Provides a mechanism for describing how m= sections should be generated. |
| 92 | // The m= section with index X will use media_description_options[X]. There |
| 93 | // must be an option for each existing section if creating an answer, or a |
| 94 | // subsequent offer. |
| 95 | struct MediaSessionOptions { |
| 96 | MediaSessionOptions() {} |
olka | 3c74766 | 2017-08-17 06:50:32 -0700 | [diff] [blame] | 97 | |
zhihuang | 1c378ed | 2017-08-17 14:10:50 -0700 | [diff] [blame] | 98 | bool has_audio() const { return HasMediaDescription(MEDIA_TYPE_AUDIO); } |
| 99 | bool has_video() const { return HasMediaDescription(MEDIA_TYPE_VIDEO); } |
| 100 | bool has_data() const { return HasMediaDescription(MEDIA_TYPE_DATA); } |
| 101 | |
| 102 | bool HasMediaDescription(MediaType type) const; |
| 103 | |
| 104 | DataChannelType data_channel_type = DCT_NONE; |
zhihuang | 1c378ed | 2017-08-17 14:10:50 -0700 | [diff] [blame] | 105 | bool vad_enabled = true; // When disabled, removes all CN codecs from SDP. |
| 106 | bool rtcp_mux_enabled = true; |
| 107 | bool bundle_enabled = false; |
Johannes Kron | 89f874e | 2018-11-12 10:25:48 +0100 | [diff] [blame] | 108 | bool offer_extmap_allow_mixed = false; |
zhihuang | 1c378ed | 2017-08-17 14:10:50 -0700 | [diff] [blame] | 109 | std::string rtcp_cname = kDefaultRtcpCname; |
Benjamin Wright | a54daf1 | 2018-10-11 15:33:17 -0700 | [diff] [blame] | 110 | webrtc::CryptoOptions crypto_options; |
zhihuang | 1c378ed | 2017-08-17 14:10:50 -0700 | [diff] [blame] | 111 | // List of media description options in the same order that the media |
| 112 | // descriptions will be generated. |
| 113 | std::vector<MediaDescriptionOptions> media_description_options; |
Jonas Oreland | 1cd39fa | 2018-10-11 07:47:12 +0200 | [diff] [blame] | 114 | std::vector<IceParameters> pooled_ice_credentials; |
Piotr (Peter) Slatala | b1ae10b | 2019-03-01 11:14:05 -0800 | [diff] [blame] | 115 | |
| 116 | // An optional media transport settings. |
| 117 | // In the future we may consider using a vector here, to indicate multiple |
| 118 | // supported transports. |
| 119 | absl::optional<cricket::SessionDescription::MediaTransportSetting> |
| 120 | media_transport_settings; |
Harald Alvestrand | 4aa1192 | 2019-05-14 22:00:01 +0200 | [diff] [blame] | 121 | // Use the draft-ietf-mmusic-sctp-sdp-03 obsolete syntax for SCTP |
| 122 | // datachannels. |
| 123 | // Default is true for backwards compatibility with clients that use |
| 124 | // this internal interface. |
| 125 | bool use_obsolete_sctp_sdp = true; |
henrike@webrtc.org | 28e2075 | 2013-07-10 00:45:36 +0000 | [diff] [blame] | 126 | }; |
| 127 | |
henrike@webrtc.org | 28e2075 | 2013-07-10 00:45:36 +0000 | [diff] [blame] | 128 | // Creates media session descriptions according to the supplied codecs and |
| 129 | // other fields, as well as the supplied per-call options. |
| 130 | // When creating answers, performs the appropriate negotiation |
| 131 | // of the various fields to determine the proper result. |
| 132 | class MediaSessionDescriptionFactory { |
| 133 | public: |
Amit Hilbuch | bcd39d4 | 2019-01-25 17:13:56 -0800 | [diff] [blame] | 134 | // Simple constructor that does not set any configuration for the factory. |
| 135 | // When using this constructor, the methods below can be used to set the |
| 136 | // configuration. |
| 137 | // The TransportDescriptionFactory and the UniqueRandomIdGenerator are not |
| 138 | // owned by MediaSessionDescriptionFactory, so they must be kept alive by the |
| 139 | // user of this class. |
| 140 | MediaSessionDescriptionFactory(const TransportDescriptionFactory* factory, |
| 141 | rtc::UniqueRandomIdGenerator* ssrc_generator); |
henrike@webrtc.org | 28e2075 | 2013-07-10 00:45:36 +0000 | [diff] [blame] | 142 | // This helper automatically sets up the factory to get its configuration |
| 143 | // from the specified ChannelManager. |
| 144 | MediaSessionDescriptionFactory(ChannelManager* cmanager, |
Amit Hilbuch | bcd39d4 | 2019-01-25 17:13:56 -0800 | [diff] [blame] | 145 | const TransportDescriptionFactory* factory, |
| 146 | rtc::UniqueRandomIdGenerator* ssrc_generator); |
henrike@webrtc.org | 28e2075 | 2013-07-10 00:45:36 +0000 | [diff] [blame] | 147 | |
ossu | dedfd28 | 2016-06-14 07:12:39 -0700 | [diff] [blame] | 148 | const AudioCodecs& audio_sendrecv_codecs() const; |
ossu | 075af92 | 2016-06-14 03:29:38 -0700 | [diff] [blame] | 149 | const AudioCodecs& audio_send_codecs() const; |
| 150 | const AudioCodecs& audio_recv_codecs() const; |
| 151 | void set_audio_codecs(const AudioCodecs& send_codecs, |
| 152 | const AudioCodecs& recv_codecs); |
henrike@webrtc.org | 28e2075 | 2013-07-10 00:45:36 +0000 | [diff] [blame] | 153 | void set_audio_rtp_header_extensions(const RtpHeaderExtensions& extensions) { |
| 154 | audio_rtp_extensions_ = extensions; |
| 155 | } |
Amit Hilbuch | 77938e6 | 2018-12-21 09:23:38 -0800 | [diff] [blame] | 156 | RtpHeaderExtensions audio_rtp_header_extensions() const; |
henrike@webrtc.org | 28e2075 | 2013-07-10 00:45:36 +0000 | [diff] [blame] | 157 | const VideoCodecs& video_codecs() const { return video_codecs_; } |
| 158 | void set_video_codecs(const VideoCodecs& codecs) { video_codecs_ = codecs; } |
| 159 | void set_video_rtp_header_extensions(const RtpHeaderExtensions& extensions) { |
| 160 | video_rtp_extensions_ = extensions; |
| 161 | } |
Amit Hilbuch | 77938e6 | 2018-12-21 09:23:38 -0800 | [diff] [blame] | 162 | RtpHeaderExtensions video_rtp_header_extensions() const; |
Harald Alvestrand | 5fc28b1 | 2019-05-13 13:36:16 +0200 | [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 +0000 | [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 +0000 | [diff] [blame] | 169 | |
jbauch | 5869f50 | 2017-06-29 12:31:36 -0700 | [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-10 16:08:05 -0800 | [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 10:15:23 -0800 | [diff] [blame] | 178 | std::unique_ptr<SessionDescription> CreateOffer( |
henrike@webrtc.org | 28e2075 | 2013-07-10 00:45:36 +0000 | [diff] [blame] | 179 | const MediaSessionOptions& options, |
| 180 | const SessionDescription* current_description) const; |
Steve Anton | 6fe1fba | 2018-12-11 10:15:23 -0800 | [diff] [blame] | 181 | std::unique_ptr<SessionDescription> CreateAnswer( |
zstein | 4b2e082 | 2017-02-17 19:48:38 -0800 | [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 +0000 | [diff] [blame] | 185 | |
| 186 | private: |
ossu | 075af92 | 2016-06-14 03:29:38 -0700 | [diff] [blame] | 187 | const AudioCodecs& GetAudioCodecsForOffer( |
Steve Anton | 1d03a75 | 2017-11-27 14:30:09 -0800 | [diff] [blame] | 188 | const webrtc::RtpTransceiverDirection& direction) const; |
ossu | 075af92 | 2016-06-14 03:29:38 -0700 | [diff] [blame] | 189 | const AudioCodecs& GetAudioCodecsForAnswer( |
Steve Anton | 1d03a75 | 2017-11-27 14:30:09 -0800 | [diff] [blame] | 190 | const webrtc::RtpTransceiverDirection& offer, |
| 191 | const webrtc::RtpTransceiverDirection& answer) const; |
Steve Anton | 5c72e71 | 2018-12-10 14:25:30 -0800 | [diff] [blame] | 192 | void GetCodecsForOffer( |
| 193 | const std::vector<const ContentInfo*>& current_active_contents, |
| 194 | AudioCodecs* audio_codecs, |
| 195 | VideoCodecs* video_codecs, |
Harald Alvestrand | 5fc28b1 | 2019-05-13 13:36:16 +0200 | [diff] [blame] | 196 | RtpDataCodecs* rtp_data_codecs) const; |
Steve Anton | 5c72e71 | 2018-12-10 14:25:30 -0800 | [diff] [blame] | 197 | void GetCodecsForAnswer( |
| 198 | const std::vector<const ContentInfo*>& current_active_contents, |
| 199 | const SessionDescription& remote_offer, |
| 200 | AudioCodecs* audio_codecs, |
| 201 | VideoCodecs* video_codecs, |
Harald Alvestrand | 5fc28b1 | 2019-05-13 13:36:16 +0200 | [diff] [blame] | 202 | RtpDataCodecs* rtp_data_codecs) const; |
Steve Anton | 5c72e71 | 2018-12-10 14:25:30 -0800 | [diff] [blame] | 203 | void GetRtpHdrExtsToOffer( |
| 204 | const std::vector<const ContentInfo*>& current_active_contents, |
Steve Anton | 5c72e71 | 2018-12-10 14:25:30 -0800 | [diff] [blame] | 205 | RtpHeaderExtensions* audio_extensions, |
| 206 | RtpHeaderExtensions* video_extensions) const; |
Yves Gerey | 665174f | 2018-06-19 15:03:05 +0200 | [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 07:47:12 +0200 | [diff] [blame] | 210 | SessionDescription* offer, |
| 211 | IceCredentialsIterator* ice_credentials) const; |
henrike@webrtc.org | 28e2075 | 2013-07-10 00:45:36 +0000 | [diff] [blame] | 212 | |
Steve Anton | 1a9d3c3 | 2018-12-10 17:18:54 -0800 | [diff] [blame] | 213 | std::unique_ptr<TransportDescription> CreateTransportAnswer( |
henrike@webrtc.org | 28e2075 | 2013-07-10 00:45:36 +0000 | [diff] [blame] | 214 | const std::string& content_name, |
| 215 | const SessionDescription* offer_desc, |
| 216 | const TransportOptions& transport_options, |
deadbeef | b789253 | 2017-02-22 19:35:18 -0800 | [diff] [blame] | 217 | const SessionDescription* current_desc, |
Jonas Oreland | 1cd39fa | 2018-10-11 07:47:12 +0200 | [diff] [blame] | 218 | bool require_transport_attributes, |
| 219 | IceCredentialsIterator* ice_credentials) const; |
henrike@webrtc.org | 28e2075 | 2013-07-10 00:45:36 +0000 | [diff] [blame] | 220 | |
Yves Gerey | 665174f | 2018-06-19 15:03:05 +0200 | [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 +0000 | [diff] [blame] | 224 | |
jiayl@webrtc.org | e7d47a1 | 2014-08-05 19:19:05 +0000 | [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 14:10:50 -0700 | [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 +0000 | [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 07:47:12 +0200 | [diff] [blame] | 237 | SessionDescription* desc, |
| 238 | IceCredentialsIterator* ice_credentials) const; |
jiayl@webrtc.org | e7d47a1 | 2014-08-05 19:19:05 +0000 | [diff] [blame] | 239 | |
| 240 | bool AddVideoContentForOffer( |
zhihuang | 1c378ed | 2017-08-17 14:10:50 -0700 | [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 +0000 | [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 07:47:12 +0200 | [diff] [blame] | 248 | SessionDescription* desc, |
| 249 | IceCredentialsIterator* ice_credentials) const; |
jiayl@webrtc.org | e7d47a1 | 2014-08-05 19:19:05 +0000 | [diff] [blame] | 250 | |
Harald Alvestrand | 5fc28b1 | 2019-05-13 13:36:16 +0200 | [diff] [blame] | 251 | bool AddSctpDataContentForOffer( |
| 252 | const MediaDescriptionOptions& media_description_options, |
| 253 | const MediaSessionOptions& session_options, |
| 254 | const ContentInfo* current_content, |
| 255 | const SessionDescription* current_description, |
| 256 | StreamParamsVec* current_streams, |
| 257 | SessionDescription* desc, |
| 258 | IceCredentialsIterator* ice_credentials) const; |
| 259 | bool AddRtpDataContentForOffer( |
| 260 | const MediaDescriptionOptions& media_description_options, |
| 261 | const MediaSessionOptions& session_options, |
| 262 | const ContentInfo* current_content, |
| 263 | const SessionDescription* current_description, |
| 264 | const RtpDataCodecs& rtp_data_codecs, |
| 265 | StreamParamsVec* current_streams, |
| 266 | SessionDescription* desc, |
| 267 | IceCredentialsIterator* ice_credentials) const; |
| 268 | // This function calls either AddRtpDataContentForOffer or |
| 269 | // AddSctpDataContentForOffer depending on protocol. |
| 270 | // The codecs argument is ignored for SCTP. |
jiayl@webrtc.org | e7d47a1 | 2014-08-05 19:19:05 +0000 | [diff] [blame] | 271 | bool AddDataContentForOffer( |
zhihuang | 1c378ed | 2017-08-17 14:10:50 -0700 | [diff] [blame] | 272 | const MediaDescriptionOptions& media_description_options, |
| 273 | const MediaSessionOptions& session_options, |
| 274 | const ContentInfo* current_content, |
jiayl@webrtc.org | e7d47a1 | 2014-08-05 19:19:05 +0000 | [diff] [blame] | 275 | const SessionDescription* current_description, |
Harald Alvestrand | 5fc28b1 | 2019-05-13 13:36:16 +0200 | [diff] [blame] | 276 | const RtpDataCodecs& rtp_data_codecs, |
jiayl@webrtc.org | e7d47a1 | 2014-08-05 19:19:05 +0000 | [diff] [blame] | 277 | StreamParamsVec* current_streams, |
Jonas Oreland | 1cd39fa | 2018-10-11 07:47:12 +0200 | [diff] [blame] | 278 | SessionDescription* desc, |
| 279 | IceCredentialsIterator* ice_credentials) const; |
jiayl@webrtc.org | e7d47a1 | 2014-08-05 19:19:05 +0000 | [diff] [blame] | 280 | |
zhihuang | 1c378ed | 2017-08-17 14:10:50 -0700 | [diff] [blame] | 281 | bool AddAudioContentForAnswer( |
| 282 | const MediaDescriptionOptions& media_description_options, |
| 283 | const MediaSessionOptions& session_options, |
| 284 | const ContentInfo* offer_content, |
| 285 | const SessionDescription* offer_description, |
| 286 | const ContentInfo* current_content, |
| 287 | const SessionDescription* current_description, |
| 288 | const TransportInfo* bundle_transport, |
| 289 | const AudioCodecs& audio_codecs, |
| 290 | StreamParamsVec* current_streams, |
Jonas Oreland | 1cd39fa | 2018-10-11 07:47:12 +0200 | [diff] [blame] | 291 | SessionDescription* answer, |
| 292 | IceCredentialsIterator* ice_credentials) const; |
jiayl@webrtc.org | e7d47a1 | 2014-08-05 19:19:05 +0000 | [diff] [blame] | 293 | |
zhihuang | 1c378ed | 2017-08-17 14:10:50 -0700 | [diff] [blame] | 294 | bool AddVideoContentForAnswer( |
| 295 | const MediaDescriptionOptions& media_description_options, |
| 296 | const MediaSessionOptions& session_options, |
| 297 | const ContentInfo* offer_content, |
| 298 | const SessionDescription* offer_description, |
| 299 | const ContentInfo* current_content, |
| 300 | const SessionDescription* current_description, |
| 301 | const TransportInfo* bundle_transport, |
| 302 | const VideoCodecs& video_codecs, |
| 303 | StreamParamsVec* current_streams, |
Jonas Oreland | 1cd39fa | 2018-10-11 07:47:12 +0200 | [diff] [blame] | 304 | SessionDescription* answer, |
| 305 | IceCredentialsIterator* ice_credentials) const; |
jiayl@webrtc.org | e7d47a1 | 2014-08-05 19:19:05 +0000 | [diff] [blame] | 306 | |
zhihuang | 1c378ed | 2017-08-17 14:10:50 -0700 | [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, |
Harald Alvestrand | 5fc28b1 | 2019-05-13 13:36:16 +0200 | [diff] [blame] | 315 | const RtpDataCodecs& rtp_data_codecs, |
zhihuang | 1c378ed | 2017-08-17 14:10:50 -0700 | [diff] [blame] | 316 | StreamParamsVec* current_streams, |
Jonas Oreland | 1cd39fa | 2018-10-11 07:47:12 +0200 | [diff] [blame] | 317 | SessionDescription* answer, |
| 318 | IceCredentialsIterator* ice_credentials) const; |
zhihuang | 1c378ed | 2017-08-17 14:10:50 -0700 | [diff] [blame] | 319 | |
| 320 | void ComputeAudioCodecsIntersectionAndUnion(); |
jiayl@webrtc.org | e7d47a1 | 2014-08-05 19:19:05 +0000 | [diff] [blame] | 321 | |
Steve Anton | 8f66ddb | 2018-12-10 16:08:05 -0800 | [diff] [blame] | 322 | bool is_unified_plan_ = false; |
ossu | 075af92 | 2016-06-14 03:29:38 -0700 | [diff] [blame] | 323 | AudioCodecs audio_send_codecs_; |
| 324 | AudioCodecs audio_recv_codecs_; |
zhihuang | 1c378ed | 2017-08-17 14:10:50 -0700 | [diff] [blame] | 325 | // Intersection of send and recv. |
ossu | 075af92 | 2016-06-14 03:29:38 -0700 | [diff] [blame] | 326 | AudioCodecs audio_sendrecv_codecs_; |
zhihuang | 1c378ed | 2017-08-17 14:10:50 -0700 | [diff] [blame] | 327 | // Union of send and recv. |
| 328 | AudioCodecs all_audio_codecs_; |
henrike@webrtc.org | 28e2075 | 2013-07-10 00:45:36 +0000 | [diff] [blame] | 329 | RtpHeaderExtensions audio_rtp_extensions_; |
| 330 | VideoCodecs video_codecs_; |
| 331 | RtpHeaderExtensions video_rtp_extensions_; |
Harald Alvestrand | 5fc28b1 | 2019-05-13 13:36:16 +0200 | [diff] [blame] | 332 | RtpDataCodecs rtp_data_codecs_; |
Amit Hilbuch | bcd39d4 | 2019-01-25 17:13:56 -0800 | [diff] [blame] | 333 | // This object is not owned by the channel so it must outlive it. |
| 334 | rtc::UniqueRandomIdGenerator* const ssrc_generator_; |
jbauch | 5869f50 | 2017-06-29 12:31:36 -0700 | [diff] [blame] | 335 | bool enable_encrypted_rtp_header_extensions_ = false; |
zhihuang | 1c378ed | 2017-08-17 14:10:50 -0700 | [diff] [blame] | 336 | // TODO(zhihuang): Rename secure_ to sdec_policy_; rename the related getter |
| 337 | // and setter. |
| 338 | SecurePolicy secure_ = SEC_DISABLED; |
henrike@webrtc.org | 28e2075 | 2013-07-10 00:45:36 +0000 | [diff] [blame] | 339 | const TransportDescriptionFactory* transport_desc_factory_; |
| 340 | }; |
| 341 | |
| 342 | // Convenience functions. |
| 343 | bool IsMediaContent(const ContentInfo* content); |
| 344 | bool IsAudioContent(const ContentInfo* content); |
| 345 | bool IsVideoContent(const ContentInfo* content); |
| 346 | bool IsDataContent(const ContentInfo* content); |
deadbeef | 0ed85b2 | 2016-02-23 17:24:52 -0800 | [diff] [blame] | 347 | const ContentInfo* GetFirstMediaContent(const ContentInfos& contents, |
| 348 | MediaType media_type); |
henrike@webrtc.org | 28e2075 | 2013-07-10 00:45:36 +0000 | [diff] [blame] | 349 | const ContentInfo* GetFirstAudioContent(const ContentInfos& contents); |
| 350 | const ContentInfo* GetFirstVideoContent(const ContentInfos& contents); |
| 351 | const ContentInfo* GetFirstDataContent(const ContentInfos& contents); |
Steve Anton | ad7bffc | 2018-01-22 10:21:56 -0800 | [diff] [blame] | 352 | const ContentInfo* GetFirstMediaContent(const SessionDescription* sdesc, |
| 353 | MediaType media_type); |
henrike@webrtc.org | 28e2075 | 2013-07-10 00:45:36 +0000 | [diff] [blame] | 354 | const ContentInfo* GetFirstAudioContent(const SessionDescription* sdesc); |
| 355 | const ContentInfo* GetFirstVideoContent(const SessionDescription* sdesc); |
| 356 | const ContentInfo* GetFirstDataContent(const SessionDescription* sdesc); |
| 357 | const AudioContentDescription* GetFirstAudioContentDescription( |
| 358 | const SessionDescription* sdesc); |
| 359 | const VideoContentDescription* GetFirstVideoContentDescription( |
| 360 | const SessionDescription* sdesc); |
Harald Alvestrand | 5fc28b1 | 2019-05-13 13:36:16 +0200 | [diff] [blame] | 361 | const RtpDataContentDescription* GetFirstRtpDataContentDescription( |
| 362 | const SessionDescription* sdesc); |
| 363 | const SctpDataContentDescription* GetFirstSctpDataContentDescription( |
| 364 | const SessionDescription* sdesc); |
| 365 | // Returns shim. Deprecated - ask for the right protocol instead. |
Harald Alvestrand | a33a860 | 2019-05-28 11:33:50 +0200 | [diff] [blame] | 366 | RTC_DEPRECATED const DataContentDescription* GetFirstDataContentDescription( |
henrike@webrtc.org | 28e2075 | 2013-07-10 00:45:36 +0000 | [diff] [blame] | 367 | const SessionDescription* sdesc); |
Taylor Brandstetter | dc4eb8c | 2016-05-12 08:14:50 -0700 | [diff] [blame] | 368 | // Non-const versions of the above functions. |
| 369 | // Useful when modifying an existing description. |
Steve Anton | 36b29d1 | 2017-10-30 09:57:42 -0700 | [diff] [blame] | 370 | ContentInfo* GetFirstMediaContent(ContentInfos* contents, MediaType media_type); |
| 371 | ContentInfo* GetFirstAudioContent(ContentInfos* contents); |
| 372 | ContentInfo* GetFirstVideoContent(ContentInfos* contents); |
| 373 | ContentInfo* GetFirstDataContent(ContentInfos* contents); |
Steve Anton | ad7bffc | 2018-01-22 10:21:56 -0800 | [diff] [blame] | 374 | ContentInfo* GetFirstMediaContent(SessionDescription* sdesc, |
| 375 | MediaType media_type); |
Taylor Brandstetter | dc4eb8c | 2016-05-12 08:14:50 -0700 | [diff] [blame] | 376 | ContentInfo* GetFirstAudioContent(SessionDescription* sdesc); |
| 377 | ContentInfo* GetFirstVideoContent(SessionDescription* sdesc); |
| 378 | ContentInfo* GetFirstDataContent(SessionDescription* sdesc); |
| 379 | AudioContentDescription* GetFirstAudioContentDescription( |
| 380 | SessionDescription* sdesc); |
| 381 | VideoContentDescription* GetFirstVideoContentDescription( |
| 382 | SessionDescription* sdesc); |
Harald Alvestrand | 5fc28b1 | 2019-05-13 13:36:16 +0200 | [diff] [blame] | 383 | RtpDataContentDescription* GetFirstRtpDataContentDescription( |
| 384 | SessionDescription* sdesc); |
| 385 | SctpDataContentDescription* GetFirstSctpDataContentDescription( |
| 386 | SessionDescription* sdesc); |
Harald Alvestrand | a33a860 | 2019-05-28 11:33:50 +0200 | [diff] [blame] | 387 | RTC_DEPRECATED DataContentDescription* GetFirstDataContentDescription( |
Taylor Brandstetter | dc4eb8c | 2016-05-12 08:14:50 -0700 | [diff] [blame] | 388 | SessionDescription* sdesc); |
henrike@webrtc.org | 28e2075 | 2013-07-10 00:45:36 +0000 | [diff] [blame] | 389 | |
deadbeef | 7914b8c | 2017-04-21 03:23:33 -0700 | [diff] [blame] | 390 | // Helper functions to return crypto suites used for SDES. |
Benjamin Wright | a54daf1 | 2018-10-11 15:33:17 -0700 | [diff] [blame] | 391 | void GetSupportedAudioSdesCryptoSuites( |
| 392 | const webrtc::CryptoOptions& crypto_options, |
| 393 | std::vector<int>* crypto_suites); |
| 394 | void GetSupportedVideoSdesCryptoSuites( |
| 395 | const webrtc::CryptoOptions& crypto_options, |
| 396 | std::vector<int>* crypto_suites); |
| 397 | void GetSupportedDataSdesCryptoSuites( |
| 398 | const webrtc::CryptoOptions& crypto_options, |
| 399 | std::vector<int>* crypto_suites); |
deadbeef | 7914b8c | 2017-04-21 03:23:33 -0700 | [diff] [blame] | 400 | void GetSupportedAudioSdesCryptoSuiteNames( |
Benjamin Wright | a54daf1 | 2018-10-11 15:33:17 -0700 | [diff] [blame] | 401 | const webrtc::CryptoOptions& crypto_options, |
Guo-wei Shieh | 521ed7b | 2015-11-18 19:41:53 -0800 | [diff] [blame] | 402 | std::vector<std::string>* crypto_suite_names); |
deadbeef | 7914b8c | 2017-04-21 03:23:33 -0700 | [diff] [blame] | 403 | void GetSupportedVideoSdesCryptoSuiteNames( |
Benjamin Wright | a54daf1 | 2018-10-11 15:33:17 -0700 | [diff] [blame] | 404 | const webrtc::CryptoOptions& crypto_options, |
Guo-wei Shieh | 521ed7b | 2015-11-18 19:41:53 -0800 | [diff] [blame] | 405 | std::vector<std::string>* crypto_suite_names); |
deadbeef | 7914b8c | 2017-04-21 03:23:33 -0700 | [diff] [blame] | 406 | void GetSupportedDataSdesCryptoSuiteNames( |
Benjamin Wright | a54daf1 | 2018-10-11 15:33:17 -0700 | [diff] [blame] | 407 | const webrtc::CryptoOptions& crypto_options, |
Guo-wei Shieh | 521ed7b | 2015-11-18 19:41:53 -0800 | [diff] [blame] | 408 | std::vector<std::string>* crypto_suite_names); |
| 409 | |
henrike@webrtc.org | 28e2075 | 2013-07-10 00:45:36 +0000 | [diff] [blame] | 410 | } // namespace cricket |
| 411 | |
Steve Anton | 10542f2 | 2019-01-11 09:11:00 -0800 | [diff] [blame] | 412 | #endif // PC_MEDIA_SESSION_H_ |