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

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

Issue 2066773002: Android: Add Size class. (Closed) Base URL: https://chromium.googlesource.com/external/webrtc.git@master
Patch Set: Created 4 years, 6 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 114 matching lines...) Expand 10 before | Expand all | Expand 10 after
125 jobject j_list_of_formats = jni->CallObjectMethod( 125 jobject j_list_of_formats = jni->CallObjectMethod(
126 *j_video_capturer_, 126 *j_video_capturer_,
127 GetMethodID(jni, *j_video_capturer_class_, "getSupportedFormats", 127 GetMethodID(jni, *j_video_capturer_class_, "getSupportedFormats",
128 "()Ljava/util/List;")); 128 "()Ljava/util/List;"));
129 CHECK_EXCEPTION(jni) << "error during getSupportedFormats"; 129 CHECK_EXCEPTION(jni) << "error during getSupportedFormats";
130 130
131 // Extract Java List<CaptureFormat> to std::vector<cricket::VideoFormat>. 131 // Extract Java List<CaptureFormat> to std::vector<cricket::VideoFormat>.
132 jclass j_list_class = jni->FindClass("java/util/List"); 132 jclass j_list_class = jni->FindClass("java/util/List");
133 jclass j_format_class = 133 jclass j_format_class =
134 jni->FindClass("org/webrtc/CameraEnumerationAndroid$CaptureFormat"); 134 jni->FindClass("org/webrtc/CameraEnumerationAndroid$CaptureFormat");
135 jclass j_size_class =
136 jni->FindClass("org/webrtc/CameraEnumerationAndroid$CaptureFormat$Size");
135 jclass j_framerate_class = jni->FindClass( 137 jclass j_framerate_class = jni->FindClass(
136 "org/webrtc/CameraEnumerationAndroid$CaptureFormat$FramerateRange"); 138 "org/webrtc/CameraEnumerationAndroid$CaptureFormat$FramerateRange");
139
137 const int size = jni->CallIntMethod( 140 const int size = jni->CallIntMethod(
138 j_list_of_formats, GetMethodID(jni, j_list_class, "size", "()I")); 141 j_list_of_formats, GetMethodID(jni, j_list_class, "size", "()I"));
139 jmethodID j_get = 142 jmethodID j_get =
140 GetMethodID(jni, j_list_class, "get", "(I)Ljava/lang/Object;"); 143 GetMethodID(jni, j_list_class, "get", "(I)Ljava/lang/Object;");
144 jfieldID j_size_field =
145 GetFieldID(jni, j_format_class, "size",
146 "org/webrtc/CameraEnumerationAndroid$CaptureFormat$Size");
141 jfieldID j_framerate_field = GetFieldID( 147 jfieldID j_framerate_field = GetFieldID(
142 jni, j_format_class, "framerate", 148 jni, j_format_class, "framerate",
143 "Lorg/webrtc/CameraEnumerationAndroid$CaptureFormat$FramerateRange;"); 149 "org/webrtc/CameraEnumerationAndroid$CaptureFormat$FramerateRange");
144 jfieldID j_width_field = GetFieldID(jni, j_format_class, "width", "I"); 150 jfieldID j_width_field = GetFieldID(jni, j_size_class, "width", "I");
145 jfieldID j_height_field = GetFieldID(jni, j_format_class, "height", "I"); 151 jfieldID j_height_field = GetFieldID(jni, j_size_class, "height", "I");
146 jfieldID j_max_framerate_field = 152 jfieldID j_max_framerate_field =
147 GetFieldID(jni, j_framerate_class, "max", "I"); 153 GetFieldID(jni, j_framerate_class, "max", "I");
148 154
149 std::vector<cricket::VideoFormat> formats; 155 std::vector<cricket::VideoFormat> formats;
150 formats.reserve(size); 156 formats.reserve(size);
151 for (int i = 0; i < size; ++i) { 157 for (int i = 0; i < size; ++i) {
152 jobject j_format = jni->CallObjectMethod(j_list_of_formats, j_get, i); 158 jobject j_format = jni->CallObjectMethod(j_list_of_formats, j_get, i);
159 jobject j_size = GetObjectField(jni, j_format, j_size_field);
153 jobject j_framerate = GetObjectField(jni, j_format, j_framerate_field); 160 jobject j_framerate = GetObjectField(jni, j_format, j_framerate_field);
154 const int frame_interval = cricket::VideoFormat::FpsToInterval( 161 const int frame_interval = cricket::VideoFormat::FpsToInterval(
155 (GetIntField(jni, j_framerate, j_max_framerate_field) + 999) / 1000); 162 (GetIntField(jni, j_framerate, j_max_framerate_field) + 999) / 1000);
156 formats.emplace_back(GetIntField(jni, j_format, j_width_field), 163 formats.emplace_back(GetIntField(jni, j_size, j_height_field),
157 GetIntField(jni, j_format, j_height_field), 164 GetIntField(jni, j_size, j_height_field),
158 frame_interval, cricket::FOURCC_NV21); 165 frame_interval, cricket::FOURCC_NV21);
159 } 166 }
160 CHECK_EXCEPTION(jni) << "error while extracting formats"; 167 CHECK_EXCEPTION(jni) << "error while extracting formats";
161 return formats; 168 return formats;
162 } 169 }
163 170
164 void AndroidVideoCapturerJni::OnCapturerStarted(bool success) { 171 void AndroidVideoCapturerJni::OnCapturerStarted(bool success) {
165 LOG(LS_INFO) << "AndroidVideoCapturerJni capture started: " << success; 172 LOG(LS_INFO) << "AndroidVideoCapturerJni capture started: " << success;
166 AsyncCapturerInvoke( 173 AsyncCapturerInvoke(
167 RTC_FROM_HERE, &webrtc::AndroidVideoCapturer::OnCapturerStarted, success); 174 RTC_FROM_HERE, &webrtc::AndroidVideoCapturer::OnCapturerStarted, success);
(...skipping 163 matching lines...) Expand 10 before | Expand all | Expand 10 after
331 338
332 JOW(void, VideoCapturer_00024NativeObserver_nativeOnOutputFormatRequest) 339 JOW(void, VideoCapturer_00024NativeObserver_nativeOnOutputFormatRequest)
333 (JNIEnv* jni, jclass, jlong j_capturer, jint j_width, jint j_height, 340 (JNIEnv* jni, jclass, jlong j_capturer, jint j_width, jint j_height,
334 jint j_fps) { 341 jint j_fps) {
335 LOG(LS_INFO) << "NativeObserver_nativeOnOutputFormatRequest"; 342 LOG(LS_INFO) << "NativeObserver_nativeOnOutputFormatRequest";
336 reinterpret_cast<AndroidVideoCapturerJni*>(j_capturer)->OnOutputFormatRequest( 343 reinterpret_cast<AndroidVideoCapturerJni*>(j_capturer)->OnOutputFormatRequest(
337 j_width, j_height, j_fps); 344 j_width, j_height, j_fps);
338 } 345 }
339 346
340 } // namespace webrtc_jni 347 } // namespace webrtc_jni
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698