Lines Matching refs:env

69         JNIEnv *env, jobject thiz,
73 jclass clazz = env->GetObjectClass(thiz);
76 mClass = (jclass)env->NewGlobalRef(clazz);
77 mObject = env->NewWeakGlobalRef(thiz);
104 JNIEnv *env = AndroidRuntime::getJNIEnv();
106 env->DeleteWeakGlobalRef(mObject);
108 env->DeleteGlobalRef(mClass);
170 JNIEnv *env, jobject bufferInfo, size_t *index, int64_t timeoutUs) {
180 jclass clazz = env->FindClass("android/media/MediaCodec$BufferInfo");
182 jmethodID method = env->GetMethodID(clazz, "set", "(IIJI)V");
183 env->CallVoidMethod(bufferInfo, method, offset, size, timeUs, flags);
194 status_t JMediaCodec::getOutputFormat(JNIEnv *env, jobject *format) const {
201 return ConvertMessageToMap(env, msg, format);
205 JNIEnv *env, bool input, jobjectArray *bufArray) const {
217 jclass byteBufferClass = env->FindClass("java/nio/ByteBuffer");
220 jmethodID orderID = env->GetMethodID(
227 jclass byteOrderClass = env->FindClass("java/nio/ByteOrder");
230 jmethodID nativeOrderID = env->GetStaticMethodID(
235 env->CallStaticObjectMethod(byteOrderClass, nativeOrderID);
238 *bufArray = (jobjectArray)env->NewObjectArray(
245 env->NewDirectByteBuffer(
249 jobject me = env->CallObjectMethod(
251 env->DeleteLocalRef(me);
254 env->SetObjectArrayElement(
257 env->DeleteLocalRef(byteBuffer);
261 env->DeleteLocalRef(nativeByteOrderObj);
280 JNIEnv *env, jobject thiz, const sp<JMediaCodec> &codec) {
281 sp<JMediaCodec> old = (JMediaCodec *)env->GetIntField(thiz, gFields.context);
288 env->SetIntField(thiz, gFields.context, (int)codec.get());
293 static sp<JMediaCodec> getMediaCodec(JNIEnv *env, jobject thiz) {
294 return (JMediaCodec *)env->GetIntField(thiz, gFields.context);
297 static void android_media_MediaCodec_release(JNIEnv *env, jobject thiz) {
298 setMediaCodec(env, thiz, NULL);
301 static void throwCryptoException(JNIEnv *env, status_t err, const char *msg) {
302 jclass clazz = env->FindClass("android/media/MediaCodec$CryptoException");
306 env->GetMethodID(clazz, "<init>", "(ILjava/lang/String;)V");
309 jstring msgObj = env->NewStringUTF(msg != NULL ? msg : "Unknown Error");
312 (jthrowable)env->NewObject(clazz, constructID, err, msgObj);
314 env->Throw(exception);
318 JNIEnv *env, status_t err, const char *msg = NULL) {
322 throwCryptoException(env, err, msg);
341 jniThrowException(env, "java/lang/IllegalStateException", NULL);
350 JNIEnv *env,
356 sp<JMediaCodec> codec = getMediaCodec(env, thiz);
359 jniThrowException(env, "java/lang/IllegalStateException", NULL);
364 status_t err = ConvertKeyValueArraysToMessage(env, keys, values, &format);
367 jniThrowException(env, "java/lang/IllegalArgumentException", NULL);
373 sp<Surface> surface(android_view_Surface_getSurface(env, jsurface));
378 env,
387 crypto = JCrypto::GetCrypto(env, jcrypto);
392 throwExceptionAsNecessary(env, err);
395 static void android_media_MediaCodec_start(JNIEnv *env, jobject thiz) {
398 sp<JMediaCodec> codec = getMediaCodec(env, thiz);
401 jniThrowException(env, "java/lang/IllegalStateException", NULL);
407 throwExceptionAsNecessary(env, err);
410 static void android_media_MediaCodec_stop(JNIEnv *env, jobject thiz) {
413 sp<JMediaCodec> codec = getMediaCodec(env, thiz);
416 jniThrowException(env, "java/lang/IllegalStateException", NULL);
422 throwExceptionAsNecessary(env, err);
425 static void android_media_MediaCodec_flush(JNIEnv *env, jobject thiz) {
428 sp<JMediaCodec> codec = getMediaCodec(env, thiz);
431 jniThrowException(env, "java/lang/IllegalStateException", NULL);
437 throwExceptionAsNecessary(env, err);
441 JNIEnv *env,
450 sp<JMediaCodec> codec = getMediaCodec(env, thiz);
453 jniThrowException(env, "java/lang/IllegalStateException", NULL);
463 env, err, errorDetailMsg.empty() ? NULL : errorDetailMsg.c_str());
467 JNIEnv *env,
476 sp<JMediaCodec> codec = getMediaCodec(env, thiz);
479 jniThrowException(env, "java/lang/IllegalStateException", NULL);
484 env->GetIntField(cryptoInfoObj, gFields.cryptoInfoNumSubSamplesID);
487 (jintArray)env->GetObjectField(
491 (jintArray)env->GetObjectField(
495 (jbyteArray)env->GetObjectField(cryptoInfoObj, gFields.cryptoInfoKeyID);
498 (jbyteArray)env->GetObjectField(cryptoInfoObj, gFields.cryptoInfoIVID);
500 jint mode = env->GetIntField(cryptoInfoObj, gFields.cryptoInfoModeID);
514 && env->GetArrayLength(numBytesOfEncryptedDataObj) < numSubSamples) {
517 && env->GetArrayLength(numBytesOfClearDataObj) < numSubSamples) {
525 : env->GetIntArrayElements(numBytesOfClearDataObj, &isCopy);
530 : env->GetIntArrayElements(numBytesOfEncryptedDataObj, &isCopy);
544 env->ReleaseIntArrayElements(
550 env->ReleaseIntArrayElements(
557 if (env->GetArrayLength(keyObj) != 16) {
561 key = env->GetByteArrayElements(keyObj, &isCopy);
566 if (env->GetArrayLength(ivObj) != 16) {
570 iv = env->GetByteArrayElements(ivObj, &isCopy);
588 env->ReleaseByteArrayElements(ivObj, iv, 0);
593 env->ReleaseByteArrayElements(keyObj, key, 0);
601 env, err, errorDetailMsg.empty() ? NULL : errorDetailMsg.c_str());
605 JNIEnv *env, jobject thiz, jlong timeoutUs) {
608 sp<JMediaCodec> codec = getMediaCodec(env, thiz);
611 jniThrowException(env, "java/lang/IllegalStateException", NULL);
622 return throwExceptionAsNecessary(env, err);
626 JNIEnv *env, jobject thiz, jobject bufferInfo, jlong timeoutUs) {
629 sp<JMediaCodec> codec = getMediaCodec(env, thiz);
632 jniThrowException(env, "java/lang/IllegalStateException", NULL);
638 env, bufferInfo, &index, timeoutUs);
644 return throwExceptionAsNecessary(env, err);
648 JNIEnv *env, jobject thiz, jint index, jboolean render) {
651 sp<JMediaCodec> codec = getMediaCodec(env, thiz);
654 jniThrowException(env, "java/lang/IllegalStateException", NULL);
660 throwExceptionAsNecessary(env, err);
664 JNIEnv *env, jobject thiz) {
667 sp<JMediaCodec> codec = getMediaCodec(env, thiz);
670 jniThrowException(env, "java/lang/IllegalStateException", NULL);
675 status_t err = codec->getOutputFormat(env, &format);
681 throwExceptionAsNecessary(env, err);
687 JNIEnv *env, jobject thiz, jboolean input) {
690 sp<JMediaCodec> codec = getMediaCodec(env, thiz);
693 jniThrowException(env, "java/lang/IllegalStateException", NULL);
698 status_t err = codec->getBuffers(env, input, &buffers);
704 throwExceptionAsNecessary(env, err);
710 JNIEnv *env, jobject thiz, jint mode) {
711 sp<JMediaCodec> codec = getMediaCodec(env, thiz);
714 jniThrowException(env, "java/lang/IllegalStateException", NULL);
720 jniThrowException(env, "java/lang/InvalidArgumentException", NULL);
727 static void android_media_MediaCodec_native_init(JNIEnv *env) {
728 jclass clazz = env->FindClass("android/media/MediaCodec");
731 gFields.context = env->GetFieldID(clazz, "mNativeContext", "I");
734 clazz = env->FindClass("android/media/MediaCodec$CryptoInfo");
738 env->GetFieldID(clazz, "numSubSamples", "I");
742 env->GetFieldID(clazz, "numBytesOfClearData", "[I");
746 env->GetFieldID(clazz, "numBytesOfEncryptedData", "[I");
749 gFields.cryptoInfoKeyID = env->GetFieldID(clazz, "key", "[B");
752 gFields.cryptoInfoIVID = env->GetFieldID(clazz, "iv", "[B");
755 gFields.cryptoInfoModeID = env->GetFieldID(clazz, "mode", "I");
760 JNIEnv *env, jobject thiz,
763 jniThrowException(env, "java/lang/IllegalArgumentException", NULL);
767 const char *tmp = env->GetStringUTFChars(name, NULL);
773 sp<JMediaCodec> codec = new JMediaCodec(env, thiz, tmp, nameIsType, encoder);
777 env->ReleaseStringUTFChars(name, tmp);
782 env,
788 setMediaCodec(env,thiz, codec);
792 JNIEnv *env, jobject thiz) {
793 android_media_MediaCodec_release(env, thiz);
841 int register_android_media_MediaCodec(JNIEnv *env) {
842 return AndroidRuntime::registerNativeMethods(env,