diff options
author | Steve Kondik <shade@chemlab.org> | 2010-11-10 18:01:52 -0500 |
---|---|---|
committer | cyanogen <shade@chemlab.org> | 2010-11-11 21:56:56 -0500 |
commit | 39215374a2b700082776d2cd64299f66c0ca68fc (patch) | |
tree | dfc731c513b72758925dfa11403658d91072290a | |
parent | 7f03aa879931b65ab452d36f97c539a550014d86 (diff) | |
download | frameworks_base-39215374a2b700082776d2cd64299f66c0ca68fc.zip frameworks_base-39215374a2b700082776d2cd64299f66c0ca68fc.tar.gz frameworks_base-39215374a2b700082776d2cd64299f66c0ca68fc.tar.bz2 |
Camera: Add support for getBufferInfo API
Reworked to avoid ABI breakage.
This reverts commit b5d9f64973f06b45423b2216050aa0d2d2513f96.
Change-Id: I602faec8e85d80a30dadceed8c7942dc133989b8
-rw-r--r-- | camera/libcameraservice/CameraHardwareStub.cpp | 9 | ||||
-rw-r--r-- | camera/libcameraservice/CameraHardwareStub.h | 3 | ||||
-rw-r--r--[-rwxr-xr-x] | camera/libcameraservice/CameraService.cpp | 15 | ||||
-rw-r--r-- | camera/libcameraservice/CameraService.h | 5 | ||||
-rw-r--r-- | include/camera/Camera.h | 5 | ||||
-rw-r--r-- | include/camera/CameraHardwareInterface.h | 9 | ||||
-rw-r--r-- | include/camera/ICamera.h | 6 | ||||
-rw-r--r-- | libs/camera/Camera.cpp | 11 | ||||
-rw-r--r-- | libs/camera/ICamera.cpp | 27 |
9 files changed, 87 insertions, 3 deletions
diff --git a/camera/libcameraservice/CameraHardwareStub.cpp b/camera/libcameraservice/CameraHardwareStub.cpp index 8b66389..db4f31a 100644 --- a/camera/libcameraservice/CameraHardwareStub.cpp +++ b/camera/libcameraservice/CameraHardwareStub.cpp @@ -1,6 +1,7 @@ /* ** ** Copyright 2008, The Android Open Source Project +** Copyright (C) 2010, Code Aurora Forum. All rights reserved. ** ** Licensed under the Apache License, Version 2.0 (the "License"); ** you may not use this file except in compliance with the License. @@ -399,4 +400,12 @@ extern "C" sp<CameraHardwareInterface> openCameraHardware() return CameraHardwareStub::createInstance(); } +status_t CameraHardwareStub::getBufferInfo(sp<IMemory>& Frame, size_t *alignedSize) { + /* No Support for this API in STUB Camera. Just return NULL */ + Frame = NULL; + if( alignedSize != NULL) + *alignedSize = 0; + + return UNKNOWN_ERROR; +} }; // namespace android diff --git a/camera/libcameraservice/CameraHardwareStub.h b/camera/libcameraservice/CameraHardwareStub.h index 957813a4..5794d5a 100644 --- a/camera/libcameraservice/CameraHardwareStub.h +++ b/camera/libcameraservice/CameraHardwareStub.h @@ -1,6 +1,7 @@ /* ** ** Copyright 2008, The Android Open Source Project +** Copyright (C) 2010, Code Aurora Forum. All rights reserved. ** ** Licensed under the Apache License, Version 2.0 (the "License"); ** you may not use this file except in compliance with the License. @@ -59,6 +60,8 @@ public: virtual CameraParameters getParameters() const; virtual status_t sendCommand(int32_t command, int32_t arg1, int32_t arg2); + virtual status_t getBufferInfo( sp<IMemory>& Frame, size_t *alignedSize); + virtual void release(); static sp<CameraHardwareInterface> createInstance(); diff --git a/camera/libcameraservice/CameraService.cpp b/camera/libcameraservice/CameraService.cpp index 3cb3ce5..d74a1dd 100755..100644 --- a/camera/libcameraservice/CameraService.cpp +++ b/camera/libcameraservice/CameraService.cpp @@ -1,6 +1,8 @@ /* ** ** Copyright (C) 2008, The Android Open Source Project +** Copyright (C) 2008 HTC Inc. +** Copyright (C) 2010, Code Aurora Forum. All rights reserved. ** ** Licensed under the Apache License, Version 2.0 (the "License"); ** you may not use this file except in compliance with the License. @@ -598,7 +600,7 @@ status_t CameraService::Client::setOverlay() // Surfaceflinger may hold onto the previous overlay reference for some // time after we try to destroy it. retry a few times. In the future, we // should make the destroy call block, or possibly specify that we can - // wait in the createOverlay call if the previous overlay is in the + // wait in the createOverlay call if the previous overlay is in the // process of being destroyed. for (int retry = 0; retry < 50; ++retry) { mOverlayRef = mSurface->createOverlay(w, h, OVERLAY_FORMAT_DEFAULT, @@ -1456,4 +1458,15 @@ status_t CameraService::onTransact( return err; } +status_t CameraService::Client::getBufferInfo(sp<IMemory>& Frame, size_t *alignedSize) +{ + LOGD(" getBufferInfo : E"); + if (mHardware == NULL) { + LOGE("mHardware is NULL, returning."); + Frame = NULL; + return INVALID_OPERATION; + } + return mHardware->getBufferInfo(Frame, alignedSize); +} + }; // namespace android diff --git a/camera/libcameraservice/CameraService.h b/camera/libcameraservice/CameraService.h index f04f39c..48cd861 100644 --- a/camera/libcameraservice/CameraService.h +++ b/camera/libcameraservice/CameraService.h @@ -1,6 +1,8 @@ /* ** ** Copyright (C) 2008, The Android Open Source Project +** Copyright (C) 2008 HTC Inc. +** Copyright (C) 2010, Code Aurora Forum. All rights reserved. ** ** Licensed under the Apache License, Version 2.0 (the "License"); ** you may not use this file except in compliance with the License. @@ -126,6 +128,9 @@ private: // our client... const sp<ICameraClient>& getCameraClient() const { return mCameraClient; } + // get the recording buffers information from HAL Layer. + virtual status_t getBufferInfo(sp<IMemory>& Frame, size_t *alignedSize); + private: friend class CameraService; Client(const sp<CameraService>& cameraService, diff --git a/include/camera/Camera.h b/include/camera/Camera.h index 57968e3..f4a80b5 100644 --- a/include/camera/Camera.h +++ b/include/camera/Camera.h @@ -1,5 +1,7 @@ /* * Copyright (C) 2008 The Android Open Source Project + * Copyright (C) 2008 HTC Inc. + * Copyright (C) 2010, Code Aurora Forum. All rights reserved. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -127,6 +129,9 @@ public: status_t setPreviewDisplay(const sp<Surface>& surface); status_t setPreviewDisplay(const sp<ISurface>& surface); + // query the recording buffer information from HAL layer. + status_t getBufferInfo(sp<IMemory>& Frame, size_t *alignedSize); + // start preview mode, must call setPreviewDisplay first status_t startPreview(); diff --git a/include/camera/CameraHardwareInterface.h b/include/camera/CameraHardwareInterface.h index d877c74..54aad5b 100644 --- a/include/camera/CameraHardwareInterface.h +++ b/include/camera/CameraHardwareInterface.h @@ -1,5 +1,6 @@ /* * Copyright (C) 2008 The Android Open Source Project + * Copyright (C) 2010, Code Aurora Forum. All rights reserved. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -211,6 +212,14 @@ public: * Dump state of the camera hardware */ virtual status_t dump(int fd, const Vector<String16>& args) const = 0; + + /** + * Query the recording buffer information from HAL. + * This is needed because the opencore expects the buffer + * information before starting the recording. + */ + virtual status_t getBufferInfo(sp<IMemory>& Frame, size_t *alignedSize) = 0; + }; /** factory function to instantiate a camera hardware object */ diff --git a/include/camera/ICamera.h b/include/camera/ICamera.h index 6fcf9e5..7b3b8fb 100644 --- a/include/camera/ICamera.h +++ b/include/camera/ICamera.h @@ -1,5 +1,6 @@ /* * Copyright (C) 2008 The Android Open Source Project + * Copyright (C) 2010, Code Aurora Forum. All rights reserved. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -65,7 +66,7 @@ public: virtual status_t startRecording() = 0; // stop recording mode - virtual void stopRecording() = 0; + virtual void stopRecording() = 0; // get recording state virtual bool recordingEnabled() = 0; @@ -90,6 +91,9 @@ public: // send command to camera driver virtual status_t sendCommand(int32_t cmd, int32_t arg1, int32_t arg2) = 0; + + // get the recording buffer information from HAL layer. + virtual status_t getBufferInfo(sp<IMemory>& Frame, size_t *alignedSize) = 0; }; // ---------------------------------------------------------------------------- diff --git a/libs/camera/Camera.cpp b/libs/camera/Camera.cpp index 30ee7c4..d289a8d 100644 --- a/libs/camera/Camera.cpp +++ b/libs/camera/Camera.cpp @@ -1,6 +1,8 @@ /* ** ** Copyright (C) 2008, The Android Open Source Project +** Copyright (C) 2008 HTC Inc. +** Copyright (C) 2010, Code Aurora Forum. All rights reserved. ** ** Licensed under the Apache License, Version 2.0 (the "License"); ** you may not use this file except in compliance with the License. @@ -173,7 +175,6 @@ status_t Camera::setPreviewDisplay(const sp<ISurface>& surface) return c->setPreviewDisplay(surface); } - // start preview mode status_t Camera::startPreview() { @@ -355,5 +356,13 @@ void Camera::DeathNotifier::binderDied(const wp<IBinder>& who) { LOGW("Camera server died!"); } +status_t Camera::getBufferInfo(sp<IMemory>& Frame, size_t *alignedSize) +{ + LOGV("getBufferInfo"); + sp <ICamera> c = mCamera; + if (c == 0) return NO_INIT; + return c->getBufferInfo(Frame, alignedSize); +} + }; // namespace android diff --git a/libs/camera/ICamera.cpp b/libs/camera/ICamera.cpp index 13673b5..48ba361 100644 --- a/libs/camera/ICamera.cpp +++ b/libs/camera/ICamera.cpp @@ -1,6 +1,7 @@ /* ** ** Copyright 2008, The Android Open Source Project +** Copyright (C) 2010, Code Aurora Forum. All rights reserved. ** ** Licensed under the Apache License, Version 2.0 (the "License"); ** you may not use this file except in compliance with the License. @@ -45,6 +46,7 @@ enum { STOP_RECORDING, RECORDING_ENABLED, RELEASE_RECORDING_FRAME, + GET_BUFFER_INFO, }; class BpCamera: public BpInterface<ICamera> @@ -86,6 +88,22 @@ public: remote()->transact(SET_PREVIEW_CALLBACK_FLAG, data, &reply); } + + // get the recording buffer information. + status_t getBufferInfo(sp<IMemory>& Frame, size_t *alignedSize) + { + status_t ret; + LOGV("getBufferInfo"); + Parcel data, reply; + data.writeInterfaceToken(ICamera::getInterfaceDescriptor()); + data.writeStrongBinder(Frame->asBinder()); + remote()->transact(GET_BUFFER_INFO, data, &reply); + ret = reply.readInt32(); + *alignedSize = reply.readInt32(); + return ret; + } + + // start preview mode, must call setPreviewDisplay first status_t startPreview() { @@ -269,6 +287,15 @@ status_t BnCamera::onTransact( setPreviewCallbackFlag(callback_flag); return NO_ERROR; } break; + case GET_BUFFER_INFO:{ + LOGV("GET_BUFFER_INFO"); + CHECK_INTERFACE(ICamera, data, reply); + sp<IMemory> Frame = interface_cast<IMemory>(data.readStrongBinder()); + size_t alignedSize; + reply->writeInt32(getBufferInfo(Frame, &alignedSize)); + reply->writeInt32(alignedSize); + return NO_ERROR; + } break; case START_PREVIEW: { LOGV("START_PREVIEW"); CHECK_INTERFACE(ICamera, data, reply); |