forked from Floorp-Projects/Floorp
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathCameraControlListener.h
138 lines (120 loc) · 3.67 KB
/
CameraControlListener.h
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
/* 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 dom {
class BlobImpl;
} // namespace dom
namespace layers {
class Image;
} // namespace layers
class CameraControlListener
{
public:
CameraControlListener()
{
MOZ_COUNT_CTOR(CameraControlListener);
}
protected:
// Protected destructor, to discourage deletion outside of Release():
virtual ~CameraControlListener()
{
MOZ_COUNT_DTOR(CameraControlListener);
}
public:
NS_INLINE_DECL_THREADSAFE_REFCOUNTING(CameraControlListener);
enum HardwareState
{
kHardwareUninitialized,
kHardwareClosed,
kHardwareOpen,
kHardwareOpenFailed
};
// aReason:
// NS_OK : state change was expected and normal;
// NS_ERROR_FAILURE : one or more system-level components failed and
// the camera was closed;
// NS_ERROR_NOT_AVAILABLE : the hardware is in use by another process
// and cannot be acquired, or another process
// was given access to the camera hardware.
virtual void OnHardwareStateChange(HardwareState aState, nsresult aReason) { }
enum PreviewState
{
kPreviewStopped,
kPreviewPaused,
kPreviewStarted
};
virtual void OnPreviewStateChange(PreviewState aState) { }
enum RecorderState
{
kRecorderStopped,
kRecorderStarted,
kRecorderPaused,
kRecorderResumed,
kPosterCreated,
kPosterFailed,
#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 void OnRateLimitPreview(bool aLimit) { }
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) { }
virtual void OnAutoFocusMoving(bool aIsMoving) { }
virtual void OnTakePictureComplete(const uint8_t* aData, uint32_t aLength, const nsAString& aMimeType) { }
virtual void OnFacesDetected(const nsTArray<ICameraControl::Face>& aFaces) { }
virtual void OnPoster(dom::BlobImpl* aBlobImpl) { }
enum UserContext
{
kInStartCamera,
kInStopCamera,
kInAutoFocus,
kInStartFaceDetection,
kInStopFaceDetection,
kInTakePicture,
kInStartRecording,
kInStopRecording,
kInPauseRecording,
kInResumeRecording,
kInSetConfiguration,
kInStartPreview,
kInStopPreview,
kInSetPictureSize,
kInSetThumbnailSize,
kInResumeContinuousFocus,
kInUnspecified
};
// Error handler for problems arising due to user-initiated actions.
virtual void OnUserError(UserContext aContext, nsresult aError) { }
enum SystemContext
{
kSystemService
};
// Error handler for problems arising due to system failures, not triggered
// by something the CameraControl API user did.
virtual void OnSystemError(SystemContext aContext, nsresult aError) { }
};
} // namespace mozilla
#endif // DOM_CAMERA_CAMERACONTROLLISTENER_H