mirror of
https://gitee.com/xia-chu/ZLMediaKit.git
synced 2026-05-17 15:27:49 +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.
|
* Copyright (c) 2016-present The ZLMediaKit project authors. All Rights Reserved.
|
||||||
*
|
*
|
||||||
* This file is part of ZLMediaKit(https://github.com/ZLMediaKit/ZLMediaKit).
|
* This file is part of ZLMediaKit(https://github.com/ZLMediaKit/ZLMediaKit).
|
||||||
@ -378,7 +378,10 @@ bool HttpSession::checkLiveStreamFMP4(const function<void()> &cb) {
|
|||||||
if (!cb) {
|
if (!cb) {
|
||||||
// 找到源,发送http头,负载后续发送 [AUTO-TRANSLATED:ac272410]
|
// 找到源,发送http头,负载后续发送 [AUTO-TRANSLATED:ac272410]
|
||||||
// Found the source, send the http header, and send the load later
|
// 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 {
|
} else {
|
||||||
// 自定义发送http头 [AUTO-TRANSLATED:b8a8f683]
|
// 自定义发送http头 [AUTO-TRANSLATED:b8a8f683]
|
||||||
// Custom send http header
|
// Custom send http header
|
||||||
@ -849,8 +852,26 @@ void HttpSession::onWrite(const Buffer::Ptr &buffer, bool flush) {
|
|||||||
|
|
||||||
_ticker.resetTime();
|
_ticker.resetTime();
|
||||||
if (!_live_over_websocket) {
|
if (!_live_over_websocket) {
|
||||||
_total_bytes_usage += buffer->size();
|
if (_is_chunked) {
|
||||||
send(buffer);
|
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 {
|
} else {
|
||||||
WebSocketHeader header;
|
WebSocketHeader header;
|
||||||
header._fin = true;
|
header._fin = true;
|
||||||
|
|||||||
@ -1,4 +1,4 @@
|
|||||||
/*
|
/*
|
||||||
* Copyright (c) 2016-present The ZLMediaKit project authors. All Rights Reserved.
|
* Copyright (c) 2016-present The ZLMediaKit project authors. All Rights Reserved.
|
||||||
*
|
*
|
||||||
* This file is part of ZLMediaKit(https://github.com/ZLMediaKit/ZLMediaKit).
|
* This file is part of ZLMediaKit(https://github.com/ZLMediaKit/ZLMediaKit).
|
||||||
@ -159,6 +159,7 @@ private:
|
|||||||
bool _is_live_stream = false;
|
bool _is_live_stream = false;
|
||||||
bool _live_over_websocket = false;
|
bool _live_over_websocket = false;
|
||||||
bool _is_websocket = false;
|
bool _is_websocket = false;
|
||||||
|
bool _is_chunked = false;
|
||||||
// 超时时间 [AUTO-TRANSLATED:f15e2672]
|
// 超时时间 [AUTO-TRANSLATED:f15e2672]
|
||||||
// Timeout
|
// Timeout
|
||||||
size_t _keep_alive_sec = 0;
|
size_t _keep_alive_sec = 0;
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user