dom/camera/CameraControlListener.h

changeset 0
6474c204b198
     1.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
     1.2 +++ b/dom/camera/CameraControlListener.h	Wed Dec 31 06:09:35 2014 +0100
     1.3 @@ -0,0 +1,116 @@
     1.4 +/* This Source Code Form is subject to the terms of the Mozilla Public
     1.5 + * License, v. 2.0. If a copy of the MPL was not distributed with this file,
     1.6 + * You can obtain one at http://mozilla.org/MPL/2.0/. */
     1.7 +
     1.8 +#ifndef DOM_CAMERA_CAMERACONTROLLISTENER_H
     1.9 +#define DOM_CAMERA_CAMERACONTROLLISTENER_H
    1.10 +
    1.11 +#include <stdint.h>
    1.12 +#include "ICameraControl.h"
    1.13 +
    1.14 +namespace mozilla {
    1.15 +
    1.16 +namespace layers {
    1.17 +  class Image;
    1.18 +}
    1.19 +
    1.20 +class CameraControlListener
    1.21 +{
    1.22 +public:
    1.23 +  CameraControlListener()
    1.24 +  {
    1.25 +    MOZ_COUNT_CTOR(CameraControlListener);
    1.26 +  }
    1.27 +
    1.28 +protected:
    1.29 +  // Protected destructor, to discourage deletion outside of Release():
    1.30 +  virtual ~CameraControlListener()
    1.31 +  {
    1.32 +    MOZ_COUNT_DTOR(CameraControlListener);
    1.33 +  }
    1.34 +
    1.35 +public:
    1.36 +  NS_INLINE_DECL_THREADSAFE_REFCOUNTING(CameraControlListener);
    1.37 +
    1.38 +  enum HardwareState
    1.39 +  {
    1.40 +    kHardwareOpen,
    1.41 +    kHardwareClosed
    1.42 +  };
    1.43 +  virtual void OnHardwareStateChange(HardwareState aState) { }
    1.44 +
    1.45 +  enum PreviewState
    1.46 +  {
    1.47 +    kPreviewStopped,
    1.48 +    kPreviewPaused,
    1.49 +    kPreviewStarted
    1.50 +  };
    1.51 +  virtual void OnPreviewStateChange(PreviewState aState) { }
    1.52 +
    1.53 +  enum RecorderState
    1.54 +  {
    1.55 +    kRecorderStopped,
    1.56 +    kRecorderStarted,
    1.57 +#ifdef MOZ_B2G_CAMERA
    1.58 +    kFileSizeLimitReached,
    1.59 +    kVideoLengthLimitReached,
    1.60 +    kTrackCompleted,
    1.61 +    kTrackFailed,
    1.62 +    kMediaRecorderFailed,
    1.63 +    kMediaServerFailed
    1.64 +#endif
    1.65 +  };
    1.66 +  enum { kNoTrackNumber = -1 };
    1.67 +  virtual void OnRecorderStateChange(RecorderState aState, int32_t aStatus, int32_t aTrackNum) { }
    1.68 +
    1.69 +  virtual void OnShutter() { }
    1.70 +  virtual bool OnNewPreviewFrame(layers::Image* aFrame, uint32_t aWidth, uint32_t aHeight)
    1.71 +  {
    1.72 +    return false;
    1.73 +  }
    1.74 +
    1.75 +  class CameraListenerConfiguration : public ICameraControl::Configuration
    1.76 +  {
    1.77 +  public:
    1.78 +    uint32_t mMaxMeteringAreas;
    1.79 +    uint32_t mMaxFocusAreas;
    1.80 +  };
    1.81 +  virtual void OnConfigurationChange(const CameraListenerConfiguration& aConfiguration) { }
    1.82 +
    1.83 +  virtual void OnAutoFocusComplete(bool aAutoFocusSucceeded) { }
    1.84 +  virtual void OnAutoFocusMoving(bool aIsMoving) { }
    1.85 +  virtual void OnTakePictureComplete(uint8_t* aData, uint32_t aLength, const nsAString& aMimeType) { }
    1.86 +  virtual void OnFacesDetected(const nsTArray<ICameraControl::Face>& aFaces) { }
    1.87 +
    1.88 +  enum CameraErrorContext
    1.89 +  {
    1.90 +    kInStartCamera,
    1.91 +    kInStopCamera,
    1.92 +    kInAutoFocus,
    1.93 +    kInStartFaceDetection,
    1.94 +    kInStopFaceDetection,
    1.95 +    kInTakePicture,
    1.96 +    kInStartRecording,
    1.97 +    kInStopRecording,
    1.98 +    kInSetConfiguration,
    1.99 +    kInStartPreview,
   1.100 +    kInStopPreview,
   1.101 +    kInResumeContinuousFocus,
   1.102 +    kInUnspecified
   1.103 +  };
   1.104 +  enum CameraError
   1.105 +  {
   1.106 +    kErrorApiFailed,
   1.107 +    kErrorInitFailed,
   1.108 +    kErrorInvalidConfiguration,
   1.109 +    kErrorServiceFailed,
   1.110 +    kErrorSetPictureSizeFailed,
   1.111 +    kErrorSetThumbnailSizeFailed,
   1.112 +    kErrorUnknown
   1.113 +  };
   1.114 +  virtual void OnError(CameraErrorContext aContext, CameraError aError) { }
   1.115 +};
   1.116 +
   1.117 +} // namespace mozilla
   1.118 +
   1.119 +#endif // DOM_CAMERA_CAMERACONTROLLISTENER_H

mercurial