michael@0: /* This Source Code Form is subject to the terms of the Mozilla Public michael@0: * License, v. 2.0. If a copy of the MPL was not distributed with this file, michael@0: * You can obtain one at http://mozilla.org/MPL/2.0/. */ michael@0: michael@0: #ifndef DOM_CAMERA_CAMERACONTROLLISTENER_H michael@0: #define DOM_CAMERA_CAMERACONTROLLISTENER_H michael@0: michael@0: #include michael@0: #include "ICameraControl.h" michael@0: michael@0: namespace mozilla { michael@0: michael@0: namespace layers { michael@0: class Image; michael@0: } michael@0: michael@0: class CameraControlListener michael@0: { michael@0: public: michael@0: CameraControlListener() michael@0: { michael@0: MOZ_COUNT_CTOR(CameraControlListener); michael@0: } michael@0: michael@0: protected: michael@0: // Protected destructor, to discourage deletion outside of Release(): michael@0: virtual ~CameraControlListener() michael@0: { michael@0: MOZ_COUNT_DTOR(CameraControlListener); michael@0: } michael@0: michael@0: public: michael@0: NS_INLINE_DECL_THREADSAFE_REFCOUNTING(CameraControlListener); michael@0: michael@0: enum HardwareState michael@0: { michael@0: kHardwareOpen, michael@0: kHardwareClosed michael@0: }; michael@0: virtual void OnHardwareStateChange(HardwareState aState) { } michael@0: michael@0: enum PreviewState michael@0: { michael@0: kPreviewStopped, michael@0: kPreviewPaused, michael@0: kPreviewStarted michael@0: }; michael@0: virtual void OnPreviewStateChange(PreviewState aState) { } michael@0: michael@0: enum RecorderState michael@0: { michael@0: kRecorderStopped, michael@0: kRecorderStarted, michael@0: #ifdef MOZ_B2G_CAMERA michael@0: kFileSizeLimitReached, michael@0: kVideoLengthLimitReached, michael@0: kTrackCompleted, michael@0: kTrackFailed, michael@0: kMediaRecorderFailed, michael@0: kMediaServerFailed michael@0: #endif michael@0: }; michael@0: enum { kNoTrackNumber = -1 }; michael@0: virtual void OnRecorderStateChange(RecorderState aState, int32_t aStatus, int32_t aTrackNum) { } michael@0: michael@0: virtual void OnShutter() { } michael@0: virtual bool OnNewPreviewFrame(layers::Image* aFrame, uint32_t aWidth, uint32_t aHeight) michael@0: { michael@0: return false; michael@0: } michael@0: michael@0: class CameraListenerConfiguration : public ICameraControl::Configuration michael@0: { michael@0: public: michael@0: uint32_t mMaxMeteringAreas; michael@0: uint32_t mMaxFocusAreas; michael@0: }; michael@0: virtual void OnConfigurationChange(const CameraListenerConfiguration& aConfiguration) { } michael@0: michael@0: virtual void OnAutoFocusComplete(bool aAutoFocusSucceeded) { } michael@0: virtual void OnAutoFocusMoving(bool aIsMoving) { } michael@0: virtual void OnTakePictureComplete(uint8_t* aData, uint32_t aLength, const nsAString& aMimeType) { } michael@0: virtual void OnFacesDetected(const nsTArray& aFaces) { } michael@0: michael@0: enum CameraErrorContext michael@0: { michael@0: kInStartCamera, michael@0: kInStopCamera, michael@0: kInAutoFocus, michael@0: kInStartFaceDetection, michael@0: kInStopFaceDetection, michael@0: kInTakePicture, michael@0: kInStartRecording, michael@0: kInStopRecording, michael@0: kInSetConfiguration, michael@0: kInStartPreview, michael@0: kInStopPreview, michael@0: kInResumeContinuousFocus, michael@0: kInUnspecified michael@0: }; michael@0: enum CameraError michael@0: { michael@0: kErrorApiFailed, michael@0: kErrorInitFailed, michael@0: kErrorInvalidConfiguration, michael@0: kErrorServiceFailed, michael@0: kErrorSetPictureSizeFailed, michael@0: kErrorSetThumbnailSizeFailed, michael@0: kErrorUnknown michael@0: }; michael@0: virtual void OnError(CameraErrorContext aContext, CameraError aError) { } michael@0: }; michael@0: michael@0: } // namespace mozilla michael@0: michael@0: #endif // DOM_CAMERA_CAMERACONTROLLISTENER_H