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