Lines Matching refs:env

75     JNIMediaPlayerListener(JNIEnv* env, jobject thiz, jobject weak_thiz);
84 JNIMediaPlayerListener::JNIMediaPlayerListener(JNIEnv* env, jobject thiz, jobject weak_thiz)
89 jclass clazz = env->GetObjectClass(thiz);
92 jniThrowException(env, "java/lang/Exception", NULL);
95 mClass = (jclass)env->NewGlobalRef(clazz);
99 mObject = env->NewGlobalRef(weak_thiz);
105 JNIEnv *env = AndroidRuntime::getJNIEnv();
106 env->DeleteGlobalRef(mObject);
107 env->DeleteGlobalRef(mClass);
112 JNIEnv *env = AndroidRuntime::getJNIEnv();
114 jobject jParcel = createJavaParcelObject(env);
116 Parcel* nativeParcel = parcelForJavaObject(env, jParcel);
118 env->CallStaticVoidMethod(mClass, fields.post_event, mObject,
120 env->DeleteLocalRef(jParcel);
123 env->CallStaticVoidMethod(mClass, fields.post_event, mObject,
126 if (env->ExceptionCheck()) {
128 LOGW_EX(env);
129 env->ExceptionClear();
135 static sp<MediaPlayer> getMediaPlayer(JNIEnv* env, jobject thiz)
138 MediaPlayer* const p = (MediaPlayer*)env->GetLongField(thiz, fields.context);
142 static sp<MediaPlayer> setMediaPlayer(JNIEnv* env, jobject thiz, const sp<MediaPlayer>& player)
145 sp<MediaPlayer> old = (MediaPlayer*)env->GetLongField(thiz, fields.context);
152 env->SetLongField(thiz, fields.context, (jlong)player.get());
160 static void process_media_player_call(JNIEnv *env, jobject thiz, status_t opStatus, const char* exception, const char *message)
164 sp<MediaPlayer> mp = getMediaPlayer(env, thiz);
169 jniThrowException(env, "java/lang/IllegalStateException", NULL);
171 jniThrowException(env, "java/lang/SecurityException", NULL);
175 jniThrowException( env, exception, message);
180 jniThrowException( env, exception, msg);
188 JNIEnv *env, jobject thiz, jobject httpServiceBinderObj, jstring path,
191 sp<MediaPlayer> mp = getMediaPlayer(env, thiz);
193 jniThrowException(env, "java/lang/IllegalStateException", NULL);
198 jniThrowException(env, "java/lang/IllegalArgumentException", NULL);
202 const char *tmp = env->GetStringUTFChars(path, NULL);
209 env->ReleaseStringUTFChars(path, tmp);
215 env, keys, values, &headersVector)) {
221 sp<IBinder> binder = ibinderForJavaObject(env, httpServiceBinderObj);
232 env, thiz, opStatus, "java/io/IOException",
237 android_media_MediaPlayer_setDataSourceFD(JNIEnv *env, jobject thiz, jobject fileDescriptor, jlong offset, jlong length)
239 sp<MediaPlayer> mp = getMediaPlayer(env, thiz);
241 jniThrowException(env, "java/lang/IllegalStateException", NULL);
246 jniThrowException(env, "java/lang/IllegalArgumentException", NULL);
249 int fd = jniGetFDFromFileDescriptor(env, fileDescriptor);
251 process_media_player_call( env, thiz, mp->setDataSource(fd, offset, length), "java/io/IOException", "setDataSourceFD failed." );
255 getVideoSurfaceTexture(JNIEnv* env, jobject thiz) {
256 IGraphicBufferProducer * const p = (IGraphicBufferProducer*)env->GetLongField(thiz, fields.surface_texture);
261 decVideoSurfaceRef(JNIEnv *env, jobject thiz)
263 sp<MediaPlayer> mp = getMediaPlayer(env, thiz);
268 sp<IGraphicBufferProducer> old_st = getVideoSurfaceTexture(env, thiz);
275 setVideoSurface(JNIEnv *env, jobject thiz, jobject jsurface, jboolean mediaPlayerMustBeAlive)
277 sp<MediaPlayer> mp = getMediaPlayer(env, thiz);
280 jniThrowException(env, "java/lang/IllegalStateException", NULL);
285 decVideoSurfaceRef(env, thiz);
289 sp<Surface> surface(android_view_Surface_getSurface(env, jsurface));
293 jniThrowException(env, "java/lang/IllegalArgumentException",
299 jniThrowException(env, "java/lang/IllegalArgumentException",
305 env->SetLongField(thiz, fields.surface_texture, (jlong)new_st.get());
315 android_media_MediaPlayer_setVideoSurface(JNIEnv *env, jobject thiz, jobject jsurface)
317 setVideoSurface(env, thiz, jsurface, true /* mediaPlayerMustBeAlive */);
321 android_media_MediaPlayer_prepare(JNIEnv *env, jobject thiz)
323 sp<MediaPlayer> mp = getMediaPlayer(env, thiz);
325 jniThrowException(env, "java/lang/IllegalStateException", NULL);
331 sp<IGraphicBufferProducer> st = getVideoSurfaceTexture(env, thiz);
334 process_media_player_call( env, thiz, mp->prepare(), "java/io/IOException", "Prepare failed." );
338 android_media_MediaPlayer_prepareAsync(JNIEnv *env, jobject thiz)
340 sp<MediaPlayer> mp = getMediaPlayer(env, thiz);
342 jniThrowException(env, "java/lang/IllegalStateException", NULL);
348 sp<IGraphicBufferProducer> st = getVideoSurfaceTexture(env, thiz);
351 process_media_player_call( env, thiz, mp->prepareAsync(), "java/io/IOException", "Prepare Async failed." );
355 android_media_MediaPlayer_start(JNIEnv *env, jobject thiz)
358 sp<MediaPlayer> mp = getMediaPlayer(env, thiz);
360 jniThrowException(env, "java/lang/IllegalStateException", NULL);
363 process_media_player_call( env, thiz, mp->start(), NULL, NULL );
367 android_media_MediaPlayer_stop(JNIEnv *env, jobject thiz)
370 sp<MediaPlayer> mp = getMediaPlayer(env, thiz);
372 jniThrowException(env, "java/lang/IllegalStateException", NULL);
375 process_media_player_call( env, thiz, mp->stop(), NULL, NULL );
379 android_media_MediaPlayer_pause(JNIEnv *env, jobject thiz)
382 sp<MediaPlayer> mp = getMediaPlayer(env, thiz);
384 jniThrowException(env, "java/lang/IllegalStateException", NULL);
387 process_media_player_call( env, thiz, mp->pause(), NULL, NULL );
391 android_media_MediaPlayer_isPlaying(JNIEnv *env, jobject thiz)
393 sp<MediaPlayer> mp = getMediaPlayer(env, thiz);
395 jniThrowException(env, "java/lang/IllegalStateException", NULL);
405 android_media_MediaPlayer_seekTo(JNIEnv *env, jobject thiz, jint msec)
407 sp<MediaPlayer> mp = getMediaPlayer(env, thiz);
409 jniThrowException(env, "java/lang/IllegalStateException", NULL);
413 process_media_player_call( env, thiz, mp->seekTo(msec), NULL, NULL );
417 android_media_MediaPlayer_getVideoWidth(JNIEnv *env, jobject thiz)
419 sp<MediaPlayer> mp = getMediaPlayer(env, thiz);
421 jniThrowException(env, "java/lang/IllegalStateException", NULL);
434 android_media_MediaPlayer_getVideoHeight(JNIEnv *env, jobject thiz)
436 sp<MediaPlayer> mp = getMediaPlayer(env, thiz);
438 jniThrowException(env, "java/lang/IllegalStateException", NULL);
452 android_media_MediaPlayer_getCurrentPosition(JNIEnv *env, jobject thiz)
454 sp<MediaPlayer> mp = getMediaPlayer(env, thiz);
456 jniThrowException(env, "java/lang/IllegalStateException", NULL);
460 process_media_player_call( env, thiz, mp->getCurrentPosition(&msec), NULL, NULL );
466 android_media_MediaPlayer_getDuration(JNIEnv *env, jobject thiz)
468 sp<MediaPlayer> mp = getMediaPlayer(env, thiz);
470 jniThrowException(env, "java/lang/IllegalStateException", NULL);
474 process_media_player_call( env, thiz, mp->getDuration(&msec), NULL, NULL );
480 android_media_MediaPlayer_reset(JNIEnv *env, jobject thiz)
483 sp<MediaPlayer> mp = getMediaPlayer(env, thiz);
485 jniThrowException(env, "java/lang/IllegalStateException", NULL);
488 process_media_player_call( env, thiz, mp->reset(), NULL, NULL );
492 android_media_MediaPlayer_setAudioStreamType(JNIEnv *env, jobject thiz, jint streamtype)
495 sp<MediaPlayer> mp = getMediaPlayer(env, thiz);
497 jniThrowException(env, "java/lang/IllegalStateException", NULL);
500 process_media_player_call( env, thiz, mp->setAudioStreamType((audio_stream_type_t) streamtype) , NULL, NULL );
504 android_media_MediaPlayer_getAudioStreamType(JNIEnv *env, jobject thiz)
506 sp<MediaPlayer> mp = getMediaPlayer(env, thiz);
508 jniThrowException(env, "java/lang/IllegalStateException", NULL);
512 process_media_player_call( env, thiz, mp->getAudioStreamType(&streamtype), NULL, NULL );
518 android_media_MediaPlayer_setParameter(JNIEnv *env, jobject thiz, jint key, jobject java_request)
521 sp<MediaPlayer> mp = getMediaPlayer(env, thiz);
523 jniThrowException(env, "java/lang/IllegalStateException", NULL);
527 Parcel *request = parcelForJavaObject(env, java_request);
537 android_media_MediaPlayer_setLooping(JNIEnv *env, jobject thiz, jboolean looping)
540 sp<MediaPlayer> mp = getMediaPlayer(env, thiz);
542 jniThrowException(env, "java/lang/IllegalStateException", NULL);
545 process_media_player_call( env, thiz, mp->setLooping(looping), NULL, NULL );
549 android_media_MediaPlayer_isLooping(JNIEnv *env, jobject thiz)
552 sp<MediaPlayer> mp = getMediaPlayer(env, thiz);
554 jniThrowException(env, "java/lang/IllegalStateException", NULL);
561 android_media_MediaPlayer_setVolume(JNIEnv *env, jobject thiz, jfloat leftVolume, jfloat rightVolume)
564 sp<MediaPlayer> mp = getMediaPlayer(env, thiz);
566 jniThrowException(env, "java/lang/IllegalStateException", NULL);
569 process_media_player_call( env, thiz, mp->setVolume((float) leftVolume, (float) rightVolume), NULL, NULL );
575 android_media_MediaPlayer_invoke(JNIEnv *env, jobject thiz,
578 sp<MediaPlayer> media_player = getMediaPlayer(env, thiz);
580 jniThrowException(env, "java/lang/IllegalStateException", NULL);
584 Parcel *request = parcelForJavaObject(env, java_request);
585 Parcel *reply = parcelForJavaObject(env, java_reply);
594 android_media_MediaPlayer_setMetadataFilter(JNIEnv *env, jobject thiz, jobject request)
596 sp<MediaPlayer> media_player = getMediaPlayer(env, thiz);
598 jniThrowException(env, "java/lang/IllegalStateException", NULL);
602 Parcel *filter = parcelForJavaObject(env, request);
605 jniThrowException(env, "java/lang/RuntimeException", "Filter is null");
613 android_media_MediaPlayer_getMetadata(JNIEnv *env, jobject thiz, jboolean update_only,
616 sp<MediaPlayer> media_player = getMediaPlayer(env, thiz);
618 jniThrowException(env, "java/lang/IllegalStateException", NULL);
622 Parcel *metadata = parcelForJavaObject(env, reply);
625 jniThrowException(env, "java/lang/RuntimeException", "Reply parcel is null");
645 android_media_MediaPlayer_native_init(JNIEnv *env)
649 clazz = env->FindClass("android/media/MediaPlayer");
654 fields.context = env->GetFieldID(clazz, "mNativeContext", "J");
659 fields.post_event = env->GetStaticMethodID(clazz, "postEventFromNative",
665 fields.surface_texture = env->GetFieldID(clazz, "mNativeSurfaceTexture", "J");
670 clazz = env->FindClass("android/net/ProxyInfo");
676 env->GetMethodID(clazz, "getHost", "()Ljava/lang/String;");
679 env->GetMethodID(clazz, "getPort", "()I");
682 env->GetMethodID(clazz, "getExclusionListAsString", "()Ljava/lang/String;");
686 android_media_MediaPlayer_native_setup(JNIEnv *env, jobject thiz, jobject weak_this)
691 jniThrowException(env, "java/lang/RuntimeException", "Out of memory");
696 sp<JNIMediaPlayerListener> listener = new JNIMediaPlayerListener(env, thiz, weak_this);
700 setMediaPlayer(env, thiz, mp);
704 android_media_MediaPlayer_release(JNIEnv *env, jobject thiz)
707 decVideoSurfaceRef(env, thiz);
708 sp<MediaPlayer> mp = setMediaPlayer(env, thiz, 0);
717 android_media_MediaPlayer_native_finalize(JNIEnv *env, jobject thiz)
720 sp<MediaPlayer> mp = getMediaPlayer(env, thiz);
724 android_media_MediaPlayer_release(env, thiz);
727 static void android_media_MediaPlayer_set_audio_session_id(JNIEnv *env, jobject thiz, jint sessionId) {
729 sp<MediaPlayer> mp = getMediaPlayer(env, thiz);
731 jniThrowException(env, "java/lang/IllegalStateException", NULL);
734 process_media_player_call( env, thiz, mp->setAudioSessionId(sessionId), NULL, NULL );
737 static jint android_media_MediaPlayer_get_audio_session_id(JNIEnv *env, jobject thiz) {
739 sp<MediaPlayer> mp = getMediaPlayer(env, thiz);
741 jniThrowException(env, "java/lang/IllegalStateException", NULL);
749 android_media_MediaPlayer_setAuxEffectSendLevel(JNIEnv *env, jobject thiz, jfloat level)
752 sp<MediaPlayer> mp = getMediaPlayer(env, thiz);
754 jniThrowException(env, "java/lang/IllegalStateException", NULL);
757 process_media_player_call( env, thiz, mp->setAuxEffectSendLevel(level), NULL, NULL );
760 static void android_media_MediaPlayer_attachAuxEffect(JNIEnv *env, jobject thiz, jint effectId) {
762 sp<MediaPlayer> mp = getMediaPlayer(env, thiz);
764 jniThrowException(env, "java/lang/IllegalStateException", NULL);
767 process_media_player_call( env, thiz, mp->attachAuxEffect(effectId), NULL, NULL );
772 JNIEnv *env, jobject /* thiz */, jobject java_reply)
777 jniThrowException(env, "java/lang/RuntimeException", "cannot get MediaPlayerService");
781 Parcel *reply = parcelForJavaObject(env, java_reply);
787 android_media_MediaPlayer_setRetransmitEndpoint(JNIEnv *env, jobject thiz,
789 sp<MediaPlayer> mp = getMediaPlayer(env, thiz);
791 jniThrowException(env, "java/lang/IllegalStateException", NULL);
798 cAddrString = env->GetStringUTFChars(addrString, NULL);
815 env->ReleaseStringUTFChars(addrString, cAddrString);
819 jniThrowException(env, "java/lang/IllegalStateException", NULL);
826 android_media_MediaPlayer_setNextMediaPlayer(JNIEnv *env, jobject thiz, jobject java_player)
829 sp<MediaPlayer> thisplayer = getMediaPlayer(env, thiz);
831 jniThrowException(env, "java/lang/IllegalStateException", "This player not initialized");
834 sp<MediaPlayer> nextplayer = (java_player == NULL) ? NULL : getMediaPlayer(env, java_player);
836 jniThrowException(env, "java/lang/IllegalStateException", "That player not initialized");
841 jniThrowException(env, "java/lang/IllegalArgumentException", "Next player can't be self");
846 env, thiz, thisplayer->setNextMediaPlayer(nextplayer),
901 static int register_android_media_MediaPlayer(JNIEnv *env)
903 return AndroidRuntime::registerNativeMethods(env,
907 extern int register_android_media_ImageReader(JNIEnv *env);
908 extern int register_android_media_Crypto(JNIEnv *env);
909 extern int register_android_media_Drm(JNIEnv *env);
910 extern int register_android_media_MediaCodec(JNIEnv *env);
911 extern int register_android_media_MediaExtractor(JNIEnv *env);
912 extern int register_android_media_MediaCodecList(JNIEnv *env);
913 extern int register_android_media_MediaHTTPConnection(JNIEnv *env);
914 extern int register_android_media_MediaMetadataRetriever(JNIEnv *env);
915 extern int register_android_media_MediaMuxer(JNIEnv *env);
916 extern int register_android_media_MediaRecorder(JNIEnv *env);
917 extern int register_android_media_MediaScanner(JNIEnv *env);
918 extern int register_android_media_ResampleInputStream(JNIEnv *env);
919 extern int register_android_media_MediaProfiles(JNIEnv *env);
920 extern int register_android_media_AmrInputStream(JNIEnv *env);
921 extern int register_android_mtp_MtpDatabase(JNIEnv *env);
922 extern int register_android_mtp_MtpDevice(JNIEnv *env);
923 extern int register_android_mtp_MtpServer(JNIEnv *env);
927 JNIEnv* env = NULL;
930 if (vm->GetEnv((void**) &env, JNI_VERSION_1_4) != JNI_OK) {
934 assert(env != NULL);
936 if (register_android_media_ImageReader(env) < 0) {
941 if (register_android_media_MediaPlayer(env) < 0) {
946 if (register_android_media_MediaRecorder(env) < 0) {
951 if (register_android_media_MediaScanner(env) < 0) {
956 if (register_android_media_MediaMetadataRetriever(env) < 0) {
961 if (register_android_media_AmrInputStream(env) < 0) {
966 if (register_android_media_ResampleInputStream(env) < 0) {
971 if (register_android_media_MediaProfiles(env) < 0) {
976 if (register_android_mtp_MtpDatabase(env) < 0) {
981 if (register_android_mtp_MtpDevice(env) < 0) {
986 if (register_android_mtp_MtpServer(env) < 0) {
991 if (register_android_media_MediaCodec(env) < 0) {
996 if (register_android_media_MediaExtractor(env) < 0) {
1001 if (register_android_media_MediaMuxer(env) < 0) {
1006 if (register_android_media_MediaCodecList(env) < 0) {
1011 if (register_android_media_Crypto(env) < 0) {
1016 if (register_android_media_Drm(env) < 0) {
1021 if (register_android_media_MediaHTTPConnection(env) < 0) {