2012-07-30 14:59:05 -07: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-04 18:01:56 -07:00
|
|
|
#include <cstring>
|
|
|
|
#include <cstdlib>
|
|
|
|
#include "base/basictypes.h"
|
2012-07-30 14:59:05 -07:00
|
|
|
#include "nsDOMClassInfo.h"
|
|
|
|
#include "jsapi.h"
|
2012-10-23 15:30:28 -07:00
|
|
|
#include "CameraRecorderProfiles.h"
|
2012-09-04 18:01:56 -07:00
|
|
|
#include "DOMCameraControl.h"
|
|
|
|
#include "DOMCameraCapabilities.h"
|
2012-07-30 14:59:05 -07:00
|
|
|
#include "CameraCommon.h"
|
|
|
|
|
|
|
|
using namespace mozilla;
|
2012-11-10 07:45:52 -08:00
|
|
|
using namespace mozilla::dom;
|
2012-07-30 14:59:05 -07:00
|
|
|
|
|
|
|
DOMCI_DATA(CameraCapabilities, nsICameraCapabilities)
|
|
|
|
|
2013-02-07 02:19:08 -08:00
|
|
|
NS_INTERFACE_MAP_BEGIN(DOMCameraCapabilities)
|
2012-07-30 14:59:05 -07:00
|
|
|
NS_INTERFACE_MAP_ENTRY(nsISupports)
|
|
|
|
NS_INTERFACE_MAP_ENTRY(nsICameraCapabilities)
|
|
|
|
NS_DOM_INTERFACE_MAP_ENTRY_CLASSINFO(CameraCapabilities)
|
|
|
|
NS_INTERFACE_MAP_END
|
|
|
|
|
2013-02-07 02:19:08 -08:00
|
|
|
NS_IMPL_ADDREF(DOMCameraCapabilities)
|
|
|
|
NS_IMPL_RELEASE(DOMCameraCapabilities)
|
2012-07-30 14:59:05 -07:00
|
|
|
|
|
|
|
static nsresult
|
2012-08-22 08:56:38 -07:00
|
|
|
ParseZoomRatioItemAndAdd(JSContext* aCx, JSObject* aArray, uint32_t aIndex, const char* aStart, char** aEnd)
|
2012-07-30 14:59:05 -07:00
|
|
|
{
|
|
|
|
if (!*aEnd) {
|
|
|
|
// make 'aEnd' follow the same semantics as strchr().
|
|
|
|
aEnd = nullptr;
|
|
|
|
}
|
|
|
|
|
2012-09-04 18:01:56 -07:00
|
|
|
/**
|
|
|
|
* The by-100 divisor is Gonk-specific. For now, assume other platforms
|
2012-10-23 15:30:28 -07:00
|
|
|
* return actual fractional multipliers.
|
2012-09-04 18:01:56 -07:00
|
|
|
*/
|
2012-07-30 14:59:05 -07:00
|
|
|
double d = strtod(aStart, aEnd);
|
2012-09-04 18:01:56 -07:00
|
|
|
#if MOZ_WIDGET_GONK
|
2012-07-30 14:59:05 -07:00
|
|
|
d /= 100;
|
2012-09-04 18:01:56 -07:00
|
|
|
#endif
|
2012-08-01 17:59:47 -07:00
|
|
|
|
|
|
|
jsval v = JS_NumberValue(d);
|
|
|
|
|
2012-07-30 14:59:05 -07:00
|
|
|
if (!JS_SetElement(aCx, aArray, aIndex, &v)) {
|
|
|
|
return NS_ERROR_FAILURE;
|
|
|
|
}
|
|
|
|
|
|
|
|
return NS_OK;
|
|
|
|
}
|
|
|
|
|
|
|
|
static nsresult
|
2012-08-22 08:56:38 -07:00
|
|
|
ParseStringItemAndAdd(JSContext* aCx, JSObject* aArray, uint32_t aIndex, const char* aStart, char** aEnd)
|
2012-07-30 14:59:05 -07:00
|
|
|
{
|
|
|
|
JSString* s;
|
|
|
|
|
|
|
|
if (*aEnd) {
|
|
|
|
s = JS_NewStringCopyN(aCx, aStart, *aEnd - aStart);
|
|
|
|
} else {
|
|
|
|
s = JS_NewStringCopyZ(aCx, aStart);
|
|
|
|
}
|
|
|
|
if (!s) {
|
|
|
|
return NS_ERROR_OUT_OF_MEMORY;
|
|
|
|
}
|
|
|
|
|
|
|
|
jsval v = STRING_TO_JSVAL(s);
|
|
|
|
if (!JS_SetElement(aCx, aArray, aIndex, &v)) {
|
|
|
|
return NS_ERROR_FAILURE;
|
|
|
|
}
|
|
|
|
|
|
|
|
return NS_OK;
|
|
|
|
}
|
|
|
|
|
|
|
|
static nsresult
|
2012-08-22 08:56:38 -07:00
|
|
|
ParseDimensionItemAndAdd(JSContext* aCx, JSObject* aArray, uint32_t aIndex, const char* aStart, char** aEnd)
|
2012-07-30 14:59:05 -07:00
|
|
|
{
|
|
|
|
char* x;
|
|
|
|
|
|
|
|
if (!*aEnd) {
|
|
|
|
// make 'aEnd' follow the same semantics as strchr().
|
|
|
|
aEnd = nullptr;
|
|
|
|
}
|
|
|
|
|
|
|
|
jsval w = INT_TO_JSVAL(strtol(aStart, &x, 10));
|
|
|
|
jsval h = INT_TO_JSVAL(strtol(x + 1, aEnd, 10));
|
|
|
|
|
|
|
|
JSObject* o = JS_NewObject(aCx, nullptr, nullptr, nullptr);
|
|
|
|
if (!o) {
|
|
|
|
return NS_ERROR_OUT_OF_MEMORY;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (!JS_SetProperty(aCx, o, "width", &w)) {
|
|
|
|
return NS_ERROR_FAILURE;
|
|
|
|
}
|
|
|
|
if (!JS_SetProperty(aCx, o, "height", &h)) {
|
|
|
|
return NS_ERROR_FAILURE;
|
|
|
|
}
|
|
|
|
|
|
|
|
jsval v = OBJECT_TO_JSVAL(o);
|
|
|
|
if (!JS_SetElement(aCx, aArray, aIndex, &v)) {
|
|
|
|
return NS_ERROR_FAILURE;
|
|
|
|
}
|
|
|
|
|
|
|
|
return NS_OK;
|
|
|
|
}
|
|
|
|
|
|
|
|
nsresult
|
2012-09-04 18:01:56 -07:00
|
|
|
DOMCameraCapabilities::ParameterListToNewArray(JSContext* aCx, JSObject** aArray, uint32_t aKey, ParseItemAndAddFunc aParseItemAndAdd)
|
2012-07-30 14:59:05 -07:00
|
|
|
{
|
|
|
|
NS_ENSURE_TRUE(mCamera, NS_ERROR_NOT_AVAILABLE);
|
|
|
|
|
2012-07-30 22:45:26 -07:00
|
|
|
const char* value = mCamera->GetParameterConstChar(aKey);
|
2012-07-30 14:59:05 -07:00
|
|
|
if (!value) {
|
|
|
|
// in case we get nonsense data back
|
|
|
|
*aArray = nullptr;
|
|
|
|
return NS_OK;
|
|
|
|
}
|
|
|
|
|
|
|
|
*aArray = JS_NewArrayObject(aCx, 0, nullptr);
|
|
|
|
if (!*aArray) {
|
|
|
|
return NS_ERROR_OUT_OF_MEMORY;
|
|
|
|
}
|
|
|
|
|
|
|
|
const char* p = value;
|
2012-08-22 08:56:38 -07:00
|
|
|
uint32_t index = 0;
|
2012-07-30 14:59:05 -07:00
|
|
|
nsresult rv;
|
|
|
|
char* q;
|
|
|
|
|
|
|
|
while (p) {
|
2012-09-04 18:01:56 -07:00
|
|
|
/**
|
|
|
|
* In C's string.h, strchr() is declared as returning 'char*'; in C++'s
|
|
|
|
* cstring, it is declared as returning 'const char*', _except_ in MSVC,
|
|
|
|
* where the C version is declared to return const like the C++ version.
|
|
|
|
*
|
|
|
|
* Unfortunately, for both cases, strtod() and strtol() take a 'char**' as
|
|
|
|
* the end-of-conversion pointer, so we need to cast away strchr()'s
|
|
|
|
* const-ness here to make the MSVC build everything happy.
|
|
|
|
*/
|
|
|
|
q = const_cast<char*>(strchr(p, ','));
|
2012-07-30 14:59:05 -07:00
|
|
|
if (q != p) { // skip consecutive delimiters, just in case
|
|
|
|
rv = aParseItemAndAdd(aCx, *aArray, index, p, &q);
|
|
|
|
NS_ENSURE_SUCCESS(rv, rv);
|
|
|
|
++index;
|
|
|
|
}
|
|
|
|
p = q;
|
|
|
|
if (p) {
|
|
|
|
++p;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
return JS_FreezeObject(aCx, *aArray) ? NS_OK : NS_ERROR_FAILURE;
|
|
|
|
}
|
|
|
|
|
|
|
|
nsresult
|
2012-09-04 18:01:56 -07:00
|
|
|
DOMCameraCapabilities::StringListToNewObject(JSContext* aCx, JS::Value* aArray, uint32_t aKey)
|
2012-07-30 14:59:05 -07:00
|
|
|
{
|
|
|
|
JSObject* array;
|
|
|
|
|
|
|
|
nsresult rv = ParameterListToNewArray(aCx, &array, aKey, ParseStringItemAndAdd);
|
|
|
|
NS_ENSURE_SUCCESS(rv, rv);
|
|
|
|
|
|
|
|
*aArray = OBJECT_TO_JSVAL(array);
|
|
|
|
return NS_OK;
|
|
|
|
}
|
|
|
|
|
|
|
|
nsresult
|
2012-09-04 18:01:56 -07:00
|
|
|
DOMCameraCapabilities::DimensionListToNewObject(JSContext* aCx, JS::Value* aArray, uint32_t aKey)
|
2012-07-30 14:59:05 -07:00
|
|
|
{
|
|
|
|
JSObject* array;
|
|
|
|
nsresult rv;
|
|
|
|
|
|
|
|
rv = ParameterListToNewArray(aCx, &array, aKey, ParseDimensionItemAndAdd);
|
|
|
|
NS_ENSURE_SUCCESS(rv, rv);
|
|
|
|
|
|
|
|
*aArray = OBJECT_TO_JSVAL(array);
|
|
|
|
return NS_OK;
|
|
|
|
}
|
|
|
|
|
|
|
|
/* readonly attribute jsval previewSizes; */
|
|
|
|
NS_IMETHODIMP
|
2012-09-04 18:01:56 -07:00
|
|
|
DOMCameraCapabilities::GetPreviewSizes(JSContext* cx, JS::Value* aPreviewSizes)
|
2012-07-30 14:59:05 -07:00
|
|
|
{
|
2012-09-04 18:01:56 -07:00
|
|
|
return DimensionListToNewObject(cx, aPreviewSizes, CAMERA_PARAM_SUPPORTED_PREVIEWSIZES);
|
2012-07-30 14:59:05 -07:00
|
|
|
}
|
|
|
|
|
|
|
|
/* readonly attribute jsval pictureSizes; */
|
|
|
|
NS_IMETHODIMP
|
2012-09-04 18:01:56 -07:00
|
|
|
DOMCameraCapabilities::GetPictureSizes(JSContext* cx, JS::Value* aPictureSizes)
|
2012-07-30 14:59:05 -07:00
|
|
|
{
|
2012-09-04 18:01:56 -07:00
|
|
|
return DimensionListToNewObject(cx, aPictureSizes, CAMERA_PARAM_SUPPORTED_PICTURESIZES);
|
2012-07-30 14:59:05 -07:00
|
|
|
}
|
|
|
|
|
|
|
|
/* readonly attribute jsval fileFormats; */
|
|
|
|
NS_IMETHODIMP
|
2012-09-04 18:01:56 -07:00
|
|
|
DOMCameraCapabilities::GetFileFormats(JSContext* cx, JS::Value* aFileFormats)
|
2012-07-30 14:59:05 -07:00
|
|
|
{
|
2012-09-04 18:01:56 -07:00
|
|
|
return StringListToNewObject(cx, aFileFormats, CAMERA_PARAM_SUPPORTED_PICTUREFORMATS);
|
2012-07-30 14:59:05 -07:00
|
|
|
}
|
|
|
|
|
|
|
|
/* readonly attribute jsval whiteBalanceModes; */
|
|
|
|
NS_IMETHODIMP
|
2012-09-04 18:01:56 -07:00
|
|
|
DOMCameraCapabilities::GetWhiteBalanceModes(JSContext* cx, JS::Value* aWhiteBalanceModes)
|
2012-07-30 14:59:05 -07:00
|
|
|
{
|
2012-09-04 18:01:56 -07:00
|
|
|
return StringListToNewObject(cx, aWhiteBalanceModes, CAMERA_PARAM_SUPPORTED_WHITEBALANCES);
|
2012-07-30 14:59:05 -07:00
|
|
|
}
|
|
|
|
|
|
|
|
/* readonly attribute jsval sceneModes; */
|
|
|
|
NS_IMETHODIMP
|
2012-09-04 18:01:56 -07:00
|
|
|
DOMCameraCapabilities::GetSceneModes(JSContext* cx, JS::Value* aSceneModes)
|
2012-07-30 14:59:05 -07:00
|
|
|
{
|
2012-09-04 18:01:56 -07:00
|
|
|
return StringListToNewObject(cx, aSceneModes, CAMERA_PARAM_SUPPORTED_SCENEMODES);
|
2012-07-30 14:59:05 -07:00
|
|
|
}
|
|
|
|
|
|
|
|
/* readonly attribute jsval effects; */
|
|
|
|
NS_IMETHODIMP
|
2012-09-04 18:01:56 -07:00
|
|
|
DOMCameraCapabilities::GetEffects(JSContext* cx, JS::Value* aEffects)
|
2012-07-30 14:59:05 -07:00
|
|
|
{
|
2012-09-04 18:01:56 -07:00
|
|
|
return StringListToNewObject(cx, aEffects, CAMERA_PARAM_SUPPORTED_EFFECTS);
|
2012-07-30 14:59:05 -07:00
|
|
|
}
|
|
|
|
|
|
|
|
/* readonly attribute jsval flashModes; */
|
|
|
|
NS_IMETHODIMP
|
2012-09-04 18:01:56 -07:00
|
|
|
DOMCameraCapabilities::GetFlashModes(JSContext* cx, JS::Value* aFlashModes)
|
2012-07-30 14:59:05 -07:00
|
|
|
{
|
2012-09-04 18:01:56 -07:00
|
|
|
return StringListToNewObject(cx, aFlashModes, CAMERA_PARAM_SUPPORTED_FLASHMODES);
|
2012-07-30 14:59:05 -07:00
|
|
|
}
|
|
|
|
|
|
|
|
/* readonly attribute jsval focusModes; */
|
|
|
|
NS_IMETHODIMP
|
2012-09-04 18:01:56 -07:00
|
|
|
DOMCameraCapabilities::GetFocusModes(JSContext* cx, JS::Value* aFocusModes)
|
2012-07-30 14:59:05 -07:00
|
|
|
{
|
2012-09-04 18:01:56 -07:00
|
|
|
return StringListToNewObject(cx, aFocusModes, CAMERA_PARAM_SUPPORTED_FOCUSMODES);
|
2012-07-30 14:59:05 -07:00
|
|
|
}
|
|
|
|
|
|
|
|
/* readonly attribute long maxFocusAreas; */
|
|
|
|
NS_IMETHODIMP
|
2012-09-04 18:01:56 -07:00
|
|
|
DOMCameraCapabilities::GetMaxFocusAreas(JSContext* cx, int32_t* aMaxFocusAreas)
|
2012-07-30 14:59:05 -07:00
|
|
|
{
|
|
|
|
NS_ENSURE_TRUE(mCamera, NS_ERROR_NOT_AVAILABLE);
|
|
|
|
|
2012-09-04 18:01:56 -07:00
|
|
|
const char* value = mCamera->GetParameterConstChar(CAMERA_PARAM_SUPPORTED_MAXFOCUSAREAS);
|
2012-07-30 14:59:05 -07:00
|
|
|
if (!value) {
|
|
|
|
// in case we get nonsense data back
|
|
|
|
*aMaxFocusAreas = 0;
|
|
|
|
return NS_OK;
|
|
|
|
}
|
|
|
|
|
|
|
|
*aMaxFocusAreas = atoi(value);
|
|
|
|
return NS_OK;
|
|
|
|
}
|
|
|
|
|
|
|
|
/* readonly attribute double minExposureCompensation; */
|
|
|
|
NS_IMETHODIMP
|
2012-09-04 18:01:56 -07:00
|
|
|
DOMCameraCapabilities::GetMinExposureCompensation(JSContext* cx, double* aMinExposureCompensation)
|
2012-07-30 14:59:05 -07:00
|
|
|
{
|
|
|
|
NS_ENSURE_TRUE(mCamera, NS_ERROR_NOT_AVAILABLE);
|
|
|
|
|
2012-09-04 18:01:56 -07:00
|
|
|
const char* value = mCamera->GetParameterConstChar(CAMERA_PARAM_SUPPORTED_MINEXPOSURECOMPENSATION);
|
2012-07-30 14:59:05 -07:00
|
|
|
if (!value) {
|
|
|
|
// in case we get nonsense data back
|
|
|
|
*aMinExposureCompensation = 0;
|
|
|
|
return NS_OK;
|
|
|
|
}
|
|
|
|
|
|
|
|
*aMinExposureCompensation = atof(value);
|
|
|
|
return NS_OK;
|
|
|
|
}
|
|
|
|
|
|
|
|
/* readonly attribute double maxExposureCompensation; */
|
|
|
|
NS_IMETHODIMP
|
2012-09-04 18:01:56 -07:00
|
|
|
DOMCameraCapabilities::GetMaxExposureCompensation(JSContext* cx, double* aMaxExposureCompensation)
|
2012-07-30 14:59:05 -07:00
|
|
|
{
|
|
|
|
NS_ENSURE_TRUE(mCamera, NS_ERROR_NOT_AVAILABLE);
|
|
|
|
|
2012-09-04 18:01:56 -07:00
|
|
|
const char* value = mCamera->GetParameterConstChar(CAMERA_PARAM_SUPPORTED_MAXEXPOSURECOMPENSATION);
|
2012-07-30 14:59:05 -07:00
|
|
|
if (!value) {
|
|
|
|
// in case we get nonsense data back
|
|
|
|
*aMaxExposureCompensation = 0;
|
|
|
|
return NS_OK;
|
|
|
|
}
|
|
|
|
|
|
|
|
*aMaxExposureCompensation = atof(value);
|
|
|
|
return NS_OK;
|
|
|
|
}
|
|
|
|
|
|
|
|
/* readonly attribute double stepExposureCompensation; */
|
|
|
|
NS_IMETHODIMP
|
2012-09-04 18:01:56 -07:00
|
|
|
DOMCameraCapabilities::GetStepExposureCompensation(JSContext* cx, double* aStepExposureCompensation)
|
2012-07-30 14:59:05 -07:00
|
|
|
{
|
|
|
|
NS_ENSURE_TRUE(mCamera, NS_ERROR_NOT_AVAILABLE);
|
|
|
|
|
2012-09-04 18:01:56 -07:00
|
|
|
const char* value = mCamera->GetParameterConstChar(CAMERA_PARAM_SUPPORTED_EXPOSURECOMPENSATIONSTEP);
|
2012-07-30 14:59:05 -07:00
|
|
|
if (!value) {
|
|
|
|
// in case we get nonsense data back
|
|
|
|
*aStepExposureCompensation = 0;
|
|
|
|
return NS_OK;
|
|
|
|
}
|
|
|
|
|
|
|
|
*aStepExposureCompensation = atof(value);
|
|
|
|
return NS_OK;
|
|
|
|
}
|
|
|
|
|
|
|
|
/* readonly attribute long maxMeteringAreas; */
|
|
|
|
NS_IMETHODIMP
|
2012-09-04 18:01:56 -07:00
|
|
|
DOMCameraCapabilities::GetMaxMeteringAreas(JSContext* cx, int32_t* aMaxMeteringAreas)
|
2012-07-30 14:59:05 -07:00
|
|
|
{
|
|
|
|
NS_ENSURE_TRUE(mCamera, NS_ERROR_NOT_AVAILABLE);
|
|
|
|
|
2012-09-04 18:01:56 -07:00
|
|
|
const char* value = mCamera->GetParameterConstChar(CAMERA_PARAM_SUPPORTED_MAXMETERINGAREAS);
|
2012-07-30 14:59:05 -07:00
|
|
|
if (!value) {
|
|
|
|
// in case we get nonsense data back
|
|
|
|
*aMaxMeteringAreas = 0;
|
|
|
|
return NS_OK;
|
|
|
|
}
|
|
|
|
|
|
|
|
*aMaxMeteringAreas = atoi(value);
|
|
|
|
return NS_OK;
|
|
|
|
}
|
|
|
|
|
|
|
|
/* readonly attribute jsval zoomRatios; */
|
|
|
|
NS_IMETHODIMP
|
2012-09-04 18:01:56 -07:00
|
|
|
DOMCameraCapabilities::GetZoomRatios(JSContext* cx, JS::Value* aZoomRatios)
|
2012-07-30 14:59:05 -07:00
|
|
|
{
|
|
|
|
NS_ENSURE_TRUE(mCamera, NS_ERROR_NOT_AVAILABLE);
|
|
|
|
|
2012-09-04 18:01:56 -07:00
|
|
|
const char* value = mCamera->GetParameterConstChar(CAMERA_PARAM_SUPPORTED_ZOOM);
|
|
|
|
if (!value || strcmp(value, "true") != 0) {
|
2012-07-30 14:59:05 -07:00
|
|
|
// if zoom is not supported, return a null object
|
|
|
|
*aZoomRatios = JSVAL_NULL;
|
|
|
|
return NS_OK;
|
|
|
|
}
|
|
|
|
|
|
|
|
JSObject* array;
|
|
|
|
|
2012-09-04 18:01:56 -07:00
|
|
|
nsresult rv = ParameterListToNewArray(cx, &array, CAMERA_PARAM_SUPPORTED_ZOOMRATIOS, ParseZoomRatioItemAndAdd);
|
2012-07-30 14:59:05 -07:00
|
|
|
NS_ENSURE_SUCCESS(rv, rv);
|
|
|
|
|
|
|
|
*aZoomRatios = OBJECT_TO_JSVAL(array);
|
|
|
|
return NS_OK;
|
|
|
|
}
|
|
|
|
|
|
|
|
/* readonly attribute jsval videoSizes; */
|
|
|
|
NS_IMETHODIMP
|
2012-09-04 18:01:56 -07:00
|
|
|
DOMCameraCapabilities::GetVideoSizes(JSContext* cx, JS::Value* aVideoSizes)
|
2012-07-30 14:59:05 -07:00
|
|
|
{
|
2012-10-23 15:30:28 -07:00
|
|
|
NS_ENSURE_TRUE(mCamera, NS_ERROR_NOT_AVAILABLE);
|
|
|
|
|
2013-02-11 11:37:50 -08:00
|
|
|
nsTArray<mozilla::idl::CameraSize> sizes;
|
2012-10-23 15:30:28 -07:00
|
|
|
nsresult rv = mCamera->GetVideoSizes(sizes);
|
|
|
|
NS_ENSURE_SUCCESS(rv, rv);
|
|
|
|
if (sizes.Length() == 0) {
|
|
|
|
// video recording not supported, return a null object
|
|
|
|
*aVideoSizes = JSVAL_NULL;
|
|
|
|
return NS_OK;
|
|
|
|
}
|
|
|
|
|
|
|
|
JSObject* array = JS_NewArrayObject(cx, 0, nullptr);
|
|
|
|
if (!array) {
|
|
|
|
return NS_ERROR_OUT_OF_MEMORY;
|
|
|
|
}
|
|
|
|
|
|
|
|
for (uint32_t i = 0; i < sizes.Length(); ++i) {
|
|
|
|
JSObject* o = JS_NewObject(cx, nullptr, nullptr, nullptr);
|
|
|
|
jsval v = INT_TO_JSVAL(sizes[i].width);
|
|
|
|
if (!JS_SetProperty(cx, o, "width", &v)) {
|
|
|
|
return NS_ERROR_FAILURE;
|
|
|
|
}
|
|
|
|
v = INT_TO_JSVAL(sizes[i].height);
|
|
|
|
if (!JS_SetProperty(cx, o, "height", &v)) {
|
|
|
|
return NS_ERROR_FAILURE;
|
|
|
|
}
|
|
|
|
|
|
|
|
v = OBJECT_TO_JSVAL(o);
|
|
|
|
if (!JS_SetElement(cx, array, i, &v)) {
|
|
|
|
return NS_ERROR_FAILURE;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
*aVideoSizes = OBJECT_TO_JSVAL(array);
|
|
|
|
return NS_OK;
|
|
|
|
}
|
|
|
|
|
|
|
|
/* readonly attribute jsval recorderProfiles; */
|
|
|
|
NS_IMETHODIMP
|
|
|
|
DOMCameraCapabilities::GetRecorderProfiles(JSContext* cx, JS::Value* aRecorderProfiles)
|
|
|
|
{
|
|
|
|
NS_ENSURE_TRUE(mCamera, NS_ERROR_NOT_AVAILABLE);
|
|
|
|
|
|
|
|
nsRefPtr<RecorderProfileManager> profileMgr = mCamera->GetRecorderProfileManager();
|
|
|
|
if (!profileMgr) {
|
|
|
|
*aRecorderProfiles = JSVAL_NULL;
|
|
|
|
return NS_OK;
|
|
|
|
}
|
|
|
|
|
|
|
|
JSObject* o = nullptr; // keeps the compiler from emitting a warning
|
|
|
|
nsresult rv = profileMgr->GetJsObject(cx, &o);
|
|
|
|
NS_ENSURE_SUCCESS(rv, rv);
|
|
|
|
|
|
|
|
*aRecorderProfiles = OBJECT_TO_JSVAL(o);
|
|
|
|
return NS_OK;
|
2012-07-30 14:59:05 -07:00
|
|
|
}
|