OLD | NEW |
1 /* | 1 /* |
2 * Copyright 2017 The WebRTC project authors. All Rights Reserved. | 2 * Copyright 2017 The WebRTC project authors. All Rights Reserved. |
3 * | 3 * |
4 * Use of this source code is governed by a BSD-style license | 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 | 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 | 6 * tree. An additional intellectual property rights grant can be found |
7 * in the file PATENTS. All contributing project authors may | 7 * in the file PATENTS. All contributing project authors may |
8 * be found in the AUTHORS file in the root of the source tree. | 8 * be found in the AUTHORS file in the root of the source tree. |
9 */ | 9 */ |
10 | 10 |
11 #ifndef WEBRTC_SDK_ANDROID_SRC_JNI_VIDEO_JNI_H_ | 11 #include "webrtc/sdk/android/src/jni/pc/mediaconstraints_jni.h" |
12 #define WEBRTC_SDK_ANDROID_SRC_JNI_VIDEO_JNI_H_ | |
13 | |
14 #include <jni.h> | |
15 | |
16 #include "webrtc/rtc_base/scoped_ref_ptr.h" | |
17 | |
18 namespace cricket { | |
19 class WebRtcVideoEncoderFactory; | |
20 class WebRtcVideoDecoderFactory; | |
21 } // namespace cricket | |
22 | 12 |
23 namespace webrtc_jni { | 13 namespace webrtc_jni { |
24 | 14 |
25 class SurfaceTextureHelper; | 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 } |
26 | 21 |
27 cricket::WebRtcVideoEncoderFactory* CreateVideoEncoderFactory( | 22 // static |
| 23 void MediaConstraintsJni::PopulateConstraintsFromJavaPairList( |
28 JNIEnv* jni, | 24 JNIEnv* jni, |
29 jobject j_encoder_factory); | 25 jobject j_constraints, |
30 | 26 const char* field_name, |
31 cricket::WebRtcVideoDecoderFactory* CreateVideoDecoderFactory( | 27 Constraints* field) { |
32 JNIEnv* jni, | 28 jfieldID j_id = GetFieldID(jni, GetObjectClass(jni, j_constraints), |
33 jobject j_decoder_factory); | 29 field_name, "Ljava/util/List;"); |
34 | 30 jobject j_list = GetObjectField(jni, j_constraints, j_id); |
35 jobject GetJavaSurfaceTextureHelper( | 31 for (jobject entry : Iterable(jni, j_list)) { |
36 const rtc::scoped_refptr<SurfaceTextureHelper>& surface_texture_helper); | 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 } |
37 | 46 |
38 } // namespace webrtc_jni | 47 } // namespace webrtc_jni |
39 | |
40 #endif // WEBRTC_SDK_ANDROID_SRC_JNI_VIDEO_JNI_H_ | |
OLD | NEW |