diff options
author | Glenn Kasten <gkasten@google.com> | 2011-02-08 17:26:17 -0800 |
---|---|---|
committer | Glenn Kasten <gkasten@google.com> | 2011-02-23 15:02:56 -0800 |
commit | 1173118eace0e9e347cb007f0da817cee87579ed (patch) | |
tree | d2d23b2120010097d1edda29cd0adffd938105c3 /media/libmedia | |
parent | f7f3e824a8cb2b38355db8e4f99e43b90ee71ce4 (diff) | |
download | frameworks_av-1173118eace0e9e347cb007f0da817cee87579ed.zip frameworks_av-1173118eace0e9e347cb007f0da817cee87579ed.tar.gz frameworks_av-1173118eace0e9e347cb007f0da817cee87579ed.tar.bz2 |
Bug 3438258 Add SurfaceTexture as MediaPlayer sink
This change enables the use of a SurfaceTexture in place of a Surface
as the video sink for an android.media.MediaPlayer. The new API
MediaPlayer.setTexture is currently hidden.
This includes:
- New Java and C++ interfaces
- C++ plumbing and implementation (JNI, Binder)
- Stagefright AwesomePlayer and NuPlayer use ANativeWindow
(either Surface or SurfaceTextureClient)
Change-Id: I2b568bee143d9eaf3dfc6cc4533c1bebbd5afc51
Diffstat (limited to 'media/libmedia')
-rw-r--r-- | media/libmedia/Android.mk | 3 | ||||
-rw-r--r-- | media/libmedia/IMediaPlayer.cpp | 24 | ||||
-rw-r--r-- | media/libmedia/mediaplayer.cpp | 10 |
3 files changed, 35 insertions, 2 deletions
diff --git a/media/libmedia/Android.mk b/media/libmedia/Android.mk index 74fb531..fd4c6c6 100644 --- a/media/libmedia/Android.mk +++ b/media/libmedia/Android.mk @@ -37,7 +37,8 @@ LOCAL_SRC_FILES:= \ LOCAL_SHARED_LIBRARIES := \ libui libcutils libutils libbinder libsonivox libicuuc libexpat \ - libsurfaceflinger_client libcamera_client libstagefright_foundation + libsurfaceflinger_client libcamera_client libstagefright_foundation \ + libgui LOCAL_MODULE:= libmedia diff --git a/media/libmedia/IMediaPlayer.cpp b/media/libmedia/IMediaPlayer.cpp index c287c0a..2399216 100644 --- a/media/libmedia/IMediaPlayer.cpp +++ b/media/libmedia/IMediaPlayer.cpp @@ -23,6 +23,7 @@ #include <media/IMediaPlayer.h> #include <surfaceflinger/ISurface.h> #include <surfaceflinger/Surface.h> +#include <gui/ISurfaceTexture.h> namespace android { @@ -45,7 +46,8 @@ enum { SET_METADATA_FILTER, GET_METADATA, SET_AUX_EFFECT_SEND_LEVEL, - ATTACH_AUX_EFFECT + ATTACH_AUX_EFFECT, + SET_VIDEO_SURFACETEXTURE, }; class BpMediaPlayer: public BpInterface<IMediaPlayer> @@ -64,6 +66,7 @@ public: remote()->transact(DISCONNECT, data, &reply); } + // pass the buffered Surface to the media player service status_t setVideoSurface(const sp<Surface>& surface) { Parcel data, reply; @@ -73,6 +76,17 @@ public: return reply.readInt32(); } + // pass the buffered ISurfaceTexture to the media player service + status_t setVideoSurfaceTexture(const sp<ISurfaceTexture>& surfaceTexture) + { + Parcel data, reply; + data.writeInterfaceToken(IMediaPlayer::getInterfaceDescriptor()); + sp<IBinder> b(surfaceTexture->asBinder()); + data.writeStrongBinder(b); + remote()->transact(SET_VIDEO_SURFACETEXTURE, data, &reply); + return reply.readInt32(); + } + status_t prepareAsync() { Parcel data, reply; @@ -220,6 +234,7 @@ public: remote()->transact(ATTACH_AUX_EFFECT, data, &reply); return reply.readInt32(); } + }; IMPLEMENT_META_INTERFACE(MediaPlayer, "android.media.IMediaPlayer"); @@ -241,6 +256,13 @@ status_t BnMediaPlayer::onTransact( reply->writeInt32(setVideoSurface(surface)); return NO_ERROR; } break; + case SET_VIDEO_SURFACETEXTURE: { + CHECK_INTERFACE(IMediaPlayer, data, reply); + sp<ISurfaceTexture> surfaceTexture = + interface_cast<ISurfaceTexture>(data.readStrongBinder()); + reply->writeInt32(setVideoSurfaceTexture(surfaceTexture)); + return NO_ERROR; + } break; case PREPARE_ASYNC: { CHECK_INTERFACE(IMediaPlayer, data, reply); reply->writeInt32(prepareAsync()); diff --git a/media/libmedia/mediaplayer.cpp b/media/libmedia/mediaplayer.cpp index 87c8fe4..0ee0249 100644 --- a/media/libmedia/mediaplayer.cpp +++ b/media/libmedia/mediaplayer.cpp @@ -201,6 +201,16 @@ status_t MediaPlayer::setVideoSurface(const sp<Surface>& surface) return mPlayer->setVideoSurface(surface); } +status_t MediaPlayer::setVideoSurfaceTexture( + const sp<ISurfaceTexture>& surfaceTexture) +{ + LOGV("setVideoSurfaceTexture"); + Mutex::Autolock _l(mLock); + if (mPlayer == 0) return NO_INIT; + + return mPlayer->setVideoSurfaceTexture(surfaceTexture); +} + // must call with lock held status_t MediaPlayer::prepareAsync_l() { |