Lines Matching refs:env

82     JNIMediaPlayerListener(JNIEnv* env, jobject thiz, jobject weak_thiz);
91 JNIMediaPlayerListener::JNIMediaPlayerListener(JNIEnv* env, jobject thiz, jobject weak_thiz)
96 jclass clazz = env->GetObjectClass(thiz);
99 jniThrowException(env, "java/lang/Exception", NULL);
102 mClass = (jclass)env->NewGlobalRef(clazz);
106 mObject = env->NewGlobalRef(weak_thiz);
112 JNIEnv *env = AndroidRuntime::getJNIEnv();
113 env->DeleteGlobalRef(mObject);
114 env->DeleteGlobalRef(mClass);
119 JNIEnv *env = AndroidRuntime::getJNIEnv();
121 jobject jParcel = createJavaParcelObject(env);
123 Parcel* nativeParcel = parcelForJavaObject(env, jParcel);
125 env->CallStaticVoidMethod(mClass, fields.post_event, mObject,
127 env->DeleteLocalRef(jParcel);
130 env->CallStaticVoidMethod(mClass, fields.post_event, mObject,
133 if (env->ExceptionCheck()) {
135 LOGW_EX(env);
136 env->ExceptionClear();
142 static sp<MediaPlayer> getMediaPlayer(JNIEnv* env, jobject thiz)
145 MediaPlayer* const p = (MediaPlayer*)env->GetLongField(thiz, fields.context);
149 static sp<MediaPlayer> setMediaPlayer(JNIEnv* env, jobject thiz, const sp<MediaPlayer>& player)
152 sp<MediaPlayer> old = (MediaPlayer*)env->GetLongField(thiz, fields.context);
159 env->SetLongField(thiz, fields.context, (jlong)player.get());
167 static void process_media_player_call(JNIEnv *env, jobject thiz, status_t opStatus, const char* exception, const char *message)
171 sp<MediaPlayer> mp = getMediaPlayer(env, thiz);
176 jniThrowException(env, "java/lang/IllegalStateException", NULL);
178 jniThrowException(env, "java/lang/IllegalArgumentException", NULL);
180 jniThrowException(env, "java/lang/SecurityException", NULL);
184 jniThrowException( env, exception, message);
189 jniThrowException( env, exception, msg);
197 JNIEnv *env, jobject thiz, jobject httpServiceBinderObj, jstring path,
200 sp<MediaPlayer> mp = getMediaPlayer(env, thiz);
202 jniThrowException(env, "java/lang/IllegalStateException", NULL);
207 jniThrowException(env, "java/lang/IllegalArgumentException", NULL);
211 const char *tmp = env->GetStringUTFChars(path, NULL);
218 env->ReleaseStringUTFChars(path, tmp);
224 env, keys, values, &headersVector)) {
230 sp<IBinder> binder = ibinderForJavaObject(env, httpServiceBinderObj);
241 env, thiz, opStatus, "java/io/IOException",
246 android_media_MediaPlayer_setDataSourceFD(JNIEnv *env, jobject thiz, jobject fileDescriptor, jlong offset, jlong length)
248 sp<MediaPlayer> mp = getMediaPlayer(env, thiz);
250 jniThrowException(env, "java/lang/IllegalStateException", NULL);
255 jniThrowException(env, "java/lang/IllegalArgumentException", NULL);
258 int fd = jniGetFDFromFileDescriptor(env, fileDescriptor);
260 process_media_player_call( env, thiz, mp->setDataSource(fd, offset, length), "java/io/IOException", "setDataSourceFD failed." );
264 android_media_MediaPlayer_setDataSourceCallback(JNIEnv *env, jobject thiz, jobject dataSource)
266 sp<MediaPlayer> mp = getMediaPlayer(env, thiz);
268 jniThrowException(env, "java/lang/IllegalStateException", NULL);
273 jniThrowException(env, "java/lang/IllegalArgumentException", NULL);
276 sp<IDataSource> callbackDataSource = new JMediaDataSource(env, dataSource);
277 process_media_player_call(env, thiz, mp->setDataSource(callbackDataSource), "java/lang/RuntimeException", "setDataSourceCallback failed." );
281 getVideoSurfaceTexture(JNIEnv* env, jobject thiz) {
282 IGraphicBufferProducer * const p = (IGraphicBufferProducer*)env->GetLongField(thiz, fields.surface_texture);
287 decVideoSurfaceRef(JNIEnv *env, jobject thiz)
289 sp<MediaPlayer> mp = getMediaPlayer(env, thiz);
294 sp<IGraphicBufferProducer> old_st = getVideoSurfaceTexture(env, thiz);
301 setVideoSurface(JNIEnv *env, jobject thiz, jobject jsurface, jboolean mediaPlayerMustBeAlive)
303 sp<MediaPlayer> mp = getMediaPlayer(env, thiz);
306 jniThrowException(env, "java/lang/IllegalStateException", NULL);
311 decVideoSurfaceRef(env, thiz);
315 sp<Surface> surface(android_view_Surface_getSurface(env, jsurface));
319 jniThrowException(env, "java/lang/IllegalArgumentException",
325 jniThrowException(env, "java/lang/IllegalArgumentException",
331 env->SetLongField(thiz, fields.surface_texture, (jlong)new_st.get());
341 android_media_MediaPlayer_setVideoSurface(JNIEnv *env, jobject thiz, jobject jsurface)
343 setVideoSurface(env, thiz, jsurface, true /* mediaPlayerMustBeAlive */);
347 android_media_MediaPlayer_prepare(JNIEnv *env, jobject thiz)
349 sp<MediaPlayer> mp = getMediaPlayer(env, thiz);
351 jniThrowException(env, "java/lang/IllegalStateException", NULL);
357 sp<IGraphicBufferProducer> st = getVideoSurfaceTexture(env, thiz);
360 process_media_player_call( env, thiz, mp->prepare(), "java/io/IOException", "Prepare failed." );
364 android_media_MediaPlayer_prepareAsync(JNIEnv *env, jobject thiz)
366 sp<MediaPlayer> mp = getMediaPlayer(env, thiz);
368 jniThrowException(env, "java/lang/IllegalStateException", NULL);
374 sp<IGraphicBufferProducer> st = getVideoSurfaceTexture(env, thiz);
377 process_media_player_call( env, thiz, mp->prepareAsync(), "java/io/IOException", "Prepare Async failed." );
381 android_media_MediaPlayer_start(JNIEnv *env, jobject thiz)
384 sp<MediaPlayer> mp = getMediaPlayer(env, thiz);
386 jniThrowException(env, "java/lang/IllegalStateException", NULL);
389 process_media_player_call( env, thiz, mp->start(), NULL, NULL );
393 android_media_MediaPlayer_stop(JNIEnv *env, jobject thiz)
396 sp<MediaPlayer> mp = getMediaPlayer(env, thiz);
398 jniThrowException(env, "java/lang/IllegalStateException", NULL);
401 process_media_player_call( env, thiz, mp->stop(), NULL, NULL );
405 android_media_MediaPlayer_pause(JNIEnv *env, jobject thiz)
408 sp<MediaPlayer> mp = getMediaPlayer(env, thiz);
410 jniThrowException(env, "java/lang/IllegalStateException", NULL);
413 process_media_player_call( env, thiz, mp->pause(), NULL, NULL );
417 android_media_MediaPlayer_isPlaying(JNIEnv *env, jobject thiz)
419 sp<MediaPlayer> mp = getMediaPlayer(env, thiz);
421 jniThrowException(env, "java/lang/IllegalStateException", NULL);
431 android_media_MediaPlayer_setPlaybackParams(JNIEnv *env, jobject thiz, jobject params)
433 sp<MediaPlayer> mp = getMediaPlayer(env, thiz);
435 jniThrowException(env, "java/lang/IllegalStateException", NULL);
440 pbp.fillFromJobject(env, gPlaybackParamsFields, params);
472 env, thiz, err,
477 android_media_MediaPlayer_getPlaybackParams(JNIEnv *env, jobject thiz)
479 sp<MediaPlayer> mp = getMediaPlayer(env, thiz);
481 jniThrowException(env, "java/lang/IllegalStateException", NULL);
488 env, thiz, mp->getPlaybackSettings(&audioRate),
498 return pbp.asJobject(env, gPlaybackParamsFields);
502 android_media_MediaPlayer_setSyncParams(JNIEnv *env, jobject thiz, jobject params)
504 sp<MediaPlayer> mp = getMediaPlayer(env, thiz);
506 jniThrowException(env, "java/lang/IllegalStateException", NULL);
511 scp.fillFromJobject(env, gSyncParamsFields, params);
540 env, thiz, err,
545 android_media_MediaPlayer_getSyncParams(JNIEnv *env, jobject thiz)
547 sp<MediaPlayer> mp = getMediaPlayer(env, thiz);
549 jniThrowException(env, "java/lang/IllegalStateException", NULL);
556 env, thiz, mp->getSyncSettings(&scp.sync, &scp.frameRate),
567 jniThrowException(env, "java/lang/IllegalStateException", NULL);
576 return scp.asJobject(env, gSyncParamsFields);
580 android_media_MediaPlayer_seekTo(JNIEnv *env, jobject thiz, jint msec)
582 sp<MediaPlayer> mp = getMediaPlayer(env, thiz);
584 jniThrowException(env, "java/lang/IllegalStateException", NULL);
588 process_media_player_call( env, thiz, mp->seekTo(msec), NULL, NULL );
592 android_media_MediaPlayer_getVideoWidth(JNIEnv *env, jobject thiz)
594 sp<MediaPlayer> mp = getMediaPlayer(env, thiz);
596 jniThrowException(env, "java/lang/IllegalStateException", NULL);
609 android_media_MediaPlayer_getVideoHeight(JNIEnv *env, jobject thiz)
611 sp<MediaPlayer> mp = getMediaPlayer(env, thiz);
613 jniThrowException(env, "java/lang/IllegalStateException", NULL);
627 android_media_MediaPlayer_getCurrentPosition(JNIEnv *env, jobject thiz)
629 sp<MediaPlayer> mp = getMediaPlayer(env, thiz);
631 jniThrowException(env, "java/lang/IllegalStateException", NULL);
635 process_media_player_call( env, thiz, mp->getCurrentPosition(&msec), NULL, NULL );
641 android_media_MediaPlayer_getDuration(JNIEnv *env, jobject thiz)
643 sp<MediaPlayer> mp = getMediaPlayer(env, thiz);
645 jniThrowException(env, "java/lang/IllegalStateException", NULL);
649 process_media_player_call( env, thiz, mp->getDuration(&msec), NULL, NULL );
655 android_media_MediaPlayer_reset(JNIEnv *env, jobject thiz)
658 sp<MediaPlayer> mp = getMediaPlayer(env, thiz);
660 jniThrowException(env, "java/lang/IllegalStateException", NULL);
663 process_media_player_call( env, thiz, mp->reset(), NULL, NULL );
667 android_media_MediaPlayer_setAudioStreamType(JNIEnv *env, jobject thiz, jint streamtype)
670 sp<MediaPlayer> mp = getMediaPlayer(env, thiz);
672 jniThrowException(env, "java/lang/IllegalStateException", NULL);
675 process_media_player_call( env, thiz, mp->setAudioStreamType((audio_stream_type_t) streamtype) , NULL, NULL );
679 android_media_MediaPlayer_getAudioStreamType(JNIEnv *env, jobject thiz)
681 sp<MediaPlayer> mp = getMediaPlayer(env, thiz);
683 jniThrowException(env, "java/lang/IllegalStateException", NULL);
687 process_media_player_call( env, thiz, mp->getAudioStreamType(&streamtype), NULL, NULL );
693 android_media_MediaPlayer_setParameter(JNIEnv *env, jobject thiz, jint key, jobject java_request)
696 sp<MediaPlayer> mp = getMediaPlayer(env, thiz);
698 jniThrowException(env, "java/lang/IllegalStateException", NULL);
702 Parcel *request = parcelForJavaObject(env, java_request);
712 android_media_MediaPlayer_setLooping(JNIEnv *env, jobject thiz, jboolean looping)
715 sp<MediaPlayer> mp = getMediaPlayer(env, thiz);
717 jniThrowException(env, "java/lang/IllegalStateException", NULL);
720 process_media_player_call( env, thiz, mp->setLooping(looping), NULL, NULL );
724 android_media_MediaPlayer_isLooping(JNIEnv *env, jobject thiz)
727 sp<MediaPlayer> mp = getMediaPlayer(env, thiz);
729 jniThrowException(env, "java/lang/IllegalStateException", NULL);
736 android_media_MediaPlayer_setVolume(JNIEnv *env, jobject thiz, jfloat leftVolume, jfloat rightVolume)
739 sp<MediaPlayer> mp = getMediaPlayer(env, thiz);
741 jniThrowException(env, "java/lang/IllegalStateException", NULL);
744 process_media_player_call( env, thiz, mp->setVolume((float) leftVolume, (float) rightVolume), NULL, NULL );
750 android_media_MediaPlayer_invoke(JNIEnv *env, jobject thiz,
753 sp<MediaPlayer> media_player = getMediaPlayer(env, thiz);
755 jniThrowException(env, "java/lang/IllegalStateException", NULL);
759 Parcel *request = parcelForJavaObject(env, java_request);
760 Parcel *reply = parcelForJavaObject(env, java_reply);
769 android_media_MediaPlayer_setMetadataFilter(JNIEnv *env, jobject thiz, jobject request)
771 sp<MediaPlayer> media_player = getMediaPlayer(env, thiz);
773 jniThrowException(env, "java/lang/IllegalStateException", NULL);
777 Parcel *filter = parcelForJavaObject(env, request);
780 jniThrowException(env, "java/lang/RuntimeException", "Filter is null");
788 android_media_MediaPlayer_getMetadata(JNIEnv *env, jobject thiz, jboolean update_only,
791 sp<MediaPlayer> media_player = getMediaPlayer(env, thiz);
793 jniThrowException(env, "java/lang/IllegalStateException", NULL);
797 Parcel *metadata = parcelForJavaObject(env, reply);
800 jniThrowException(env, "java/lang/RuntimeException", "Reply parcel is null");
820 android_media_MediaPlayer_native_init(JNIEnv *env)
824 clazz = env->FindClass("android/media/MediaPlayer");
829 fields.context = env->GetFieldID(clazz, "mNativeContext", "J");
834 fields.post_event = env->GetStaticMethodID(clazz, "postEventFromNative",
840 fields.surface_texture = env->GetFieldID(clazz, "mNativeSurfaceTexture", "J");
845 env->DeleteLocalRef(clazz);
847 clazz = env->FindClass("android/net/ProxyInfo");
853 env->GetMethodID(clazz, "getHost", "()Ljava/lang/String;");
856 env->GetMethodID(clazz, "getPort", "()I");
859 env->GetMethodID(clazz, "getExclusionListAsString", "()Ljava/lang/String;");
861 env->DeleteLocalRef(clazz);
863 gPlaybackParamsFields.init(env);
864 gSyncParamsFields.init(env);
868 android_media_MediaPlayer_native_setup(JNIEnv *env, jobject thiz, jobject weak_this)
873 jniThrowException(env, "java/lang/RuntimeException", "Out of memory");
878 sp<JNIMediaPlayerListener> listener = new JNIMediaPlayerListener(env, thiz, weak_this);
882 setMediaPlayer(env, thiz, mp);
886 android_media_MediaPlayer_release(JNIEnv *env, jobject thiz)
889 decVideoSurfaceRef(env, thiz);
890 sp<MediaPlayer> mp = setMediaPlayer(env, thiz, 0);
899 android_media_MediaPlayer_native_finalize(JNIEnv *env, jobject thiz)
902 sp<MediaPlayer> mp = getMediaPlayer(env, thiz);
906 android_media_MediaPlayer_release(env, thiz);
909 static void android_media_MediaPlayer_set_audio_session_id(JNIEnv *env, jobject thiz,
912 sp<MediaPlayer> mp = getMediaPlayer(env, thiz);
914 jniThrowException(env, "java/lang/IllegalStateException", NULL);
917 process_media_player_call( env, thiz, mp->setAudioSessionId((audio_session_t) sessionId), NULL,
921 static jint android_media_MediaPlayer_get_audio_session_id(JNIEnv *env, jobject thiz) {
923 sp<MediaPlayer> mp = getMediaPlayer(env, thiz);
925 jniThrowException(env, "java/lang/IllegalStateException", NULL);
933 android_media_MediaPlayer_setAuxEffectSendLevel(JNIEnv *env, jobject thiz, jfloat level)
936 sp<MediaPlayer> mp = getMediaPlayer(env, thiz);
938 jniThrowException(env, "java/lang/IllegalStateException", NULL);
941 process_media_player_call( env, thiz, mp->setAuxEffectSendLevel(level), NULL, NULL );
944 static void android_media_MediaPlayer_attachAuxEffect(JNIEnv *env, jobject thiz, jint effectId) {
946 sp<MediaPlayer> mp = getMediaPlayer(env, thiz);
948 jniThrowException(env, "java/lang/IllegalStateException", NULL);
951 process_media_player_call( env, thiz, mp->attachAuxEffect(effectId), NULL, NULL );
956 JNIEnv *env, jobject /* thiz */, jobject java_reply)
961 jniThrowException(env, "java/lang/RuntimeException", "cannot get MediaPlayerService");
965 Parcel *reply = parcelForJavaObject(env, java_reply);
971 android_media_MediaPlayer_setRetransmitEndpoint(JNIEnv *env, jobject thiz,
973 sp<MediaPlayer> mp = getMediaPlayer(env, thiz);
975 jniThrowException(env, "java/lang/IllegalStateException", NULL);
982 cAddrString = env->GetStringUTFChars(addrString, NULL);
999 env->ReleaseStringUTFChars(addrString, cAddrString);
1003 jniThrowException(env, "java/lang/IllegalStateException", NULL);
1010 android_media_MediaPlayer_setNextMediaPlayer(JNIEnv *env, jobject thiz, jobject java_player)
1013 sp<MediaPlayer> thisplayer = getMediaPlayer(env, thiz);
1015 jniThrowException(env, "java/lang/IllegalStateException", "This player not initialized");
1018 sp<MediaPlayer> nextplayer = (java_player == NULL) ? NULL : getMediaPlayer(env, java_player);
1020 jniThrowException(env, "java/lang/IllegalStateException", "That player not initialized");
1025 jniThrowException(env, "java/lang/IllegalArgumentException", "Next player can't be self");
1030 env, thiz, thisplayer->setNextMediaPlayer(nextplayer),
1088 static int register_android_media_MediaPlayer(JNIEnv *env)
1090 return AndroidRuntime::registerNativeMethods(env,
1093 extern int register_android_media_ExifInterface(JNIEnv *env);
1094 extern int register_android_media_ImageReader(JNIEnv *env);
1095 extern int register_android_media_ImageWriter(JNIEnv *env);
1096 extern int register_android_media_Crypto(JNIEnv *env);
1097 extern int register_android_media_Drm(JNIEnv *env);
1098 extern int register_android_media_MediaCodec(JNIEnv *env);
1099 extern int register_android_media_MediaExtractor(JNIEnv *env);
1100 extern int register_android_media_MediaCodecList(JNIEnv *env);
1101 extern int register_android_media_MediaHTTPConnection(JNIEnv *env);
1102 extern int register_android_media_MediaMetadataRetriever(JNIEnv *env);
1103 extern int register_android_media_MediaMuxer(JNIEnv *env);
1104 extern int register_android_media_MediaRecorder(JNIEnv *env);
1105 extern int register_android_media_MediaScanner(JNIEnv *env);
1106 extern int register_android_media_MediaSync(JNIEnv *env);
1107 extern int register_android_media_ResampleInputStream(JNIEnv *env);
1108 extern int register_android_media_MediaProfiles(JNIEnv *env);
1109 extern int register_android_media_AmrInputStream(JNIEnv *env);
1110 extern int register_android_mtp_MtpDatabase(JNIEnv *env);
1111 extern int register_android_mtp_MtpDevice(JNIEnv *env);
1112 extern int register_android_mtp_MtpServer(JNIEnv *env);
1116 JNIEnv* env = NULL;
1119 if (vm->GetEnv((void**) &env, JNI_VERSION_1_4) != JNI_OK) {
1123 assert(env != NULL);
1125 if (register_android_media_ImageWriter(env) != JNI_OK) {
1130 if (register_android_media_ImageReader(env) < 0) {
1135 if (register_android_media_MediaPlayer(env) < 0) {
1140 if (register_android_media_MediaRecorder(env) < 0) {
1145 if (register_android_media_MediaScanner(env) < 0) {
1150 if (register_android_media_MediaMetadataRetriever(env) < 0) {
1155 if (register_android_media_AmrInputStream(env) < 0) {
1160 if (register_android_media_ResampleInputStream(env) < 0) {
1165 if (register_android_media_MediaProfiles(env) < 0) {
1170 if (register_android_mtp_MtpDatabase(env) < 0) {
1175 if (register_android_mtp_MtpDevice(env) < 0) {
1180 if (register_android_mtp_MtpServer(env) < 0) {
1185 if (register_android_media_MediaCodec(env) < 0) {
1190 if (register_android_media_MediaSync(env) < 0) {
1195 if (register_android_media_MediaExtractor(env) < 0) {
1200 if (register_android_media_MediaMuxer(env) < 0) {
1205 if (register_android_media_MediaCodecList(env) < 0) {
1210 if (register_android_media_Crypto(env) < 0) {
1215 if (register_android_media_Drm(env) < 0) {
1220 if (register_android_media_MediaHTTPConnection(env) < 0) {
1225 if (register_android_media_ExifInterface(env) < 0) {