2014-02-14 22:41:07 +00:00
|
|
|
/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
|
|
|
|
/* vim:set ts=2 sw=2 sts=2 et cindent: */
|
2012-07-30 21:59:05 +00:00
|
|
|
/* This Source Code Form is subject to the terms of the Mozilla Public
|
2014-02-14 22:41:07 +00:00
|
|
|
* 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 01:01:56 +00:00
|
|
|
#include "DOMCameraCapabilities.h"
|
2014-02-14 22:41:07 +00:00
|
|
|
#include "nsPIDOMWindow.h"
|
|
|
|
#include "nsContentUtils.h"
|
2014-12-13 02:18:03 +00:00
|
|
|
#include "nsProxyRelease.h"
|
2014-02-14 22:41:07 +00:00
|
|
|
#include "mozilla/dom/CameraManagerBinding.h"
|
|
|
|
#include "mozilla/dom/CameraCapabilitiesBinding.h"
|
2014-04-09 15:53:34 +00:00
|
|
|
#include "Navigator.h"
|
2012-07-30 21:59:05 +00:00
|
|
|
#include "CameraCommon.h"
|
2014-02-14 22:41:07 +00:00
|
|
|
#include "ICameraControl.h"
|
2014-12-13 02:18:03 +00:00
|
|
|
#include "CameraControlListener.h"
|
2014-02-14 22:41:07 +00:00
|
|
|
|
|
|
|
namespace mozilla {
|
|
|
|
namespace dom {
|
|
|
|
|
2014-12-13 02:18:03 +00:00
|
|
|
/**
|
|
|
|
* CameraClosedListenerProxy and CameraClosedMessage
|
|
|
|
*/
|
|
|
|
template<class T>
|
|
|
|
class CameraClosedMessage : public nsRunnable
|
|
|
|
{
|
|
|
|
public:
|
2014-12-15 15:37:32 +00:00
|
|
|
explicit CameraClosedMessage(nsMainThreadPtrHandle<T> aListener)
|
2014-12-13 02:18:03 +00:00
|
|
|
: mListener(aListener)
|
|
|
|
{
|
|
|
|
DOM_CAMERA_LOGT("%s:%d : this=%p\n", __func__, __LINE__, this);
|
|
|
|
}
|
|
|
|
|
|
|
|
NS_IMETHODIMP
|
|
|
|
Run() MOZ_OVERRIDE
|
|
|
|
{
|
|
|
|
MOZ_ASSERT(NS_IsMainThread());
|
|
|
|
|
|
|
|
nsRefPtr<T> listener = mListener.get();
|
|
|
|
if (listener) {
|
|
|
|
listener->OnHardwareClosed();
|
|
|
|
}
|
|
|
|
return NS_OK;
|
|
|
|
}
|
|
|
|
|
|
|
|
protected:
|
|
|
|
virtual ~CameraClosedMessage()
|
|
|
|
{
|
|
|
|
DOM_CAMERA_LOGT("%s:%d : this=%p\n", __func__, __LINE__, this);
|
|
|
|
}
|
|
|
|
|
|
|
|
nsMainThreadPtrHandle<T> mListener;
|
|
|
|
};
|
|
|
|
|
|
|
|
template<class T>
|
|
|
|
class CameraClosedListenerProxy : public CameraControlListener
|
|
|
|
{
|
|
|
|
public:
|
2014-12-15 15:37:32 +00:00
|
|
|
explicit CameraClosedListenerProxy(T* aListener)
|
2014-12-13 02:18:03 +00:00
|
|
|
: mListener(new nsMainThreadPtrHolder<T>(aListener))
|
|
|
|
{
|
|
|
|
DOM_CAMERA_LOGT("%s:%d : this=%p\n", __func__, __LINE__, this);
|
|
|
|
}
|
|
|
|
|
|
|
|
virtual void
|
|
|
|
OnHardwareStateChange(HardwareState aState, nsresult aReason) MOZ_OVERRIDE
|
|
|
|
{
|
|
|
|
if (aState != kHardwareClosed) {
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
NS_DispatchToMainThread(new CameraClosedMessage<T>(mListener));
|
|
|
|
}
|
|
|
|
|
|
|
|
protected:
|
|
|
|
virtual ~CameraClosedListenerProxy()
|
|
|
|
{
|
|
|
|
DOM_CAMERA_LOGT("%s:%d : this=%p\n", __func__, __LINE__, this);
|
|
|
|
}
|
|
|
|
|
|
|
|
nsMainThreadPtrHandle<T> mListener;
|
|
|
|
};
|
|
|
|
|
2014-10-31 17:19:06 +00:00
|
|
|
/**
|
|
|
|
* CameraRecorderVideoProfile
|
|
|
|
*/
|
|
|
|
NS_IMPL_CYCLE_COLLECTION_WRAPPERCACHE(CameraRecorderVideoProfile, mParent)
|
2014-02-14 22:41:07 +00:00
|
|
|
|
2014-10-31 17:19:06 +00:00
|
|
|
NS_IMPL_CYCLE_COLLECTING_ADDREF(CameraRecorderVideoProfile)
|
|
|
|
NS_IMPL_CYCLE_COLLECTING_RELEASE(CameraRecorderVideoProfile)
|
2012-07-30 21:59:05 +00:00
|
|
|
|
2014-10-31 17:19:06 +00:00
|
|
|
NS_INTERFACE_MAP_BEGIN_CYCLE_COLLECTION(CameraRecorderVideoProfile)
|
|
|
|
NS_WRAPPERCACHE_INTERFACE_MAP_ENTRY
|
|
|
|
NS_INTERFACE_MAP_ENTRY(nsISupports)
|
|
|
|
NS_INTERFACE_MAP_END
|
|
|
|
|
|
|
|
JSObject*
|
|
|
|
CameraRecorderVideoProfile::WrapObject(JSContext* aCx)
|
|
|
|
{
|
|
|
|
return CameraRecorderVideoProfileBinding::Wrap(aCx, this);
|
|
|
|
}
|
|
|
|
|
|
|
|
CameraRecorderVideoProfile::CameraRecorderVideoProfile(nsISupports* aParent,
|
|
|
|
const ICameraControl::RecorderProfile::Video& aProfile)
|
|
|
|
: mParent(aParent)
|
|
|
|
, mCodec(aProfile.GetCodec())
|
|
|
|
, mBitrate(aProfile.GetBitsPerSecond())
|
|
|
|
, mFramerate(aProfile.GetFramesPerSecond())
|
|
|
|
{
|
|
|
|
DOM_CAMERA_LOGT("%s:%d : this=%p\n", __func__, __LINE__, this);
|
|
|
|
|
|
|
|
mSize.mWidth = aProfile.GetSize().width;
|
|
|
|
mSize.mHeight = aProfile.GetSize().height;
|
|
|
|
|
|
|
|
DOM_CAMERA_LOGI(" video: '%s' %ux%u bps=%u fps=%u\n",
|
|
|
|
NS_ConvertUTF16toUTF8(mCodec).get(), mSize.mWidth, mSize.mHeight, mBitrate, mFramerate);
|
|
|
|
}
|
|
|
|
|
|
|
|
CameraRecorderVideoProfile::~CameraRecorderVideoProfile()
|
|
|
|
{
|
|
|
|
DOM_CAMERA_LOGT("%s:%d : this=%p\n", __func__, __LINE__, this);
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* CameraRecorderAudioProfile
|
|
|
|
*/
|
|
|
|
NS_IMPL_CYCLE_COLLECTION_WRAPPERCACHE(CameraRecorderAudioProfile, mParent)
|
|
|
|
|
|
|
|
NS_IMPL_CYCLE_COLLECTING_ADDREF(CameraRecorderAudioProfile)
|
|
|
|
NS_IMPL_CYCLE_COLLECTING_RELEASE(CameraRecorderAudioProfile)
|
|
|
|
|
|
|
|
NS_INTERFACE_MAP_BEGIN_CYCLE_COLLECTION(CameraRecorderAudioProfile)
|
|
|
|
NS_WRAPPERCACHE_INTERFACE_MAP_ENTRY
|
|
|
|
NS_INTERFACE_MAP_ENTRY(nsISupports)
|
|
|
|
NS_INTERFACE_MAP_END
|
|
|
|
|
|
|
|
JSObject*
|
|
|
|
CameraRecorderAudioProfile::WrapObject(JSContext* aCx)
|
|
|
|
{
|
|
|
|
return CameraRecorderAudioProfileBinding::Wrap(aCx, this);
|
|
|
|
}
|
|
|
|
|
|
|
|
CameraRecorderAudioProfile::CameraRecorderAudioProfile(nsISupports* aParent,
|
|
|
|
const ICameraControl::RecorderProfile::Audio& aProfile)
|
|
|
|
: mParent(aParent)
|
|
|
|
, mCodec(aProfile.GetCodec())
|
|
|
|
, mBitrate(aProfile.GetBitsPerSecond())
|
|
|
|
, mSamplerate(aProfile.GetSamplesPerSecond())
|
|
|
|
, mChannels(aProfile.GetChannels())
|
|
|
|
{
|
|
|
|
DOM_CAMERA_LOGT("%s:%d : this=%p\n", __func__, __LINE__, this);
|
|
|
|
DOM_CAMERA_LOGI(" audio: '%s' bps=%u samples/s=%u channels=%u\n",
|
|
|
|
NS_ConvertUTF16toUTF8(mCodec).get(), mBitrate, mSamplerate, mChannels);
|
|
|
|
}
|
|
|
|
|
|
|
|
CameraRecorderAudioProfile::~CameraRecorderAudioProfile()
|
|
|
|
{
|
|
|
|
DOM_CAMERA_LOGT("%s:%d : this=%p\n", __func__, __LINE__, this);
|
|
|
|
}
|
2012-07-30 21:59:05 +00:00
|
|
|
|
2014-10-31 17:19:06 +00:00
|
|
|
/**
|
|
|
|
* CameraRecorderProfile
|
|
|
|
*/
|
2014-12-13 02:18:03 +00:00
|
|
|
NS_IMPL_CYCLE_COLLECTION_WRAPPERCACHE(CameraRecorderProfile,
|
|
|
|
mParent,
|
|
|
|
mVideo,
|
|
|
|
mAudio)
|
2014-10-31 17:19:06 +00:00
|
|
|
|
|
|
|
NS_IMPL_CYCLE_COLLECTING_ADDREF(CameraRecorderProfile)
|
|
|
|
NS_IMPL_CYCLE_COLLECTING_RELEASE(CameraRecorderProfile)
|
|
|
|
|
|
|
|
NS_INTERFACE_MAP_BEGIN_CYCLE_COLLECTION(CameraRecorderProfile)
|
|
|
|
NS_WRAPPERCACHE_INTERFACE_MAP_ENTRY
|
|
|
|
NS_INTERFACE_MAP_ENTRY(nsISupports)
|
|
|
|
NS_INTERFACE_MAP_END
|
|
|
|
|
|
|
|
JSObject*
|
|
|
|
CameraRecorderProfile::WrapObject(JSContext* aCx)
|
|
|
|
{
|
|
|
|
return CameraRecorderProfileBinding::Wrap(aCx, this);
|
|
|
|
}
|
|
|
|
|
|
|
|
CameraRecorderProfile::CameraRecorderProfile(nsISupports* aParent,
|
|
|
|
const ICameraControl::RecorderProfile& aProfile)
|
|
|
|
: mParent(aParent)
|
|
|
|
, mName(aProfile.GetName())
|
|
|
|
, mContainerFormat(aProfile.GetContainer())
|
|
|
|
, mMimeType(aProfile.GetMimeType())
|
|
|
|
, mVideo(new CameraRecorderVideoProfile(this, aProfile.GetVideo()))
|
|
|
|
, mAudio(new CameraRecorderAudioProfile(this, aProfile.GetAudio()))
|
|
|
|
{
|
|
|
|
DOM_CAMERA_LOGT("%s:%d : this=%p\n", __func__, __LINE__, this);
|
|
|
|
DOM_CAMERA_LOGI("profile: '%s' container=%s mime-type=%s\n",
|
|
|
|
NS_ConvertUTF16toUTF8(mName).get(),
|
|
|
|
NS_ConvertUTF16toUTF8(mContainerFormat).get(),
|
|
|
|
NS_ConvertUTF16toUTF8(mMimeType).get());
|
|
|
|
}
|
|
|
|
|
|
|
|
CameraRecorderProfile::~CameraRecorderProfile()
|
|
|
|
{
|
|
|
|
DOM_CAMERA_LOGT("%s:%d : this=%p\n", __func__, __LINE__, this);
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* CameraRecorderProfiles
|
|
|
|
*/
|
2014-12-13 02:18:03 +00:00
|
|
|
NS_IMPL_CYCLE_COLLECTION_WRAPPERCACHE(CameraRecorderProfiles,
|
|
|
|
mParent,
|
|
|
|
mProfiles)
|
2014-10-31 17:19:06 +00:00
|
|
|
|
|
|
|
NS_IMPL_CYCLE_COLLECTING_ADDREF(CameraRecorderProfiles)
|
|
|
|
NS_IMPL_CYCLE_COLLECTING_RELEASE(CameraRecorderProfiles)
|
|
|
|
|
|
|
|
NS_INTERFACE_MAP_BEGIN_CYCLE_COLLECTION(CameraRecorderProfiles)
|
|
|
|
NS_WRAPPERCACHE_INTERFACE_MAP_ENTRY
|
|
|
|
NS_INTERFACE_MAP_ENTRY(nsISupports)
|
|
|
|
NS_INTERFACE_MAP_END
|
|
|
|
|
|
|
|
JSObject*
|
|
|
|
CameraRecorderProfiles::WrapObject(JSContext* aCx)
|
|
|
|
{
|
|
|
|
return CameraRecorderProfilesBinding::Wrap(aCx, this);
|
|
|
|
}
|
|
|
|
|
|
|
|
CameraRecorderProfiles::CameraRecorderProfiles(nsISupports* aParent,
|
|
|
|
ICameraControl* aCameraControl)
|
|
|
|
: mParent(aParent)
|
|
|
|
, mCameraControl(aCameraControl)
|
|
|
|
{
|
|
|
|
DOM_CAMERA_LOGT("%s:%d : this=%p\n", __func__, __LINE__, this);
|
2014-12-13 02:18:03 +00:00
|
|
|
if (mCameraControl) {
|
|
|
|
mListener = new CameraClosedListenerProxy<CameraRecorderProfiles>(this);
|
|
|
|
mCameraControl->AddListener(mListener);
|
|
|
|
}
|
2014-10-31 17:19:06 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
CameraRecorderProfiles::~CameraRecorderProfiles()
|
|
|
|
{
|
|
|
|
DOM_CAMERA_LOGT("%s:%d : this=%p\n", __func__, __LINE__, this);
|
|
|
|
}
|
|
|
|
|
|
|
|
void
|
|
|
|
CameraRecorderProfiles::GetSupportedNames(unsigned aFlags, nsTArray<nsString>& aNames)
|
|
|
|
{
|
|
|
|
DOM_CAMERA_LOGT("%s:%d : this=%p, flags=0x%x\n",
|
|
|
|
__func__, __LINE__, this, aFlags);
|
2014-12-13 02:18:03 +00:00
|
|
|
if (!mCameraControl) {
|
|
|
|
aNames.Clear();
|
|
|
|
return;
|
|
|
|
}
|
2014-10-31 17:19:06 +00:00
|
|
|
|
|
|
|
nsresult rv = mCameraControl->GetRecorderProfiles(aNames);
|
|
|
|
if (NS_WARN_IF(NS_FAILED(rv))) {
|
|
|
|
aNames.Clear();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
CameraRecorderProfile*
|
|
|
|
CameraRecorderProfiles::NamedGetter(const nsAString& aName, bool& aFound)
|
|
|
|
{
|
|
|
|
DOM_CAMERA_LOGT("%s:%d : this=%p, name='%s'\n", __func__, __LINE__, this,
|
|
|
|
NS_ConvertUTF16toUTF8(aName).get());
|
2014-12-13 02:18:03 +00:00
|
|
|
if (!mCameraControl) {
|
|
|
|
return nullptr;
|
|
|
|
}
|
2014-10-31 17:19:06 +00:00
|
|
|
|
|
|
|
CameraRecorderProfile* profile = mProfiles.GetWeak(aName, &aFound);
|
|
|
|
if (!aFound || !profile) {
|
|
|
|
nsRefPtr<ICameraControl::RecorderProfile> p = mCameraControl->GetProfileInfo(aName);
|
|
|
|
if (p) {
|
|
|
|
profile = new CameraRecorderProfile(this, *p);
|
|
|
|
mProfiles.Put(aName, profile);
|
|
|
|
aFound = true;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
return profile;
|
|
|
|
}
|
|
|
|
|
|
|
|
bool
|
|
|
|
CameraRecorderProfiles::NameIsEnumerable(const nsAString& aName)
|
|
|
|
{
|
|
|
|
DOM_CAMERA_LOGT("%s:%d : this=%p, name='%s' (always returns true)\n",
|
|
|
|
__func__, __LINE__, this, NS_ConvertUTF16toUTF8(aName).get());
|
|
|
|
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
2014-12-13 02:18:03 +00:00
|
|
|
void
|
|
|
|
CameraRecorderProfiles::OnHardwareClosed()
|
|
|
|
{
|
|
|
|
DOM_CAMERA_LOGT("%s:%d : this=%p\n", __func__, __LINE__, this);
|
|
|
|
MOZ_ASSERT(NS_IsMainThread());
|
|
|
|
|
|
|
|
if (mCameraControl) {
|
|
|
|
mCameraControl->RemoveListener(mListener);
|
|
|
|
mCameraControl = nullptr;
|
|
|
|
}
|
|
|
|
mListener = nullptr;
|
|
|
|
}
|
|
|
|
|
2014-10-31 17:19:06 +00:00
|
|
|
/**
|
|
|
|
* CameraCapabilities
|
|
|
|
*/
|
2014-12-13 02:42:13 +00:00
|
|
|
NS_IMPL_CYCLE_COLLECTION_WRAPPERCACHE(CameraCapabilities, mWindow)
|
2012-07-30 21:59:05 +00:00
|
|
|
|
2014-02-14 22:41:07 +00:00
|
|
|
NS_IMPL_CYCLE_COLLECTING_ADDREF(CameraCapabilities)
|
|
|
|
NS_IMPL_CYCLE_COLLECTING_RELEASE(CameraCapabilities)
|
|
|
|
|
|
|
|
NS_INTERFACE_MAP_BEGIN_CYCLE_COLLECTION(CameraCapabilities)
|
|
|
|
NS_WRAPPERCACHE_INTERFACE_MAP_ENTRY
|
2012-07-30 21:59:05 +00:00
|
|
|
NS_INTERFACE_MAP_ENTRY(nsISupports)
|
|
|
|
NS_INTERFACE_MAP_END
|
|
|
|
|
2014-04-09 15:53:34 +00:00
|
|
|
/* static */
|
|
|
|
bool
|
|
|
|
CameraCapabilities::HasSupport(JSContext* aCx, JSObject* aGlobal)
|
|
|
|
{
|
|
|
|
return Navigator::HasCameraSupport(aCx, aGlobal);
|
|
|
|
}
|
|
|
|
|
2014-10-31 17:19:06 +00:00
|
|
|
CameraCapabilities::CameraCapabilities(nsPIDOMWindow* aWindow,
|
|
|
|
ICameraControl* aCameraControl)
|
2014-12-13 02:42:13 +00:00
|
|
|
: mWindow(aWindow)
|
2014-10-31 17:19:06 +00:00
|
|
|
, mCameraControl(aCameraControl)
|
2014-02-14 05:28:57 +00:00
|
|
|
{
|
2014-02-14 22:41:07 +00:00
|
|
|
DOM_CAMERA_LOGT("%s:%d : this=%p\n", __func__, __LINE__, this);
|
2014-12-13 02:18:03 +00:00
|
|
|
if (mCameraControl) {
|
|
|
|
mListener = new CameraClosedListenerProxy<CameraCapabilities>(this);
|
|
|
|
mCameraControl->AddListener(mListener);
|
|
|
|
}
|
2014-02-14 22:41:07 +00:00
|
|
|
}
|
2012-07-30 21:59:05 +00:00
|
|
|
|
2014-02-14 22:41:07 +00:00
|
|
|
CameraCapabilities::~CameraCapabilities()
|
|
|
|
{
|
|
|
|
DOM_CAMERA_LOGT("%s:%d : this=%p\n", __func__, __LINE__, this);
|
|
|
|
MOZ_COUNT_DTOR(CameraCapabilities);
|
|
|
|
}
|
2012-07-30 21:59:05 +00:00
|
|
|
|
2014-12-13 02:18:03 +00:00
|
|
|
void
|
|
|
|
CameraCapabilities::OnHardwareClosed()
|
|
|
|
{
|
|
|
|
DOM_CAMERA_LOGT("%s:%d : this=%p\n", __func__, __LINE__, this);
|
|
|
|
MOZ_ASSERT(NS_IsMainThread());
|
|
|
|
|
|
|
|
if (mCameraControl) {
|
|
|
|
mCameraControl->RemoveListener(mListener);
|
|
|
|
mCameraControl = nullptr;
|
|
|
|
}
|
|
|
|
mListener = nullptr;
|
|
|
|
}
|
|
|
|
|
2014-02-14 22:41:07 +00:00
|
|
|
JSObject*
|
2014-04-08 22:27:18 +00:00
|
|
|
CameraCapabilities::WrapObject(JSContext* aCx)
|
2014-02-14 22:41:07 +00:00
|
|
|
{
|
Bug 991742 part 6. Remove the "aScope" argument of binding Wrap() methods. r=bholley
This patch was mostly generated with this command:
find . -name "*.h" -o -name "*.cpp" | xargs sed -e 's/Binding::Wrap(aCx, aScope, this/Binding::Wrap(aCx, this/' -e 's/Binding_workers::Wrap(aCx, aScope, this/Binding_workers::Wrap(aCx, this/' -e 's/Binding::Wrap(cx, scope, this/Binding::Wrap(cx, this/' -i ""
plus a few manual fixes to dom/bindings/Codegen.py, js/xpconnect/src/event_impl_gen.py, and a few C++ files that were not caught in the search-and-replace above.
2014-04-08 22:27:17 +00:00
|
|
|
return CameraCapabilitiesBinding::Wrap(aCx, this);
|
2014-02-14 13:27:44 +00:00
|
|
|
}
|
2014-02-14 05:28:57 +00:00
|
|
|
|
2014-02-14 22:41:07 +00:00
|
|
|
#define LOG_IF_ERROR(rv, param) \
|
|
|
|
do { \
|
|
|
|
if (NS_FAILED(rv)) { \
|
|
|
|
DOM_CAMERA_LOGW("Error %x trying to get " #param "\n", \
|
|
|
|
(rv)); \
|
|
|
|
} \
|
|
|
|
} while(0)
|
|
|
|
|
|
|
|
nsresult
|
2014-10-31 17:19:06 +00:00
|
|
|
CameraCapabilities::TranslateToDictionary(uint32_t aKey, nsTArray<CameraSize>& aSizes)
|
2012-07-30 21:59:05 +00:00
|
|
|
{
|
2014-12-13 02:18:03 +00:00
|
|
|
if (NS_WARN_IF(!mCameraControl)) {
|
|
|
|
return NS_ERROR_NOT_AVAILABLE;
|
|
|
|
}
|
|
|
|
|
2014-02-14 22:41:07 +00:00
|
|
|
nsresult rv;
|
|
|
|
nsTArray<ICameraControl::Size> sizes;
|
2012-07-30 21:59:05 +00:00
|
|
|
|
2014-10-31 17:19:06 +00:00
|
|
|
rv = mCameraControl->Get(aKey, sizes);
|
2014-02-14 22:41:07 +00:00
|
|
|
if (NS_FAILED(rv)) {
|
|
|
|
return rv;
|
2012-07-30 21:59:05 +00:00
|
|
|
}
|
|
|
|
|
2014-02-14 22:41:07 +00:00
|
|
|
aSizes.Clear();
|
|
|
|
aSizes.SetCapacity(sizes.Length());
|
|
|
|
for (uint32_t i = 0; i < sizes.Length(); ++i) {
|
|
|
|
CameraSize* s = aSizes.AppendElement();
|
|
|
|
s->mWidth = sizes[i].width;
|
|
|
|
s->mHeight = sizes[i].height;
|
2012-07-30 21:59:05 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
return NS_OK;
|
|
|
|
}
|
|
|
|
|
2014-12-13 02:42:13 +00:00
|
|
|
// The following attributes are tagged [Cached, Constant] in the WebIDL, so
|
|
|
|
// the framework will handle caching them for us.
|
|
|
|
|
2014-10-31 22:51:23 +00:00
|
|
|
void
|
2014-12-13 02:42:13 +00:00
|
|
|
CameraCapabilities::GetPreviewSizes(nsTArray<dom::CameraSize>& aRetVal)
|
2014-10-31 22:51:23 +00:00
|
|
|
{
|
2014-12-13 02:42:13 +00:00
|
|
|
nsresult rv = TranslateToDictionary(CAMERA_PARAM_SUPPORTED_PREVIEWSIZES, aRetVal);
|
|
|
|
LOG_IF_ERROR(rv, CAMERA_PARAM_SUPPORTED_PREVIEWSIZES);
|
2012-07-30 21:59:05 +00:00
|
|
|
}
|
|
|
|
|
2014-02-14 22:41:07 +00:00
|
|
|
void
|
2014-12-13 02:42:13 +00:00
|
|
|
CameraCapabilities::GetPictureSizes(nsTArray<dom::CameraSize>& aRetVal)
|
2012-07-30 21:59:05 +00:00
|
|
|
{
|
2014-12-13 02:42:13 +00:00
|
|
|
nsresult rv = TranslateToDictionary(CAMERA_PARAM_SUPPORTED_PICTURESIZES, aRetVal);
|
|
|
|
LOG_IF_ERROR(rv, CAMERA_PARAM_SUPPORTED_PICTURESIZES);
|
2013-10-30 19:41:08 +00:00
|
|
|
}
|
|
|
|
|
2014-02-14 22:41:07 +00:00
|
|
|
void
|
2014-12-13 02:42:13 +00:00
|
|
|
CameraCapabilities::GetThumbnailSizes(nsTArray<dom::CameraSize>& aRetVal)
|
2013-10-30 19:41:08 +00:00
|
|
|
{
|
2014-12-13 02:42:13 +00:00
|
|
|
nsresult rv = TranslateToDictionary(CAMERA_PARAM_SUPPORTED_JPEG_THUMBNAIL_SIZES, aRetVal);
|
|
|
|
LOG_IF_ERROR(rv, CAMERA_PARAM_SUPPORTED_JPEG_THUMBNAIL_SIZES);
|
2012-07-30 21:59:05 +00:00
|
|
|
}
|
|
|
|
|
2014-02-14 22:41:07 +00:00
|
|
|
void
|
2014-12-13 02:42:13 +00:00
|
|
|
CameraCapabilities::GetVideoSizes(nsTArray<dom::CameraSize>& aRetVal)
|
2012-07-30 21:59:05 +00:00
|
|
|
{
|
2014-12-13 02:42:13 +00:00
|
|
|
nsresult rv = TranslateToDictionary(CAMERA_PARAM_SUPPORTED_VIDEOSIZES, aRetVal);
|
|
|
|
LOG_IF_ERROR(rv, CAMERA_PARAM_SUPPORTED_VIDEOSIZES);
|
2012-07-30 21:59:05 +00:00
|
|
|
}
|
|
|
|
|
2014-02-14 22:41:07 +00:00
|
|
|
void
|
2014-12-13 02:42:13 +00:00
|
|
|
CameraCapabilities::GetFileFormats(nsTArray<nsString>& aRetVal)
|
2012-07-30 21:59:05 +00:00
|
|
|
{
|
2014-12-13 02:18:03 +00:00
|
|
|
if (NS_WARN_IF(!mCameraControl)) {
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
2014-12-13 02:42:13 +00:00
|
|
|
nsresult rv = mCameraControl->Get(CAMERA_PARAM_SUPPORTED_PICTUREFORMATS, aRetVal);
|
|
|
|
LOG_IF_ERROR(rv, CAMERA_PARAM_SUPPORTED_PICTUREFORMATS);
|
2012-07-30 21:59:05 +00:00
|
|
|
}
|
|
|
|
|
2014-02-14 22:41:07 +00:00
|
|
|
void
|
2014-12-13 02:42:13 +00:00
|
|
|
CameraCapabilities::GetWhiteBalanceModes(nsTArray<nsString>& aRetVal)
|
2012-07-30 21:59:05 +00:00
|
|
|
{
|
2014-12-13 02:18:03 +00:00
|
|
|
if (NS_WARN_IF(!mCameraControl)) {
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
2014-12-13 02:42:13 +00:00
|
|
|
nsresult rv = mCameraControl->Get(CAMERA_PARAM_SUPPORTED_WHITEBALANCES, aRetVal);
|
|
|
|
LOG_IF_ERROR(rv, CAMERA_PARAM_SUPPORTED_WHITEBALANCES);
|
2012-07-30 21:59:05 +00:00
|
|
|
}
|
|
|
|
|
2014-02-14 22:41:07 +00:00
|
|
|
void
|
2014-12-13 02:42:13 +00:00
|
|
|
CameraCapabilities::GetSceneModes(nsTArray<nsString>& aRetVal)
|
2012-07-30 21:59:05 +00:00
|
|
|
{
|
2014-12-13 02:18:03 +00:00
|
|
|
if (NS_WARN_IF(!mCameraControl)) {
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
2014-12-13 02:42:13 +00:00
|
|
|
nsresult rv = mCameraControl->Get(CAMERA_PARAM_SUPPORTED_SCENEMODES, aRetVal);
|
|
|
|
LOG_IF_ERROR(rv, CAMERA_PARAM_SUPPORTED_SCENEMODES);
|
2012-07-30 21:59:05 +00:00
|
|
|
}
|
|
|
|
|
2014-02-14 22:41:07 +00:00
|
|
|
void
|
2014-12-13 02:42:13 +00:00
|
|
|
CameraCapabilities::GetEffects(nsTArray<nsString>& aRetVal)
|
2012-07-30 21:59:05 +00:00
|
|
|
{
|
2014-12-13 02:18:03 +00:00
|
|
|
if (NS_WARN_IF(!mCameraControl)) {
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
2014-12-13 02:42:13 +00:00
|
|
|
nsresult rv = mCameraControl->Get(CAMERA_PARAM_SUPPORTED_EFFECTS, aRetVal);
|
|
|
|
LOG_IF_ERROR(rv, CAMERA_PARAM_SUPPORTED_EFFECTS);
|
2012-07-30 21:59:05 +00:00
|
|
|
}
|
|
|
|
|
2014-02-14 22:41:07 +00:00
|
|
|
void
|
2014-12-13 02:42:13 +00:00
|
|
|
CameraCapabilities::GetFlashModes(nsTArray<nsString>& aRetVal)
|
2012-07-30 21:59:05 +00:00
|
|
|
{
|
2014-12-13 02:18:03 +00:00
|
|
|
if (NS_WARN_IF(!mCameraControl)) {
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
2014-12-13 02:42:13 +00:00
|
|
|
nsresult rv = mCameraControl->Get(CAMERA_PARAM_SUPPORTED_FLASHMODES, aRetVal);
|
|
|
|
LOG_IF_ERROR(rv, CAMERA_PARAM_SUPPORTED_FLASHMODES);
|
2012-07-30 21:59:05 +00:00
|
|
|
}
|
|
|
|
|
2014-02-14 22:41:07 +00:00
|
|
|
void
|
2014-12-13 02:42:13 +00:00
|
|
|
CameraCapabilities::GetFocusModes(nsTArray<nsString>& aRetVal)
|
2012-07-30 21:59:05 +00:00
|
|
|
{
|
2014-12-13 02:18:03 +00:00
|
|
|
if (NS_WARN_IF(!mCameraControl)) {
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
2014-12-13 02:42:13 +00:00
|
|
|
nsresult rv = mCameraControl->Get(CAMERA_PARAM_SUPPORTED_FOCUSMODES, aRetVal);
|
|
|
|
LOG_IF_ERROR(rv, CAMERA_PARAM_SUPPORTED_FOCUSMODES);
|
2012-07-30 21:59:05 +00:00
|
|
|
}
|
|
|
|
|
2014-02-14 22:41:07 +00:00
|
|
|
void
|
2014-12-13 02:42:13 +00:00
|
|
|
CameraCapabilities::GetZoomRatios(nsTArray<double>& aRetVal)
|
2012-07-30 21:59:05 +00:00
|
|
|
{
|
2014-12-13 02:18:03 +00:00
|
|
|
if (NS_WARN_IF(!mCameraControl)) {
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
2014-12-13 02:42:13 +00:00
|
|
|
nsresult rv = mCameraControl->Get(CAMERA_PARAM_SUPPORTED_ZOOMRATIOS, aRetVal);
|
|
|
|
LOG_IF_ERROR(rv, CAMERA_PARAM_SUPPORTED_ZOOMRATIOS);
|
2012-07-30 21:59:05 +00:00
|
|
|
}
|
|
|
|
|
2014-02-14 22:41:07 +00:00
|
|
|
uint32_t
|
2014-10-31 17:19:06 +00:00
|
|
|
CameraCapabilities::MaxFocusAreas()
|
2012-07-30 21:59:05 +00:00
|
|
|
{
|
2014-12-13 02:18:03 +00:00
|
|
|
if (NS_WARN_IF(!mCameraControl)) {
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
2014-12-13 02:42:13 +00:00
|
|
|
int32_t areas = 0;
|
|
|
|
nsresult rv = mCameraControl->Get(CAMERA_PARAM_SUPPORTED_MAXFOCUSAREAS, areas);
|
|
|
|
LOG_IF_ERROR(rv, CAMERA_PARAM_SUPPORTED_MAXFOCUSAREAS);
|
|
|
|
return areas < 0 ? 0 : areas;
|
2012-07-30 21:59:05 +00:00
|
|
|
}
|
|
|
|
|
2014-02-14 22:41:07 +00:00
|
|
|
uint32_t
|
2014-10-31 17:19:06 +00:00
|
|
|
CameraCapabilities::MaxMeteringAreas()
|
2012-07-30 21:59:05 +00:00
|
|
|
{
|
2014-12-13 02:18:03 +00:00
|
|
|
if (NS_WARN_IF(!mCameraControl)) {
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
2014-12-13 02:42:13 +00:00
|
|
|
int32_t areas = 0;
|
|
|
|
nsresult rv = mCameraControl->Get(CAMERA_PARAM_SUPPORTED_MAXMETERINGAREAS, areas);
|
|
|
|
LOG_IF_ERROR(rv, CAMERA_PARAM_SUPPORTED_MAXMETERINGAREAS);
|
|
|
|
return areas < 0 ? 0 : areas;
|
2012-07-30 21:59:05 +00:00
|
|
|
}
|
|
|
|
|
2014-04-09 15:52:10 +00:00
|
|
|
uint32_t
|
2014-10-31 17:19:06 +00:00
|
|
|
CameraCapabilities::MaxDetectedFaces()
|
2014-04-09 15:52:10 +00:00
|
|
|
{
|
2014-12-13 02:18:03 +00:00
|
|
|
if (NS_WARN_IF(!mCameraControl)) {
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
2014-12-13 02:42:13 +00:00
|
|
|
int32_t faces = 0;
|
|
|
|
nsresult rv = mCameraControl->Get(CAMERA_PARAM_SUPPORTED_MAXDETECTEDFACES, faces);
|
|
|
|
LOG_IF_ERROR(rv, CAMERA_PARAM_SUPPORTED_MAXDETECTEDFACES);
|
|
|
|
return faces < 0 ? 0 : faces;
|
2014-04-09 15:52:10 +00:00
|
|
|
}
|
|
|
|
|
2014-02-14 22:41:07 +00:00
|
|
|
double
|
2014-10-31 17:19:06 +00:00
|
|
|
CameraCapabilities::MinExposureCompensation()
|
2012-07-30 21:59:05 +00:00
|
|
|
{
|
2014-12-13 02:18:03 +00:00
|
|
|
if (NS_WARN_IF(!mCameraControl)) {
|
|
|
|
return 0.0;
|
|
|
|
}
|
|
|
|
|
2014-12-13 02:42:13 +00:00
|
|
|
double minEv = 0.0;
|
|
|
|
nsresult rv = mCameraControl->Get(CAMERA_PARAM_SUPPORTED_MINEXPOSURECOMPENSATION, minEv);
|
|
|
|
LOG_IF_ERROR(rv, CAMERA_PARAM_SUPPORTED_MINEXPOSURECOMPENSATION);
|
|
|
|
return minEv;
|
2012-07-30 21:59:05 +00:00
|
|
|
}
|
|
|
|
|
2014-02-14 22:41:07 +00:00
|
|
|
double
|
2014-10-31 17:19:06 +00:00
|
|
|
CameraCapabilities::MaxExposureCompensation()
|
2012-07-30 21:59:05 +00:00
|
|
|
{
|
2014-12-13 02:18:03 +00:00
|
|
|
if (NS_WARN_IF(!mCameraControl)) {
|
|
|
|
return 0.0;
|
|
|
|
}
|
|
|
|
|
2014-12-13 02:42:13 +00:00
|
|
|
double maxEv = 0.0;
|
|
|
|
nsresult rv = mCameraControl->Get(CAMERA_PARAM_SUPPORTED_MAXEXPOSURECOMPENSATION, maxEv);
|
|
|
|
LOG_IF_ERROR(rv, CAMERA_PARAM_SUPPORTED_MAXEXPOSURECOMPENSATION);
|
|
|
|
return maxEv;
|
2012-07-30 21:59:05 +00:00
|
|
|
}
|
|
|
|
|
2014-02-14 22:41:07 +00:00
|
|
|
double
|
2014-10-31 17:19:06 +00:00
|
|
|
CameraCapabilities::ExposureCompensationStep()
|
2012-07-30 21:59:05 +00:00
|
|
|
{
|
2014-12-13 02:18:03 +00:00
|
|
|
if (NS_WARN_IF(!mCameraControl)) {
|
|
|
|
return 0.0;
|
|
|
|
}
|
|
|
|
|
2014-12-13 02:42:13 +00:00
|
|
|
double evStep = 0.0;
|
|
|
|
nsresult rv = mCameraControl->Get(CAMERA_PARAM_SUPPORTED_EXPOSURECOMPENSATIONSTEP, evStep);
|
|
|
|
LOG_IF_ERROR(rv, CAMERA_PARAM_SUPPORTED_EXPOSURECOMPENSATIONSTEP);
|
|
|
|
return evStep;
|
2012-10-23 22:30:28 +00:00
|
|
|
}
|
|
|
|
|
2014-10-31 17:19:06 +00:00
|
|
|
CameraRecorderProfiles*
|
|
|
|
CameraCapabilities::RecorderProfiles()
|
2012-10-23 22:30:28 +00:00
|
|
|
{
|
2014-12-13 02:18:03 +00:00
|
|
|
if (NS_WARN_IF(!mCameraControl)) {
|
|
|
|
return nullptr;
|
|
|
|
}
|
|
|
|
|
2014-12-13 02:42:13 +00:00
|
|
|
nsRefPtr<CameraRecorderProfiles> profiles =
|
|
|
|
new CameraRecorderProfiles(this, mCameraControl);
|
2014-10-31 17:19:06 +00:00
|
|
|
return profiles;
|
2014-02-14 13:27:44 +00:00
|
|
|
}
|
2014-02-14 22:41:07 +00:00
|
|
|
|
2014-03-07 06:00:43 +00:00
|
|
|
void
|
2014-12-13 02:42:13 +00:00
|
|
|
CameraCapabilities::GetIsoModes(nsTArray<nsString>& aRetVal)
|
2014-03-07 06:00:43 +00:00
|
|
|
{
|
2014-12-13 02:18:03 +00:00
|
|
|
if (NS_WARN_IF(!mCameraControl)) {
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
2014-12-13 02:42:13 +00:00
|
|
|
nsresult rv = mCameraControl->Get(CAMERA_PARAM_SUPPORTED_ISOMODES, aRetVal);
|
|
|
|
LOG_IF_ERROR(rv, CAMERA_PARAM_SUPPORTED_ISOMODES);
|
|
|
|
}
|
|
|
|
|
|
|
|
void
|
|
|
|
CameraCapabilities::GetMeteringModes(nsTArray<nsString>& aRetVal)
|
|
|
|
{
|
|
|
|
if (NS_WARN_IF(!mCameraControl)) {
|
|
|
|
return;
|
2014-10-31 17:19:06 +00:00
|
|
|
}
|
2014-12-13 02:42:13 +00:00
|
|
|
|
|
|
|
nsresult rv = mCameraControl->Get(CAMERA_PARAM_SUPPORTED_METERINGMODES, aRetVal);
|
|
|
|
LOG_IF_ERROR(rv, CAMERA_PARAM_SUPPORTED_METERINGMODES);
|
2014-03-07 06:00:43 +00:00
|
|
|
}
|
|
|
|
|
2014-02-14 22:41:07 +00:00
|
|
|
} // namespace dom
|
|
|
|
} // namespace mozilla
|