Lines Matching refs:env

68     JNIMediaPlayerListener(JNIEnv* env, jobject thiz, jobject weak_thiz);
77 JNIMediaPlayerListener::JNIMediaPlayerListener(JNIEnv* env, jobject thiz, jobject weak_thiz)
82 jclass clazz = env->GetObjectClass(thiz);
85 jniThrowException(env, "java/lang/Exception", NULL);
88 mClass = (jclass)env->NewGlobalRef(clazz);
92 mObject = env->NewGlobalRef(weak_thiz);
98 JNIEnv *env = AndroidRuntime::getJNIEnv();
99 env->DeleteGlobalRef(mObject);
100 env->DeleteGlobalRef(mClass);
105 JNIEnv *env = AndroidRuntime::getJNIEnv();
107 jobject jParcel = createJavaParcelObject(env);
109 Parcel* nativeParcel = parcelForJavaObject(env, jParcel);
111 env->CallStaticVoidMethod(mClass, fields.post_event, mObject,
115 env->CallStaticVoidMethod(mClass, fields.post_event, mObject,
118 if (env->ExceptionCheck()) {
120 LOGW_EX(env);
121 env->ExceptionClear();
127 static sp<MediaPlayer> getMediaPlayer(JNIEnv* env, jobject thiz)
130 MediaPlayer* const p = (MediaPlayer*)env->GetIntField(thiz, fields.context);
134 static sp<MediaPlayer> setMediaPlayer(JNIEnv* env, jobject thiz, const sp<MediaPlayer>& player)
137 sp<MediaPlayer> old = (MediaPlayer*)env->GetIntField(thiz, fields.context);
144 env->SetIntField(thiz, fields.context, (int)player.get());
152 static void process_media_player_call(JNIEnv *env, jobject thiz, status_t opStatus, const char* exception, const char *message)
156 sp<MediaPlayer> mp = getMediaPlayer(env, thiz);
161 jniThrowException(env, "java/lang/IllegalStateException", NULL);
163 jniThrowException(env, "java/lang/SecurityException", NULL);
167 jniThrowException( env, exception, message);
172 jniThrowException( env, exception, msg);
180 JNIEnv *env, jobject thiz, jstring path,
183 sp<MediaPlayer> mp = getMediaPlayer(env, thiz);
185 jniThrowException(env, "java/lang/IllegalStateException", NULL);
190 jniThrowException(env, "java/lang/IllegalArgumentException", NULL);
194 const char *tmp = env->GetStringUTFChars(path, NULL);
201 env->ReleaseStringUTFChars(path, tmp);
207 env, keys, values, &headersVector)) {
217 env, thiz, opStatus, "java/io/IOException",
222 android_media_MediaPlayer_setDataSourceFD(JNIEnv *env, jobject thiz, jobject fileDescriptor, jlong offset, jlong length)
224 sp<MediaPlayer> mp = getMediaPlayer(env, thiz);
226 jniThrowException(env, "java/lang/IllegalStateException", NULL);
231 jniThrowException(env, "java/lang/IllegalArgumentException", NULL);
234 int fd = jniGetFDFromFileDescriptor(env, fileDescriptor);
236 process_media_player_call( env, thiz, mp->setDataSource(fd, offset, length), "java/io/IOException", "setDataSourceFD failed." );
240 getVideoSurfaceTexture(JNIEnv* env, jobject thiz) {
241 ISurfaceTexture * const p = (ISurfaceTexture*)env->GetIntField(thiz, fields.surface_texture);
246 decVideoSurfaceRef(JNIEnv *env, jobject thiz)
248 sp<MediaPlayer> mp = getMediaPlayer(env, thiz);
253 sp<ISurfaceTexture> old_st = getVideoSurfaceTexture(env, thiz);
260 setVideoSurface(JNIEnv *env, jobject thiz, jobject jsurface, jboolean mediaPlayerMustBeAlive)
262 sp<MediaPlayer> mp = getMediaPlayer(env, thiz);
265 jniThrowException(env, "java/lang/IllegalStateException", NULL);
270 decVideoSurfaceRef(env, thiz);
274 sp<Surface> surface(android_view_Surface_getSurface(env, jsurface));
278 jniThrowException(env, "java/lang/IllegalArgumentException",
284 jniThrowException(env, "java/lang/IllegalArgumentException",
290 env->SetIntField(thiz, fields.surface_texture, (int)new_st.get());
300 android_media_MediaPlayer_setVideoSurface(JNIEnv *env, jobject thiz, jobject jsurface)
302 setVideoSurface(env, thiz, jsurface, true /* mediaPlayerMustBeAlive */);
306 android_media_MediaPlayer_prepare(JNIEnv *env, jobject thiz)
308 sp<MediaPlayer> mp = getMediaPlayer(env, thiz);
310 jniThrowException(env, "java/lang/IllegalStateException", NULL);
316 sp<ISurfaceTexture> st = getVideoSurfaceTexture(env, thiz);
319 process_media_player_call( env, thiz, mp->prepare(), "java/io/IOException", "Prepare failed." );
323 android_media_MediaPlayer_prepareAsync(JNIEnv *env, jobject thiz)
325 sp<MediaPlayer> mp = getMediaPlayer(env, thiz);
327 jniThrowException(env, "java/lang/IllegalStateException", NULL);
333 sp<ISurfaceTexture> st = getVideoSurfaceTexture(env, thiz);
336 process_media_player_call( env, thiz, mp->prepareAsync(), "java/io/IOException", "Prepare Async failed." );
340 android_media_MediaPlayer_start(JNIEnv *env, jobject thiz)
343 sp<MediaPlayer> mp = getMediaPlayer(env, thiz);
345 jniThrowException(env, "java/lang/IllegalStateException", NULL);
348 process_media_player_call( env, thiz, mp->start(), NULL, NULL );
352 android_media_MediaPlayer_stop(JNIEnv *env, jobject thiz)
355 sp<MediaPlayer> mp = getMediaPlayer(env, thiz);
357 jniThrowException(env, "java/lang/IllegalStateException", NULL);
360 process_media_player_call( env, thiz, mp->stop(), NULL, NULL );
364 android_media_MediaPlayer_pause(JNIEnv *env, jobject thiz)
367 sp<MediaPlayer> mp = getMediaPlayer(env, thiz);
369 jniThrowException(env, "java/lang/IllegalStateException", NULL);
372 process_media_player_call( env, thiz, mp->pause(), NULL, NULL );
376 android_media_MediaPlayer_isPlaying(JNIEnv *env, jobject thiz)
378 sp<MediaPlayer> mp = getMediaPlayer(env, thiz);
380 jniThrowException(env, "java/lang/IllegalStateException", NULL);
390 android_media_MediaPlayer_seekTo(JNIEnv *env, jobject thiz, int msec)
392 sp<MediaPlayer> mp = getMediaPlayer(env, thiz);
394 jniThrowException(env, "java/lang/IllegalStateException", NULL);
398 process_media_player_call( env, thiz, mp->seekTo(msec), NULL, NULL );
402 android_media_MediaPlayer_getVideoWidth(JNIEnv *env, jobject thiz)
404 sp<MediaPlayer> mp = getMediaPlayer(env, thiz);
406 jniThrowException(env, "java/lang/IllegalStateException", NULL);
419 android_media_MediaPlayer_getVideoHeight(JNIEnv *env, jobject thiz)
421 sp<MediaPlayer> mp = getMediaPlayer(env, thiz);
423 jniThrowException(env, "java/lang/IllegalStateException", NULL);
437 android_media_MediaPlayer_getCurrentPosition(JNIEnv *env, jobject thiz)
439 sp<MediaPlayer> mp = getMediaPlayer(env, thiz);
441 jniThrowException(env, "java/lang/IllegalStateException", NULL);
445 process_media_player_call( env, thiz, mp->getCurrentPosition(&msec), NULL, NULL );
451 android_media_MediaPlayer_getDuration(JNIEnv *env, jobject thiz)
453 sp<MediaPlayer> mp = getMediaPlayer(env, thiz);
455 jniThrowException(env, "java/lang/IllegalStateException", NULL);
459 process_media_player_call( env, thiz, mp->getDuration(&msec), NULL, NULL );
465 android_media_MediaPlayer_reset(JNIEnv *env, jobject thiz)
468 sp<MediaPlayer> mp = getMediaPlayer(env, thiz);
470 jniThrowException(env, "java/lang/IllegalStateException", NULL);
473 process_media_player_call( env, thiz, mp->reset(), NULL, NULL );
477 android_media_MediaPlayer_setAudioStreamType(JNIEnv *env, jobject thiz, int streamtype)
480 sp<MediaPlayer> mp = getMediaPlayer(env, thiz);
482 jniThrowException(env, "java/lang/IllegalStateException", NULL);
485 process_media_player_call( env, thiz, mp->setAudioStreamType((audio_stream_type_t) streamtype) , NULL, NULL );
489 android_media_MediaPlayer_setLooping(JNIEnv *env, jobject thiz, jboolean looping)
492 sp<MediaPlayer> mp = getMediaPlayer(env, thiz);
494 jniThrowException(env, "java/lang/IllegalStateException", NULL);
497 process_media_player_call( env, thiz, mp->setLooping(looping), NULL, NULL );
501 android_media_MediaPlayer_isLooping(JNIEnv *env, jobject thiz)
504 sp<MediaPlayer> mp = getMediaPlayer(env, thiz);
506 jniThrowException(env, "java/lang/IllegalStateException", NULL);
513 android_media_MediaPlayer_setVolume(JNIEnv *env, jobject thiz, float leftVolume, float rightVolume)
516 sp<MediaPlayer> mp = getMediaPlayer(env, thiz);
518 jniThrowException(env, "java/lang/IllegalStateException", NULL);
521 process_media_player_call( env, thiz, mp->setVolume(leftVolume, rightVolume), NULL, NULL );
526 android_media_MediaPlayer_getFrameAt(JNIEnv *env, jobject thiz, jint msec)
535 android_media_MediaPlayer_invoke(JNIEnv *env, jobject thiz,
538 sp<MediaPlayer> media_player = getMediaPlayer(env, thiz);
540 jniThrowException(env, "java/lang/IllegalStateException", NULL);
544 Parcel *request = parcelForJavaObject(env, java_request);
545 Parcel *reply = parcelForJavaObject(env, java_reply);
554 android_media_MediaPlayer_setMetadataFilter(JNIEnv *env, jobject thiz, jobject request)
556 sp<MediaPlayer> media_player = getMediaPlayer(env, thiz);
558 jniThrowException(env, "java/lang/IllegalStateException", NULL);
562 Parcel *filter = parcelForJavaObject(env, request);
565 jniThrowException(env, "java/lang/RuntimeException", "Filter is null");
573 android_media_MediaPlayer_getMetadata(JNIEnv *env, jobject thiz, jboolean update_only,
576 sp<MediaPlayer> media_player = getMediaPlayer(env, thiz);
578 jniThrowException(env, "java/lang/IllegalStateException", NULL);
582 Parcel *metadata = parcelForJavaObject(env, reply);
585 jniThrowException(env, "java/lang/RuntimeException", "Reply parcel is null");
601 android_media_MediaPlayer_native_init(JNIEnv *env)
605 clazz = env->FindClass("android/media/MediaPlayer");
610 fields.context = env->GetFieldID(clazz, "mNativeContext", "I");
615 fields.post_event = env->GetStaticMethodID(clazz, "postEventFromNative",
621 fields.surface_texture = env->GetFieldID(clazz, "mNativeSurfaceTexture", "I");
628 android_media_MediaPlayer_native_setup(JNIEnv *env, jobject thiz, jobject weak_this)
633 jniThrowException(env, "java/lang/RuntimeException", "Out of memory");
638 sp<JNIMediaPlayerListener> listener = new JNIMediaPlayerListener(env, thiz, weak_this);
642 setMediaPlayer(env, thiz, mp);
646 android_media_MediaPlayer_release(JNIEnv *env, jobject thiz)
649 decVideoSurfaceRef(env, thiz);
650 sp<MediaPlayer> mp = setMediaPlayer(env, thiz, 0);
659 android_media_MediaPlayer_native_finalize(JNIEnv *env, jobject thiz)
662 sp<MediaPlayer> mp = getMediaPlayer(env, thiz);
666 android_media_MediaPlayer_release(env, thiz);
669 static void android_media_MediaPlayer_set_audio_session_id(JNIEnv *env, jobject thiz, jint sessionId) {
671 sp<MediaPlayer> mp = getMediaPlayer(env, thiz);
673 jniThrowException(env, "java/lang/IllegalStateException", NULL);
676 process_media_player_call( env, thiz, mp->setAudioSessionId(sessionId), NULL, NULL );
679 static jint android_media_MediaPlayer_get_audio_session_id(JNIEnv *env, jobject thiz) {
681 sp<MediaPlayer> mp = getMediaPlayer(env, thiz);
683 jniThrowException(env, "java/lang/IllegalStateException", NULL);
691 android_media_MediaPlayer_setAuxEffectSendLevel(JNIEnv *env, jobject thiz, jfloat level)
694 sp<MediaPlayer> mp = getMediaPlayer(env, thiz);
696 jniThrowException(env, "java/lang/IllegalStateException", NULL);
699 process_media_player_call( env, thiz, mp->setAuxEffectSendLevel(level), NULL, NULL );
702 static void android_media_MediaPlayer_attachAuxEffect(JNIEnv *env, jobject thiz, jint effectId) {
704 sp<MediaPlayer> mp = getMediaPlayer(env, thiz);
706 jniThrowException(env, "java/lang/IllegalStateException", NULL);
709 process_media_player_call( env, thiz, mp->attachAuxEffect(effectId), NULL, NULL );
713 android_media_MediaPlayer_pullBatteryData(JNIEnv *env, jobject thiz, jobject java_reply)
718 jniThrowException(env, "java/lang/RuntimeException", "cannot get MediaPlayerService");
722 Parcel *reply = parcelForJavaObject(env, java_reply);
728 android_media_MediaPlayer_setRetransmitEndpoint(JNIEnv *env, jobject thiz,
730 sp<MediaPlayer> mp = getMediaPlayer(env, thiz);
732 jniThrowException(env, "java/lang/IllegalStateException", NULL);
739 cAddrString = env->GetStringUTFChars(addrString, NULL);
756 env->ReleaseStringUTFChars(addrString, cAddrString);
760 jniThrowException(env, "java/lang/IllegalStateException", NULL);
767 android_media_MediaPlayer_setParameter(JNIEnv *env, jobject thiz, jint key, jobject java_request)
770 sp<MediaPlayer> mp = getMediaPlayer(env, thiz);
772 jniThrowException(env, "java/lang/IllegalStateException", NULL);
776 Parcel *request = parcelForJavaObject(env, java_request);
786 android_media_MediaPlayer_getParameter(JNIEnv *env, jobject thiz, jint key, jobject java_reply)
789 sp<MediaPlayer> mp = getMediaPlayer(env, thiz);
791 jniThrowException(env, "java/lang/IllegalStateException", NULL);
795 Parcel *reply = parcelForJavaObject(env, java_reply);
796 process_media_player_call(env, thiz, mp->getParameter(key, reply), NULL, NULL );
800 android_media_MediaPlayer_setNextMediaPlayer(JNIEnv *env, jobject thiz, jobject java_player)
803 sp<MediaPlayer> thisplayer = getMediaPlayer(env, thiz);
805 jniThrowException(env, "java/lang/IllegalStateException", "This player not initialized");
808 sp<MediaPlayer> nextplayer = (java_player == NULL) ? NULL : getMediaPlayer(env, java_player);
810 jniThrowException(env, "java/lang/IllegalStateException", "That player not initialized");
815 jniThrowException(env, "java/lang/IllegalArgumentException", "Next player can't be self");
820 env, thiz, thisplayer->setNextMediaPlayer(nextplayer),
875 static int register_android_media_MediaPlayer(JNIEnv *env)
877 return AndroidRuntime::registerNativeMethods(env,
881 extern int register_android_media_Crypto(JNIEnv *env);
882 extern int register_android_media_MediaCodec(JNIEnv *env);
883 extern int register_android_media_MediaExtractor(JNIEnv *env);
884 extern int register_android_media_MediaCodecList(JNIEnv *env);
885 extern int register_android_media_MediaMetadataRetriever(JNIEnv *env);
886 extern int register_android_media_MediaRecorder(JNIEnv *env);
887 extern int register_android_media_MediaScanner(JNIEnv *env);
888 extern int register_android_media_ResampleInputStream(JNIEnv *env);
889 extern int register_android_media_MediaProfiles(JNIEnv *env);
890 extern int register_android_media_AmrInputStream(JNIEnv *env);
891 extern int register_android_mtp_MtpDatabase(JNIEnv *env);
892 extern int register_android_mtp_MtpDevice(JNIEnv *env);
893 extern int register_android_mtp_MtpServer(JNIEnv *env);
897 JNIEnv* env = NULL;
900 if (vm->GetEnv((void**) &env, JNI_VERSION_1_4) != JNI_OK) {
904 assert(env != NULL);
906 if (register_android_media_MediaPlayer(env) < 0) {
911 if (register_android_media_MediaRecorder(env) < 0) {
916 if (register_android_media_MediaScanner(env) < 0) {
921 if (register_android_media_MediaMetadataRetriever(env) < 0) {
926 if (register_android_media_AmrInputStream(env) < 0) {
931 if (register_android_media_ResampleInputStream(env) < 0) {
936 if (register_android_media_MediaProfiles(env) < 0) {
941 if (register_android_mtp_MtpDatabase(env) < 0) {
946 if (register_android_mtp_MtpDevice(env) < 0) {
951 if (register_android_mtp_MtpServer(env) < 0) {
956 if (register_android_media_MediaCodec(env) < 0) {
961 if (register_android_media_MediaExtractor(env) < 0) {
966 if (register_android_media_MediaCodecList(env) < 0) {
971 if (register_android_media_Crypto(env) < 0) {