UVCDeviceManager.h 1.3 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970
  1. #ifndef UVCDEVICE_MANAGER_H
  2. #define UVCDEVICE_MANAGER_H
  3. #include "../libuvc/libuvc.h"
  4. #include "../MppDecoder/MppDecoder.h"
  5. #include <stdio.h>
  6. #include <unistd.h>
  7. #include <sys/time.h>
  8. #include "UVCCallBack.h"
  9. #include <list>
  10. #include "UVCDevice.h"
  11. #include <iostream>
  12. #include <memory>
  13. #include "../gpio_explorer.hpp"
  14. #include "../DataManager/DataManager.h"
  15. class UVCManager
  16. {
  17. public:
  18. static UVCManager &getInstance()
  19. {
  20. static UVCManager instance;
  21. return instance;
  22. }
  23. void init();
  24. int deliverFrameInCallBack(uvc_device_handle_t *devh);
  25. void startAllStreaming();
  26. void stopAllStreaming();
  27. uvc_context_t *getContext()
  28. {
  29. return ctx;
  30. }
  31. private:
  32. UVCManager()
  33. {
  34. uvc_init(&ctx, NULL);
  35. }
  36. ~UVCManager()
  37. {
  38. uvc_exit(ctx);
  39. }
  40. UVCManager(const UVCManager &) = delete;
  41. UVCManager &operator=(const UVCManager &) = delete;
  42. uvc_context_t *ctx;
  43. // device list
  44. uvc_device_t **deviceList;
  45. // device number
  46. int deviceNum;
  47. // the UVC device list is been managed by UVCManager
  48. std::list<UVCDevice *> uvcDeviceList;
  49. //
  50. std::shared_ptr<GPIOExplorer> m_GpioExplorer;
  51. };
  52. #endif // UVCDEVICE_MANAGER_H