csi_camera_frame.h 2.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869
  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. #ifndef __CSI_CAMERA_FRAME_H__
  10. #define __CSI_CAMERA_FRAME_H__
  11. #include <stddef.h>
  12. #include <stdbool.h>
  13. #include <sys/time.h>
  14. #include "csi_frame.h"
  15. #ifdef __cplusplus
  16. extern "C" {
  17. #endif
  18. #define CSI_CAMERA_META_MAX_LEN 1024
  19. typedef enum csi_camera_meta_id {
  20. CSI_CAMERA_META_ID_CAMERA_NAME = (1<<0), /* str_value */
  21. CSI_CAMERA_META_ID_CHANNEL_ID = (1<<1), /* uint_value */
  22. CSI_CAMERA_META_ID_FRAME_ID = (1<<2), /* uint_value: Re-Count from zero when start() */
  23. CSI_CAMERA_META_ID_TIMESTAMP = (1<<3), /* time_value: Get from gettimeofday() */
  24. CSI_CAMERA_META_ID_HDR = (1<<4), /* bool_value */
  25. } csi_camera_meta_id_e;
  26. #define CSI_CAMERA_META_NO_FIELD 0
  27. #define CSI_CAMERA_META_DEFAULT_FIELDS (CSI_CAMERA_META_ID_CAMERA_NAME | \
  28. CSI_CAMERA_META_ID_CHANNEL_ID | \
  29. CSI_CAMERA_META_ID_FRAME_ID | \
  30. CSI_CAMERA_META_ID_TIMESTAMP)
  31. typedef struct csi_camrea_meta_unit {
  32. csi_camera_meta_id_e id;
  33. csi_meta_value_type_e type;
  34. union {
  35. bool bool_value;
  36. int int_value;
  37. unsigned int uint_value;
  38. char str_value[32];
  39. struct timeval time_value;
  40. };
  41. } csi_camera_meta_unit_s;
  42. typedef struct csi_camera_meta {
  43. unsigned int count;
  44. size_t size;
  45. csi_camera_meta_unit_s *units; // Is meta_unit array head
  46. } csi_camera_meta_s;
  47. int csi_camera_frame_alloc_meta(csi_camera_meta_s **meta, int meta_count, size_t *meta_data_size);
  48. int csi_camera_frame_free_meta(csi_camera_meta_s *meta);
  49. int csi_camera_frame_get_meta_unit(csi_camera_meta_unit_s *meta_unit,
  50. csi_camera_meta_s *meta_data,
  51. csi_camera_meta_id_e meta_field);
  52. #ifdef __cplusplus
  53. }
  54. #endif
  55. #endif /* __CSI_CAMERA_FRAME_H__ */