| 65 | } |
| 66 | |
| 67 | void CMultimediaRecord::slotUpdateVideoFrame(const QImage image) |
| 68 | { |
| 69 | //qDebug(log) << Q_FUNC_INFO; |
| 70 | #ifdef HAVE_QT6_RECORD |
| 71 | // 将 QImage 转换为 QVideoFrame |
| 72 | QImage img = image; |
| 73 | //qDebug(log) << "Image format:" << img.format(); |
| 74 | if(QImage::Format_ARGB32 != image.format()) |
| 75 | img = image.convertToFormat(QImage::Format_ARGB32); |
| 76 | /* |
| 77 | QVideoFrameFormat format(image.size(), QVideoFrameFormat::Format_ABGR8888); |
| 78 | QVideoFrame frame(format); |
| 79 | if (frame.map(QVideoFrame::WriteOnly)) { |
| 80 | memcpy(frame.bits(0), image.bits(), image.sizeInBytes()); |
| 81 | frame.unmap(); |
| 82 | }//*/ |
| 83 | QVideoFrame frame(img); |
| 84 | // 设置帧的时间戳(微秒),这对于同步很重要 |
| 85 | if (m_VideoFrameStartTime == 0) m_VideoFrameStartTime = QDateTime::currentMSecsSinceEpoch() * 1000; |
| 86 | qint64 currentTime = QDateTime::currentMSecsSinceEpoch() * 1000 - m_VideoFrameStartTime; |
| 87 | frame.setStartTime(currentTime); |
| 88 | qreal rate = m_ParaRecord.GetVideoFrameRate(); |
| 89 | if(rate <= 0) |
| 90 | rate = 24; |
| 91 | frame.setEndTime(currentTime + qreal(1000000) / rate); |
| 92 | frame.setStreamFrameRate(m_ParaRecord.GetVideoFrameRate());//*/ |
| 93 | m_VideoFrameInput.sendVideoFrame(frame); |
| 94 | #endif |
| 95 | } |
| 96 | |
| 97 | #if HAVE_QT6_RECORD |
| 98 | void CMultimediaRecord::slotRecordStateChanged(QMediaRecorder::RecorderState state) |
nothing calls this directly
no test coverage detected