Files
palemoon27/dom/camera/CameraControlImpl.h
T
roytam1 b9843e0358 import changes from `dev' branch of rmottola/Arctic-Fox:
- Bug 1167459 - Skip rendering function name nodes if there's no name available (e.g. for C++ pseudoframes), r=jsantell (4a69ed224)
- missing bits Bug 1102219 - Part 4: Replace String.prototype.contains with `String.prototype.includes` in chrome code. r=till (73cd2d2b1)
- Bug 1165045 - Don't create nodes with empty text in the call tree, r=jsantell (b013aa82d)
- Bug 1166122 - Fix regression in the call tree caused by bug 1165045, r=jsantell (ee3f16901)
- Bug 1167975 - CallView._displaySelf sets this.document just because other functions use it; it should pass it as an argument instead, r=jsantell (5ef560c4f)
- Bug 1122662 - Resize graphs when window resizes;r=vporof (25c108e4e)
- Bug 1164784 - Eliminate CSS duplication with perf tool record button r=jsantell (43c9bb999)
- Bug 1150761 - Rename the performance tool's details view names to better describe the data visualizations. r=vp (04ceb6a37)
- Bug 1144424 - Rename '{self,total} allocations' to '{self,total} sampled allocations' in the performance tool. r=jsantell (ae79ad54f)
- Bug 1069910 - Add tooltips explaining what each column in the profiler's tree view represents; r=jsantell (8756f88b6)
- Bug 1107849 - Define a min/max width for the performance panel sidebar. r=vporof (e1769e831)
- Bug 11663354 - A locked recording button should appear disabled in the performance tool. r=vp (4a359d39e)
- Bug 1023546 - DevTools - Support HDPI resolutions for Windows. r=bgrins (ef1a3ecb8)
- Bug 1168125 - Cleanup performance xul and css, r=jsantell (8ec794e46)
- Bug 1168125 - Replace the waterfall view with a tree, r=jsantell (ea76514fe)
- Bug 1168125 - Add marker folding logic, r=jsantell (1d3748d2a)
- Bug 862341 Part 1: Move the network request storage from the console frontend to the console client so the netmonitor can reuse it. r=vporof (d29fb2b73)
- remove gre from resource path (126b00df1)
- Bug 943306 - Allow persisting console input history between sessions;r=past (146ebb486)
- Bug 1134845 - Add clearHistory jsterm helper to remove persisted console input history. r=past (22237e95b)
- Bug 1143497 - Offer a way to extend WebConsole commands. r=bgrins (84e2d2957)
- Bug 1125205 - Display console API messages from shared or service workers to the web console, r=past (b4b701a2c)
- Bug 1169342 - Remove nsIDOMDeviceStorage. Cleanup nsDOMDeviceStorage event wrappers. r=dhylands (41338e16f)
- Bug 1151610 - Manage the case where two extensions fight over the same command. r=bgrins (63f9d2064)
- Bug 862341 Part 2: Display cached network requests in the web console. r=vporof (83c0e7263)
- Bug 1144211 - Improve code coverage of camera mochitests. r=mikeh (ba9f3de89)
- Bug 1152500 - Fix how stop recording may be handled out-of-order. r=dhylands (d8bdd379c)
- Bug 862341 Part 3: Display cached network requests in the network panel. r=vporof (a1a6f151d)
- Bug 862341 Part 4: Start recording network requests when the toolbox opens. r=vporof (7a2bdf847)
- Bug 1151499 - Correct the FM playable state. r=baku (8af26fff2)
- Bug 1180347 - Split media.useAudioChannelService to support turning the service on without turning the Firefox OS specific APIs on; r=baku (3fa29291a)
- Bug 862341 Part 5: Tests. r=vporof (82fb944c6)
2021-05-29 22:53:37 +08:00

140 lines
5.6 KiB
C++

/* 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_CAMERACONTROLIMPL_H
#define DOM_CAMERA_CAMERACONTROLIMPL_H
#include "nsTArray.h"
#include "nsWeakPtr.h"
#include "mozilla/Attributes.h"
#include "mozilla/ReentrantMonitor.h"
#include "nsIFile.h"
#include "nsProxyRelease.h"
#include "AutoRwLock.h"
#include "ICameraControl.h"
#include "CameraCommon.h"
#include "DeviceStorage.h"
#include "DeviceStorageFileDescriptor.h"
#include "CameraControlListener.h"
namespace mozilla {
namespace layers {
class Image;
}
class CameraControlImpl : public ICameraControl
{
public:
explicit CameraControlImpl();
virtual void AddListener(CameraControlListener* aListener) override;
virtual void RemoveListener(CameraControlListener* aListener) override;
// See ICameraControl.h for these methods' return values.
virtual nsresult Start(const Configuration* aConfig = nullptr) override;
virtual nsresult Stop() override;
virtual nsresult SetConfiguration(const Configuration& aConfig) override;
virtual nsresult StartPreview() override;
virtual nsresult StopPreview() override;
virtual nsresult AutoFocus() override;
virtual nsresult StartFaceDetection() override;
virtual nsresult StopFaceDetection() override;
virtual nsresult TakePicture() override;
virtual nsresult StartRecording(DeviceStorageFileDescriptor* aFileDescriptor,
const StartRecordingOptions* aOptions) override;
virtual nsresult StopRecording() override;
virtual nsresult ResumeContinuousFocus() override;
// Event handlers called directly from outside this class.
void OnShutter();
void OnUserError(CameraControlListener::UserContext aContext, nsresult aError);
void OnSystemError(CameraControlListener::SystemContext aContext, nsresult aError);
void OnAutoFocusMoving(bool aIsMoving);
protected:
// Event handlers.
void OnAutoFocusComplete(bool aAutoFocusSucceeded);
void OnFacesDetected(const nsTArray<Face>& aFaces);
void OnTakePictureComplete(uint8_t* aData, uint32_t aLength, const nsAString& aMimeType);
void OnRateLimitPreview(bool aLimit);
bool OnNewPreviewFrame(layers::Image* aImage, uint32_t aWidth, uint32_t aHeight);
void OnRecorderStateChange(CameraControlListener::RecorderState aState,
int32_t aStatus = -1, int32_t aTrackNumber = -1);
void OnPreviewStateChange(CameraControlListener::PreviewState aState);
void OnHardwareStateChange(CameraControlListener::HardwareState aState,
nsresult aReason);
void OnConfigurationChange();
// When we create a new CameraThread, we keep a static reference to it so
// that multiple CameraControl instances can find and reuse it; but we
// don't want that reference to keep the thread object around unnecessarily,
// so we make it a weak reference. The strong dynamic references will keep
// the thread object alive as needed.
static StaticRefPtr<nsIThread> sCameraThread;
nsCOMPtr<nsIThread> mCameraThread;
virtual ~CameraControlImpl();
virtual void BeginBatchParameterSet() override { }
virtual void EndBatchParameterSet() override { }
// Manage camera event listeners.
void AddListenerImpl(already_AddRefed<CameraControlListener> aListener);
void RemoveListenerImpl(CameraControlListener* aListener);
nsTArray<nsRefPtr<CameraControlListener> > mListeners;
PRRWLock* mListenerLock;
class ControlMessage;
class ListenerMessage;
nsresult Dispatch(ControlMessage* aMessage);
// Asynchronous method implementations, invoked on the Camera Thread.
//
// Return values:
// - NS_OK on success;
// - NS_ERROR_INVALID_ARG if one or more arguments is invalid;
// - NS_ERROR_NOT_INITIALIZED if the underlying hardware is not initialized,
// failed to initialize (in the case of StartImpl()), or has been stopped;
// for StartRecordingImpl(), this indicates that no recorder has been
// configured (either by calling StartImpl() or SetConfigurationImpl());
// - NS_ERROR_ALREADY_INITIALIZED if the underlying hardware is already
// initialized;
// - NS_ERROR_NOT_IMPLEMENTED if the method is not implemented;
// - NS_ERROR_FAILURE on general failures.
virtual nsresult StartImpl(const Configuration* aConfig = nullptr) = 0;
virtual nsresult StopImpl() = 0;
virtual nsresult SetConfigurationImpl(const Configuration& aConfig) = 0;
virtual nsresult StartPreviewImpl() = 0;
virtual nsresult StopPreviewImpl() = 0;
virtual nsresult AutoFocusImpl() = 0;
virtual nsresult StartFaceDetectionImpl() = 0;
virtual nsresult StopFaceDetectionImpl() = 0;
virtual nsresult TakePictureImpl() = 0;
virtual nsresult StartRecordingImpl(DeviceStorageFileDescriptor* aFileDescriptor,
const StartRecordingOptions* aOptions) = 0;
virtual nsresult StopRecordingImpl() = 0;
virtual nsresult ResumeContinuousFocusImpl() = 0;
virtual nsresult PushParametersImpl() = 0;
virtual nsresult PullParametersImpl() = 0;
void OnShutterInternal();
void OnClosedInternal();
CameraControlListener::CameraListenerConfiguration mCurrentConfiguration;
CameraControlListener::PreviewState mPreviewState;
CameraControlListener::HardwareState mHardwareState;
nsresult mHardwareStateChangeReason;
private:
CameraControlImpl(const CameraControlImpl&) = delete;
CameraControlImpl& operator=(const CameraControlImpl&) = delete;
};
} // namespace mozilla
#endif // DOM_CAMERA_CAMERACONTROLIMPL_H