| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748 |
- #ifndef __VIDEO_RECORDER_H__
- #define __VIDEO_RECORDER_H__
- #include "basic/timer.h"
- #include "avrecorder/capturer/video/VideoCaptureManager.h"
- using namespace avrecorder::video;
- #include "muxer/av_muxer.h"
- #include <deque>
- // #include <condition_variable>
- // #include <queue>
- class VideoRecorder {
- public:
- bool Open(HWND srcHwnd, Encoder<MediaType::VIDEO>::Param& param, CaptureMethod method);
- bool Open(int monitorIdx, Encoder<MediaType::VIDEO>::Param& param, CaptureMethod method);
- bool LoadMuxer(AvMuxer& muxer);
- bool StartRecord();
- void StopRecord();
- AVFrame* GetRenderFrame();
- void Close();
- void SetIsDrawCursor(bool isDraw) { _capturer.setDrawCursor(isDraw); }
- bool IsCaptureOverload() const { return _captureTimer.IsOverload(); }
- double GetLossRate();
- void SetCaptureSource(HWND srcHwnd, CaptureMethod method);
- void SetCaptureSource(int monitorIdx, CaptureMethod method);
- private:
- static constexpr int kCanvasWidth = 1920;
- static constexpr int kCanvasHeight = 1080;
- bool _Open(Encoder<MediaType::VIDEO>::Param& param);
- VideoCaptureManager _capturer;
- AvMuxer* _muxer = nullptr;
- bool _isRecord = false;
- int _streamIndex = -1;
- AVFrame* _encodeFrame = nullptr;
- AVFrame* _renderFrame = nullptr;
- Encoder<MediaType::VIDEO>::Param _param;
- Timer _captureTimer;
- Timer _muxTimer;
- std::mutex _renderMtx;
- uint64_t _totalPts = 0;
- uint64_t _lossPts = 0;
- // 滑动窗口丢帧统计
- static constexpr int LOSS_WINDOW = 100;
- std::deque<bool> _lossHistory;
- };
- #endif
|