Lines Matching defs:env
69 JNIImageWriterContext(JNIEnv* env, jobject weakThiz, jclass clazz);
101 JNIImageWriterContext::JNIImageWriterContext(JNIEnv* env, jobject weakThiz, jclass clazz) :
102 mWeakThiz(env->NewGlobalRef(weakThiz)),
103 mClazz((jclass)env->NewGlobalRef(clazz)),
112 JNIEnv* env = getJNIEnv(&needsDetach);
113 if (env != NULL) {
114 env->DeleteGlobalRef(mWeakThiz);
115 env->DeleteGlobalRef(mClazz);
130 JNIEnv* env = AndroidRuntime::getJNIEnv();
131 if (env == NULL) {
134 int result = vm->AttachCurrentThread(&env, (void*) &args);
141 return env;
156 JNIEnv* env = getJNIEnv(&needsDetach);
157 if (env != NULL) {
168 env->CallStaticVoidMethod(mClazz, gImageWriterClassInfo.postEventFromNative, mWeakThiz);
185 static void Image_setNativeContext(JNIEnv* env, jobject thiz,
187 static void Image_getNativeContext(JNIEnv* env, jobject thiz,
189 static void Image_unlockIfLocked(JNIEnv* env, jobject thiz);
194 static void ImageWriter_classInit(JNIEnv* env, jclass clazz) {
196 jclass imageClazz = env->FindClass("android/media/ImageWriter$WriterSurfaceImage");
199 gSurfaceImageClassInfo.mNativeBuffer = env->GetFieldID(
204 gSurfaceImageClassInfo.mNativeFenceFd = env->GetFieldID(
209 gSurfaceImageClassInfo.mPlanes = env->GetFieldID(
214 gImageWriterClassInfo.postEventFromNative = env->GetStaticMethodID(
219 gImageWriterClassInfo.mWriterFormat = env->GetFieldID(
224 jclass planeClazz = env->FindClass("android/media/ImageWriter$WriterSurfaceImage$SurfacePlane");
227 gSurfacePlaneClassInfo.clazz = (jclass) env->NewGlobalRef(planeClazz);
228 gSurfacePlaneClassInfo.ctor = env->GetMethodID(gSurfacePlaneClassInfo.clazz, "<init>",
234 static jlong ImageWriter_init(JNIEnv* env, jobject thiz, jobject weakThiz, jobject jsurface,
240 sp<Surface> surface(android_view_Surface_getSurface(env, jsurface));
242 jniThrowException(env,
249 jclass clazz = env->GetObjectClass(thiz);
251 jniThrowRuntimeException(env, "Can't find android/graphics/ImageWriter");
254 sp<JNIImageWriterContext> ctx(new JNIImageWriterContext(env, weakThiz, clazz));
271 jniThrowRuntimeException(env, "Failed to query Surface width");
278 jniThrowRuntimeException(env, "Failed to query Surface height");
285 jniThrowRuntimeException(env, "Failed to query Surface format");
289 env->SetIntField(thiz, gImageWriterClassInfo.mWriterFormat, reinterpret_cast<jint>(format));
298 jniThrowRuntimeException(env, "Failed to SW_WRITE_OFTEN configure usage");
309 jniThrowRuntimeException(env, "Query producer undequeued buffer count failed");
317 jniThrowRuntimeException(env, "Set buffer count failed");
327 static void ImageWriter_dequeueImage(JNIEnv* env, jobject thiz, jlong nativeCtx, jobject image) {
331 jniThrowException(env, "java/lang/IllegalStateException",
344 jniThrowException(env, "java/lang/IllegalStateException",
349 jniThrowRuntimeException(env, "dequeue buffer failed");
364 Image_setNativeContext(env, image, buffer, fenceFd);
367 static void ImageWriter_close(JNIEnv* env, jobject thiz, jlong nativeCtx) {
394 jniThrowRuntimeException(env, "Native window disconnect failed");
402 static void ImageWriter_cancelImage(JNIEnv* env, jobject thiz, jlong nativeCtx, jobject image) {
406 jniThrowException(env, "java/lang/IllegalStateException",
415 Image_getNativeContext(env, image, &buffer, &fenceFd);
417 jniThrowException(env, "java/lang/IllegalStateException",
423 Image_unlockIfLocked(env, image);
427 Image_setNativeContext(env, image, NULL, -1);
430 static void ImageWriter_queueImage(JNIEnv* env, jobject thiz, jlong nativeCtx, jobject image,
435 env, "java/lang/IllegalStateException",
445 Image_getNativeContext(env, image, &buffer, &fenceFd);
447 jniThrowException(env, "java/lang/IllegalStateException",
453 Image_unlockIfLocked(env, image);
459 jniThrowRuntimeException(env, "Set timestamp failed");
471 jniThrowRuntimeException(env, "Set crop rect failed");
481 jniThrowException(env, "java/lang/IllegalStateException",
486 jniThrowRuntimeException(env, "Queue input buffer failed");
492 Image_setNativeContext(env, image, NULL, -1);
495 static jint ImageWriter_attachAndQueueImage(JNIEnv* env, jobject thiz, jlong nativeCtx,
501 jniThrowException(env, "java/lang/IllegalStateException",
510 jniThrowRuntimeException(env,
516 jniThrowException(env, "java/lang/IllegalStateException",
525 jniThrowException(env, "java/lang/IllegalStateException",
536 jniThrowException(env, "java/lang/IllegalStateException",
541 jniThrowRuntimeException(env, "nativeAttachImage failed!!!");
552 jniThrowRuntimeException(env, "Set timestamp failed");
563 jniThrowRuntimeException(env, "Set crop rect failed");
574 jniThrowException(env, "java/lang/IllegalStateException",
579 jniThrowRuntimeException(env, "Queue input buffer failed");
592 static void Image_getNativeContext(JNIEnv* env, jobject thiz,
597 (env->GetLongField(thiz, gSurfaceImageClassInfo.mNativeBuffer));
602 *fenceFd = reinterpret_cast<jint>(env->GetIntField(
607 static void Image_setNativeContext(JNIEnv* env, jobject thiz,
611 Image_getNativeContext(env, thiz, &p, /*fenceFd*/NULL);
618 env->SetLongField(thiz, gSurfaceImageClassInfo.mNativeBuffer,
621 env->SetIntField(thiz, gSurfaceImageClassInfo.mNativeFenceFd, reinterpret_cast<jint>(fenceFd));
624 static void Image_unlockIfLocked(JNIEnv* env, jobject thiz) {
627 Image_getNativeContext(env, thiz, &buffer, NULL);
629 jniThrowException(env, "java/lang/IllegalStateException",
638 planes = env->GetObjectField(thiz, gSurfaceImageClassInfo.mPlanes);
645 jniThrowRuntimeException(env, "unlock buffer failed");
651 static jint Image_getWidth(JNIEnv* env, jobject thiz) {
654 Image_getNativeContext(env, thiz, &buffer, NULL);
656 jniThrowException(env, "java/lang/IllegalStateException",
664 static jint Image_getHeight(JNIEnv* env, jobject thiz) {
667 Image_getNativeContext(env, thiz, &buffer, NULL);
669 jniThrowException(env, "java/lang/IllegalStateException",
679 static int Image_getPixelFormat(JNIEnv* env, int format) {
685 jclass imageFormatClazz = env->FindClass("android/graphics/ImageFormat");
688 fid = env->GetStaticFieldID(imageFormatClazz, "JPEG", "I");
689 jpegFormat = env->GetStaticIntField(imageFormatClazz, fid);
699 static jint Image_getFormat(JNIEnv* env, jobject thiz) {
702 Image_getNativeContext(env, thiz, &buffer, NULL);
704 jniThrowException(env, "java/lang/IllegalStateException",
709 return Image_getPixelFormat(env, buffer->getPixelFormat());
712 static void Image_setFenceFd(JNIEnv* env, jobject thiz, int fenceFd) {
714 env->SetIntField(thiz, gSurfaceImageClassInfo.mNativeFenceFd, reinterpret_cast<jint>(fenceFd));
717 static void Image_getLockedImage(JNIEnv* env, jobject thiz, LockedImage *image) {
721 Image_getNativeContext(env, thiz, &buffer, &fenceFd);
723 jniThrowException(env, "java/lang/IllegalStateException",
731 int format = Image_getFormat(env, thiz);
737 Image_setFenceFd(env, thiz, /*fenceFd*/-1);
739 jniThrowRuntimeException(env, "lockAsyncYCbCr failed for YUV buffer");
750 jniThrowRuntimeException(env, "lockAsync failed");
820 static void Image_getLockedImageInfo(JNIEnv* env, LockedImage* buffer, int idx,
985 jniThrowExceptionFmt(env, "java/lang/UnsupportedOperationException",
996 static jobjectArray Image_createSurfacePlanes(JNIEnv* env, jobject thiz,
1004 int format = Image_getFormat(env, thiz);
1009 jniThrowException(env, "java/lang/IllegalArgumentException", msg.string());
1013 jobjectArray surfacePlanes = env->NewObjectArray(numPlanes, gSurfacePlaneClassInfo.clazz,
1016 jniThrowRuntimeException(env, "Failed to create SurfacePlane arrays,"
1026 Image_getLockedImage(env, thiz, &lockedImg);
1029 writerFormat = Image_getPixelFormat(env, writerFormat);
1031 Image_getLockedImageInfo(env, &lockedImg, i, writerFormat,
1033 byteBuffer = env->NewDirectByteBuffer(pData, dataSize);
1034 if ((byteBuffer == NULL) && (env->ExceptionCheck() == false)) {
1035 jniThrowException(env, "java/lang/IllegalStateException",
1041 jobject surfacePlane = env->NewObject(gSurfacePlaneClassInfo.clazz,
1043 env->SetObjectArrayElement(surfacePlanes, i, surfacePlane);
1105 int register_android_media_ImageWriter(JNIEnv *env) {
1107 int ret1 = AndroidRuntime::registerNativeMethods(env,
1110 int ret2 = AndroidRuntime::registerNativeMethods(env,