av_recorder.h 2.3 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677
  1. #pragma once
  2. #include <QCheckBox>
  3. #include <QLayout>
  4. #include <QListWidget>
  5. #include <QPushButton>
  6. #include <QTime>
  7. #include <QTimer>
  8. #include <QWidget>
  9. #include "audio_widget.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. class AvRecorder : public QWidget
  16. {
  17. Q_OBJECT
  18. public:
  19. AvRecorder(QWidget* parent = nullptr);
  20. ~AvRecorder();
  21. bool start();
  22. QWidget* statusBar() const { return m_statusBar; }
  23. void setSettings(const SettingsPage::Param& param);
  24. private:
  25. AudioRecorder m_audioRecorder;
  26. VideoRecorder m_videoRecorder;
  27. AvMuxer m_avMuxer;
  28. AvMuxer m_recordMuxer; // 添加用于同步录像的Muxer
  29. // VideoRender m_videoRender;
  30. OpenGLVideoWidget* m_glWidget;
  31. AudioWidget* m_microphoneWidget = nullptr;
  32. AudioWidget* m_speakerWidget = nullptr;
  33. QPushButton* m_recordBtn = nullptr;
  34. QPushButton* m_liveBtn = nullptr;
  35. QPushButton* m_settingsBtn = nullptr;
  36. QCheckBox* m_isDrawCursorBox = nullptr;
  37. QCheckBox* m_syncRecordBox = nullptr; // 添加同步录像的复选框
  38. Timer m_videoRenderTimer;
  39. QTimer m_otherTimer;
  40. QListWidget* m_captureListWidget = nullptr;
  41. QPushButton* m_updateListBtn = nullptr;
  42. bool m_isRecord = false;
  43. bool m_isLive = false;
  44. bool m_isSyncRecord = false; // 是否同步录像
  45. QComboBox* m_captureMethodBox = nullptr;
  46. QLabel* m_captureStatusLabel = nullptr;
  47. QLabel* m_captureTimeLabel = nullptr;
  48. QLabel* m_fpsLabel = nullptr;
  49. QLabel* m_videoEncodeLabel = nullptr;
  50. QLabel* m_videolossRate = nullptr;
  51. SettingsPage::Param m_settingsParam;
  52. QVBoxLayout* initListUi();
  53. QVBoxLayout* initAudioUi();
  54. QVBoxLayout* initOtherUi();
  55. QTime m_recordTime;
  56. bool m_isLocked = false;
  57. QStatusBar* m_statusBar = nullptr;
  58. void initStatusBarUi();
  59. void updateCaptureList();
  60. void startCapture(VideoCapturer::Method method);
  61. void stopCapture();
  62. void startPreview();
  63. void dealCapture();
  64. void stopPreview();
  65. bool startStream(std::string_view path, std::string_view format);
  66. void stopStream();
  67. bool startSyncRecord(); // 开始同步录像
  68. void stopSyncRecord(); // 停止同步录像
  69. void initConnect();
  70. };