android_media_MediaRecorder.cpp revision 04167d34f5eb2b3a0cc50f4271cf18b33f5483d9
1/* 2 * Copyright (C) 2008 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#include <assert.h> 18#include <fcntl.h> 19#include <inttypes.h> 20#include <limits.h> 21#include <stdio.h> 22#include <unistd.h> 23 24//#define LOG_NDEBUG 0 25#define LOG_TAG "MediaRecorderJNI" 26#include <utils/Log.h> 27 28#include <gui/Surface.h> 29#include <camera/Camera.h> 30#include <media/mediarecorder.h> 31#include <media/stagefright/PersistentSurface.h> 32#include <utils/threads.h> 33 34#include <ScopedUtfChars.h> 35 36#include "jni.h" 37#include "JNIHelp.h" 38#include "android_runtime/AndroidRuntime.h" 39 40#include <system/audio.h> 41#include <android_runtime/android_view_Surface.h> 42 43// ---------------------------------------------------------------------------- 44 45using namespace android; 46 47// ---------------------------------------------------------------------------- 48 49// helper function to extract a native Camera object from a Camera Java object 50extern sp<Camera> get_native_camera(JNIEnv *env, jobject thiz, struct JNICameraContext** context); 51extern sp<PersistentSurface> 52android_media_MediaCodec_getPersistentInputSurface(JNIEnv* env, jobject object); 53 54struct fields_t { 55 jfieldID context; 56 jfieldID surface; 57 58 jmethodID post_event; 59}; 60static fields_t fields; 61 62static Mutex sLock; 63 64// ---------------------------------------------------------------------------- 65// ref-counted object for callbacks 66class JNIMediaRecorderListener: public MediaRecorderListener 67{ 68public: 69 JNIMediaRecorderListener(JNIEnv* env, jobject thiz, jobject weak_thiz); 70 ~JNIMediaRecorderListener(); 71 void notify(int msg, int ext1, int ext2); 72private: 73 JNIMediaRecorderListener(); 74 jclass mClass; // Reference to MediaRecorder class 75 jobject mObject; // Weak ref to MediaRecorder Java object to call on 76}; 77 78JNIMediaRecorderListener::JNIMediaRecorderListener(JNIEnv* env, jobject thiz, jobject weak_thiz) 79{ 80 81 // Hold onto the MediaRecorder class for use in calling the static method 82 // that posts events to the application thread. 83 jclass clazz = env->GetObjectClass(thiz); 84 if (clazz == NULL) { 85 ALOGE("Can't find android/media/MediaRecorder"); 86 jniThrowException(env, "java/lang/Exception", NULL); 87 return; 88 } 89 mClass = (jclass)env->NewGlobalRef(clazz); 90 91 // We use a weak reference so the MediaRecorder object can be garbage collected. 92 // The reference is only used as a proxy for callbacks. 93 mObject = env->NewGlobalRef(weak_thiz); 94} 95 96JNIMediaRecorderListener::~JNIMediaRecorderListener() 97{ 98 // remove global references 99 JNIEnv *env = AndroidRuntime::getJNIEnv(); 100 env->DeleteGlobalRef(mObject); 101 env->DeleteGlobalRef(mClass); 102} 103 104void JNIMediaRecorderListener::notify(int msg, int ext1, int ext2) 105{ 106 ALOGV("JNIMediaRecorderListener::notify"); 107 108 JNIEnv *env = AndroidRuntime::getJNIEnv(); 109 env->CallStaticVoidMethod(mClass, fields.post_event, mObject, msg, ext1, ext2, NULL); 110} 111 112// ---------------------------------------------------------------------------- 113 114static sp<Surface> get_surface(JNIEnv* env, jobject clazz) 115{ 116 ALOGV("get_surface"); 117 return android_view_Surface_getSurface(env, clazz); 118} 119 120static sp<PersistentSurface> get_persistentSurface(JNIEnv* env, jobject object) 121{ 122 ALOGV("get_persistentSurface"); 123 return android_media_MediaCodec_getPersistentInputSurface(env, object); 124} 125 126// Returns true if it throws an exception. 127static bool process_media_recorder_call(JNIEnv *env, status_t opStatus, const char* exception, const char* message) 128{ 129 ALOGV("process_media_recorder_call"); 130 if (opStatus == (status_t)INVALID_OPERATION) { 131 jniThrowException(env, "java/lang/IllegalStateException", NULL); 132 return true; 133 } else if (opStatus != (status_t)OK) { 134 jniThrowException(env, exception, message); 135 return true; 136 } 137 return false; 138} 139 140static sp<MediaRecorder> getMediaRecorder(JNIEnv* env, jobject thiz) 141{ 142 Mutex::Autolock l(sLock); 143 MediaRecorder* const p = (MediaRecorder*)env->GetLongField(thiz, fields.context); 144 return sp<MediaRecorder>(p); 145} 146 147static sp<MediaRecorder> setMediaRecorder(JNIEnv* env, jobject thiz, const sp<MediaRecorder>& recorder) 148{ 149 Mutex::Autolock l(sLock); 150 sp<MediaRecorder> old = (MediaRecorder*)env->GetLongField(thiz, fields.context); 151 if (recorder.get()) { 152 recorder->incStrong(thiz); 153 } 154 if (old != 0) { 155 old->decStrong(thiz); 156 } 157 env->SetLongField(thiz, fields.context, (jlong)recorder.get()); 158 return old; 159} 160 161 162static void android_media_MediaRecorder_setCamera(JNIEnv* env, jobject thiz, jobject camera) 163{ 164 // we should not pass a null camera to get_native_camera() call. 165 if (camera == NULL) { 166 jniThrowNullPointerException(env, "camera object is a NULL pointer"); 167 return; 168 } 169 sp<Camera> c = get_native_camera(env, camera, NULL); 170 if (c == NULL) { 171 // get_native_camera will throw an exception in this case 172 return; 173 } 174 sp<MediaRecorder> mr = getMediaRecorder(env, thiz); 175 if (mr == NULL) { 176 jniThrowException(env, "java/lang/IllegalStateException", NULL); 177 return; 178 } 179 process_media_recorder_call(env, mr->setCamera(c->remote(), c->getRecordingProxy()), 180 "java/lang/RuntimeException", "setCamera failed."); 181} 182 183static void 184android_media_MediaRecorder_setVideoSource(JNIEnv *env, jobject thiz, jint vs) 185{ 186 ALOGV("setVideoSource(%d)", vs); 187 if (vs < VIDEO_SOURCE_DEFAULT || vs >= VIDEO_SOURCE_LIST_END) { 188 jniThrowException(env, "java/lang/IllegalArgumentException", "Invalid video source"); 189 return; 190 } 191 sp<MediaRecorder> mr = getMediaRecorder(env, thiz); 192 if (mr == NULL) { 193 jniThrowException(env, "java/lang/IllegalStateException", NULL); 194 return; 195 } 196 process_media_recorder_call(env, mr->setVideoSource(vs), "java/lang/RuntimeException", "setVideoSource failed."); 197} 198 199static void 200android_media_MediaRecorder_setAudioSource(JNIEnv *env, jobject thiz, jint as) 201{ 202 ALOGV("setAudioSource(%d)", as); 203 if (as < AUDIO_SOURCE_DEFAULT || 204 (as >= AUDIO_SOURCE_CNT && as != AUDIO_SOURCE_FM_TUNER)) { 205 jniThrowException(env, "java/lang/IllegalArgumentException", "Invalid audio source"); 206 return; 207 } 208 209 sp<MediaRecorder> mr = getMediaRecorder(env, thiz); 210 if (mr == NULL) { 211 jniThrowException(env, "java/lang/IllegalStateException", NULL); 212 return; 213 } 214 process_media_recorder_call(env, mr->setAudioSource(as), "java/lang/RuntimeException", "setAudioSource failed."); 215} 216 217static void 218android_media_MediaRecorder_setOutputFormat(JNIEnv *env, jobject thiz, jint of) 219{ 220 ALOGV("setOutputFormat(%d)", of); 221 if (of < OUTPUT_FORMAT_DEFAULT || of >= OUTPUT_FORMAT_LIST_END) { 222 jniThrowException(env, "java/lang/IllegalArgumentException", "Invalid output format"); 223 return; 224 } 225 sp<MediaRecorder> mr = getMediaRecorder(env, thiz); 226 if (mr == NULL) { 227 jniThrowException(env, "java/lang/IllegalStateException", NULL); 228 return; 229 } 230 process_media_recorder_call(env, mr->setOutputFormat(of), "java/lang/RuntimeException", "setOutputFormat failed."); 231} 232 233static void 234android_media_MediaRecorder_setVideoEncoder(JNIEnv *env, jobject thiz, jint ve) 235{ 236 ALOGV("setVideoEncoder(%d)", ve); 237 if (ve < VIDEO_ENCODER_DEFAULT || ve >= VIDEO_ENCODER_LIST_END) { 238 jniThrowException(env, "java/lang/IllegalArgumentException", "Invalid video encoder"); 239 return; 240 } 241 sp<MediaRecorder> mr = getMediaRecorder(env, thiz); 242 if (mr == NULL) { 243 jniThrowException(env, "java/lang/IllegalStateException", NULL); 244 return; 245 } 246 process_media_recorder_call(env, mr->setVideoEncoder(ve), "java/lang/RuntimeException", "setVideoEncoder failed."); 247} 248 249static void 250android_media_MediaRecorder_setAudioEncoder(JNIEnv *env, jobject thiz, jint ae) 251{ 252 ALOGV("setAudioEncoder(%d)", ae); 253 if (ae < AUDIO_ENCODER_DEFAULT || ae >= AUDIO_ENCODER_LIST_END) { 254 jniThrowException(env, "java/lang/IllegalArgumentException", "Invalid audio encoder"); 255 return; 256 } 257 sp<MediaRecorder> mr = getMediaRecorder(env, thiz); 258 if (mr == NULL) { 259 jniThrowException(env, "java/lang/IllegalStateException", NULL); 260 return; 261 } 262 process_media_recorder_call(env, mr->setAudioEncoder(ae), "java/lang/RuntimeException", "setAudioEncoder failed."); 263} 264 265static void 266android_media_MediaRecorder_setParameter(JNIEnv *env, jobject thiz, jstring params) 267{ 268 ALOGV("setParameter()"); 269 if (params == NULL) 270 { 271 ALOGE("Invalid or empty params string. This parameter will be ignored."); 272 return; 273 } 274 275 sp<MediaRecorder> mr = getMediaRecorder(env, thiz); 276 if (mr == NULL) { 277 jniThrowException(env, "java/lang/IllegalStateException", NULL); 278 return; 279 } 280 281 const char* params8 = env->GetStringUTFChars(params, NULL); 282 if (params8 == NULL) 283 { 284 ALOGE("Failed to covert jstring to String8. This parameter will be ignored."); 285 return; 286 } 287 288 process_media_recorder_call(env, mr->setParameters(String8(params8)), "java/lang/RuntimeException", "setParameter failed."); 289 env->ReleaseStringUTFChars(params,params8); 290} 291 292static void 293android_media_MediaRecorder_setOutputFileFD(JNIEnv *env, jobject thiz, jobject fileDescriptor, jlong offset, jlong length) 294{ 295 ALOGV("setOutputFile"); 296 if (fileDescriptor == NULL) { 297 jniThrowException(env, "java/lang/IllegalArgumentException", NULL); 298 return; 299 } 300 int fd = jniGetFDFromFileDescriptor(env, fileDescriptor); 301 sp<MediaRecorder> mr = getMediaRecorder(env, thiz); 302 if (mr == NULL) { 303 jniThrowException(env, "java/lang/IllegalStateException", NULL); 304 return; 305 } 306 status_t opStatus = mr->setOutputFile(fd, offset, length); 307 process_media_recorder_call(env, opStatus, "java/io/IOException", "setOutputFile failed."); 308} 309 310static void 311android_media_MediaRecorder_setVideoSize(JNIEnv *env, jobject thiz, jint width, jint height) 312{ 313 ALOGV("setVideoSize(%d, %d)", width, height); 314 sp<MediaRecorder> mr = getMediaRecorder(env, thiz); 315 if (mr == NULL) { 316 jniThrowException(env, "java/lang/IllegalStateException", NULL); 317 return; 318 } 319 320 if (width <= 0 || height <= 0) { 321 jniThrowException(env, "java/lang/IllegalArgumentException", "invalid video size"); 322 return; 323 } 324 process_media_recorder_call(env, mr->setVideoSize(width, height), "java/lang/RuntimeException", "setVideoSize failed."); 325} 326 327static void 328android_media_MediaRecorder_setVideoFrameRate(JNIEnv *env, jobject thiz, jint rate) 329{ 330 ALOGV("setVideoFrameRate(%d)", rate); 331 if (rate <= 0) { 332 jniThrowException(env, "java/lang/IllegalArgumentException", "invalid frame rate"); 333 return; 334 } 335 sp<MediaRecorder> mr = getMediaRecorder(env, thiz); 336 if (mr == NULL) { 337 jniThrowException(env, "java/lang/IllegalStateException", NULL); 338 return; 339 } 340 process_media_recorder_call(env, mr->setVideoFrameRate(rate), "java/lang/RuntimeException", "setVideoFrameRate failed."); 341} 342 343static void 344android_media_MediaRecorder_setMaxDuration(JNIEnv *env, jobject thiz, jint max_duration_ms) 345{ 346 ALOGV("setMaxDuration(%d)", max_duration_ms); 347 sp<MediaRecorder> mr = getMediaRecorder(env, thiz); 348 if (mr == NULL) { 349 jniThrowException(env, "java/lang/IllegalStateException", NULL); 350 return; 351 } 352 353 char params[64]; 354 sprintf(params, "max-duration=%d", max_duration_ms); 355 356 process_media_recorder_call(env, mr->setParameters(String8(params)), "java/lang/RuntimeException", "setMaxDuration failed."); 357} 358 359static void 360android_media_MediaRecorder_setMaxFileSize( 361 JNIEnv *env, jobject thiz, jlong max_filesize_bytes) 362{ 363 ALOGV("setMaxFileSize(%lld)", (long long)max_filesize_bytes); 364 sp<MediaRecorder> mr = getMediaRecorder(env, thiz); 365 if (mr == NULL) { 366 jniThrowException(env, "java/lang/IllegalStateException", NULL); 367 return; 368 } 369 370 char params[64]; 371 sprintf(params, "max-filesize=%" PRId64, max_filesize_bytes); 372 373 process_media_recorder_call(env, mr->setParameters(String8(params)), "java/lang/RuntimeException", "setMaxFileSize failed."); 374} 375 376static void 377android_media_MediaRecorder_prepare(JNIEnv *env, jobject thiz) 378{ 379 ALOGV("prepare"); 380 sp<MediaRecorder> mr = getMediaRecorder(env, thiz); 381 if (mr == NULL) { 382 jniThrowException(env, "java/lang/IllegalStateException", NULL); 383 return; 384 } 385 386 jobject surface = env->GetObjectField(thiz, fields.surface); 387 if (surface != NULL) { 388 const sp<Surface> native_surface = get_surface(env, surface); 389 390 // The application may misbehave and 391 // the preview surface becomes unavailable 392 if (native_surface.get() == 0) { 393 ALOGE("Application lost the surface"); 394 jniThrowException(env, "java/io/IOException", "invalid preview surface"); 395 return; 396 } 397 398 ALOGI("prepare: surface=%p", native_surface.get()); 399 if (process_media_recorder_call(env, mr->setPreviewSurface(native_surface->getIGraphicBufferProducer()), "java/lang/RuntimeException", "setPreviewSurface failed.")) { 400 return; 401 } 402 } 403 process_media_recorder_call(env, mr->prepare(), "java/io/IOException", "prepare failed."); 404} 405 406static jint 407android_media_MediaRecorder_native_getMaxAmplitude(JNIEnv *env, jobject thiz) 408{ 409 ALOGV("getMaxAmplitude"); 410 sp<MediaRecorder> mr = getMediaRecorder(env, thiz); 411 if (mr == NULL) { 412 jniThrowException(env, "java/lang/IllegalStateException", NULL); 413 return 0; 414 } 415 int result = 0; 416 process_media_recorder_call(env, mr->getMaxAmplitude(&result), "java/lang/RuntimeException", "getMaxAmplitude failed."); 417 return (jint) result; 418} 419 420static jobject 421android_media_MediaRecorder_getSurface(JNIEnv *env, jobject thiz) 422{ 423 ALOGV("getSurface"); 424 sp<MediaRecorder> mr = getMediaRecorder(env, thiz); 425 if (mr == NULL) { 426 jniThrowException(env, "java/lang/IllegalStateException", NULL); 427 return NULL; 428 } 429 430 sp<IGraphicBufferProducer> bufferProducer = mr->querySurfaceMediaSourceFromMediaServer(); 431 if (bufferProducer == NULL) { 432 jniThrowException( 433 env, 434 "java/lang/IllegalStateException", 435 "failed to get surface"); 436 return NULL; 437 } 438 439 // Wrap the IGBP in a Java-language Surface. 440 return android_view_Surface_createFromIGraphicBufferProducer(env, 441 bufferProducer); 442} 443 444static void 445android_media_MediaRecorder_start(JNIEnv *env, jobject thiz) 446{ 447 ALOGV("start"); 448 sp<MediaRecorder> mr = getMediaRecorder(env, thiz); 449 if (mr == NULL) { 450 jniThrowException(env, "java/lang/IllegalStateException", NULL); 451 return; 452 } 453 process_media_recorder_call(env, mr->start(), "java/lang/RuntimeException", "start failed."); 454} 455 456static void 457android_media_MediaRecorder_stop(JNIEnv *env, jobject thiz) 458{ 459 ALOGV("stop"); 460 sp<MediaRecorder> mr = getMediaRecorder(env, thiz); 461 if (mr == NULL) { 462 jniThrowException(env, "java/lang/IllegalStateException", NULL); 463 return; 464 } 465 process_media_recorder_call(env, mr->stop(), "java/lang/RuntimeException", "stop failed."); 466} 467 468static void 469android_media_MediaRecorder_pause(JNIEnv *env, jobject thiz) 470{ 471 ALOGV("pause"); 472 sp<MediaRecorder> mr = getMediaRecorder(env, thiz); 473 if (mr == NULL) { 474 jniThrowException(env, "java/lang/IllegalStateException", NULL); 475 return; 476 } 477 process_media_recorder_call(env, mr->pause(), "java/lang/RuntimeException", "pause failed."); 478} 479 480static void 481android_media_MediaRecorder_resume(JNIEnv *env, jobject thiz) 482{ 483 ALOGV("resume"); 484 sp<MediaRecorder> mr = getMediaRecorder(env, thiz); 485 if (mr == NULL) { 486 jniThrowException(env, "java/lang/IllegalStateException", NULL); 487 return; 488 } 489 process_media_recorder_call(env, mr->resume(), "java/lang/RuntimeException", "resume failed."); 490} 491 492static void 493android_media_MediaRecorder_native_reset(JNIEnv *env, jobject thiz) 494{ 495 ALOGV("native_reset"); 496 sp<MediaRecorder> mr = getMediaRecorder(env, thiz); 497 if (mr == NULL) { 498 jniThrowException(env, "java/lang/IllegalStateException", NULL); 499 return; 500 } 501 process_media_recorder_call(env, mr->reset(), "java/lang/RuntimeException", "native_reset failed."); 502} 503 504static void 505android_media_MediaRecorder_release(JNIEnv *env, jobject thiz) 506{ 507 ALOGV("release"); 508 sp<MediaRecorder> mr = setMediaRecorder(env, thiz, 0); 509 if (mr != NULL) { 510 mr->setListener(NULL); 511 mr->release(); 512 } 513} 514 515// This function gets some field IDs, which in turn causes class initialization. 516// It is called from a static block in MediaRecorder, which won't run until the 517// first time an instance of this class is used. 518static void 519android_media_MediaRecorder_native_init(JNIEnv *env) 520{ 521 jclass clazz; 522 523 clazz = env->FindClass("android/media/MediaRecorder"); 524 if (clazz == NULL) { 525 return; 526 } 527 528 fields.context = env->GetFieldID(clazz, "mNativeContext", "J"); 529 if (fields.context == NULL) { 530 return; 531 } 532 533 fields.surface = env->GetFieldID(clazz, "mSurface", "Landroid/view/Surface;"); 534 if (fields.surface == NULL) { 535 return; 536 } 537 538 jclass surface = env->FindClass("android/view/Surface"); 539 if (surface == NULL) { 540 return; 541 } 542 543 fields.post_event = env->GetStaticMethodID(clazz, "postEventFromNative", 544 "(Ljava/lang/Object;IIILjava/lang/Object;)V"); 545 if (fields.post_event == NULL) { 546 return; 547 } 548} 549 550 551static void 552android_media_MediaRecorder_native_setup(JNIEnv *env, jobject thiz, jobject weak_this, 553 jstring packageName, jstring opPackageName) 554{ 555 ALOGV("setup"); 556 557 ScopedUtfChars opPackageNameStr(env, opPackageName); 558 559 sp<MediaRecorder> mr = new MediaRecorder(String16(opPackageNameStr.c_str())); 560 if (mr == NULL) { 561 jniThrowException(env, "java/lang/RuntimeException", "Out of memory"); 562 return; 563 } 564 if (mr->initCheck() != NO_ERROR) { 565 jniThrowException(env, "java/lang/RuntimeException", "Unable to initialize media recorder"); 566 return; 567 } 568 569 // create new listener and give it to MediaRecorder 570 sp<JNIMediaRecorderListener> listener = new JNIMediaRecorderListener(env, thiz, weak_this); 571 mr->setListener(listener); 572 573 // Convert client name jstring to String16 574 const char16_t *rawClientName = reinterpret_cast<const char16_t*>( 575 env->GetStringChars(packageName, NULL)); 576 jsize rawClientNameLen = env->GetStringLength(packageName); 577 String16 clientName(rawClientName, rawClientNameLen); 578 env->ReleaseStringChars(packageName, 579 reinterpret_cast<const jchar*>(rawClientName)); 580 581 // pass client package name for permissions tracking 582 mr->setClientName(clientName); 583 584 setMediaRecorder(env, thiz, mr); 585} 586 587static void 588android_media_MediaRecorder_native_finalize(JNIEnv *env, jobject thiz) 589{ 590 ALOGV("finalize"); 591 android_media_MediaRecorder_release(env, thiz); 592} 593 594void android_media_MediaRecorder_setInputSurface( 595 JNIEnv* env, jobject thiz, jobject object) { 596 ALOGV("android_media_MediaRecorder_setInputSurface"); 597 598 sp<MediaRecorder> mr = getMediaRecorder(env, thiz); 599 if (mr == NULL) { 600 jniThrowException(env, "java/lang/IllegalStateException", NULL); 601 return; 602 } 603 604 sp<PersistentSurface> persistentSurface = get_persistentSurface(env, object); 605 606 process_media_recorder_call(env, mr->setInputSurface(persistentSurface), 607 "java/lang/IllegalArgumentException", "native_setInputSurface failed."); 608} 609 610// ---------------------------------------------------------------------------- 611 612static const JNINativeMethod gMethods[] = { 613 {"setCamera", "(Landroid/hardware/Camera;)V", (void *)android_media_MediaRecorder_setCamera}, 614 {"setVideoSource", "(I)V", (void *)android_media_MediaRecorder_setVideoSource}, 615 {"setAudioSource", "(I)V", (void *)android_media_MediaRecorder_setAudioSource}, 616 {"setOutputFormat", "(I)V", (void *)android_media_MediaRecorder_setOutputFormat}, 617 {"setVideoEncoder", "(I)V", (void *)android_media_MediaRecorder_setVideoEncoder}, 618 {"setAudioEncoder", "(I)V", (void *)android_media_MediaRecorder_setAudioEncoder}, 619 {"setParameter", "(Ljava/lang/String;)V", (void *)android_media_MediaRecorder_setParameter}, 620 {"_setOutputFile", "(Ljava/io/FileDescriptor;JJ)V", (void *)android_media_MediaRecorder_setOutputFileFD}, 621 {"setVideoSize", "(II)V", (void *)android_media_MediaRecorder_setVideoSize}, 622 {"setVideoFrameRate", "(I)V", (void *)android_media_MediaRecorder_setVideoFrameRate}, 623 {"setMaxDuration", "(I)V", (void *)android_media_MediaRecorder_setMaxDuration}, 624 {"setMaxFileSize", "(J)V", (void *)android_media_MediaRecorder_setMaxFileSize}, 625 {"_prepare", "()V", (void *)android_media_MediaRecorder_prepare}, 626 {"getSurface", "()Landroid/view/Surface;", (void *)android_media_MediaRecorder_getSurface}, 627 {"getMaxAmplitude", "()I", (void *)android_media_MediaRecorder_native_getMaxAmplitude}, 628 {"start", "()V", (void *)android_media_MediaRecorder_start}, 629 {"stop", "()V", (void *)android_media_MediaRecorder_stop}, 630 {"pause", "()V", (void *)android_media_MediaRecorder_pause}, 631 {"resume", "()V", (void *)android_media_MediaRecorder_resume}, 632 {"native_reset", "()V", (void *)android_media_MediaRecorder_native_reset}, 633 {"release", "()V", (void *)android_media_MediaRecorder_release}, 634 {"native_init", "()V", (void *)android_media_MediaRecorder_native_init}, 635 {"native_setup", "(Ljava/lang/Object;Ljava/lang/String;Ljava/lang/String;)V", 636 (void *)android_media_MediaRecorder_native_setup}, 637 {"native_finalize", "()V", (void *)android_media_MediaRecorder_native_finalize}, 638 {"native_setInputSurface", "(Landroid/view/Surface;)V", (void *)android_media_MediaRecorder_setInputSurface }, 639}; 640 641// This function only registers the native methods, and is called from 642// JNI_OnLoad in android_media_MediaPlayer.cpp 643int register_android_media_MediaRecorder(JNIEnv *env) 644{ 645 return AndroidRuntime::registerNativeMethods(env, 646 "android/media/MediaRecorder", gMethods, NELEM(gMethods)); 647} 648