Lines Matching defs:env

60 var = env->FindClass(className); \
64 var = env->GetMethodID(clazz, fieldName, fieldDescriptor); \
103 JNIEnv *env, jobjectArray keys, jobjectArray values,
109 nKeyValuePairs = env->GetArrayLength(keys);
110 failed = (nKeyValuePairs != env->GetArrayLength(values));
120 jniThrowException(env, "java/lang/IllegalArgumentException", NULL);
127 jstring key = (jstring) env->GetObjectArrayElement(keys, i);
128 jstring value = (jstring) env->GetObjectArrayElement(values, i);
130 const char* keyStr = env->GetStringUTFChars(key, NULL);
135 const char* valueStr = env->GetStringUTFChars(value, NULL);
137 env->ReleaseStringUTFChars(key, keyStr);
143 env->ReleaseStringUTFChars(key, keyStr);
144 env->ReleaseStringUTFChars(value, valueStr);
145 env->DeleteLocalRef(key);
146 env->DeleteLocalRef(value);
156 JNIMediaPlayer2Listener(JNIEnv* env, jobject thiz, jobject weak_thiz);
166 JNIMediaPlayer2Listener::JNIMediaPlayer2Listener(JNIEnv* env, jobject thiz, jobject weak_thiz)
171 jclass clazz = env->GetObjectClass(thiz);
174 jniThrowException(env, "java/lang/Exception", NULL);
177 mClass = (jclass)env->NewGlobalRef(clazz);
181 mObject = env->NewGlobalRef(weak_thiz);
187 JNIEnv *env = AndroidRuntime::getJNIEnv();
188 env->DeleteGlobalRef(mObject);
189 env->DeleteGlobalRef(mClass);
194 JNIEnv *env = AndroidRuntime::getJNIEnv();
196 jobject jParcel = createJavaParcelObject(env);
198 Parcel* nativeParcel = parcelForJavaObject(env, jParcel);
200 env->CallStaticVoidMethod(mClass, fields.post_event, mObject,
202 env->DeleteLocalRef(jParcel);
205 env->CallStaticVoidMethod(mClass, fields.post_event, mObject,
208 if (env->ExceptionCheck()) {
210 LOGW_EX(env);
211 env->ExceptionClear();
217 static sp<MediaPlayer2> getMediaPlayer(JNIEnv* env, jobject thiz)
220 MediaPlayer2* const p = (MediaPlayer2*)env->GetLongField(thiz, fields.context);
224 static sp<MediaPlayer2> setMediaPlayer(JNIEnv* env, jobject thiz, const sp<MediaPlayer2>& player)
227 sp<MediaPlayer2> old = (MediaPlayer2*)env->GetLongField(thiz, fields.context);
234 env->SetLongField(thiz, fields.context, (jlong)player.get());
243 JNIEnv *env, jobject thiz, status_t opStatus, const char* exception, const char *message)
247 sp<MediaPlayer2> mp = getMediaPlayer(env, thiz);
256 jniThrowException(env, "java/lang/IllegalStateException", NULL);
258 jniThrowException(env, "java/lang/IllegalArgumentException", NULL);
260 jniThrowException(env, "java/lang/SecurityException", NULL);
264 jniThrowException( env, exception, message);
269 jniThrowException( env, exception, msg);
277 JNIEnv *env, jobject thiz, jboolean isCurrent, jlong srcId,
280 sp<MediaPlayer2> mp = getMediaPlayer(env, thiz);
282 jniThrowException(env, "java/lang/IllegalStateException", NULL);
287 jniThrowException(env, "java/lang/IllegalArgumentException", NULL);
291 const char *tmp = env->GetStringUTFChars(path, NULL);
299 jniThrowException(env, "java/io/IOException",
309 env->ReleaseStringUTFChars(path, tmp);
314 env, keys, values, &dsd->mHeaders)) {
320 httpService = new JMedia2HTTPService(env, httpServiceObj);
330 process_media_player_call(env, thiz, err,
336 JNIEnv *env, jobject thiz, jboolean isCurrent, jlong srcId,
339 sp<MediaPlayer2> mp = getMediaPlayer(env, thiz);
341 jniThrowException(env, "java/lang/IllegalStateException", NULL);
346 jniThrowException(env, "java/lang/IllegalArgumentException", NULL);
349 int fd = jniGetFDFromFileDescriptor(env, fileDescriptor);
357 jniThrowException(env, "java/io/IOException", "handleDataSourceFD failed fstat");
369 jniThrowException(env, "java/lang/IllegalArgumentException",
391 process_media_player_call(env, thiz, err,
397 JNIEnv *env, jobject thiz, jboolean isCurrent, jlong srcId, jobject dataSource)
399 sp<MediaPlayer2> mp = getMediaPlayer(env, thiz);
401 jniThrowException(env, "java/lang/IllegalStateException", NULL);
406 jniThrowException(env, "java/lang/IllegalArgumentException", NULL);
409 sp<DataSource> callbackDataSource = new JMedia2DataSource(env, dataSource);
421 process_media_player_call(env, thiz, err,
426 getVideoSurfaceTexture(JNIEnv* env, jobject thiz) {
427 ANativeWindow * const p = (ANativeWindow*)env->GetLongField(thiz, fields.surface_texture);
432 decVideoSurfaceRef(JNIEnv *env, jobject thiz)
434 sp<MediaPlayer2> mp = getMediaPlayer(env, thiz);
439 ANativeWindow * const old_anw = (ANativeWindow*)env->GetLongField(thiz, fields.surface_texture);
442 env->SetLongField(thiz, fields.surface_texture, (jlong)NULL);
447 setVideoSurface(JNIEnv *env, jobject thiz, jobject jsurface, jboolean mediaPlayerMustBeAlive)
449 sp<MediaPlayer2> mp = getMediaPlayer(env, thiz);
452 jniThrowException(env, "java/lang/IllegalStateException", NULL);
457 decVideoSurfaceRef(env, thiz);
461 anw = ANativeWindow_fromSurface(env, jsurface);
463 jniThrowException(env, "java/lang/IllegalArgumentException",
469 env->SetLongField(thiz, fields.surface_texture, (jlong)anw);
479 android_media_MediaPlayer2_setVideoSurface(JNIEnv *env, jobject thiz, jobject jsurface)
481 setVideoSurface(env, thiz, jsurface, true /* mediaPlayerMustBeAlive */);
485 android_media_MediaPlayer2_getBufferingParams(JNIEnv *env, jobject thiz)
487 sp<MediaPlayer2> mp = getMediaPlayer(env, thiz);
489 jniThrowException(env, "java/lang/IllegalStateException", NULL);
496 env, thiz, mp->getBufferingSettings(&settings),
498 if (env->ExceptionCheck()) {
503 return bp.asJobject(env, gBufferingParamsFields);
507 android_media_MediaPlayer2_setBufferingParams(JNIEnv *env, jobject thiz, jobject params)
513 sp<MediaPlayer2> mp = getMediaPlayer(env, thiz);
515 jniThrowException(env, "java/lang/IllegalStateException", NULL);
520 bp.fillFromJobject(env, gBufferingParamsFields, params);
524 env, thiz, mp->setBufferingSettings(bp.settings),
529 android_media_MediaPlayer2_playNextDataSource(JNIEnv *env, jobject thiz, jlong srcId)
531 sp<MediaPlayer2> mp = getMediaPlayer(env, thiz);
533 jniThrowException(env, "java/lang/IllegalStateException", NULL);
537 process_media_player_call(env, thiz, mp->playNextDataSource((int64_t)srcId),
542 android_media_MediaPlayer2_prepare(JNIEnv *env, jobject thiz)
544 sp<MediaPlayer2> mp = getMediaPlayer(env, thiz);
546 jniThrowException(env, "java/lang/IllegalStateException", NULL);
552 sp<ANativeWindowWrapper> st = getVideoSurfaceTexture(env, thiz);
555 process_media_player_call( env, thiz, mp->prepareAsync(), "java/io/IOException", "Prepare Async failed." );
559 android_media_MediaPlayer2_start(JNIEnv *env, jobject thiz)
562 sp<MediaPlayer2> mp = getMediaPlayer(env, thiz);
564 jniThrowException(env, "java/lang/IllegalStateException", NULL);
567 process_media_player_call( env, thiz, mp->start(), NULL, NULL );
571 android_media_MediaPlayer2_stop(JNIEnv *env, jobject thiz)
574 sp<MediaPlayer2> mp = getMediaPlayer(env, thiz);
576 jniThrowException(env, "java/lang/IllegalStateException", NULL);
579 process_media_player_call( env, thiz, mp->stop(), NULL, NULL );
583 android_media_MediaPlayer2_pause(JNIEnv *env, jobject thiz)
586 sp<MediaPlayer2> mp = getMediaPlayer(env, thiz);
588 jniThrowException(env, "java/lang/IllegalStateException", NULL);
591 process_media_player_call( env, thiz, mp->pause(), NULL, NULL );
595 android_media_MediaPlayer2_isPlaying(JNIEnv *env, jobject thiz)
597 sp<MediaPlayer2> mp = getMediaPlayer(env, thiz);
599 jniThrowException(env, "java/lang/IllegalStateException", NULL);
609 android_media_MediaPlayer2_setPlaybackParams(JNIEnv *env, jobject thiz, jobject params)
611 sp<MediaPlayer2> mp = getMediaPlayer(env, thiz);
613 jniThrowException(env, "java/lang/IllegalStateException", NULL);
618 pbp.fillFromJobject(env, gPlaybackParamsFields, params);
650 env, thiz, err,
655 android_media_MediaPlayer2_getPlaybackParams(JNIEnv *env, jobject thiz)
657 sp<MediaPlayer2> mp = getMediaPlayer(env, thiz);
659 jniThrowException(env, "java/lang/IllegalStateException", NULL);
666 env, thiz, mp->getPlaybackSettings(&audioRate),
668 if (env->ExceptionCheck()) {
679 return pbp.asJobject(env, gPlaybackParamsFields);
683 android_media_MediaPlayer2_setSyncParams(JNIEnv *env, jobject thiz, jobject params)
685 sp<MediaPlayer2> mp = getMediaPlayer(env, thiz);
687 jniThrowException(env, "java/lang/IllegalStateException", NULL);
692 scp.fillFromJobject(env, gSyncParamsFields, params);
721 env, thiz, err,
726 android_media_MediaPlayer2_getSyncParams(JNIEnv *env, jobject thiz)
728 sp<MediaPlayer2> mp = getMediaPlayer(env, thiz);
730 jniThrowException(env, "java/lang/IllegalStateException", NULL);
737 env, thiz, mp->getSyncSettings(&scp.sync, &scp.frameRate),
739 if (env->ExceptionCheck()) {
751 jniThrowException(env, "java/lang/IllegalStateException", NULL);
760 return scp.asJobject(env, gSyncParamsFields);
764 android_media_MediaPlayer2_seekTo(JNIEnv *env, jobject thiz, jlong msec, jint mode)
766 sp<MediaPlayer2> mp = getMediaPlayer(env, thiz);
768 jniThrowException(env, "java/lang/IllegalStateException", NULL);
772 process_media_player_call(env, thiz, mp->seekTo((int64_t)msec, (MediaPlayer2SeekMode)mode),
777 android_media_MediaPlayer2_notifyAt(JNIEnv *env, jobject thiz, jlong mediaTimeUs)
779 sp<MediaPlayer2> mp = getMediaPlayer(env, thiz);
781 jniThrowException(env, "java/lang/IllegalStateException", NULL);
785 process_media_player_call( env, thiz, mp->notifyAt((int64_t)mediaTimeUs), NULL, NULL );
789 android_media_MediaPlayer2_getMediaPlayer2State(JNIEnv *env, jobject thiz)
791 sp<MediaPlayer2> mp = getMediaPlayer(env, thiz);
799 android_media_MediaPlayer2_getVideoWidth(JNIEnv *env, jobject thiz)
801 sp<MediaPlayer2> mp = getMediaPlayer(env, thiz);
803 jniThrowException(env, "java/lang/IllegalStateException", NULL);
816 android_media_MediaPlayer2_getVideoHeight(JNIEnv *env, jobject thiz)
818 sp<MediaPlayer2> mp = getMediaPlayer(env, thiz);
820 jniThrowException(env, "java/lang/IllegalStateException", NULL);
833 android_media_MediaPlayer2_native_getMetrics(JNIEnv *env, jobject thiz)
835 sp<MediaPlayer2> mp = getMediaPlayer(env, thiz);
837 jniThrowException(env, "java/lang/IllegalStateException", NULL);
852 jobject mybundle = MediaMetricsJNI::writeMetricsToBundle(env, item, NULL);
862 android_media_MediaPlayer2_getCurrentPosition(JNIEnv *env, jobject thiz)
864 sp<MediaPlayer2> mp = getMediaPlayer(env, thiz);
866 jniThrowException(env, "java/lang/IllegalStateException", NULL);
870 process_media_player_call( env, thiz, mp->getCurrentPosition(&msec), NULL, NULL );
876 android_media_MediaPlayer2_getDuration(JNIEnv *env, jobject thiz)
878 sp<MediaPlayer2> mp = getMediaPlayer(env, thiz);
880 jniThrowException(env, "java/lang/IllegalStateException", NULL);
884 process_media_player_call( env, thiz, mp->getDuration(&msec), NULL, NULL );
890 android_media_MediaPlayer2_reset(JNIEnv *env, jobject thiz)
893 sp<MediaPlayer2> mp = getMediaPlayer(env, thiz);
895 jniThrowException(env, "java/lang/IllegalStateException", NULL);
898 process_media_player_call( env, thiz, mp->reset(), NULL, NULL );
902 android_media_MediaPlayer2_getAudioStreamType(JNIEnv *env, jobject thiz)
904 sp<MediaPlayer2> mp = getMediaPlayer(env, thiz);
906 jniThrowException(env, "java/lang/IllegalStateException", NULL);
910 process_media_player_call( env, thiz, mp->getAudioStreamType(&streamtype), NULL, NULL );
916 android_media_MediaPlayer2_setParameter(JNIEnv *env, jobject thiz, jint key, jobject java_request)
919 sp<MediaPlayer2> mp = getMediaPlayer(env, thiz);
921 jniThrowException(env, "java/lang/IllegalStateException", NULL);
925 Parcel *request = parcelForJavaObject(env, java_request);
935 android_media_MediaPlayer2_getParameter(JNIEnv *env, jobject thiz, jint key)
938 sp<MediaPlayer2> mp = getMediaPlayer(env, thiz);
940 jniThrowException(env, "java/lang/IllegalStateException", NULL);
944 jobject jParcel = createJavaParcelObject(env);
946 Parcel* nativeParcel = parcelForJavaObject(env, jParcel);
949 env->DeleteLocalRef(jParcel);
957 android_media_MediaPlayer2_setLooping(JNIEnv *env, jobject thiz, jboolean looping)
960 sp<MediaPlayer2> mp = getMediaPlayer(env, thiz);
962 jniThrowException(env, "java/lang/IllegalStateException", NULL);
965 process_media_player_call( env, thiz, mp->setLooping(looping), NULL, NULL );
969 android_media_MediaPlayer2_isLooping(JNIEnv *env, jobject thiz)
972 sp<MediaPlayer2> mp = getMediaPlayer(env, thiz);
974 jniThrowException(env, "java/lang/IllegalStateException", NULL);
981 android_media_MediaPlayer2_setVolume(JNIEnv *env, jobject thiz, jfloat leftVolume, jfloat rightVolume)
984 sp<MediaPlayer2> mp = getMediaPlayer(env, thiz);
986 jniThrowException(env, "java/lang/IllegalStateException", NULL);
989 process_media_player_call( env, thiz, mp->setVolume((float) leftVolume, (float) rightVolume), NULL, NULL );
995 android_media_MediaPlayer2_invoke(JNIEnv *env, jobject thiz,
998 sp<MediaPlayer2> media_player = getMediaPlayer(env, thiz);
1000 jniThrowException(env, "java/lang/IllegalStateException", NULL);
1004 Parcel *request = parcelForJavaObject(env, java_request);
1005 Parcel *reply = parcelForJavaObject(env, java_reply);
1016 android_media_MediaPlayer2_setMetadataFilter(JNIEnv *env, jobject thiz, jobject request)
1018 sp<MediaPlayer2> media_player = getMediaPlayer(env, thiz);
1020 jniThrowException(env, "java/lang/IllegalStateException", NULL);
1024 Parcel *filter = parcelForJavaObject(env, request);
1027 jniThrowException(env, "java/lang/RuntimeException", "Filter is null");
1035 android_media_MediaPlayer2_getMetadata(JNIEnv *env, jobject thiz, jboolean update_only,
1038 sp<MediaPlayer2> media_player = getMediaPlayer(env, thiz);
1040 jniThrowException(env, "java/lang/IllegalStateException", NULL);
1044 Parcel *metadata = parcelForJavaObject(env, reply);
1047 jniThrowException(env, "java/lang/RuntimeException", "Reply parcel is null");
1067 android_media_MediaPlayer2_native_init(JNIEnv *env)
1071 clazz = env->FindClass("android/media/MediaPlayer2Impl");
1076 fields.context = env->GetFieldID(clazz, "mNativeContext", "J");
1081 fields.post_event = env->GetStaticMethodID(clazz, "postEventFromNative",
1087 fields.surface_texture = env->GetFieldID(clazz, "mNativeSurfaceTexture", "J");
1092 env->DeleteLocalRef(clazz);
1094 clazz = env->FindClass("android/net/ProxyInfo");
1100 env->GetMethodID(clazz, "getHost", "()Ljava/lang/String;");
1103 env->GetMethodID(clazz, "getPort", "()I");
1106 env->GetMethodID(clazz, "getExclusionListAsString", "()Ljava/lang/String;");
1108 env->DeleteLocalRef(clazz);
1110 gBufferingParamsFields.init(env);
1116 gStateExceptionFields.classId = static_cast<jclass>(env->NewGlobalRef(clazz));
1118 env->DeleteLocalRef(clazz);
1124 gPlaybackParamsFields.init(env);
1125 gSyncParamsFields.init(env);
1126 gVolumeShaperFields.init(env);
1130 android_media_MediaPlayer2_native_setup(JNIEnv *env, jobject thiz, jobject weak_this)
1135 jniThrowException(env, "java/lang/RuntimeException", "Out of memory");
1140 sp<JNIMediaPlayer2Listener> listener = new JNIMediaPlayer2Listener(env, thiz, weak_this);
1144 setMediaPlayer(env, thiz, mp);
1148 android_media_MediaPlayer2_release(JNIEnv *env, jobject thiz)
1151 decVideoSurfaceRef(env, thiz);
1152 sp<MediaPlayer2> mp = setMediaPlayer(env, thiz, 0);
1161 android_media_MediaPlayer2_native_finalize(JNIEnv *env, jobject thiz)
1164 sp<MediaPlayer2> mp = getMediaPlayer(env, thiz);
1168 android_media_MediaPlayer2_release(env, thiz);
1171 static void android_media_MediaPlayer2_set_audio_session_id(JNIEnv *env, jobject thiz,
1174 sp<MediaPlayer2> mp = getMediaPlayer(env, thiz);
1176 jniThrowException(env, "java/lang/IllegalStateException", NULL);
1179 process_media_player_call( env, thiz, mp->setAudioSessionId((audio_session_t) sessionId), NULL,
1183 static jint android_media_MediaPlayer2_get_audio_session_id(JNIEnv *env, jobject thiz) {
1185 sp<MediaPlayer2> mp = getMediaPlayer(env, thiz);
1187 jniThrowException(env, "java/lang/IllegalStateException", NULL);
1195 android_media_MediaPlayer2_setAuxEffectSendLevel(JNIEnv *env, jobject thiz, jfloat level)
1198 sp<MediaPlayer2> mp = getMediaPlayer(env, thiz);
1200 jniThrowException(env, "java/lang/IllegalStateException", NULL);
1203 process_media_player_call( env, thiz, mp->setAuxEffectSendLevel(level), NULL, NULL );
1206 static void android_media_MediaPlayer2_attachAuxEffect(JNIEnv *env, jobject thiz, jint effectId) {
1208 sp<MediaPlayer2> mp = getMediaPlayer(env, thiz);
1210 jniThrowException(env, "java/lang/IllegalStateException", NULL);
1213 process_media_player_call( env, thiz, mp->attachAuxEffect(effectId), NULL, NULL );
1220 static void throwDrmStateException(JNIEnv *env, const char *msg, status_t err)
1224 jobject exception = env->NewObject(gStateExceptionFields.classId,
1226 env->NewStringUTF(msg));
1227 env->Throw(static_cast<jthrowable>(exception));
1231 static bool throwDrmExceptionAsNecessary(JNIEnv *env, status_t err, const char *msg = NULL)
1271 jniThrowException(env, "java/lang/IllegalArgumentException", msg);
1274 jniThrowException(env, "android/media/NotProvisionedException", msg);
1277 jniThrowException(env, "android/media/ResourceBusyException", msg);
1280 jniThrowException(env, "android/media/DeniedByServerException", msg);
1283 jniThrowException(env, "android/media/MediaDrmResetException",
1296 throwDrmStateException(env, msg, err);
1302 static Vector<uint8_t> JByteArrayToVector(JNIEnv *env, jbyteArray const &byteArray)
1305 size_t length = env->GetArrayLength(byteArray);
1307 env->GetByteArrayRegion(byteArray, 0, length, (jbyte *)vector.editArray());
1311 static void android_media_MediaPlayer2_prepareDrm(JNIEnv *env, jobject thiz,
1314 sp<MediaPlayer2> mp = getMediaPlayer(env, thiz);
1316 jniThrowException(env, "java/lang/IllegalStateException", NULL);
1321 jniThrowException(env, "java/lang/IllegalArgumentException", NULL);
1325 Vector<uint8_t> uuid = JByteArrayToVector(env, uuidObj);
1329 env,
1335 Vector<uint8_t> drmSessionId = JByteArrayToVector(env, drmSessionIdObj);
1339 env,
1349 env,
1354 env,
1358 throwDrmExceptionAsNecessary(env, err, "Failed to prepare DRM scheme");
1363 static void android_media_MediaPlayer2_releaseDrm(JNIEnv *env, jobject thiz)
1365 sp<MediaPlayer2> mp = getMediaPlayer(env, thiz);
1367 jniThrowException(env, "java/lang/IllegalStateException", NULL);
1375 env,
1386 static jboolean android_media_MediaPlayer2_setOutputDevice(JNIEnv *env, jobject thiz, jint device_id)
1388 sp<MediaPlayer2> mp = getMediaPlayer(env, thiz);
1395 static jint android_media_MediaPlayer2_getRoutedDeviceId(JNIEnv *env, jobject thiz)
1397 sp<MediaPlayer2> mp = getMediaPlayer(env, thiz);
1405 JNIEnv* env, jobject thiz, jboolean enabled)
1407 sp<MediaPlayer2> mp = getMediaPlayer(env, thiz);
1414 jniThrowException(env, "java/lang/IllegalStateException", NULL);
1424 static void android_media_MediaPlayer2_native_on_tear_down(JNIEnv *env __unused,
1433 static void android_media_MediaPlayer2_native_on_stream_presentation_end(JNIEnv *env __unused,
1442 static void android_media_MediaPlayer2_native_on_stream_data_request(JNIEnv *env __unused,
1553 static int register_android_media_MediaPlayer2Impl(JNIEnv *env)
1555 return AndroidRuntime::registerNativeMethods(env,
1561 JNIEnv* env = NULL;
1564 if (vm->GetEnv((void**) &env, JNI_VERSION_1_4) != JNI_OK) {
1568 assert(env != NULL);
1570 if (register_android_media_MediaPlayer2Impl(env) < 0) {