Update call video controls and sensor rotation across Android and desktop
This commit is contained in:
1 parent
ae1d05deda
commit
10018d008e
36 files changed
+1408
-381
No files matched your search
@@ -227,37 +227,44 @@ call_video_caps CallVideoDecoder::capabilities() {
|
||||
for (unsigned codec = 1; codec <= 2; ++codec) {
|
||||
unsigned profiles = 0, hardwareProfiles = 0, pipeline = 0;
|
||||
for (unsigned profile = 1; profile <= (codec == 1 ? 2u : 1u); ++profile) {
|
||||
uint8_t bytes[8192]; int size = call_video_probe_key(codec, profile, bytes, sizeof(bytes));
|
||||
if (size < 0) continue;
|
||||
for (Backend backend : {Backend::HardwareOnly, Backend::SoftwareOnly}) {
|
||||
CallVideoDecoder decoder(backend);
|
||||
call_video_frame input{}; input.call_id = 1; input.flags = CALL_VIDEO_KEY;
|
||||
input.data = bytes; input.size = input.length = size;
|
||||
input.format = {1, 1280, 720, 30, 0, (uint8_t)codec, (uint8_t)(codec == 1 ? 31 : 93), 4000000, (uint8_t)profile};
|
||||
unsigned sent = 0, received = 0; bool valid = true, outputBeforeEos = false;
|
||||
const int64_t start = call_video_playout_now_us();
|
||||
while (valid && received < 8 && call_video_playout_now_us() - start < 1500000) {
|
||||
if (sent < 8 && call_video_playout_now_us() - start >= sent * 33333ll) {
|
||||
input.frame_id = sent + 1; input.pts_us = 1000000 + sent * 33333ll;
|
||||
int result = decoder.submit(input); if (result < 0) valid = false; else if (result) ++sent;
|
||||
bool bothOrientations = true;
|
||||
unsigned backendPipeline = 0;
|
||||
for (int portrait = 0; portrait <= 1 && bothOrientations; ++portrait) {
|
||||
uint8_t bytes[8192]; int size = call_video_probe_key(codec, profile, portrait, bytes, sizeof(bytes));
|
||||
if (size < 0) { bothOrientations = false; break; }
|
||||
CallVideoDecoder decoder(backend);
|
||||
call_video_frame input{}; input.call_id = 1; input.flags = CALL_VIDEO_KEY;
|
||||
input.data = bytes; input.size = input.length = size;
|
||||
input.format = {1, (uint16_t)(portrait ? 720 : 1280), (uint16_t)(portrait ? 1280 : 720), 30, 0,
|
||||
(uint8_t)codec, (uint8_t)(codec == 1 ? 31 : 93), 4000000, (uint8_t)profile};
|
||||
unsigned sent = 0, received = 0; bool valid = true, outputBeforeEos = false;
|
||||
const int64_t start = call_video_playout_now_us();
|
||||
while (valid && received < 8 && call_video_playout_now_us() - start < 1500000) {
|
||||
if (sent < 8 && call_video_playout_now_us() - start >= sent * 33333ll) {
|
||||
input.frame_id = sent + 1; input.pts_us = 1000000 + sent * 33333ll;
|
||||
int result = decoder.submit(input); if (result < 0) valid = false; else if (result) ++sent;
|
||||
}
|
||||
call_video_frame output{}; QImage image;
|
||||
int result = decoder.receive(output, image);
|
||||
if (result < 0) valid = false;
|
||||
else if (result) {
|
||||
valid = output.pts_us == 1000000 + received * 33333ll;
|
||||
if (!decoder.m->eos) outputBeforeEos = true;
|
||||
++received;
|
||||
}
|
||||
if (sent == 8 && decoder.finish() < 0) valid = false;
|
||||
if (valid && received < 8) QThread::usleep(1000);
|
||||
}
|
||||
call_video_frame output{}; QImage image;
|
||||
int result = decoder.receive(output, image);
|
||||
if (result < 0) valid = false;
|
||||
else if (result) {
|
||||
valid = output.pts_us == 1000000 + received * 33333ll;
|
||||
if (!decoder.m->eos) outputBeforeEos = true;
|
||||
++received;
|
||||
}
|
||||
if (sent == 8 && decoder.finish() < 0) valid = false;
|
||||
if (valid && received < 8) QThread::usleep(1000);
|
||||
valid = valid && received == 8 && outputBeforeEos;
|
||||
DEBUG_INFO(DEBUG_CATEGORY_CALL, "video decoder probe codec=%u profile=%u portrait=%d backend=%d valid=%d inputs=%u outputs=%u pipeline=%u",
|
||||
codec, profile, portrait, int(backend), valid, sent, received, decoder.pipelineFrames());
|
||||
bothOrientations = valid; backendPipeline = std::max(backendPipeline, decoder.pipelineFrames());
|
||||
}
|
||||
valid = valid && received == 8 && outputBeforeEos;
|
||||
DEBUG_INFO(DEBUG_CATEGORY_CALL, "video decoder probe codec=%u profile=%u backend=%d valid=%d inputs=%u outputs=%u pipeline=%u",
|
||||
codec, profile, int(backend), valid, sent, received, decoder.pipelineFrames());
|
||||
if (valid) {
|
||||
|
||||
if (bothOrientations) {
|
||||
profiles |= profile;
|
||||
if (backend == Backend::HardwareOnly) { hardwareProfiles |= profile; pipeline = std::max(pipeline, decoder.pipelineFrames()); }
|
||||
if (backend == Backend::HardwareOnly) { hardwareProfiles |= profile; pipeline = std::max(pipeline, backendPipeline); }
|
||||
break;
|
||||
}
|
||||
}
|
||||
@@ -265,8 +272,10 @@ call_video_caps CallVideoDecoder::capabilities() {
|
||||
#ifdef HAVE_FFMPEG
|
||||
gpuPipeline[codec - 1].store(pipeline); gpuProfiles[codec - 1].store(hardwareProfiles);
|
||||
#endif
|
||||
if (profiles) caps.decode[codec - 1] = {1280, 720, 30, 1280 * 720 * 30, 4000000,
|
||||
(uint8_t)profiles, (uint8_t)(codec == 1 ? 31 : 93)};
|
||||
if (profiles) {
|
||||
call_video_limit limit{1280, 720, 30, 1280 * 720 * 30, 4000000, (uint8_t)profiles, (uint8_t)(codec == 1 ? 31 : 93)};
|
||||
if (!call_video_limit_orientations(&limit, codec)) caps.decode[codec - 1] = limit;
|
||||
}
|
||||
}
|
||||
});
|
||||
return caps;
|
||||
|
||||
Reference in new issue
Block a user