EmulatedFakeCamera2: Add recording support for 320x240, NV21. DO NOT MERGE
- Support 320x240 in addition to 640x480 - Support NV21 (monochrome only right now) - Base simulated time on system time, since stagefright cares about timestamp base - Use emulator magic gralloc format to enable gralloc to pick format based on destination. Bug: 6243944 Change-Id: I3ea56bca726c69b51e03233ce86d4881401a3ffd
This commit is contained in:
@@ -27,6 +27,7 @@
|
||||
#include "EmulatedCameraFactory.h"
|
||||
#include <ui/Rect.h>
|
||||
#include <ui/GraphicBufferMapper.h>
|
||||
#include "gralloc_cb.h"
|
||||
|
||||
namespace android {
|
||||
|
||||
@@ -47,8 +48,8 @@ const uint64_t EmulatedFakeCamera2::kAvailableRawMinDurations[1] = {
|
||||
Sensor::kFrameDurationRange[0]
|
||||
};
|
||||
|
||||
const uint32_t EmulatedFakeCamera2::kAvailableProcessedSizes[2] = {
|
||||
640, 480
|
||||
const uint32_t EmulatedFakeCamera2::kAvailableProcessedSizes[4] = {
|
||||
640, 480, 320, 240
|
||||
// Sensor::kResolution[0], Sensor::kResolution[1]
|
||||
};
|
||||
|
||||
@@ -251,8 +252,9 @@ int EmulatedFakeCamera2::allocateStream(
|
||||
return BAD_VALUE;
|
||||
}
|
||||
} else {
|
||||
// Emulator's opaque format is RGBA
|
||||
format = HAL_PIXEL_FORMAT_RGBA_8888;
|
||||
// Translate to emulator's magic format.
|
||||
// Note: It is assumed that this is a processed format (not raw or JPEG).
|
||||
format = GRALLOC_EMULATOR_PIXEL_FORMAT_AUTO;
|
||||
}
|
||||
|
||||
const uint32_t *availableSizes;
|
||||
@@ -266,6 +268,7 @@ int EmulatedFakeCamera2::allocateStream(
|
||||
availableSizes = kAvailableJpegSizes;
|
||||
availableSizeCount = sizeof(kAvailableJpegSizes)/sizeof(uint32_t);
|
||||
break;
|
||||
case GRALLOC_EMULATOR_PIXEL_FORMAT_AUTO:
|
||||
case HAL_PIXEL_FORMAT_RGBA_8888:
|
||||
case HAL_PIXEL_FORMAT_YV12:
|
||||
case HAL_PIXEL_FORMAT_YCrCb_420_SP:
|
||||
@@ -326,7 +329,7 @@ int EmulatedFakeCamera2::allocateStream(
|
||||
|
||||
*stream_id = mNextStreamId;
|
||||
if (format_actual) *format_actual = format;
|
||||
*usage = GRALLOC_USAGE_SW_WRITE_OFTEN;
|
||||
*usage = GRALLOC_USAGE_HW_CAMERA_WRITE;
|
||||
*max_buffers = 4;
|
||||
|
||||
ALOGV("Stream allocated: %d, %d x %d, 0x%x. U: %x, B: %d",
|
||||
@@ -340,9 +343,42 @@ int EmulatedFakeCamera2::registerStreamBuffers(
|
||||
uint32_t stream_id,
|
||||
int num_buffers,
|
||||
buffer_handle_t *buffers) {
|
||||
// Emulator doesn't need to register these with V4L2, etc.
|
||||
Mutex::Autolock l(mMutex);
|
||||
|
||||
ALOGV("%s: Stream %d registering %d buffers", __FUNCTION__,
|
||||
stream_id, num_buffers);
|
||||
// Need to find out what the final concrete pixel format for our stream is
|
||||
// Assumes that all buffers have the same format.
|
||||
if (num_buffers < 1) {
|
||||
ALOGE("%s: Stream %d only has %d buffers!",
|
||||
__FUNCTION__, stream_id, num_buffers);
|
||||
return BAD_VALUE;
|
||||
}
|
||||
const cb_handle_t *streamBuffer =
|
||||
reinterpret_cast<const cb_handle_t*>(buffers[0]);
|
||||
|
||||
int finalFormat = streamBuffer->format;
|
||||
|
||||
if (finalFormat == GRALLOC_EMULATOR_PIXEL_FORMAT_AUTO) {
|
||||
ALOGE("%s: Stream %d: Bad final pixel format "
|
||||
"GRALLOC_EMULATOR_PIXEL_FORMAT_AUTO; "
|
||||
"concrete pixel format required!", __FUNCTION__, stream_id);
|
||||
return BAD_VALUE;
|
||||
}
|
||||
|
||||
ssize_t streamIndex = mStreams.indexOfKey(stream_id);
|
||||
if (streamIndex < 0) {
|
||||
ALOGE("%s: Unknown stream id %d!", __FUNCTION__, stream_id);
|
||||
return BAD_VALUE;
|
||||
}
|
||||
|
||||
Stream &stream = mStreams.editValueAt(streamIndex);
|
||||
|
||||
ALOGV("%s: Stream %d format set to %x, previously %x",
|
||||
__FUNCTION__, stream_id, finalFormat, stream.format);
|
||||
|
||||
stream.format = finalFormat;
|
||||
|
||||
return NO_ERROR;
|
||||
}
|
||||
|
||||
@@ -593,7 +629,14 @@ bool EmulatedFakeCamera2::ConfigureThread::threadLoop() {
|
||||
mNextNeedsJpeg = false;
|
||||
ALOGV("Setting up buffers for capture");
|
||||
for (size_t i = 0; i < streams.count; i++) {
|
||||
const Stream &s = mParent->getStreamInfo(streams.data.u8[i]);
|
||||
int streamId = streams.data.u8[i];
|
||||
const Stream &s = mParent->getStreamInfo(streamId);
|
||||
if (s.format == GRALLOC_EMULATOR_PIXEL_FORMAT_AUTO) {
|
||||
ALOGE("%s: Stream %d does not have a concrete pixel format, but "
|
||||
"is included in a request!", __FUNCTION__, streamId);
|
||||
mParent->signalError();
|
||||
return false;
|
||||
}
|
||||
StreamBuffer b;
|
||||
b.streamId = streams.data.u8[i];
|
||||
b.width = s.width;
|
||||
@@ -708,7 +751,7 @@ bool EmulatedFakeCamera2::ConfigureThread::threadLoop() {
|
||||
const Rect rect(s.width, s.height);
|
||||
|
||||
res = GraphicBufferMapper::get().lock(*(b.buffer),
|
||||
GRALLOC_USAGE_SW_WRITE_OFTEN,
|
||||
GRALLOC_USAGE_HW_CAMERA_WRITE,
|
||||
rect, (void**)&(b.img) );
|
||||
|
||||
if (res != NO_ERROR) {
|
||||
@@ -1220,7 +1263,7 @@ status_t EmulatedFakeCamera2::constructStaticInfo(
|
||||
sizeof(exposureCompensationRange)/sizeof(int32_t));
|
||||
|
||||
static const int32_t availableTargetFpsRanges[] = {
|
||||
5, 30
|
||||
5, 30, 15, 30
|
||||
};
|
||||
ADD_OR_SIZE(ANDROID_CONTROL_AE_AVAILABLE_TARGET_FPS_RANGES,
|
||||
availableTargetFpsRanges,
|
||||
|
||||
Reference in New Issue
Block a user