mirror of
https://gitee.com/xia-chu/ZLMediaKit.git
synced 2026-05-06 10:57:50 +08:00
Pre Merge pull request !33 from sky/N/A
This commit is contained in:
commit
b3fc7975d7
@ -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;
|
||||
|
||||
@ -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;
|
||||
|
||||
Loading…
Reference in New Issue
Block a user