michael@0: /* michael@0: * Copyright (C) 2012-2014 Mozilla Foundation michael@0: * michael@0: * Licensed under the Apache License, Version 2.0 (the "License"); michael@0: * you may not use this file except in compliance with the License. michael@0: * You may obtain a copy of the License at michael@0: * michael@0: * http://www.apache.org/licenses/LICENSE-2.0 michael@0: * michael@0: * Unless required by applicable law or agreed to in writing, software michael@0: * distributed under the License is distributed on an "AS IS" BASIS, michael@0: * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. michael@0: * See the License for the specific language governing permissions and michael@0: * limitations under the License. michael@0: */ michael@0: michael@0: #ifndef DOM_CAMERA_GONKCAMERAHWMGR_H michael@0: #define DOM_CAMERA_GONKCAMERAHWMGR_H michael@0: michael@0: #include michael@0: #include michael@0: #include michael@0: #include michael@0: michael@0: #include "GonkCameraControl.h" michael@0: #include "CameraCommon.h" michael@0: michael@0: #include "GonkCameraListener.h" michael@0: #include "GonkNativeWindow.h" michael@0: #include "GonkCameraParameters.h" michael@0: #include "mozilla/ReentrantMonitor.h" michael@0: michael@0: namespace mozilla { michael@0: class nsGonkCameraControl; michael@0: class GonkCameraParameters; michael@0: } michael@0: michael@0: namespace android { michael@0: michael@0: class GonkCameraHardware : public GonkNativeWindowNewFrameCallback michael@0: , public CameraListener michael@0: { michael@0: protected: michael@0: GonkCameraHardware(mozilla::nsGonkCameraControl* aTarget, uint32_t aCameraId, const sp& aCamera); michael@0: virtual ~GonkCameraHardware(); michael@0: virtual nsresult Init(); michael@0: michael@0: public: michael@0: static sp Connect(mozilla::nsGonkCameraControl* aTarget, uint32_t aCameraId); michael@0: virtual void Close(); michael@0: michael@0: // derived from GonkNativeWindowNewFrameCallback michael@0: virtual void OnNewFrame() MOZ_OVERRIDE; michael@0: michael@0: // derived from CameraListener michael@0: virtual void notify(int32_t aMsgType, int32_t ext1, int32_t ext2); michael@0: virtual void postData(int32_t aMsgType, const sp& aDataPtr, camera_frame_metadata_t* metadata); michael@0: virtual void postDataTimestamp(nsecs_t aTimestamp, int32_t aMsgType, const sp& aDataPtr); michael@0: michael@0: /** michael@0: * The physical orientation of the camera sensor: 0, 90, 180, or 270. michael@0: * michael@0: * For example, suppose a device has a naturally tall screen. The michael@0: * back-facing camera sensor is mounted in landscape. You are looking at michael@0: * the screen. If the top side of the camera sensor is aligned with the michael@0: * right edge of the screen in natural orientation, the value should be michael@0: * 90. If the top side of a front-facing camera sensor is aligned with the michael@0: * right of the screen, the value should be 270. michael@0: * michael@0: * RAW_SENSOR_ORIENTATION is the uncorrected orientation returned directly michael@0: * by get_camera_info(); OFFSET_SENSOR_ORIENTATION is the offset adjusted michael@0: * orientation. michael@0: */ michael@0: enum { michael@0: RAW_SENSOR_ORIENTATION, michael@0: OFFSET_SENSOR_ORIENTATION michael@0: }; michael@0: virtual int GetSensorOrientation(uint32_t aType = RAW_SENSOR_ORIENTATION); michael@0: michael@0: virtual int AutoFocus(); michael@0: virtual int CancelAutoFocus(); michael@0: virtual int StartFaceDetection(); michael@0: virtual int StopFaceDetection(); michael@0: virtual int TakePicture(); michael@0: virtual void CancelTakePicture(); michael@0: virtual int StartPreview(); michael@0: virtual void StopPreview(); michael@0: virtual int PushParameters(const mozilla::GonkCameraParameters& aParams); michael@0: virtual int PushParameters(const CameraParameters& aParams); michael@0: virtual nsresult PullParameters(mozilla::GonkCameraParameters& aParams); michael@0: virtual void PullParameters(CameraParameters& aParams); michael@0: virtual int StartRecording(); michael@0: virtual int StopRecording(); michael@0: virtual int SetListener(const sp& aListener); michael@0: virtual void ReleaseRecordingFrame(const sp& aFrame); michael@0: virtual int StoreMetaDataInBuffers(bool aEnabled); michael@0: michael@0: protected: michael@0: uint32_t mCameraId; michael@0: bool mClosing; michael@0: uint32_t mNumFrames; michael@0: sp mCamera; michael@0: mozilla::nsGonkCameraControl* mTarget; michael@0: sp mNativeWindow; michael@0: sp mListener; michael@0: int mRawSensorOrientation; michael@0: int mSensorOrientation; michael@0: michael@0: private: michael@0: GonkCameraHardware(const GonkCameraHardware&) MOZ_DELETE; michael@0: GonkCameraHardware& operator=(const GonkCameraHardware&) MOZ_DELETE; michael@0: }; michael@0: michael@0: } // namespace android michael@0: michael@0: #endif // GONK_IMPL_HW_MGR_H