Merge b-i to m-c, a=merge

This commit is contained in:
Phil Ringnalda 2014-11-15 15:16:34 -08:00
commit 9c3b7c2e85
17 changed files with 295 additions and 128 deletions

View File

@ -15,7 +15,7 @@
<project name="platform_build" path="build" remote="b2g" revision="3ab0d9c70f0b2e1ededc679112c392303f037361">
<copyfile dest="Makefile" src="core/root.mk"/>
</project>
<project name="gaia" path="gaia" remote="mozillaorg" revision="ccda843399fe0d26fac7747fd787e5fe2e8dfdf7"/>
<project name="gaia" path="gaia" remote="mozillaorg" revision="1dd8ad8f96988afebc9691e1b818fa37aa32c790"/>
<project name="fake-libdvm" path="dalvik" remote="b2g" revision="d50ae982b19f42f0b66d08b9eb306be81687869f"/>
<project name="gonk-misc" path="gonk-misc" remote="b2g" revision="45c54a55e31758f7e54e5eafe0d01d387f35897a"/>
<project name="librecovery" path="librecovery" remote="b2g" revision="891e5069c0ad330d8191bf8c7b879c814258c89f"/>
@ -23,7 +23,7 @@
<project name="rilproxy" path="rilproxy" remote="b2g" revision="827214fcf38d6569aeb5c6d6f31cb296d1f09272"/>
<project name="valgrind" path="external/valgrind" remote="b2g" revision="daa61633c32b9606f58799a3186395fd2bbb8d8c"/>
<project name="vex" path="external/VEX" remote="b2g" revision="47f031c320888fe9f3e656602588565b52d43010"/>
<project name="apitrace" path="external/apitrace" remote="apitrace" revision="ec7f77a328cb8bddd1907f90d16865a986bb4fef"/>
<project name="apitrace" path="external/apitrace" remote="apitrace" revision="11ad0ea69796915552c9bae148d81fddf9856ddb"/>
<!-- Stock Android things -->
<project groups="linux" name="platform/prebuilts/gcc/linux-x86/host/i686-linux-glibc2.7-4.6" path="prebuilts/gcc/linux-x86/host/i686-linux-glibc2.7-4.6" revision="95bb5b66b3ec5769c3de8d3f25d681787418e7d2"/>
<project groups="linux" name="platform/prebuilts/gcc/linux-x86/host/x86_64-linux-glibc2.7-4.6" path="prebuilts/gcc/linux-x86/host/x86_64-linux-glibc2.7-4.6" revision="ebdad82e61c16772f6cd47e9f11936bf6ebe9aa0"/>

View File

@ -19,13 +19,13 @@
<copyfile dest="Makefile" src="core/root.mk"/>
</project>
<project name="fake-dalvik" path="dalvik" remote="b2g" revision="ca1f327d5acc198bb4be62fa51db2c039032c9ce"/>
<project name="gaia.git" path="gaia" remote="mozillaorg" revision="ccda843399fe0d26fac7747fd787e5fe2e8dfdf7"/>
<project name="gaia.git" path="gaia" remote="mozillaorg" revision="1dd8ad8f96988afebc9691e1b818fa37aa32c790"/>
<project name="gonk-misc" path="gonk-misc" remote="b2g" revision="45c54a55e31758f7e54e5eafe0d01d387f35897a"/>
<project name="rilproxy" path="rilproxy" remote="b2g" revision="827214fcf38d6569aeb5c6d6f31cb296d1f09272"/>
<project name="platform_hardware_ril" path="hardware/ril" remote="b2g" revision="cd88d860656c31c7da7bb310d6a160d0011b0961"/>
<project name="platform_external_qemu" path="external/qemu" remote="b2g" revision="67f2907bc340bad250b4ea6ce2902b52896c9ef0"/>
<project name="moztt" path="external/moztt" remote="b2g" revision="fe893bb760a3bb64375f62fdf4762a58c59df9ef"/>
<project name="apitrace" path="external/apitrace" remote="apitrace" revision="ec7f77a328cb8bddd1907f90d16865a986bb4fef"/>
<project name="apitrace" path="external/apitrace" remote="apitrace" revision="11ad0ea69796915552c9bae148d81fddf9856ddb"/>
<!-- Stock Android things -->
<project name="platform/abi/cpp" path="abi/cpp" revision="dd924f92906085b831bf1cbbc7484d3c043d613c"/>
<project name="platform/bionic" path="bionic" revision="c72b8f6359de7ed17c11ddc9dfdde3f615d188a9"/>

View File

