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