dialog_camera_list.c 1.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990
  1. /*
  2. * Copyright (C) 2021 Alibaba Group Holding Limited
  3. * Author: LuChongzhi <chongzhi.lcz@alibaba-inc.com>
  4. *
  5. * This program is free software; you can redistribute it and/or modify
  6. * it under the terms of the GNU General Public License version 2 as
  7. * published by the Free Software Foundation.
  8. */
  9. #include <stdio.h>
  10. #include <ctype.h>
  11. #include <string.h>
  12. #include <stdlib.h>
  13. #include <unistd.h>
  14. #include <curses.h>
  15. #define LOG_LEVEL 3
  16. #define LOG_PREFIX "dlg_camera_list"
  17. #include <syslog.h>
  18. #include <camera_manager.h>
  19. #include "param.h"
  20. #include "app_dialogs.h"
  21. extern cams_t *cam_session;
  22. int dialog_camera_list(void)
  23. {
  24. int ret_key = KEY_ESC;
  25. int ret;
  26. if (cam_session == NULL) {
  27. LOG_E("cam_session is NULL\n");
  28. return KEY_ESC;
  29. }
  30. /* Get camera list */
  31. if (camera_query_list(cam_session) != 0) {
  32. LOG_E("camera_query_list() failed\n");
  33. return KEY_ESC;
  34. }
  35. char str_buf[1024] = "";
  36. char str_item[256];
  37. /* Prepare for checklist nodes */
  38. csi_camera_infos_s *cam_infos = &cam_session->camera_infos;
  39. for (int i = 0; i < cam_infos->count; i++) {
  40. csi_camera_info_s *info = &(cam_infos->info[i]);
  41. snprintf(str_item, sizeof(str_item),
  42. "Camera[%d] info:\n"
  43. "\t name = %s\n"
  44. "\t dev = %s\n"
  45. "\t bus = %s\n",
  46. i,
  47. info->camera_name,
  48. info->device_name,
  49. info->bus_info);
  50. strcat(str_buf, str_item);
  51. strcat(str_buf, "\t caps = ");
  52. for (unsigned int j = 1; j < 0x80000000; j = j << 1) {
  53. switch (info->capabilities & j) {
  54. case CSI_CAMERA_CAP_VIDEO_CAPTURE:
  55. strcat(str_buf,"VIDEO_CAPTURE | ");
  56. break;
  57. case CSI_CAMERA_CAP_META_CAPTURE:
  58. strcat(str_buf, "META_CAPTURE | ");
  59. break;
  60. default:
  61. if (info->capabilities & j) {
  62. strcat(str_buf, "Unknown");
  63. }
  64. break;
  65. }
  66. }
  67. strcat(str_buf, "\n\n");
  68. }
  69. dialog_textbox_simple("System Camera List",
  70. str_buf,
  71. 20, //int initial_height,
  72. 80); //int initial_width
  73. return ret;
  74. }