dom/camera/GonkCameraHwMgr.h

Tue, 06 Jan 2015 21:39:09 +0100

author
Michael Schloh von Bennewitz <michael@schloh.com>
date
Tue, 06 Jan 2015 21:39:09 +0100
branch
TOR_BUG_9701
changeset 8
97036ab72558
permissions
-rw-r--r--

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.

     1 /*
     2  * Copyright (C) 2012-2014 Mozilla Foundation
     3  *
     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
     7  *
     8  *      http://www.apache.org/licenses/LICENSE-2.0
     9  *
    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.
    15  */
    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 "GonkCameraParameters.h"
    31 #include "mozilla/ReentrantMonitor.h"
    33 namespace mozilla {
    34   class nsGonkCameraControl;
    35   class GonkCameraParameters;
    36 }
    38 namespace android {
    40 class GonkCameraHardware : public GonkNativeWindowNewFrameCallback
    41                          , public CameraListener
    42 {
    43 protected:
    44   GonkCameraHardware(mozilla::nsGonkCameraControl* aTarget, uint32_t aCameraId, const sp<Camera>& aCamera);
    45   virtual ~GonkCameraHardware();
    46   virtual nsresult Init();
    48 public:
    49   static sp<GonkCameraHardware> Connect(mozilla::nsGonkCameraControl* aTarget, uint32_t aCameraId);
    50   virtual void Close();
    52   // derived from GonkNativeWindowNewFrameCallback
    53   virtual void OnNewFrame() MOZ_OVERRIDE;
    55   // derived from CameraListener
    56   virtual void notify(int32_t aMsgType, int32_t ext1, int32_t ext2);
    57   virtual void postData(int32_t aMsgType, const sp<IMemory>& aDataPtr, camera_frame_metadata_t* metadata);
    58   virtual void postDataTimestamp(nsecs_t aTimestamp, int32_t aMsgType, const sp<IMemory>& aDataPtr);
    60   /**
    61    * The physical orientation of the camera sensor: 0, 90, 180, or 270.
    62    *
    63    * For example, suppose a device has a naturally tall screen. The
    64    * back-facing camera sensor is mounted in landscape. You are looking at
    65    * the screen. If the top side of the camera sensor is aligned with the
    66    * right edge of the screen in natural orientation, the value should be
    67    * 90. If the top side of a front-facing camera sensor is aligned with the
    68    * right of the screen, the value should be 270.
    69    *
    70    * RAW_SENSOR_ORIENTATION is the uncorrected orientation returned directly
    71    * by get_camera_info(); OFFSET_SENSOR_ORIENTATION is the offset adjusted
    72    * orientation.
    73    */
    74   enum {
    75     RAW_SENSOR_ORIENTATION,
    76     OFFSET_SENSOR_ORIENTATION
    77   };
    78   virtual int      GetSensorOrientation(uint32_t aType = RAW_SENSOR_ORIENTATION);
    80   virtual int      AutoFocus();
    81   virtual int      CancelAutoFocus();
    82   virtual int      StartFaceDetection();
    83   virtual int      StopFaceDetection();
    84   virtual int      TakePicture();
    85   virtual void     CancelTakePicture();
    86   virtual int      StartPreview();
    87   virtual void     StopPreview();
    88   virtual int      PushParameters(const mozilla::GonkCameraParameters& aParams);
    89   virtual int      PushParameters(const CameraParameters& aParams);
    90   virtual nsresult PullParameters(mozilla::GonkCameraParameters& aParams);
    91   virtual void     PullParameters(CameraParameters& aParams);
    92   virtual int      StartRecording();
    93   virtual int      StopRecording();
    94   virtual int      SetListener(const sp<GonkCameraListener>& aListener);
    95   virtual void     ReleaseRecordingFrame(const sp<IMemory>& aFrame);
    96   virtual int      StoreMetaDataInBuffers(bool aEnabled);
    98 protected:
    99   uint32_t                      mCameraId;
   100   bool                          mClosing;
   101   uint32_t                      mNumFrames;
   102   sp<Camera>                    mCamera;
   103   mozilla::nsGonkCameraControl* mTarget;
   104   sp<GonkNativeWindow>          mNativeWindow;
   105   sp<GonkCameraListener>        mListener;
   106   int                           mRawSensorOrientation;
   107   int                           mSensorOrientation;
   109 private:
   110   GonkCameraHardware(const GonkCameraHardware&) MOZ_DELETE;
   111   GonkCameraHardware& operator=(const GonkCameraHardware&) MOZ_DELETE;
   112 };
   114 } // namespace android
   116 #endif // GONK_IMPL_HW_MGR_H

mercurial