av_recorder.h 2.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081
  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. 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. signals:
  25. void renderFrame(AVFrame* frame);
  26. private:
  27. SettingsPage::Param m_settingsParam;
  28. void initStatusBarUi();
  29. void updateCaptureList();
  30. void startCapture(VideoCapturer::Method method);
  31. void stopCapture();
  32. void startPreview();
  33. void dealCapture();
  34. void stopPreview();
  35. bool startStream(std::string_view path, std::string_view format);
  36. void stopStream();
  37. bool startSyncRecord(); // 开始同步录像
  38. void stopSyncRecord(); // 停止同步录像
  39. void initConnect();
  40. private:
  41. AudioRecorder m_audioRecorder;
  42. VideoRecorder m_videoRecorder;
  43. AvMuxer m_avMuxer;
  44. AvMuxer m_recordMuxer; // 添加用于同步录像的Muxer
  45. // VideoRender m_videoRender;
  46. OpenGLVideoWidget* m_glWidget;
  47. AudioWidget* m_microphoneWidget = nullptr;
  48. AudioWidget* m_speakerWidget = nullptr;
  49. QPushButton* m_recordBtn = nullptr;
  50. QPushButton* m_liveBtn = nullptr;
  51. QPushButton* m_settingsBtn = nullptr;
  52. QCheckBox* m_isDrawCursorBox = nullptr;
  53. QCheckBox* m_syncRecordBox = nullptr; // 添加同步录像的复选框
  54. Timer m_videoRenderTimer;
  55. QTimer m_otherTimer;
  56. QComboBox* m_captureComboBox = nullptr;
  57. QPushButton* m_updateListBtn = nullptr;
  58. bool m_isRecord = false;
  59. bool m_isLive = false;
  60. bool m_isSyncRecord = false; // 是否同步录像
  61. QComboBox* m_captureMethodBox = nullptr;
  62. QLabel* m_captureStatusLabel = nullptr;
  63. QLabel* m_captureTimeLabel = nullptr;
  64. QLabel* m_fpsLabel = nullptr;
  65. QLabel* m_videoEncodeLabel = nullptr;
  66. QLabel* m_videolossRate = nullptr;
  67. QTime m_recordTime;
  68. bool m_isLocked = false;
  69. QStatusBar* m_statusBar = nullptr;
  70. };