2 * Copyright (C) 2012 Mozilla Foundation
4 * Licensed under the Apache License, Version 2.0 (the "License");
5 * you may not use this file except in compliance with the License.
6 * You may obtain a copy of the License at
8 * http://www.apache.org/licenses/LICENSE-2.0
10 * Unless required by applicable law or agreed to in writing, software
11 * distributed under the License is distributed on an "AS IS" BASIS,
12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 * See the License for the specific language governing permissions and
14 * limitations under the License.
17 #ifndef DOM_CAMERA_GONKCAMERAHWMGR_H
18 #define DOM_CAMERA_GONKCAMERAHWMGR_H
20 #include <binder/IMemory.h>
21 #include <camera/Camera.h>
22 #include <camera/CameraParameters.h>
23 #include <utils/threads.h>
25 #include "GonkCameraControl.h"
26 #include "CameraCommon.h"
28 #include "GonkCameraListener.h"
29 #include "GonkNativeWindow.h"
30 #include "mozilla/ReentrantMonitor.h"
33 #define GIHM_TIMING_RECEIVEFRAME 0
34 #define GIHM_TIMING_OVERALL 1
38 class nsGonkCameraControl
;
43 class GonkCameraHardware
: public GonkNativeWindowNewFrameCallback
44 , public CameraListener
47 GonkCameraHardware(mozilla::nsGonkCameraControl
* aTarget
, uint32_t aCameraId
, const sp
<Camera
>& aCamera
);
48 virtual ~GonkCameraHardware();
52 static sp
<GonkCameraHardware
> Connect(mozilla::nsGonkCameraControl
* aTarget
, uint32_t aCameraId
);
55 // derived from GonkNativeWindowNewFrameCallback
56 virtual void OnNewFrame() MOZ_OVERRIDE
;
58 // derived from CameraListener
59 virtual void notify(int32_t aMsgType
, int32_t ext1
, int32_t ext2
);
60 virtual void postData(int32_t aMsgType
, const sp
<IMemory
>& aDataPtr
, camera_frame_metadata_t
* metadata
);
61 virtual void postDataTimestamp(nsecs_t aTimestamp
, int32_t aMsgType
, const sp
<IMemory
>& aDataPtr
);
64 * The physical orientation of the camera sensor: 0, 90, 180, or 270.
66 * For example, suppose a device has a naturally tall screen. The
67 * back-facing camera sensor is mounted in landscape. You are looking at
68 * the screen. If the top side of the camera sensor is aligned with the
69 * right edge of the screen in natural orientation, the value should be
70 * 90. If the top side of a front-facing camera sensor is aligned with the
71 * right of the screen, the value should be 270.
73 * RAW_SENSOR_ORIENTATION is the uncorrected orientation returned directly
74 * by get_camera_info(); OFFSET_SENSOR_ORIENTATION is the offset adjusted
78 RAW_SENSOR_ORIENTATION
,
79 OFFSET_SENSOR_ORIENTATION
81 int GetSensorOrientation(uint32_t aType
= RAW_SENSOR_ORIENTATION
);
84 void CancelAutoFocus();
86 void CancelTakePicture();
89 int PushParameters(const CameraParameters
& aParams
);
90 void PullParameters(CameraParameters
& aParams
);
93 int SetListener(const sp
<GonkCameraListener
>& aListener
);
94 void ReleaseRecordingFrame(const sp
<IMemory
>& aFrame
);
95 int StoreMetaDataInBuffers(bool aEnabled
);
101 mozilla::ReentrantMonitor mMonitor
;
104 mozilla::nsGonkCameraControl
* mTarget
;
105 sp
<GonkNativeWindow
> mNativeWindow
;
106 #if GIHM_TIMING_OVERALL
107 struct timespec mStart
;
108 struct timespec mAutoFocusStart
;
110 sp
<GonkCameraListener
> mListener
;
112 int mRawSensorOrientation
;
113 int mSensorOrientation
;
121 GonkCameraHardware(const GonkCameraHardware
&) MOZ_DELETE
;
122 GonkCameraHardware
& operator=(const GonkCameraHardware
&) MOZ_DELETE
;
125 } // namespace android
127 #endif // GONK_IMPL_HW_MGR_H