mirror of
https://github.com/ZLMediaKit/ZLMediaKit.git
synced 2026-03-01 19:50:53 +08:00
优化getMediaList接口,新增返回currentStamp字段,获取单个流时确保返回loss字段 (#4260)
This commit is contained in:
@@ -391,6 +391,7 @@ Value makeMediaSourceJson(MediaSource &media){
|
||||
item["schema"] = media.getSchema();
|
||||
dumpMediaTuple(media.getMediaTuple(), item);
|
||||
item["createStamp"] = (Json::UInt64) media.getCreateStamp();
|
||||
item["currentStamp"] = (Json::UInt64) media.getTimeStamp(TrackInvalid);
|
||||
item["aliveSecond"] = (Json::UInt64) media.getAliveSecond();
|
||||
item["bytesSpeed"] = (Json::UInt64) media.getBytesSpeed();
|
||||
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__
|
||||
// 测试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
|
||||
api_regist("/index/api/getMediaList",[](API_ARGS_MAP){
|
||||
api_regist("/index/api/getMediaList",[](API_ARGS_MAP_ASYNC){
|
||||
CHECK_SECRET();
|
||||
// 获取所有MediaSource列表 [AUTO-TRANSLATED:7bf16dc2]
|
||||
// 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) {
|
||||
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"]);
|
||||
});
|
||||
|
||||
|
||||
Reference in New Issue
Block a user