dom/camera/GonkCameraHwMgr.h

changeset 0
6474c204b198
     1.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
     1.2 +++ b/dom/camera/GonkCameraHwMgr.h	Wed Dec 31 06:09:35 2014 +0100
     1.3 @@ -0,0 +1,116 @@
     1.4 +/*
     1.5 + * Copyright (C) 2012-2014 Mozilla Foundation
     1.6 + *
     1.7 + * Licensed under the Apache License, Version 2.0 (the "License");
     1.8 + * you may not use this file except in compliance with the License.
     1.9 + * You may obtain a copy of the License at
    1.10 + *
    1.11 + *      http://www.apache.org/licenses/LICENSE-2.0
    1.12 + *
    1.13 + * Unless required by applicable law or agreed to in writing, software
    1.14 + * distributed under the License is distributed on an "AS IS" BASIS,
    1.15 + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
    1.16 + * See the License for the specific language governing permissions and
    1.17 + * limitations under the License.
    1.18 + */
    1.19 +
    1.20 +#ifndef DOM_CAMERA_GONKCAMERAHWMGR_H
    1.21 +#define DOM_CAMERA_GONKCAMERAHWMGR_H
    1.22 +
    1.23 +#include <binder/IMemory.h>
    1.24 +#include <camera/Camera.h>
    1.25 +#include <camera/CameraParameters.h>
    1.26 +#include <utils/threads.h>
    1.27 +
    1.28 +#include "GonkCameraControl.h"
    1.29 +#include "CameraCommon.h"
    1.30 +
    1.31 +#include "GonkCameraListener.h"
    1.32 +#include "GonkNativeWindow.h"
    1.33 +#include "GonkCameraParameters.h"
    1.34 +#include "mozilla/ReentrantMonitor.h"
    1.35 +
    1.36 +namespace mozilla {
    1.37 +  class nsGonkCameraControl;
    1.38 +  class GonkCameraParameters;
    1.39 +}
    1.40 +
    1.41 +namespace android {
    1.42 +
    1.43 +class GonkCameraHardware : public GonkNativeWindowNewFrameCallback
    1.44 +                         , public CameraListener
    1.45 +{
    1.46 +protected:
    1.47 +  GonkCameraHardware(mozilla::nsGonkCameraControl* aTarget, uint32_t aCameraId, const sp<Camera>& aCamera);
    1.48 +  virtual ~GonkCameraHardware();
    1.49 +  virtual nsresult Init();
    1.50 +
    1.51 +public:
    1.52 +  static sp<GonkCameraHardware> Connect(mozilla::nsGonkCameraControl* aTarget, uint32_t aCameraId);
    1.53 +  virtual void Close();
    1.54 +
    1.55 +  // derived from GonkNativeWindowNewFrameCallback
    1.56 +  virtual void OnNewFrame() MOZ_OVERRIDE;
    1.57 +
    1.58 +  // derived from CameraListener
    1.59 +  virtual void notify(int32_t aMsgType, int32_t ext1, int32_t ext2);
    1.60 +  virtual void postData(int32_t aMsgType, const sp<IMemory>& aDataPtr, camera_frame_metadata_t* metadata);
    1.61 +  virtual void postDataTimestamp(nsecs_t aTimestamp, int32_t aMsgType, const sp<IMemory>& aDataPtr);
    1.62 +
    1.63 +  /**
    1.64 +   * The physical orientation of the camera sensor: 0, 90, 180, or 270.
    1.65 +   *
    1.66 +   * For example, suppose a device has a naturally tall screen. The
    1.67 +   * back-facing camera sensor is mounted in landscape. You are looking at
    1.68 +   * the screen. If the top side of the camera sensor is aligned with the
    1.69 +   * right edge of the screen in natural orientation, the value should be
    1.70 +   * 90. If the top side of a front-facing camera sensor is aligned with the
    1.71 +   * right of the screen, the value should be 270.
    1.72 +   *
    1.73 +   * RAW_SENSOR_ORIENTATION is the uncorrected orientation returned directly
    1.74 +   * by get_camera_info(); OFFSET_SENSOR_ORIENTATION is the offset adjusted
    1.75 +   * orientation.
    1.76 +   */
    1.77 +  enum {
    1.78 +    RAW_SENSOR_ORIENTATION,
    1.79 +    OFFSET_SENSOR_ORIENTATION
    1.80 +  };
    1.81 +  virtual int      GetSensorOrientation(uint32_t aType = RAW_SENSOR_ORIENTATION);
    1.82 +
    1.83 +  virtual int      AutoFocus();
    1.84 +  virtual int      CancelAutoFocus();
    1.85 +  virtual int      StartFaceDetection();
    1.86 +  virtual int      StopFaceDetection();
    1.87 +  virtual int      TakePicture();
    1.88 +  virtual void     CancelTakePicture();
    1.89 +  virtual int      StartPreview();
    1.90 +  virtual void     StopPreview();
    1.91 +  virtual int      PushParameters(const mozilla::GonkCameraParameters& aParams);
    1.92 +  virtual int      PushParameters(const CameraParameters& aParams);
    1.93 +  virtual nsresult PullParameters(mozilla::GonkCameraParameters& aParams);
    1.94 +  virtual void     PullParameters(CameraParameters& aParams);
    1.95 +  virtual int      StartRecording();
    1.96 +  virtual int      StopRecording();
    1.97 +  virtual int      SetListener(const sp<GonkCameraListener>& aListener);
    1.98 +  virtual void     ReleaseRecordingFrame(const sp<IMemory>& aFrame);
    1.99 +  virtual int      StoreMetaDataInBuffers(bool aEnabled);
   1.100 +
   1.101 +protected:
   1.102 +  uint32_t                      mCameraId;
   1.103 +  bool                          mClosing;
   1.104 +  uint32_t                      mNumFrames;
   1.105 +  sp<Camera>                    mCamera;
   1.106 +  mozilla::nsGonkCameraControl* mTarget;
   1.107 +  sp<GonkNativeWindow>          mNativeWindow;
   1.108 +  sp<GonkCameraListener>        mListener;
   1.109 +  int                           mRawSensorOrientation;
   1.110 +  int                           mSensorOrientation;
   1.111 +
   1.112 +private:
   1.113 +  GonkCameraHardware(const GonkCameraHardware&) MOZ_DELETE;
   1.114 +  GonkCameraHardware& operator=(const GonkCameraHardware&) MOZ_DELETE;
   1.115 +};
   1.116 +
   1.117 +} // namespace android
   1.118 +
   1.119 +#endif // GONK_IMPL_HW_MGR_H

mercurial