| 330 | } |
| 331 | |
| 332 | void CBackendPlayer::slotVideoFrameChanged(const QVideoFrame &frame) |
| 333 | { |
| 334 | #ifndef HAVE_QVideoWidget |
| 335 | if(m_Video.width() != frame.width() |
| 336 | || m_Video.height() != frame.height()) |
| 337 | { |
| 338 | m_Video = QRect(0, 0, frame.width(), frame.height()); |
| 339 | emit sigSetDesktopSize(m_Video.width(), m_Video.height()); |
| 340 | } |
| 341 | QImage img(frame.width(), frame.height(), QImage::Format_ARGB32); |
| 342 | QPainter painter(&img); |
| 343 | const QVideoFrame::PaintOptions option; |
| 344 | QVideoFrame f = frame; |
| 345 | f.paint(&painter, m_Video, option); |
| 346 | //qDebug(log) << "QVideoSink::videoFrameChanged" << frame << img; |
| 347 | emit this->sigUpdateRect(img); |
| 348 | #endif |
| 349 | //qDebug(log) << "QVideoSink::videoFrameChanged" << frame; |
| 350 | if(m_bScreenShot) { |
| 351 | m_bScreenShot = false; |
| 352 | QImage image = frame.toImage(); |
| 353 | if(image.isNull()) { |
| 354 | qCritical(log) << "frame.toImage() fail"; |
| 355 | } else { |
| 356 | QString szFile = m_pParameters->m_Record.GetImageFile(true); |
| 357 | if(!image.save(szFile, "PNG")) |
| 358 | { |
| 359 | qCritical(log) << "Capture image save to file fail." << szFile; |
| 360 | return; |
| 361 | } |
| 362 | qDebug(log) << "Capture image to file:" << szFile; |
| 363 | qDebug(log) << "End action:" << m_pParameters->m_Record.GetEndAction(); |
| 364 | switch(m_pParameters->m_Record.GetEndAction()) |
| 365 | { |
| 366 | case CParameterRecord::ENDACTION::OpenFile: { |
| 367 | bool bRet = QDesktopServices::openUrl(QUrl::fromLocalFile(szFile)); |
| 368 | if(!bRet) |
| 369 | qCritical(log) << "Fail: Open capture image file" << szFile; |
| 370 | break; |
| 371 | } |
| 372 | case CParameterRecord::ENDACTION::OpenFolder: { |
| 373 | QFileInfo fi(szFile); |
| 374 | QDesktopServices::openUrl(QUrl::fromLocalFile(fi.absolutePath())); |
| 375 | break; |
| 376 | } |
| 377 | default: |
| 378 | break; |
| 379 | } |
| 380 | } |
| 381 | } |
| 382 | |
| 383 | #if defined(HAVE_QT6_RECORD) && defined(HAVE_QVideoWidget) |
| 384 | if(QMediaRecorder::RecordingState == m_Recorder.recorderState()) { |
| 385 | bool bRet = m_VideoFrameInput.sendVideoFrame(frame); |
| 386 | if(!bRet) { |
| 387 | //TODO: 放入未成功发送队列, |
| 388 | // 当 QVideoFrameInput::readyToSendVideoFrame() 时,再发送 |
| 389 | qDebug(log) << "m_VideoFrameInput.sendVideoFrame fail"; |
nothing calls this directly
no test coverage detected