Tue, 06 Jan 2015 21:39:09 +0100
Conditionally force memory storage according to privacy.thirdparty.isolate;
This solves Tor bug #9701, complying with disk avoidance documented in
https://www.torproject.org/projects/torbrowser/design/#disk-avoidance.
michael@0 | 1 | /* |
michael@0 | 2 | * Copyright (C) 2012-2014 Mozilla Foundation |
michael@0 | 3 | * |
michael@0 | 4 | * Licensed under the Apache License, Version 2.0 (the "License"); |
michael@0 | 5 | * you may not use this file except in compliance with the License. |
michael@0 | 6 | * You may obtain a copy of the License at |
michael@0 | 7 | * |
michael@0 | 8 | * http://www.apache.org/licenses/LICENSE-2.0 |
michael@0 | 9 | * |
michael@0 | 10 | * Unless required by applicable law or agreed to in writing, software |
michael@0 | 11 | * distributed under the License is distributed on an "AS IS" BASIS, |
michael@0 | 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
michael@0 | 13 | * See the License for the specific language governing permissions and |
michael@0 | 14 | * limitations under the License. |
michael@0 | 15 | */ |
michael@0 | 16 | |
michael@0 | 17 | #ifndef DOM_CAMERA_GONKCAMERAHWMGR_H |
michael@0 | 18 | #define DOM_CAMERA_GONKCAMERAHWMGR_H |
michael@0 | 19 | |
michael@0 | 20 | #include <binder/IMemory.h> |
michael@0 | 21 | #include <camera/Camera.h> |
michael@0 | 22 | #include <camera/CameraParameters.h> |
michael@0 | 23 | #include <utils/threads.h> |
michael@0 | 24 | |
michael@0 | 25 | #include "GonkCameraControl.h" |
michael@0 | 26 | #include "CameraCommon.h" |
michael@0 | 27 | |
michael@0 | 28 | #include "GonkCameraListener.h" |
michael@0 | 29 | #include "GonkNativeWindow.h" |
michael@0 | 30 | #include "GonkCameraParameters.h" |
michael@0 | 31 | #include "mozilla/ReentrantMonitor.h" |
michael@0 | 32 | |
michael@0 | 33 | namespace mozilla { |
michael@0 | 34 | class nsGonkCameraControl; |
michael@0 | 35 | class GonkCameraParameters; |
michael@0 | 36 | } |
michael@0 | 37 | |
michael@0 | 38 | namespace android { |
michael@0 | 39 | |
michael@0 | 40 | class GonkCameraHardware : public GonkNativeWindowNewFrameCallback |
michael@0 | 41 | , public CameraListener |
michael@0 | 42 | { |
michael@0 | 43 | protected: |
michael@0 | 44 | GonkCameraHardware(mozilla::nsGonkCameraControl* aTarget, uint32_t aCameraId, const sp<Camera>& aCamera); |
michael@0 | 45 | virtual ~GonkCameraHardware(); |
michael@0 | 46 | virtual nsresult Init(); |
michael@0 | 47 | |
michael@0 | 48 | public: |
michael@0 | 49 | static sp<GonkCameraHardware> Connect(mozilla::nsGonkCameraControl* aTarget, uint32_t aCameraId); |
michael@0 | 50 | virtual void Close(); |
michael@0 | 51 | |
michael@0 | 52 | // derived from GonkNativeWindowNewFrameCallback |
michael@0 | 53 | virtual void OnNewFrame() MOZ_OVERRIDE; |
michael@0 | 54 | |
michael@0 | 55 | // derived from CameraListener |
michael@0 | 56 | virtual void notify(int32_t aMsgType, int32_t ext1, int32_t ext2); |
michael@0 | 57 | virtual void postData(int32_t aMsgType, const sp<IMemory>& aDataPtr, camera_frame_metadata_t* metadata); |
michael@0 | 58 | virtual void postDataTimestamp(nsecs_t aTimestamp, int32_t aMsgType, const sp<IMemory>& aDataPtr); |
michael@0 | 59 | |
michael@0 | 60 | /** |
michael@0 | 61 | * The physical orientation of the camera sensor: 0, 90, 180, or 270. |
michael@0 | 62 | * |
michael@0 | 63 | * For example, suppose a device has a naturally tall screen. The |
michael@0 | 64 | * back-facing camera sensor is mounted in landscape. You are looking at |
michael@0 | 65 | * the screen. If the top side of the camera sensor is aligned with the |
michael@0 | 66 | * right edge of the screen in natural orientation, the value should be |
michael@0 | 67 | * 90. If the top side of a front-facing camera sensor is aligned with the |
michael@0 | 68 | * right of the screen, the value should be 270. |
michael@0 | 69 | * |
michael@0 | 70 | * RAW_SENSOR_ORIENTATION is the uncorrected orientation returned directly |
michael@0 | 71 | * by get_camera_info(); OFFSET_SENSOR_ORIENTATION is the offset adjusted |
michael@0 | 72 | * orientation. |
michael@0 | 73 | */ |
michael@0 | 74 | enum { |
michael@0 | 75 | RAW_SENSOR_ORIENTATION, |
michael@0 | 76 | OFFSET_SENSOR_ORIENTATION |
michael@0 | 77 | }; |
michael@0 | 78 | virtual int GetSensorOrientation(uint32_t aType = RAW_SENSOR_ORIENTATION); |
michael@0 | 79 | |
michael@0 | 80 | virtual int AutoFocus(); |
michael@0 | 81 | virtual int CancelAutoFocus(); |
michael@0 | 82 | virtual int StartFaceDetection(); |
michael@0 | 83 | virtual int StopFaceDetection(); |
michael@0 | 84 | virtual int TakePicture(); |
michael@0 | 85 | virtual void CancelTakePicture(); |
michael@0 | 86 | virtual int StartPreview(); |
michael@0 | 87 | virtual void StopPreview(); |
michael@0 | 88 | virtual int PushParameters(const mozilla::GonkCameraParameters& aParams); |
michael@0 | 89 | virtual int PushParameters(const CameraParameters& aParams); |
michael@0 | 90 | virtual nsresult PullParameters(mozilla::GonkCameraParameters& aParams); |
michael@0 | 91 | virtual void PullParameters(CameraParameters& aParams); |
michael@0 | 92 | virtual int StartRecording(); |
michael@0 | 93 | virtual int StopRecording(); |
michael@0 | 94 | virtual int SetListener(const sp<GonkCameraListener>& aListener); |
michael@0 | 95 | virtual void ReleaseRecordingFrame(const sp<IMemory>& aFrame); |
michael@0 | 96 | virtual int StoreMetaDataInBuffers(bool aEnabled); |
michael@0 | 97 | |
michael@0 | 98 | protected: |
michael@0 | 99 | uint32_t mCameraId; |
michael@0 | 100 | bool mClosing; |
michael@0 | 101 | uint32_t mNumFrames; |
michael@0 | 102 | sp<Camera> mCamera; |
michael@0 | 103 | mozilla::nsGonkCameraControl* mTarget; |
michael@0 | 104 | sp<GonkNativeWindow> mNativeWindow; |
michael@0 | 105 | sp<GonkCameraListener> mListener; |
michael@0 | 106 | int mRawSensorOrientation; |
michael@0 | 107 | int mSensorOrientation; |
michael@0 | 108 | |
michael@0 | 109 | private: |
michael@0 | 110 | GonkCameraHardware(const GonkCameraHardware&) MOZ_DELETE; |
michael@0 | 111 | GonkCameraHardware& operator=(const GonkCameraHardware&) MOZ_DELETE; |
michael@0 | 112 | }; |
michael@0 | 113 | |
michael@0 | 114 | } // namespace android |
michael@0 | 115 | |
michael@0 | 116 | #endif // GONK_IMPL_HW_MGR_H |