feat: VideoStack (#3373)

This commit is contained in:
KkemChen
2024-03-16 22:56:32 +08:00
committed by GitHub
parent ff43fa5075
commit 437ae778c0
6 changed files with 906 additions and 3 deletions

View File

@@ -62,6 +62,10 @@
#include "version.h"
#endif
#if defined(ENABLE_X264) && defined (ENABLE_FFMPEG)
#include "VideoStack.h"
#endif
using namespace std;
using namespace Json;
using namespace toolkit;
@@ -1925,6 +1929,36 @@ void installWebApi() {
invoker(401, StrCaseMap {}, "None http access event listener");
}
});
#if defined(ENABLE_X264) && defined(ENABLE_FFMPEG)
VideoStackManager::Instance().loadBgImg("novideo.yuv");
NoticeCenter::Instance().addListener(nullptr, Broadcast::kBroadcastStreamNoneReader, [](BroadcastStreamNoneReaderArgs) {
auto id = sender.getMediaTuple().stream;
VideoStackManager::Instance().stopVideoStack(id);
InfoL << "VideoStack: " << id <<" stop";
});
api_regist("/index/api/stack/start", [](API_ARGS_JSON_ASYNC) {
CHECK_SECRET();
auto ret = VideoStackManager::Instance().startVideoStack(allArgs.getArgs());
if (!ret) {
invoker(200, headerOut, "success");
} else {
invoker(200, headerOut, "failed");
}
});
api_regist("/index/api/stack/stop", [](API_ARGS_MAP_ASYNC) {
CHECK_SECRET();
CHECK_ARGS("id");
auto ret = VideoStackManager::Instance().stopVideoStack(allArgs["id"]);
if (!ret) {
invoker(200, headerOut, "success");
} else {
invoker(200, headerOut, "failed");
}
});
#endif
}
void unInstallWebApi(){