av_recorder.h 2.4 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586
  1. #pragma once
  2. #include <QCheckBox>
  3. #include <QLayout>
  4. #include <QPushButton>
  5. #include <QTime>
  6. #include <QTimer>
  7. #include <QWidget>
  8. #include "audio_widget.h"
  9. #include "avrecorder/capturer/video/VideoCaptureManager.h"
  10. #include "qcombobox.h"
  11. #include "qobjectdefs.h"
  12. #include "qstatusbar.h"
  13. #include "recorder/audio_recorder.h"
  14. #include "recorder/video_recorder.h"
  15. #include "ui/opengl_video_widget.h"
  16. #include "ui/settings_page.h"
  17. using namespace avrecorder::video;
  18. class AvRecorder : public QWidget
  19. {
  20. Q_OBJECT
  21. public:
  22. AvRecorder(QWidget* parent = nullptr);
  23. ~AvRecorder();
  24. bool start();
  25. QWidget* statusBar() const { return m_statusBar; }
  26. void setSettings(const SettingsPage::Param& param);
  27. public slots:
  28. void renderFrame();
  29. private:
  30. SettingsPage::Param m_settingsParam;
  31. void initStatusBarUi();
  32. void updateCaptureList();
  33. void startCapture(CaptureMethod method);
  34. void stopCapture();
  35. void startPreview();
  36. void dealCapture();
  37. void stopPreview();
  38. bool startStream(std::string_view path, std::string_view format);
  39. void stopStream();
  40. bool startSyncRecord(); // 开始同步录像
  41. void stopSyncRecord(); // 停止同步录像
  42. void initConnect();
  43. private:
  44. AudioRecorder m_audioRecorder;
  45. VideoRecorder m_videoRecorder;
  46. AvMuxer m_avMuxer;
  47. AvMuxer m_recordMuxer; // 添加用于同步录像的Muxer
  48. // VideoRender m_videoRender;
  49. OpenGLVideoWidget* m_glWidget;
  50. AudioWidget* m_microphoneWidget = nullptr;
  51. AudioWidget* m_speakerWidget = nullptr;
  52. QPushButton* m_recordBtn = nullptr;
  53. QPushButton* m_liveBtn = nullptr;
  54. QPushButton* m_settingsBtn = nullptr;
  55. QCheckBox* m_isDrawCursorBox = nullptr;
  56. QCheckBox* m_syncRecordBox = nullptr; // 添加同步录像的复选框
  57. QTimer* m_videoRenderTimer = nullptr;
  58. QTimer m_otherTimer;
  59. QComboBox* m_captureComboBox = nullptr;
  60. QPushButton* m_updateListBtn = nullptr;
  61. bool m_isRecord = false;
  62. bool m_isLive = false;
  63. bool m_isSyncRecord = false; // 是否同步录像
  64. QComboBox* m_captureMethodBox = nullptr;
  65. QLabel* m_captureStatusLabel = nullptr;
  66. QLabel* m_captureTimeLabel = nullptr;
  67. QLabel* m_fpsLabel = nullptr;
  68. QLabel* m_videoEncodeLabel = nullptr;
  69. QLabel* m_videolossRate = nullptr;
  70. QTime m_recordTime;
  71. bool m_isLocked = false;
  72. QStatusBar* m_statusBar = nullptr;
  73. void updateCaptureMethodBox(bool isMonitor);
  74. void onCaptureSourceChanged();
  75. };