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