Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(171)

Side by Side Diff: webrtc/api/java/jni/androidvideocapturer_jni.cc

Issue 2013433003: WIP: Android Camera2 capture implementation (Closed) Base URL: https://chromium.googlesource.com/external/webrtc.git@master
Patch Set: Fix CaptureFormat jni parsing Created 4 years, 7 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
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 115 matching lines...) Expand 10 before | Expand all | Expand 10 after
126 jobject j_list_of_formats = jni->CallObjectMethod( 126 jobject j_list_of_formats = jni->CallObjectMethod(
127 *j_video_capturer_, 127 *j_video_capturer_,
128 GetMethodID(jni, *j_video_capturer_class_, "getSupportedFormats", 128 GetMethodID(jni, *j_video_capturer_class_, "getSupportedFormats",
129 "()Ljava/util/List;")); 129 "()Ljava/util/List;"));
130 CHECK_EXCEPTION(jni) << "error during getSupportedFormats"; 130 CHECK_EXCEPTION(jni) << "error during getSupportedFormats";
131 131
132 // Extract Java List<CaptureFormat> to std::vector<cricket::VideoFormat>. 132 // Extract Java List<CaptureFormat> to std::vector<cricket::VideoFormat>.
133 jclass j_list_class = jni->FindClass("java/util/List"); 133 jclass j_list_class = jni->FindClass("java/util/List");
134 jclass j_format_class = 134 jclass j_format_class =
135 jni->FindClass("org/webrtc/CameraEnumerationAndroid$CaptureFormat"); 135 jni->FindClass("org/webrtc/CameraEnumerationAndroid$CaptureFormat");
136 jclass j_size_class =
137 jni->FindClass("org/webrtc/CameraEnumerationAndroid$CaptureFormat$Size");
138 jclass j_framerate_class = jni->FindClass(
139 "org/webrtc/CameraEnumerationAndroid$CaptureFormat$FramerateRange");
140
136 const int size = jni->CallIntMethod( 141 const int size = jni->CallIntMethod(
137 j_list_of_formats, GetMethodID(jni, j_list_class, "size", "()I")); 142 j_list_of_formats, GetMethodID(jni, j_list_class, "size", "()I"));
138 jmethodID j_get = 143 jmethodID j_get =
139 GetMethodID(jni, j_list_class, "get", "(I)Ljava/lang/Object;"); 144 GetMethodID(jni, j_list_class, "get", "(I)Ljava/lang/Object;");
140 jfieldID j_width_field = GetFieldID(jni, j_format_class, "width", "I"); 145 jfieldID j_size_field =
141 jfieldID j_height_field = GetFieldID(jni, j_format_class, "height", "I"); 146 GetFieldID(jni, j_format_class, "size",
147 "org/webrtc/CameraEnumerationAndroid$CaptureFormat$Size");
148 jfieldID j_framerate_field = GetFieldID(
149 jni, j_format_class, "framerate",
150 "org/webrtc/CameraEnumerationAndroid$CaptureFormat$FramerateRange");
151 jfieldID j_width_field = GetFieldID(jni, j_size_class, "width", "I");
152 jfieldID j_height_field = GetFieldID(jni, j_size_class, "height", "I");
142 jfieldID j_max_framerate_field = 153 jfieldID j_max_framerate_field =
143 GetFieldID(jni, j_format_class, "maxFramerate", "I"); 154 GetFieldID(jni, j_framerate_class, "max", "I");
144 155
145 std::vector<cricket::VideoFormat> formats; 156 std::vector<cricket::VideoFormat> formats;
146 formats.reserve(size); 157 formats.reserve(size);
147 for (int i = 0; i < size; ++i) { 158 for (int i = 0; i < size; ++i) {
148 jobject j_format = jni->CallObjectMethod(j_list_of_formats, j_get, i); 159 jobject j_format = jni->CallObjectMethod(j_list_of_formats, j_get, i);
160 jobject j_size = GetObjectField(jni, j_format, j_size_field);
161 jobject j_framerate = GetObjectField(jni, j_format, j_framerate_field);
149 const int frame_interval = cricket::VideoFormat::FpsToInterval( 162 const int frame_interval = cricket::VideoFormat::FpsToInterval(
150 (GetIntField(jni, j_format, j_max_framerate_field) + 999) / 1000); 163 (GetIntField(jni, j_framerate, j_max_framerate_field) + 999) / 1000);
151 formats.emplace_back(GetIntField(jni, j_format, j_width_field), 164 formats.emplace_back(GetIntField(jni, j_size, j_height_field),
152 GetIntField(jni, j_format, j_height_field), 165 GetIntField(jni, j_size, j_height_field),
153 frame_interval, cricket::FOURCC_NV21); 166 frame_interval, cricket::FOURCC_NV21);
154 } 167 }
155 CHECK_EXCEPTION(jni) << "error while extracting formats"; 168 CHECK_EXCEPTION(jni) << "error while extracting formats";
156 return formats; 169 return formats;
157 } 170 }
158 171
159 void AndroidVideoCapturerJni::OnCapturerStarted(bool success) { 172 void AndroidVideoCapturerJni::OnCapturerStarted(bool success) {
160 LOG(LS_INFO) << "AndroidVideoCapturerJni capture started: " << success; 173 LOG(LS_INFO) << "AndroidVideoCapturerJni capture started: " << success;
161 AsyncCapturerInvoke("OnCapturerStarted", 174 AsyncCapturerInvoke("OnCapturerStarted",
162 &webrtc::AndroidVideoCapturer::OnCapturerStarted, 175 &webrtc::AndroidVideoCapturer::OnCapturerStarted,
(...skipping 83 matching lines...) Expand 10 before | Expand all | Expand 10 after
246 259
247 JOW(void, VideoCapturer_00024NativeObserver_nativeOnOutputFormatRequest) 260 JOW(void, VideoCapturer_00024NativeObserver_nativeOnOutputFormatRequest)
248 (JNIEnv* jni, jclass, jlong j_capturer, jint j_width, jint j_height, 261 (JNIEnv* jni, jclass, jlong j_capturer, jint j_width, jint j_height,
249 jint j_fps) { 262 jint j_fps) {
250 LOG(LS_INFO) << "NativeObserver_nativeOnOutputFormatRequest"; 263 LOG(LS_INFO) << "NativeObserver_nativeOnOutputFormatRequest";
251 reinterpret_cast<AndroidVideoCapturerJni*>(j_capturer)->OnOutputFormatRequest( 264 reinterpret_cast<AndroidVideoCapturerJni*>(j_capturer)->OnOutputFormatRequest(
252 j_width, j_height, j_fps); 265 j_width, j_height, j_fps);
253 } 266 }
254 267
255 } // namespace webrtc_jni 268 } // namespace webrtc_jni
OLDNEW
« no previous file with comments | « webrtc/api/java/android/org/webrtc/VideoCapturerAndroid2.java ('k') | webrtc/api/java/jni/classreferenceholder.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698