新增Ts拉流

This commit is contained in:
Alex
2022-01-04 15:32:59 +08:00
parent a441168004
commit 4792f6213b
8 changed files with 467 additions and 9 deletions

View File

@@ -15,7 +15,8 @@
namespace mediakit {
void HttpClient::sendRequest(const string &url, float timeout_sec) {
void HttpClient::sendRequest(const string &url, float timeout_sec, float recv_timeout_sec) {
_recv_timeout_second = recv_timeout_sec;
clearResponse();
_url = url;
auto protocol = FindField(url.data(), NULL, "://");
@@ -188,7 +189,7 @@ ssize_t HttpClient::onRecvHeader(const char *data, size_t len) {
}
if (onRedirectUrl(new_url, _parser.Url() == "302")) {
setMethod("GET");
HttpClient::sendRequest(new_url, _timeout_second);
HttpClient::sendRequest(new_url, _timeout_second, _recv_timeout_second);
return 0;
}
}
@@ -278,7 +279,7 @@ void HttpClient::onFlush() {
}
void HttpClient::onManager() {
if (_recv_timeout_ticker.elapsedTime() > 3 * 1000 && _total_body_size < 0 && !_chunked_splitter) {
if (_recv_timeout_ticker.elapsedTime() > _recv_timeout_second * 1000 && _total_body_size < 0 && !_chunked_splitter) {
//如果Content-Length未指定 但接收数据超时
//则认为本次http请求完成
onResponseCompleted_l();