1
This commit is contained in:
parent
e1cc6fe10f
commit
8a676136e3
@ -175,7 +175,16 @@ void RTMPManager::stream_loop(Camera cam, StreamType type, std::promise<StreamSt
|
||||
|
||||
while (true)
|
||||
{
|
||||
// 检查超时
|
||||
// 检查 stop_flag 或超时
|
||||
{
|
||||
std::lock_guard<std::mutex> lock(streams_mutex);
|
||||
auto it = streams.find(key);
|
||||
if (it == streams.end() || !it->second->running.load())
|
||||
{
|
||||
break; // 停止逻辑
|
||||
}
|
||||
}
|
||||
|
||||
if (!first_frame_received &&
|
||||
std::chrono::duration_cast<std::chrono::seconds>(std::chrono::steady_clock::now() - start_time).count() > 5)
|
||||
{
|
||||
@ -204,7 +213,7 @@ void RTMPManager::stream_loop(Camera cam, StreamType type, std::promise<StreamSt
|
||||
status.running = true;
|
||||
status.last_result = StreamResult::OK;
|
||||
status.last_error = "";
|
||||
if (status_promise) status_promise->set_value(status); // 立刻返回给 start_camera
|
||||
if (status_promise) status_promise->set_value(status);
|
||||
}
|
||||
break;
|
||||
}
|
||||
@ -219,10 +228,10 @@ void RTMPManager::stream_loop(Camera cam, StreamType type, std::promise<StreamSt
|
||||
}
|
||||
|
||||
gst_message_unref(msg);
|
||||
if (!running) break; // 停止逻辑
|
||||
}
|
||||
|
||||
gst_element_set_state(pipeline, GST_STATE_NULL);
|
||||
if (bus) gst_object_unref(bus);
|
||||
gst_object_unref(pipeline);
|
||||
}
|
||||
|
||||
|
||||
Loading…
Reference in New Issue
Block a user