1
This commit is contained in:
parent
5f4518cebf
commit
b1d61be69d
@ -120,10 +120,27 @@ void RTMPManager::stream_loop(Camera cam, StreamContext *ctx)
|
|||||||
|
|
||||||
GstBus *bus = gst_element_get_bus(pipeline);
|
GstBus *bus = gst_element_get_bus(pipeline);
|
||||||
gst_element_set_state(pipeline, GST_STATE_PLAYING);
|
gst_element_set_state(pipeline, GST_STATE_PLAYING);
|
||||||
|
|
||||||
|
// -------- 等待状态切换结果 --------
|
||||||
|
GstStateChangeReturn ret = gst_element_get_state(pipeline, nullptr, nullptr, 3 * GST_SECOND);
|
||||||
|
|
||||||
|
if (ret != GST_STATE_CHANGE_SUCCESS)
|
||||||
|
{
|
||||||
|
ctx->status.running = false;
|
||||||
|
ctx->status.last_error = "Pipeline failed to reach PLAYING";
|
||||||
|
LOG_ERROR("[RTMP] " + key + " failed to start (no video signal?)");
|
||||||
|
gst_element_set_state(pipeline, GST_STATE_NULL);
|
||||||
|
gst_object_unref(bus);
|
||||||
|
gst_object_unref(pipeline);
|
||||||
|
std::this_thread::sleep_for(std::chrono::seconds(3));
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
ctx->status.running = true;
|
ctx->status.running = true;
|
||||||
ctx->status.last_error.clear();
|
ctx->status.last_error.clear();
|
||||||
LOG_INFO("[RTMP] Started stream for " + key);
|
LOG_INFO("[RTMP] Started stream for " + key);
|
||||||
|
|
||||||
|
// -------- 主循环 --------
|
||||||
bool need_restart = false;
|
bool need_restart = false;
|
||||||
while (ctx->running)
|
while (ctx->running)
|
||||||
{
|
{
|
||||||
@ -153,8 +170,8 @@ void RTMPManager::stream_loop(Camera cam, StreamContext *ctx)
|
|||||||
default:
|
default:
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
gst_message_unref(msg);
|
|
||||||
|
|
||||||
|
gst_message_unref(msg);
|
||||||
if (need_restart) break;
|
if (need_restart) break;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user