av_recorder.h 2.2 KB

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