diff options
-rw-r--r-- | camera/Camera.cpp | 25 | ||||
-rw-r--r-- | camera/ICamera.cpp | 54 | ||||
-rw-r--r-- | include/camera/Camera.h | 9 | ||||
-rw-r--r-- | include/camera/ICamera.h | 9 | ||||
-rw-r--r-- | services/camera/libcameraservice/CameraService.cpp | 25 | ||||
-rw-r--r-- | services/camera/libcameraservice/CameraService.h | 3 |
6 files changed, 124 insertions, 1 deletions
diff --git a/camera/Camera.cpp b/camera/Camera.cpp index b5f78e8..148e864 100644 --- a/camera/Camera.cpp +++ b/camera/Camera.cpp @@ -190,6 +190,31 @@ status_t Camera::startPreview() return c->startPreview(); } +int32_t Camera::getNumberOfVideoBuffers() const +{ + LOGV("getNumberOfVideoBuffers"); + sp <ICamera> c = mCamera; + if (c == 0) return 0; + return c->getNumberOfVideoBuffers(); +} + +sp<IMemory> Camera::getVideoBuffer(int32_t index) const +{ + LOGV("getVideoBuffer: %d", index); + sp <ICamera> c = mCamera; + if (c == 0) return 0; + return c->getVideoBuffer(index); +} + +status_t Camera::storeMetaDataInBuffers(bool enabled) +{ + LOGV("storeMetaDataInBuffers: %s", + enabled? "true": "false"); + sp <ICamera> c = mCamera; + if (c == 0) return NO_INIT; + return c->storeMetaDataInBuffers(enabled); +} + // start recording mode, must call setPreviewDisplay first status_t Camera::startRecording() { diff --git a/camera/ICamera.cpp b/camera/ICamera.cpp index 94dc5c1..7ba8d12 100644 --- a/camera/ICamera.cpp +++ b/camera/ICamera.cpp @@ -45,6 +45,9 @@ enum { STOP_RECORDING, RECORDING_ENABLED, RELEASE_RECORDING_FRAME, + GET_NUM_VIDEO_BUFFERS, + GET_VIDEO_BUFFER, + STORE_META_DATA_IN_BUFFERS, }; class BpCamera: public BpInterface<ICamera> @@ -133,6 +136,37 @@ public: remote()->transact(RELEASE_RECORDING_FRAME, data, &reply); } + int32_t getNumberOfVideoBuffers() const + { + LOGV("getNumberOfVideoBuffers"); + Parcel data, reply; + data.writeInterfaceToken(ICamera::getInterfaceDescriptor()); + remote()->transact(GET_NUM_VIDEO_BUFFERS, data, &reply); + return reply.readInt32(); + } + + sp<IMemory> getVideoBuffer(int32_t index) const + { + LOGV("getVideoBuffer: %d", index); + Parcel data, reply; + data.writeInterfaceToken(ICamera::getInterfaceDescriptor()); + data.writeInt32(index); + remote()->transact(GET_VIDEO_BUFFER, data, &reply); + sp<IMemory> mem = interface_cast<IMemory>( + reply.readStrongBinder()); + return mem; + } + + status_t storeMetaDataInBuffers(bool enabled) + { + LOGV("storeMetaDataInBuffers: %s", enabled? "true": "false"); + Parcel data, reply; + data.writeInterfaceToken(ICamera::getInterfaceDescriptor()); + data.writeInt32(enabled); + remote()->transact(STORE_META_DATA_IN_BUFFERS, data, &reply); + return reply.readInt32(); + } + // check preview state bool previewEnabled() { @@ -300,6 +334,26 @@ status_t BnCamera::onTransact( releaseRecordingFrame(mem); return NO_ERROR; } break; + case GET_NUM_VIDEO_BUFFERS: { + LOGV("GET_NUM_VIDEO_BUFFERS"); + CHECK_INTERFACE(ICamera, data, reply); + reply->writeInt32(getNumberOfVideoBuffers()); + return NO_ERROR; + } break; + case GET_VIDEO_BUFFER: { + LOGV("GET_VIDEO_BUFFER"); + CHECK_INTERFACE(ICamera, data, reply); + int32_t index = data.readInt32(); + reply->writeStrongBinder(getVideoBuffer(index)->asBinder()); + return NO_ERROR; + } break; + case STORE_META_DATA_IN_BUFFERS: { + LOGV("STORE_META_DATA_IN_BUFFERS"); + CHECK_INTERFACE(ICamera, data, reply); + bool enabled = data.readInt32(); + reply->writeInt32(storeMetaDataInBuffers(enabled)); + return NO_ERROR; + } break; case PREVIEW_ENABLED: { LOGV("PREVIEW_ENABLED"); CHECK_INTERFACE(ICamera, data, reply); diff --git a/include/camera/Camera.h b/include/camera/Camera.h index f7b3b42..171a3b6 100644 --- a/include/camera/Camera.h +++ b/include/camera/Camera.h @@ -200,6 +200,15 @@ public: // send command to camera driver status_t sendCommand(int32_t cmd, int32_t arg1, int32_t arg2); + // return the total number of available video buffers. + int32_t getNumberOfVideoBuffers() const; + + // return the individual video buffer corresponding to the given index. + sp<IMemory> getVideoBuffer(int32_t index) const; + + // tell camera hal to store meta data or real YUV in video buffers. + status_t storeMetaDataInBuffers(bool enabled); + void setListener(const sp<CameraListener>& listener); void setPreviewCallbackFlags(int preview_callback_flag); diff --git a/include/camera/ICamera.h b/include/camera/ICamera.h index 8bceea5..b69e075 100644 --- a/include/camera/ICamera.h +++ b/include/camera/ICamera.h @@ -90,6 +90,15 @@ public: // send command to camera driver virtual status_t sendCommand(int32_t cmd, int32_t arg1, int32_t arg2) = 0; + + // return the total number of available video buffers + virtual int32_t getNumberOfVideoBuffers() const = 0; + + // return the individual video buffer corresponding to the given index. + virtual sp<IMemory> getVideoBuffer(int32_t index) const = 0; + + // tell the camera hal to store meta data or real YUV data in video buffers. + virtual status_t storeMetaDataInBuffers(bool enabled) = 0; }; // ---------------------------------------------------------------------------- diff --git a/services/camera/libcameraservice/CameraService.cpp b/services/camera/libcameraservice/CameraService.cpp index d09dfff..2bfdc29 100644 --- a/services/camera/libcameraservice/CameraService.cpp +++ b/services/camera/libcameraservice/CameraService.cpp @@ -304,7 +304,6 @@ CameraService::Client::Client(const sp<CameraService>& cameraService, mClientPid = clientPid; mUseOverlay = mHardware->useOverlay(); mMsgEnabled = 0; - mHardware->setCallbacks(notifyCallback, dataCallback, dataCallbackTimestamp, @@ -706,6 +705,30 @@ void CameraService::Client::releaseRecordingFrame(const sp<IMemory>& mem) { mHardware->releaseRecordingFrame(mem); } +int32_t CameraService::Client::getNumberOfVideoBuffers() const { + LOG1("getNumberOfVideoBuffers"); + Mutex::Autolock lock(mLock); + if (checkPidAndHardware() != NO_ERROR) return 0; + return mHardware->getNumberOfVideoBuffers(); +} + +sp<IMemory> CameraService::Client::getVideoBuffer(int32_t index) const { + LOG1("getVideoBuffer: %d", index); + Mutex::Autolock lock(mLock); + if (checkPidAndHardware() != NO_ERROR) return 0; + return mHardware->getVideoBuffer(index); +} + +status_t CameraService::Client::storeMetaDataInBuffers(bool enabled) +{ + LOG1("storeMetaDataInBuffers: %s", enabled? "true": "false"); + Mutex::Autolock lock(mLock); + if (checkPidAndHardware() != NO_ERROR) { + return UNKNOWN_ERROR; + } + return mHardware->storeMetaDataInBuffers(enabled); +} + bool CameraService::Client::previewEnabled() { LOG1("previewEnabled (pid %d)", getCallingPid()); diff --git a/services/camera/libcameraservice/CameraService.h b/services/camera/libcameraservice/CameraService.h index c8e0c88..b5b85bc 100644 --- a/services/camera/libcameraservice/CameraService.h +++ b/services/camera/libcameraservice/CameraService.h @@ -98,6 +98,9 @@ private: virtual status_t startPreview(); virtual void stopPreview(); virtual bool previewEnabled(); + virtual int32_t getNumberOfVideoBuffers() const; + virtual sp<IMemory> getVideoBuffer(int32_t index) const; + virtual status_t storeMetaDataInBuffers(bool enabled); virtual status_t startRecording(); virtual void stopRecording(); virtual bool recordingEnabled(); |