diff options
author | Jamie Gennis <jgennis@google.com> | 2010-12-20 11:51:31 -0800 |
---|---|---|
committer | Jamie Gennis <jgennis@google.com> | 2011-01-06 13:31:53 -0800 |
commit | bfa33aae4f54c0020a0568b16a3acb7b30b6ca3d (patch) | |
tree | 3dae4190516dcddec996a2b7c51b5f192c3ed4ca /camera | |
parent | 5de2001a5c3f854b63dbcea284e02f930881ca75 (diff) | |
download | frameworks_av-bfa33aae4f54c0020a0568b16a3acb7b30b6ca3d.zip frameworks_av-bfa33aae4f54c0020a0568b16a3acb7b30b6ca3d.tar.gz frameworks_av-bfa33aae4f54c0020a0568b16a3acb7b30b6ca3d.tar.bz2 |
Add camera service support for SurfaceTexture.
This change enables the use of a SurfaceTexture in place of a Surface as
the destination of camera preview frames.
Change-Id: Ic70d404c8fe261e9d5da6f1de93d6babb5b191cb
Diffstat (limited to 'camera')
-rw-r--r-- | camera/Android.mk | 3 | ||||
-rw-r--r-- | camera/Camera.cpp | 14 | ||||
-rw-r--r-- | camera/ICamera.cpp | 20 |
3 files changed, 36 insertions, 1 deletions
diff --git a/camera/Android.mk b/camera/Android.mk index 03ff229..2f16923 100644 --- a/camera/Android.mk +++ b/camera/Android.mk @@ -14,7 +14,8 @@ LOCAL_SHARED_LIBRARIES := \ libbinder \ libhardware \ libsurfaceflinger_client \ - libui + libui \ + libgui LOCAL_MODULE:= libcamera_client diff --git a/camera/Camera.cpp b/camera/Camera.cpp index ab626ad..907f119 100644 --- a/camera/Camera.cpp +++ b/camera/Camera.cpp @@ -182,6 +182,20 @@ status_t Camera::setPreviewDisplay(const sp<Surface>& surface) } } +// pass the buffered ISurfaceTexture to the camera service +status_t Camera::setPreviewTexture(const sp<ISurfaceTexture>& surfaceTexture) +{ + LOGV("setPreviewTexture(%p)", surfaceTexture.get()); + sp <ICamera> c = mCamera; + if (c == 0) return NO_INIT; + if (surfaceTexture != 0) { + return c->setPreviewTexture(surfaceTexture); + } else { + LOGD("app passed NULL surface"); + return c->setPreviewTexture(0); + } +} + // start preview mode status_t Camera::startPreview() { diff --git a/camera/ICamera.cpp b/camera/ICamera.cpp index 7ba8d12..0881d65 100644 --- a/camera/ICamera.cpp +++ b/camera/ICamera.cpp @@ -28,6 +28,7 @@ namespace android { enum { DISCONNECT = IBinder::FIRST_CALL_TRANSACTION, SET_PREVIEW_DISPLAY, + SET_PREVIEW_TEXTURE, SET_PREVIEW_CALLBACK_FLAG, START_PREVIEW, STOP_PREVIEW, @@ -78,6 +79,18 @@ public: return reply.readInt32(); } + // pass the buffered SurfaceTexture to the camera service + status_t setPreviewTexture(const sp<ISurfaceTexture>& surfaceTexture) + { + LOGV("setPreviewTexture"); + Parcel data, reply; + data.writeInterfaceToken(ICamera::getInterfaceDescriptor()); + sp<IBinder> b(surfaceTexture->asBinder()); + data.writeStrongBinder(b); + remote()->transact(SET_PREVIEW_TEXTURE, data, &reply); + return reply.readInt32(); + } + // set the preview callback flag to affect how the received frames from // preview are handled. See Camera.h for details. void setPreviewCallbackFlag(int flag) @@ -296,6 +309,13 @@ status_t BnCamera::onTransact( reply->writeInt32(setPreviewDisplay(surface)); return NO_ERROR; } break; + case SET_PREVIEW_TEXTURE: { + LOGV("SET_PREVIEW_TEXTURE"); + CHECK_INTERFACE(ICamera, data, reply); + sp<ISurfaceTexture> st = interface_cast<ISurfaceTexture>(data.readStrongBinder()); + reply->writeInt32(setPreviewTexture(st)); + return NO_ERROR; + } break; case SET_PREVIEW_CALLBACK_FLAG: { LOGV("SET_PREVIEW_CALLBACK_TYPE"); CHECK_INTERFACE(ICamera, data, reply); |