@ -17,10 +17,10 @@
</project>
<project name="rilproxy" path="rilproxy" remote="b2g" revision="827214fcf38d6569aeb5c6d6f31cb296d1f09272"/>
<project name="fake-libdvm" path="dalvik" remote="b2g" revision="d50ae982b19f42f0b66d08b9eb306be81687869f"/>
<project name="gaia" path="gaia" remote="mozillaorg" revision="ccda843399fe0d26fac7747fd787e5fe2e8dfdf7"/>
<project name="gaia" path="gaia" remote="mozillaorg" revision="1dd8ad8f96988afebc9691e1b818fa37aa32c790"/>
<project name="gonk-misc" path="gonk-misc" remote="b2g" revision="45c54a55e31758f7e54e5eafe0d01d387f35897a"/>
<project name="moztt" path="external/moztt" remote="b2g" revision="fe893bb760a3bb64375f62fdf4762a58c59df9ef"/>
<project name="apitrace" path="external/apitrace" remote="apitrace" revision="ec7f77a328cb8bddd1907f90d16865a986bb4fef"/>
<project name="apitrace" path="external/apitrace" remote="apitrace" revision="11ad0ea69796915552c9bae148d81fddf9856ddb"/>
<project name="valgrind" path="external/valgrind" remote="b2g" revision="daa61633c32b9606f58799a3186395fd2bbb8d8c"/>
<project name="vex" path="external/VEX" remote="b2g" revision="47f031c320888fe9f3e656602588565b52d43010"/>
<!-- Stock Android things -->

View File

@ -15,7 +15,7 @@
<project name="platform_build" path="build" remote="b2g" revision="3ab0d9c70f0b2e1ededc679112c392303f037361">
<copyfile dest="Makefile" src="core/root.mk"/>
</project>
<project name="gaia" path="gaia" remote="mozillaorg" revision="ccda843399fe0d26fac7747fd787e5fe2e8dfdf7"/>
<project name="gaia" path="gaia" remote="mozillaorg" revision="1dd8ad8f96988afebc9691e1b818fa37aa32c790"/>
<project name="fake-libdvm" path="dalvik" remote="b2g" revision="d50ae982b19f42f0b66d08b9eb306be81687869f"/>
<project name="gonk-misc" path="gonk-misc" remote="b2g" revision="45c54a55e31758f7e54e5eafe0d01d387f35897a"/>
<project name="librecovery" path="librecovery" remote="b2g" revision="891e5069c0ad330d8191bf8c7b879c814258c89f"/>
@ -23,7 +23,7 @@
<project name="rilproxy" path="rilproxy" remote="b2g" revision="827214fcf38d6569aeb5c6d6f31cb296d1f09272"/>
<project name="valgrind" path="external/valgrind" remote="b2g" revision="daa61633c32b9606f58799a3186395fd2bbb8d8c"/>
<project name="vex" path="external/VEX" remote="b2g" revision="47f031c320888fe9f3e656602588565b52d43010"/>
<project name="apitrace" path="external/apitrace" remote="apitrace" revision="ec7f77a328cb8bddd1907f90d16865a986bb4fef"/>
<project name="apitrace" path="external/apitrace" remote="apitrace" revision="11ad0ea69796915552c9bae148d81fddf9856ddb"/>
<!-- Stock Android things -->
<project groups="linux" name="platform/prebuilts/gcc/linux-x86/host/i686-linux-glibc2.7-4.6" path="prebuilts/gcc/linux-x86/host/i686-linux-glibc2.7-4.6" revision="f92a936f2aa97526d4593386754bdbf02db07a12"/>
<project groups="linux" name="platform/prebuilts/gcc/linux-x86/host/x86_64-linux-glibc2.7-4.6" path="prebuilts/gcc/linux-x86/host/x86_64-linux-glibc2.7-4.6" revision="6e47ff2790f5656b5b074407829ceecf3e6188c4"/>

View File

@ -19,13 +19,13 @@
<copyfile dest="Makefile" src="core/root.mk"/>
</project>
<project name="fake-dalvik" path="dalvik" remote="b2g" revision="ca1f327d5acc198bb4be62fa51db2c039032c9ce"/>
<project name="gaia.git" path="gaia" remote="mozillaorg" revision="ccda843399fe0d26fac7747fd787e5fe2e8dfdf7"/>
<project name="gaia.git" path="gaia" remote="mozillaorg" revision="1dd8ad8f96988afebc9691e1b818fa37aa32c790"/>
<project name="gonk-misc" path="gonk-misc" remote="b2g" revision="45c54a55e31758f7e54e5eafe0d01d387f35897a"/>
<project name="rilproxy" path="rilproxy" remote="b2g" revision="827214fcf38d6569aeb5c6d6f31cb296d1f09272"/>
<project name="platform_hardware_ril" path="hardware/ril" remote="b2g" revision="cd88d860656c31c7da7bb310d6a160d0011b0961"/>
<project name="platform_external_qemu" path="external/qemu" remote="b2g" revision="67f2907bc340bad250b4ea6ce2902b52896c9ef0"/>
<project name="moztt" path="external/moztt" remote="b2g" revision="fe893bb760a3bb64375f62fdf4762a58c59df9ef"/>
<project name="apitrace" path="external/apitrace" remote="apitrace" revision="ec7f77a328cb8bddd1907f90d16865a986bb4fef"/>
<project name="apitrace" path="external/apitrace" remote="apitrace" revision="11ad0ea69796915552c9bae148d81fddf9856ddb"/>
<!-- Stock Android things -->
<project name="platform/abi/cpp" path="abi/cpp" revision="dd924f92906085b831bf1cbbc7484d3c043d613c"/>
<project name="platform/bionic" path="bionic" revision="c72b8f6359de7ed17c11ddc9dfdde3f615d188a9"/>

View File

