OLD | NEW |
1 /* | 1 /* |
2 * Copyright 2015 The WebRTC project authors. All Rights Reserved. | 2 * Copyright 2015 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 |
(...skipping 116 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
127 jobject j_list_of_formats = jni->CallObjectMethod( | 127 jobject j_list_of_formats = jni->CallObjectMethod( |
128 *j_video_capturer_, | 128 *j_video_capturer_, |
129 GetMethodID(jni, *j_video_capturer_class_, "getSupportedFormats", | 129 GetMethodID(jni, *j_video_capturer_class_, "getSupportedFormats", |
130 "()Ljava/util/List;")); | 130 "()Ljava/util/List;")); |
131 CHECK_EXCEPTION(jni) << "error during getSupportedFormats"; | 131 CHECK_EXCEPTION(jni) << "error during getSupportedFormats"; |
132 | 132 |
133 // Extract Java List<CaptureFormat> to std::vector<cricket::VideoFormat>. | 133 // Extract Java List<CaptureFormat> to std::vector<cricket::VideoFormat>. |
134 jclass j_list_class = jni->FindClass("java/util/List"); | 134 jclass j_list_class = jni->FindClass("java/util/List"); |
135 jclass j_format_class = | 135 jclass j_format_class = |
136 jni->FindClass("org/webrtc/CameraEnumerationAndroid$CaptureFormat"); | 136 jni->FindClass("org/webrtc/CameraEnumerationAndroid$CaptureFormat"); |
| 137 jclass j_framerate_class = jni->FindClass( |
| 138 "org/webrtc/CameraEnumerationAndroid$CaptureFormat$FramerateRange"); |
137 const int size = jni->CallIntMethod( | 139 const int size = jni->CallIntMethod( |
138 j_list_of_formats, GetMethodID(jni, j_list_class, "size", "()I")); | 140 j_list_of_formats, GetMethodID(jni, j_list_class, "size", "()I")); |
139 jmethodID j_get = | 141 jmethodID j_get = |
140 GetMethodID(jni, j_list_class, "get", "(I)Ljava/lang/Object;"); | 142 GetMethodID(jni, j_list_class, "get", "(I)Ljava/lang/Object;"); |
| 143 jfieldID j_framerate_field = GetFieldID( |
| 144 jni, j_format_class, "framerate", |
| 145 "org/webrtc/CameraEnumerationAndroid$CaptureFormat$FramerateRange"); |
141 jfieldID j_width_field = GetFieldID(jni, j_format_class, "width", "I"); | 146 jfieldID j_width_field = GetFieldID(jni, j_format_class, "width", "I"); |
142 jfieldID j_height_field = GetFieldID(jni, j_format_class, "height", "I"); | 147 jfieldID j_height_field = GetFieldID(jni, j_format_class, "height", "I"); |
143 jfieldID j_max_framerate_field = | 148 jfieldID j_max_framerate_field = |
144 GetFieldID(jni, j_format_class, "maxFramerate", "I"); | 149 GetFieldID(jni, j_framerate_class, "max", "I"); |
145 | 150 |
146 std::vector<cricket::VideoFormat> formats; | 151 std::vector<cricket::VideoFormat> formats; |
147 formats.reserve(size); | 152 formats.reserve(size); |
148 for (int i = 0; i < size; ++i) { | 153 for (int i = 0; i < size; ++i) { |
149 jobject j_format = jni->CallObjectMethod(j_list_of_formats, j_get, i); | 154 jobject j_format = jni->CallObjectMethod(j_list_of_formats, j_get, i); |
| 155 jobject j_framerate = GetObjectField(jni, j_format, j_framerate_field); |
150 const int frame_interval = cricket::VideoFormat::FpsToInterval( | 156 const int frame_interval = cricket::VideoFormat::FpsToInterval( |
151 (GetIntField(jni, j_format, j_max_framerate_field) + 999) / 1000); | 157 (GetIntField(jni, j_framerate, j_max_framerate_field) + 999) / 1000); |
152 formats.emplace_back(GetIntField(jni, j_format, j_width_field), | 158 formats.emplace_back(GetIntField(jni, j_format, j_width_field), |
153 GetIntField(jni, j_format, j_height_field), | 159 GetIntField(jni, j_format, j_height_field), |
154 frame_interval, cricket::FOURCC_NV21); | 160 frame_interval, cricket::FOURCC_NV21); |
155 } | 161 } |
156 CHECK_EXCEPTION(jni) << "error while extracting formats"; | 162 CHECK_EXCEPTION(jni) << "error while extracting formats"; |
157 return formats; | 163 return formats; |
158 } | 164 } |
159 | 165 |
160 void AndroidVideoCapturerJni::OnCapturerStarted(bool success) { | 166 void AndroidVideoCapturerJni::OnCapturerStarted(bool success) { |
161 LOG(LS_INFO) << "AndroidVideoCapturerJni capture started: " << success; | 167 LOG(LS_INFO) << "AndroidVideoCapturerJni capture started: " << success; |
(...skipping 172 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
334 | 340 |
335 JOW(void, VideoCapturer_00024NativeObserver_nativeOnOutputFormatRequest) | 341 JOW(void, VideoCapturer_00024NativeObserver_nativeOnOutputFormatRequest) |
336 (JNIEnv* jni, jclass, jlong j_capturer, jint j_width, jint j_height, | 342 (JNIEnv* jni, jclass, jlong j_capturer, jint j_width, jint j_height, |
337 jint j_fps) { | 343 jint j_fps) { |
338 LOG(LS_INFO) << "NativeObserver_nativeOnOutputFormatRequest"; | 344 LOG(LS_INFO) << "NativeObserver_nativeOnOutputFormatRequest"; |
339 reinterpret_cast<AndroidVideoCapturerJni*>(j_capturer)->OnOutputFormatRequest( | 345 reinterpret_cast<AndroidVideoCapturerJni*>(j_capturer)->OnOutputFormatRequest( |
340 j_width, j_height, j_fps); | 346 j_width, j_height, j_fps); |
341 } | 347 } |
342 | 348 |
343 } // namespace webrtc_jni | 349 } // namespace webrtc_jni |
OLD | NEW |