Skip to content

Commit 251f66c

Browse files
Merge branch 'master' of github.com:ZoneMinder/zoneminder
2 parents fcf9d41 + 5237641 commit 251f66c

File tree

2 files changed

+16
-7
lines changed

2 files changed

+16
-7
lines changed

src/zm_eventstream.cpp

Lines changed: 11 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -940,12 +940,13 @@ void EventStream::runStream() {
940940
Microseconds delta = Microseconds(0);
941941

942942
while (!zm_terminate) {
943-
start = std::chrono::steady_clock::now();
943+
now = start = std::chrono::steady_clock::now();
944944

945945
{
946946
std::scoped_lock lck{mutex};
947947

948948
send_frame = false;
949+
TimePoint::duration time_since_last_send = now - last_frame_sent;
949950

950951
if (!paused) {
951952
// Figure out if we should send this frame
@@ -964,16 +965,22 @@ void EventStream::runStream() {
964965
send_frame = true;
965966
} else if (!send_frame) {
966967
// We are paused, not stepping and doing nothing, meaning that comms didn't set send_frame to true
967-
if (now - last_frame_sent > MAX_STREAM_DELAY) {
968+
if (time_since_last_send > MAX_STREAM_DELAY) {
968969
// Send keepalive
969970
Debug(2, "Sending keepalive frame");
970971
send_frame = true;
972+
} else {
973+
Debug(4, "Not Sending keepalive frame now %.2f - %.2f last = %.2f > Max %.2f",
974+
FPSeconds(now.time_since_epoch()).count(),
975+
FPSeconds(last_frame_sent.time_since_epoch()).count(),
976+
FPSeconds(time_since_last_send).count(),
977+
FPSeconds(MAX_STREAM_DELAY).count()
978+
);
971979
}
972980
} // end if streaming stepping or doing nothing
973981

974982
// time_to_event > 0 means that we are not in the event
975983
if (time_to_event > Seconds(0) and mode == MODE_ALL) {
976-
TimePoint::duration time_since_last_send = now - last_frame_sent;
977984
Debug(1, "Time since last send = %.2f s", FPSeconds(time_since_last_send).count());
978985
if (time_since_last_send > Seconds(1)) {
979986
char frame_text[64];
@@ -1069,8 +1076,7 @@ void EventStream::runStream() {
10691076
base_fps,
10701077
effective_fps);
10711078
}
1072-
now = std::chrono::steady_clock::now();
1073-
TimePoint::duration elapsed = now - start;
1079+
TimePoint::duration elapsed = std::chrono::steady_clock::now() - start;
10741080
delta -= std::chrono::duration_cast<Microseconds>(elapsed); // sending frames takes time, so remove it from the sleep time
10751081

10761082
Debug(2, "New delta: %fs from last frame offset %fs - next_frame_offset %fs - elapsed %fs",

web/skins/classic/views/video.php

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -78,8 +78,6 @@
7878
unlink($videoFiles[$deleteIndex]);
7979
unset($videoFiles[$deleteIndex]);
8080
} else if (isset($_REQUEST['downloadIndex'])) {
81-
// can't be output buffering, as this file might be large
82-
ob_end_clean();
8381
$downloadIndex = validInt($_REQUEST['downloadIndex']);
8482
ZM\Debug("Download $downloadIndex, file: " . $videoFiles[$downloadIndex]);
8583
header('Pragma: public');
@@ -91,6 +89,11 @@
9189
header('Content-Transfer-Encoding: binary');
9290
header('Content-Type: application/force-download');
9391
header('Content-Length: '.filesize($videoFiles[$downloadIndex]));
92+
// can't be output buffering, as this file might be large
93+
while (ob_get_level()) {
94+
ob_end_clean();
95+
}
96+
set_time_limit(0);
9497
readfile($videoFiles[$downloadIndex]);
9598
exit;
9699
}

0 commit comments

Comments
 (0)