@ -15,7 +15,7 @@
<project name="platform_build" path="build" remote="b2g" revision="3ab0d9c70f0b2e1ededc679112c392303f037361">
<copyfile dest="Makefile" src="core/root.mk"/>
</project>
<project name="gaia" path="gaia" remote="mozillaorg" revision="ccda843399fe0d26fac7747fd787e5fe2e8dfdf7"/>
<project name="gaia" path="gaia" remote="mozillaorg" revision="1dd8ad8f96988afebc9691e1b818fa37aa32c790"/>
<project name="fake-libdvm" path="dalvik" remote="b2g" revision="d50ae982b19f42f0b66d08b9eb306be81687869f"/>
<project name="gonk-misc" path="gonk-misc" remote="b2g" revision="45c54a55e31758f7e54e5eafe0d01d387f35897a"/>
<project name="librecovery" path="librecovery" remote="b2g" revision="891e5069c0ad330d8191bf8c7b879c814258c89f"/>
@ -23,7 +23,7 @@
<project name="rilproxy" path="rilproxy" remote="b2g" revision="827214fcf38d6569aeb5c6d6f31cb296d1f09272"/>
<project name="valgrind" path="external/valgrind" remote="b2g" revision="daa61633c32b9606f58799a3186395fd2bbb8d8c"/>
<project name="vex" path="external/VEX" remote="b2g" revision="47f031c320888fe9f3e656602588565b52d43010"/>
<project name="apitrace" path="external/apitrace" remote="apitrace" revision="ec7f77a328cb8bddd1907f90d16865a986bb4fef"/>
<project name="apitrace" path="external/apitrace" remote="apitrace" revision="11ad0ea69796915552c9bae148d81fddf9856ddb"/>
<!-- Stock Android things -->
<project groups="linux" name="platform/prebuilts/gcc/linux-x86/host/i686-linux-glibc2.7-4.6" path="prebuilts/gcc/linux-x86/host/i686-linux-glibc2.7-4.6" revision="95bb5b66b3ec5769c3de8d3f25d681787418e7d2"/>
<project groups="linux" name="platform/prebuilts/gcc/linux-x86/host/x86_64-linux-glibc2.7-4.6" path="prebuilts/gcc/linux-x86/host/x86_64-linux-glibc2.7-4.6" revision="ebdad82e61c16772f6cd47e9f11936bf6ebe9aa0"/>

View File

@ -17,10 +17,10 @@
</project>
<project name="librecovery" path="librecovery" remote="b2g" revision="891e5069c0ad330d8191bf8c7b879c814258c89f"/>
<project name="fake-libdvm" path="dalvik" remote="b2g" revision="d50ae982b19f42f0b66d08b9eb306be81687869f"/>
<project name="gaia" path="gaia" remote="mozillaorg" revision="ccda843399fe0d26fac7747fd787e5fe2e8dfdf7"/>
<project name="gaia" path="gaia" remote="mozillaorg" revision="1dd8ad8f96988afebc9691e1b818fa37aa32c790"/>
<project name="gonk-misc" path="gonk-misc" remote="b2g" revision="45c54a55e31758f7e54e5eafe0d01d387f35897a"/>
<project name="moztt" path="external/moztt" remote="b2g" revision="fe893bb760a3bb64375f62fdf4762a58c59df9ef"/>
<project name="apitrace" path="external/apitrace" remote="apitrace" revision="ec7f77a328cb8bddd1907f90d16865a986bb4fef"/>
<project name="apitrace" path="external/apitrace" remote="apitrace" revision="11ad0ea69796915552c9bae148d81fddf9856ddb"/>
<project name="valgrind" path="external/valgrind" remote="b2g" revision="daa61633c32b9606f58799a3186395fd2bbb8d8c"/>
<project name="vex" path="external/VEX" remote="b2g" revision="47f031c320888fe9f3e656602588565b52d43010"/>
<!-- Stock Android things -->

View File

@ -4,6 +4,6 @@
"remote": "",
"branch": ""
},
"revision": "1f41a654b3311705e7d71ff9b2137d3340c6c272",
"revision": "eba399d3ba9724c77e073adccc0dfe9f8169dceb",
"repo_path": "integration/gaia-central"
}

View File

@ -17,11 +17,11 @@
<copyfile dest="Makefile" src="core/root.mk"/>
</project>
<project name="fake-dalvik" path="dalvik" remote="b2g" revision="ca1f327d5acc198bb4be62fa51db2c039032c9ce"/>
<project name="gaia.git" path="gaia" remote="mozillaorg" revision="ccda843399fe0d26fac7747fd787e5fe2e8dfdf7"/>
<project name="gaia.git" path="gaia" remote="mozillaorg" revision="1dd8ad8f96988afebc9691e1b818fa37aa32c790"/>
<project name="gonk-misc" path="gonk-misc" remote="b2g" revision="45c54a55e31758f7e54e5eafe0d01d387f35897a"/>
<project name="librecovery" path="librecovery" remote="b2g" revision="891e5069c0ad330d8191bf8c7b879c814258c89f"/>
<project name="moztt" path="external/moztt" remote="b2g" revision="fe893bb760a3bb64375f62fdf4762a58c59df9ef"/>
<project name="apitrace" path="external/apitrace" remote="apitrace" revision="ec7f77a328cb8bddd1907f90d16865a986bb4fef"/>
<project name="apitrace" path="external/apitrace" remote="apitrace" revision="11ad0ea69796915552c9bae148d81fddf9856ddb"/>
<!-- Stock Android things -->
<project name="platform/abi/cpp" path="abi/cpp" revision="6426040f1be4a844082c9769171ce7f5341a5528"/>
<project name="platform/bionic" path="bionic" revision="d2eb6c7b6e1bc7643c17df2d9d9bcb1704d0b9ab"/>

