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

Side by Side 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 unified diff | Download patch | Annotate | Revision Log
OLDNEW
1 // Copyright (c) 2013 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2013 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #include "media/video/capture/android/video_capture_device_android.h" 5 #include "media/video/capture/android/video_capture_device_android.h"
6 6
7 #include <string> 7 #include <string>
8 8
9 #include "base/android/jni_android.h" 9 #include "base/android/jni_android.h"
10 #include "base/android/jni_string.h" 10 #include "base/android/jni_string.h"
(...skipping 39 matching lines...) Expand 10 before | Expand all | Expand 10 after
50 << ", unique_id=" 50 << ", unique_id="
51 << name.id() 51 << name.id()
52 << ", orientation " 52 << ", orientation "
53 << Java_ChromiumCameraInfo_getOrientation(env, ci.obj()); 53 << Java_ChromiumCameraInfo_getOrientation(env, ci.obj());
54 } 54 }
55 } 55 }
56 56
57 // static 57 // static
58 void VideoCaptureDevice::GetDeviceSupportedFormats(const Name& device, 58 void VideoCaptureDevice::GetDeviceSupportedFormats(const Name& device,
59 VideoCaptureFormats* formats) { 59 VideoCaptureFormats* formats) {
60 NOTIMPLEMENTED(); 60 JNIEnv* env = AttachCurrentThread();
61 int id;
62 if (!base::StringToInt(device.id(), &id))
63 return;
64 base::android::ScopedJavaLocalRef<jobjectArray> collected_formats =
65 Java_VideoCapture_getDeviceSupportedFormats(env, id);
66 if (collected_formats.is_null())
67 return;
68
69 jsize num_formats = env->GetArrayLength(collected_formats.obj());
70 for (int i = 0; i < num_formats; ++i) {
71 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.
72
73 VideoPixelFormat pixel_format = media::PIXEL_FORMAT_UNKNOWN;
74 switch (media::Java_CaptureFormat_getPixelFormat(env, format)) {
75 case VideoCaptureDeviceAndroid::ANDROID_IMAGEFORMAT_YV12:
76 pixel_format = media::PIXEL_FORMAT_YV12;
77 break;
78 case VideoCaptureDeviceAndroid::ANDROID_IMAGEFORMAT_NV21:
79 pixel_format = media::PIXEL_FORMAT_NV21;
80 break;
81 default:
82 break;
83 }
84 formats->push_back(VideoCaptureFormat(
85 gfx::Size(media::Java_CaptureFormat_getWidth(env, format),
86 media::Java_CaptureFormat_getHeight(env, format)),
87 media::Java_CaptureFormat_getFramerate(env, format),
88 pixel_format));
89 env->DeleteLocalRef(format);
90
91 VideoCaptureFormat& last_format = formats->back();
92 DVLOG(1) << device.name() << " resolution: " <<
93 last_format.frame_size.ToString() << ", fps: " << last_format.frame_rate
94 << ", pixel format: " << last_format.pixel_format;
95 }
61 } 96 }
62 97
63 const std::string VideoCaptureDevice::Name::GetModel() const { 98 const std::string VideoCaptureDevice::Name::GetModel() const {
64 // Android cameras are not typically USB devices, and this method is currently 99 // Android cameras are not typically USB devices, and this method is currently
65 // only used for USB model identifiers, so this implementation just indicates 100 // only used for USB model identifiers, so this implementation just indicates
66 // an unknown device model. 101 // an unknown device model.
67 return ""; 102 return "";
68 } 103 }
69 104
70 // static 105 // static
(...skipping 179 matching lines...) Expand 10 before | Expand all | Expand 10 after
250 void VideoCaptureDeviceAndroid::SetErrorState(const std::string& reason) { 285 void VideoCaptureDeviceAndroid::SetErrorState(const std::string& reason) {
251 LOG(ERROR) << "VideoCaptureDeviceAndroid::SetErrorState: " << reason; 286 LOG(ERROR) << "VideoCaptureDeviceAndroid::SetErrorState: " << reason;
252 { 287 {
253 base::AutoLock lock(lock_); 288 base::AutoLock lock(lock_);
254 state_ = kError; 289 state_ = kError;
255 } 290 }
256 client_->OnError(reason); 291 client_->OnError(reason);
257 } 292 }
258 293
259 } // namespace media 294 } // namespace media
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698