blob: 97d5cf63f5fe291c550a4687c645b70d05c34df0 [file] [log] [blame]
henrike@webrtc.org28e20752013-07-10 00:45:36 +00001/*
2 * libjingle
3 * Copyright 2013, Google Inc.
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
39namespace webrtc {
40
41// MediaConstraintsInterface
42// Interface used for passing arguments about media constraints
43// to the MediaStream and PeerConnection implementation.
44class 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
63
64 // Constraint keys used by a local video source.
65 // Specified by draft-alvestrand-constraints-resolution-00b
66 static const char kMinAspectRatio[]; // minAspectRatio
67 static const char kMaxAspectRatio[]; // maxAspectRatio
68 static const char kMaxWidth[]; // maxWidth
69 static const char kMinWidth[]; // minWidth
70 static const char kMaxHeight[]; // maxHeight
71 static const char kMinHeight[]; // minHeight
72 static const char kMaxFrameRate[]; // maxFrameRate
73 static const char kMinFrameRate[]; // minFrameRate
74
75 // Constraint keys used by a local audio source.
76 // These keys are google specific.
77 static const char kEchoCancellation[]; // googEchoCancellation
78 static const char kExperimentalEchoCancellation[]; // googEchoCancellation2
79 static const char kAutoGainControl[]; // googAutoGainControl
80 static const char kExperimentalAutoGainControl[]; // googAutoGainControl2
81 static const char kNoiseSuppression[]; // googNoiseSuppression
82 static const char kHighpassFilter[]; // googHighpassFilter
sergeyu@chromium.orga59696b2013-09-13 23:48:58 +000083 static const char kTypingNoiseDetection[]; // googTypingNoiseDetection
wu@webrtc.org97077a32013-10-25 21:18:33 +000084 static const char kAudioMirroring[]; // googAudioMirroring
henrike@webrtc.org28e20752013-07-10 00:45:36 +000085
86 // Google-specific constraint keys for a local video source
87 static const char kNoiseReduction[]; // googNoiseReduction
88 static const char kLeakyBucket[]; // googLeakyBucket
89 // googTemporalLayeredScreencast
90 static const char kTemporalLayeredScreencast[];
wu@webrtc.orgcadf9042013-08-30 21:24:16 +000091 static const char kCpuOveruseDetection[];
henrike@webrtc.org28e20752013-07-10 00:45:36 +000092
93 // Constraint keys for CreateOffer / CreateAnswer
94 // Specified by the W3C PeerConnection spec
95 static const char kOfferToReceiveVideo[]; // OfferToReceiveVideo
96 static const char kOfferToReceiveAudio[]; // OfferToReceiveAudio
97 static const char kVoiceActivityDetection[]; // VoiceActivityDetection
98 static const char kIceRestart[]; // IceRestart
99 // These keys are google specific.
100 static const char kUseRtpMux[]; // googUseRtpMUX
101
102 // Constraints values.
103 static const char kValueTrue[]; // true
104 static const char kValueFalse[]; // false
105
106 // Temporary pseudo-constraints used to enable DTLS-SRTP
107 static const char kEnableDtlsSrtp[]; // Enable DTLS-SRTP
108 // Temporary pseudo-constraints used to enable DataChannels
109 static const char kEnableRtpDataChannels[]; // Enable RTP DataChannels
wu@webrtc.org97077a32013-10-25 21:18:33 +0000110 // TODO(perkj): Remove kEnableSctpDataChannels once Chrome use
111 // PeerConnectionFactory::SetOptions.
henrike@webrtc.org28e20752013-07-10 00:45:36 +0000112 static const char kEnableSctpDataChannels[]; // Enable SCTP DataChannels
113
114 // The prefix of internal-only constraints whose JS set values should be
115 // stripped by Chrome before passed down to Libjingle.
116 static const char kInternalConstraintPrefix[];
117
mallinath@webrtc.org7e809c32013-09-30 18:59:08 +0000118 // These constraints are for internal use only, representing Chrome command
119 // line flags. So they are prefixed with "internal" so JS values will be
120 // removed.
henrike@webrtc.org28e20752013-07-10 00:45:36 +0000121 // Used by a local audio source.
wu@webrtc.org97077a32013-10-25 21:18:33 +0000122 // TODO(perkj): Remove once Chrome use PeerConnectionFactory::SetOptions.
henrike@webrtc.org28e20752013-07-10 00:45:36 +0000123 static const char kInternalAecDump[]; // internalAecDump
henrike@webrtc.org28e20752013-07-10 00:45:36 +0000124
125 protected:
126 // Dtor protected as objects shouldn't be deleted via this interface
127 virtual ~MediaConstraintsInterface() {}
128};
129
130bool FindConstraint(const MediaConstraintsInterface* constraints,
131 const std::string& key, bool* value,
132 size_t* mandatory_constraints);
133
134} // namespace webrtc
135
136#endif // TALK_APP_WEBRTC_MEDIACONSTRAINTSINTERFACE_H_