csi_camera_frame.h 1.9 KB

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