|
|
|
|
@ -459,19 +459,19 @@ void StreamPublishEngine::videoLoop(StreamPublishConfig initial) {
|
|
|
|
|
QMetaObject::invokeMethod(this, [this, generation] { sourceFailed(generation, text("Invalid stream video dimensions")); }); |
|
|
|
|
continue; |
|
|
|
|
} |
|
|
|
|
std::lock_guard<std::mutex> guard(m->lock); |
|
|
|
|
if (m->generation != generation) continue; |
|
|
|
|
config.source.size = frame.size(); |
|
|
|
|
if (config.video.width != size.width() || config.video.height != size.height()) { |
|
|
|
|
config.video.width = size.width(); config.video.height = size.height(); |
|
|
|
|
if (config.automaticBitrate) config.video.bitrate = std::clamp(size.width() * size.height() * config.video.fps / 11, 250000, 16000000); |
|
|
|
|
generation = ++m->generation; m->frameGeneration = generation; m->started = monotonicUs(); |
|
|
|
|
} |
|
|
|
|
m->wanted = config; |
|
|
|
|
config.video.width = size.width(); config.video.height = size.height(); |
|
|
|
|
if (config.automaticBitrate) config.video.bitrate = std::clamp(size.width() * size.height() * config.video.fps / 11, 250000, 16000000); |
|
|
|
|
DEBUG_INFO(DEBUG_CATEGORY_VIDEO, "desktop screen size resolved source=%s raw=%dx%d target=%dx%d native=%d generation=%llu", |
|
|
|
|
qPrintable(config.source.name), frame.width(), frame.height(), size.width(), size.height(), config.nativeSize, |
|
|
|
|
(unsigned long long)generation); |
|
|
|
|
QMetaObject::invokeMethod(this, [this, generation] { if (generation == m->generation) emit sourcesChanged(); }); |
|
|
|
|
QMetaObject::invokeMethod(this, [this, generation, config] { |
|
|
|
|
if (generation == m->generation && m->running && reconfigure(config)) emit sourcesChanged(); |
|
|
|
|
}); |
|
|
|
|
// GUI изменяет конфигурацию и возвращает последний preview frame уже с новым поколением.
|
|
|
|
|
std::unique_lock<std::mutex> lock(m->lock); |
|
|
|
|
m->wake.wait_for(lock, std::chrono::milliseconds(100), [this, generation] { return !m->running || m->generation != generation; }); |
|
|
|
|
continue; |
|
|
|
|
} |
|
|
|
|
if (config.source.kind == StreamVideoSource::Screen && config.source.size.isEmpty() && !frame.isValid()) { |
|
|
|
|
std::unique_lock<std::mutex> lock(m->lock); m->wake.wait_for(lock, std::chrono::milliseconds(5)); continue; |
|
|
|
|
|