Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(452)

Side by Side Diff: talk/app/webrtc/test/fakeconstraints.h

Issue 1610243002: Move talk/app/webrtc to webrtc/api (Closed) Base URL: https://chromium.googlesource.com/external/webrtc.git@master
Patch Set: Removed processing of api.gyp for Chromium builds Created 4 years, 10 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
(Empty)
1 /*
2 * libjingle
3 * Copyright 2012 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 #ifndef TALK_APP_WEBRTC_TEST_FAKECONSTRAINTS_H_
29 #define TALK_APP_WEBRTC_TEST_FAKECONSTRAINTS_H_
30
31 #include <string>
32 #include <vector>
33
34 #include "talk/app/webrtc/mediaconstraintsinterface.h"
35 #include "webrtc/base/stringencode.h"
36
37 namespace webrtc {
38
39 class FakeConstraints : public webrtc::MediaConstraintsInterface {
40 public:
41 FakeConstraints() { }
42 virtual ~FakeConstraints() { }
43
44 virtual const Constraints& GetMandatory() const {
45 return mandatory_;
46 }
47
48 virtual const Constraints& GetOptional() const {
49 return optional_;
50 }
51
52 template <class T>
53 void AddMandatory(const std::string& key, const T& value) {
54 mandatory_.push_back(Constraint(key, rtc::ToString<T>(value)));
55 }
56
57 template <class T>
58 void SetMandatory(const std::string& key, const T& value) {
59 std::string value_str;
60 if (mandatory_.FindFirst(key, &value_str)) {
61 for (Constraints::iterator iter = mandatory_.begin();
62 iter != mandatory_.end(); ++iter) {
63 if (iter->key == key) {
64 mandatory_.erase(iter);
65 break;
66 }
67 }
68 }
69 mandatory_.push_back(Constraint(key, rtc::ToString<T>(value)));
70 }
71
72 template <class T>
73 void AddOptional(const std::string& key, const T& value) {
74 optional_.push_back(Constraint(key, rtc::ToString<T>(value)));
75 }
76
77 void SetMandatoryMinAspectRatio(double ratio) {
78 SetMandatory(MediaConstraintsInterface::kMinAspectRatio, ratio);
79 }
80
81 void SetMandatoryMinWidth(int width) {
82 SetMandatory(MediaConstraintsInterface::kMinWidth, width);
83 }
84
85 void SetMandatoryMinHeight(int height) {
86 SetMandatory(MediaConstraintsInterface::kMinHeight, height);
87 }
88
89 void SetOptionalMaxWidth(int width) {
90 AddOptional(MediaConstraintsInterface::kMaxWidth, width);
91 }
92
93 void SetMandatoryMaxFrameRate(int frame_rate) {
94 SetMandatory(MediaConstraintsInterface::kMaxFrameRate, frame_rate);
95 }
96
97 void SetMandatoryReceiveAudio(bool enable) {
98 SetMandatory(MediaConstraintsInterface::kOfferToReceiveAudio, enable);
99 }
100
101 void SetMandatoryReceiveVideo(bool enable) {
102 SetMandatory(MediaConstraintsInterface::kOfferToReceiveVideo, enable);
103 }
104
105 void SetMandatoryUseRtpMux(bool enable) {
106 SetMandatory(MediaConstraintsInterface::kUseRtpMux, enable);
107 }
108
109 void SetMandatoryIceRestart(bool enable) {
110 SetMandatory(MediaConstraintsInterface::kIceRestart, enable);
111 }
112
113 void SetAllowRtpDataChannels() {
114 SetMandatory(MediaConstraintsInterface::kEnableRtpDataChannels, true);
115 SetMandatory(MediaConstraintsInterface::kEnableDtlsSrtp, false);
116 }
117
118 void SetOptionalVAD(bool enable) {
119 AddOptional(MediaConstraintsInterface::kVoiceActivityDetection, enable);
120 }
121
122 void SetAllowDtlsSctpDataChannels() {
123 SetMandatory(MediaConstraintsInterface::kEnableDtlsSrtp, true);
124 }
125
126 private:
127 Constraints mandatory_;
128 Constraints optional_;
129 };
130
131 } // namespace webrtc
132
133 #endif // TALK_APP_WEBRTC_TEST_FAKECONSTRAINTS_H_
OLDNEW
« no previous file with comments | « talk/app/webrtc/test/fakeaudiocapturemodule_unittest.cc ('k') | talk/app/webrtc/test/fakedatachannelprovider.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698