Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 93aa950b authored by Jamie Gennis's avatar Jamie Gennis Committed by Android (Google) Code Review
Browse files

Merge "Add camera service support for SurfaceTexture." into honeycomb

parents b1787e3b bfa33aae
Loading
Loading
Loading
Loading
+2 −1
Original line number Diff line number Diff line
@@ -14,7 +14,8 @@ LOCAL_SHARED_LIBRARIES := \
	libbinder \
	libhardware \
	libsurfaceflinger_client \
	libui
	libui \
	libgui

LOCAL_MODULE:= libcamera_client

+14 −0
Original line number Diff line number Diff line
@@ -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()
{
+20 −0
Original line number Diff line number Diff line
@@ -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);
+4 −0
Original line number Diff line number Diff line
@@ -19,6 +19,7 @@

#include <utils/Timers.h>
#include <camera/ICameraClient.h>
#include <gui/ISurfaceTexture.h>

namespace android {

@@ -175,6 +176,9 @@ public:
            // pass the buffered Surface to the camera service
            status_t    setPreviewDisplay(const sp<Surface>& surface);

            // pass the buffered ISurfaceTexture to the camera service
            status_t    setPreviewTexture(const sp<ISurfaceTexture>& surfaceTexture);

            // start preview mode, must call setPreviewDisplay first
            status_t    startPreview();

+5 −0
Original line number Diff line number Diff line
@@ -24,6 +24,7 @@
#include <binder/IMemory.h>
#include <utils/String8.h>
#include <camera/Camera.h>
#include <gui/ISurfaceTexture.h>

namespace android {

@@ -48,6 +49,10 @@ public:
    // pass the buffered Surface to the camera service
    virtual status_t        setPreviewDisplay(const sp<Surface>& surface) = 0;

    // pass the buffered ISurfaceTexture to the camera service
    virtual status_t        setPreviewTexture(
            const sp<ISurfaceTexture>& surfaceTexture) = 0;

    // set the preview callback flag to affect how the received frames from
    // preview are handled.
    virtual void            setPreviewCallbackFlag(int flag) = 0;
Loading