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