| 11 | #include "BackendPlayer.h" |
| 12 | |
| 13 | static Q_LOGGING_CATEGORY(log, "Player.Backend") |
| 14 | |
| 15 | CBackendPlayer::CBackendPlayer(COperatePlayer *pOperate) |
| 16 | : CBackendDesktop(pOperate) |
| 17 | , m_pCamera(nullptr) |
| 18 | , m_bScreenShot(false) |
| 19 | , m_nPosition(0) |
| 20 | , m_nDuration(0) |
| 21 | { |
| 22 | bool check = false; |
| 23 | qDebug(log) << Q_FUNC_INFO; |
| 24 | |
| 25 | m_pParameters = qobject_cast<CParameterPlayer*>(pOperate->GetParameter()); |
| 26 | |
| 27 | #if HAVE_QVideoWidget |
| 28 | check = connect(&m_VideoSink, &QVideoSink::videoFrameChanged, |
| 29 | pOperate->GetVideoSink(), &QVideoSink::videoFrameChanged); |
| 30 | Q_ASSERT(check); |
| 31 | #endif |
| 32 | |
| 33 | check = connect( |
| 34 | &m_VideoSink, SIGNAL(videoFrameChanged(const QVideoFrame&)), |
| 35 | this, SLOT(slotVideoFrameChanged(QVideoFrame))); |
| 36 | Q_ASSERT(check); |
| 37 | |
| 38 | #if HAVE_QT6_RECORD |
| 39 | check = connect( |
| 40 | &m_AudioBufferOutput, &QAudioBufferOutput::audioBufferReceived, |
| 41 | this, [&](const QAudioBuffer &buffer){ |
| 42 | //qDebug(log) << "Audio buffer output"; |
| 43 | if(QMediaRecorder::RecordingState != m_Recorder.recorderState()) |
| 44 | return; |
| 45 | bool bRet = m_AudioBufferInput.sendAudioBuffer(buffer); |
| 46 | if(!bRet) { |
| 47 | //TODO: 放入未成功发送队列, |
| 48 | // 当 QVideoFrameInput::readyToSendVideoFrame() 时,再发送 |
| 49 | qDebug(log) << "m_AudioBufferInput.sendAudioBuffer fail"; |
| 50 | } |
| 51 | }); |
| 52 | Q_ASSERT(check); |
| 53 | #endif |
| 54 | |
| 55 | check = connect(pOperate, &COperatePlayer::sigStart, |
| 56 | this, [&](bool bStart){ |
| 57 | if(bStart) |
| 58 | slotStart(); |
| 59 | else |
| 60 | slotStop(); |
| 61 | }); |
| 62 | Q_ASSERT(check); |
| 63 | check = connect( |
| 64 | pOperate, &COperatePlayer::sigPause, |
| 65 | this, [&](bool bPause){ |
| 66 | switch (m_pParameters->GetType()) { |
| 67 | case CParameterPlayer::TYPE::Camera: |
| 68 | if(bPause) { |
| 69 | if(m_pCamera->isActive()) |
| 70 | m_pCamera->stop(); |
nothing calls this directly
no test coverage detected