Log capture conversion thread and completion
This commit is contained in:
1 parent
8d7ab6a1a6
commit
5c9bf9e47c
1 file changed
+9
-1
@@ -4,6 +4,7 @@
|
||||
#include "../transport/stream_bridge.h"
|
||||
#include "debug_config.h"
|
||||
#include <QGuiApplication>
|
||||
#include <QThread>
|
||||
#include <QScreen>
|
||||
#include <QRandomGenerator>
|
||||
#include <QTransform>
|
||||
@@ -75,6 +76,7 @@ struct StreamPublishEngine::Impl {
|
||||
uint64_t audioFrames = 0;
|
||||
int channels = 2;
|
||||
uint64_t capturedFrames = 0;
|
||||
uint64_t convertedCaptureFrames = 0;
|
||||
int64_t captureReport = 0;
|
||||
std::atomic<const char*> videoStage{"stopped"};
|
||||
std::atomic<int64_t> videoStageAt{0};
|
||||
@@ -233,7 +235,7 @@ bool StreamPublishEngine::openSource(const StreamPublishConfig& config) {
|
||||
#ifdef HAVE_STREAM_CAPTURE
|
||||
uint64_t generation;
|
||||
{ std::lock_guard<std::mutex> guard(m->lock); generation = ++m->sourceGeneration;
|
||||
m->backendOrigin = m->backendAnchor = -1; m->capturedFrames = 0; m->lastImageCaptureAt = 0; }
|
||||
m->backendOrigin = m->backendAnchor = -1; m->capturedFrames = m->convertedCaptureFrames = 0; m->lastImageCaptureAt = 0; }
|
||||
m->session = std::make_unique<QMediaCaptureSession>(); m->sink = std::make_unique<QVideoSink>(this);
|
||||
m->session->setVideoSink(m->sink.get());
|
||||
connect(m->sink.get(), &QVideoSink::videoFrameChanged, this, [this, generation](const QVideoFrame& frame) {
|
||||
@@ -267,6 +269,7 @@ bool StreamPublishEngine::openSource(const StreamPublishConfig& config) {
|
||||
}
|
||||
/* QVideoFrame conversion stays on Qt's persistent multimedia callback thread.
|
||||
* Qt worker-thread storage was preventing the short-lived publisher thread from exiting on Windows. */
|
||||
int64_t convertAt = monotonicUs();
|
||||
QImage image = frame.toImage();
|
||||
if (image.isNull()) {
|
||||
DEBUG_ERROR(DEBUG_CATEGORY_VIDEO, "desktop captured frame conversion failed generation=%llu format=%d size=%dx%d",
|
||||
@@ -284,6 +287,11 @@ bool StreamPublishEngine::openSource(const StreamPublishConfig& config) {
|
||||
std::lock_guard<std::mutex> guard(m->lock);
|
||||
if (!m->running || generation != m->sourceGeneration) return;
|
||||
m->latestImage = image; m->frame = std::move(image); m->framePts = framePts; m->frameGeneration = m->generation;
|
||||
if (!m->convertedCaptureFrames++) DEBUG_INFO(DEBUG_CATEGORY_VIDEO,
|
||||
"desktop first image conversion complete generation=%llu size=%dx%d callback_tid=%llu gui_thread=%d convert_us=%lld",
|
||||
(unsigned long long)generation, m->latestImage.width(), m->latestImage.height(),
|
||||
(unsigned long long)(quintptr)QThread::currentThreadId(), QThread::currentThread() == qApp->thread(),
|
||||
(long long)(monotonicUs() - convertAt));
|
||||
}
|
||||
m->wake.notify_all();
|
||||
}, Qt::DirectConnection);
|
||||
|
||||
Reference in new issue
Block a user