av_recorder.h 2.3 KB

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