video_capture_linux.h 2.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566
  1. /*
  2. * Copyright (c) 2012 The WebRTC project authors. All Rights Reserved.
  3. *
  4. * Use of this source code is governed by a BSD-style license
  5. * that can be found in the LICENSE file in the root of the source
  6. * tree. An additional intellectual property rights grant can be found
  7. * in the file PATENTS. All contributing project authors may
  8. * be found in the AUTHORS file in the root of the source tree.
  9. */
  10. #ifndef MODULES_VIDEO_CAPTURE_MAIN_SOURCE_LINUX_VIDEO_CAPTURE_LINUX_H_
  11. #define MODULES_VIDEO_CAPTURE_MAIN_SOURCE_LINUX_VIDEO_CAPTURE_LINUX_H_
  12. #include <stddef.h>
  13. #include <stdint.h>
  14. #include <memory>
  15. #include "modules/video_capture/video_capture_defines.h"
  16. #include "modules/video_capture/video_capture_impl.h"
  17. #include "rtc_base/platform_thread.h"
  18. #include "rtc_base/synchronization/mutex.h"
  19. namespace webrtc {
  20. namespace videocapturemodule {
  21. class VideoCaptureModuleV4L2 : public VideoCaptureImpl {
  22. public:
  23. VideoCaptureModuleV4L2();
  24. ~VideoCaptureModuleV4L2() override;
  25. int32_t Init(const char* deviceUniqueId);
  26. int32_t StartCapture(const VideoCaptureCapability& capability) override;
  27. int32_t StopCapture() override;
  28. bool CaptureStarted() override;
  29. int32_t CaptureSettings(VideoCaptureCapability& settings) override;
  30. private:
  31. enum { kNoOfV4L2Bufffers = 4 };
  32. static void CaptureThread(void*);
  33. bool CaptureProcess();
  34. bool AllocateVideoBuffers();
  35. bool DeAllocateVideoBuffers();
  36. // TODO(pbos): Stop using unique_ptr and resetting the thread.
  37. std::unique_ptr<rtc::PlatformThread> _captureThread;
  38. Mutex capture_lock_;
  39. bool quit_ RTC_GUARDED_BY(capture_lock_);
  40. int32_t _deviceId;
  41. int32_t _deviceFd;
  42. int32_t _buffersAllocatedByDevice;
  43. int32_t _currentWidth;
  44. int32_t _currentHeight;
  45. int32_t _currentFrameRate;
  46. bool _captureStarted;
  47. VideoType _captureVideoType;
  48. struct Buffer {
  49. void* start;
  50. size_t length;
  51. };
  52. Buffer* _pool;
  53. };
  54. } // namespace videocapturemodule
  55. } // namespace webrtc
  56. #endif // MODULES_VIDEO_CAPTURE_MAIN_SOURCE_LINUX_VIDEO_CAPTURE_LINUX_H_