blob: fbb19551e1c524c6aba8c4f39517cf4541793f52 [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
htaa2a49d92016-03-04 02:51:39 -080016// This interface is being deprecated in Chrome, and may be removed
17// from WebRTC too.
18// https://bugs.chromium.org/p/webrtc/issues/detail?id=5617
19
Henrik Kjellander15583c12016-02-10 10:53:12 +010020#ifndef WEBRTC_API_MEDIACONSTRAINTSINTERFACE_H_
21#define WEBRTC_API_MEDIACONSTRAINTSINTERFACE_H_
henrike@webrtc.org28e20752013-07-10 00:45:36 +000022
23#include <string>
24#include <vector>
25
htaa2a49d92016-03-04 02:51:39 -080026#include "webrtc/base/optional.h"
27#include "webrtc/api/peerconnectioninterface.h"
28
henrike@webrtc.org28e20752013-07-10 00:45:36 +000029namespace webrtc {
30
31// MediaConstraintsInterface
32// Interface used for passing arguments about media constraints
33// to the MediaStream and PeerConnection implementation.
34class MediaConstraintsInterface {
35 public:
36 struct Constraint {
37 Constraint() {}
38 Constraint(const std::string& key, const std::string value)
39 : key(key), value(value) {
40 }
41 std::string key;
42 std::string value;
43 };
44
45 class Constraints : public std::vector<Constraint> {
46 public:
47 bool FindFirst(const std::string& key, std::string* value) const;
48 };
49
50 virtual const Constraints& GetMandatory() const = 0;
51 virtual const Constraints& GetOptional() const = 0;
52
henrike@webrtc.org28e20752013-07-10 00:45:36 +000053 // Constraint keys used by a local video source.
54 // Specified by draft-alvestrand-constraints-resolution-00b
55 static const char kMinAspectRatio[]; // minAspectRatio
56 static const char kMaxAspectRatio[]; // maxAspectRatio
57 static const char kMaxWidth[]; // maxWidth
58 static const char kMinWidth[]; // minWidth
59 static const char kMaxHeight[]; // maxHeight
60 static const char kMinHeight[]; // minHeight
61 static const char kMaxFrameRate[]; // maxFrameRate
62 static const char kMinFrameRate[]; // minFrameRate
63
64 // Constraint keys used by a local audio source.
tommi39b31002015-06-23 09:50:47 -070065 static const char kEchoCancellation[]; // echoCancellation
66
henrike@webrtc.org28e20752013-07-10 00:45:36 +000067 // These keys are google specific.
Tommi70c7fe12015-06-15 09:14:03 +020068 static const char kGoogEchoCancellation[]; // googEchoCancellation
69
Henrik Lundin441f6342015-06-09 16:03:13 +020070 static const char kExtendedFilterEchoCancellation[]; // googEchoCancellation2
Bjorn Volckerbf395c12015-03-25 22:45:56 +010071 static const char kDAEchoCancellation[]; // googDAEchoCancellation
henrike@webrtc.org28e20752013-07-10 00:45:36 +000072 static const char kAutoGainControl[]; // googAutoGainControl
73 static const char kExperimentalAutoGainControl[]; // googAutoGainControl2
74 static const char kNoiseSuppression[]; // googNoiseSuppression
sergeyu@chromium.org9cf037b2014-02-07 19:03:26 +000075 static const char kExperimentalNoiseSuppression[]; // googNoiseSuppression2
Alejandro Luebsc9b0c262016-05-16 15:32:38 -070076 static const char kIntelligibilityEnhancer[]; // intelligibilityEnhancer
peaha3333bf2016-06-30 00:02:34 -070077 static const char kLevelControl[]; // levelControl
aleloie33c5d92016-10-20 01:53:27 -070078 static const char
79 kLevelControlInitialPeakLevelDBFS[]; // levelControlInitialPeakLevelDBFS
henrike@webrtc.org28e20752013-07-10 00:45:36 +000080 static const char kHighpassFilter[]; // googHighpassFilter
sergeyu@chromium.orga59696b2013-09-13 23:48:58 +000081 static const char kTypingNoiseDetection[]; // googTypingNoiseDetection
wu@webrtc.org97077a32013-10-25 21:18:33 +000082 static const char kAudioMirroring[]; // googAudioMirroring
henrike@webrtc.org28e20752013-07-10 00:45:36 +000083
84 // Google-specific constraint keys for a local video source
85 static const char kNoiseReduction[]; // googNoiseReduction
henrike@webrtc.orgdce3feb2014-03-26 01:17:30 +000086
henrike@webrtc.org28e20752013-07-10 00:45:36 +000087 // Constraint keys for CreateOffer / CreateAnswer
88 // Specified by the W3C PeerConnection spec
89 static const char kOfferToReceiveVideo[]; // OfferToReceiveVideo
90 static const char kOfferToReceiveAudio[]; // OfferToReceiveAudio
91 static const char kVoiceActivityDetection[]; // VoiceActivityDetection
92 static const char kIceRestart[]; // IceRestart
93 // These keys are google specific.
94 static const char kUseRtpMux[]; // googUseRtpMUX
95
96 // Constraints values.
97 static const char kValueTrue[]; // true
98 static const char kValueFalse[]; // false
99
wu@webrtc.org14814912014-04-02 23:25:15 +0000100 // PeerConnection constraint keys.
henrike@webrtc.org28e20752013-07-10 00:45:36 +0000101 // Temporary pseudo-constraints used to enable DTLS-SRTP
102 static const char kEnableDtlsSrtp[]; // Enable DTLS-SRTP
103 // Temporary pseudo-constraints used to enable DataChannels
104 static const char kEnableRtpDataChannels[]; // Enable RTP DataChannels
wu@webrtc.org14814912014-04-02 23:25:15 +0000105 // Google-specific constraint keys.
wu@webrtc.orgde305012013-10-31 15:40:38 +0000106 // Temporary pseudo-constraint for enabling DSCP through JS.
wu@webrtc.org14814912014-04-02 23:25:15 +0000107 static const char kEnableDscp[]; // googDscp
henrika@webrtc.orgaebb1ad2014-01-14 10:00:58 +0000108 // Constraint to enable IPv6 through JS.
wu@webrtc.org14814912014-04-02 23:25:15 +0000109 static const char kEnableIPv6[]; // googIPv6
henrike@webrtc.org6e3dbc22014-03-25 17:09:47 +0000110 // Temporary constraint to enable suspend below min bitrate feature.
111 static const char kEnableVideoSuspendBelowMinBitrate[];
wu@webrtc.org14814912014-04-02 23:25:15 +0000112 // googSuspendBelowMinBitrate
buildbot@webrtc.orgb4c7b092014-08-25 12:11:58 +0000113 // Constraint to enable combined audio+video bandwidth estimation.
114 static const char kCombinedAudioVideoBwe[]; // googCombinedAudioVideoBwe
wu@webrtc.org14814912014-04-02 23:25:15 +0000115 static const char kScreencastMinBitrate[]; // googScreencastMinBitrate
wu@webrtc.org14814912014-04-02 23:25:15 +0000116 static const char kCpuOveruseDetection[]; // googCpuOveruseDetection
buildbot@webrtc.org44a317a2014-06-17 07:49:15 +0000117 static const char kPayloadPadding[]; // googPayloadPadding
buildbot@webrtc.orgd27d9ae2014-06-19 01:56:46 +0000118
henrike@webrtc.org28e20752013-07-10 00:45:36 +0000119 // The prefix of internal-only constraints whose JS set values should be
120 // stripped by Chrome before passed down to Libjingle.
121 static const char kInternalConstraintPrefix[];
122
henrike@webrtc.org28e20752013-07-10 00:45:36 +0000123 protected:
124 // Dtor protected as objects shouldn't be deleted via this interface
125 virtual ~MediaConstraintsInterface() {}
126};
127
128bool FindConstraint(const MediaConstraintsInterface* constraints,
129 const std::string& key, bool* value,
130 size_t* mandatory_constraints);
131
htaa2a49d92016-03-04 02:51:39 -0800132bool FindConstraint(const MediaConstraintsInterface* constraints,
133 const std::string& key,
134 int* value,
135 size_t* mandatory_constraints);
136
137// Copy all relevant constraints into an RTCConfiguration object.
138void CopyConstraintsIntoRtcConfiguration(
139 const MediaConstraintsInterface* constraints,
140 PeerConnectionInterface::RTCConfiguration* configuration);
141
henrike@webrtc.org28e20752013-07-10 00:45:36 +0000142} // namespace webrtc
143
Henrik Kjellander15583c12016-02-10 10:53:12 +0100144#endif // WEBRTC_API_MEDIACONSTRAINTSINTERFACE_H_