Use verified Android encoder levels and expose negotiated frame rate
This commit is contained in:
1 parent
3037c5fa87
commit
521dce5528
3 files changed
+12
-6
No files matched your search
@@ -283,7 +283,9 @@ class CallVideoEngine(private val context: Context, private val id: Long) {
|
||||
val selected = CallVideoNative.choose(caps, peer, desired.array()) ?: continue
|
||||
var candidate: CallVideoCodec? = null
|
||||
try {
|
||||
candidate = CallVideoCodec(CallVideoFormat.from(selected), bitrate, implementation.name)
|
||||
val verified = CallVideoFormat.from(selected).let { it.copy(level = maxOf(it.level, implementation.level)) }
|
||||
check(CallVideoNative.supported(caps, peer, verified.array())) { "Verified encoder level exceeds peer capabilities" }
|
||||
candidate = CallVideoCodec(verified, bitrate, implementation.name)
|
||||
candidate.prepare()
|
||||
check(CallVideoNative.supported(caps, peer, candidate.format.array())) { "Actual encoder format exceeds peer capabilities" }
|
||||
return candidate
|
||||
|
||||
@@ -370,7 +370,8 @@ void CallVideoEngine::transmit() {
|
||||
}
|
||||
format = next; appliedRevision = revision; forceKey = true; request = 0;
|
||||
if (call_video_port_format(m->id, &format, encoder.bitrate()) < 0) break;
|
||||
m->report(QString("%1 · %2×%3 · %4 kbit/s").arg(format.codec == 2 ? "H.265" : "H.264").arg(width).arg(height).arg(encoder.bitrate() / 1000));
|
||||
m->report(QString("%1 · %2×%3 · %4 fps · %5 kbit/s").arg(format.codec == 2 ? "H.265" : "H.264")
|
||||
.arg(width).arg(height).arg(format.fps).arg(encoder.bitrate() / 1000));
|
||||
}
|
||||
if (state.configured_generation != format.generation) { idle(); continue; }
|
||||
if (state.key_serial != keySerial) { keySerial = state.key_serial; forceKey = true; }
|
||||
@@ -393,8 +394,8 @@ void CallVideoEngine::transmit() {
|
||||
encodeMax = std::max(encodeMax, nowUs() - encodeStarted);
|
||||
if (completion.request) {
|
||||
call_video_port_applied(m->id, completion.generation, completion.request, completion.bitrate);
|
||||
m->report(QString("%1 · %2×%3 · %4 kbit/s").arg(format.codec == 2 ? "H.265" : "H.264")
|
||||
.arg(format.width).arg(format.height).arg(encoder.bitrate() / 1000));
|
||||
m->report(QString("%1 · %2×%3 · %4 fps · %5 kbit/s").arg(format.codec == 2 ? "H.265" : "H.264")
|
||||
.arg(format.width).arg(format.height).arg(format.fps).arg(encoder.bitrate() / 1000));
|
||||
}
|
||||
if (!encoded) {
|
||||
m->report(encoder.error());
|
||||
|
||||
@@ -2,6 +2,7 @@
|
||||
* один decoder на весь поток, непрерывные capture PTS и измеренный bitrate. */
|
||||
#include <QtTest>
|
||||
#include <QScopeGuard>
|
||||
#include <QRegularExpression>
|
||||
#include <clocale>
|
||||
#include "../src/call_video_encoder.h"
|
||||
#include "../src/call_video_decoder.h"
|
||||
@@ -144,10 +145,12 @@ private slots:
|
||||
QVERIFY(!call_video_inspect_key(codec, reinterpret_cast<const uint8_t*>(bytes.constData()), bytes.size(), &actual));
|
||||
call_video_frame f{}; f.call_id = 1; f.flags = CALL_VIDEO_KEY; f.size = f.length = bytes.size();
|
||||
f.data = reinterpret_cast<const uint8_t*>(bytes.constData());
|
||||
f.format = {1, (uint16_t)actual.width, (uint16_t)actual.height, 30, 0, (uint8_t)codec,
|
||||
const auto rate = QRegularExpression(QStringLiteral("-fps(30|50|60)-")).match(name);
|
||||
const unsigned fps = rate.hasMatch() ? rate.captured(1).toUInt() : 30;
|
||||
f.format = {1, (uint16_t)actual.width, (uint16_t)actual.height, (uint16_t)fps, 0, (uint8_t)codec,
|
||||
(uint8_t)actual.level, 4000000, (uint8_t)actual.profile};
|
||||
CallVideoDecoder decoder(CallVideoDecoder::Backend::SoftwareOnly);
|
||||
for (unsigned i = 0; i < 4; ++i) { f.frame_id = i + 1; f.pts_us = 1000000 + i * 33333;
|
||||
for (unsigned i = 0; i < 8; ++i) { f.frame_id = i + 1; f.pts_us = 1000000 + i * 1000000ll / fps;
|
||||
QImage image; call_video_frame output{};
|
||||
QCOMPARE(decoder.submit(f), 1); QCOMPARE(decoder.receive(output, image), 1); QCOMPARE(output.pts_us, f.pts_us); }
|
||||
DEBUG_INFO(DEBUG_CATEGORY_CALL, "hardware stream decoded file=%s", qPrintable(name));
|
||||
|
||||
Reference in new issue
Block a user