thead_camera.h 2.5 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788
  1. /* GStreamer
  2. * Copyright (C) <2021> Charles Lu <chongzhi.lcz@alibaba-inc.com>
  3. *
  4. * This library is free software; you can redistribute it and/or
  5. * modify it under the terms of the GNU Library General Public
  6. * License as published by the Free Software Foundation; either
  7. * version 2 of the License, or (at your option) any later version.
  8. *
  9. * This library is distributed in the hope that it will be useful,
  10. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  11. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
  12. * Library General Public License for more details.
  13. *
  14. * You should have received a copy of the GNU Library General Public
  15. * License along with this library; if not, write to the
  16. * Free Software Foundation, Inc., 51 Franklin St, Fifth Floor,
  17. * Boston, MA 02110-1301, USA.
  18. */
  19. #pragma once
  20. #include <map>
  21. #include <gst/gst.h>
  22. #include <camera_manager.h>
  23. using namespace std;
  24. #define DEFAULT_TIMESTAMP_OFFSET 0
  25. typedef struct gst_property_info
  26. {
  27. int id;
  28. const char *name;
  29. const char *nick;
  30. const char *blurb;
  31. } gst_property_names_t;
  32. typedef struct camera_mode_info {
  33. int mode_id;
  34. char description[128];
  35. } camera_mode_info_t;
  36. /* Use map manage csi_camera properties */
  37. typedef map<int, csi_camera_property_description_s> CameraPropertyMap_t;
  38. typedef map<int, csi_camera_info_s> CamerasInfoMap_t;
  39. typedef map<int, camera_mode_info_t> CameraModeMap_t;
  40. class THeadCamera
  41. {
  42. public:
  43. THeadCamera ();
  44. ~THeadCamera ();
  45. CameraPropertyMap_t m_CurrPropMap;
  46. CameraPropertyMap_t m_TempPropMap;
  47. static int InstallProperties(GObjectClass * gobject_class);
  48. static int CameraEventAction(cams_t *session, csi_camera_event_s *event);
  49. static int ChannelEventAction(cams_t *session, csi_camera_event_s *event);
  50. static int GetGstPropertyInfo(int id, const gst_property_names_t ** info);
  51. bool IsOpened ();
  52. int Init();
  53. int GetProperty(int propId);
  54. int FetchProperty();
  55. int ApplyProperty(bool fullApply = false);
  56. int OpenChannel();
  57. int SubscribeEvent();
  58. int RegisterEventAction();
  59. int Start();
  60. int Stop();
  61. csi_cam_handle_t get_CamHandle(){
  62. return m_CamSession->camera_handle;
  63. }
  64. cams_t *get_CamSession(){
  65. return m_CamSession;
  66. }
  67. private:
  68. cams_t *m_CamSession;
  69. static const gst_property_names_t camera_property_names[];
  70. static CamerasInfoMap_t m_CamerasInfoMap;
  71. static CameraModeMap_t m_CameraModeMap;
  72. static GType BuildExposureModeEnumTypes(void);
  73. static GType BuildCamerasInfoEnumTypes(void);
  74. static GType BuildModeEnumTypes(void);
  75. void DumpProperties(CameraPropertyMap_t &propMap);
  76. };