static int g_ret_release_video_buffer;
static void *g_hal_handle;
static camera_device_info_list_s g_device_info_list;
+static camera_device_capability_list_s g_device_capability_list;
static camera_format_s g_preview_format;
static camera_format_s g_video_format;
static GMutex g_msg_cb_lock;
ret = hal_camera_get_device_info_list(g_hal_handle, &g_device_info_list);
if (ret != CAMERA_ERROR_NONE) {
- cout << "get device list failed " << ret << endl;
+ cout << "get device info list failed " << ret << endl;
+ return;
+ }
+
+ ret = hal_camera_get_device_capability_list(g_hal_handle, &g_device_capability_list);
+ if (ret != CAMERA_ERROR_NONE) {
+ cout << "get device capability list failed " << ret << endl;
return;
}
}
}
- int GetSupportedFormat(int index)
+ int GetSupportedFormat(uint32_t device_index)
{
- camera_device_info_s *d = NULL;
+ camera_device_capability_s *capability = nullptr;
+ camera_device_capability_format_s *capability_format = nullptr;
+ camera_device_capability_resolution_s *capability_resolution = nullptr;
+
+ if (device_index >= g_device_capability_list.device_count) {
+ cout << "invalid device_index[" << device_index << "] vs device_count[" << g_device_capability_list.device_count << "]" << endl;
+ return CAMERA_ERROR_DEVICE_NOT_SUPPORTED;
+ }
+
+ capability = g_device_capability_list.capability[device_index];
+ if (!capability || capability->format_count < 1 || !capability->format[0]) {
+ cout << "no format for device[" << device_index << "]" << endl;
+ return CAMERA_ERROR_DEVICE_NOT_SUPPORTED;
+ }
- if (g_device_info_list.count < 1) {
- cout << "no available camera device" << endl;
+ capability_format = capability->format[0];
+ if (capability_format->resolution_count < 1 || !capability_format->resolution[0]) {
+ cout << "no resolution for format[0] of device[" << device_index << "]" << endl;
return CAMERA_ERROR_DEVICE_NOT_SUPPORTED;
}
- d = &g_device_info_list.device_info[index];
+ capability_resolution = capability_format->resolution[0];
+ if (capability_resolution->fps_list.count < 1) {
+ cout << "no FPS for format[0]:resolution[0] of device[" << device_index << "]" << endl;
+ return CAMERA_ERROR_DEVICE_NOT_SUPPORTED;
+ }
- /* set preview format */
- g_preview_format.stream_format = d->format_list.formats[0];
- g_preview_format.stream_resolution.width = d->preview_list.resolutions[0].width;
- g_preview_format.stream_resolution.height = d->preview_list.resolutions[0].height;
- g_preview_format.stream_fps = d->preview_fps_list[0].fps[0];
+ g_preview_format.stream_format = capability_format->pixel_format;
+ g_preview_format.stream_resolution.width = capability_resolution->width;
+ g_preview_format.stream_resolution.height = capability_resolution->height;
+ g_preview_format.stream_fps = capability_resolution->fps_list.fps[capability_resolution->default_fps_index];
g_preview_format.stream_rotation = CAMERA_ROTATION_0;
- g_preview_format.capture_format = d->format_list.formats[0];
- g_preview_format.capture_resolution.width = d->capture_list.resolutions[0].width;
- g_preview_format.capture_resolution.height = d->capture_list.resolutions[0].height;
+ g_preview_format.capture_format = capability_format->pixel_format;
+ g_preview_format.capture_resolution.width = capability_resolution->width;
+ g_preview_format.capture_resolution.height = capability_resolution->height;
g_preview_format.capture_quality = 95;
- /* set video format */
- g_video_format.stream_format = d->format_list.formats[0];
- g_video_format.stream_resolution.width = d->video_list.resolutions[0].width;
- g_video_format.stream_resolution.height = d->video_list.resolutions[0].height;
- g_video_format.stream_fps = d->video_fps_list[0].fps[0];;
+ g_video_format.stream_format = capability_format->pixel_format;
+ g_video_format.stream_resolution.width = capability_resolution->width;
+ g_video_format.stream_resolution.height = capability_resolution->height;
+ g_video_format.stream_fps = capability_resolution->fps_list.fps[capability_resolution->default_fps_index];
g_video_format.stream_rotation = CAMERA_ROTATION_0;
- g_video_format.capture_format = d->format_list.formats[0];
- g_video_format.capture_resolution.width = d->capture_list.resolutions[0].width;
- g_video_format.capture_resolution.height = d->capture_list.resolutions[0].height;
+ g_video_format.capture_format = capability_format->pixel_format;
+ g_video_format.capture_resolution.width = capability_resolution->width;
+ g_video_format.capture_resolution.height = capability_resolution->height;
g_video_format.capture_quality = 95;
return CAMERA_ERROR_NONE;
*/
TEST_F(CameraHalTest, StartPreviewP)
{
- unsigned int i = 0;
+ uint32_t i = 0;
CAMERA_SUPPORT_CHECK;