Pre Merge pull request !33 from sky/N/A

This commit is contained in:
sky 2025-11-03 04:57:11 +00:00 committed by Gitee
commit b3fc7975d7
No known key found for this signature in database
GPG Key ID: 173E9B9CA92EEF8F
2 changed files with 27 additions and 5 deletions

View File

@ -1,4 +1,4 @@
/*
/*
* Copyright (c) 2016-present The ZLMediaKit project authors. All Rights Reserved.
*
* This file is part of ZLMediaKit(https://github.com/ZLMediaKit/ZLMediaKit).
@ -378,7 +378,10 @@ bool HttpSession::checkLiveStreamFMP4(const function<void()> &cb) {
if (!cb) {
// 找到源发送http头负载后续发送 [AUTO-TRANSLATED:ac272410]
// Found the source, send the http header, and send the load later
sendResponse(200, false, HttpFileManager::getContentType(".mp4").data(), KeyValue(), nullptr, true);
_is_chunked = true;
KeyValue headerOut;
headerOut["Transfer-Encoding"] = "chunked";
sendResponse(200, false, HttpFileManager::getContentType(".mp4").data(), headerOut, nullptr, true);
} else {
// 自定义发送http头 [AUTO-TRANSLATED:b8a8f683]
// Custom send http header
@ -849,8 +852,26 @@ void HttpSession::onWrite(const Buffer::Ptr &buffer, bool flush) {
_ticker.resetTime();
if (!_live_over_websocket) {
_total_bytes_usage += buffer->size();
send(buffer);
if (_is_chunked) {
std::stringstream ss;
ss << hex << buffer->size();
string sizeStr = ss.str();
auto sizeBuffer = make_shared<BufferLikeString>();
sizeBuffer->assign(sizeStr.data(), sizeStr.size());
sizeBuffer->append("\r\n");
send(sizeBuffer);
send(buffer);
auto lfcf = make_shared<BufferLikeString>();
lfcf->assign("\r\n");
send(lfcf);
_total_bytes_usage += buffer->size() + sizeStr.size() + 4;
} else {
_total_bytes_usage += buffer->size();
send(buffer);
}
} else {
WebSocketHeader header;
header._fin = true;

View File

@ -1,4 +1,4 @@
/*
/*
* Copyright (c) 2016-present The ZLMediaKit project authors. All Rights Reserved.
*
* This file is part of ZLMediaKit(https://github.com/ZLMediaKit/ZLMediaKit).
@ -159,6 +159,7 @@ private:
bool _is_live_stream = false;
bool _live_over_websocket = false;
bool _is_websocket = false;
bool _is_chunked = false;
// 超时时间 [AUTO-TRANSLATED:f15e2672]
// Timeout
size_t _keep_alive_sec = 0;