mirror of
https://github.com/ZLMediaKit/ZLMediaKit.git
synced 2024-11-23 11:17:09 +08:00
调整代码细节
This commit is contained in:
parent
06023f1770
commit
936c6f7965
@ -647,45 +647,41 @@ void installWebApi() {
|
|||||||
//测试url http://127.0.0.1/index/api/addStreamPusherProxy?schema=rtmp&vhost=__defaultVhost__&app=proxy&stream=0&dst_url=rtmp://127.0.0.1/live/obs
|
//测试url http://127.0.0.1/index/api/addStreamPusherProxy?schema=rtmp&vhost=__defaultVhost__&app=proxy&stream=0&dst_url=rtmp://127.0.0.1/live/obs
|
||||||
api_regist("/index/api/addStreamPusherProxy", [](API_ARGS_MAP_ASYNC) {
|
api_regist("/index/api/addStreamPusherProxy", [](API_ARGS_MAP_ASYNC) {
|
||||||
CHECK_SECRET();
|
CHECK_SECRET();
|
||||||
CHECK_ARGS("schema","vhost","app","stream");
|
CHECK_ARGS("schema", "vhost", "app", "stream", "dst_url");
|
||||||
|
|
||||||
InfoL << allArgs["schema"] << ", " << allArgs["vhost"] << ", " << allArgs["app"] << ", " << allArgs["stream"];
|
auto dst_url = allArgs["dst_url"];
|
||||||
|
auto src_url = allArgs["schema"] + "/" + allArgs["vhost"] + "/" + allArgs["app"] + "/" + allArgs["stream"];
|
||||||
//查找源
|
|
||||||
auto src = MediaSource::find(allArgs["schema"],
|
auto src = MediaSource::find(allArgs["schema"],
|
||||||
allArgs["vhost"],
|
allArgs["vhost"],
|
||||||
allArgs["app"],
|
allArgs["app"],
|
||||||
allArgs["stream"]);
|
allArgs["stream"]);
|
||||||
if (!src) {
|
if (!src) {
|
||||||
InfoL << "addStreamPusherProxy, canont find source stream!";
|
WarnL << "addStreamPusherProxy, can not find source stream:" << src_url;
|
||||||
const_cast<Value &>(val)["code"] = API::OtherFailed;
|
val["code"] = API::NotFound;
|
||||||
const_cast<Value &>(val)["msg"] = "can not find the source stream";
|
val["msg"] = "can not find the source stream";
|
||||||
invoker(200, headerOut, val.toStyledString());
|
invoker(200, headerOut, val.toStyledString());
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
std::string srcUrl = allArgs["schema"] + "://" + "127.0.0.1" + "/" + allArgs["app"] + "/" + allArgs["stream"];
|
InfoL << "addStreamPusherProxy, find stream: " << src_url << ", push dst url: " << dst_url;
|
||||||
std::string pushUrl = decodeBase64(allArgs["dst_url"]);
|
|
||||||
InfoL << "addStreamPusherProxy, find stream: " << srcUrl << ", push dst url: " << pushUrl;
|
|
||||||
|
|
||||||
addStreamPusherProxy(allArgs["schema"],
|
addStreamPusherProxy(allArgs["schema"],
|
||||||
allArgs["vhost"],
|
allArgs["vhost"],
|
||||||
allArgs["app"],
|
allArgs["app"],
|
||||||
allArgs["stream"],
|
allArgs["stream"],
|
||||||
pushUrl,
|
allArgs["dst_url"],
|
||||||
allArgs["retry_count"],
|
allArgs["retry_count"],
|
||||||
[invoker,val,headerOut, pushUrl](const SockException &ex, const string &key){
|
[invoker, val, headerOut, dst_url](const SockException &ex, const string &key) mutable {
|
||||||
if (ex) {
|
if (ex) {
|
||||||
const_cast<Value &>(val)["code"] = API::OtherFailed;
|
val["code"] = API::OtherFailed;
|
||||||
const_cast<Value &>(val)["msg"] = ex.what();
|
val["msg"] = ex.what();
|
||||||
InfoL << "Publish error url: " << pushUrl;
|
WarnL << "Publish stream failed, dst url is: " << dst_url;
|
||||||
} else {
|
} else {
|
||||||
const_cast<Value &>(val)["data"]["key"] = key;
|
val["data"]["key"] = key;
|
||||||
InfoL << "Publish success, Please play with player:" << pushUrl;
|
InfoL << "Publish success, please play with player:" << dst_url;
|
||||||
}
|
}
|
||||||
invoker(200, headerOut, val.toStyledString());
|
invoker(200, headerOut, val.toStyledString());
|
||||||
});
|
});
|
||||||
|
|
||||||
});
|
});
|
||||||
|
|
||||||
//关闭推流代理
|
//关闭推流代理
|
||||||
|
Loading…
Reference in New Issue
Block a user