henrike@webrtc.org | 28e2075 | 2013-07-10 00:45:36 +0000 | [diff] [blame] | 1 | /* |
kjellander | b24317b | 2016-02-10 07:54:43 -0800 | [diff] [blame^] | 2 | * Copyright 2013 The WebRTC project authors. All Rights Reserved. |
henrike@webrtc.org | 28e2075 | 2013-07-10 00:45:36 +0000 | [diff] [blame] | 3 | * |
kjellander | b24317b | 2016-02-10 07:54:43 -0800 | [diff] [blame^] | 4 | * 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.org | 28e2075 | 2013-07-10 00:45:36 +0000 | [diff] [blame] | 9 | */ |
| 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 Kjellander | 15583c1 | 2016-02-10 10:53:12 +0100 | [diff] [blame] | 16 | #ifndef WEBRTC_API_MEDIACONSTRAINTSINTERFACE_H_ |
| 17 | #define WEBRTC_API_MEDIACONSTRAINTSINTERFACE_H_ |
henrike@webrtc.org | 28e2075 | 2013-07-10 00:45:36 +0000 | [diff] [blame] | 18 | |
| 19 | #include <string> |
| 20 | #include <vector> |
| 21 | |
| 22 | namespace webrtc { |
| 23 | |
| 24 | // MediaConstraintsInterface |
| 25 | // Interface used for passing arguments about media constraints |
| 26 | // to the MediaStream and PeerConnection implementation. |
| 27 | class 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.org | 28e2075 | 2013-07-10 00:45:36 +0000 | [diff] [blame] | 46 | // 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. |
tommi | 39b3100 | 2015-06-23 09:50:47 -0700 | [diff] [blame] | 58 | static const char kEchoCancellation[]; // echoCancellation |
| 59 | |
henrike@webrtc.org | 28e2075 | 2013-07-10 00:45:36 +0000 | [diff] [blame] | 60 | // These keys are google specific. |
Tommi | 70c7fe1 | 2015-06-15 09:14:03 +0200 | [diff] [blame] | 61 | static const char kGoogEchoCancellation[]; // googEchoCancellation |
| 62 | |
Henrik Lundin | 441f634 | 2015-06-09 16:03:13 +0200 | [diff] [blame] | 63 | static const char kExtendedFilterEchoCancellation[]; // googEchoCancellation2 |
Bjorn Volcker | bf395c1 | 2015-03-25 22:45:56 +0100 | [diff] [blame] | 64 | static const char kDAEchoCancellation[]; // googDAEchoCancellation |
henrike@webrtc.org | 28e2075 | 2013-07-10 00:45:36 +0000 | [diff] [blame] | 65 | static const char kAutoGainControl[]; // googAutoGainControl |
| 66 | static const char kExperimentalAutoGainControl[]; // googAutoGainControl2 |
| 67 | static const char kNoiseSuppression[]; // googNoiseSuppression |
sergeyu@chromium.org | 9cf037b | 2014-02-07 19:03:26 +0000 | [diff] [blame] | 68 | static const char kExperimentalNoiseSuppression[]; // googNoiseSuppression2 |
henrike@webrtc.org | 28e2075 | 2013-07-10 00:45:36 +0000 | [diff] [blame] | 69 | static const char kHighpassFilter[]; // googHighpassFilter |
sergeyu@chromium.org | a59696b | 2013-09-13 23:48:58 +0000 | [diff] [blame] | 70 | static const char kTypingNoiseDetection[]; // googTypingNoiseDetection |
wu@webrtc.org | 97077a3 | 2013-10-25 21:18:33 +0000 | [diff] [blame] | 71 | static const char kAudioMirroring[]; // googAudioMirroring |
Bjorn Volcker | 1ba344a | 2015-04-29 07:28:10 +0200 | [diff] [blame] | 72 | static const char kAecDump[]; // audioDebugRecording |
henrike@webrtc.org | 28e2075 | 2013-07-10 00:45:36 +0000 | [diff] [blame] | 73 | |
| 74 | // Google-specific constraint keys for a local video source |
| 75 | static const char kNoiseReduction[]; // googNoiseReduction |
henrike@webrtc.org | dce3feb | 2014-03-26 01:17:30 +0000 | [diff] [blame] | 76 | |
henrike@webrtc.org | 28e2075 | 2013-07-10 00:45:36 +0000 | [diff] [blame] | 77 | // Constraint keys for CreateOffer / CreateAnswer |
| 78 | // Specified by the W3C PeerConnection spec |
| 79 | static const char kOfferToReceiveVideo[]; // OfferToReceiveVideo |
| 80 | static const char kOfferToReceiveAudio[]; // OfferToReceiveAudio |
| 81 | static const char kVoiceActivityDetection[]; // VoiceActivityDetection |
| 82 | static const char kIceRestart[]; // IceRestart |
| 83 | // These keys are google specific. |
| 84 | static const char kUseRtpMux[]; // googUseRtpMUX |
| 85 | |
| 86 | // Constraints values. |
| 87 | static const char kValueTrue[]; // true |
| 88 | static const char kValueFalse[]; // false |
| 89 | |
wu@webrtc.org | 1481491 | 2014-04-02 23:25:15 +0000 | [diff] [blame] | 90 | // PeerConnection constraint keys. |
henrike@webrtc.org | 28e2075 | 2013-07-10 00:45:36 +0000 | [diff] [blame] | 91 | // Temporary pseudo-constraints used to enable DTLS-SRTP |
| 92 | static const char kEnableDtlsSrtp[]; // Enable DTLS-SRTP |
| 93 | // Temporary pseudo-constraints used to enable DataChannels |
| 94 | static const char kEnableRtpDataChannels[]; // Enable RTP DataChannels |
wu@webrtc.org | 1481491 | 2014-04-02 23:25:15 +0000 | [diff] [blame] | 95 | // Google-specific constraint keys. |
wu@webrtc.org | de30501 | 2013-10-31 15:40:38 +0000 | [diff] [blame] | 96 | // Temporary pseudo-constraint for enabling DSCP through JS. |
wu@webrtc.org | 1481491 | 2014-04-02 23:25:15 +0000 | [diff] [blame] | 97 | static const char kEnableDscp[]; // googDscp |
henrika@webrtc.org | aebb1ad | 2014-01-14 10:00:58 +0000 | [diff] [blame] | 98 | // Constraint to enable IPv6 through JS. |
wu@webrtc.org | 1481491 | 2014-04-02 23:25:15 +0000 | [diff] [blame] | 99 | static const char kEnableIPv6[]; // googIPv6 |
henrike@webrtc.org | 6e3dbc2 | 2014-03-25 17:09:47 +0000 | [diff] [blame] | 100 | // Temporary constraint to enable suspend below min bitrate feature. |
| 101 | static const char kEnableVideoSuspendBelowMinBitrate[]; |
wu@webrtc.org | 1481491 | 2014-04-02 23:25:15 +0000 | [diff] [blame] | 102 | // googSuspendBelowMinBitrate |
buildbot@webrtc.org | b4c7b09 | 2014-08-25 12:11:58 +0000 | [diff] [blame] | 103 | // Constraint to enable combined audio+video bandwidth estimation. |
| 104 | static const char kCombinedAudioVideoBwe[]; // googCombinedAudioVideoBwe |
wu@webrtc.org | 1481491 | 2014-04-02 23:25:15 +0000 | [diff] [blame] | 105 | static const char kScreencastMinBitrate[]; // googScreencastMinBitrate |
wu@webrtc.org | 1481491 | 2014-04-02 23:25:15 +0000 | [diff] [blame] | 106 | static const char kCpuOveruseDetection[]; // googCpuOveruseDetection |
buildbot@webrtc.org | 44a317a | 2014-06-17 07:49:15 +0000 | [diff] [blame] | 107 | static const char kPayloadPadding[]; // googPayloadPadding |
buildbot@webrtc.org | d27d9ae | 2014-06-19 01:56:46 +0000 | [diff] [blame] | 108 | |
henrike@webrtc.org | 28e2075 | 2013-07-10 00:45:36 +0000 | [diff] [blame] | 109 | // The prefix of internal-only constraints whose JS set values should be |
| 110 | // stripped by Chrome before passed down to Libjingle. |
| 111 | static const char kInternalConstraintPrefix[]; |
| 112 | |
henrike@webrtc.org | 28e2075 | 2013-07-10 00:45:36 +0000 | [diff] [blame] | 113 | protected: |
| 114 | // Dtor protected as objects shouldn't be deleted via this interface |
| 115 | virtual ~MediaConstraintsInterface() {} |
| 116 | }; |
| 117 | |
| 118 | bool FindConstraint(const MediaConstraintsInterface* constraints, |
| 119 | const std::string& key, bool* value, |
| 120 | size_t* mandatory_constraints); |
| 121 | |
| 122 | } // namespace webrtc |
| 123 | |
Henrik Kjellander | 15583c1 | 2016-02-10 10:53:12 +0100 | [diff] [blame] | 124 | #endif // WEBRTC_API_MEDIACONSTRAINTSINTERFACE_H_ |