playerdemowindow.h 1.6 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667
  1. #ifndef PLAYERDEMOWINDOW_H
  2. #define PLAYERDEMOWINDOW_H
  3. #pragma once
  4. #include <QAudioOutput>
  5. #include <QComboBox>
  6. #include <QIODevice>
  7. #include <QLabel>
  8. #include <QPushButton>
  9. #include <QSlider>
  10. #include <QWidget>
  11. #include <QCheckBox>
  12. #include "AvRecorder/ui/opengl_video_widget.h"
  13. #include "Avplayer/FFmpegVideoPuller.h"
  14. #include "AudioPlayer.h"
  15. #include "VideoPlayer.h"
  16. extern "C" {
  17. #include <libswresample/swresample.h>
  18. }
  19. struct sonicStreamStruct;
  20. class PlayerDemoWindow : public QWidget
  21. {
  22. Q_OBJECT
  23. public:
  24. explicit PlayerDemoWindow(QWidget* parent = nullptr);
  25. ~PlayerDemoWindow();
  26. void startPlay(const QString& url);
  27. private slots:
  28. void onProgressSliderMoved(int value);
  29. void onProgressSliderReleased();
  30. void onSpeedChanged(int index);
  31. void onPlayClicked();
  32. private:
  33. FFmpegVideoPuller* m_puller = nullptr;
  34. OpenGLVideoWidget* m_videoWidget = nullptr;
  35. AudioPlayer* m_audioPlayer = nullptr;
  36. VideoPlayer* m_videoPlayer = nullptr;
  37. // UI
  38. QSlider* m_progressSlider = nullptr;
  39. QLabel* m_timeLabel = nullptr;
  40. QComboBox* m_speedCombo = nullptr;
  41. QPushButton* m_playBtn = nullptr;
  42. // 进度相关
  43. bool m_sliderPressed = false;
  44. double m_firstPts = 0.0;
  45. double m_lastPts = 0.0;
  46. double m_duration = 0.0;
  47. std::atomic<bool> speedFlag;
  48. bool m_playing;
  49. void updateProgress();
  50. QString formatTime(double seconds) const;
  51. QCheckBox* m_keepAspectCheck = nullptr;
  52. private:
  53. SwrContext* m_swrCtx = nullptr;
  54. uint8_t* m_swrBuffer = nullptr;
  55. int m_swrBufferSize = 0;
  56. };
  57. #endif // PLAYERDEMOWINDOW_H