OLD | NEW |
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 38 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
49 << name.name() | 49 << name.name() |
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* capture_formats) { |
60 NOTIMPLEMENTED(); | 60 int id; |
| 61 if (!base::StringToInt(device.id(), &id)) |
| 62 return; |
| 63 JNIEnv* env = AttachCurrentThread(); |
| 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 base::android::ScopedJavaLocalRef<jobject> format( |
| 72 env, env->GetObjectArrayElement(collected_formats.obj(), i)); |
| 73 |
| 74 VideoPixelFormat pixel_format = media::PIXEL_FORMAT_UNKNOWN; |
| 75 switch (media::Java_CaptureFormat_getPixelFormat(env, format.obj())) { |
| 76 case VideoCaptureDeviceAndroid::ANDROID_IMAGEFORMAT_YV12: |
| 77 pixel_format = media::PIXEL_FORMAT_YV12; |
| 78 break; |
| 79 case VideoCaptureDeviceAndroid::ANDROID_IMAGEFORMAT_NV21: |
| 80 pixel_format = media::PIXEL_FORMAT_NV21; |
| 81 break; |
| 82 default: |
| 83 break; |
| 84 } |
| 85 VideoCaptureFormat capture_format( |
| 86 gfx::Size(media::Java_CaptureFormat_getWidth(env, format.obj()), |
| 87 media::Java_CaptureFormat_getHeight(env, format.obj())), |
| 88 media::Java_CaptureFormat_getFramerate(env, format.obj()), |
| 89 pixel_format); |
| 90 capture_formats->push_back(capture_format); |
| 91 DVLOG(1) << device.name() << " resolution: " |
| 92 << capture_format.frame_size.ToString() << ", fps: " |
| 93 << capture_format.frame_rate << ", pixel format: " |
| 94 << capture_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 Loading... |
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 |
OLD | NEW |