mirror of
https://gitee.com/xia-chu/ZLMediaKit.git
synced 2026-05-06 10:57:50 +08:00
优化getMediaList接口,新增返回currentStamp字段,获取单个流时确保返回loss字段 (#4260)
Some checks are pending
Android / build (push) Waiting to run
CodeQL / Analyze (cpp) (push) Waiting to run
CodeQL / Analyze (javascript) (push) Waiting to run
Docker / build (push) Waiting to run
Linux / build (push) Waiting to run
macOS / build (push) Waiting to run
Windows / build (push) Waiting to run
Some checks are pending
Android / build (push) Waiting to run
CodeQL / Analyze (cpp) (push) Waiting to run
CodeQL / Analyze (javascript) (push) Waiting to run
Docker / build (push) Waiting to run
Linux / build (push) Waiting to run
macOS / build (push) Waiting to run
Windows / build (push) Waiting to run
This commit is contained in:
parent
f7c2803691
commit
5c58f39046
@ -391,6 +391,7 @@ Value makeMediaSourceJson(MediaSource &media){
|
|||||||
item["schema"] = media.getSchema();
|
item["schema"] = media.getSchema();
|
||||||
dumpMediaTuple(media.getMediaTuple(), item);
|
dumpMediaTuple(media.getMediaTuple(), item);
|
||||||
item["createStamp"] = (Json::UInt64) media.getCreateStamp();
|
item["createStamp"] = (Json::UInt64) media.getCreateStamp();
|
||||||
|
item["currentStamp"] = (Json::UInt64) media.getTimeStamp(TrackInvalid);
|
||||||
item["aliveSecond"] = (Json::UInt64) media.getAliveSecond();
|
item["aliveSecond"] = (Json::UInt64) media.getAliveSecond();
|
||||||
item["bytesSpeed"] = (Json::UInt64) media.getBytesSpeed();
|
item["bytesSpeed"] = (Json::UInt64) media.getBytesSpeed();
|
||||||
item["totalBytes"] = (Json::UInt64) media.getTotalBytes();
|
item["totalBytes"] = (Json::UInt64) media.getTotalBytes();
|
||||||
@ -908,12 +909,24 @@ void installWebApi() {
|
|||||||
// Test url1 (get streams with virtual host "__defaultVost__") http://127.0.0.1/index/api/getMediaList?vhost=__defaultVost__
|
// Test url1 (get streams with virtual host "__defaultVost__") http://127.0.0.1/index/api/getMediaList?vhost=__defaultVost__
|
||||||
// 测试url2(获取rtsp类型的流) http://127.0.0.1/index/api/getMediaList?schema=rtsp [AUTO-TRANSLATED:21c2c15d]
|
// 测试url2(获取rtsp类型的流) http://127.0.0.1/index/api/getMediaList?schema=rtsp [AUTO-TRANSLATED:21c2c15d]
|
||||||
// Test url2 (get rtsp type streams) http://127.0.0.1/index/api/getMediaList?schema=rtsp
|
// Test url2 (get rtsp type streams) http://127.0.0.1/index/api/getMediaList?schema=rtsp
|
||||||
api_regist("/index/api/getMediaList",[](API_ARGS_MAP){
|
api_regist("/index/api/getMediaList",[](API_ARGS_MAP_ASYNC){
|
||||||
CHECK_SECRET();
|
CHECK_SECRET();
|
||||||
// 获取所有MediaSource列表 [AUTO-TRANSLATED:7bf16dc2]
|
// 获取所有MediaSource列表 [AUTO-TRANSLATED:7bf16dc2]
|
||||||
// Get all MediaSource lists
|
// Get all MediaSource lists
|
||||||
|
bool first = true;
|
||||||
|
std::shared_ptr<Json::Value> done(new Json::Value(val), [invoker, headerOut](Json::Value *val) {
|
||||||
|
invoker(200, headerOut, val->toStyledString());
|
||||||
|
delete val;
|
||||||
|
});
|
||||||
MediaSource::for_each_media([&](const MediaSource::Ptr &media) {
|
MediaSource::for_each_media([&](const MediaSource::Ptr &media) {
|
||||||
val["data"].append(makeMediaSourceJson(*media));
|
if (first) {
|
||||||
|
first = false;
|
||||||
|
media->getOwnerPoller()->async([media, done]() mutable {
|
||||||
|
(*done)["data"].append(makeMediaSourceJson(*media));
|
||||||
|
});
|
||||||
|
} else {
|
||||||
|
(*done)["data"].append(makeMediaSourceJson(*media));
|
||||||
|
}
|
||||||
}, allArgs["schema"], allArgs["vhost"], allArgs["app"], allArgs["stream"]);
|
}, allArgs["schema"], allArgs["vhost"], allArgs["app"], allArgs["stream"]);
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user