Merge change 2716 into donut
* changes: Update MediaPlayer to allow setVideoSurface calls after prepare. Also allow passing a null surface. The API is now enabled to change the surface while the video is playing. This could allow orientation changes during playback or to allow the audio track from a video to play in the background. NOTE: There are still changes required to pmem driver to allow remapping shared physical memory into a process in order for this to work. This change only enables the API to send the appropriate calls when the lower level code supports it.
This commit is contained in:
@@ -468,6 +468,11 @@ public class MediaPlayer
|
|||||||
*/
|
*/
|
||||||
native_setup(new WeakReference<MediaPlayer>(this));
|
native_setup(new WeakReference<MediaPlayer>(this));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Update the MediaPlayer ISurface. Call after updating mSurface.
|
||||||
|
*/
|
||||||
|
private native void _setVideoSurface();
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Sets the SurfaceHolder to use for displaying the video portion of the media.
|
* Sets the SurfaceHolder to use for displaying the video portion of the media.
|
||||||
@@ -478,7 +483,12 @@ public class MediaPlayer
|
|||||||
*/
|
*/
|
||||||
public void setDisplay(SurfaceHolder sh) {
|
public void setDisplay(SurfaceHolder sh) {
|
||||||
mSurfaceHolder = sh;
|
mSurfaceHolder = sh;
|
||||||
mSurface = sh.getSurface();
|
if (sh != null) {
|
||||||
|
mSurface = sh.getSurface();
|
||||||
|
} else {
|
||||||
|
mSurface = null;
|
||||||
|
}
|
||||||
|
_setVideoSurface();
|
||||||
updateSurfaceScreenOn();
|
updateSurfaceScreenOn();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -198,6 +198,27 @@ android_media_MediaPlayer_setDataSourceFD(JNIEnv *env, jobject thiz, jobject fil
|
|||||||
process_media_player_call( env, thiz, mp->setDataSource(fd, offset, length), "java/io/IOException", "setDataSourceFD failed." );
|
process_media_player_call( env, thiz, mp->setDataSource(fd, offset, length), "java/io/IOException", "setDataSourceFD failed." );
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static void setVideoSurface(const sp<MediaPlayer>& mp, JNIEnv *env, jobject thiz)
|
||||||
|
{
|
||||||
|
jobject surface = env->GetObjectField(thiz, fields.surface);
|
||||||
|
if (surface != NULL) {
|
||||||
|
const sp<Surface>& native_surface = get_surface(env, surface);
|
||||||
|
LOGV("prepare: surface=%p (id=%d)",
|
||||||
|
native_surface.get(), native_surface->ID());
|
||||||
|
mp->setVideoSurface(native_surface);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
static void
|
||||||
|
android_media_MediaPlayer_setVideoSurface(JNIEnv *env, jobject thiz)
|
||||||
|
{
|
||||||
|
sp<MediaPlayer> mp = getMediaPlayer(env, thiz);
|
||||||
|
if (mp == NULL ) {
|
||||||
|
jniThrowException(env, "java/lang/IllegalStateException", NULL);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
setVideoSurface(mp, env, thiz);
|
||||||
|
}
|
||||||
|
|
||||||
static void
|
static void
|
||||||
android_media_MediaPlayer_prepare(JNIEnv *env, jobject thiz)
|
android_media_MediaPlayer_prepare(JNIEnv *env, jobject thiz)
|
||||||
@@ -207,13 +228,7 @@ android_media_MediaPlayer_prepare(JNIEnv *env, jobject thiz)
|
|||||||
jniThrowException(env, "java/lang/IllegalStateException", NULL);
|
jniThrowException(env, "java/lang/IllegalStateException", NULL);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
jobject surface = env->GetObjectField(thiz, fields.surface);
|
setVideoSurface(mp, env, thiz);
|
||||||
if (surface != NULL) {
|
|
||||||
const sp<Surface>& native_surface = get_surface(env, surface);
|
|
||||||
LOGV("prepare: surface=%p (id=%d)",
|
|
||||||
native_surface.get(), native_surface->ID());
|
|
||||||
mp->setVideoSurface(native_surface);
|
|
||||||
}
|
|
||||||
process_media_player_call( env, thiz, mp->prepare(), "java/io/IOException", "Prepare failed." );
|
process_media_player_call( env, thiz, mp->prepare(), "java/io/IOException", "Prepare failed." );
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -469,6 +484,7 @@ android_media_MediaPlayer_native_finalize(JNIEnv *env, jobject thiz)
|
|||||||
static JNINativeMethod gMethods[] = {
|
static JNINativeMethod gMethods[] = {
|
||||||
{"setDataSource", "(Ljava/lang/String;)V", (void *)android_media_MediaPlayer_setDataSource},
|
{"setDataSource", "(Ljava/lang/String;)V", (void *)android_media_MediaPlayer_setDataSource},
|
||||||
{"setDataSource", "(Ljava/io/FileDescriptor;JJ)V", (void *)android_media_MediaPlayer_setDataSourceFD},
|
{"setDataSource", "(Ljava/io/FileDescriptor;JJ)V", (void *)android_media_MediaPlayer_setDataSourceFD},
|
||||||
|
{"_setVideoSurface", "()V", (void *)android_media_MediaPlayer_setVideoSurface},
|
||||||
{"prepare", "()V", (void *)android_media_MediaPlayer_prepare},
|
{"prepare", "()V", (void *)android_media_MediaPlayer_prepare},
|
||||||
{"prepareAsync", "()V", (void *)android_media_MediaPlayer_prepareAsync},
|
{"prepareAsync", "()V", (void *)android_media_MediaPlayer_prepareAsync},
|
||||||
{"_start", "()V", (void *)android_media_MediaPlayer_start},
|
{"_start", "()V", (void *)android_media_MediaPlayer_start},
|
||||||
|
|||||||
Reference in New Issue
Block a user