Skip to content

Commit a307db7

Browse files
committed
fix: Drop video frames when TCP send lags instead of buffering unbounded
1 parent f23c81f commit a307db7

2 files changed

Lines changed: 2 additions & 12 deletions

File tree

include/web_video_server/multipart_stream.hpp

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,6 @@ namespace web_video_server
4646

4747
struct PendingFooter
4848
{
49-
std::chrono::steady_clock::time_point timestamp;
5049
std::weak_ptr<std::string> contents;
5150
};
5251

src/multipart_stream.cpp

Lines changed: 2 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -86,11 +86,10 @@ void MultipartStream::send_part_header(
8686
connection_->write(async_web_server_cpp::HttpReply::to_buffers(*headers), headers);
8787
}
8888

89-
void MultipartStream::send_part_footer(const std::chrono::steady_clock::time_point & time)
89+
void MultipartStream::send_part_footer(const std::chrono::steady_clock::time_point & /* time */)
9090
{
9191
const std::shared_ptr<std::string> str(new std::string("\r\n--" + boundary_ + "\r\n"));
9292
PendingFooter pf;
93-
pf.timestamp = time;
9493
pf.contents = str;
9594
connection_->write(boost::asio::buffer(*str), str);
9695
if (max_queue_size_ > 0) {pending_footers_.push(pf);}
@@ -121,19 +120,11 @@ void MultipartStream::send_part(
121120

122121
bool MultipartStream::is_busy()
123122
{
124-
auto current_time = std::chrono::steady_clock::now();
125123
while (!pending_footers_.empty()) {
126124
if (pending_footers_.front().contents.expired()) {
127125
pending_footers_.pop();
128126
} else {
129-
auto footer_time = pending_footers_.front().timestamp;
130-
if (std::chrono::duration_cast<std::chrono::duration<double>>(
131-
(current_time - footer_time)).count() > 0.5)
132-
{
133-
pending_footers_.pop();
134-
} else {
135-
break;
136-
}
127+
break;
137128
}
138129
}
139130
return max_queue_size_ != 0 && pending_footers_.size() >= max_queue_size_;

0 commit comments

Comments
 (0)