View File

@ -15,7 +15,7 @@
<copyfile dest="Makefile" src="core/root.mk"/>
</project>
<project name="fake-dalvik" path="dalvik" remote="b2g" revision="ca1f327d5acc198bb4be62fa51db2c039032c9ce"/>
<project name="gaia.git" path="gaia" remote="mozillaorg" revision="ccda843399fe0d26fac7747fd787e5fe2e8dfdf7"/>
<project name="gaia.git" path="gaia" remote="mozillaorg" revision="1dd8ad8f96988afebc9691e1b818fa37aa32c790"/>
<project name="gonk-misc" path="gonk-misc" remote="b2g" revision="45c54a55e31758f7e54e5eafe0d01d387f35897a"/>
<project name="rilproxy" path="rilproxy" remote="b2g" revision="827214fcf38d6569aeb5c6d6f31cb296d1f09272"/>
<project name="librecovery" path="librecovery" remote="b2g" revision="891e5069c0ad330d8191bf8c7b879c814258c89f"/>

View File

@ -17,10 +17,10 @@
</project>
<project name="rilproxy" path="rilproxy" remote="b2g" revision="827214fcf38d6569aeb5c6d6f31cb296d1f09272"/>
<project name="fake-libdvm" path="dalvik" remote="b2g" revision="d50ae982b19f42f0b66d08b9eb306be81687869f"/>
<project name="gaia" path="gaia" remote="mozillaorg" revision="ccda843399fe0d26fac7747fd787e5fe2e8dfdf7"/>
<project name="gaia" path="gaia" remote="mozillaorg" revision="1dd8ad8f96988afebc9691e1b818fa37aa32c790"/>
<project name="gonk-misc" path="gonk-misc" remote="b2g" revision="45c54a55e31758f7e54e5eafe0d01d387f35897a"/>
<project name="moztt" path="external/moztt" remote="b2g" revision="fe893bb760a3bb64375f62fdf4762a58c59df9ef"/>
<project name="apitrace" path="external/apitrace" remote="apitrace" revision="ec7f77a328cb8bddd1907f90d16865a986bb4fef"/>
<project name="apitrace" path="external/apitrace" remote="apitrace" revision="11ad0ea69796915552c9bae148d81fddf9856ddb"/>
<project name="valgrind" path="external/valgrind" remote="b2g" revision="daa61633c32b9606f58799a3186395fd2bbb8d8c"/>
<project name="vex" path="external/VEX" remote="b2g" revision="47f031c320888fe9f3e656602588565b52d43010"/>
<!-- Stock Android things -->

View File

@ -17,12 +17,12 @@
<copyfile dest="Makefile" src="core/root.mk"/>
</project>
<project name="fake-dalvik" path="dalvik" remote="b2g" revision="ca1f327d5acc198bb4be62fa51db2c039032c9ce"/>
<project name="gaia.git" path="gaia" remote="mozillaorg" revision="ccda843399fe0d26fac7747fd787e5fe2e8dfdf7"/>
<project name="gaia.git" path="gaia" remote="mozillaorg" revision="1dd8ad8f96988afebc9691e1b818fa37aa32c790"/>
<project name="gonk-misc" path="gonk-misc" remote="b2g" revision="45c54a55e31758f7e54e5eafe0d01d387f35897a"/>
<project name="rilproxy" path="rilproxy" remote="b2g" revision="827214fcf38d6569aeb5c6d6f31cb296d1f09272"/>
<project name="librecovery" path="librecovery" remote="b2g" revision="891e5069c0ad330d8191bf8c7b879c814258c89f"/>
<project name="moztt" path="external/moztt" remote="b2g" revision="fe893bb760a3bb64375f62fdf4762a58c59df9ef"/>
<project name="apitrace" path="external/apitrace" remote="apitrace" revision="ec7f77a328cb8bddd1907f90d16865a986bb4fef"/>
<project name="apitrace" path="external/apitrace" remote="apitrace" revision="11ad0ea69796915552c9bae148d81fddf9856ddb"/>
<project name="gonk-patches" path="patches" remote="b2g" revision="223a2421006e8f5da33f516f6891c87cae86b0f6"/>
<!-- Stock Android things -->
<project name="platform/abi/cpp" path="abi/cpp" revision="6426040f1be4a844082c9769171ce7f5341a5528"/>

View File

