1
This commit is contained in:
parent
465d87ce0a
commit
5c007716a0
@ -258,29 +258,8 @@ bool RTSPManager::is_streaming(const std::string &cam_name)
|
|||||||
// 停止 server
|
// 停止 server
|
||||||
void RTSPManager::stop()
|
void RTSPManager::stop()
|
||||||
{
|
{
|
||||||
// 先卸载所有挂载摄像头
|
// Ctrl-C 退出时,不再尝试逐路卸载摄像头,
|
||||||
std::vector<std::string> cams_to_unmount;
|
// 只负责让 g_main_loop_run() 退出,线程自然收尾。
|
||||||
{
|
|
||||||
std::lock_guard<std::mutex> lock(mounted_factories_mutex);
|
|
||||||
for (const auto &kv : mounted_factories)
|
|
||||||
cams_to_unmount.push_back(kv.first);
|
|
||||||
}
|
|
||||||
|
|
||||||
for (const auto &cam_name : cams_to_unmount)
|
|
||||||
{
|
|
||||||
Camera cam;
|
|
||||||
cam.name = cam_name;
|
|
||||||
unmount_camera(cam);
|
|
||||||
}
|
|
||||||
|
|
||||||
// 等待所有流停止(最多 5 秒)
|
|
||||||
auto deadline = std::chrono::steady_clock::now() + std::chrono::seconds(5);
|
|
||||||
while (is_any_streaming() && std::chrono::steady_clock::now() < deadline)
|
|
||||||
{
|
|
||||||
std::this_thread::sleep_for(std::chrono::milliseconds(50));
|
|
||||||
}
|
|
||||||
|
|
||||||
// 退出 main loop
|
|
||||||
if (loop)
|
if (loop)
|
||||||
{
|
{
|
||||||
g_main_context_invoke(
|
g_main_context_invoke(
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user