blob: f3e98539714a0f4dae3c661f289cfd317c143b22 [file] [log] [blame]
henrike@webrtc.org28e20752013-07-10 00:45:361/*
kjellanderb24317b2016-02-10 15:54:432 * Copyright 2013 The WebRTC project authors. All Rights Reserved.
henrike@webrtc.org28e20752013-07-10 00:45:363 *
kjellanderb24317b2016-02-10 15:54:434 * 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
Niels Möllerf06f9232018-08-07 10:32:1811// Implementation of the w3c constraints spec is the responsibility of the
12// browser. Chrome no longer uses the constraints api declared here, and it will
13// be removed from WebRTC.
14// https://bugs.chromium.org/p/webrtc/issues/detail?id=9239
htaa2a49d92016-03-04 10:51:3915
Niels Möllerdac03d92019-02-13 07:52:2716#ifndef SDK_MEDIA_CONSTRAINTS_H_
17#define SDK_MEDIA_CONSTRAINTS_H_
henrike@webrtc.org28e20752013-07-10 00:45:3618
Yves Gerey988cc082018-10-23 10:03:0119#include <stddef.h>
henrike@webrtc.org28e20752013-07-10 00:45:3620#include <string>
Niels Möllerdac03d92019-02-13 07:52:2721#include <utility>
henrike@webrtc.org28e20752013-07-10 00:45:3622#include <vector>
23
Yves Gerey988cc082018-10-23 10:03:0124#include "api/audio_options.h"
Steve Anton10542f22019-01-11 17:11:0025#include "api/peer_connection_interface.h"
htaa2a49d92016-03-04 10:51:3926
henrike@webrtc.org28e20752013-07-10 00:45:3627namespace webrtc {
28
Niels Möllerdac03d92019-02-13 07:52:2729// Class representing constraints, as used by the android and objc apis.
deadbeefb10f32f2017-02-08 09:38:2130//
31// Constraints may be either "mandatory", which means that unless satisfied,
32// the method taking the constraints should fail, or "optional", which means
33// they may not be satisfied..
Niels Möllerdac03d92019-02-13 07:52:2734class MediaConstraints {
henrike@webrtc.org28e20752013-07-10 00:45:3635 public:
36 struct Constraint {
37 Constraint() {}
38 Constraint(const std::string& key, const std::string value)
Yves Gerey665174f2018-06-19 13:03:0539 : key(key), value(value) {}
henrike@webrtc.org28e20752013-07-10 00:45:3640 std::string key;
41 std::string value;
42 };
43
44 class Constraints : public std::vector<Constraint> {
45 public:
Niels Möllerdac03d92019-02-13 07:52:2746 Constraints() = default;
47 Constraints(std::initializer_list<Constraint> l)
48 : std::vector<Constraint>(l) {}
49
henrike@webrtc.org28e20752013-07-10 00:45:3650 bool FindFirst(const std::string& key, std::string* value) const;
51 };
52
Niels Möllerdac03d92019-02-13 07:52:2753 MediaConstraints() = default;
54 MediaConstraints(Constraints mandatory, Constraints optional)
55 : mandatory_(std::move(mandatory)), optional_(std::move(optional)) {}
56
henrike@webrtc.org28e20752013-07-10 00:45:3657 // Constraint keys used by a local audio source.
tommi39b31002015-06-23 16:50:4758
henrike@webrtc.org28e20752013-07-10 00:45:3659 // These keys are google specific.
Tommi70c7fe12015-06-15 07:14:0360 static const char kGoogEchoCancellation[]; // googEchoCancellation
61
Henrik Lundin441f6342015-06-09 14:03:1362 static const char kExtendedFilterEchoCancellation[]; // googEchoCancellation2
Yves Gerey665174f2018-06-19 13:03:0563 static const char kDAEchoCancellation[]; // googDAEchoCancellation
64 static const char kAutoGainControl[]; // googAutoGainControl
65 static const char kExperimentalAutoGainControl[]; // googAutoGainControl2
66 static const char kNoiseSuppression[]; // googNoiseSuppression
sergeyu@chromium.org9cf037b2014-02-07 19:03:2667 static const char kExperimentalNoiseSuppression[]; // googNoiseSuppression2
Yves Gerey665174f2018-06-19 13:03:0568 static const char kHighpassFilter[]; // googHighpassFilter
sergeyu@chromium.orga59696b2013-09-13 23:48:5869 static const char kTypingNoiseDetection[]; // googTypingNoiseDetection
Yves Gerey665174f2018-06-19 13:03:0570 static const char kAudioMirroring[]; // googAudioMirroring
minyueba414282016-12-11 10:17:5271 static const char
72 kAudioNetworkAdaptorConfig[]; // goodAudioNetworkAdaptorConfig
henrike@webrtc.org28e20752013-07-10 00:45:3673
henrike@webrtc.org28e20752013-07-10 00:45:3674 // Constraint keys for CreateOffer / CreateAnswer
75 // Specified by the W3C PeerConnection spec
Yves Gerey665174f2018-06-19 13:03:0576 static const char kOfferToReceiveVideo[]; // OfferToReceiveVideo
77 static const char kOfferToReceiveAudio[]; // OfferToReceiveAudio
henrike@webrtc.org28e20752013-07-10 00:45:3678 static const char kVoiceActivityDetection[]; // VoiceActivityDetection
Yves Gerey665174f2018-06-19 13:03:0579 static const char kIceRestart[]; // IceRestart
henrike@webrtc.org28e20752013-07-10 00:45:3680 // These keys are google specific.
81 static const char kUseRtpMux[]; // googUseRtpMUX
82
83 // Constraints values.
Yves Gerey665174f2018-06-19 13:03:0584 static const char kValueTrue[]; // true
henrike@webrtc.org28e20752013-07-10 00:45:3685 static const char kValueFalse[]; // false
86
wu@webrtc.org14814912014-04-02 23:25:1587 // PeerConnection constraint keys.
henrike@webrtc.org28e20752013-07-10 00:45:3688 // Temporary pseudo-constraints used to enable DTLS-SRTP
89 static const char kEnableDtlsSrtp[]; // Enable DTLS-SRTP
90 // Temporary pseudo-constraints used to enable DataChannels
91 static const char kEnableRtpDataChannels[]; // Enable RTP DataChannels
wu@webrtc.org14814912014-04-02 23:25:1592 // Google-specific constraint keys.
wu@webrtc.orgde305012013-10-31 15:40:3893 // Temporary pseudo-constraint for enabling DSCP through JS.
wu@webrtc.org14814912014-04-02 23:25:1594 static const char kEnableDscp[]; // googDscp
henrika@webrtc.orgaebb1ad2014-01-14 10:00:5895 // Constraint to enable IPv6 through JS.
wu@webrtc.org14814912014-04-02 23:25:1596 static const char kEnableIPv6[]; // googIPv6
henrike@webrtc.org6e3dbc22014-03-25 17:09:4797 // Temporary constraint to enable suspend below min bitrate feature.
98 static const char kEnableVideoSuspendBelowMinBitrate[];
Yves Gerey665174f2018-06-19 13:03:0599 // googSuspendBelowMinBitrate
buildbot@webrtc.orgb4c7b092014-08-25 12:11:58100 // Constraint to enable combined audio+video bandwidth estimation.
101 static const char kCombinedAudioVideoBwe[]; // googCombinedAudioVideoBwe
Yves Gerey665174f2018-06-19 13:03:05102 static const char kScreencastMinBitrate[]; // googScreencastMinBitrate
103 static const char kCpuOveruseDetection[]; // googCpuOveruseDetection
henrike@webrtc.org28e20752013-07-10 00:45:36104
Mirta Dvornicic479a3c02019-06-04 13:38:50105 // Constraint to enable negotiating raw RTP packetization using attribute
106 // "a=packetization:<payload_type> raw" in the SDP for all video payload.
107 static const char kRawPacketizationForVideoEnabled[];
108
Jonas Orelandfc1acd22018-08-24 08:58:37109 // Specifies number of simulcast layers for all video tracks
110 // with a Plan B offer/answer
111 // (see RTCOfferAnswerOptions::num_simulcast_layers).
112 static const char kNumSimulcastLayers[];
113
Niels Möllerdac03d92019-02-13 07:52:27114 ~MediaConstraints() = default;
Magnus Jedvert3ecdd0f2017-11-24 10:21:14115
Niels Möllerdac03d92019-02-13 07:52:27116 const Constraints& GetMandatory() const { return mandatory_; }
117 const Constraints& GetOptional() const { return optional_; }
118
119 private:
120 const Constraints mandatory_ = {};
121 const Constraints optional_ = {};
henrike@webrtc.org28e20752013-07-10 00:45:36122};
123
htaa2a49d92016-03-04 10:51:39124// Copy all relevant constraints into an RTCConfiguration object.
125void CopyConstraintsIntoRtcConfiguration(
Niels Möllerdac03d92019-02-13 07:52:27126 const MediaConstraints* constraints,
htaa2a49d92016-03-04 10:51:39127 PeerConnectionInterface::RTCConfiguration* configuration);
128
deadbeeffe0fd412017-01-13 19:47:56129// Copy all relevant constraints into an AudioOptions object.
Niels Möllerdac03d92019-02-13 07:52:27130void CopyConstraintsIntoAudioOptions(const MediaConstraints* constraints,
131 cricket::AudioOptions* options);
deadbeeffe0fd412017-01-13 19:47:56132
Niels Möllerf06f9232018-08-07 10:32:18133bool CopyConstraintsIntoOfferAnswerOptions(
Niels Möllerdac03d92019-02-13 07:52:27134 const MediaConstraints* constraints,
Niels Möllerf06f9232018-08-07 10:32:18135 PeerConnectionInterface::RTCOfferAnswerOptions* offer_answer_options);
136
henrike@webrtc.org28e20752013-07-10 00:45:36137} // namespace webrtc
138
Niels Möllerdac03d92019-02-13 07:52:27139#endif // SDK_MEDIA_CONSTRAINTS_H_