OLD | NEW |
| (Empty) |
1 /* | |
2 * Copyright 2017 The WebRTC project authors. All Rights Reserved. | |
3 * | |
4 * Use of this source code is governed by a BSD-style license | |
5 * that can be found in the LICENSE file in the root of the source | |
6 * tree. An additional intellectual property rights grant can be found | |
7 * in the file PATENTS. All contributing project authors may | |
8 * be found in the AUTHORS file in the root of the source tree. | |
9 */ | |
10 | |
11 #include "webrtc/sdk/android/src/jni/pc/mediaconstraints_jni.h" | |
12 | |
13 namespace webrtc_jni { | |
14 | |
15 MediaConstraintsJni::MediaConstraintsJni(JNIEnv* jni, jobject j_constraints) { | |
16 PopulateConstraintsFromJavaPairList(jni, j_constraints, "mandatory", | |
17 &mandatory_); | |
18 PopulateConstraintsFromJavaPairList(jni, j_constraints, "optional", | |
19 &optional_); | |
20 } | |
21 | |
22 // static | |
23 void MediaConstraintsJni::PopulateConstraintsFromJavaPairList( | |
24 JNIEnv* jni, | |
25 jobject j_constraints, | |
26 const char* field_name, | |
27 Constraints* field) { | |
28 jfieldID j_id = GetFieldID(jni, GetObjectClass(jni, j_constraints), | |
29 field_name, "Ljava/util/List;"); | |
30 jobject j_list = GetObjectField(jni, j_constraints, j_id); | |
31 for (jobject entry : Iterable(jni, j_list)) { | |
32 jmethodID get_key = GetMethodID(jni, GetObjectClass(jni, entry), "getKey", | |
33 "()Ljava/lang/String;"); | |
34 jstring j_key = | |
35 reinterpret_cast<jstring>(jni->CallObjectMethod(entry, get_key)); | |
36 CHECK_EXCEPTION(jni) << "error during CallObjectMethod"; | |
37 jmethodID get_value = GetMethodID(jni, GetObjectClass(jni, entry), | |
38 "getValue", "()Ljava/lang/String;"); | |
39 jstring j_value = | |
40 reinterpret_cast<jstring>(jni->CallObjectMethod(entry, get_value)); | |
41 CHECK_EXCEPTION(jni) << "error during CallObjectMethod"; | |
42 field->push_back( | |
43 Constraint(JavaToStdString(jni, j_key), JavaToStdString(jni, j_value))); | |
44 } | |
45 } | |
46 | |
47 } // namespace webrtc_jni | |
OLD | NEW |