Use shared live encoder types in stream publication
This commit is contained in:
1 parent
dca1adc173
commit
45720ebaba
3 files changed
+7
-7
No files matched your search
@@ -82,7 +82,7 @@ StreamPublishEngine::StreamPublishEngine(QObject* parent) : QObject(parent), m(s
|
||||
#endif
|
||||
try {
|
||||
m->probeThread = std::thread([this] {
|
||||
auto codecs = supported() ? StreamVideoEncoder::available() : QList<int>();
|
||||
auto codecs = supported() ? LiveVideoEncoder::available() : QList<int>();
|
||||
std::lock_guard<std::mutex> guard(m->lock); m->codecs = std::move(codecs); m->probeReady = true;
|
||||
});
|
||||
} catch (const std::system_error& error) {
|
||||
@@ -415,7 +415,7 @@ void StreamPublishEngine::audioLoop() {
|
||||
|
||||
void StreamPublishEngine::videoLoop() {
|
||||
#ifdef HAVE_STREAM_CAPTURE
|
||||
std::unique_ptr<StreamVideoEncoder> encoder;
|
||||
std::unique_ptr<LiveVideoEncoder> encoder;
|
||||
StreamPublishConfig encoding;
|
||||
QImage lastImage; uint64_t current = 0; uint32_t revision = 0;
|
||||
int64_t lastPts = -1, lastKey = -1000000, next = 0, report = 0; unsigned count = 0, skipped = 0;
|
||||
@@ -438,7 +438,7 @@ void StreamPublishEngine::videoLoop() {
|
||||
if (generation == m->generation) { emit configurationChanged(); emit stateChanged(text("Live")); }
|
||||
});
|
||||
} else {
|
||||
auto candidate = std::make_unique<StreamVideoEncoder>();
|
||||
auto candidate = std::make_unique<LiveVideoEncoder>();
|
||||
if (!candidate->open(config.video)) {
|
||||
QString error = candidate->error();
|
||||
QMetaObject::invokeMethod(this, [this, generation, error] { sourceFailed(generation, error); });
|
||||
@@ -475,7 +475,7 @@ void StreamPublishEngine::videoLoop() {
|
||||
next = now + 1000000 / config.video.fps;
|
||||
stream_publisher_status status; bool needsKey = gui_stream_publish_status(m->id, status) && status.need_key;
|
||||
bool key = pts - lastKey >= 1000000 || needsKey;
|
||||
QList<StreamEncodedFrame> output;
|
||||
QList<LiveEncodedFrame> output;
|
||||
if (!encoder->encode(lastImage, std::max(lastPts + 1, pts), key, output)) {
|
||||
QString error = encoder->error(); QMetaObject::invokeMethod(this, [this, generation, error] { sourceFailed(generation, error); }); continue;
|
||||
}
|
||||
|
||||
@@ -8,7 +8,7 @@
|
||||
#include <QImage>
|
||||
#include <QList>
|
||||
#include <memory>
|
||||
#include "stream_video_encoder.h"
|
||||
#include "live_video_encoder.h"
|
||||
#include "audio_device.h"
|
||||
#include "audio_capture_lease.h"
|
||||
#include "../../../src/stream/stream_publisher.h"
|
||||
@@ -22,7 +22,7 @@ struct StreamVideoSource {
|
||||
};
|
||||
struct StreamPublishConfig {
|
||||
StreamVideoSource source;
|
||||
StreamVideoConfig video;
|
||||
LiveVideoConfig video;
|
||||
QString microphone;
|
||||
bool audio = true;
|
||||
};
|
||||
|
||||
@@ -120,7 +120,7 @@ void StreamPublishWindow::refreshSources() {
|
||||
}
|
||||
void StreamPublishWindow::refreshCodecs() {
|
||||
m_updating = true; int previous = m_codec->currentData().toInt(); m_codec->clear();
|
||||
for (int codec : m_engine->codecs()) m_codec->addItem(StreamVideoEncoder::codecName(codec), codec);
|
||||
for (int codec : m_engine->codecs()) m_codec->addItem(LiveVideoEncoder::codecName(codec), codec);
|
||||
int index = m_codec->findData(previous); if (index >= 0) m_codec->setCurrentIndex(index);
|
||||
m_updating = false; synchronize();
|
||||
}
|
||||
|
||||
Reference in new issue
Block a user