diff options
author | Vladimir Chtchetkine <vchtchetkine@google.com> | 2011-11-15 09:17:29 -0800 |
---|---|---|
committer | Vladimir Chtchetkine <vchtchetkine@google.com> | 2011-11-15 09:17:29 -0800 |
commit | 8d9a7a5fa4bd32f9b8aeb7b9e3bd047a475539ab (patch) | |
tree | dd0a823549135e5b6184c44d19d8ad8754666845 /android/camera | |
parent | 9ef86366e076f45bb9a6e6e98651062bc3ad7da8 (diff) | |
download | external_qemu-8d9a7a5fa4bd32f9b8aeb7b9e3bd047a475539ab.zip external_qemu-8d9a7a5fa4bd32f9b8aeb7b9e3bd047a475539ab.tar.gz external_qemu-8d9a7a5fa4bd32f9b8aeb7b9e3bd047a475539ab.tar.bz2 |
Add required frame dimensions for Win and Mac.
Camera framework requires that certain frame dimensions must be supported by the
camera devices. Since on Windows and Mac we have no way of knowing the real
webcam capabilities, but camera API there pretty much allows us to choose any
frame dimensions that we want, we will hard-code those that are required by
the camera framework.
Change-Id: I625381776f374103d2ac1c62fabae23b1c5afa88
Diffstat (limited to 'android/camera')
-rw-r--r-- | android/camera/camera-capture-mac.m | 6 | ||||
-rwxr-xr-x | android/camera/camera-capture-windows.c | 28 |
2 files changed, 22 insertions, 12 deletions
diff --git a/android/camera/camera-capture-mac.m b/android/camera/camera-capture-mac.m index 1c1c3d5..228838b 100644 --- a/android/camera/camera-capture-mac.m +++ b/android/camera/camera-capture-mac.m @@ -494,8 +494,10 @@ static const CameraFrameDim _emulate_dims[] = { /* Emulates 640x480 frame. */ {640, 480}, - /* Emulates 320x240 frame. */ - {320, 240}, + /* Emulates 352x288 frame (required by camera framework). */ + {352, 288}, + /* Emulates 176x144 frame (required by camera framework). */ + {176, 144} }; /* Obtain default video device. QT API doesn't really provide a reliable diff --git a/android/camera/camera-capture-windows.c b/android/camera/camera-capture-windows.c index 28820a8..781ba05 100755 --- a/android/camera/camera-capture-windows.c +++ b/android/camera/camera-capture-windows.c @@ -545,6 +545,20 @@ camera_device_close(CameraDevice* cd) int enumerate_camera_devices(CameraInfo* cis, int max) { +/* Array containing emulated webcam frame dimensions. + * capXxx API provides device independent frame dimensions, by scaling frames + * received from the device to whatever dimensions were requested by the user. + * So, we can just use a small set of frame dimensions to emulate. + */ +static const CameraFrameDim _emulate_dims[] = +{ + /* Emulates 640x480 frame. */ + {640, 480}, + /* Emulates 352x288 frame (required by camera framework). */ + {352, 288}, + /* Emulates 176x144 frame (required by camera framework). */ + {176, 144} +}; int inp_channel, found = 0; for (inp_channel = 0; inp_channel < 10 && found < max; inp_channel++) { @@ -557,14 +571,9 @@ enumerate_camera_devices(CameraInfo* cis, int max) WndCameraDevice* wcd = (WndCameraDevice*)cd->opaque; /* Unfortunately, on Windows we have to start capturing in order to get the - * actual frame properties. Note that on Windows camera_device_start_capturing - * will ignore the pixel format parameter, since it will be determined during - * the course of the routine. Also note that on Windows all frames will be - * 640x480. */ + * actual frame properties. */ if (!camera_device_start_capturing(cd, V4L2_PIX_FMT_RGB32, 640, 480)) { - /* capXxx API supports only single frame size (always observed 640x480, - * but the actual numbers may vary). */ - cis[found].frame_sizes = (CameraFrameDim*)malloc(sizeof(CameraFrameDim)); + cis[found].frame_sizes = (CameraFrameDim*)malloc(sizeof(_emulate_dims)); if (cis[found].frame_sizes != NULL) { char disp_name[24]; sprintf(disp_name, "webcam%d", found); @@ -572,9 +581,8 @@ enumerate_camera_devices(CameraInfo* cis, int max) cis[found].device_name = ASTRDUP(name); cis[found].direction = ASTRDUP("front"); cis[found].inp_channel = inp_channel; - cis[found].frame_sizes->width = wcd->frame_bitmap->bmiHeader.biWidth; - cis[found].frame_sizes->height = wcd->frame_bitmap->bmiHeader.biHeight; - cis[found].frame_sizes_num = 1; + cis[found].frame_sizes_num = sizeof(_emulate_dims) / sizeof(*_emulate_dims); + memcpy(cis[found].frame_sizes, _emulate_dims, sizeof(_emulate_dims)); cis[found].pixel_format = wcd->pixel_format; cis[found].in_use = 0; found++; |