@ -84,7 +84,7 @@ CameraControlImpl::OnHardwareStateChange(CameraControlListener::HardwareState aN
}
#ifdef PR_LOGGING
const char* state[] = { "open", "closed", "failed" };
const char* state[] = { "closed", "open", "failed" };
MOZ_ASSERT(aNewState >= 0);
if (static_cast<unsigned int>(aNewState) < sizeof(state) / sizeof(state[0])) {
DOM_CAMERA_LOGI("New hardware state is '%s'\n", state[aNewState]);

View File

@ -313,22 +313,114 @@ nsGonkCameraControl::SetConfigurationImpl(const Configuration& aConfig)
return StartPreviewImpl();
}
nsresult
nsGonkCameraControl::MaybeAdjustVideoSize()
{
MOZ_ASSERT(NS_GetCurrentThread() == mCameraThread);
MOZ_ASSERT(mSeparateVideoAndPreviewSizesSupported);
const Size& preview = mCurrentConfiguration.mPreviewSize;
// Some camera drivers will ignore our preview size if it's larger
// than the currently set video recording size, so in picture mode, we
// give preview size priority, and bump up the video size just in case.
// This is done on a best-effort basis.
if (preview.width <= mLastRecorderSize.width &&
preview.height <= mLastRecorderSize.height) {
DOM_CAMERA_LOGI("Video size %ux%u is suitable for preview size %ux%u\n",
mLastRecorderSize.width, mLastRecorderSize.height,
preview.width, preview.height);
return NS_OK;
}
nsTArray<Size> sizes;
nsresult rv = Get(CAMERA_PARAM_SUPPORTED_VIDEOSIZES, sizes);
if (NS_WARN_IF(NS_FAILED(rv))) {
return rv;
}
const uint32_t previewArea = preview.width * preview.height;
uint32_t bestDelta = UINT32_MAX;
bool foundBest = false;
SizeIndex best;
for (SizeIndex i = 0; i < sizes.Length(); ++i) {
const Size& s = sizes[i];
if (s.width < preview.width || s.height < preview.height) {
continue;
}
const uint32_t area = s.width * s.height;
const uint32_t delta = area - previewArea;
if (delta < bestDelta) {
bestDelta = delta;
best = i;
foundBest = true;
}
}
if (!foundBest) {
// If no candidate was found, the driver will be fine with a video size
// smaller than the chosen preview size.
DOM_CAMERA_LOGI("No video size candidate for preview size %ux%u (0x%x)\n",
preview.width, preview.height, rv);
return NS_OK;
}
DOM_CAMERA_LOGI("Adjusting video size upwards to %ux%u\n",
sizes[best].width, sizes[best].height);
rv = Set(CAMERA_PARAM_VIDEOSIZE, sizes[best]);
if (NS_FAILED(rv)) {
DOM_CAMERA_LOGW("Failed to adjust video size for preview size %ux%u (0x%x)\n",
preview.width, preview.height, rv);
return rv;
}
mLastRecorderSize = preview;
return NS_OK;
}
nsresult
nsGonkCameraControl::SetPictureConfiguration(const Configuration& aConfig)
{
DOM_CAMERA_LOGT("%s:%d\n", __func__, __LINE__);
MOZ_ASSERT(NS_GetCurrentThread() == mCameraThread);
nsresult rv = SetPreviewSize(aConfig.mPreviewSize);
nsTArray<Size> sizes;
nsresult rv = Get(CAMERA_PARAM_SUPPORTED_PREVIEWSIZES, sizes);
if (NS_WARN_IF(NS_FAILED(rv))) {
return rv;
}
Size preview;
rv = GetSupportedSize(aConfig.mPreviewSize, sizes, preview);
if (NS_FAILED(rv)) {
DOM_CAMERA_LOGE(
"Failed to find a supported preview size, requested size %ux%u (0x%x)",
aConfig.mPreviewSize.width, aConfig.mPreviewSize.height, rv);
return rv;
}
rv = Set(CAMERA_PARAM_PREVIEWSIZE, preview);
if (NS_FAILED(rv)) {
DOM_CAMERA_LOGE("Failed to set supported preview size %ux%u (0x%x)",
preview.width, preview.height, rv);
return rv;
}
mCurrentConfiguration.mPreviewSize = preview;
if (mSeparateVideoAndPreviewSizesSupported) {
MaybeAdjustVideoSize();
}
mParams.Get(CAMERA_PARAM_PREVIEWFRAMERATE, mPreviewFps);
DOM_CAMERA_LOGI("picture mode preview: wanted %ux%u, got %ux%u (%u fps)\n",
aConfig.mPreviewSize.width, aConfig.mPreviewSize.height,
mCurrentConfiguration.mPreviewSize.width, mCurrentConfiguration.mPreviewSize.height,
mPreviewFps);
aConfig.mPreviewSize.width, aConfig.mPreviewSize.height,
preview.width, preview.height,
mPreviewFps);
return NS_OK;
}
@ -695,11 +787,10 @@ nsGonkCameraControl::SetThumbnailSizeImpl(const Size& aSize)
int area = supportedSizes[i].width * supportedSizes[i].height;
int delta = abs(area - targetArea);
if (area != 0
&& delta < smallestDelta
&& supportedSizes[i].width * mLastPictureSize.height /
supportedSizes[i].height == mLastPictureSize.width
) {
if (area != 0 &&
delta < smallestDelta &&
supportedSizes[i].width * mLastPictureSize.height ==
mLastPictureSize.width * supportedSizes[i].height) {
smallestDelta = delta;
smallestDeltaIndex = i;
}
@ -1249,71 +1340,9 @@ nsGonkCameraControl::OnTakePictureError()
NS_ERROR_FAILURE);
}
nsresult
nsGonkCameraControl::SetPreviewSize(const Size& aSize)
{
MOZ_ASSERT(NS_GetCurrentThread() == mCameraThread);
nsTArray<Size> previewSizes;
nsresult rv = Get(CAMERA_PARAM_SUPPORTED_PREVIEWSIZES, previewSizes);
if (NS_FAILED(rv)) {
DOM_CAMERA_LOGE("Camera failed to return any preview sizes (0x%x)\n", rv);
return rv;
}
Size best;
rv = GetSupportedSize(aSize, previewSizes, best);
if (NS_FAILED(rv)) {
DOM_CAMERA_LOGE("Failed to find a supported preview size, requested size %dx%d",
aSize.width, aSize.height);
return rv;
}
if (mSeparateVideoAndPreviewSizesSupported) {
// Some camera drivers will ignore our preview size if it's larger
// than the currently set video recording size, so we need to set
// the video size here as well, just in case.
if (best.width > mLastRecorderSize.width || best.height > mLastRecorderSize.height) {
SetVideoSize(best);
}
} else {
mLastRecorderSize = best;
}
mCurrentConfiguration.mPreviewSize = best;
return Set(CAMERA_PARAM_PREVIEWSIZE, best);
}
nsresult
nsGonkCameraControl::SetVideoSize(const Size& aSize)
{
MOZ_ASSERT(NS_GetCurrentThread() == mCameraThread);
if (!mSeparateVideoAndPreviewSizesSupported) {
DOM_CAMERA_LOGE("Camera does not support setting separate video size\n");
return NS_ERROR_NOT_AVAILABLE;
}
nsTArray<Size> videoSizes;
nsresult rv = Get(CAMERA_PARAM_SUPPORTED_VIDEOSIZES, videoSizes);
if (NS_FAILED(rv)) {
DOM_CAMERA_LOGE("Camera failed to return any video sizes (0x%x)\n", rv);
return rv;
}
Size best;
rv = GetSupportedSize(aSize, videoSizes, best);
if (NS_FAILED(rv)) {
DOM_CAMERA_LOGE("Failed to find a supported video size, requested size %dx%d",
aSize.width, aSize.height);
return rv;
}
mLastRecorderSize = best;
return Set(CAMERA_PARAM_VIDEOSIZE, best);
}
nsresult
nsGonkCameraControl::GetSupportedSize(const Size& aSize,
const nsTArray<Size>& supportedSizes,
const nsTArray<Size>& aSupportedSizes,
Size& best)
{
nsresult rv = NS_ERROR_INVALID_ARG;
@ -1323,24 +1352,25 @@ nsGonkCameraControl::GetSupportedSize(const Size& aSize,
if (!aSize.width && !aSize.height) {
// no size specified, take the first supported size
best = supportedSizes[0];
best = aSupportedSizes[0];
return NS_OK;
} else if (aSize.width && aSize.height) {
// both height and width specified, find the supported size closest to
// the requested size, looking for an exact match first
for (nsTArray<Size>::index_type i = 0; i < supportedSizes.Length(); i++) {
Size size = supportedSizes[i];
for (SizeIndex i = 0; i < aSupportedSizes.Length(); ++i) {
Size size = aSupportedSizes[i];
if (size.width == aSize.width && size.height == aSize.height) {
best = size;
return NS_OK;
}
}
// no exact matches--look for a match closest in area
uint32_t targetArea = aSize.width * aSize.height;
for (nsTArray<Size>::index_type i = 0; i < supportedSizes.Length(); i++) {
Size size = supportedSizes[i];
uint32_t delta = abs((long int)(size.width * size.height - targetArea));
// no exact match on dimensions--look for a match closest in area
const uint32_t targetArea = aSize.width * aSize.height;
for (SizeIndex i = 0; i < aSupportedSizes.Length(); i++) {
Size size = aSupportedSizes[i];
uint32_t delta =
abs(static_cast<long int>(size.width * size.height - targetArea));
if (delta < minSizeDelta) {
minSizeDelta = delta;
best = size;
@ -1349,9 +1379,9 @@ nsGonkCameraControl::GetSupportedSize(const Size& aSize,
}
} else if (!aSize.width) {
// width not specified, find closest height match
for (nsTArray<Size>::index_type i = 0; i < supportedSizes.Length(); i++) {
Size size = supportedSizes[i];
delta = abs((long int)(size.height - aSize.height));
for (SizeIndex i = 0; i < aSupportedSizes.Length(); i++) {
Size size = aSupportedSizes[i];
delta = abs(static_cast<long int>(size.height - aSize.height));
if (delta < minSizeDelta) {
minSizeDelta = delta;
best = size;
@ -1360,9 +1390,9 @@ nsGonkCameraControl::GetSupportedSize(const Size& aSize,
}
} else if (!aSize.height) {
// height not specified, find closest width match
for (nsTArray<Size>::index_type i = 0; i < supportedSizes.Length(); i++) {
Size size = supportedSizes[i];
delta = abs((long int)(size.width - aSize.width));
for (SizeIndex i = 0; i < aSupportedSizes.Length(); i++) {
Size size = aSupportedSizes[i];
delta = abs(static_cast<long int>(size.width - aSize.width));
if (delta < minSizeDelta) {
minSizeDelta = delta;
best = size;
@ -1370,9 +1400,147 @@ nsGonkCameraControl::GetSupportedSize(const Size& aSize,
}
}
}
return rv;
}
nsresult
nsGonkCameraControl::SetVideoAndPreviewSize(const Size& aPreviewSize, const Size& aVideoSize)
{
MOZ_ASSERT(NS_GetCurrentThread() == mCameraThread);
MOZ_ASSERT(mSeparateVideoAndPreviewSizesSupported);
DOM_CAMERA_LOGI("Setting video size to %ux%u, preview size to %ux%u\n",
aVideoSize.width, aVideoSize.height,
aPreviewSize.width, aPreviewSize.height);
Size oldSize;
nsresult rv = Get(CAMERA_PARAM_PREVIEWSIZE, oldSize);
if (NS_WARN_IF(NS_FAILED(rv))) {
return rv;
}
rv = Set(CAMERA_PARAM_PREVIEWSIZE, aPreviewSize);
if (NS_WARN_IF(NS_FAILED(rv))) {
return rv;
}
rv = Set(CAMERA_PARAM_VIDEOSIZE, aVideoSize);
if (NS_WARN_IF(NS_FAILED(rv))) {
Set(CAMERA_PARAM_VIDEOSIZE, oldSize); // error, try to restore the original preview size
return rv;
}
mCurrentConfiguration.mPreviewSize = aPreviewSize;
mLastRecorderSize = aVideoSize;
return NS_OK;
}
nsresult
nsGonkCameraControl::SelectVideoAndPreviewSize(const Configuration& aConfig, const Size& aVideoSize)
{
MOZ_ASSERT(NS_GetCurrentThread() == mCameraThread);
MOZ_ASSERT(mSeparateVideoAndPreviewSizesSupported);
nsTArray<Size> sizes;
nsresult rv = Get(CAMERA_PARAM_SUPPORTED_VIDEOSIZES, sizes);
if (NS_WARN_IF(NS_FAILED(rv))) {
return rv;
}
Size video;
rv = GetSupportedSize(aVideoSize, sizes, video);
if (NS_FAILED(rv)) {
DOM_CAMERA_LOGE("Failed to find a supported video size, requested size %ux%u",
aVideoSize.width, aVideoSize.height);
return rv;
}
rv = Get(CAMERA_PARAM_SUPPORTED_PREVIEWSIZES, sizes);
if (NS_WARN_IF(NS_FAILED(rv))) {
return rv;
}
Size preview;
rv = GetSupportedSize(aConfig.mPreviewSize, sizes, preview);
if (NS_FAILED(rv)) {
DOM_CAMERA_LOGE("Failed to find a supported preview size, requested size %ux%u",
aConfig.mPreviewSize.width, aConfig.mPreviewSize.height);
return rv;
}
Size preferred;
rv = Get(CAMERA_PARAM_PREFERRED_PREVIEWSIZE_FOR_VIDEO, preferred);
if (NS_WARN_IF(NS_FAILED(rv))) {
return rv;
}
// If the requested preview size has the same aspect ratio as the
// requested video size, *and* is the same size or smaller than
// the preferred video size, then we're done.
const uint32_t preferredArea = preferred.width * preferred.height;
if (video.width * aConfig.mPreviewSize.height == aConfig.mPreviewSize.width * video.height &&
preview.width * preview.height <= preferredArea) {
// We're done: set the video and preview sizes and return...
return SetVideoAndPreviewSize(preview, video);
}
// Otherwise, if the requested preview size is larger than the preferred
// size, or there is an aspect ratio mismatch, then we need to set the
// preview size to the closest size smaller than the preferred size,
// preferably with the same aspect ratio as the requested video size.
SizeIndex bestSizeMatch;
SizeIndex bestSizeMatchWithAspectRatio;
bool foundSizeMatch = false;
bool foundSizeMatchWithAspectRatio = false;
uint32_t bestAreaDelta = UINT32_MAX;
uint32_t bestAreaDeltaWithAspect = UINT32_MAX;
for (SizeIndex i = 0; i < sizes.Length(); ++i) {
const Size& s = sizes[i];
const uint32_t area = s.width * s.height;
if (area > preferredArea) {
continue;
}
const uint32_t delta = preferredArea - area;
if (s.width * video.height == video.width * s.height) {
if (delta == 0) {
// exact match, including aspect ratio--we can stop now
bestSizeMatchWithAspectRatio = i;
foundSizeMatchWithAspectRatio = true;
break;
} else if (delta < bestAreaDeltaWithAspect) {
// aspect ratio match
bestAreaDeltaWithAspect = delta;
bestSizeMatchWithAspectRatio = i;
foundSizeMatchWithAspectRatio = true;
}
} else if (delta < bestAreaDelta) {
bestAreaDelta = delta;
bestSizeMatch = i;
foundSizeMatch = true;
}
}
if (foundSizeMatchWithAspectRatio) {
preview = sizes[bestSizeMatchWithAspectRatio];
} else if (foundSizeMatch) {
DOM_CAMERA_LOGW("Unable to match a preview size with aspect ratio of video size %ux%u\n",
video.width, video.height);
preview = sizes[bestSizeMatch];
} else {
DOM_CAMERA_LOGE("Unable to find a preview size for video size %ux%u\n",
video.width, video.height);
return NS_ERROR_INVALID_ARG;
}
return SetVideoAndPreviewSize(preview, video);
}
nsresult
nsGonkCameraControl::SetVideoConfiguration(const Configuration& aConfig)
{
@ -1392,12 +1560,11 @@ nsGonkCameraControl::SetVideoConfiguration(const Configuration& aConfig)
return NS_ERROR_INVALID_ARG;
}
mCurrentConfiguration.mRecorderProfile = aConfig.mRecorderProfile;
const RecorderProfile::Video& video(profile->GetVideo());
const Size& size = video.GetSize();
int fps = video.GetFramesPerSecond();
if (fps <= 0 || size.width <= 0 || size.height <= 0) {
DOM_CAMERA_LOGE("Can't configure video with fps=%d, width=%d, height=%d\n",
const uint32_t fps = video.GetFramesPerSecond();
if (fps == 0 || fps > INT_MAX || size.width == 0 || size.height == 0) {
DOM_CAMERA_LOGE("Can't configure video with fps=%u, width=%u, height=%u\n",
fps, size.width, size.height);
return NS_ERROR_FAILURE;
}
@ -1410,32 +1577,26 @@ nsGonkCameraControl::SetVideoConfiguration(const Configuration& aConfig)
if (mSeparateVideoAndPreviewSizesSupported) {
// The camera supports two video streams: a low(er) resolution preview
// stream and and a potentially high(er) resolution stream for encoding.
rv = SetVideoSize(size);
// stream and and a potentially high(er) resolution stream for encoding.
rv = SelectVideoAndPreviewSize(aConfig, size);
if (NS_FAILED(rv)) {
DOM_CAMERA_LOGE("Failed to set video mode video size (0x%x)\n", rv);
return rv;
}
// The video size must be set first, before the preview size, because
// some platforms have a dependency between the two.
rv = SetPreviewSize(aConfig.mPreviewSize);
if (NS_FAILED(rv)) {
DOM_CAMERA_LOGE("Failed to set video mode preview size (0x%x)\n", rv);
DOM_CAMERA_LOGE("Failed to set video and preview sizes (0x%x)\n", rv);
return rv;
}
} else {
// The camera only supports a single video stream: in this case, we set
// the preview size to be the desired video recording size, and ignore
// the specified preview size.
rv = SetPreviewSize(size);
rv = Set(CAMERA_PARAM_PREVIEWSIZE, size);
if (NS_FAILED(rv)) {
DOM_CAMERA_LOGE("Failed to set video mode preview size (0x%x)\n", rv);
return rv;
}
mCurrentConfiguration.mPreviewSize = size;
}
rv = Set(CAMERA_PARAM_PREVIEWFRAMERATE, fps);
rv = Set(CAMERA_PARAM_PREVIEWFRAMERATE, static_cast<int>(fps));
if (NS_FAILED(rv)) {
DOM_CAMERA_LOGE("Failed to set video mode frame rate (0x%x)\n", rv);
return rv;

View File

@ -98,6 +98,8 @@ protected:
using CameraControlImpl::OnConfigurationChange;
using CameraControlImpl::OnUserError;
typedef nsTArray<Size>::index_type SizeIndex;
virtual void BeginBatchParameterSet() MOZ_OVERRIDE;
virtual void EndBatchParameterSet() MOZ_OVERRIDE;
@ -130,8 +132,9 @@ protected:
nsresult SetupRecording(int aFd, int aRotation, uint64_t aMaxFileSizeBytes,
uint64_t aMaxVideoLengthMs);
nsresult SetupRecordingFlash(bool aAutoEnableLowLightTorch);
nsresult SetPreviewSize(const Size& aSize);
nsresult SetVideoSize(const Size& aSize);
nsresult SelectVideoAndPreviewSize(const Configuration& aConfig, const Size& aVideoSize);
nsresult SetVideoAndPreviewSize(const Size& aPreviewSize, const Size& aVideoSize);
nsresult MaybeAdjustVideoSize();
nsresult PausePreview();
nsresult GetSupportedSize(const Size& aSize, const nsTArray<Size>& supportedSizes, Size& best);

View File

@ -117,6 +117,8 @@ GonkCameraParameters::Parameters::GetTextKey(uint32_t aKey)
return KEY_RECORDING_HINT;
case CAMERA_PARAM_PICTURE_QUALITY:
return KEY_JPEG_QUALITY;
case CAMERA_PARAM_PREFERRED_PREVIEWSIZE_FOR_VIDEO:
return KEY_PREFERRED_PREVIEW_SIZE_FOR_VIDEO;
case CAMERA_PARAM_SUPPORTED_PREVIEWSIZES:
return KEY_SUPPORTED_PREVIEW_SIZES;

View File

@ -54,6 +54,7 @@ enum {
CAMERA_PARAM_LUMINANCE,
CAMERA_PARAM_SCENEMODE_HDR_RETURNNORMALPICTURE,
CAMERA_PARAM_RECORDINGHINT,
CAMERA_PARAM_PREFERRED_PREVIEWSIZE_FOR_VIDEO,
// supported features
CAMERA_PARAM_SUPPORTED_PREVIEWSIZES,