Merge branch 'master' into patch-72

This commit is contained in:
夏楚 2023-12-01 14:35:53 +08:00 committed by GitHub
commit c379bbab82
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
4 changed files with 20 additions and 10 deletions

View File

@ -540,7 +540,7 @@ void getStatisticJson(const function<void(Value &val)> &cb) {
}
void addStreamProxy(const string &vhost, const string &app, const string &stream, const string &url, int retry_count,
const ProtocolOption &option, int rtp_type, float timeout_sec,
const ProtocolOption &option, int rtp_type, float timeout_sec, const mINI &args,
const function<void(const SockException &ex, const string &key)> &cb) {
auto key = getProxyKey(vhost, app, stream);
lock_guard<recursive_mutex> lck(s_proxyMapMtx);
@ -575,6 +575,7 @@ void addStreamProxy(const string &vhost, const string &app, const string &stream
lock_guard<recursive_mutex> lck(s_proxyMapMtx);
s_proxyMap.erase(key);
});
player->mINI::operator=(args);
player->play(url);
};
@ -1058,6 +1059,11 @@ void installWebApi() {
CHECK_SECRET();
CHECK_ARGS("vhost","app","stream","url");
mINI args;
for (auto &pr : allArgs.getArgs()) {
args.emplace(pr.first, pr.second);
}
ProtocolOption option(allArgs);
auto retry_count = allArgs["retry_count"].empty()? -1: allArgs["retry_count"].as<int>();
addStreamProxy(allArgs["vhost"],
@ -1068,6 +1074,7 @@ void installWebApi() {
option,
allArgs["rtp_type"],
allArgs["timeout_sec"],
args,
[invoker,val,headerOut](const SockException &ex,const string &key) mutable{
if (ex) {
val["code"] = API::OtherFailed;
@ -1891,6 +1898,7 @@ void installWebApi() {
option,
0,//rtp over tcp方式拉流
10,//10秒超时
mINI{},
[invoker,val,headerOut](const SockException &ex,const string &key) mutable{
if(ex){
val["code"] = API::OtherFailed;

View File

@ -247,6 +247,6 @@ bool closeRtpServer(const std::string &stream_id);
Json::Value makeMediaSourceJson(mediakit::MediaSource &media);
void getStatisticJson(const std::function<void(Json::Value &val)> &cb);
void addStreamProxy(const std::string &vhost, const std::string &app, const std::string &stream, const std::string &url, int retry_count,
const mediakit::ProtocolOption &option, int rtp_type, float timeout_sec,
const mediakit::ProtocolOption &option, int rtp_type, float timeout_sec, const toolkit::mINI &args,
const std::function<void(const toolkit::SockException &ex, const std::string &key)> &cb);
#endif //ZLMEDIAKIT_WEBAPI_H

View File

@ -301,7 +301,7 @@ static void pullStreamFromOrigin(const vector<string> &urls, size_t index, size_
option.enable_hls = option.enable_hls || (args.schema == HLS_SCHEMA);
option.enable_mp4 = false;
addStreamProxy(args.vhost, args.app, args.stream, url, retry_count, option, Rtsp::RTP_TCP, timeout_sec, [=](const SockException &ex, const string &key) mutable {
addStreamProxy(args.vhost, args.app, args.stream, url, retry_count, option, Rtsp::RTP_TCP, timeout_sec, mINI{}, [=](const SockException &ex, const string &key) mutable {
if (!ex) {
return;
}

View File

@ -82,15 +82,17 @@ void HttpClient::sendRequest(const string &url) {
printer.pop_back();
_header.emplace("Cookie", printer);
}
if (isUsedProxy()) {
startConnect(_proxy_host, _proxy_port, _wait_header_ms / 1000.0f);
} else {
if (!alive() || host_changed || !_http_persistent) {
startConnect(host, port, _wait_header_ms / 1000.0f);
if (!alive() || host_changed) {
if (isUsedProxy()) {
_proxy_connected = false;
startConnect(_proxy_host, _proxy_port, _wait_header_ms / 1000.0f);
} else {
SockException ex;
onConnect_l(ex);
startConnect(host, port, _wait_header_ms / 1000.0f);
}
} else {
SockException ex;
onConnect_l(ex);
}
}