blob: 0c251f879387c7189120e6cb3601e5e42232dc12 [file] [log] [blame]
henrike@webrtc.org28e20752013-07-10 00:45:36 +00001/*
kjellanderb24317b2016-02-10 07:54:43 -08002 * Copyright 2013 The WebRTC project authors. All Rights Reserved.
henrike@webrtc.org28e20752013-07-10 00:45:36 +00003 *
kjellanderb24317b2016-02-10 07:54:43 -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// This file contains the interface for MediaConstraints, corresponding to
12// the definition at
13// http://www.w3.org/TR/mediacapture-streams/#mediastreamconstraints and also
14// used in WebRTC: http://dev.w3.org/2011/webrtc/editor/webrtc.html#constraints.
15
Henrik Kjellander15583c12016-02-10 10:53:12 +010016#ifndef WEBRTC_API_MEDIACONSTRAINTSINTERFACE_H_
17#define WEBRTC_API_MEDIACONSTRAINTSINTERFACE_H_
henrike@webrtc.org28e20752013-07-10 00:45:36 +000018
19#include <string>
20#include <vector>
21
22namespace webrtc {
23
24// MediaConstraintsInterface
25// Interface used for passing arguments about media constraints
26// to the MediaStream and PeerConnection implementation.
27class MediaConstraintsInterface {
28 public:
29 struct Constraint {
30 Constraint() {}
31 Constraint(const std::string& key, const std::string value)
32 : key(key), value(value) {
33 }
34 std::string key;
35 std::string value;
36 };
37
38 class Constraints : public std::vector<Constraint> {
39 public:
40 bool FindFirst(const std::string& key, std::string* value) const;
41 };
42
43 virtual const Constraints& GetMandatory() const = 0;
44 virtual const Constraints& GetOptional() const = 0;
45
henrike@webrtc.org28e20752013-07-10 00:45:36 +000046 // Constraint keys used by a local video source.
47 // Specified by draft-alvestrand-constraints-resolution-00b
48 static const char kMinAspectRatio[]; // minAspectRatio
49 static const char kMaxAspectRatio[]; // maxAspectRatio
50 static const char kMaxWidth[]; // maxWidth
51 static const char kMinWidth[]; // minWidth
52 static const char kMaxHeight[]; // maxHeight
53 static const char kMinHeight[]; // minHeight
54 static const char kMaxFrameRate[]; // maxFrameRate
55 static const char kMinFrameRate[]; // minFrameRate
56
57 // Constraint keys used by a local audio source.
tommi39b31002015-06-23 09:50:47 -070058 static const char kEchoCancellation[]; // echoCancellation
59
henrike@webrtc.org28e20752013-07-10 00:45:36 +000060 // These keys are google specific.
Tommi70c7fe12015-06-15 09:14:03 +020061 static const char kGoogEchoCancellation[]; // googEchoCancellation
62
Henrik Lundin441f6342015-06-09 16:03:13 +020063 static const char kExtendedFilterEchoCancellation[]; // googEchoCancellation2
Bjorn Volckerbf395c12015-03-25 22:45:56 +010064 static const char kDAEchoCancellation[]; // googDAEchoCancellation
henrike@webrtc.org28e20752013-07-10 00:45:36 +000065 static const char kAutoGainControl[]; // googAutoGainControl
66 static const char kExperimentalAutoGainControl[]; // googAutoGainControl2
67 static const char kNoiseSuppression[]; // googNoiseSuppression
sergeyu@chromium.org9cf037b2014-02-07 19:03:26 +000068 static const char kExperimentalNoiseSuppression[]; // googNoiseSuppression2
henrike@webrtc.org28e20752013-07-10 00:45:36 +000069 static const char kHighpassFilter[]; // googHighpassFilter
sergeyu@chromium.orga59696b2013-09-13 23:48:58 +000070 static const char kTypingNoiseDetection[]; // googTypingNoiseDetection
wu@webrtc.org97077a32013-10-25 21:18:33 +000071 static const char kAudioMirroring[]; // googAudioMirroring
henrike@webrtc.org28e20752013-07-10 00:45:36 +000072
73 // Google-specific constraint keys for a local video source
74 static const char kNoiseReduction[]; // googNoiseReduction
henrike@webrtc.orgdce3feb2014-03-26 01:17:30 +000075
henrike@webrtc.org28e20752013-07-10 00:45:36 +000076 // Constraint keys for CreateOffer / CreateAnswer
77 // Specified by the W3C PeerConnection spec
78 static const char kOfferToReceiveVideo[]; // OfferToReceiveVideo
79 static const char kOfferToReceiveAudio[]; // OfferToReceiveAudio
80 static const char kVoiceActivityDetection[]; // VoiceActivityDetection
81 static const char kIceRestart[]; // IceRestart
82 // These keys are google specific.
83 static const char kUseRtpMux[]; // googUseRtpMUX
84
85 // Constraints values.
86 static const char kValueTrue[]; // true
87 static const char kValueFalse[]; // false
88
wu@webrtc.org14814912014-04-02 23:25:15 +000089 // PeerConnection constraint keys.
henrike@webrtc.org28e20752013-07-10 00:45:36 +000090 // Temporary pseudo-constraints used to enable DTLS-SRTP
91 static const char kEnableDtlsSrtp[]; // Enable DTLS-SRTP
92 // Temporary pseudo-constraints used to enable DataChannels
93 static const char kEnableRtpDataChannels[]; // Enable RTP DataChannels
wu@webrtc.org14814912014-04-02 23:25:15 +000094 // Google-specific constraint keys.
wu@webrtc.orgde305012013-10-31 15:40:38 +000095 // Temporary pseudo-constraint for enabling DSCP through JS.
wu@webrtc.org14814912014-04-02 23:25:15 +000096 static const char kEnableDscp[]; // googDscp
henrika@webrtc.orgaebb1ad2014-01-14 10:00:58 +000097 // Constraint to enable IPv6 through JS.
wu@webrtc.org14814912014-04-02 23:25:15 +000098 static const char kEnableIPv6[]; // googIPv6
henrike@webrtc.org6e3dbc22014-03-25 17:09:47 +000099 // Temporary constraint to enable suspend below min bitrate feature.
100 static const char kEnableVideoSuspendBelowMinBitrate[];
wu@webrtc.org14814912014-04-02 23:25:15 +0000101 // googSuspendBelowMinBitrate
buildbot@webrtc.orgb4c7b092014-08-25 12:11:58 +0000102 // Constraint to enable combined audio+video bandwidth estimation.
103 static const char kCombinedAudioVideoBwe[]; // googCombinedAudioVideoBwe
wu@webrtc.org14814912014-04-02 23:25:15 +0000104 static const char kScreencastMinBitrate[]; // googScreencastMinBitrate
wu@webrtc.org14814912014-04-02 23:25:15 +0000105 static const char kCpuOveruseDetection[]; // googCpuOveruseDetection
buildbot@webrtc.org44a317a2014-06-17 07:49:15 +0000106 static const char kPayloadPadding[]; // googPayloadPadding
buildbot@webrtc.orgd27d9ae2014-06-19 01:56:46 +0000107
henrike@webrtc.org28e20752013-07-10 00:45:36 +0000108 // The prefix of internal-only constraints whose JS set values should be
109 // stripped by Chrome before passed down to Libjingle.
110 static const char kInternalConstraintPrefix[];
111
henrike@webrtc.org28e20752013-07-10 00:45:36 +0000112 protected:
113 // Dtor protected as objects shouldn't be deleted via this interface
114 virtual ~MediaConstraintsInterface() {}
115};
116
117bool FindConstraint(const MediaConstraintsInterface* constraints,
118 const std::string& key, bool* value,
119 size_t* mandatory_constraints);
120
121} // namespace webrtc
122
Henrik Kjellander15583c12016-02-10 10:53:12 +0100123#endif // WEBRTC_API_MEDIACONSTRAINTSINTERFACE_H_