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