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