blob: 596bd18ad1432cdc8702d80707e15787f479434a [file] [log] [blame]
henrike@webrtc.org28e20752013-07-10 00:45:361/*
kjellander65c7f672016-02-12 08:05:012 * Copyright 2004 The WebRTC project authors. All Rights Reserved.
henrike@webrtc.org28e20752013-07-10 00:45:363 *
kjellander65c7f672016-02-12 08:05:014 * 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.org28e20752013-07-10 00:45:369 */
10
11// Types and classes used in media session descriptions.
12
terelius8c011e52016-04-26 12:28:1113#ifndef WEBRTC_PC_MEDIASESSION_H_
14#define WEBRTC_PC_MEDIASESSION_H_
henrike@webrtc.org28e20752013-07-10 00:45:3615
buildbot@webrtc.orga09a9992014-08-13 17:26:0816#include <algorithm>
deadbeef0ed85b22016-02-24 01:24:5217#include <map>
henrike@webrtc.org28e20752013-07-10 00:45:3618#include <string>
19#include <vector>
henrike@webrtc.org28e20752013-07-10 00:45:3620
ossu7bb87ee2017-01-23 12:56:2521#include "webrtc/api/mediatypes.h"
kjellandera96e2d72016-02-05 07:52:2822#include "webrtc/media/base/codec.h"
kjellandera96e2d72016-02-05 07:52:2823#include "webrtc/media/base/cryptoparams.h"
24#include "webrtc/media/base/mediachannel.h"
kjellanderf4752772016-03-02 13:42:3025#include "webrtc/media/base/mediaconstants.h"
kjellandera96e2d72016-02-05 07:52:2826#include "webrtc/media/base/mediaengine.h" // For DataChannelType
27#include "webrtc/media/base/streamparams.h"
henrike@webrtc.org269fb4b2014-10-28 22:20:1128#include "webrtc/p2p/base/sessiondescription.h"
deadbeef49f34fd2016-12-07 00:22:0629#include "webrtc/p2p/base/jseptransport.h"
henrike@webrtc.org269fb4b2014-10-28 22:20:1130#include "webrtc/p2p/base/transportdescriptionfactory.h"
henrike@webrtc.org28e20752013-07-10 00:45:3631
32namespace cricket {
33
34class ChannelManager;
35typedef std::vector<AudioCodec> AudioCodecs;
36typedef std::vector<VideoCodec> VideoCodecs;
37typedef std::vector<DataCodec> DataCodecs;
38typedef std::vector<CryptoParams> CryptoParamsVec;
isheriff6f8d6862016-05-26 18:24:5539typedef std::vector<webrtc::RtpExtension> RtpHeaderExtensions;
henrike@webrtc.org28e20752013-07-10 00:45:3640
henrike@webrtc.org28e20752013-07-10 00:45:3641enum MediaContentDirection {
42 MD_INACTIVE,
43 MD_SENDONLY,
44 MD_RECVONLY,
45 MD_SENDRECV
46};
47
ossu075af922016-06-14 10:29:3848std::string MediaContentDirectionToString(MediaContentDirection direction);
49
henrike@webrtc.orgb90991d2014-03-04 19:54:5750enum CryptoType {
51 CT_NONE,
52 CT_SDES,
53 CT_DTLS
54};
55
henrike@webrtc.org28e20752013-07-10 00:45:3656// RTC4585 RTP/AVPF
57extern const char kMediaProtocolAvpf[];
58// RFC5124 RTP/SAVPF
59extern const char kMediaProtocolSavpf[];
60
jiayl@webrtc.org8dcd43c2014-05-29 22:07:5961extern const char kMediaProtocolDtlsSavpf[];
62
henrike@webrtc.org28e20752013-07-10 00:45:3663extern const char kMediaProtocolRtpPrefix[];
64
65extern const char kMediaProtocolSctp[];
66extern const char kMediaProtocolDtlsSctp[];
lally@webrtc.orgec97c652015-02-24 20:18:4867extern const char kMediaProtocolUdpDtlsSctp[];
lally@webrtc.orga7470932015-02-24 20:19:2168extern const char kMediaProtocolTcpDtlsSctp[];
henrike@webrtc.org28e20752013-07-10 00:45:3669
70// Options to control how session descriptions are generated.
71const int kAutoBandwidth = -1;
72const int kBufferedModeDisabled = 0;
henrike@webrtc.org28e20752013-07-10 00:45:3673
zhihuang8f65cdf2016-05-07 01:40:3074// Default RTCP CNAME for unit tests.
75const char kDefaultRtcpCname[] = "DefaultRtcpCname";
76
ossu075af922016-06-14 10:29:3877struct RtpTransceiverDirection {
78 bool send;
79 bool recv;
80
81 RtpTransceiverDirection(bool send, bool recv) : send(send), recv(recv) {}
82
83 bool operator==(const RtpTransceiverDirection& o) const {
84 return send == o.send && recv == o.recv;
85 }
86
87 bool operator!=(const RtpTransceiverDirection& o) const {
88 return !(*this == o);
89 }
90
91 static RtpTransceiverDirection FromMediaContentDirection(
92 MediaContentDirection md);
93
94 MediaContentDirection ToMediaContentDirection() const;
deadbeefe814a0d2017-02-26 02:15:0995
96 RtpTransceiverDirection Reversed() const {
97 return RtpTransceiverDirection(recv, send);
98 }
ossu075af922016-06-14 10:29:3899};
100
101RtpTransceiverDirection
102NegotiateRtpTransceiverDirection(RtpTransceiverDirection offer,
103 RtpTransceiverDirection wants);
104
zhihuanga77e6bb2017-08-15 01:17:48105struct MediaSessionOptions {
olka3c747662017-08-17 13:50:32106 MediaSessionOptions()
107 : recv_audio(true),
108 recv_video(false),
109 data_channel_type(DCT_NONE),
110 is_muc(false),
111 vad_enabled(true), // When disabled, removes all CN codecs from SDP.
112 rtcp_mux_enabled(true),
113 bundle_enabled(false),
114 video_bandwidth(kAutoBandwidth),
115 data_bandwidth(kDataMaxBandwidth),
116 rtcp_cname(kDefaultRtcpCname) {}
jiayl@webrtc.org742922b2014-10-07 21:32:43117
olka3c747662017-08-17 13:50:32118 bool has_audio() const {
119 return recv_audio || HasSendMediaStream(MEDIA_TYPE_AUDIO);
120 }
121 bool has_video() const {
122 return recv_video || HasSendMediaStream(MEDIA_TYPE_VIDEO);
123 }
124 bool has_data() const { return data_channel_type != DCT_NONE; }
zhihuanga77e6bb2017-08-15 01:17:48125
olka3c747662017-08-17 13:50:32126 // Add a stream with MediaType type and id.
127 // All streams with the same sync_label will get the same CNAME.
128 // All ids must be unique.
129 void AddSendStream(MediaType type,
130 const std::string& id,
131 const std::string& sync_label);
132 void AddSendVideoStream(const std::string& id,
133 const std::string& sync_label,
134 int num_sim_layers);
135 void RemoveSendStream(MediaType type, const std::string& id);
zhihuanga77e6bb2017-08-15 01:17:48136
olka3c747662017-08-17 13:50:32137
138 // Helper function.
139 void AddSendStreamInternal(MediaType type,
140 const std::string& id,
141 const std::string& sync_label,
142 int num_sim_layers);
143
144 bool HasSendMediaStream(MediaType type) const;
145
146 // TODO(deadbeef): Put all the audio/video/data-specific options into a map
147 // structure (content name -> options).
148 // MediaSessionDescriptionFactory assumes there will never be more than one
149 // audio/video/data content, but this will change with unified plan.
150 bool recv_audio;
151 bool recv_video;
152 DataChannelType data_channel_type;
153 bool is_muc;
154 bool vad_enabled;
155 bool rtcp_mux_enabled;
156 bool bundle_enabled;
157 // bps. -1 == auto.
158 int video_bandwidth;
159 int data_bandwidth;
160 bool enable_ice_renomination = false;
161 // content name ("mid") => options.
162 std::map<std::string, TransportOptions> transport_options;
163 std::string rtcp_cname;
jbauchcb560652016-08-04 12:20:32164 rtc::CryptoOptions crypto_options;
olka3c747662017-08-17 13:50:32165
166 struct Stream {
167 Stream(MediaType type,
168 const std::string& id,
169 const std::string& sync_label,
170 int num_sim_layers)
171 : type(type), id(id), sync_label(sync_label),
172 num_sim_layers(num_sim_layers) {
173 }
174 MediaType type;
175 std::string id;
176 std::string sync_label;
177 int num_sim_layers;
178 };
179
180 typedef std::vector<Stream> Streams;
181 Streams streams;
henrike@webrtc.org28e20752013-07-10 00:45:36182};
183
184// "content" (as used in XEP-0166) descriptions for voice and video.
185class MediaContentDescription : public ContentDescription {
186 public:
deadbeef13871492015-12-09 20:37:51187 MediaContentDescription() {}
henrike@webrtc.org28e20752013-07-10 00:45:36188
189 virtual MediaType type() const = 0;
190 virtual bool has_codecs() const = 0;
191
192 // |protocol| is the expected media transport protocol, such as RTP/AVPF,
193 // RTP/SAVPF or SCTP/DTLS.
194 std::string protocol() const { return protocol_; }
195 void set_protocol(const std::string& protocol) { protocol_ = protocol; }
196
197 MediaContentDirection direction() const { return direction_; }
198 void set_direction(MediaContentDirection direction) {
199 direction_ = direction;
200 }
201
202 bool rtcp_mux() const { return rtcp_mux_; }
203 void set_rtcp_mux(bool mux) { rtcp_mux_ = mux; }
204
deadbeef13871492015-12-09 20:37:51205 bool rtcp_reduced_size() const { return rtcp_reduced_size_; }
206 void set_rtcp_reduced_size(bool reduced_size) {
207 rtcp_reduced_size_ = reduced_size;
208 }
209
henrike@webrtc.org28e20752013-07-10 00:45:36210 int bandwidth() const { return bandwidth_; }
211 void set_bandwidth(int bandwidth) { bandwidth_ = bandwidth; }
212
213 const std::vector<CryptoParams>& cryptos() const { return cryptos_; }
214 void AddCrypto(const CryptoParams& params) {
215 cryptos_.push_back(params);
216 }
217 void set_cryptos(const std::vector<CryptoParams>& cryptos) {
218 cryptos_ = cryptos;
219 }
henrike@webrtc.orgb90991d2014-03-04 19:54:57220
221 CryptoType crypto_required() const { return crypto_required_; }
222 void set_crypto_required(CryptoType type) {
223 crypto_required_ = type;
henrike@webrtc.org28e20752013-07-10 00:45:36224 }
225
226 const RtpHeaderExtensions& rtp_header_extensions() const {
227 return rtp_header_extensions_;
228 }
229 void set_rtp_header_extensions(const RtpHeaderExtensions& extensions) {
230 rtp_header_extensions_ = extensions;
231 rtp_header_extensions_set_ = true;
232 }
isheriff6f8d6862016-05-26 18:24:55233 void AddRtpHeaderExtension(const webrtc::RtpExtension& ext) {
henrike@webrtc.org28e20752013-07-10 00:45:36234 rtp_header_extensions_.push_back(ext);
235 rtp_header_extensions_set_ = true;
236 }
isheriffa1c548b2016-05-31 23:12:24237 void AddRtpHeaderExtension(const cricket::RtpHeaderExtension& ext) {
238 webrtc::RtpExtension webrtc_extension;
239 webrtc_extension.uri = ext.uri;
240 webrtc_extension.id = ext.id;
241 rtp_header_extensions_.push_back(webrtc_extension);
242 rtp_header_extensions_set_ = true;
243 }
henrike@webrtc.org28e20752013-07-10 00:45:36244 void ClearRtpHeaderExtensions() {
245 rtp_header_extensions_.clear();
246 rtp_header_extensions_set_ = true;
247 }
248 // We can't always tell if an empty list of header extensions is
249 // because the other side doesn't support them, or just isn't hooked up to
250 // signal them. For now we assume an empty list means no signaling, but
251 // provide the ClearRtpHeaderExtensions method to allow "no support" to be
252 // clearly indicated (i.e. when derived from other information).
253 bool rtp_header_extensions_set() const {
254 return rtp_header_extensions_set_;
255 }
256 // True iff the client supports multiple streams.
257 void set_multistream(bool multistream) { multistream_ = multistream; }
258 bool multistream() const { return multistream_; }
259 const StreamParamsVec& streams() const {
260 return streams_;
261 }
262 // TODO(pthatcher): Remove this by giving mediamessage.cc access
263 // to MediaContentDescription
264 StreamParamsVec& mutable_streams() {
265 return streams_;
266 }
267 void AddStream(const StreamParams& stream) {
268 streams_.push_back(stream);
269 }
270 // Legacy streams have an ssrc, but nothing else.
Peter Boström0c4e06b2015-10-07 10:23:21271 void AddLegacyStream(uint32_t ssrc) {
henrike@webrtc.org28e20752013-07-10 00:45:36272 streams_.push_back(StreamParams::CreateLegacy(ssrc));
273 }
Peter Boström0c4e06b2015-10-07 10:23:21274 void AddLegacyStream(uint32_t ssrc, uint32_t fid_ssrc) {
henrike@webrtc.org28e20752013-07-10 00:45:36275 StreamParams sp = StreamParams::CreateLegacy(ssrc);
276 sp.AddFidSsrc(ssrc, fid_ssrc);
277 streams_.push_back(sp);
278 }
279 // Sets the CNAME of all StreamParams if it have not been set.
olka3c747662017-08-17 13:50:32280 // This can be used to set the CNAME of legacy streams.
henrike@webrtc.org28e20752013-07-10 00:45:36281 void SetCnameIfEmpty(const std::string& cname) {
282 for (cricket::StreamParamsVec::iterator it = streams_.begin();
283 it != streams_.end(); ++it) {
284 if (it->cname.empty())
285 it->cname = cname;
286 }
287 }
Peter Boström0c4e06b2015-10-07 10:23:21288 uint32_t first_ssrc() const {
henrike@webrtc.org28e20752013-07-10 00:45:36289 if (streams_.empty()) {
290 return 0;
291 }
292 return streams_[0].first_ssrc();
293 }
294 bool has_ssrcs() const {
295 if (streams_.empty()) {
296 return false;
297 }
298 return streams_[0].has_ssrcs();
299 }
300
301 void set_conference_mode(bool enable) { conference_mode_ = enable; }
302 bool conference_mode() const { return conference_mode_; }
303
304 void set_partial(bool partial) { partial_ = partial; }
305 bool partial() const { return partial_; }
306
307 void set_buffered_mode_latency(int latency) {
308 buffered_mode_latency_ = latency;
309 }
310 int buffered_mode_latency() const { return buffered_mode_latency_; }
311
zhihuang38989e52017-03-21 18:04:53312 // https://tools.ietf.org/html/rfc4566#section-5.7
313 // May be present at the media or session level of SDP. If present at both
314 // levels, the media-level attribute overwrites the session-level one.
315 void set_connection_address(const rtc::SocketAddress& address) {
316 connection_address_ = address;
317 }
318 const rtc::SocketAddress& connection_address() const {
319 return connection_address_;
320 }
321
henrike@webrtc.org28e20752013-07-10 00:45:36322 protected:
deadbeef13871492015-12-09 20:37:51323 bool rtcp_mux_ = false;
324 bool rtcp_reduced_size_ = false;
325 int bandwidth_ = kAutoBandwidth;
henrike@webrtc.org28e20752013-07-10 00:45:36326 std::string protocol_;
327 std::vector<CryptoParams> cryptos_;
deadbeef13871492015-12-09 20:37:51328 CryptoType crypto_required_ = CT_NONE;
isheriff6f8d6862016-05-26 18:24:55329 std::vector<webrtc::RtpExtension> rtp_header_extensions_;
deadbeef13871492015-12-09 20:37:51330 bool rtp_header_extensions_set_ = false;
331 bool multistream_ = false;
henrike@webrtc.org28e20752013-07-10 00:45:36332 StreamParamsVec streams_;
deadbeef13871492015-12-09 20:37:51333 bool conference_mode_ = false;
334 bool partial_ = false;
335 int buffered_mode_latency_ = kBufferedModeDisabled;
336 MediaContentDirection direction_ = MD_SENDRECV;
zhihuang38989e52017-03-21 18:04:53337 rtc::SocketAddress connection_address_;
henrike@webrtc.org28e20752013-07-10 00:45:36338};
339
340template <class C>
341class MediaContentDescriptionImpl : public MediaContentDescription {
342 public:
deadbeef67cf2c12016-04-13 17:07:16343 typedef C CodecType;
henrike@webrtc.org28e20752013-07-10 00:45:36344
deadbeef67cf2c12016-04-13 17:07:16345 // Codecs should be in preference order (most preferred codec first).
henrike@webrtc.org28e20752013-07-10 00:45:36346 const std::vector<C>& codecs() const { return codecs_; }
347 void set_codecs(const std::vector<C>& codecs) { codecs_ = codecs; }
348 virtual bool has_codecs() const { return !codecs_.empty(); }
349 bool HasCodec(int id) {
350 bool found = false;
351 for (typename std::vector<C>::iterator iter = codecs_.begin();
352 iter != codecs_.end(); ++iter) {
353 if (iter->id == id) {
354 found = true;
355 break;
356 }
357 }
358 return found;
359 }
360 void AddCodec(const C& codec) {
361 codecs_.push_back(codec);
362 }
jiayl@webrtc.org9c16c392014-05-01 18:30:30363 void AddOrReplaceCodec(const C& codec) {
364 for (typename std::vector<C>::iterator iter = codecs_.begin();
365 iter != codecs_.end(); ++iter) {
366 if (iter->id == codec.id) {
367 *iter = codec;
368 return;
369 }
370 }
371 AddCodec(codec);
372 }
henrike@webrtc.org28e20752013-07-10 00:45:36373 void AddCodecs(const std::vector<C>& codecs) {
374 typename std::vector<C>::const_iterator codec;
375 for (codec = codecs.begin(); codec != codecs.end(); ++codec) {
376 AddCodec(*codec);
377 }
378 }
henrike@webrtc.org28e20752013-07-10 00:45:36379
380 private:
381 std::vector<C> codecs_;
382};
383
384class AudioContentDescription : public MediaContentDescriptionImpl<AudioCodec> {
385 public:
386 AudioContentDescription() :
387 agc_minus_10db_(false) {}
388
389 virtual ContentDescription* Copy() const {
390 return new AudioContentDescription(*this);
391 }
392 virtual MediaType type() const { return MEDIA_TYPE_AUDIO; }
393
394 const std::string &lang() const { return lang_; }
395 void set_lang(const std::string &lang) { lang_ = lang; }
396
397 bool agc_minus_10db() const { return agc_minus_10db_; }
398 void set_agc_minus_10db(bool enable) {
399 agc_minus_10db_ = enable;
400 }
401
402 private:
403 bool agc_minus_10db_;
404
405 private:
406 std::string lang_;
407};
408
409class VideoContentDescription : public MediaContentDescriptionImpl<VideoCodec> {
410 public:
411 virtual ContentDescription* Copy() const {
412 return new VideoContentDescription(*this);
413 }
414 virtual MediaType type() const { return MEDIA_TYPE_VIDEO; }
415};
416
417class DataContentDescription : public MediaContentDescriptionImpl<DataCodec> {
418 public:
zstein4b2e0822017-02-18 03:48:38419 DataContentDescription() {}
420
henrike@webrtc.org28e20752013-07-10 00:45:36421 virtual ContentDescription* Copy() const {
422 return new DataContentDescription(*this);
423 }
424 virtual MediaType type() const { return MEDIA_TYPE_DATA; }
zstein4b2e0822017-02-18 03:48:38425
426 bool use_sctpmap() const { return use_sctpmap_; }
427 void set_use_sctpmap(bool enable) { use_sctpmap_ = enable; }
428
429 private:
430 bool use_sctpmap_ = true;
henrike@webrtc.org28e20752013-07-10 00:45:36431};
432
433// Creates media session descriptions according to the supplied codecs and
434// other fields, as well as the supplied per-call options.
435// When creating answers, performs the appropriate negotiation
436// of the various fields to determine the proper result.
437class MediaSessionDescriptionFactory {
438 public:
439 // Default ctor; use methods below to set configuration.
440 // The TransportDescriptionFactory is not owned by MediaSessionDescFactory,
441 // so it must be kept alive by the user of this class.
442 explicit MediaSessionDescriptionFactory(
443 const TransportDescriptionFactory* factory);
444 // This helper automatically sets up the factory to get its configuration
445 // from the specified ChannelManager.
446 MediaSessionDescriptionFactory(ChannelManager* cmanager,
447 const TransportDescriptionFactory* factory);
448
ossudedfd282016-06-14 14:12:39449 const AudioCodecs& audio_sendrecv_codecs() const;
ossu075af922016-06-14 10:29:38450 const AudioCodecs& audio_send_codecs() const;
451 const AudioCodecs& audio_recv_codecs() const;
452 void set_audio_codecs(const AudioCodecs& send_codecs,
453 const AudioCodecs& recv_codecs);
henrike@webrtc.org28e20752013-07-10 00:45:36454 void set_audio_rtp_header_extensions(const RtpHeaderExtensions& extensions) {
455 audio_rtp_extensions_ = extensions;
456 }
457 const RtpHeaderExtensions& audio_rtp_header_extensions() const {
458 return audio_rtp_extensions_;
459 }
460 const VideoCodecs& video_codecs() const { return video_codecs_; }
461 void set_video_codecs(const VideoCodecs& codecs) { video_codecs_ = codecs; }
462 void set_video_rtp_header_extensions(const RtpHeaderExtensions& extensions) {
463 video_rtp_extensions_ = extensions;
464 }
465 const RtpHeaderExtensions& video_rtp_header_extensions() const {
466 return video_rtp_extensions_;
467 }
468 const DataCodecs& data_codecs() const { return data_codecs_; }
469 void set_data_codecs(const DataCodecs& codecs) { data_codecs_ = codecs; }
470 SecurePolicy secure() const { return secure_; }
471 void set_secure(SecurePolicy s) { secure_ = s; }
olka3c747662017-08-17 13:50:32472 // Decides if a StreamParams shall be added to the audio and video media
473 // content in SessionDescription when CreateOffer and CreateAnswer is called
474 // even if |options| don't include a Stream. This is needed to support legacy
475 // applications. |add_legacy_| is true per default.
476 void set_add_legacy_streams(bool add_legacy) { add_legacy_ = add_legacy; }
henrike@webrtc.org28e20752013-07-10 00:45:36477
jbauch5869f502017-06-29 19:31:36478 void set_enable_encrypted_rtp_header_extensions(bool enable) {
479 enable_encrypted_rtp_header_extensions_ = enable;
480 }
481
henrike@webrtc.org28e20752013-07-10 00:45:36482 SessionDescription* CreateOffer(
483 const MediaSessionOptions& options,
484 const SessionDescription* current_description) const;
485 SessionDescription* CreateAnswer(
zstein4b2e0822017-02-18 03:48:38486 const SessionDescription* offer,
487 const MediaSessionOptions& options,
488 const SessionDescription* current_description) const;
henrike@webrtc.org28e20752013-07-10 00:45:36489
490 private:
ossu075af922016-06-14 10:29:38491 const AudioCodecs& GetAudioCodecsForOffer(
492 const RtpTransceiverDirection& direction) const;
493 const AudioCodecs& GetAudioCodecsForAnswer(
494 const RtpTransceiverDirection& offer,
495 const RtpTransceiverDirection& answer) const;
olka3c747662017-08-17 13:50:32496 void GetCodecsToOffer(const SessionDescription* current_description,
497 const AudioCodecs& supported_audio_codecs,
498 const VideoCodecs& supported_video_codecs,
499 const DataCodecs& supported_data_codecs,
500 AudioCodecs* audio_codecs,
501 VideoCodecs* video_codecs,
502 DataCodecs* data_codecs) const;
henrike@webrtc.org28e20752013-07-10 00:45:36503 void GetRtpHdrExtsToOffer(const SessionDescription* current_description,
504 RtpHeaderExtensions* audio_extensions,
505 RtpHeaderExtensions* video_extensions) const;
506 bool AddTransportOffer(
507 const std::string& content_name,
508 const TransportOptions& transport_options,
509 const SessionDescription* current_desc,
510 SessionDescription* offer) const;
511
512 TransportDescription* CreateTransportAnswer(
513 const std::string& content_name,
514 const SessionDescription* offer_desc,
515 const TransportOptions& transport_options,
deadbeefb7892532017-02-23 03:35:18516 const SessionDescription* current_desc,
517 bool require_transport_attributes) const;
henrike@webrtc.org28e20752013-07-10 00:45:36518
519 bool AddTransportAnswer(
520 const std::string& content_name,
521 const TransportDescription& transport_desc,
522 SessionDescription* answer_desc) const;
523
jiayl@webrtc.orge7d47a12014-08-05 19:19:05524 // Helpers for adding media contents to the SessionDescription. Returns true
525 // it succeeds or the media content is not needed, or false if there is any
526 // error.
527
528 bool AddAudioContentForOffer(
olka3c747662017-08-17 13:50:32529 const MediaSessionOptions& options,
jiayl@webrtc.orge7d47a12014-08-05 19:19:05530 const SessionDescription* current_description,
531 const RtpHeaderExtensions& audio_rtp_extensions,
532 const AudioCodecs& audio_codecs,
533 StreamParamsVec* current_streams,
534 SessionDescription* desc) const;
535
536 bool AddVideoContentForOffer(
olka3c747662017-08-17 13:50:32537 const MediaSessionOptions& options,
jiayl@webrtc.orge7d47a12014-08-05 19:19:05538 const SessionDescription* current_description,
539 const RtpHeaderExtensions& video_rtp_extensions,
540 const VideoCodecs& video_codecs,
541 StreamParamsVec* current_streams,
542 SessionDescription* desc) const;
543
544 bool AddDataContentForOffer(
olka3c747662017-08-17 13:50:32545 const MediaSessionOptions& options,
jiayl@webrtc.orge7d47a12014-08-05 19:19:05546 const SessionDescription* current_description,
olka3c747662017-08-17 13:50:32547 DataCodecs* data_codecs,
jiayl@webrtc.orge7d47a12014-08-05 19:19:05548 StreamParamsVec* current_streams,
549 SessionDescription* desc) const;
550
olka3c747662017-08-17 13:50:32551 bool AddAudioContentForAnswer(const SessionDescription* offer,
552 const MediaSessionOptions& options,
553 const SessionDescription* current_description,
554 const TransportInfo* bundle_transport,
555 StreamParamsVec* current_streams,
556 SessionDescription* answer) const;
jiayl@webrtc.orge7d47a12014-08-05 19:19:05557
olka3c747662017-08-17 13:50:32558 bool AddVideoContentForAnswer(const SessionDescription* offer,
559 const MediaSessionOptions& options,
560 const SessionDescription* current_description,
561 const TransportInfo* bundle_transport,
562 StreamParamsVec* current_streams,
563 SessionDescription* answer) const;
jiayl@webrtc.orge7d47a12014-08-05 19:19:05564
olka3c747662017-08-17 13:50:32565 bool AddDataContentForAnswer(const SessionDescription* offer,
566 const MediaSessionOptions& options,
567 const SessionDescription* current_description,
568 const TransportInfo* bundle_transport,
569 StreamParamsVec* current_streams,
570 SessionDescription* answer) const;
jiayl@webrtc.orge7d47a12014-08-05 19:19:05571
ossu075af922016-06-14 10:29:38572 AudioCodecs audio_send_codecs_;
573 AudioCodecs audio_recv_codecs_;
574 AudioCodecs audio_sendrecv_codecs_;
henrike@webrtc.org28e20752013-07-10 00:45:36575 RtpHeaderExtensions audio_rtp_extensions_;
576 VideoCodecs video_codecs_;
577 RtpHeaderExtensions video_rtp_extensions_;
578 DataCodecs data_codecs_;
olka3c747662017-08-17 13:50:32579 SecurePolicy secure_;
580 bool add_legacy_;
jbauch5869f502017-06-29 19:31:36581 bool enable_encrypted_rtp_header_extensions_ = false;
henrike@webrtc.org28e20752013-07-10 00:45:36582 std::string lang_;
583 const TransportDescriptionFactory* transport_desc_factory_;
584};
585
586// Convenience functions.
587bool IsMediaContent(const ContentInfo* content);
588bool IsAudioContent(const ContentInfo* content);
589bool IsVideoContent(const ContentInfo* content);
590bool IsDataContent(const ContentInfo* content);
deadbeef0ed85b22016-02-24 01:24:52591const ContentInfo* GetFirstMediaContent(const ContentInfos& contents,
592 MediaType media_type);
henrike@webrtc.org28e20752013-07-10 00:45:36593const ContentInfo* GetFirstAudioContent(const ContentInfos& contents);
594const ContentInfo* GetFirstVideoContent(const ContentInfos& contents);
595const ContentInfo* GetFirstDataContent(const ContentInfos& contents);
596const ContentInfo* GetFirstAudioContent(const SessionDescription* sdesc);
597const ContentInfo* GetFirstVideoContent(const SessionDescription* sdesc);
598const ContentInfo* GetFirstDataContent(const SessionDescription* sdesc);
599const AudioContentDescription* GetFirstAudioContentDescription(
600 const SessionDescription* sdesc);
601const VideoContentDescription* GetFirstVideoContentDescription(
602 const SessionDescription* sdesc);
603const DataContentDescription* GetFirstDataContentDescription(
604 const SessionDescription* sdesc);
Taylor Brandstetterdc4eb8c2016-05-12 15:14:50605// Non-const versions of the above functions.
606// Useful when modifying an existing description.
607ContentInfo* GetFirstMediaContent(ContentInfos& contents, MediaType media_type);
608ContentInfo* GetFirstAudioContent(ContentInfos& contents);
609ContentInfo* GetFirstVideoContent(ContentInfos& contents);
610ContentInfo* GetFirstDataContent(ContentInfos& contents);
611ContentInfo* GetFirstAudioContent(SessionDescription* sdesc);
612ContentInfo* GetFirstVideoContent(SessionDescription* sdesc);
613ContentInfo* GetFirstDataContent(SessionDescription* sdesc);
614AudioContentDescription* GetFirstAudioContentDescription(
615 SessionDescription* sdesc);
616VideoContentDescription* GetFirstVideoContentDescription(
617 SessionDescription* sdesc);
618DataContentDescription* GetFirstDataContentDescription(
619 SessionDescription* sdesc);
henrike@webrtc.org28e20752013-07-10 00:45:36620
deadbeef7914b8c2017-04-21 10:23:33621// Helper functions to return crypto suites used for SDES.
622void GetSupportedAudioSdesCryptoSuites(const rtc::CryptoOptions& crypto_options,
623 std::vector<int>* crypto_suites);
624void GetSupportedVideoSdesCryptoSuites(const rtc::CryptoOptions& crypto_options,
625 std::vector<int>* crypto_suites);
626void GetSupportedDataSdesCryptoSuites(const rtc::CryptoOptions& crypto_options,
627 std::vector<int>* crypto_suites);
628void GetSupportedAudioSdesCryptoSuiteNames(
629 const rtc::CryptoOptions& crypto_options,
Guo-wei Shieh521ed7b2015-11-19 03:41:53630 std::vector<std::string>* crypto_suite_names);
deadbeef7914b8c2017-04-21 10:23:33631void GetSupportedVideoSdesCryptoSuiteNames(
632 const rtc::CryptoOptions& crypto_options,
Guo-wei Shieh521ed7b2015-11-19 03:41:53633 std::vector<std::string>* crypto_suite_names);
deadbeef7914b8c2017-04-21 10:23:33634void GetSupportedDataSdesCryptoSuiteNames(
635 const rtc::CryptoOptions& crypto_options,
Guo-wei Shieh521ed7b2015-11-19 03:41:53636 std::vector<std::string>* crypto_suite_names);
637
henrike@webrtc.org28e20752013-07-10 00:45:36638} // namespace cricket
639
terelius8c011e52016-04-26 12:28:11640#endif // WEBRTC_PC_MEDIASESSION_H_