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

Unified Diff: media/video/capture/android/video_capture_device_android.cc

Issue 135213005: Add GetDeviceSupportedFormats to Android VideoCapture.java. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 6 years, 10 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 side-by-side diff with in-line comments
Download patch
Index: media/video/capture/android/video_capture_device_android.cc
diff --git a/media/video/capture/android/video_capture_device_android.cc b/media/video/capture/android/video_capture_device_android.cc
index d8b3796155dd7d087fc45511e9d1ad348da116eb..e13d92bb8a521d06cda0c3905d8c8052cf6117e6 100644
--- a/media/video/capture/android/video_capture_device_android.cc
+++ b/media/video/capture/android/video_capture_device_android.cc
@@ -57,7 +57,42 @@ void VideoCaptureDevice::GetDeviceNames(Names* device_names) {
// static
void VideoCaptureDevice::GetDeviceSupportedFormats(const Name& device,
VideoCaptureFormats* formats) {
- NOTIMPLEMENTED();
+ JNIEnv* env = AttachCurrentThread();
+ int id;
+ if (!base::StringToInt(device.id(), &id))
+ return;
+ base::android::ScopedJavaLocalRef<jobjectArray> collected_formats =
+ Java_VideoCapture_getDeviceSupportedFormats(env, id);
+ if (collected_formats.is_null())
+ return;
+
+ jsize num_formats = env->GetArrayLength(collected_formats.obj());
+ for (int i = 0; i < num_formats; ++i) {
+ jobject format = env->GetObjectArrayElement(collected_formats.obj(), i);
bulach 2014/02/12 12:48:20 nit: base::android::ScopedJavaLocalRef and remove
mcasas 2014/02/12 18:24:15 Done.
+
+ VideoPixelFormat pixel_format = media::PIXEL_FORMAT_UNKNOWN;
+ switch (media::Java_CaptureFormat_getPixelFormat(env, format)) {
+ case VideoCaptureDeviceAndroid::ANDROID_IMAGEFORMAT_YV12:
+ pixel_format = media::PIXEL_FORMAT_YV12;
+ break;
+ case VideoCaptureDeviceAndroid::ANDROID_IMAGEFORMAT_NV21:
+ pixel_format = media::PIXEL_FORMAT_NV21;
+ break;
+ default:
+ break;
+ }
+ formats->push_back(VideoCaptureFormat(
+ gfx::Size(media::Java_CaptureFormat_getWidth(env, format),
+ media::Java_CaptureFormat_getHeight(env, format)),
+ media::Java_CaptureFormat_getFramerate(env, format),
+ pixel_format));
+ env->DeleteLocalRef(format);
+
+ VideoCaptureFormat& last_format = formats->back();
+ DVLOG(1) << device.name() << " resolution: " <<
+ last_format.frame_size.ToString() << ", fps: " << last_format.frame_rate
+ << ", pixel format: " << last_format.pixel_format;
+ }
}
const std::string VideoCaptureDevice::Name::GetModel() const {

Powered by Google App Engine
This is Rietveld 408576698