Выдавать готовые кадры GPU без дополнительного ожидания в TX
This commit is contained in:
1 parent
6715acdef8
commit
ae8eeab490
3 files changed
+31
-25
No files matched your search
@@ -238,10 +238,10 @@ void CallVideoEngine::transmit() {
|
||||
DEBUG_WARN(DEBUG_CATEGORY_CALL, "video TX skips old capture age_us=%lld", (long long)(nowUs() - pts));
|
||||
lastPts = pts; ++expired; continue;
|
||||
}
|
||||
LiveEncodedFrame output; CallVideoRateCompletion completion;
|
||||
QList<LiveEncodedFrame> outputs; CallVideoRateCompletion completion;
|
||||
int64_t encodeStarted = nowUs();
|
||||
inputAgeMax = std::max(inputAgeMax, encodeStarted - pts);
|
||||
bool encoded = encoder.encode(image, pts, forceKey, output, completion); lastPts = pts;
|
||||
bool encoded = encoder.encode(image, pts, forceKey, outputs, completion); lastPts = pts;
|
||||
encodeMax = std::max(encodeMax, nowUs() - encodeStarted);
|
||||
if (completion.request) {
|
||||
call_video_port_applied(m->id, completion.generation, completion.request, completion.bitrate);
|
||||
@@ -249,26 +249,29 @@ void CallVideoEngine::transmit() {
|
||||
.arg(format.width).arg(format.height).arg(encoder.bitrate() / 1000));
|
||||
}
|
||||
if (!encoded) { forceKey = true; m->report(encoder.error()); continue; }
|
||||
// GPU может вернуть несколько уже готовых кадров: отправляем все, не добавляя очередь в TX worker.
|
||||
for (const auto& output : outputs) {
|
||||
++encodedCount; if (output.key) ++keyCount;
|
||||
call_video_frame packet{};
|
||||
packet.call_id = m->id; packet.frame_id = ++frameId; packet.pts_us = pts; packet.format = format;
|
||||
packet.call_id = m->id; packet.frame_id = ++frameId; packet.pts_us = output.pts; packet.format = format;
|
||||
packet.size = packet.length = output.data.size(); packet.data = reinterpret_cast<const uint8_t*>(output.data.constData());
|
||||
packet.flags = output.key ? CALL_VIDEO_KEY : 0;
|
||||
{ std::lock_guard<std::mutex> guard(m->lock);
|
||||
if (!m->running || !m->enabled || m->revision != revision || nowUs() - pts > CallCameraMaxFrameAgeUs) {
|
||||
if (!m->running || !m->enabled || m->revision != revision || nowUs() - output.pts > CallCameraMaxFrameAgeUs) {
|
||||
DEBUG_WARN(DEBUG_CATEGORY_CALL, "video TX discards obsolete encoded frame revision=%llu/%llu enabled=%d age_us=%lld",
|
||||
(unsigned long long)revision, (unsigned long long)m->revision, m->enabled, (long long)(nowUs() - pts));
|
||||
(unsigned long long)revision, (unsigned long long)m->revision, m->enabled, (long long)(nowUs() - output.pts));
|
||||
++expired;
|
||||
forceKey = true; continue;
|
||||
}
|
||||
forceKey = call_video_port_send(&packet) != 1; }
|
||||
// Одинаковое окно исходного PTS на всех этапах: примерно один кадр в секунду, без трассы каждого кадра.
|
||||
if (pts % 1000000 < 34000)
|
||||
if (output.pts % 1000000 < 34000)
|
||||
DEBUG_DEBUG(DEBUG_CATEGORY_CALL,
|
||||
"video timing stage=encode call=%llu frame=%llu pts=%lld mono_us=%lld encode_us=%lld accepted=%d",
|
||||
(unsigned long long)m->id, (unsigned long long)frameId, (long long)pts, (long long)nowUs(),
|
||||
(unsigned long long)m->id, (unsigned long long)frameId, (long long)output.pts, (long long)nowUs(),
|
||||
(long long)(nowUs() - encodeStarted), !forceKey);
|
||||
if (forceKey) ++sendBusy;
|
||||
if (forceKey) { ++sendBusy; break; }
|
||||
}
|
||||
#else
|
||||
idle();
|
||||
#endif
|
||||
|
||||
Reference in new issue
Block a user