henrike@webrtc.org | 28e2075 | 2013-07-10 00:45:36 +0000 | [diff] [blame] | 1 | /* |
| 2 | * libjingle |
jlmiller@webrtc.org | 5f93d0a | 2015-01-20 21:36:13 +0000 | [diff] [blame] | 3 | * Copyright 2013 Google Inc. |
henrike@webrtc.org | 28e2075 | 2013-07-10 00:45:36 +0000 | [diff] [blame] | 4 | * |
| 5 | * Redistribution and use in source and binary forms, with or without |
| 6 | * modification, are permitted provided that the following conditions are met: |
| 7 | * |
| 8 | * 1. Redistributions of source code must retain the above copyright notice, |
| 9 | * this list of conditions and the following disclaimer. |
| 10 | * 2. Redistributions in binary form must reproduce the above copyright notice, |
| 11 | * this list of conditions and the following disclaimer in the documentation |
| 12 | * and/or other materials provided with the distribution. |
| 13 | * 3. The name of the author may not be used to endorse or promote products |
| 14 | * derived from this software without specific prior written permission. |
| 15 | * |
| 16 | * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR IMPLIED |
| 17 | * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF |
| 18 | * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO |
| 19 | * EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, |
| 20 | * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, |
| 21 | * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; |
| 22 | * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, |
| 23 | * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR |
| 24 | * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF |
| 25 | * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. |
| 26 | */ |
| 27 | |
| 28 | // This file contains the interface for MediaConstraints, corresponding to |
| 29 | // the definition at |
| 30 | // http://www.w3.org/TR/mediacapture-streams/#mediastreamconstraints and also |
| 31 | // used in WebRTC: http://dev.w3.org/2011/webrtc/editor/webrtc.html#constraints. |
| 32 | |
| 33 | #ifndef TALK_APP_WEBRTC_MEDIACONSTRAINTSINTERFACE_H_ |
| 34 | #define TALK_APP_WEBRTC_MEDIACONSTRAINTSINTERFACE_H_ |
| 35 | |
| 36 | #include <string> |
| 37 | #include <vector> |
| 38 | |
| 39 | namespace webrtc { |
| 40 | |
| 41 | // MediaConstraintsInterface |
| 42 | // Interface used for passing arguments about media constraints |
| 43 | // to the MediaStream and PeerConnection implementation. |
| 44 | class MediaConstraintsInterface { |
| 45 | public: |
| 46 | struct Constraint { |
| 47 | Constraint() {} |
| 48 | Constraint(const std::string& key, const std::string value) |
| 49 | : key(key), value(value) { |
| 50 | } |
| 51 | std::string key; |
| 52 | std::string value; |
| 53 | }; |
| 54 | |
| 55 | class Constraints : public std::vector<Constraint> { |
| 56 | public: |
| 57 | bool FindFirst(const std::string& key, std::string* value) const; |
| 58 | }; |
| 59 | |
| 60 | virtual const Constraints& GetMandatory() const = 0; |
| 61 | virtual const Constraints& GetOptional() const = 0; |
| 62 | |
henrike@webrtc.org | 28e2075 | 2013-07-10 00:45:36 +0000 | [diff] [blame] | 63 | // Constraint keys used by a local video source. |
| 64 | // Specified by draft-alvestrand-constraints-resolution-00b |
| 65 | static const char kMinAspectRatio[]; // minAspectRatio |
| 66 | static const char kMaxAspectRatio[]; // maxAspectRatio |
| 67 | static const char kMaxWidth[]; // maxWidth |
| 68 | static const char kMinWidth[]; // minWidth |
| 69 | static const char kMaxHeight[]; // maxHeight |
| 70 | static const char kMinHeight[]; // minHeight |
| 71 | static const char kMaxFrameRate[]; // maxFrameRate |
| 72 | static const char kMinFrameRate[]; // minFrameRate |
| 73 | |
| 74 | // Constraint keys used by a local audio source. |
tommi | 39b3100 | 2015-06-23 09:50:47 -0700 | [diff] [blame^] | 75 | static const char kEchoCancellation[]; // echoCancellation |
| 76 | |
henrike@webrtc.org | 28e2075 | 2013-07-10 00:45:36 +0000 | [diff] [blame] | 77 | // These keys are google specific. |
Tommi | 70c7fe1 | 2015-06-15 09:14:03 +0200 | [diff] [blame] | 78 | static const char kGoogEchoCancellation[]; // googEchoCancellation |
| 79 | |
Henrik Lundin | 441f634 | 2015-06-09 16:03:13 +0200 | [diff] [blame] | 80 | static const char kExtendedFilterEchoCancellation[]; // googEchoCancellation2 |
Bjorn Volcker | bf395c1 | 2015-03-25 22:45:56 +0100 | [diff] [blame] | 81 | static const char kDAEchoCancellation[]; // googDAEchoCancellation |
henrike@webrtc.org | 28e2075 | 2013-07-10 00:45:36 +0000 | [diff] [blame] | 82 | static const char kAutoGainControl[]; // googAutoGainControl |
| 83 | static const char kExperimentalAutoGainControl[]; // googAutoGainControl2 |
| 84 | static const char kNoiseSuppression[]; // googNoiseSuppression |
sergeyu@chromium.org | 9cf037b | 2014-02-07 19:03:26 +0000 | [diff] [blame] | 85 | static const char kExperimentalNoiseSuppression[]; // googNoiseSuppression2 |
henrike@webrtc.org | 28e2075 | 2013-07-10 00:45:36 +0000 | [diff] [blame] | 86 | static const char kHighpassFilter[]; // googHighpassFilter |
sergeyu@chromium.org | a59696b | 2013-09-13 23:48:58 +0000 | [diff] [blame] | 87 | static const char kTypingNoiseDetection[]; // googTypingNoiseDetection |
wu@webrtc.org | 97077a3 | 2013-10-25 21:18:33 +0000 | [diff] [blame] | 88 | static const char kAudioMirroring[]; // googAudioMirroring |
Bjorn Volcker | 1ba344a | 2015-04-29 07:28:10 +0200 | [diff] [blame] | 89 | static const char kAecDump[]; // audioDebugRecording |
henrike@webrtc.org | 28e2075 | 2013-07-10 00:45:36 +0000 | [diff] [blame] | 90 | |
| 91 | // Google-specific constraint keys for a local video source |
| 92 | static const char kNoiseReduction[]; // googNoiseReduction |
henrike@webrtc.org | dce3feb | 2014-03-26 01:17:30 +0000 | [diff] [blame] | 93 | |
henrike@webrtc.org | 28e2075 | 2013-07-10 00:45:36 +0000 | [diff] [blame] | 94 | // Constraint keys for CreateOffer / CreateAnswer |
| 95 | // Specified by the W3C PeerConnection spec |
| 96 | static const char kOfferToReceiveVideo[]; // OfferToReceiveVideo |
| 97 | static const char kOfferToReceiveAudio[]; // OfferToReceiveAudio |
| 98 | static const char kVoiceActivityDetection[]; // VoiceActivityDetection |
| 99 | static const char kIceRestart[]; // IceRestart |
| 100 | // These keys are google specific. |
| 101 | static const char kUseRtpMux[]; // googUseRtpMUX |
| 102 | |
| 103 | // Constraints values. |
| 104 | static const char kValueTrue[]; // true |
| 105 | static const char kValueFalse[]; // false |
| 106 | |
wu@webrtc.org | 1481491 | 2014-04-02 23:25:15 +0000 | [diff] [blame] | 107 | // PeerConnection constraint keys. |
henrike@webrtc.org | 28e2075 | 2013-07-10 00:45:36 +0000 | [diff] [blame] | 108 | // Temporary pseudo-constraints used to enable DTLS-SRTP |
| 109 | static const char kEnableDtlsSrtp[]; // Enable DTLS-SRTP |
| 110 | // Temporary pseudo-constraints used to enable DataChannels |
| 111 | static const char kEnableRtpDataChannels[]; // Enable RTP DataChannels |
wu@webrtc.org | 1481491 | 2014-04-02 23:25:15 +0000 | [diff] [blame] | 112 | // Google-specific constraint keys. |
wu@webrtc.org | de30501 | 2013-10-31 15:40:38 +0000 | [diff] [blame] | 113 | // Temporary pseudo-constraint for enabling DSCP through JS. |
wu@webrtc.org | 1481491 | 2014-04-02 23:25:15 +0000 | [diff] [blame] | 114 | static const char kEnableDscp[]; // googDscp |
henrika@webrtc.org | aebb1ad | 2014-01-14 10:00:58 +0000 | [diff] [blame] | 115 | // Constraint to enable IPv6 through JS. |
wu@webrtc.org | 1481491 | 2014-04-02 23:25:15 +0000 | [diff] [blame] | 116 | static const char kEnableIPv6[]; // googIPv6 |
henrike@webrtc.org | 6e3dbc2 | 2014-03-25 17:09:47 +0000 | [diff] [blame] | 117 | // Temporary constraint to enable suspend below min bitrate feature. |
| 118 | static const char kEnableVideoSuspendBelowMinBitrate[]; |
wu@webrtc.org | 1481491 | 2014-04-02 23:25:15 +0000 | [diff] [blame] | 119 | // googSuspendBelowMinBitrate |
buildbot@webrtc.org | 53df88c | 2014-08-07 22:46:01 +0000 | [diff] [blame] | 120 | static const char kNumUnsignalledRecvStreams[]; |
| 121 | // googNumUnsignalledRecvStreams |
buildbot@webrtc.org | b4c7b09 | 2014-08-25 12:11:58 +0000 | [diff] [blame] | 122 | // Constraint to enable combined audio+video bandwidth estimation. |
| 123 | static const char kCombinedAudioVideoBwe[]; // googCombinedAudioVideoBwe |
wu@webrtc.org | 1481491 | 2014-04-02 23:25:15 +0000 | [diff] [blame] | 124 | static const char kScreencastMinBitrate[]; // googScreencastMinBitrate |
wu@webrtc.org | 1481491 | 2014-04-02 23:25:15 +0000 | [diff] [blame] | 125 | static const char kCpuOveruseDetection[]; // googCpuOveruseDetection |
| 126 | static const char kCpuUnderuseThreshold[]; // googCpuUnderuseThreshold |
| 127 | static const char kCpuOveruseThreshold[]; // googCpuOveruseThreshold |
buildbot@webrtc.org | 27626a6 | 2014-06-16 13:39:40 +0000 | [diff] [blame] | 128 | // Low cpu adaptation threshold for relative standard deviation of encode |
| 129 | // time. |
| 130 | static const char kCpuUnderuseEncodeRsdThreshold[]; |
| 131 | // High cpu adaptation threshold for relative standard deviation of encode |
| 132 | // time. |
| 133 | static const char kCpuOveruseEncodeRsdThreshold[]; |
wu@webrtc.org | 1481491 | 2014-04-02 23:25:15 +0000 | [diff] [blame] | 134 | static const char kCpuOveruseEncodeUsage[]; // googCpuOveruseEncodeUsage |
| 135 | static const char kHighStartBitrate[]; // googHighStartBitrate |
| 136 | static const char kHighBitrate[]; // googHighBitrate |
| 137 | static const char kVeryHighBitrate[]; // googVeryHighBitrate |
buildbot@webrtc.org | 44a317a | 2014-06-17 07:49:15 +0000 | [diff] [blame] | 138 | static const char kPayloadPadding[]; // googPayloadPadding |
buildbot@webrtc.org | d27d9ae | 2014-06-19 01:56:46 +0000 | [diff] [blame] | 139 | |
henrike@webrtc.org | 28e2075 | 2013-07-10 00:45:36 +0000 | [diff] [blame] | 140 | // The prefix of internal-only constraints whose JS set values should be |
| 141 | // stripped by Chrome before passed down to Libjingle. |
| 142 | static const char kInternalConstraintPrefix[]; |
| 143 | |
henrike@webrtc.org | 28e2075 | 2013-07-10 00:45:36 +0000 | [diff] [blame] | 144 | protected: |
| 145 | // Dtor protected as objects shouldn't be deleted via this interface |
| 146 | virtual ~MediaConstraintsInterface() {} |
| 147 | }; |
| 148 | |
| 149 | bool FindConstraint(const MediaConstraintsInterface* constraints, |
| 150 | const std::string& key, bool* value, |
| 151 | size_t* mandatory_constraints); |
| 152 | |
| 153 | } // namespace webrtc |
| 154 | |
| 155 | #endif // TALK_APP_WEBRTC_MEDIACONSTRAINTSINTERFACE_H_ |