Fix API requests content type

This commit is contained in:
Yukino Song
2025-07-15 22:22:47 +08:00
parent 4f6334abdb
commit 2a97b3cbff
4 changed files with 21 additions and 8 deletions

View File

@@ -1924,8 +1924,10 @@ namespace video {
// set minimum frame time based on client-requested target framerate // set minimum frame time based on client-requested target framerate
auto minimum_frame_time = std::chrono::milliseconds(1000 / config.framerate); auto minimum_frame_time = std::chrono::milliseconds(1000 / config.framerate);
auto frame_threshold = std::chrono::microseconds(1000ms * 1000 / config.encodingFramerate); auto capture_frame_threshold = std::chrono::microseconds(1000 * 1000 / config.framerate);
BOOST_LOG(info) << "Frame threshold: "sv << frame_threshold; auto encode_frame_threshold = std::chrono::microseconds(1000 * 1000 / config.encodingFramerate);
BOOST_LOG(info) << "Capture Frame threshold: "sv << capture_frame_threshold;
BOOST_LOG(info) << "Encoding Frame threshold: "sv << encode_frame_threshold;
auto shutdown_event = mail->event<bool>(mail::shutdown); auto shutdown_event = mail->event<bool>(mail::shutdown);
auto packets = mail::man->queue<packet_t>(mail::video_packets); auto packets = mail::man->queue<packet_t>(mail::video_packets);
@@ -1999,7 +2001,7 @@ namespace video {
if (auto img = images->pop(minimum_frame_time)) { if (auto img = images->pop(minimum_frame_time)) {
frame_timestamp = img->frame_timestamp; frame_timestamp = img->frame_timestamp;
// If new frame comes in way too fast, just drop // If new frame comes in way too fast, just drop
if (*frame_timestamp < next_frame_start) { if (*frame_timestamp < (next_frame_start - capture_frame_threshold / 2)) {
continue; continue;
} }
if (session->convert(*img)) { if (session->convert(*img)) {
@@ -2013,11 +2015,13 @@ namespace video {
if (frame_timestamp) { if (frame_timestamp) {
auto frame_diff = *frame_timestamp - next_frame_start; auto frame_diff = *frame_timestamp - next_frame_start;
if (frame_diff > frame_threshold / 2) { next_frame_start = *frame_timestamp + encode_frame_threshold;
next_frame_start = *frame_timestamp + frame_threshold / 2;
if (frame_diff > encode_frame_threshold / 2) {
next_frame_start = *frame_timestamp + encode_frame_threshold;
} else { } else {
frame_timestamp = next_frame_start; frame_timestamp = next_frame_start;
next_frame_start += frame_threshold; next_frame_start += encode_frame_threshold;
} }
} }
} }

View File

@@ -735,6 +735,9 @@
this.actionDisabled = true; this.actionDisabled = true;
fetch("./api/apps/close", { fetch("./api/apps/close", {
credentials: 'include', credentials: 'include',
headers: {
'Content-Type': 'application/json'
},
method: 'POST', method: 'POST',
}) })
.then((r) => r.json()) .then((r) => r.json())

View File

@@ -475,7 +475,10 @@
this.saved = this.restarted = false; this.saved = this.restarted = false;
}, 5000); }, 5000);
fetch("./api/restart", { fetch("./api/restart", {
method: 'POST' method: 'POST',
headers: {
'Content-Type': 'application/json'
}
}) })
.then((resp) => { .then((resp) => {
if (resp.status !== 200) { if (resp.status !== 200) {

View File

@@ -655,7 +655,10 @@
this.unpairAllPressed = true; this.unpairAllPressed = true;
fetch("./api/clients/unpair-all", { fetch("./api/clients/unpair-all", {
credentials: 'include', credentials: 'include',
method: 'POST' method: 'POST',
headers: {
'Content-Type': 'application/json'
},
}) })
.then((r) => r.json()) .then((r) => r.json())
.then((r) => { .then((r) => {