|
1 /* This Source Code Form is subject to the terms of the Mozilla Public |
|
2 * License, v. 2.0. If a copy of the MPL was not distributed with this file, |
|
3 * You can obtain one at http://mozilla.org/MPL/2.0/. */ |
|
4 |
|
5 #ifndef DOM_CAMERA_CAMERACONTROLLISTENER_H |
|
6 #define DOM_CAMERA_CAMERACONTROLLISTENER_H |
|
7 |
|
8 #include <stdint.h> |
|
9 #include "ICameraControl.h" |
|
10 |
|
11 namespace mozilla { |
|
12 |
|
13 namespace layers { |
|
14 class Image; |
|
15 } |
|
16 |
|
17 class CameraControlListener |
|
18 { |
|
19 public: |
|
20 CameraControlListener() |
|
21 { |
|
22 MOZ_COUNT_CTOR(CameraControlListener); |
|
23 } |
|
24 |
|
25 protected: |
|
26 // Protected destructor, to discourage deletion outside of Release(): |
|
27 virtual ~CameraControlListener() |
|
28 { |
|
29 MOZ_COUNT_DTOR(CameraControlListener); |
|
30 } |
|
31 |
|
32 public: |
|
33 NS_INLINE_DECL_THREADSAFE_REFCOUNTING(CameraControlListener); |
|
34 |
|
35 enum HardwareState |
|
36 { |
|
37 kHardwareOpen, |
|
38 kHardwareClosed |
|
39 }; |
|
40 virtual void OnHardwareStateChange(HardwareState aState) { } |
|
41 |
|
42 enum PreviewState |
|
43 { |
|
44 kPreviewStopped, |
|
45 kPreviewPaused, |
|
46 kPreviewStarted |
|
47 }; |
|
48 virtual void OnPreviewStateChange(PreviewState aState) { } |
|
49 |
|
50 enum RecorderState |
|
51 { |
|
52 kRecorderStopped, |
|
53 kRecorderStarted, |
|
54 #ifdef MOZ_B2G_CAMERA |
|
55 kFileSizeLimitReached, |
|
56 kVideoLengthLimitReached, |
|
57 kTrackCompleted, |
|
58 kTrackFailed, |
|
59 kMediaRecorderFailed, |
|
60 kMediaServerFailed |
|
61 #endif |
|
62 }; |
|
63 enum { kNoTrackNumber = -1 }; |
|
64 virtual void OnRecorderStateChange(RecorderState aState, int32_t aStatus, int32_t aTrackNum) { } |
|
65 |
|
66 virtual void OnShutter() { } |
|
67 virtual bool OnNewPreviewFrame(layers::Image* aFrame, uint32_t aWidth, uint32_t aHeight) |
|
68 { |
|
69 return false; |
|
70 } |
|
71 |
|
72 class CameraListenerConfiguration : public ICameraControl::Configuration |
|
73 { |
|
74 public: |
|
75 uint32_t mMaxMeteringAreas; |
|
76 uint32_t mMaxFocusAreas; |
|
77 }; |
|
78 virtual void OnConfigurationChange(const CameraListenerConfiguration& aConfiguration) { } |
|
79 |
|
80 virtual void OnAutoFocusComplete(bool aAutoFocusSucceeded) { } |
|
81 virtual void OnAutoFocusMoving(bool aIsMoving) { } |
|
82 virtual void OnTakePictureComplete(uint8_t* aData, uint32_t aLength, const nsAString& aMimeType) { } |
|
83 virtual void OnFacesDetected(const nsTArray<ICameraControl::Face>& aFaces) { } |
|
84 |
|
85 enum CameraErrorContext |
|
86 { |
|
87 kInStartCamera, |
|
88 kInStopCamera, |
|
89 kInAutoFocus, |
|
90 kInStartFaceDetection, |
|
91 kInStopFaceDetection, |
|
92 kInTakePicture, |
|
93 kInStartRecording, |
|
94 kInStopRecording, |
|
95 kInSetConfiguration, |
|
96 kInStartPreview, |
|
97 kInStopPreview, |
|
98 kInResumeContinuousFocus, |
|
99 kInUnspecified |
|
100 }; |
|
101 enum CameraError |
|
102 { |
|
103 kErrorApiFailed, |
|
104 kErrorInitFailed, |
|
105 kErrorInvalidConfiguration, |
|
106 kErrorServiceFailed, |
|
107 kErrorSetPictureSizeFailed, |
|
108 kErrorSetThumbnailSizeFailed, |
|
109 kErrorUnknown |
|
110 }; |
|
111 virtual void OnError(CameraErrorContext aContext, CameraError aError) { } |
|
112 }; |
|
113 |
|
114 } // namespace mozilla |
|
115 |
|
116 #endif // DOM_CAMERA_CAMERACONTROLLISTENER_H |