James Dong | c371194 | 2010-01-19 17:45:38 -0800 | [diff] [blame] | 1 | /* |
| 2 | * Copyright (C) 2010 The Android Open Source Project |
| 3 | * |
| 4 | * Licensed under the Apache License, Version 2.0 (the "License"); |
| 5 | * you may not use this file except in compliance with the License. |
| 6 | * You may obtain a copy of the License at |
| 7 | * |
| 8 | * http://www.apache.org/licenses/LICENSE-2.0 |
| 9 | * |
| 10 | * Unless required by applicable law or agreed to in writing, software |
| 11 | * distributed under the License is distributed on an "AS IS" BASIS, |
| 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
| 13 | * See the License for the specific language governing permissions and |
| 14 | * limitations under the License. |
| 15 | */ |
| 16 | |
| 17 | //#define LOG_NDEBUG 0 |
| 18 | #define LOG_TAG "MediaProfilesJNI" |
| 19 | #include <utils/Log.h> |
| 20 | |
| 21 | #include <stdio.h> |
| 22 | #include <utils/threads.h> |
| 23 | |
| 24 | #include "jni.h" |
| 25 | #include "JNIHelp.h" |
| 26 | #include "android_runtime/AndroidRuntime.h" |
| 27 | #include <media/MediaProfiles.h> |
| 28 | |
| 29 | using namespace android; |
| 30 | |
| 31 | static Mutex sLock; |
| 32 | MediaProfiles *sProfiles = NULL; |
| 33 | |
| 34 | // This function is called from a static block in MediaProfiles.java class, |
| 35 | // which won't run until the first time an instance of this class is used. |
| 36 | static void |
| 37 | android_media_MediaProfiles_native_init(JNIEnv *env) |
| 38 | { |
| 39 | LOGV("native_init"); |
| 40 | Mutex::Autolock lock(sLock); |
| 41 | |
| 42 | if (sProfiles == NULL) { |
| 43 | sProfiles = MediaProfiles::getInstance(); |
| 44 | } |
| 45 | } |
| 46 | |
James Dong | d32fba4 | 2010-02-11 14:32:13 -0800 | [diff] [blame] | 47 | static jint |
James Dong | c371194 | 2010-01-19 17:45:38 -0800 | [diff] [blame] | 48 | android_media_MediaProfiles_native_get_num_file_formats(JNIEnv *env, jobject thiz) |
| 49 | { |
| 50 | LOGV("native_get_num_file_formats"); |
| 51 | return sProfiles->getOutputFileFormats().size(); |
| 52 | } |
| 53 | |
James Dong | d32fba4 | 2010-02-11 14:32:13 -0800 | [diff] [blame] | 54 | static jint |
James Dong | c371194 | 2010-01-19 17:45:38 -0800 | [diff] [blame] | 55 | android_media_MediaProfiles_native_get_file_format(JNIEnv *env, jobject thiz, jint index) |
| 56 | { |
| 57 | LOGV("native_get_file_format: %d", index); |
| 58 | Vector<output_format> formats = sProfiles->getOutputFileFormats(); |
| 59 | int nSize = formats.size(); |
| 60 | if (index < 0 || index >= nSize) { |
| 61 | jniThrowException(env, "java/lang/IllegalArgumentException", "out of array boundary"); |
| 62 | return -1; |
| 63 | } |
James Dong | d32fba4 | 2010-02-11 14:32:13 -0800 | [diff] [blame] | 64 | return static_cast<jint>(formats[index]); |
James Dong | c371194 | 2010-01-19 17:45:38 -0800 | [diff] [blame] | 65 | } |
| 66 | |
James Dong | d32fba4 | 2010-02-11 14:32:13 -0800 | [diff] [blame] | 67 | static jint |
James Dong | c371194 | 2010-01-19 17:45:38 -0800 | [diff] [blame] | 68 | android_media_MediaProfiles_native_get_num_video_encoders(JNIEnv *env, jobject thiz) |
| 69 | { |
| 70 | LOGV("native_get_num_video_encoders"); |
| 71 | return sProfiles->getVideoEncoders().size(); |
| 72 | } |
| 73 | |
| 74 | static jobject |
| 75 | android_media_MediaProfiles_native_get_video_encoder_cap(JNIEnv *env, jobject thiz, jint index) |
| 76 | { |
| 77 | LOGV("native_get_video_encoder_cap: %d", index); |
| 78 | Vector<video_encoder> encoders = sProfiles->getVideoEncoders(); |
| 79 | int nSize = encoders.size(); |
| 80 | if (index < 0 || index >= nSize) { |
| 81 | jniThrowException(env, "java/lang/IllegalArgumentException", "out of array boundary"); |
| 82 | return NULL; |
| 83 | } |
| 84 | |
| 85 | video_encoder encoder = encoders[index]; |
| 86 | int minBitRate = sProfiles->getVideoEncoderParamByName("enc.vid.bps.min", encoder); |
| 87 | int maxBitRate = sProfiles->getVideoEncoderParamByName("enc.vid.bps.max", encoder); |
| 88 | int minFrameRate = sProfiles->getVideoEncoderParamByName("enc.vid.fps.min", encoder); |
| 89 | int maxFrameRate = sProfiles->getVideoEncoderParamByName("enc.vid.fps.max", encoder); |
| 90 | int minFrameWidth = sProfiles->getVideoEncoderParamByName("enc.vid.width.min", encoder); |
| 91 | int maxFrameWidth = sProfiles->getVideoEncoderParamByName("enc.vid.width.max", encoder); |
| 92 | int minFrameHeight = sProfiles->getVideoEncoderParamByName("enc.vid.height.min", encoder); |
| 93 | int maxFrameHeight = sProfiles->getVideoEncoderParamByName("enc.vid.height.max", encoder); |
| 94 | |
| 95 | // Check on the values retrieved |
| 96 | if ((minBitRate == -1 || maxBitRate == -1) || |
| 97 | (minFrameRate == -1 || maxFrameRate == -1) || |
| 98 | (minFrameWidth == -1 || maxFrameWidth == -1) || |
| 99 | (minFrameHeight == -1 || maxFrameHeight == -1)) { |
| 100 | |
| 101 | jniThrowException(env, "java/lang/RuntimeException", "Error retrieving video encoder capability params"); |
| 102 | return NULL; |
| 103 | } |
| 104 | |
| 105 | // Construct an instance of the VideoEncoderCap and set its member variables |
| 106 | jclass videoEncoderCapClazz = env->FindClass("android/media/EncoderCapabilities$VideoEncoderCap"); |
| 107 | jmethodID videoEncoderCapConstructorMethodID = env->GetMethodID(videoEncoderCapClazz, "<init>", "(IIIIIIIII)V"); |
| 108 | jobject cap = env->NewObject(videoEncoderCapClazz, |
| 109 | videoEncoderCapConstructorMethodID, |
| 110 | static_cast<int>(encoder), |
| 111 | minBitRate, maxBitRate, |
| 112 | minFrameRate, maxFrameRate, |
| 113 | minFrameWidth, maxFrameWidth, |
| 114 | minFrameHeight, maxFrameHeight); |
| 115 | return cap; |
| 116 | } |
| 117 | |
James Dong | d32fba4 | 2010-02-11 14:32:13 -0800 | [diff] [blame] | 118 | static jint |
James Dong | c371194 | 2010-01-19 17:45:38 -0800 | [diff] [blame] | 119 | android_media_MediaProfiles_native_get_num_audio_encoders(JNIEnv *env, jobject thiz) |
| 120 | { |
| 121 | LOGV("native_get_num_audio_encoders"); |
| 122 | return sProfiles->getAudioEncoders().size(); |
| 123 | } |
| 124 | |
| 125 | static jobject |
| 126 | android_media_MediaProfiles_native_get_audio_encoder_cap(JNIEnv *env, jobject thiz, jint index) |
| 127 | { |
| 128 | LOGV("native_get_audio_encoder_cap: %d", index); |
| 129 | Vector<audio_encoder> encoders = sProfiles->getAudioEncoders(); |
| 130 | int nSize = encoders.size(); |
| 131 | if (index < 0 || index >= nSize) { |
| 132 | jniThrowException(env, "java/lang/IllegalArgumentException", "out of array boundary"); |
| 133 | return NULL; |
| 134 | } |
| 135 | |
| 136 | audio_encoder encoder = encoders[index]; |
| 137 | int minBitRate = sProfiles->getAudioEncoderParamByName("enc.aud.bps.min", encoder); |
| 138 | int maxBitRate = sProfiles->getAudioEncoderParamByName("enc.aud.bps.max", encoder); |
| 139 | int minSampleRate = sProfiles->getAudioEncoderParamByName("enc.aud.hz.min", encoder); |
| 140 | int maxSampleRate = sProfiles->getAudioEncoderParamByName("enc.aud.hz.max", encoder); |
| 141 | int minChannels = sProfiles->getAudioEncoderParamByName("enc.aud.ch.min", encoder); |
| 142 | int maxChannels = sProfiles->getAudioEncoderParamByName("enc.aud.ch.max", encoder); |
| 143 | |
| 144 | // Check on the values retrieved |
| 145 | if ((minBitRate == -1 || maxBitRate == -1) || |
| 146 | (minSampleRate == -1 || maxSampleRate == -1) || |
| 147 | (minChannels == -1 || maxChannels == -1)) { |
| 148 | |
| 149 | jniThrowException(env, "java/lang/RuntimeException", "Error retrieving video encoder capability params"); |
| 150 | return NULL; |
| 151 | } |
| 152 | |
| 153 | jclass audioEncoderCapClazz = env->FindClass("android/media/EncoderCapabilities$AudioEncoderCap"); |
| 154 | jmethodID audioEncoderCapConstructorMethodID = env->GetMethodID(audioEncoderCapClazz, "<init>", "(IIIIIII)V"); |
| 155 | jobject cap = env->NewObject(audioEncoderCapClazz, |
| 156 | audioEncoderCapConstructorMethodID, |
| 157 | static_cast<int>(encoder), |
| 158 | minBitRate, maxBitRate, |
| 159 | minSampleRate, maxSampleRate, |
| 160 | minChannels, maxChannels); |
| 161 | return cap; |
| 162 | } |
| 163 | |
James Dong | e7038ac | 2010-02-03 16:50:18 -0800 | [diff] [blame] | 164 | static jobject |
Chih-Chung Chang | 09b9005 | 2010-06-22 20:50:55 +0800 | [diff] [blame] | 165 | android_media_MediaProfiles_native_get_camcorder_profile(JNIEnv *env, jobject thiz, jint id, jint quality) |
James Dong | e7038ac | 2010-02-03 16:50:18 -0800 | [diff] [blame] | 166 | { |
Chih-Chung Chang | 09b9005 | 2010-06-22 20:50:55 +0800 | [diff] [blame] | 167 | LOGV("native_get_camcorder_profile: %d %d", id, quality); |
Nipun Kwatra | 4af0dfd | 2010-09-06 15:59:02 -0700 | [diff] [blame] | 168 | if (!((quality >= CAMCORDER_QUALITY_LOW && quality <= CAMCORDER_QUALITY_1080P) || |
| 169 | (quality >= CAMCORDER_QUALITY_TIME_LAPSE_LOW && |
| 170 | quality <= CAMCORDER_QUALITY_TIME_LAPSE_1080P))) { |
James Dong | e7038ac | 2010-02-03 16:50:18 -0800 | [diff] [blame] | 171 | jniThrowException(env, "java/lang/RuntimeException", "Unknown camcorder profile quality"); |
| 172 | return NULL; |
| 173 | } |
| 174 | |
| 175 | camcorder_quality q = static_cast<camcorder_quality>(quality); |
Chih-Chung Chang | 09b9005 | 2010-06-22 20:50:55 +0800 | [diff] [blame] | 176 | int duration = sProfiles->getCamcorderProfileParamByName("duration", id, q); |
| 177 | int fileFormat = sProfiles->getCamcorderProfileParamByName("file.format", id, q); |
| 178 | int videoCodec = sProfiles->getCamcorderProfileParamByName("vid.codec", id, q); |
| 179 | int videoBitRate = sProfiles->getCamcorderProfileParamByName("vid.bps", id, q); |
| 180 | int videoFrameRate = sProfiles->getCamcorderProfileParamByName("vid.fps", id, q); |
| 181 | int videoFrameWidth = sProfiles->getCamcorderProfileParamByName("vid.width", id, q); |
| 182 | int videoFrameHeight = sProfiles->getCamcorderProfileParamByName("vid.height", id, q); |
| 183 | int audioCodec = sProfiles->getCamcorderProfileParamByName("aud.codec", id, q); |
| 184 | int audioBitRate = sProfiles->getCamcorderProfileParamByName("aud.bps", id, q); |
| 185 | int audioSampleRate = sProfiles->getCamcorderProfileParamByName("aud.hz", id, q); |
| 186 | int audioChannels = sProfiles->getCamcorderProfileParamByName("aud.ch", id, q); |
James Dong | e7038ac | 2010-02-03 16:50:18 -0800 | [diff] [blame] | 187 | |
| 188 | // Check on the values retrieved |
James Dong | 9b433f0 | 2010-02-23 17:21:44 -0800 | [diff] [blame] | 189 | if (duration == -1 || fileFormat == -1 || videoCodec == -1 || audioCodec == -1 || |
James Dong | e7038ac | 2010-02-03 16:50:18 -0800 | [diff] [blame] | 190 | videoBitRate == -1 || videoFrameRate == -1 || videoFrameWidth == -1 || videoFrameHeight == -1 || |
| 191 | audioBitRate == -1 || audioSampleRate == -1 || audioChannels == -1) { |
| 192 | |
| 193 | jniThrowException(env, "java/lang/RuntimeException", "Error retrieving camcorder profile params"); |
| 194 | return NULL; |
| 195 | } |
| 196 | |
| 197 | jclass camcorderProfileClazz = env->FindClass("android/media/CamcorderProfile"); |
James Dong | 9b433f0 | 2010-02-23 17:21:44 -0800 | [diff] [blame] | 198 | jmethodID camcorderProfileConstructorMethodID = env->GetMethodID(camcorderProfileClazz, "<init>", "(IIIIIIIIIIII)V"); |
James Dong | e7038ac | 2010-02-03 16:50:18 -0800 | [diff] [blame] | 199 | return env->NewObject(camcorderProfileClazz, |
| 200 | camcorderProfileConstructorMethodID, |
James Dong | 9b433f0 | 2010-02-23 17:21:44 -0800 | [diff] [blame] | 201 | duration, |
James Dong | e7038ac | 2010-02-03 16:50:18 -0800 | [diff] [blame] | 202 | quality, |
| 203 | fileFormat, |
| 204 | videoCodec, |
| 205 | videoBitRate, |
| 206 | videoFrameRate, |
| 207 | videoFrameWidth, |
| 208 | videoFrameHeight, |
| 209 | audioCodec, |
| 210 | audioBitRate, |
| 211 | audioSampleRate, |
| 212 | audioChannels); |
| 213 | } |
| 214 | |
Nipun Kwatra | 9d61954 | 2010-09-09 16:25:08 -0700 | [diff] [blame] | 215 | static jboolean |
| 216 | android_media_MediaProfiles_native_has_camcorder_profile(JNIEnv *env, jobject thiz, jint id, jint quality) |
| 217 | { |
| 218 | LOGV("native_has_camcorder_profile: %d %d", id, quality); |
| 219 | if (!((quality >= CAMCORDER_QUALITY_LOW && quality <= CAMCORDER_QUALITY_1080P) || |
| 220 | (quality >= CAMCORDER_QUALITY_TIME_LAPSE_LOW && |
| 221 | quality <= CAMCORDER_QUALITY_TIME_LAPSE_1080P))) { |
| 222 | return false; |
| 223 | } |
| 224 | |
| 225 | camcorder_quality q = static_cast<camcorder_quality>(quality); |
| 226 | return sProfiles->hasCamcorderProfile(id, q); |
| 227 | } |
| 228 | |
James Dong | d32fba4 | 2010-02-11 14:32:13 -0800 | [diff] [blame] | 229 | static jint |
| 230 | android_media_MediaProfiles_native_get_num_video_decoders(JNIEnv *env, jobject thiz) |
| 231 | { |
| 232 | LOGV("native_get_num_video_decoders"); |
| 233 | return sProfiles->getVideoDecoders().size(); |
| 234 | } |
| 235 | |
| 236 | static jint |
| 237 | android_media_MediaProfiles_native_get_video_decoder_type(JNIEnv *env, jobject thiz, jint index) |
| 238 | { |
| 239 | LOGV("native_get_video_decoder_type: %d", index); |
| 240 | Vector<video_decoder> decoders = sProfiles->getVideoDecoders(); |
| 241 | int nSize = decoders.size(); |
| 242 | if (index < 0 || index >= nSize) { |
| 243 | jniThrowException(env, "java/lang/IllegalArgumentException", "out of array boundary"); |
| 244 | return -1; |
| 245 | } |
| 246 | |
| 247 | return static_cast<jint>(decoders[index]); |
| 248 | } |
| 249 | |
| 250 | static jint |
| 251 | android_media_MediaProfiles_native_get_num_audio_decoders(JNIEnv *env, jobject thiz) |
| 252 | { |
| 253 | LOGV("native_get_num_audio_decoders"); |
| 254 | return sProfiles->getAudioDecoders().size(); |
| 255 | } |
| 256 | |
| 257 | static jint |
| 258 | android_media_MediaProfiles_native_get_audio_decoder_type(JNIEnv *env, jobject thiz, jint index) |
| 259 | { |
| 260 | LOGV("native_get_audio_decoder_type: %d", index); |
| 261 | Vector<audio_decoder> decoders = sProfiles->getAudioDecoders(); |
| 262 | int nSize = decoders.size(); |
| 263 | if (index < 0 || index >= nSize) { |
| 264 | jniThrowException(env, "java/lang/IllegalArgumentException", "out of array boundary"); |
| 265 | return -1; |
| 266 | } |
| 267 | |
| 268 | return static_cast<jint>(decoders[index]); |
| 269 | } |
| 270 | |
James Dong | 9b433f0 | 2010-02-23 17:21:44 -0800 | [diff] [blame] | 271 | static jint |
Chih-Chung Chang | 09b9005 | 2010-06-22 20:50:55 +0800 | [diff] [blame] | 272 | android_media_MediaProfiles_native_get_num_image_encoding_quality_levels(JNIEnv *env, jobject thiz, jint cameraId) |
James Dong | 9b433f0 | 2010-02-23 17:21:44 -0800 | [diff] [blame] | 273 | { |
| 274 | LOGV("native_get_num_image_encoding_quality_levels"); |
Chih-Chung Chang | 09b9005 | 2010-06-22 20:50:55 +0800 | [diff] [blame] | 275 | return sProfiles->getImageEncodingQualityLevels(cameraId).size(); |
James Dong | 9b433f0 | 2010-02-23 17:21:44 -0800 | [diff] [blame] | 276 | } |
| 277 | |
| 278 | static jint |
Chih-Chung Chang | 09b9005 | 2010-06-22 20:50:55 +0800 | [diff] [blame] | 279 | android_media_MediaProfiles_native_get_image_encoding_quality_level(JNIEnv *env, jobject thiz, jint cameraId, jint index) |
James Dong | 9b433f0 | 2010-02-23 17:21:44 -0800 | [diff] [blame] | 280 | { |
| 281 | LOGV("native_get_image_encoding_quality_level"); |
Chih-Chung Chang | 09b9005 | 2010-06-22 20:50:55 +0800 | [diff] [blame] | 282 | Vector<int> levels = sProfiles->getImageEncodingQualityLevels(cameraId); |
James Dong | 9b433f0 | 2010-02-23 17:21:44 -0800 | [diff] [blame] | 283 | if (index < 0 || index >= levels.size()) { |
| 284 | jniThrowException(env, "java/lang/IllegalArgumentException", "out of array boundary"); |
| 285 | return -1; |
| 286 | } |
| 287 | return static_cast<jint>(levels[index]); |
| 288 | } |
| 289 | |
James Dong | e7038ac | 2010-02-03 16:50:18 -0800 | [diff] [blame] | 290 | static JNINativeMethod gMethodsForEncoderCapabilitiesClass[] = { |
James Dong | c371194 | 2010-01-19 17:45:38 -0800 | [diff] [blame] | 291 | {"native_init", "()V", (void *)android_media_MediaProfiles_native_init}, |
| 292 | {"native_get_num_file_formats", "()I", (void *)android_media_MediaProfiles_native_get_num_file_formats}, |
| 293 | {"native_get_file_format", "(I)I", (void *)android_media_MediaProfiles_native_get_file_format}, |
| 294 | {"native_get_num_video_encoders", "()I", (void *)android_media_MediaProfiles_native_get_num_video_encoders}, |
| 295 | {"native_get_num_audio_encoders", "()I", (void *)android_media_MediaProfiles_native_get_num_audio_encoders}, |
| 296 | |
| 297 | {"native_get_video_encoder_cap", "(I)Landroid/media/EncoderCapabilities$VideoEncoderCap;", |
| 298 | (void *)android_media_MediaProfiles_native_get_video_encoder_cap}, |
| 299 | |
| 300 | {"native_get_audio_encoder_cap", "(I)Landroid/media/EncoderCapabilities$AudioEncoderCap;", |
| 301 | (void *)android_media_MediaProfiles_native_get_audio_encoder_cap}, |
| 302 | }; |
| 303 | |
James Dong | e7038ac | 2010-02-03 16:50:18 -0800 | [diff] [blame] | 304 | static JNINativeMethod gMethodsForCamcorderProfileClass[] = { |
| 305 | {"native_init", "()V", (void *)android_media_MediaProfiles_native_init}, |
Chih-Chung Chang | 09b9005 | 2010-06-22 20:50:55 +0800 | [diff] [blame] | 306 | {"native_get_camcorder_profile", "(II)Landroid/media/CamcorderProfile;", |
James Dong | e7038ac | 2010-02-03 16:50:18 -0800 | [diff] [blame] | 307 | (void *)android_media_MediaProfiles_native_get_camcorder_profile}, |
Nipun Kwatra | 9d61954 | 2010-09-09 16:25:08 -0700 | [diff] [blame] | 308 | {"native_has_camcorder_profile", "(II)Z", |
| 309 | (void *)android_media_MediaProfiles_native_has_camcorder_profile}, |
James Dong | e7038ac | 2010-02-03 16:50:18 -0800 | [diff] [blame] | 310 | }; |
| 311 | |
James Dong | d32fba4 | 2010-02-11 14:32:13 -0800 | [diff] [blame] | 312 | static JNINativeMethod gMethodsForDecoderCapabilitiesClass[] = { |
| 313 | {"native_init", "()V", (void *)android_media_MediaProfiles_native_init}, |
| 314 | {"native_get_num_video_decoders", "()I", (void *)android_media_MediaProfiles_native_get_num_video_decoders}, |
| 315 | {"native_get_num_audio_decoders", "()I", (void *)android_media_MediaProfiles_native_get_num_audio_decoders}, |
| 316 | {"native_get_video_decoder_type", "(I)I", (void *)android_media_MediaProfiles_native_get_video_decoder_type}, |
| 317 | {"native_get_audio_decoder_type", "(I)I", (void *)android_media_MediaProfiles_native_get_audio_decoder_type}, |
| 318 | }; |
| 319 | |
James Dong | 9b433f0 | 2010-02-23 17:21:44 -0800 | [diff] [blame] | 320 | static JNINativeMethod gMethodsForCameraProfileClass[] = { |
| 321 | {"native_init", "()V", (void *)android_media_MediaProfiles_native_init}, |
| 322 | {"native_get_num_image_encoding_quality_levels", |
Chih-Chung Chang | 09b9005 | 2010-06-22 20:50:55 +0800 | [diff] [blame] | 323 | "(I)I", (void *)android_media_MediaProfiles_native_get_num_image_encoding_quality_levels}, |
| 324 | {"native_get_image_encoding_quality_level","(II)I", (void *)android_media_MediaProfiles_native_get_image_encoding_quality_level}, |
James Dong | 9b433f0 | 2010-02-23 17:21:44 -0800 | [diff] [blame] | 325 | }; |
| 326 | |
James Dong | e7038ac | 2010-02-03 16:50:18 -0800 | [diff] [blame] | 327 | static const char* const kEncoderCapabilitiesClassPathName = "android/media/EncoderCapabilities"; |
James Dong | d32fba4 | 2010-02-11 14:32:13 -0800 | [diff] [blame] | 328 | static const char* const kDecoderCapabilitiesClassPathName = "android/media/DecoderCapabilities"; |
James Dong | e7038ac | 2010-02-03 16:50:18 -0800 | [diff] [blame] | 329 | static const char* const kCamcorderProfileClassPathName = "android/media/CamcorderProfile"; |
James Dong | 9b433f0 | 2010-02-23 17:21:44 -0800 | [diff] [blame] | 330 | static const char* const kCameraProfileClassPathName = "android/media/CameraProfile"; |
James Dong | c371194 | 2010-01-19 17:45:38 -0800 | [diff] [blame] | 331 | |
| 332 | // This function only registers the native methods, and is called from |
| 333 | // JNI_OnLoad in android_media_MediaPlayer.cpp |
| 334 | int register_android_media_MediaProfiles(JNIEnv *env) |
| 335 | { |
James Dong | e7038ac | 2010-02-03 16:50:18 -0800 | [diff] [blame] | 336 | int ret1 = AndroidRuntime::registerNativeMethods(env, |
| 337 | kEncoderCapabilitiesClassPathName, |
| 338 | gMethodsForEncoderCapabilitiesClass, |
| 339 | NELEM(gMethodsForEncoderCapabilitiesClass)); |
| 340 | |
| 341 | int ret2 = AndroidRuntime::registerNativeMethods(env, |
| 342 | kCamcorderProfileClassPathName, |
| 343 | gMethodsForCamcorderProfileClass, |
| 344 | NELEM(gMethodsForCamcorderProfileClass)); |
| 345 | |
James Dong | d32fba4 | 2010-02-11 14:32:13 -0800 | [diff] [blame] | 346 | int ret3 = AndroidRuntime::registerNativeMethods(env, |
| 347 | kDecoderCapabilitiesClassPathName, |
| 348 | gMethodsForDecoderCapabilitiesClass, |
| 349 | NELEM(gMethodsForDecoderCapabilitiesClass)); |
| 350 | |
James Dong | 9b433f0 | 2010-02-23 17:21:44 -0800 | [diff] [blame] | 351 | int ret4 = AndroidRuntime::registerNativeMethods(env, |
| 352 | kCameraProfileClassPathName, |
| 353 | gMethodsForCameraProfileClass, |
| 354 | NELEM(gMethodsForCameraProfileClass)); |
| 355 | |
| 356 | // Success if all return values from above are 0 |
| 357 | return (ret1 || ret2 || ret3 || ret4); |
James Dong | c371194 | 2010-01-19 17:45:38 -0800 | [diff] [blame] | 358 | } |