55#include " GUI/filterselector.h"
66#include " GUI/Comments.h"
77#include " GUI/Plots.h"
8+ #include " GUI/utils.h"
89#include < QDir>
910#include < QAction>
1011#include < QStandardPaths>
@@ -39,7 +40,9 @@ Player::Player(QWidget *parent) :
3940 ui->commentsPlaceHolderFrame ->setLayout (new QHBoxLayout);
4041 ui->commentsPlaceHolderFrame ->layout ()->setContentsMargins (0 , 0 , 0 , 0 );
4142
43+ #ifdef QT_AVPLAYER_MULTIMEDIA
4244 m_audioOutput.reset (new QAVAudioOutput);
45+ #endif // QT_AVPLAYER_MULTIMEDIA
4346
4447 QGraphicsScene* scene = new QGraphicsScene (ui->graphicsView );
4548 ui->graphicsView ->setScene (scene);
@@ -50,14 +53,49 @@ Player::Player(QWidget *parent) :
5053
5154 m_player = new MediaPlayer ();
5255
56+ #ifdef QT_AVPLAYER_MULTIMEDIA
5357 QObject::connect (m_player, &QAVPlayer::audioFrame, m_player, [this ](const QAVAudioFrame &frame) {
5458 if (!ui->playerSlider ->isSliderDown () && !m_mute)
5559 m_audioOutput->play (frame);
5660 }, Qt::DirectConnection);
61+ #else
62+ QObject::connect (m_player, &QAVPlayer::audioFrame, m_player, [this ](const QAVAudioFrame &frame) {
63+ if (!ui->playerSlider ->isSliderDown () && !m_mute)
64+ {
65+ QAudioFormat format;
66+ format.setSampleRate (frame.format ().sampleRate ());
67+ format.setChannelCount (frame.format ().channelCount ());
68+ switch (frame.format ().sampleFormat ())
69+ {
70+ case QAVAudioFormat::UInt8:
71+ format.setSampleFormat (QAudioFormat::UInt8); break ;
72+ case QAVAudioFormat::Int16:
73+ format.setSampleFormat (QAudioFormat::Int16); break ;
74+ case QAVAudioFormat::Int32:
75+ format.setSampleFormat (QAudioFormat::Int32); break ;
76+ case QAVAudioFormat::Float:
77+ format.setSampleFormat (QAudioFormat::Float); break ;
78+ default :
79+ format.setSampleFormat (QAudioFormat::Unknown); break ;
80+ }
5781
58- QObject::connect (m_player, &QAVPlayer::videoFrame, m_player, [this ](const QAVVideoFrame &frame) {
82+ if (m_audioOutput.isNull () || m_audioOutput->state () == QAudio::StoppedState || m_audioOutput->format () != format)
83+ {
84+ m_audioOutput.reset (new QAudioSink (format));
85+ m_audioDevice = m_audioOutput->start ();
86+ }
87+
88+ m_audioDevice->write (frame.data ());
89+ }
90+ }, Qt::DirectConnection);
91+ #endif // QT_AVPLAYER_MULTIMEDIA
5992
93+ QObject::connect (m_player, &QAVPlayer::videoFrame, m_player, [this ](const QAVVideoFrame &frame) {
94+ #ifdef QT_AVPLAYER_MULTIMEDIA
6095 videoFrame = frame.convertTo (AV_PIX_FMT_RGB32);
96+ #else
97+ videoFrame = QAVV_QV (frame);
98+ #endif // QT_AVPLAYER_MULTIMEDIA
6199
62100#if QT_VERSION < QT_VERSION_CHECK(6, 0, 0)
63101 auto surface = m_w->videoSurface ();
0 commit comments