Keep a converted frame for encoder reconfiguration
This commit is contained in:
1 parent
97e20d2f1c
commit
8d7ab6a1a6
1 file changed
+5
-3
@@ -103,6 +103,7 @@ struct StreamPublishEngine::Impl {
|
||||
#endif
|
||||
std::unique_ptr<QWindowCapture> window;
|
||||
QImage frame;
|
||||
QImage latestImage;
|
||||
QVideoFrame previewFrame;
|
||||
QVideoFrame presentedPreview;
|
||||
int64_t lastImageCaptureAt = 0;
|
||||
@@ -282,7 +283,7 @@ bool StreamPublishEngine::openSource(const StreamPublishConfig& config) {
|
||||
{
|
||||
std::lock_guard<std::mutex> guard(m->lock);
|
||||
if (!m->running || generation != m->sourceGeneration) return;
|
||||
m->frame = std::move(image); m->framePts = framePts; m->frameGeneration = m->generation;
|
||||
m->latestImage = image; m->frame = std::move(image); m->framePts = framePts; m->frameGeneration = m->generation;
|
||||
}
|
||||
m->wake.notify_all();
|
||||
}, Qt::DirectConnection);
|
||||
@@ -414,7 +415,8 @@ void StreamPublishEngine::closeSource() {
|
||||
if (m->screen) { disconnect(m->screen.get(), nullptr, this, nullptr); m->screen->stop(); }
|
||||
if (m->window) { disconnect(m->window.get(), nullptr, this, nullptr); m->window->stop(); }
|
||||
m->session.reset(); m->camera.reset(); m->screen.reset(); m->window.reset(); m->sink.reset();
|
||||
std::lock_guard<std::mutex> guard(m->lock); m->frame = {}; m->previewFrame = {}; m->presentedPreview = {}; m->framePts = -1;
|
||||
std::lock_guard<std::mutex> guard(m->lock);
|
||||
m->frame = {}; m->latestImage = {}; m->previewFrame = {}; m->presentedPreview = {}; m->framePts = -1;
|
||||
#endif
|
||||
}
|
||||
|
||||
@@ -491,7 +493,7 @@ bool StreamPublishEngine::reconfigure(const StreamPublishConfig& config) {
|
||||
&& (config.video.width != previous.video.width || config.video.height != previous.video.height || config.video.fps != previous.video.fps));
|
||||
{ std::lock_guard<std::mutex> guard(m->lock); m->wanted = config; m->generation++; m->started = monotonicUs(); m->softwareRequest = 0;
|
||||
#ifdef HAVE_STREAM_CAPTURE
|
||||
if (!sourceChange) m->frameGeneration = m->generation;
|
||||
if (!sourceChange) { m->frame = m->latestImage; m->frameGeneration = m->generation; }
|
||||
#endif
|
||||
}
|
||||
if (sourceChange && !openSource(config)) { sourceFailed(m->generation, text("Could not open the selected video source")); return false; }
|
||||
|
||||
Reference in new issue
Block a user