2014-02-14 14:41:07 -08: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-09-04 18:01:56 -07:00
|
|
|
/* This Source Code Form is subject to the terms of the Mozilla Public
|
2014-02-14 14:41:07 -08: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-04 18:01:56 -07:00
|
|
|
|
2014-02-14 14:41:07 -08:00
|
|
|
#ifndef mozilla_dom_CameraCapabilities_h__
|
|
|
|
#define mozilla_dom_CameraCapabilities_h__
|
2012-09-04 18:01:56 -07:00
|
|
|
|
2014-02-14 14:41:07 -08:00
|
|
|
#include "nsString.h"
|
2012-09-04 18:01:56 -07:00
|
|
|
#include "nsAutoPtr.h"
|
2014-10-31 10:19:06 -07:00
|
|
|
#include "base/basictypes.h"
|
2014-02-14 14:41:07 -08:00
|
|
|
#include "mozilla/Attributes.h"
|
|
|
|
#include "mozilla/ErrorResult.h"
|
|
|
|
#include "mozilla/dom/CameraManagerBinding.h"
|
|
|
|
#include "nsCycleCollectionParticipant.h"
|
|
|
|
#include "nsWrapperCache.h"
|
2014-02-27 04:54:32 -08:00
|
|
|
#include "nsPIDOMWindow.h"
|
2014-10-31 10:19:06 -07:00
|
|
|
#include "nsHashKeys.h"
|
|
|
|
#include "nsRefPtrHashtable.h"
|
|
|
|
#include "nsDataHashtable.h"
|
|
|
|
#include "ICameraControl.h"
|
2014-02-14 14:41:07 -08:00
|
|
|
|
|
|
|
struct JSContext;
|
2012-09-04 18:01:56 -07:00
|
|
|
|
|
|
|
namespace mozilla {
|
2014-10-31 10:19:06 -07:00
|
|
|
namespace dom {
|
|
|
|
|
|
|
|
/**
|
|
|
|
* CameraRecorderVideoProfile
|
|
|
|
*/
|
|
|
|
class CameraRecorderVideoProfile MOZ_FINAL : public nsISupports
|
|
|
|
, public nsWrapperCache
|
|
|
|
{
|
|
|
|
public:
|
|
|
|
NS_DECL_CYCLE_COLLECTING_ISUPPORTS
|
|
|
|
NS_DECL_CYCLE_COLLECTION_SCRIPT_HOLDER_CLASS(CameraRecorderVideoProfile)
|
|
|
|
|
|
|
|
explicit CameraRecorderVideoProfile(nsISupports* aParent,
|
|
|
|
const ICameraControl::RecorderProfile::Video& aProfile);
|
|
|
|
nsISupports* GetParentObject() const { return mParent; }
|
|
|
|
virtual JSObject* WrapObject(JSContext* aCx) MOZ_OVERRIDE;
|
2014-02-14 14:41:07 -08:00
|
|
|
|
2014-10-31 10:19:06 -07:00
|
|
|
uint32_t BitsPerSecond() const { return mBitrate; }
|
|
|
|
uint32_t FramesPerSecond() const { return mFramerate; }
|
|
|
|
void GetCodec(nsAString& aCodec) const { aCodec = mCodec; }
|
2012-09-04 18:01:56 -07:00
|
|
|
|
2014-10-31 10:19:06 -07:00
|
|
|
void GetSize(dom::CameraSize& aSize) const { aSize = mSize; }
|
2014-10-31 10:19:06 -07:00
|
|
|
|
2014-10-31 10:19:06 -07:00
|
|
|
// XXXmikeh - legacy, remove these when the Camera app is updated
|
|
|
|
uint32_t Width() const { return mSize.mWidth; }
|
|
|
|
uint32_t Height() const { return mSize.mHeight; }
|
|
|
|
|
|
|
|
protected:
|
|
|
|
virtual ~CameraRecorderVideoProfile();
|
|
|
|
|
|
|
|
nsCOMPtr<nsISupports> mParent;
|
|
|
|
|
|
|
|
const nsString mCodec;
|
|
|
|
uint32_t mBitrate;
|
|
|
|
uint32_t mFramerate;
|
|
|
|
dom::CameraSize mSize;
|
|
|
|
|
|
|
|
private:
|
|
|
|
DISALLOW_EVIL_CONSTRUCTORS(CameraRecorderVideoProfile);
|
|
|
|
};
|
|
|
|
|
|
|
|
/**
|
|
|
|
* CameraRecorderAudioProfile
|
|
|
|
*/
|
|
|
|
class CameraRecorderAudioProfile MOZ_FINAL : public nsISupports
|
|
|
|
, public nsWrapperCache
|
|
|
|
{
|
|
|
|
public:
|
|
|
|
NS_DECL_CYCLE_COLLECTING_ISUPPORTS
|
|
|
|
NS_DECL_CYCLE_COLLECTION_SCRIPT_HOLDER_CLASS(CameraRecorderAudioProfile)
|
|
|
|
|
|
|
|
explicit CameraRecorderAudioProfile(nsISupports* aParent,
|
|
|
|
const ICameraControl::RecorderProfile::Audio& aProfile);
|
|
|
|
nsISupports* GetParentObject() const { return mParent; }
|
|
|
|
virtual JSObject* WrapObject(JSContext* aCx) MOZ_OVERRIDE;
|
|
|
|
|
|
|
|
uint32_t BitsPerSecond() const { return mBitrate; }
|
|
|
|
uint32_t SamplesPerSecond() const { return mSamplerate; }
|
|
|
|
uint32_t Channels() const { return mChannels; }
|
|
|
|
void GetCodec(nsAString& aCodec) const { aCodec = mCodec; }
|
|
|
|
|
|
|
|
protected:
|
|
|
|
virtual ~CameraRecorderAudioProfile();
|
|
|
|
|
|
|
|
nsCOMPtr<nsISupports> mParent;
|
|
|
|
|
|
|
|
const nsString mCodec;
|
|
|
|
uint32_t mBitrate;
|
|
|
|
uint32_t mSamplerate;
|
|
|
|
uint32_t mChannels;
|
|
|
|
|
|
|
|
private:
|
|
|
|
DISALLOW_EVIL_CONSTRUCTORS(CameraRecorderAudioProfile);
|
|
|
|
};
|
|
|
|
|
|
|
|
/**
|
|
|
|
* CameraRecorderProfile
|
|
|
|
*/
|
|
|
|
class CameraRecorderProfile MOZ_FINAL : public nsISupports
|
|
|
|
, public nsWrapperCache
|
|
|
|
{
|
|
|
|
public:
|
|
|
|
NS_DECL_CYCLE_COLLECTING_ISUPPORTS
|
|
|
|
NS_DECL_CYCLE_COLLECTION_SCRIPT_HOLDER_CLASS(CameraRecorderProfile)
|
|
|
|
|
|
|
|
explicit CameraRecorderProfile(nsISupports* aParent,
|
|
|
|
const ICameraControl::RecorderProfile& aProfile);
|
|
|
|
nsISupports* GetParentObject() const { return mParent; }
|
|
|
|
virtual JSObject* WrapObject(JSContext* aCx) MOZ_OVERRIDE;
|
|
|
|
|
|
|
|
void GetMimeType(nsAString& aMimeType) const { aMimeType = mMimeType; }
|
|
|
|
|
|
|
|
CameraRecorderVideoProfile* Video() { return mVideo; }
|
|
|
|
CameraRecorderAudioProfile* Audio() { return mAudio; }
|
|
|
|
|
|
|
|
void GetName(nsAString& aName) const { aName = mName; }
|
|
|
|
|
|
|
|
void
|
|
|
|
GetContainerFormat(nsAString& aContainerFormat) const
|
|
|
|
{
|
|
|
|
aContainerFormat = mContainerFormat;
|
|
|
|
}
|
|
|
|
|
|
|
|
protected:
|
|
|
|
virtual ~CameraRecorderProfile();
|
|
|
|
|
|
|
|
nsCOMPtr<nsISupports> mParent;
|
|
|
|
|
|
|
|
const nsString mName;
|
|
|
|
const nsString mContainerFormat;
|
|
|
|
const nsString mMimeType;
|
|
|
|
|
|
|
|
nsRefPtr<CameraRecorderVideoProfile> mVideo;
|
|
|
|
nsRefPtr<CameraRecorderAudioProfile> mAudio;
|
|
|
|
|
|
|
|
private:
|
|
|
|
DISALLOW_EVIL_CONSTRUCTORS(CameraRecorderProfile);
|
|
|
|
};
|
|
|
|
|
|
|
|
/**
|
|
|
|
* CameraRecorderProfiles
|
|
|
|
*/
|
|
|
|
class CameraRecorderProfiles MOZ_FINAL : public nsISupports
|
|
|
|
, public nsWrapperCache
|
|
|
|
{
|
|
|
|
public:
|
|
|
|
NS_DECL_CYCLE_COLLECTING_ISUPPORTS
|
|
|
|
NS_DECL_CYCLE_COLLECTION_SCRIPT_HOLDER_CLASS(CameraRecorderProfiles)
|
|
|
|
|
|
|
|
explicit CameraRecorderProfiles(nsISupports* aParent,
|
|
|
|
ICameraControl* aCameraControl);
|
|
|
|
nsISupports* GetParentObject() const { return mParent; }
|
|
|
|
virtual JSObject* WrapObject(JSContext* aCx) MOZ_OVERRIDE;
|
|
|
|
|
|
|
|
CameraRecorderProfile* NamedGetter(const nsAString& aName, bool& aFound);
|
|
|
|
bool NameIsEnumerable(const nsAString& aName);
|
|
|
|
void GetSupportedNames(unsigned aFlags, nsTArray<nsString>& aNames);
|
|
|
|
|
|
|
|
protected:
|
|
|
|
virtual ~CameraRecorderProfiles();
|
|
|
|
|
|
|
|
nsCOMPtr<nsISupports> mParent;
|
|
|
|
nsRefPtr<ICameraControl> mCameraControl;
|
|
|
|
nsRefPtrHashtable<nsStringHashKey, CameraRecorderProfile> mProfiles;
|
|
|
|
|
|
|
|
private:
|
|
|
|
DISALLOW_EVIL_CONSTRUCTORS(CameraRecorderProfiles);
|
|
|
|
};
|
|
|
|
|
|
|
|
/**
|
|
|
|
* CameraCapabilities
|
|
|
|
*/
|
2014-02-14 14:41:07 -08:00
|
|
|
class CameraCapabilities MOZ_FINAL : public nsISupports
|
|
|
|
, public nsWrapperCache
|
2012-09-04 18:01:56 -07:00
|
|
|
{
|
|
|
|
public:
|
2014-02-14 14:41:07 -08:00
|
|
|
NS_DECL_CYCLE_COLLECTING_ISUPPORTS
|
|
|
|
NS_DECL_CYCLE_COLLECTION_SCRIPT_HOLDER_CLASS(CameraCapabilities)
|
|
|
|
|
2014-04-09 08:53:34 -07:00
|
|
|
// Because this header's filename doesn't match its C++ or DOM-facing
|
|
|
|
// classname, we can't rely on the [Func="..."] WebIDL tag to implicitly
|
|
|
|
// include the right header for us; instead we must explicitly include a
|
|
|
|
// HasSupport() method in each header. We can get rid of these with the
|
|
|
|
// Great Renaming proposed in bug 983177.
|
|
|
|
static bool HasSupport(JSContext* aCx, JSObject* aGlobal);
|
|
|
|
|
2014-10-31 10:19:06 -07:00
|
|
|
explicit CameraCapabilities(nsPIDOMWindow* aWindow,
|
|
|
|
ICameraControl* aCameraControl);
|
2014-02-14 14:41:07 -08:00
|
|
|
|
|
|
|
nsPIDOMWindow* GetParentObject() const { return mWindow; }
|
|
|
|
|
2014-04-08 15:27:18 -07:00
|
|
|
virtual JSObject* WrapObject(JSContext* aCx) MOZ_OVERRIDE;
|
2014-02-14 14:41:07 -08:00
|
|
|
|
2014-10-31 10:19:06 -07:00
|
|
|
void GetPreviewSizes(nsTArray<CameraSize>& aRetVal);
|
|
|
|
void GetPictureSizes(nsTArray<CameraSize>& aRetVal);
|
|
|
|
void GetThumbnailSizes(nsTArray<CameraSize>& aRetVal);
|
|
|
|
void GetVideoSizes(nsTArray<CameraSize>& aRetVal);
|
|
|
|
void GetFileFormats(nsTArray<nsString>& aRetVal);
|
|
|
|
void GetWhiteBalanceModes(nsTArray<nsString>& aRetVal);
|
|
|
|
void GetSceneModes(nsTArray<nsString>& aRetVal);
|
|
|
|
void GetEffects(nsTArray<nsString>& aRetVal);
|
|
|
|
void GetFlashModes(nsTArray<nsString>& aRetVal);
|
|
|
|
void GetFocusModes(nsTArray<nsString>& aRetVal);
|
|
|
|
void GetZoomRatios(nsTArray<double>& aRetVal);
|
|
|
|
uint32_t MaxFocusAreas();
|
|
|
|
uint32_t MaxMeteringAreas();
|
|
|
|
uint32_t MaxDetectedFaces();
|
|
|
|
double MinExposureCompensation();
|
|
|
|
double MaxExposureCompensation();
|
|
|
|
double ExposureCompensationStep();
|
|
|
|
void GetIsoModes(nsTArray<nsString>& aRetVal);
|
|
|
|
|
|
|
|
CameraRecorderProfiles* RecorderProfiles();
|
2012-09-04 18:01:56 -07:00
|
|
|
|
|
|
|
protected:
|
2014-04-25 13:28:15 -07:00
|
|
|
~CameraCapabilities();
|
|
|
|
|
2014-10-31 10:19:06 -07:00
|
|
|
nsresult TranslateToDictionary(uint32_t aKey, nsTArray<CameraSize>& aSizes);
|
2014-02-14 14:41:07 -08:00
|
|
|
|
|
|
|
nsTArray<CameraSize> mPreviewSizes;
|
|
|
|
nsTArray<CameraSize> mPictureSizes;
|
|
|
|
nsTArray<CameraSize> mThumbnailSizes;
|
|
|
|
nsTArray<CameraSize> mVideoSizes;
|
|
|
|
|
|
|
|
nsTArray<nsString> mFileFormats;
|
|
|
|
nsTArray<nsString> mWhiteBalanceModes;
|
|
|
|
nsTArray<nsString> mSceneModes;
|
|
|
|
nsTArray<nsString> mEffects;
|
|
|
|
nsTArray<nsString> mFlashModes;
|
|
|
|
nsTArray<nsString> mFocusModes;
|
2014-03-06 22:00:43 -08:00
|
|
|
nsTArray<nsString> mIsoModes;
|
2014-02-14 14:41:07 -08:00
|
|
|
|
|
|
|
nsTArray<double> mZoomRatios;
|
|
|
|
|
|
|
|
uint32_t mMaxFocusAreas;
|
|
|
|
uint32_t mMaxMeteringAreas;
|
2014-04-09 08:52:10 -07:00
|
|
|
uint32_t mMaxDetectedFaces;
|
2014-02-14 14:41:07 -08:00
|
|
|
|
|
|
|
double mMinExposureCompensation;
|
|
|
|
double mMaxExposureCompensation;
|
|
|
|
double mExposureCompensationStep;
|
|
|
|
|
2014-10-31 15:51:23 -07:00
|
|
|
nsRefPtr<nsPIDOMWindow> mWindow;
|
2014-10-31 10:19:06 -07:00
|
|
|
nsRefPtr<ICameraControl> mCameraControl;
|
|
|
|
nsRefPtr<CameraRecorderProfiles> mRecorderProfiles;
|
|
|
|
|
|
|
|
private:
|
|
|
|
DISALLOW_EVIL_CONSTRUCTORS(CameraCapabilities);
|
2012-09-04 18:01:56 -07:00
|
|
|
};
|
|
|
|
|
2014-02-14 14:41:07 -08:00
|
|
|
} // namespace dom
|
2012-09-04 18:01:56 -07:00
|
|
|
} // namespace mozilla
|
|
|
|
|
2014-02-14 14:41:07 -08:00
|
|
|
#endif // mozilla_dom_CameraCapabilities_h__
|