blob: 289bc35642b52372aa23ac77161cf7616c01e017 [file] [log] [blame]
henrike@webrtc.org28e20752013-07-10 00:45:36 +00001/*
kjellander65c7f672016-02-12 00:05:01 -08002 * Copyright 2004 The WebRTC project authors. All Rights Reserved.
henrike@webrtc.org28e20752013-07-10 00:45:36 +00003 *
kjellander65c7f672016-02-12 00:05:01 -08004 * 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:36 +00009 */
10
11// Types and classes used in media session descriptions.
12
terelius8c011e52016-04-26 05:28:11 -070013#ifndef WEBRTC_PC_MEDIASESSION_H_
14#define WEBRTC_PC_MEDIASESSION_H_
henrike@webrtc.org28e20752013-07-10 00:45:36 +000015
buildbot@webrtc.orga09a9992014-08-13 17:26:08 +000016#include <algorithm>
deadbeef0ed85b22016-02-23 17:24:52 -080017#include <map>
henrike@webrtc.org28e20752013-07-10 00:45:36 +000018#include <string>
19#include <vector>
henrike@webrtc.org28e20752013-07-10 00:45:36 +000020
kjellandera96e2d72016-02-04 23:52:28 -080021#include "webrtc/media/base/codec.h"
kjellandera96e2d72016-02-04 23:52:28 -080022#include "webrtc/media/base/cryptoparams.h"
23#include "webrtc/media/base/mediachannel.h"
kjellanderf4752772016-03-02 05:42:30 -080024#include "webrtc/media/base/mediaconstants.h"
kjellandera96e2d72016-02-04 23:52:28 -080025#include "webrtc/media/base/mediaengine.h" // For DataChannelType
26#include "webrtc/media/base/streamparams.h"
henrike@webrtc.org269fb4b2014-10-28 22:20:11 +000027#include "webrtc/p2p/base/sessiondescription.h"
28#include "webrtc/p2p/base/transport.h"
29#include "webrtc/p2p/base/transportdescriptionfactory.h"
henrike@webrtc.org28e20752013-07-10 00:45:36 +000030
31namespace cricket {
32
33class ChannelManager;
34typedef std::vector<AudioCodec> AudioCodecs;
35typedef std::vector<VideoCodec> VideoCodecs;
36typedef std::vector<DataCodec> DataCodecs;
37typedef std::vector<CryptoParams> CryptoParamsVec;
isheriff6f8d6862016-05-26 11:24:55 -070038typedef std::vector<webrtc::RtpExtension> RtpHeaderExtensions;
henrike@webrtc.org28e20752013-07-10 00:45:36 +000039
henrike@webrtc.org28e20752013-07-10 00:45:36 +000040enum MediaType {
41 MEDIA_TYPE_AUDIO,
42 MEDIA_TYPE_VIDEO,
43 MEDIA_TYPE_DATA
44};
45
sergeyu@chromium.org4b26e2e2014-01-15 23:15:54 +000046std::string MediaTypeToString(MediaType type);
47
henrike@webrtc.org28e20752013-07-10 00:45:36 +000048enum MediaContentDirection {
49 MD_INACTIVE,
50 MD_SENDONLY,
51 MD_RECVONLY,
52 MD_SENDRECV
53};
54
ossu075af922016-06-14 03:29:38 -070055std::string MediaContentDirectionToString(MediaContentDirection direction);
56
henrike@webrtc.orgb90991d2014-03-04 19:54:57 +000057enum CryptoType {
58 CT_NONE,
59 CT_SDES,
60 CT_DTLS
61};
62
henrike@webrtc.org28e20752013-07-10 00:45:36 +000063// RTC4585 RTP/AVPF
64extern const char kMediaProtocolAvpf[];
65// RFC5124 RTP/SAVPF
66extern const char kMediaProtocolSavpf[];
67
jiayl@webrtc.org8dcd43c2014-05-29 22:07:59 +000068extern const char kMediaProtocolDtlsSavpf[];
69
henrike@webrtc.org28e20752013-07-10 00:45:36 +000070extern const char kMediaProtocolRtpPrefix[];
71
72extern const char kMediaProtocolSctp[];
73extern const char kMediaProtocolDtlsSctp[];
lally@webrtc.orgec97c652015-02-24 20:18:48 +000074extern const char kMediaProtocolUdpDtlsSctp[];
lally@webrtc.orga7470932015-02-24 20:19:21 +000075extern const char kMediaProtocolTcpDtlsSctp[];
henrike@webrtc.org28e20752013-07-10 00:45:36 +000076
77// Options to control how session descriptions are generated.
78const int kAutoBandwidth = -1;
79const int kBufferedModeDisabled = 0;
henrike@webrtc.org28e20752013-07-10 00:45:36 +000080
zhihuang8f65cdf2016-05-06 18:40:30 -070081// Default RTCP CNAME for unit tests.
82const char kDefaultRtcpCname[] = "DefaultRtcpCname";
83
ossu075af922016-06-14 03:29:38 -070084struct RtpTransceiverDirection {
85 bool send;
86 bool recv;
87
88 RtpTransceiverDirection(bool send, bool recv) : send(send), recv(recv) {}
89
90 bool operator==(const RtpTransceiverDirection& o) const {
91 return send == o.send && recv == o.recv;
92 }
93
94 bool operator!=(const RtpTransceiverDirection& o) const {
95 return !(*this == o);
96 }
97
98 static RtpTransceiverDirection FromMediaContentDirection(
99 MediaContentDirection md);
100
101 MediaContentDirection ToMediaContentDirection() const;
102};
103
104RtpTransceiverDirection
105NegotiateRtpTransceiverDirection(RtpTransceiverDirection offer,
106 RtpTransceiverDirection wants);
107
henrike@webrtc.org28e20752013-07-10 00:45:36 +0000108struct MediaSessionOptions {
zhihuang8f65cdf2016-05-06 18:40:30 -0700109 MediaSessionOptions()
110 : recv_audio(true),
111 recv_video(false),
112 data_channel_type(DCT_NONE),
113 is_muc(false),
114 vad_enabled(true), // When disabled, removes all CN codecs from SDP.
115 rtcp_mux_enabled(true),
116 bundle_enabled(false),
117 video_bandwidth(kAutoBandwidth),
118 data_bandwidth(kDataMaxBandwidth),
119 rtcp_cname(kDefaultRtcpCname) {}
henrike@webrtc.org28e20752013-07-10 00:45:36 +0000120
jiayl@webrtc.org742922b2014-10-07 21:32:43 +0000121 bool has_audio() const {
122 return recv_audio || HasSendMediaStream(MEDIA_TYPE_AUDIO);
123 }
124 bool has_video() const {
125 return recv_video || HasSendMediaStream(MEDIA_TYPE_VIDEO);
126 }
henrike@webrtc.org28e20752013-07-10 00:45:36 +0000127 bool has_data() const { return data_channel_type != DCT_NONE; }
128
129 // Add a stream with MediaType type and id.
130 // All streams with the same sync_label will get the same CNAME.
131 // All ids must be unique.
jiayl@webrtc.org742922b2014-10-07 21:32:43 +0000132 void AddSendStream(MediaType type,
henrike@webrtc.org28e20752013-07-10 00:45:36 +0000133 const std::string& id,
134 const std::string& sync_label);
jiayl@webrtc.org742922b2014-10-07 21:32:43 +0000135 void AddSendVideoStream(const std::string& id,
wu@webrtc.orgcecfd182013-10-30 05:18:12 +0000136 const std::string& sync_label,
137 int num_sim_layers);
jiayl@webrtc.org742922b2014-10-07 21:32:43 +0000138 void RemoveSendStream(MediaType type, const std::string& id);
henrike@webrtc.org28e20752013-07-10 00:45:36 +0000139
wu@webrtc.orgcecfd182013-10-30 05:18:12 +0000140
141 // Helper function.
jiayl@webrtc.org742922b2014-10-07 21:32:43 +0000142 void AddSendStreamInternal(MediaType type,
wu@webrtc.orgcecfd182013-10-30 05:18:12 +0000143 const std::string& id,
144 const std::string& sync_label,
145 int num_sim_layers);
146
jiayl@webrtc.org742922b2014-10-07 21:32:43 +0000147 bool HasSendMediaStream(MediaType type) const;
148
Taylor Brandstetterf475d362016-01-08 15:35:57 -0800149 // TODO(deadbeef): Put all the audio/video/data-specific options into a map
150 // structure (content name -> options).
151 // MediaSessionDescriptionFactory assumes there will never be more than one
152 // audio/video/data content, but this will change with unified plan.
jiayl@webrtc.org742922b2014-10-07 21:32:43 +0000153 bool recv_audio;
154 bool recv_video;
henrike@webrtc.org28e20752013-07-10 00:45:36 +0000155 DataChannelType data_channel_type;
156 bool is_muc;
157 bool vad_enabled;
158 bool rtcp_mux_enabled;
159 bool bundle_enabled;
160 // bps. -1 == auto.
161 int video_bandwidth;
162 int data_bandwidth;
Honghai Zhang4cedf2b2016-08-31 08:18:11 -0700163 bool enable_ice_renomination = false;
deadbeef0ed85b22016-02-23 17:24:52 -0800164 // content name ("mid") => options.
165 std::map<std::string, TransportOptions> transport_options;
zhihuang8f65cdf2016-05-06 18:40:30 -0700166 std::string rtcp_cname;
jbauchcb560652016-08-04 05:20:32 -0700167 rtc::CryptoOptions crypto_options;
henrike@webrtc.org28e20752013-07-10 00:45:36 +0000168
169 struct Stream {
170 Stream(MediaType type,
171 const std::string& id,
wu@webrtc.orgcecfd182013-10-30 05:18:12 +0000172 const std::string& sync_label,
173 int num_sim_layers)
174 : type(type), id(id), sync_label(sync_label),
175 num_sim_layers(num_sim_layers) {
henrike@webrtc.org28e20752013-07-10 00:45:36 +0000176 }
177 MediaType type;
178 std::string id;
179 std::string sync_label;
wu@webrtc.orgcecfd182013-10-30 05:18:12 +0000180 int num_sim_layers;
henrike@webrtc.org28e20752013-07-10 00:45:36 +0000181 };
182
183 typedef std::vector<Stream> Streams;
184 Streams streams;
185};
186
187// "content" (as used in XEP-0166) descriptions for voice and video.
188class MediaContentDescription : public ContentDescription {
189 public:
deadbeef13871492015-12-09 12:37:51 -0800190 MediaContentDescription() {}
henrike@webrtc.org28e20752013-07-10 00:45:36 +0000191
192 virtual MediaType type() const = 0;
193 virtual bool has_codecs() const = 0;
194
195 // |protocol| is the expected media transport protocol, such as RTP/AVPF,
196 // RTP/SAVPF or SCTP/DTLS.
197 std::string protocol() const { return protocol_; }
198 void set_protocol(const std::string& protocol) { protocol_ = protocol; }
199
200 MediaContentDirection direction() const { return direction_; }
201 void set_direction(MediaContentDirection direction) {
202 direction_ = direction;
203 }
204
205 bool rtcp_mux() const { return rtcp_mux_; }
206 void set_rtcp_mux(bool mux) { rtcp_mux_ = mux; }
207
deadbeef13871492015-12-09 12:37:51 -0800208 bool rtcp_reduced_size() const { return rtcp_reduced_size_; }
209 void set_rtcp_reduced_size(bool reduced_size) {
210 rtcp_reduced_size_ = reduced_size;
211 }
212
henrike@webrtc.org28e20752013-07-10 00:45:36 +0000213 int bandwidth() const { return bandwidth_; }
214 void set_bandwidth(int bandwidth) { bandwidth_ = bandwidth; }
215
216 const std::vector<CryptoParams>& cryptos() const { return cryptos_; }
217 void AddCrypto(const CryptoParams& params) {
218 cryptos_.push_back(params);
219 }
220 void set_cryptos(const std::vector<CryptoParams>& cryptos) {
221 cryptos_ = cryptos;
222 }
henrike@webrtc.orgb90991d2014-03-04 19:54:57 +0000223
224 CryptoType crypto_required() const { return crypto_required_; }
225 void set_crypto_required(CryptoType type) {
226 crypto_required_ = type;
henrike@webrtc.org28e20752013-07-10 00:45:36 +0000227 }
228
229 const RtpHeaderExtensions& rtp_header_extensions() const {
230 return rtp_header_extensions_;
231 }
232 void set_rtp_header_extensions(const RtpHeaderExtensions& extensions) {
233 rtp_header_extensions_ = extensions;
234 rtp_header_extensions_set_ = true;
235 }
isheriff6f8d6862016-05-26 11:24:55 -0700236 void AddRtpHeaderExtension(const webrtc::RtpExtension& ext) {
henrike@webrtc.org28e20752013-07-10 00:45:36 +0000237 rtp_header_extensions_.push_back(ext);
238 rtp_header_extensions_set_ = true;
239 }
isheriffa1c548b2016-05-31 16:12:24 -0700240 void AddRtpHeaderExtension(const cricket::RtpHeaderExtension& ext) {
241 webrtc::RtpExtension webrtc_extension;
242 webrtc_extension.uri = ext.uri;
243 webrtc_extension.id = ext.id;
244 rtp_header_extensions_.push_back(webrtc_extension);
245 rtp_header_extensions_set_ = true;
246 }
henrike@webrtc.org28e20752013-07-10 00:45:36 +0000247 void ClearRtpHeaderExtensions() {
248 rtp_header_extensions_.clear();
249 rtp_header_extensions_set_ = true;
250 }
251 // We can't always tell if an empty list of header extensions is
252 // because the other side doesn't support them, or just isn't hooked up to
253 // signal them. For now we assume an empty list means no signaling, but
254 // provide the ClearRtpHeaderExtensions method to allow "no support" to be
255 // clearly indicated (i.e. when derived from other information).
256 bool rtp_header_extensions_set() const {
257 return rtp_header_extensions_set_;
258 }
259 // True iff the client supports multiple streams.
260 void set_multistream(bool multistream) { multistream_ = multistream; }
261 bool multistream() const { return multistream_; }
262 const StreamParamsVec& streams() const {
263 return streams_;
264 }
265 // TODO(pthatcher): Remove this by giving mediamessage.cc access
266 // to MediaContentDescription
267 StreamParamsVec& mutable_streams() {
268 return streams_;
269 }
270 void AddStream(const StreamParams& stream) {
271 streams_.push_back(stream);
272 }
273 // Legacy streams have an ssrc, but nothing else.
Peter Boström0c4e06b2015-10-07 12:23:21 +0200274 void AddLegacyStream(uint32_t ssrc) {
henrike@webrtc.org28e20752013-07-10 00:45:36 +0000275 streams_.push_back(StreamParams::CreateLegacy(ssrc));
276 }
Peter Boström0c4e06b2015-10-07 12:23:21 +0200277 void AddLegacyStream(uint32_t ssrc, uint32_t fid_ssrc) {
henrike@webrtc.org28e20752013-07-10 00:45:36 +0000278 StreamParams sp = StreamParams::CreateLegacy(ssrc);
279 sp.AddFidSsrc(ssrc, fid_ssrc);
280 streams_.push_back(sp);
281 }
282 // Sets the CNAME of all StreamParams if it have not been set.
283 // This can be used to set the CNAME of legacy streams.
284 void SetCnameIfEmpty(const std::string& cname) {
285 for (cricket::StreamParamsVec::iterator it = streams_.begin();
286 it != streams_.end(); ++it) {
287 if (it->cname.empty())
288 it->cname = cname;
289 }
290 }
Peter Boström0c4e06b2015-10-07 12:23:21 +0200291 uint32_t first_ssrc() const {
henrike@webrtc.org28e20752013-07-10 00:45:36 +0000292 if (streams_.empty()) {
293 return 0;
294 }
295 return streams_[0].first_ssrc();
296 }
297 bool has_ssrcs() const {
298 if (streams_.empty()) {
299 return false;
300 }
301 return streams_[0].has_ssrcs();
302 }
303
304 void set_conference_mode(bool enable) { conference_mode_ = enable; }
305 bool conference_mode() const { return conference_mode_; }
306
307 void set_partial(bool partial) { partial_ = partial; }
308 bool partial() const { return partial_; }
309
310 void set_buffered_mode_latency(int latency) {
311 buffered_mode_latency_ = latency;
312 }
313 int buffered_mode_latency() const { return buffered_mode_latency_; }
314
315 protected:
deadbeef13871492015-12-09 12:37:51 -0800316 bool rtcp_mux_ = false;
317 bool rtcp_reduced_size_ = false;
318 int bandwidth_ = kAutoBandwidth;
henrike@webrtc.org28e20752013-07-10 00:45:36 +0000319 std::string protocol_;
320 std::vector<CryptoParams> cryptos_;
deadbeef13871492015-12-09 12:37:51 -0800321 CryptoType crypto_required_ = CT_NONE;
isheriff6f8d6862016-05-26 11:24:55 -0700322 std::vector<webrtc::RtpExtension> rtp_header_extensions_;
deadbeef13871492015-12-09 12:37:51 -0800323 bool rtp_header_extensions_set_ = false;
324 bool multistream_ = false;
henrike@webrtc.org28e20752013-07-10 00:45:36 +0000325 StreamParamsVec streams_;
deadbeef13871492015-12-09 12:37:51 -0800326 bool conference_mode_ = false;
327 bool partial_ = false;
328 int buffered_mode_latency_ = kBufferedModeDisabled;
329 MediaContentDirection direction_ = MD_SENDRECV;
henrike@webrtc.org28e20752013-07-10 00:45:36 +0000330};
331
332template <class C>
333class MediaContentDescriptionImpl : public MediaContentDescription {
334 public:
deadbeef67cf2c12016-04-13 10:07:16 -0700335 typedef C CodecType;
henrike@webrtc.org28e20752013-07-10 00:45:36 +0000336
deadbeef67cf2c12016-04-13 10:07:16 -0700337 // Codecs should be in preference order (most preferred codec first).
henrike@webrtc.org28e20752013-07-10 00:45:36 +0000338 const std::vector<C>& codecs() const { return codecs_; }
339 void set_codecs(const std::vector<C>& codecs) { codecs_ = codecs; }
340 virtual bool has_codecs() const { return !codecs_.empty(); }
341 bool HasCodec(int id) {
342 bool found = false;
343 for (typename std::vector<C>::iterator iter = codecs_.begin();
344 iter != codecs_.end(); ++iter) {
345 if (iter->id == id) {
346 found = true;
347 break;
348 }
349 }
350 return found;
351 }
352 void AddCodec(const C& codec) {
353 codecs_.push_back(codec);
354 }
jiayl@webrtc.org9c16c392014-05-01 18:30:30 +0000355 void AddOrReplaceCodec(const C& codec) {
356 for (typename std::vector<C>::iterator iter = codecs_.begin();
357 iter != codecs_.end(); ++iter) {
358 if (iter->id == codec.id) {
359 *iter = codec;
360 return;
361 }
362 }
363 AddCodec(codec);
364 }
henrike@webrtc.org28e20752013-07-10 00:45:36 +0000365 void AddCodecs(const std::vector<C>& codecs) {
366 typename std::vector<C>::const_iterator codec;
367 for (codec = codecs.begin(); codec != codecs.end(); ++codec) {
368 AddCodec(*codec);
369 }
370 }
henrike@webrtc.org28e20752013-07-10 00:45:36 +0000371
372 private:
373 std::vector<C> codecs_;
374};
375
376class AudioContentDescription : public MediaContentDescriptionImpl<AudioCodec> {
377 public:
378 AudioContentDescription() :
379 agc_minus_10db_(false) {}
380
381 virtual ContentDescription* Copy() const {
382 return new AudioContentDescription(*this);
383 }
384 virtual MediaType type() const { return MEDIA_TYPE_AUDIO; }
385
386 const std::string &lang() const { return lang_; }
387 void set_lang(const std::string &lang) { lang_ = lang; }
388
389 bool agc_minus_10db() const { return agc_minus_10db_; }
390 void set_agc_minus_10db(bool enable) {
391 agc_minus_10db_ = enable;
392 }
393
394 private:
395 bool agc_minus_10db_;
396
397 private:
398 std::string lang_;
399};
400
401class VideoContentDescription : public MediaContentDescriptionImpl<VideoCodec> {
402 public:
403 virtual ContentDescription* Copy() const {
404 return new VideoContentDescription(*this);
405 }
406 virtual MediaType type() const { return MEDIA_TYPE_VIDEO; }
407};
408
409class DataContentDescription : public MediaContentDescriptionImpl<DataCodec> {
410 public:
411 virtual ContentDescription* Copy() const {
412 return new DataContentDescription(*this);
413 }
414 virtual MediaType type() const { return MEDIA_TYPE_DATA; }
415};
416
417// Creates media session descriptions according to the supplied codecs and
418// other fields, as well as the supplied per-call options.
419// When creating answers, performs the appropriate negotiation
420// of the various fields to determine the proper result.
421class MediaSessionDescriptionFactory {
422 public:
423 // Default ctor; use methods below to set configuration.
424 // The TransportDescriptionFactory is not owned by MediaSessionDescFactory,
425 // so it must be kept alive by the user of this class.
426 explicit MediaSessionDescriptionFactory(
427 const TransportDescriptionFactory* factory);
428 // This helper automatically sets up the factory to get its configuration
429 // from the specified ChannelManager.
430 MediaSessionDescriptionFactory(ChannelManager* cmanager,
431 const TransportDescriptionFactory* factory);
432
ossudedfd282016-06-14 07:12:39 -0700433 const AudioCodecs& audio_sendrecv_codecs() const;
ossu075af922016-06-14 03:29:38 -0700434 const AudioCodecs& audio_send_codecs() const;
435 const AudioCodecs& audio_recv_codecs() const;
436 void set_audio_codecs(const AudioCodecs& send_codecs,
437 const AudioCodecs& recv_codecs);
henrike@webrtc.org28e20752013-07-10 00:45:36 +0000438 void set_audio_rtp_header_extensions(const RtpHeaderExtensions& extensions) {
439 audio_rtp_extensions_ = extensions;
440 }
441 const RtpHeaderExtensions& audio_rtp_header_extensions() const {
442 return audio_rtp_extensions_;
443 }
444 const VideoCodecs& video_codecs() const { return video_codecs_; }
445 void set_video_codecs(const VideoCodecs& codecs) { video_codecs_ = codecs; }
446 void set_video_rtp_header_extensions(const RtpHeaderExtensions& extensions) {
447 video_rtp_extensions_ = extensions;
448 }
449 const RtpHeaderExtensions& video_rtp_header_extensions() const {
450 return video_rtp_extensions_;
451 }
452 const DataCodecs& data_codecs() const { return data_codecs_; }
453 void set_data_codecs(const DataCodecs& codecs) { data_codecs_ = codecs; }
454 SecurePolicy secure() const { return secure_; }
455 void set_secure(SecurePolicy s) { secure_ = s; }
456 // Decides if a StreamParams shall be added to the audio and video media
457 // content in SessionDescription when CreateOffer and CreateAnswer is called
458 // even if |options| don't include a Stream. This is needed to support legacy
459 // applications. |add_legacy_| is true per default.
460 void set_add_legacy_streams(bool add_legacy) { add_legacy_ = add_legacy; }
461
462 SessionDescription* CreateOffer(
463 const MediaSessionOptions& options,
464 const SessionDescription* current_description) const;
465 SessionDescription* CreateAnswer(
466 const SessionDescription* offer,
467 const MediaSessionOptions& options,
468 const SessionDescription* current_description) const;
469
470 private:
ossu075af922016-06-14 03:29:38 -0700471 const AudioCodecs& GetAudioCodecsForOffer(
472 const RtpTransceiverDirection& direction) const;
473 const AudioCodecs& GetAudioCodecsForAnswer(
474 const RtpTransceiverDirection& offer,
475 const RtpTransceiverDirection& answer) const;
henrike@webrtc.org28e20752013-07-10 00:45:36 +0000476 void GetCodecsToOffer(const SessionDescription* current_description,
ossu075af922016-06-14 03:29:38 -0700477 const AudioCodecs& supported_audio_codecs,
478 const VideoCodecs& supported_video_codecs,
479 const DataCodecs& supported_data_codecs,
henrike@webrtc.org28e20752013-07-10 00:45:36 +0000480 AudioCodecs* audio_codecs,
481 VideoCodecs* video_codecs,
482 DataCodecs* data_codecs) const;
483 void GetRtpHdrExtsToOffer(const SessionDescription* current_description,
484 RtpHeaderExtensions* audio_extensions,
485 RtpHeaderExtensions* video_extensions) const;
486 bool AddTransportOffer(
487 const std::string& content_name,
488 const TransportOptions& transport_options,
489 const SessionDescription* current_desc,
490 SessionDescription* offer) const;
491
492 TransportDescription* CreateTransportAnswer(
493 const std::string& content_name,
494 const SessionDescription* offer_desc,
495 const TransportOptions& transport_options,
496 const SessionDescription* current_desc) const;
497
498 bool AddTransportAnswer(
499 const std::string& content_name,
500 const TransportDescription& transport_desc,
501 SessionDescription* answer_desc) const;
502
jiayl@webrtc.orge7d47a12014-08-05 19:19:05 +0000503 // Helpers for adding media contents to the SessionDescription. Returns true
504 // it succeeds or the media content is not needed, or false if there is any
505 // error.
506
507 bool AddAudioContentForOffer(
508 const MediaSessionOptions& options,
509 const SessionDescription* current_description,
510 const RtpHeaderExtensions& audio_rtp_extensions,
511 const AudioCodecs& audio_codecs,
512 StreamParamsVec* current_streams,
513 SessionDescription* desc) const;
514
515 bool AddVideoContentForOffer(
516 const MediaSessionOptions& options,
517 const SessionDescription* current_description,
518 const RtpHeaderExtensions& video_rtp_extensions,
519 const VideoCodecs& video_codecs,
520 StreamParamsVec* current_streams,
521 SessionDescription* desc) const;
522
523 bool AddDataContentForOffer(
524 const MediaSessionOptions& options,
525 const SessionDescription* current_description,
526 DataCodecs* data_codecs,
527 StreamParamsVec* current_streams,
528 SessionDescription* desc) const;
529
530 bool AddAudioContentForAnswer(
531 const SessionDescription* offer,
532 const MediaSessionOptions& options,
533 const SessionDescription* current_description,
534 StreamParamsVec* current_streams,
535 SessionDescription* answer) const;
536
537 bool AddVideoContentForAnswer(
538 const SessionDescription* offer,
539 const MediaSessionOptions& options,
540 const SessionDescription* current_description,
541 StreamParamsVec* current_streams,
542 SessionDescription* answer) const;
543
544 bool AddDataContentForAnswer(
545 const SessionDescription* offer,
546 const MediaSessionOptions& options,
547 const SessionDescription* current_description,
548 StreamParamsVec* current_streams,
549 SessionDescription* answer) const;
550
ossu075af922016-06-14 03:29:38 -0700551 AudioCodecs audio_send_codecs_;
552 AudioCodecs audio_recv_codecs_;
553 AudioCodecs audio_sendrecv_codecs_;
henrike@webrtc.org28e20752013-07-10 00:45:36 +0000554 RtpHeaderExtensions audio_rtp_extensions_;
555 VideoCodecs video_codecs_;
556 RtpHeaderExtensions video_rtp_extensions_;
557 DataCodecs data_codecs_;
558 SecurePolicy secure_;
559 bool add_legacy_;
560 std::string lang_;
561 const TransportDescriptionFactory* transport_desc_factory_;
562};
563
564// Convenience functions.
565bool IsMediaContent(const ContentInfo* content);
566bool IsAudioContent(const ContentInfo* content);
567bool IsVideoContent(const ContentInfo* content);
568bool IsDataContent(const ContentInfo* content);
deadbeef0ed85b22016-02-23 17:24:52 -0800569const ContentInfo* GetFirstMediaContent(const ContentInfos& contents,
570 MediaType media_type);
henrike@webrtc.org28e20752013-07-10 00:45:36 +0000571const ContentInfo* GetFirstAudioContent(const ContentInfos& contents);
572const ContentInfo* GetFirstVideoContent(const ContentInfos& contents);
573const ContentInfo* GetFirstDataContent(const ContentInfos& contents);
574const ContentInfo* GetFirstAudioContent(const SessionDescription* sdesc);
575const ContentInfo* GetFirstVideoContent(const SessionDescription* sdesc);
576const ContentInfo* GetFirstDataContent(const SessionDescription* sdesc);
577const AudioContentDescription* GetFirstAudioContentDescription(
578 const SessionDescription* sdesc);
579const VideoContentDescription* GetFirstVideoContentDescription(
580 const SessionDescription* sdesc);
581const DataContentDescription* GetFirstDataContentDescription(
582 const SessionDescription* sdesc);
Taylor Brandstetterdc4eb8c2016-05-12 08:14:50 -0700583// Non-const versions of the above functions.
584// Useful when modifying an existing description.
585ContentInfo* GetFirstMediaContent(ContentInfos& contents, MediaType media_type);
586ContentInfo* GetFirstAudioContent(ContentInfos& contents);
587ContentInfo* GetFirstVideoContent(ContentInfos& contents);
588ContentInfo* GetFirstDataContent(ContentInfos& contents);
589ContentInfo* GetFirstAudioContent(SessionDescription* sdesc);
590ContentInfo* GetFirstVideoContent(SessionDescription* sdesc);
591ContentInfo* GetFirstDataContent(SessionDescription* sdesc);
592AudioContentDescription* GetFirstAudioContentDescription(
593 SessionDescription* sdesc);
594VideoContentDescription* GetFirstVideoContentDescription(
595 SessionDescription* sdesc);
596DataContentDescription* GetFirstDataContentDescription(
597 SessionDescription* sdesc);
henrike@webrtc.org28e20752013-07-10 00:45:36 +0000598
jbauchcb560652016-08-04 05:20:32 -0700599void GetSupportedAudioCryptoSuites(const rtc::CryptoOptions& crypto_options,
600 std::vector<int>* crypto_suites);
601void GetSupportedVideoCryptoSuites(const rtc::CryptoOptions& crypto_options,
602 std::vector<int>* crypto_suites);
603void GetSupportedDataCryptoSuites(const rtc::CryptoOptions& crypto_options,
604 std::vector<int>* crypto_suites);
605void GetDefaultSrtpCryptoSuites(const rtc::CryptoOptions& crypto_options,
606 std::vector<int>* crypto_suites);
607void GetSupportedAudioCryptoSuiteNames(const rtc::CryptoOptions& crypto_options,
Guo-wei Shieh521ed7b2015-11-18 19:41:53 -0800608 std::vector<std::string>* crypto_suite_names);
jbauchcb560652016-08-04 05:20:32 -0700609void GetSupportedVideoCryptoSuiteNames(const rtc::CryptoOptions& crypto_options,
Guo-wei Shieh521ed7b2015-11-18 19:41:53 -0800610 std::vector<std::string>* crypto_suite_names);
jbauchcb560652016-08-04 05:20:32 -0700611void GetSupportedDataCryptoSuiteNames(const rtc::CryptoOptions& crypto_options,
Guo-wei Shieh521ed7b2015-11-18 19:41:53 -0800612 std::vector<std::string>* crypto_suite_names);
jbauchcb560652016-08-04 05:20:32 -0700613void GetDefaultSrtpCryptoSuiteNames(const rtc::CryptoOptions& crypto_options,
Guo-wei Shieh521ed7b2015-11-18 19:41:53 -0800614 std::vector<std::string>* crypto_suite_names);
615
henrike@webrtc.org28e20752013-07-10 00:45:36 +0000616} // namespace cricket
617
terelius8c011e52016-04-26 05:28:11 -0700618#endif // WEBRTC_PC_MEDIASESSION_H_