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

Side by Side Diff: content/renderer/media/rtc_media_constraints.cc

Issue 23171026: Feed audio constraints over to WebRtcLocalAudioTrack (Closed) Base URL: http://git.chromium.org/chromium/src.git@master
Patch Set: Address comments Created 7 years, 3 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
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 #include "content/renderer/media/rtc_media_constraints.h" 4 #include "content/renderer/media/rtc_media_constraints.h"
5 5
6 #include "base/logging.h" 6 #include "base/logging.h"
7 #include "base/strings/string_util.h" 7 #include "base/strings/string_util.h"
8 #include "content/common/media/media_stream_options.h" 8 #include "content/common/media/media_stream_options.h"
9 #include "third_party/WebKit/public/platform/WebMediaConstraints.h" 9 #include "third_party/WebKit/public/platform/WebMediaConstraints.h"
10 #include "third_party/WebKit/public/platform/WebCString.h" 10 #include "third_party/WebKit/public/platform/WebCString.h"
(...skipping 24 matching lines...) Expand all
35 continue; 35 continue;
36 36
37 DVLOG(3) << "MediaStreamConstraints:" << new_constraint.key 37 DVLOG(3) << "MediaStreamConstraints:" << new_constraint.key
38 << " : " << new_constraint.value; 38 << " : " << new_constraint.value;
39 native_constraints->push_back(new_constraint); 39 native_constraints->push_back(new_constraint);
40 } 40 }
41 } 41 }
42 42
43 } // namespace 43 } // namespace
44 44
45 RTCMediaConstraints::RTCMediaConstraints() {}
46
45 RTCMediaConstraints::RTCMediaConstraints( 47 RTCMediaConstraints::RTCMediaConstraints(
46 const WebKit::WebMediaConstraints& constraints) { 48 const WebKit::WebMediaConstraints& constraints) {
47 if (constraints.isNull()) 49 if (constraints.isNull())
48 return; // Will happen in unit tests. 50 return; // Will happen in unit tests.
49 WebKit::WebVector<WebKit::WebMediaConstraint> mandatory; 51 WebKit::WebVector<WebKit::WebMediaConstraint> mandatory;
50 constraints.getMandatoryConstraints(mandatory); 52 constraints.getMandatoryConstraints(mandatory);
51 GetNativeMediaConstraints(mandatory, &mandatory_); 53 GetNativeMediaConstraints(mandatory, &mandatory_);
52 WebKit::WebVector<WebKit::WebMediaConstraint> optional; 54 WebKit::WebVector<WebKit::WebMediaConstraint> optional;
53 constraints.getOptionalConstraints(optional); 55 constraints.getOptionalConstraints(optional);
54 GetNativeMediaConstraints(optional, &optional_); 56 GetNativeMediaConstraints(optional, &optional_);
55 } 57 }
56 58
57 RTCMediaConstraints::~RTCMediaConstraints() {} 59 RTCMediaConstraints::~RTCMediaConstraints() {}
58 60
59 const webrtc::MediaConstraintsInterface::Constraints& 61 const webrtc::MediaConstraintsInterface::Constraints&
60 RTCMediaConstraints::GetMandatory() const { 62 RTCMediaConstraints::GetMandatory() const {
61 return mandatory_; 63 return mandatory_;
62 } 64 }
63 65
64 const webrtc::MediaConstraintsInterface::Constraints& 66 const webrtc::MediaConstraintsInterface::Constraints&
65 RTCMediaConstraints::GetOptional() const { 67 RTCMediaConstraints::GetOptional() const {
66 return optional_; 68 return optional_;
67 } 69 }
68 70
69 void RTCMediaConstraints::AddOptional(const std::string& key, 71 void RTCMediaConstraints::AddOptional(const std::string& key,
70 const std::string& value) { 72 const std::string& value) {
71 optional_.push_back(Constraint(key, value)); 73 optional_.push_back(Constraint(key, value));
72 } 74 }
73 75
76 bool RTCMediaConstraints::AddMandatory(const std::string& key,
77 const std::string& value,
78 bool override_if_exists) {
79 for (Constraints::iterator iter = mandatory_.begin();
80 iter != mandatory_.end();
81 ++iter) {
82 if (iter->key == key) {
83 if (override_if_exists)
84 iter->value = value;
85 return override_if_exists;
86 }
87 }
88 // The key wasn't found, add it.
89 mandatory_.push_back(Constraint(key, value));
90 return true;
91 }
92
74 } // namespace content 93 } // namespace content
OLDNEW
« no previous file with comments | « content/renderer/media/rtc_media_constraints.h ('k') | content/renderer/media/rtc_peer_connection_handler_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698