blob: f864fe99b769e10de359e9f9be4d319a35633352 [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
ossu7bb87ee2017-01-23 04:56:25 -080021#include "webrtc/api/mediatypes.h"
kjellandera96e2d72016-02-04 23:52:28 -080022#include "webrtc/media/base/codec.h"
kjellandera96e2d72016-02-04 23:52:28 -080023#include "webrtc/media/base/cryptoparams.h"
24#include "webrtc/media/base/mediachannel.h"
kjellanderf4752772016-03-02 05:42:30 -080025#include "webrtc/media/base/mediaconstants.h"
kjellandera96e2d72016-02-04 23:52:28 -080026#include "webrtc/media/base/mediaengine.h" // For DataChannelType
27#include "webrtc/media/base/streamparams.h"
henrike@webrtc.org269fb4b2014-10-28 22:20:11 +000028#include "webrtc/p2p/base/sessiondescription.h"
deadbeef49f34fd2016-12-06 16:22:06 -080029#include "webrtc/p2p/base/jseptransport.h"
henrike@webrtc.org269fb4b2014-10-28 22:20:11 +000030#include "webrtc/p2p/base/transportdescriptionfactory.h"
henrike@webrtc.org28e20752013-07-10 00:45:36 +000031
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 11:24:55 -070039typedef std::vector<webrtc::RtpExtension> RtpHeaderExtensions;
henrike@webrtc.org28e20752013-07-10 00:45:36 +000040
henrike@webrtc.org28e20752013-07-10 00:45:36 +000041enum MediaContentDirection {
42 MD_INACTIVE,
43 MD_SENDONLY,
44 MD_RECVONLY,
45 MD_SENDRECV
46};
47
ossu075af922016-06-14 03:29:38 -070048std::string MediaContentDirectionToString(MediaContentDirection direction);
49
henrike@webrtc.orgb90991d2014-03-04 19:54:57 +000050enum CryptoType {
51 CT_NONE,
52 CT_SDES,
53 CT_DTLS
54};
55
henrike@webrtc.org28e20752013-07-10 00:45:36 +000056// RTC4585 RTP/AVPF
57extern const char kMediaProtocolAvpf[];
58// RFC5124 RTP/SAVPF
59extern const char kMediaProtocolSavpf[];
60
jiayl@webrtc.org8dcd43c2014-05-29 22:07:59 +000061extern const char kMediaProtocolDtlsSavpf[];
62
henrike@webrtc.org28e20752013-07-10 00:45:36 +000063extern const char kMediaProtocolRtpPrefix[];
64
65extern const char kMediaProtocolSctp[];
66extern const char kMediaProtocolDtlsSctp[];
lally@webrtc.orgec97c652015-02-24 20:18:48 +000067extern const char kMediaProtocolUdpDtlsSctp[];
lally@webrtc.orga7470932015-02-24 20:19:21 +000068extern const char kMediaProtocolTcpDtlsSctp[];
henrike@webrtc.org28e20752013-07-10 00:45:36 +000069
70// Options to control how session descriptions are generated.
71const int kAutoBandwidth = -1;
72const int kBufferedModeDisabled = 0;
henrike@webrtc.org28e20752013-07-10 00:45:36 +000073
zhihuang8f65cdf2016-05-06 18:40:30 -070074// Default RTCP CNAME for unit tests.
75const char kDefaultRtcpCname[] = "DefaultRtcpCname";
76
ossu075af922016-06-14 03:29:38 -070077struct 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;
95};
96
97RtpTransceiverDirection
98NegotiateRtpTransceiverDirection(RtpTransceiverDirection offer,
99 RtpTransceiverDirection wants);
100
henrike@webrtc.org28e20752013-07-10 00:45:36 +0000101struct MediaSessionOptions {
zhihuang8f65cdf2016-05-06 18:40:30 -0700102 MediaSessionOptions()
103 : recv_audio(true),
104 recv_video(false),
105 data_channel_type(DCT_NONE),
106 is_muc(false),
107 vad_enabled(true), // When disabled, removes all CN codecs from SDP.
108 rtcp_mux_enabled(true),
109 bundle_enabled(false),
110 video_bandwidth(kAutoBandwidth),
111 data_bandwidth(kDataMaxBandwidth),
112 rtcp_cname(kDefaultRtcpCname) {}
henrike@webrtc.org28e20752013-07-10 00:45:36 +0000113
jiayl@webrtc.org742922b2014-10-07 21:32:43 +0000114 bool has_audio() const {
115 return recv_audio || HasSendMediaStream(MEDIA_TYPE_AUDIO);
116 }
117 bool has_video() const {
118 return recv_video || HasSendMediaStream(MEDIA_TYPE_VIDEO);
119 }
henrike@webrtc.org28e20752013-07-10 00:45:36 +0000120 bool has_data() const { return data_channel_type != DCT_NONE; }
121
122 // Add a stream with MediaType type and id.
123 // All streams with the same sync_label will get the same CNAME.
124 // All ids must be unique.
jiayl@webrtc.org742922b2014-10-07 21:32:43 +0000125 void AddSendStream(MediaType type,
henrike@webrtc.org28e20752013-07-10 00:45:36 +0000126 const std::string& id,
127 const std::string& sync_label);
jiayl@webrtc.org742922b2014-10-07 21:32:43 +0000128 void AddSendVideoStream(const std::string& id,
wu@webrtc.orgcecfd182013-10-30 05:18:12 +0000129 const std::string& sync_label,
130 int num_sim_layers);
jiayl@webrtc.org742922b2014-10-07 21:32:43 +0000131 void RemoveSendStream(MediaType type, const std::string& id);
henrike@webrtc.org28e20752013-07-10 00:45:36 +0000132
wu@webrtc.orgcecfd182013-10-30 05:18:12 +0000133
134 // Helper function.
jiayl@webrtc.org742922b2014-10-07 21:32:43 +0000135 void AddSendStreamInternal(MediaType type,
wu@webrtc.orgcecfd182013-10-30 05:18:12 +0000136 const std::string& id,
137 const std::string& sync_label,
138 int num_sim_layers);
139
jiayl@webrtc.org742922b2014-10-07 21:32:43 +0000140 bool HasSendMediaStream(MediaType type) const;
141
Taylor Brandstetterf475d362016-01-08 15:35:57 -0800142 // TODO(deadbeef): Put all the audio/video/data-specific options into a map
143 // structure (content name -> options).
144 // MediaSessionDescriptionFactory assumes there will never be more than one
145 // audio/video/data content, but this will change with unified plan.
jiayl@webrtc.org742922b2014-10-07 21:32:43 +0000146 bool recv_audio;
147 bool recv_video;
henrike@webrtc.org28e20752013-07-10 00:45:36 +0000148 DataChannelType data_channel_type;
149 bool is_muc;
150 bool vad_enabled;
151 bool rtcp_mux_enabled;
152 bool bundle_enabled;
153 // bps. -1 == auto.
154 int video_bandwidth;
155 int data_bandwidth;
Honghai Zhang4cedf2b2016-08-31 08:18:11 -0700156 bool enable_ice_renomination = false;
deadbeef0ed85b22016-02-23 17:24:52 -0800157 // content name ("mid") => options.
158 std::map<std::string, TransportOptions> transport_options;
zhihuang8f65cdf2016-05-06 18:40:30 -0700159 std::string rtcp_cname;
jbauchcb560652016-08-04 05:20:32 -0700160 rtc::CryptoOptions crypto_options;
henrike@webrtc.org28e20752013-07-10 00:45:36 +0000161
162 struct Stream {
163 Stream(MediaType type,
164 const std::string& id,
wu@webrtc.orgcecfd182013-10-30 05:18:12 +0000165 const std::string& sync_label,
166 int num_sim_layers)
167 : type(type), id(id), sync_label(sync_label),
168 num_sim_layers(num_sim_layers) {
henrike@webrtc.org28e20752013-07-10 00:45:36 +0000169 }
170 MediaType type;
171 std::string id;
172 std::string sync_label;
wu@webrtc.orgcecfd182013-10-30 05:18:12 +0000173 int num_sim_layers;
henrike@webrtc.org28e20752013-07-10 00:45:36 +0000174 };
175
176 typedef std::vector<Stream> Streams;
177 Streams streams;
178};
179
180// "content" (as used in XEP-0166) descriptions for voice and video.
181class MediaContentDescription : public ContentDescription {
182 public:
deadbeef13871492015-12-09 12:37:51 -0800183 MediaContentDescription() {}
henrike@webrtc.org28e20752013-07-10 00:45:36 +0000184
185 virtual MediaType type() const = 0;
186 virtual bool has_codecs() const = 0;
187
188 // |protocol| is the expected media transport protocol, such as RTP/AVPF,
189 // RTP/SAVPF or SCTP/DTLS.
190 std::string protocol() const { return protocol_; }
191 void set_protocol(const std::string& protocol) { protocol_ = protocol; }
192
193 MediaContentDirection direction() const { return direction_; }
194 void set_direction(MediaContentDirection direction) {
195 direction_ = direction;
196 }
197
198 bool rtcp_mux() const { return rtcp_mux_; }
199 void set_rtcp_mux(bool mux) { rtcp_mux_ = mux; }
200
deadbeef13871492015-12-09 12:37:51 -0800201 bool rtcp_reduced_size() const { return rtcp_reduced_size_; }
202 void set_rtcp_reduced_size(bool reduced_size) {
203 rtcp_reduced_size_ = reduced_size;
204 }
205
henrike@webrtc.org28e20752013-07-10 00:45:36 +0000206 int bandwidth() const { return bandwidth_; }
207 void set_bandwidth(int bandwidth) { bandwidth_ = bandwidth; }
208
209 const std::vector<CryptoParams>& cryptos() const { return cryptos_; }
210 void AddCrypto(const CryptoParams& params) {
211 cryptos_.push_back(params);
212 }
213 void set_cryptos(const std::vector<CryptoParams>& cryptos) {
214 cryptos_ = cryptos;
215 }
henrike@webrtc.orgb90991d2014-03-04 19:54:57 +0000216
217 CryptoType crypto_required() const { return crypto_required_; }
218 void set_crypto_required(CryptoType type) {
219 crypto_required_ = type;
henrike@webrtc.org28e20752013-07-10 00:45:36 +0000220 }
221
222 const RtpHeaderExtensions& rtp_header_extensions() const {
223 return rtp_header_extensions_;
224 }
225 void set_rtp_header_extensions(const RtpHeaderExtensions& extensions) {
226 rtp_header_extensions_ = extensions;
227 rtp_header_extensions_set_ = true;
228 }
isheriff6f8d6862016-05-26 11:24:55 -0700229 void AddRtpHeaderExtension(const webrtc::RtpExtension& ext) {
henrike@webrtc.org28e20752013-07-10 00:45:36 +0000230 rtp_header_extensions_.push_back(ext);
231 rtp_header_extensions_set_ = true;
232 }
isheriffa1c548b2016-05-31 16:12:24 -0700233 void AddRtpHeaderExtension(const cricket::RtpHeaderExtension& ext) {
234 webrtc::RtpExtension webrtc_extension;
235 webrtc_extension.uri = ext.uri;
236 webrtc_extension.id = ext.id;
237 rtp_header_extensions_.push_back(webrtc_extension);
238 rtp_header_extensions_set_ = true;
239 }
henrike@webrtc.org28e20752013-07-10 00:45:36 +0000240 void ClearRtpHeaderExtensions() {
241 rtp_header_extensions_.clear();
242 rtp_header_extensions_set_ = true;
243 }
244 // We can't always tell if an empty list of header extensions is
245 // because the other side doesn't support them, or just isn't hooked up to
246 // signal them. For now we assume an empty list means no signaling, but
247 // provide the ClearRtpHeaderExtensions method to allow "no support" to be
248 // clearly indicated (i.e. when derived from other information).
249 bool rtp_header_extensions_set() const {
250 return rtp_header_extensions_set_;
251 }
252 // True iff the client supports multiple streams.
253 void set_multistream(bool multistream) { multistream_ = multistream; }
254 bool multistream() const { return multistream_; }
255 const StreamParamsVec& streams() const {
256 return streams_;
257 }
258 // TODO(pthatcher): Remove this by giving mediamessage.cc access
259 // to MediaContentDescription
260 StreamParamsVec& mutable_streams() {
261 return streams_;
262 }
263 void AddStream(const StreamParams& stream) {
264 streams_.push_back(stream);
265 }
266 // Legacy streams have an ssrc, but nothing else.
Peter Boström0c4e06b2015-10-07 12:23:21 +0200267 void AddLegacyStream(uint32_t ssrc) {
henrike@webrtc.org28e20752013-07-10 00:45:36 +0000268 streams_.push_back(StreamParams::CreateLegacy(ssrc));
269 }
Peter Boström0c4e06b2015-10-07 12:23:21 +0200270 void AddLegacyStream(uint32_t ssrc, uint32_t fid_ssrc) {
henrike@webrtc.org28e20752013-07-10 00:45:36 +0000271 StreamParams sp = StreamParams::CreateLegacy(ssrc);
272 sp.AddFidSsrc(ssrc, fid_ssrc);
273 streams_.push_back(sp);
274 }
275 // Sets the CNAME of all StreamParams if it have not been set.
276 // This can be used to set the CNAME of legacy streams.
277 void SetCnameIfEmpty(const std::string& cname) {
278 for (cricket::StreamParamsVec::iterator it = streams_.begin();
279 it != streams_.end(); ++it) {
280 if (it->cname.empty())
281 it->cname = cname;
282 }
283 }
Peter Boström0c4e06b2015-10-07 12:23:21 +0200284 uint32_t first_ssrc() const {
henrike@webrtc.org28e20752013-07-10 00:45:36 +0000285 if (streams_.empty()) {
286 return 0;
287 }
288 return streams_[0].first_ssrc();
289 }
290 bool has_ssrcs() const {
291 if (streams_.empty()) {
292 return false;
293 }
294 return streams_[0].has_ssrcs();
295 }
296
297 void set_conference_mode(bool enable) { conference_mode_ = enable; }
298 bool conference_mode() const { return conference_mode_; }
299
300 void set_partial(bool partial) { partial_ = partial; }
301 bool partial() const { return partial_; }
302
303 void set_buffered_mode_latency(int latency) {
304 buffered_mode_latency_ = latency;
305 }
306 int buffered_mode_latency() const { return buffered_mode_latency_; }
307
308 protected:
deadbeef13871492015-12-09 12:37:51 -0800309 bool rtcp_mux_ = false;
310 bool rtcp_reduced_size_ = false;
311 int bandwidth_ = kAutoBandwidth;
henrike@webrtc.org28e20752013-07-10 00:45:36 +0000312 std::string protocol_;
313 std::vector<CryptoParams> cryptos_;
deadbeef13871492015-12-09 12:37:51 -0800314 CryptoType crypto_required_ = CT_NONE;
isheriff6f8d6862016-05-26 11:24:55 -0700315 std::vector<webrtc::RtpExtension> rtp_header_extensions_;
deadbeef13871492015-12-09 12:37:51 -0800316 bool rtp_header_extensions_set_ = false;
317 bool multistream_ = false;
henrike@webrtc.org28e20752013-07-10 00:45:36 +0000318 StreamParamsVec streams_;
deadbeef13871492015-12-09 12:37:51 -0800319 bool conference_mode_ = false;
320 bool partial_ = false;
321 int buffered_mode_latency_ = kBufferedModeDisabled;
322 MediaContentDirection direction_ = MD_SENDRECV;
henrike@webrtc.org28e20752013-07-10 00:45:36 +0000323};
324
325template <class C>
326class MediaContentDescriptionImpl : public MediaContentDescription {
327 public:
deadbeef67cf2c12016-04-13 10:07:16 -0700328 typedef C CodecType;
henrike@webrtc.org28e20752013-07-10 00:45:36 +0000329
deadbeef67cf2c12016-04-13 10:07:16 -0700330 // Codecs should be in preference order (most preferred codec first).
henrike@webrtc.org28e20752013-07-10 00:45:36 +0000331 const std::vector<C>& codecs() const { return codecs_; }
332 void set_codecs(const std::vector<C>& codecs) { codecs_ = codecs; }
333 virtual bool has_codecs() const { return !codecs_.empty(); }
334 bool HasCodec(int id) {
335 bool found = false;
336 for (typename std::vector<C>::iterator iter = codecs_.begin();
337 iter != codecs_.end(); ++iter) {
338 if (iter->id == id) {
339 found = true;
340 break;
341 }
342 }
343 return found;
344 }
345 void AddCodec(const C& codec) {
346 codecs_.push_back(codec);
347 }
jiayl@webrtc.org9c16c392014-05-01 18:30:30 +0000348 void AddOrReplaceCodec(const C& codec) {
349 for (typename std::vector<C>::iterator iter = codecs_.begin();
350 iter != codecs_.end(); ++iter) {
351 if (iter->id == codec.id) {
352 *iter = codec;
353 return;
354 }
355 }
356 AddCodec(codec);
357 }
henrike@webrtc.org28e20752013-07-10 00:45:36 +0000358 void AddCodecs(const std::vector<C>& codecs) {
359 typename std::vector<C>::const_iterator codec;
360 for (codec = codecs.begin(); codec != codecs.end(); ++codec) {
361 AddCodec(*codec);
362 }
363 }
henrike@webrtc.org28e20752013-07-10 00:45:36 +0000364
365 private:
366 std::vector<C> codecs_;
367};
368
369class AudioContentDescription : public MediaContentDescriptionImpl<AudioCodec> {
370 public:
371 AudioContentDescription() :
372 agc_minus_10db_(false) {}
373
374 virtual ContentDescription* Copy() const {
375 return new AudioContentDescription(*this);
376 }
377 virtual MediaType type() const { return MEDIA_TYPE_AUDIO; }
378
379 const std::string &lang() const { return lang_; }
380 void set_lang(const std::string &lang) { lang_ = lang; }
381
382 bool agc_minus_10db() const { return agc_minus_10db_; }
383 void set_agc_minus_10db(bool enable) {
384 agc_minus_10db_ = enable;
385 }
386
387 private:
388 bool agc_minus_10db_;
389
390 private:
391 std::string lang_;
392};
393
394class VideoContentDescription : public MediaContentDescriptionImpl<VideoCodec> {
395 public:
396 virtual ContentDescription* Copy() const {
397 return new VideoContentDescription(*this);
398 }
399 virtual MediaType type() const { return MEDIA_TYPE_VIDEO; }
400};
401
402class DataContentDescription : public MediaContentDescriptionImpl<DataCodec> {
403 public:
zstein4b2e0822017-02-17 19:48:38 -0800404 DataContentDescription() {}
405
henrike@webrtc.org28e20752013-07-10 00:45:36 +0000406 virtual ContentDescription* Copy() const {
407 return new DataContentDescription(*this);
408 }
409 virtual MediaType type() const { return MEDIA_TYPE_DATA; }
zstein4b2e0822017-02-17 19:48:38 -0800410
411 bool use_sctpmap() const { return use_sctpmap_; }
412 void set_use_sctpmap(bool enable) { use_sctpmap_ = enable; }
413
414 private:
415 bool use_sctpmap_ = true;
henrike@webrtc.org28e20752013-07-10 00:45:36 +0000416};
417
418// Creates media session descriptions according to the supplied codecs and
419// other fields, as well as the supplied per-call options.
420// When creating answers, performs the appropriate negotiation
421// of the various fields to determine the proper result.
422class MediaSessionDescriptionFactory {
423 public:
424 // Default ctor; use methods below to set configuration.
425 // The TransportDescriptionFactory is not owned by MediaSessionDescFactory,
426 // so it must be kept alive by the user of this class.
427 explicit MediaSessionDescriptionFactory(
428 const TransportDescriptionFactory* factory);
429 // This helper automatically sets up the factory to get its configuration
430 // from the specified ChannelManager.
431 MediaSessionDescriptionFactory(ChannelManager* cmanager,
432 const TransportDescriptionFactory* factory);
433
ossudedfd282016-06-14 07:12:39 -0700434 const AudioCodecs& audio_sendrecv_codecs() const;
ossu075af922016-06-14 03:29:38 -0700435 const AudioCodecs& audio_send_codecs() const;
436 const AudioCodecs& audio_recv_codecs() const;
437 void set_audio_codecs(const AudioCodecs& send_codecs,
438 const AudioCodecs& recv_codecs);
henrike@webrtc.org28e20752013-07-10 00:45:36 +0000439 void set_audio_rtp_header_extensions(const RtpHeaderExtensions& extensions) {
440 audio_rtp_extensions_ = extensions;
441 }
442 const RtpHeaderExtensions& audio_rtp_header_extensions() const {
443 return audio_rtp_extensions_;
444 }
445 const VideoCodecs& video_codecs() const { return video_codecs_; }
446 void set_video_codecs(const VideoCodecs& codecs) { video_codecs_ = codecs; }
447 void set_video_rtp_header_extensions(const RtpHeaderExtensions& extensions) {
448 video_rtp_extensions_ = extensions;
449 }
450 const RtpHeaderExtensions& video_rtp_header_extensions() const {
451 return video_rtp_extensions_;
452 }
453 const DataCodecs& data_codecs() const { return data_codecs_; }
454 void set_data_codecs(const DataCodecs& codecs) { data_codecs_ = codecs; }
455 SecurePolicy secure() const { return secure_; }
456 void set_secure(SecurePolicy s) { secure_ = s; }
457 // Decides if a StreamParams shall be added to the audio and video media
458 // content in SessionDescription when CreateOffer and CreateAnswer is called
459 // even if |options| don't include a Stream. This is needed to support legacy
460 // applications. |add_legacy_| is true per default.
461 void set_add_legacy_streams(bool add_legacy) { add_legacy_ = add_legacy; }
462
463 SessionDescription* CreateOffer(
464 const MediaSessionOptions& options,
465 const SessionDescription* current_description) const;
466 SessionDescription* CreateAnswer(
zstein4b2e0822017-02-17 19:48:38 -0800467 const SessionDescription* offer,
468 const MediaSessionOptions& options,
469 const SessionDescription* current_description) const;
henrike@webrtc.org28e20752013-07-10 00:45:36 +0000470
471 private:
ossu075af922016-06-14 03:29:38 -0700472 const AudioCodecs& GetAudioCodecsForOffer(
473 const RtpTransceiverDirection& direction) const;
474 const AudioCodecs& GetAudioCodecsForAnswer(
475 const RtpTransceiverDirection& offer,
476 const RtpTransceiverDirection& answer) const;
henrike@webrtc.org28e20752013-07-10 00:45:36 +0000477 void GetCodecsToOffer(const SessionDescription* current_description,
ossu075af922016-06-14 03:29:38 -0700478 const AudioCodecs& supported_audio_codecs,
479 const VideoCodecs& supported_video_codecs,
480 const DataCodecs& supported_data_codecs,
henrike@webrtc.org28e20752013-07-10 00:45:36 +0000481 AudioCodecs* audio_codecs,
482 VideoCodecs* video_codecs,
483 DataCodecs* data_codecs) const;
484 void GetRtpHdrExtsToOffer(const SessionDescription* current_description,
485 RtpHeaderExtensions* audio_extensions,
486 RtpHeaderExtensions* video_extensions) const;
487 bool AddTransportOffer(
488 const std::string& content_name,
489 const TransportOptions& transport_options,
490 const SessionDescription* current_desc,
491 SessionDescription* offer) const;
492
493 TransportDescription* CreateTransportAnswer(
494 const std::string& content_name,
495 const SessionDescription* offer_desc,
496 const TransportOptions& transport_options,
deadbeefb7892532017-02-22 19:35:18 -0800497 const SessionDescription* current_desc,
498 bool require_transport_attributes) const;
henrike@webrtc.org28e20752013-07-10 00:45:36 +0000499
500 bool AddTransportAnswer(
501 const std::string& content_name,
502 const TransportDescription& transport_desc,
503 SessionDescription* answer_desc) const;
504
jiayl@webrtc.orge7d47a12014-08-05 19:19:05 +0000505 // Helpers for adding media contents to the SessionDescription. Returns true
506 // it succeeds or the media content is not needed, or false if there is any
507 // error.
508
509 bool AddAudioContentForOffer(
510 const MediaSessionOptions& options,
511 const SessionDescription* current_description,
512 const RtpHeaderExtensions& audio_rtp_extensions,
513 const AudioCodecs& audio_codecs,
514 StreamParamsVec* current_streams,
515 SessionDescription* desc) const;
516
517 bool AddVideoContentForOffer(
518 const MediaSessionOptions& options,
519 const SessionDescription* current_description,
520 const RtpHeaderExtensions& video_rtp_extensions,
521 const VideoCodecs& video_codecs,
522 StreamParamsVec* current_streams,
523 SessionDescription* desc) const;
524
525 bool AddDataContentForOffer(
526 const MediaSessionOptions& options,
527 const SessionDescription* current_description,
528 DataCodecs* data_codecs,
529 StreamParamsVec* current_streams,
530 SessionDescription* desc) const;
531
deadbeefb7892532017-02-22 19:35:18 -0800532 bool AddAudioContentForAnswer(const SessionDescription* offer,
533 const MediaSessionOptions& options,
534 const SessionDescription* current_description,
535 const TransportInfo* bundle_transport,
536 StreamParamsVec* current_streams,
537 SessionDescription* answer) const;
jiayl@webrtc.orge7d47a12014-08-05 19:19:05 +0000538
deadbeefb7892532017-02-22 19:35:18 -0800539 bool AddVideoContentForAnswer(const SessionDescription* offer,
540 const MediaSessionOptions& options,
541 const SessionDescription* current_description,
542 const TransportInfo* bundle_transport,
543 StreamParamsVec* current_streams,
544 SessionDescription* answer) const;
jiayl@webrtc.orge7d47a12014-08-05 19:19:05 +0000545
deadbeefb7892532017-02-22 19:35:18 -0800546 bool AddDataContentForAnswer(const SessionDescription* offer,
547 const MediaSessionOptions& options,
548 const SessionDescription* current_description,
549 const TransportInfo* bundle_transport,
550 StreamParamsVec* current_streams,
551 SessionDescription* answer) const;
jiayl@webrtc.orge7d47a12014-08-05 19:19:05 +0000552
ossu075af922016-06-14 03:29:38 -0700553 AudioCodecs audio_send_codecs_;
554 AudioCodecs audio_recv_codecs_;
555 AudioCodecs audio_sendrecv_codecs_;
henrike@webrtc.org28e20752013-07-10 00:45:36 +0000556 RtpHeaderExtensions audio_rtp_extensions_;
557 VideoCodecs video_codecs_;
558 RtpHeaderExtensions video_rtp_extensions_;
559 DataCodecs data_codecs_;
560 SecurePolicy secure_;
561 bool add_legacy_;
562 std::string lang_;
563 const TransportDescriptionFactory* transport_desc_factory_;
564};
565
566// Convenience functions.
567bool IsMediaContent(const ContentInfo* content);
568bool IsAudioContent(const ContentInfo* content);
569bool IsVideoContent(const ContentInfo* content);
570bool IsDataContent(const ContentInfo* content);
deadbeef0ed85b22016-02-23 17:24:52 -0800571const ContentInfo* GetFirstMediaContent(const ContentInfos& contents,
572 MediaType media_type);
henrike@webrtc.org28e20752013-07-10 00:45:36 +0000573const ContentInfo* GetFirstAudioContent(const ContentInfos& contents);
574const ContentInfo* GetFirstVideoContent(const ContentInfos& contents);
575const ContentInfo* GetFirstDataContent(const ContentInfos& contents);
576const ContentInfo* GetFirstAudioContent(const SessionDescription* sdesc);
577const ContentInfo* GetFirstVideoContent(const SessionDescription* sdesc);
578const ContentInfo* GetFirstDataContent(const SessionDescription* sdesc);
579const AudioContentDescription* GetFirstAudioContentDescription(
580 const SessionDescription* sdesc);
581const VideoContentDescription* GetFirstVideoContentDescription(
582 const SessionDescription* sdesc);
583const DataContentDescription* GetFirstDataContentDescription(
584 const SessionDescription* sdesc);
Taylor Brandstetterdc4eb8c2016-05-12 08:14:50 -0700585// Non-const versions of the above functions.
586// Useful when modifying an existing description.
587ContentInfo* GetFirstMediaContent(ContentInfos& contents, MediaType media_type);
588ContentInfo* GetFirstAudioContent(ContentInfos& contents);
589ContentInfo* GetFirstVideoContent(ContentInfos& contents);
590ContentInfo* GetFirstDataContent(ContentInfos& contents);
591ContentInfo* GetFirstAudioContent(SessionDescription* sdesc);
592ContentInfo* GetFirstVideoContent(SessionDescription* sdesc);
593ContentInfo* GetFirstDataContent(SessionDescription* sdesc);
594AudioContentDescription* GetFirstAudioContentDescription(
595 SessionDescription* sdesc);
596VideoContentDescription* GetFirstVideoContentDescription(
597 SessionDescription* sdesc);
598DataContentDescription* GetFirstDataContentDescription(
599 SessionDescription* sdesc);
henrike@webrtc.org28e20752013-07-10 00:45:36 +0000600
jbauchcb560652016-08-04 05:20:32 -0700601void GetSupportedAudioCryptoSuites(const rtc::CryptoOptions& crypto_options,
602 std::vector<int>* crypto_suites);
603void GetSupportedVideoCryptoSuites(const rtc::CryptoOptions& crypto_options,
604 std::vector<int>* crypto_suites);
605void GetSupportedDataCryptoSuites(const rtc::CryptoOptions& crypto_options,
606 std::vector<int>* crypto_suites);
607void GetDefaultSrtpCryptoSuites(const rtc::CryptoOptions& crypto_options,
608 std::vector<int>* crypto_suites);
609void GetSupportedAudioCryptoSuiteNames(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 GetSupportedVideoCryptoSuiteNames(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 GetSupportedDataCryptoSuiteNames(const rtc::CryptoOptions& crypto_options,
Guo-wei Shieh521ed7b2015-11-18 19:41:53 -0800614 std::vector<std::string>* crypto_suite_names);
jbauchcb560652016-08-04 05:20:32 -0700615void GetDefaultSrtpCryptoSuiteNames(const rtc::CryptoOptions& crypto_options,
Guo-wei Shieh521ed7b2015-11-18 19:41:53 -0800616 std::vector<std::string>* crypto_suite_names);
617
henrike@webrtc.org28e20752013-07-10 00:45:36 +0000618} // namespace cricket
619
terelius8c011e52016-04-26 05:28:11 -0700620#endif // WEBRTC_PC_MEDIASESSION_H_