OLD | NEW |
1 // Copyright 2016 The Chromium Authors. All rights reserved. | 1 // Copyright 2016 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/capture/video/android/photo_capabilities.h" | 5 #include "media/capture/video/android/photo_capabilities.h" |
6 | 6 |
7 #include "base/android/jni_android.h" | 7 #include "base/android/jni_android.h" |
8 #include "base/android/jni_array.h" | 8 #include "base/android/jni_array.h" |
9 #include "base/android/jni_string.h" | 9 #include "base/android/jni_string.h" |
10 #include "jni/PhotoCapabilities_jni.h" | 10 #include "jni/PhotoCapabilities_jni.h" |
11 | 11 |
12 using base::android::AttachCurrentThread; | 12 using base::android::AttachCurrentThread; |
13 | 13 |
14 namespace media { | 14 namespace media { |
15 | 15 |
| 16 namespace { |
| 17 |
| 18 static_assert( |
| 19 std::is_same<int, |
| 20 std::underlying_type< |
| 21 PhotoCapabilities::AndroidMeteringMode>::type>::value, |
| 22 "AndroidMeteringMode underlying type should be int"); |
| 23 |
| 24 std::vector<PhotoCapabilities::AndroidMeteringMode> ToAndroidMeteringModes( |
| 25 base::android::ScopedJavaLocalRef<jintArray> jni_modes) { |
| 26 JNIEnv* env = AttachCurrentThread(); |
| 27 std::vector<PhotoCapabilities::AndroidMeteringMode> modes; |
| 28 if (jni_modes.obj()) { |
| 29 base::android::JavaIntArrayToIntVector( |
| 30 env, jni_modes.obj(), reinterpret_cast<std::vector<int>*>(&modes)); |
| 31 } |
| 32 return modes; |
| 33 } |
| 34 |
| 35 } // anonymous namespace |
| 36 |
16 PhotoCapabilities::PhotoCapabilities( | 37 PhotoCapabilities::PhotoCapabilities( |
17 base::android::ScopedJavaLocalRef<jobject> object) | 38 base::android::ScopedJavaLocalRef<jobject> object) |
18 : object_(object) {} | 39 : object_(object) {} |
19 | 40 |
20 PhotoCapabilities::~PhotoCapabilities() {} | 41 PhotoCapabilities::~PhotoCapabilities() {} |
21 | 42 |
22 int PhotoCapabilities::getMinIso() const { | 43 int PhotoCapabilities::getMinIso() const { |
23 DCHECK(!object_.is_null()); | 44 DCHECK(!object_.is_null()); |
24 return Java_PhotoCapabilities_getMinIso(AttachCurrentThread(), object_); | 45 return Java_PhotoCapabilities_getMinIso(AttachCurrentThread(), object_); |
25 } | 46 } |
(...skipping 73 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
99 DCHECK(!object_.is_null()); | 120 DCHECK(!object_.is_null()); |
100 return Java_PhotoCapabilities_getStepZoom(AttachCurrentThread(), object_); | 121 return Java_PhotoCapabilities_getStepZoom(AttachCurrentThread(), object_); |
101 } | 122 } |
102 | 123 |
103 PhotoCapabilities::AndroidMeteringMode PhotoCapabilities::getFocusMode() const { | 124 PhotoCapabilities::AndroidMeteringMode PhotoCapabilities::getFocusMode() const { |
104 DCHECK(!object_.is_null()); | 125 DCHECK(!object_.is_null()); |
105 return static_cast<AndroidMeteringMode>( | 126 return static_cast<AndroidMeteringMode>( |
106 Java_PhotoCapabilities_getFocusMode(AttachCurrentThread(), object_)); | 127 Java_PhotoCapabilities_getFocusMode(AttachCurrentThread(), object_)); |
107 } | 128 } |
108 | 129 |
| 130 std::vector<PhotoCapabilities::AndroidMeteringMode> |
| 131 PhotoCapabilities::getFocusModes() const { |
| 132 DCHECK(!object_.is_null()); |
| 133 |
| 134 JNIEnv* env = AttachCurrentThread(); |
| 135 base::android::ScopedJavaLocalRef<jintArray> jni_modes = |
| 136 Java_PhotoCapabilities_getFocusModes(env, object_); |
| 137 return ToAndroidMeteringModes(jni_modes); |
| 138 } |
| 139 |
109 PhotoCapabilities::AndroidMeteringMode PhotoCapabilities::getExposureMode() | 140 PhotoCapabilities::AndroidMeteringMode PhotoCapabilities::getExposureMode() |
110 const { | 141 const { |
111 DCHECK(!object_.is_null()); | 142 DCHECK(!object_.is_null()); |
112 return static_cast<AndroidMeteringMode>( | 143 return static_cast<AndroidMeteringMode>( |
113 Java_PhotoCapabilities_getExposureMode(AttachCurrentThread(), object_)); | 144 Java_PhotoCapabilities_getExposureMode(AttachCurrentThread(), object_)); |
114 } | 145 } |
115 | 146 |
| 147 std::vector<PhotoCapabilities::AndroidMeteringMode> |
| 148 PhotoCapabilities::getExposureModes() const { |
| 149 DCHECK(!object_.is_null()); |
| 150 |
| 151 JNIEnv* env = AttachCurrentThread(); |
| 152 base::android::ScopedJavaLocalRef<jintArray> jni_modes = |
| 153 Java_PhotoCapabilities_getExposureModes(env, object_); |
| 154 return ToAndroidMeteringModes(jni_modes); |
| 155 } |
| 156 |
116 double PhotoCapabilities::getMinExposureCompensation() const { | 157 double PhotoCapabilities::getMinExposureCompensation() const { |
117 DCHECK(!object_.is_null()); | 158 DCHECK(!object_.is_null()); |
118 return Java_PhotoCapabilities_getMinExposureCompensation( | 159 return Java_PhotoCapabilities_getMinExposureCompensation( |
119 AttachCurrentThread(), object_); | 160 AttachCurrentThread(), object_); |
120 } | 161 } |
121 | 162 |
122 double PhotoCapabilities::getMaxExposureCompensation() const { | 163 double PhotoCapabilities::getMaxExposureCompensation() const { |
123 DCHECK(!object_.is_null()); | 164 DCHECK(!object_.is_null()); |
124 return Java_PhotoCapabilities_getMaxExposureCompensation( | 165 return Java_PhotoCapabilities_getMaxExposureCompensation( |
125 AttachCurrentThread(), object_); | 166 AttachCurrentThread(), object_); |
(...skipping 12 matching lines...) Expand all Loading... |
138 } | 179 } |
139 | 180 |
140 PhotoCapabilities::AndroidMeteringMode PhotoCapabilities::getWhiteBalanceMode() | 181 PhotoCapabilities::AndroidMeteringMode PhotoCapabilities::getWhiteBalanceMode() |
141 const { | 182 const { |
142 DCHECK(!object_.is_null()); | 183 DCHECK(!object_.is_null()); |
143 return static_cast<AndroidMeteringMode>( | 184 return static_cast<AndroidMeteringMode>( |
144 Java_PhotoCapabilities_getWhiteBalanceMode(AttachCurrentThread(), | 185 Java_PhotoCapabilities_getWhiteBalanceMode(AttachCurrentThread(), |
145 object_)); | 186 object_)); |
146 } | 187 } |
147 | 188 |
| 189 std::vector<PhotoCapabilities::AndroidMeteringMode> |
| 190 PhotoCapabilities::getWhiteBalanceModes() const { |
| 191 DCHECK(!object_.is_null()); |
| 192 |
| 193 JNIEnv* env = AttachCurrentThread(); |
| 194 base::android::ScopedJavaLocalRef<jintArray> jni_modes = |
| 195 Java_PhotoCapabilities_getWhiteBalanceModes(env, object_); |
| 196 return ToAndroidMeteringModes(jni_modes); |
| 197 } |
| 198 |
148 std::vector<PhotoCapabilities::AndroidFillLightMode> | 199 std::vector<PhotoCapabilities::AndroidFillLightMode> |
149 PhotoCapabilities::getFillLightModes() const { | 200 PhotoCapabilities::getFillLightModes() const { |
150 DCHECK(!object_.is_null()); | 201 DCHECK(!object_.is_null()); |
151 | 202 |
152 JNIEnv* env = AttachCurrentThread(); | 203 JNIEnv* env = AttachCurrentThread(); |
153 std::vector<AndroidFillLightMode> modes; | 204 std::vector<AndroidFillLightMode> modes; |
154 static_assert( | 205 static_assert( |
155 std::is_same<int, | 206 std::is_same<int, |
156 std::underlying_type<AndroidFillLightMode>::type>::value, | 207 std::underlying_type<AndroidFillLightMode>::type>::value, |
157 "AndroidFillLightMode underlying type should be int"); | 208 "AndroidFillLightMode underlying type should be int"); |
(...skipping 42 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
200 AttachCurrentThread(), object_); | 251 AttachCurrentThread(), object_); |
201 } | 252 } |
202 | 253 |
203 int PhotoCapabilities::getStepColorTemperature() const { | 254 int PhotoCapabilities::getStepColorTemperature() const { |
204 DCHECK(!object_.is_null()); | 255 DCHECK(!object_.is_null()); |
205 return Java_PhotoCapabilities_getStepColorTemperature(AttachCurrentThread(), | 256 return Java_PhotoCapabilities_getStepColorTemperature(AttachCurrentThread(), |
206 object_); | 257 object_); |
207 } | 258 } |
208 | 259 |
209 } // namespace media | 260 } // namespace media |
OLD | NEW |