2012-07-31 01:59:05 +04: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/. */
|
|
|
|
|
2012-09-05 05:01:56 +04:00
|
|
|
#include "DOMCameraControl.h"
|
|
|
|
#include "CameraControlImpl.h"
|
2012-07-31 01:59:05 +04:00
|
|
|
|
|
|
|
using namespace mozilla;
|
2012-11-10 19:45:52 +04:00
|
|
|
using namespace mozilla::dom;
|
2012-07-31 01:59:05 +04:00
|
|
|
|
2012-10-24 02:30:28 +04:00
|
|
|
namespace mozilla {
|
|
|
|
class RecorderProfileManager;
|
|
|
|
}
|
|
|
|
|
2012-07-31 01:59:05 +04:00
|
|
|
/**
|
|
|
|
* Fallback camera control subclass. Can be used as a template for the
|
|
|
|
* definition of new camera support classes.
|
|
|
|
*/
|
2012-09-05 05:01:56 +04:00
|
|
|
class nsFallbackCameraControl : public CameraControlImpl
|
2012-07-31 01:59:05 +04:00
|
|
|
{
|
|
|
|
public:
|
2012-10-01 04:37:47 +04:00
|
|
|
nsFallbackCameraControl(uint32_t aCameraId, nsIThread* aCameraThread, nsDOMCameraControl* aDOMCameraControl, nsICameraGetCameraCallback* onSuccess, nsICameraErrorCallback* onError, uint64_t aWindowId);
|
2012-07-31 01:59:05 +04:00
|
|
|
|
|
|
|
const char* GetParameter(const char* aKey);
|
2012-08-22 19:56:38 +04:00
|
|
|
const char* GetParameterConstChar(uint32_t aKey);
|
|
|
|
double GetParameterDouble(uint32_t aKey);
|
2013-12-06 18:47:29 +04:00
|
|
|
int32_t GetParameterInt32(uint32_t aKey);
|
2013-02-11 23:37:50 +04:00
|
|
|
void GetParameter(uint32_t aKey, nsTArray<idl::CameraRegion>& aRegions);
|
2013-10-30 23:41:08 +04:00
|
|
|
void GetParameter(uint32_t aKey, idl::CameraSize& aSize);
|
2012-07-31 01:59:05 +04:00
|
|
|
void SetParameter(const char* aKey, const char* aValue);
|
2012-08-22 19:56:38 +04:00
|
|
|
void SetParameter(uint32_t aKey, const char* aValue);
|
|
|
|
void SetParameter(uint32_t aKey, double aValue);
|
2013-02-11 23:37:50 +04:00
|
|
|
void SetParameter(uint32_t aKey, const nsTArray<idl::CameraRegion>& aRegions);
|
2013-10-30 23:41:08 +04:00
|
|
|
void SetParameter(uint32_t aKey, const idl::CameraSize& aSize);
|
2013-02-11 23:37:50 +04:00
|
|
|
nsresult GetVideoSizes(nsTArray<idl::CameraSize>& aVideoSizes);
|
2012-09-05 05:01:56 +04:00
|
|
|
nsresult PushParameters();
|
2012-07-31 01:59:05 +04:00
|
|
|
|
|
|
|
protected:
|
|
|
|
~nsFallbackCameraControl();
|
|
|
|
|
|
|
|
nsresult GetPreviewStreamImpl(GetPreviewStreamTask* aGetPreviewStream);
|
2012-09-05 05:01:56 +04:00
|
|
|
nsresult StartPreviewImpl(StartPreviewTask* aStartPreview);
|
|
|
|
nsresult StopPreviewImpl(StopPreviewTask* aStopPreview);
|
2012-07-31 01:59:05 +04:00
|
|
|
nsresult AutoFocusImpl(AutoFocusTask* aAutoFocus);
|
|
|
|
nsresult TakePictureImpl(TakePictureTask* aTakePicture);
|
|
|
|
nsresult StartRecordingImpl(StartRecordingTask* aStartRecording);
|
|
|
|
nsresult StopRecordingImpl(StopRecordingTask* aStopRecording);
|
2012-09-05 05:01:56 +04:00
|
|
|
nsresult PushParametersImpl();
|
|
|
|
nsresult PullParametersImpl();
|
2012-10-24 02:30:28 +04:00
|
|
|
already_AddRefed<RecorderProfileManager> GetRecorderProfileManagerImpl();
|
2012-07-31 01:59:05 +04:00
|
|
|
|
|
|
|
private:
|
|
|
|
nsFallbackCameraControl(const nsFallbackCameraControl&) MOZ_DELETE;
|
|
|
|
nsFallbackCameraControl& operator=(const nsFallbackCameraControl&) MOZ_DELETE;
|
|
|
|
};
|
|
|
|
|
2012-09-05 05:01:56 +04:00
|
|
|
/**
|
|
|
|
* Stub implementation of the DOM-facing camera control constructor.
|
|
|
|
*
|
|
|
|
* This should never get called--it exists to keep the linker happy; if
|
|
|
|
* implemented, it should construct (e.g.) nsFallbackCameraControl and
|
|
|
|
* store a reference in the 'mCameraControl' member (which is why it is
|
|
|
|
* defined here).
|
|
|
|
*/
|
2013-07-07 00:55:10 +04:00
|
|
|
nsDOMCameraControl::nsDOMCameraControl(uint32_t aCameraId, nsIThread* aCameraThread, nsICameraGetCameraCallback* onSuccess, nsICameraErrorCallback* onError, nsPIDOMWindow* aWindow) :
|
|
|
|
mWindow(aWindow)
|
2012-09-05 05:01:56 +04:00
|
|
|
{
|
2013-07-07 00:55:10 +04:00
|
|
|
MOZ_ASSERT(aWindow, "shouldn't be created with null window!");
|
2013-08-29 17:57:53 +04:00
|
|
|
SetIsDOMBinding();
|
2012-09-05 05:01:56 +04:00
|
|
|
}
|
|
|
|
|
2012-07-31 01:59:05 +04:00
|
|
|
/**
|
|
|
|
* Stub implemetations of the fallback camera control.
|
|
|
|
*
|
|
|
|
* None of these should ever get called--they exist to keep the linker happy,
|
|
|
|
* and may be used as templates for new camera support classes.
|
|
|
|
*/
|
2012-10-01 04:37:47 +04:00
|
|
|
nsFallbackCameraControl::nsFallbackCameraControl(uint32_t aCameraId, nsIThread* aCameraThread, nsDOMCameraControl* aDOMCameraControl, nsICameraGetCameraCallback* onSuccess, nsICameraErrorCallback* onError, uint64_t aWindowId)
|
|
|
|
: CameraControlImpl(aCameraId, aCameraThread, aWindowId)
|
2012-09-05 05:01:56 +04:00
|
|
|
{
|
|
|
|
}
|
2012-07-31 01:59:05 +04:00
|
|
|
|
|
|
|
nsFallbackCameraControl::~nsFallbackCameraControl()
|
2012-09-05 05:01:56 +04:00
|
|
|
{
|
|
|
|
}
|
2012-07-31 01:59:05 +04:00
|
|
|
|
|
|
|
const char*
|
|
|
|
nsFallbackCameraControl::GetParameter(const char* aKey)
|
|
|
|
{
|
|
|
|
return nullptr;
|
|
|
|
}
|
|
|
|
|
|
|
|
const char*
|
2012-08-22 19:56:38 +04:00
|
|
|
nsFallbackCameraControl::GetParameterConstChar(uint32_t aKey)
|
2012-07-31 01:59:05 +04:00
|
|
|
{
|
|
|
|
return nullptr;
|
|
|
|
}
|
|
|
|
|
|
|
|
double
|
2012-08-22 19:56:38 +04:00
|
|
|
nsFallbackCameraControl::GetParameterDouble(uint32_t aKey)
|
2012-07-31 01:59:05 +04:00
|
|
|
{
|
|
|
|
return NAN;
|
|
|
|
}
|
|
|
|
|
2013-12-06 18:47:29 +04:00
|
|
|
int32_t
|
|
|
|
nsFallbackCameraControl::GetParameterInt32(uint32_t aKey)
|
|
|
|
{
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
2012-07-31 01:59:05 +04:00
|
|
|
void
|
2013-02-11 23:37:50 +04:00
|
|
|
nsFallbackCameraControl::GetParameter(uint32_t aKey, nsTArray<idl::CameraRegion>& aRegions)
|
2012-07-31 01:59:05 +04:00
|
|
|
{
|
|
|
|
}
|
|
|
|
|
2013-10-30 23:41:08 +04:00
|
|
|
void
|
|
|
|
nsFallbackCameraControl::GetParameter(uint32_t aKey, idl::CameraSize& aSize)
|
|
|
|
{
|
|
|
|
}
|
|
|
|
|
2012-07-31 01:59:05 +04:00
|
|
|
void
|
|
|
|
nsFallbackCameraControl::SetParameter(const char* aKey, const char* aValue)
|
|
|
|
{
|
|
|
|
}
|
|
|
|
|
|
|
|
void
|
2012-08-22 19:56:38 +04:00
|
|
|
nsFallbackCameraControl::SetParameter(uint32_t aKey, const char* aValue)
|
2012-07-31 01:59:05 +04:00
|
|
|
{
|
|
|
|
}
|
|
|
|
|
|
|
|
void
|
2012-08-22 19:56:38 +04:00
|
|
|
nsFallbackCameraControl::SetParameter(uint32_t aKey, double aValue)
|
2012-07-31 01:59:05 +04:00
|
|
|
{
|
|
|
|
}
|
|
|
|
|
|
|
|
void
|
2013-02-11 23:37:50 +04:00
|
|
|
nsFallbackCameraControl::SetParameter(uint32_t aKey, const nsTArray<idl::CameraRegion>& aRegions)
|
2012-07-31 01:59:05 +04:00
|
|
|
{
|
|
|
|
}
|
|
|
|
|
2013-10-30 23:41:08 +04:00
|
|
|
void
|
|
|
|
nsFallbackCameraControl::SetParameter(uint32_t aKey, const idl::CameraSize& aSize)
|
|
|
|
{
|
|
|
|
}
|
|
|
|
|
2012-09-05 05:01:56 +04:00
|
|
|
nsresult
|
2012-07-31 01:59:05 +04:00
|
|
|
nsFallbackCameraControl::PushParameters()
|
|
|
|
{
|
2012-09-05 05:01:56 +04:00
|
|
|
return NS_ERROR_NOT_IMPLEMENTED;
|
2012-07-31 01:59:05 +04:00
|
|
|
}
|
|
|
|
|
|
|
|
nsresult
|
|
|
|
nsFallbackCameraControl::GetPreviewStreamImpl(GetPreviewStreamTask* aGetPreviewStream)
|
|
|
|
{
|
|
|
|
return NS_ERROR_NOT_IMPLEMENTED;
|
|
|
|
}
|
|
|
|
|
2012-09-05 05:01:56 +04:00
|
|
|
nsresult
|
|
|
|
nsFallbackCameraControl::StartPreviewImpl(StartPreviewTask* aGetPreviewStream)
|
|
|
|
{
|
|
|
|
return NS_ERROR_NOT_IMPLEMENTED;
|
|
|
|
}
|
|
|
|
|
|
|
|
nsresult
|
|
|
|
nsFallbackCameraControl::StopPreviewImpl(StopPreviewTask* aGetPreviewStream)
|
|
|
|
{
|
|
|
|
return NS_ERROR_NOT_IMPLEMENTED;
|
|
|
|
}
|
|
|
|
|
2012-07-31 01:59:05 +04:00
|
|
|
nsresult
|
|
|
|
nsFallbackCameraControl::AutoFocusImpl(AutoFocusTask* aAutoFocus)
|
|
|
|
{
|
|
|
|
return NS_ERROR_NOT_IMPLEMENTED;
|
|
|
|
}
|
|
|
|
|
|
|
|
nsresult
|
|
|
|
nsFallbackCameraControl::TakePictureImpl(TakePictureTask* aTakePicture)
|
|
|
|
{
|
|
|
|
return NS_ERROR_NOT_IMPLEMENTED;
|
|
|
|
}
|
|
|
|
|
|
|
|
nsresult
|
|
|
|
nsFallbackCameraControl::StartRecordingImpl(StartRecordingTask* aStartRecording)
|
|
|
|
{
|
|
|
|
return NS_ERROR_NOT_IMPLEMENTED;
|
|
|
|
}
|
|
|
|
|
|
|
|
nsresult
|
|
|
|
nsFallbackCameraControl::StopRecordingImpl(StopRecordingTask* aStopRecording)
|
|
|
|
{
|
|
|
|
return NS_ERROR_NOT_IMPLEMENTED;
|
|
|
|
}
|
|
|
|
|
|
|
|
nsresult
|
2012-09-05 05:01:56 +04:00
|
|
|
nsFallbackCameraControl::PushParametersImpl()
|
2012-07-31 01:59:05 +04:00
|
|
|
{
|
|
|
|
return NS_ERROR_NOT_IMPLEMENTED;
|
|
|
|
}
|
|
|
|
|
|
|
|
nsresult
|
2012-09-05 05:01:56 +04:00
|
|
|
nsFallbackCameraControl::PullParametersImpl()
|
2012-07-31 01:59:05 +04:00
|
|
|
{
|
|
|
|
return NS_ERROR_NOT_IMPLEMENTED;
|
|
|
|
}
|
2012-10-24 02:30:28 +04:00
|
|
|
|
|
|
|
nsresult
|
2013-02-11 23:37:50 +04:00
|
|
|
nsFallbackCameraControl::GetVideoSizes(nsTArray<idl::CameraSize>& aVideoSizes)
|
2012-10-24 02:30:28 +04:00
|
|
|
{
|
|
|
|
return NS_ERROR_NOT_IMPLEMENTED;
|
|
|
|
}
|
|
|
|
|
|
|
|
already_AddRefed<RecorderProfileManager>
|
|
|
|
nsFallbackCameraControl::GetRecorderProfileManagerImpl()
|
|
|
|
{
|
|
|
|
return nullptr;
|
|
|
|
}
|