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
3 // found in the LICENSE file.
4 #include "content/renderer/media/rtc_media_constraints.h"
6 #include "base/logging.h"
8 #include "content/common/media/media_stream_options.h"
9 #include "third_party/WebKit/Source/Platform/chromium/public/WebMediaConstraints.h"
10 #include "third_party/WebKit/Source/Platform/chromium/public/WebCString.h"
11 #include "third_party/WebKit/Source/Platform/chromium/public/WebString.h"
16 void GetNativeMediaConstraints(
17 const WebKit::WebVector
<WebKit::WebMediaConstraint
>& constraints
,
18 webrtc::MediaConstraintsInterface::Constraints
* native_constraints
) {
19 DCHECK(native_constraints
);
20 for (size_t i
= 0; i
< constraints
.size(); ++i
) {
21 webrtc::MediaConstraintsInterface::Constraint new_constraint
;
22 new_constraint
.key
= constraints
[i
].m_name
.utf8();
23 new_constraint
.value
= constraints
[i
].m_value
.utf8();
25 // Ignore Chrome specific Tab capture constraints.
26 if (new_constraint
.key
== kMediaStreamSource
||
27 new_constraint
.key
== kMediaStreamSourceId
)
29 DVLOG(3) << "MediaStreamConstraints:" << new_constraint
.key
30 << " : " << new_constraint
.value
;
31 native_constraints
->push_back(new_constraint
);
37 RTCMediaConstraints::RTCMediaConstraints(
38 const WebKit::WebMediaConstraints
& constraints
) {
39 if (constraints
.isNull())
40 return; // Will happen in unit tests.
41 WebKit::WebVector
<WebKit::WebMediaConstraint
> mandatory
;
42 constraints
.getMandatoryConstraints(mandatory
);
43 GetNativeMediaConstraints(mandatory
, &mandatory_
);
44 WebKit::WebVector
<WebKit::WebMediaConstraint
> optional
;
45 constraints
.getOptionalConstraints(optional
);
46 GetNativeMediaConstraints(optional
, &optional_
);
49 RTCMediaConstraints::~RTCMediaConstraints() {}
51 const webrtc::MediaConstraintsInterface::Constraints
&
52 RTCMediaConstraints::GetMandatory() const {
56 const webrtc::MediaConstraintsInterface::Constraints
&
57 RTCMediaConstraints::GetOptional() const {
61 } // namespace content