dialog_channel_list.c 2.3 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. #define LOG_LEVEL 3
  15. #define LOG_PREFIX "dlg_chn_list"
  16. #include <syslog.h>
  17. #include <curses.h>
  18. #include <camera_manager.h>
  19. #include <camera_string.h>
  20. #include "app_dialogs.h"
  21. extern cams_t *cam_session;
  22. int dialog_channel_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_channel_query_list(cam_session) != 0) {
  32. LOG_E("camera_get_list() failed\n");
  33. return KEY_ESC;
  34. }
  35. char title[64];
  36. snprintf(title, sizeof(title), "Camera[%d] Channels List", cam_session->camera_id);
  37. char text[256*CSI_CAMERA_CHANNEL_MAX_COUNT] = "";
  38. char item[256];
  39. char temp[128];
  40. int valid_count = 0;
  41. for (int i = CSI_CAMERA_CHANNEL_0; i < CSI_CAMERA_CHANNEL_MAX_COUNT; i++) {
  42. csi_camera_channel_cfg_s *chn_cfg = &(cam_session->chn_cfg[i]);
  43. if (chn_cfg->status == CSI_CAMERA_CHANNEL_INVALID)
  44. continue;
  45. if (valid_count > 0)
  46. strcat(text, "\n");
  47. snprintf(item, sizeof(item), "Channel[%d] info:\n", chn_cfg->chn_id);
  48. strcat(text, item);
  49. snprintf(item, sizeof(item), "\t Status : %s\n",
  50. camera_string_chn_status(chn_cfg->status));
  51. strcat(text, item);
  52. snprintf(item, sizeof(item), "\t Capture: %s\n",
  53. camera_string_chn_capture_types(chn_cfg->capture_type, temp));
  54. strcat(text, item);
  55. snprintf(item, sizeof(item), "\t Frame : count=%d, type=%s\n",
  56. chn_cfg->frm_cnt, camera_string_img_type(chn_cfg->img_type));
  57. strcat(text, item);
  58. snprintf(item, sizeof(item), "\t Image : width=%d, height=%d, pix_fmt=%s\n",
  59. chn_cfg->img_fmt.width, chn_cfg->img_fmt.height,
  60. camera_string_pixel_format(chn_cfg->img_fmt.pix_fmt));
  61. strcat(text, item);
  62. snprintf(item, sizeof(item), "\t Meta : %s\n",
  63. camera_string_chn_meta_fields(chn_cfg->meta_fields, temp));
  64. strcat(text, item);
  65. valid_count++;
  66. }
  67. int height = MIN((valid_count * 7 + 4), (WIN_ROWS - 6));
  68. return dialog_textbox_simple(title, text, height, 80);
  69. }