1
This commit is contained in:
parent
42bad1d949
commit
11d21c467b
@ -82,11 +82,11 @@ GstRTSPMediaFactory *RTSPManager::create_media_factory(const Camera &cam)
|
|||||||
std::string launch_str =
|
std::string launch_str =
|
||||||
"( v4l2src device=" + cam.device +
|
"( v4l2src device=" + cam.device +
|
||||||
" io-mode=2 is-live=true do-timestamp=true"
|
" io-mode=2 is-live=true do-timestamp=true"
|
||||||
|
" ! identity sync=false"
|
||||||
" ! " +
|
" ! " +
|
||||||
caps +
|
caps +
|
||||||
" ! queue max-size-buffers=0 max-size-bytes=0 max-size-time=0"
|
" ! queue leaky=downstream max-size-buffers=0 max-size-bytes=0 max-size-time=0"
|
||||||
" ! mpph264enc rc-mode=cbr"
|
" ! mpph264enc rc-mode=cbr bps=" +
|
||||||
" bps=" +
|
|
||||||
std::to_string(cam.bitrate) +
|
std::to_string(cam.bitrate) +
|
||||||
" gop=" + std::to_string(cam.fps) +
|
" gop=" + std::to_string(cam.fps) +
|
||||||
" header-mode=1"
|
" header-mode=1"
|
||||||
@ -176,10 +176,25 @@ void RTSPManager::on_media_created(GstRTSPMediaFactory *, GstRTSPMedia *media, g
|
|||||||
media_map[cam_name].push_back(media);
|
media_map[cam_name].push_back(media);
|
||||||
}
|
}
|
||||||
|
|
||||||
g_signal_connect_data(media, "unprepared", G_CALLBACK(on_media_unprepared),
|
g_signal_connect_data(
|
||||||
g_strdup(cam_name),
|
media,
|
||||||
(GClosureNotify)g_free,
|
"unprepared",
|
||||||
(GConnectFlags)0);
|
G_CALLBACK(on_media_unprepared),
|
||||||
|
g_strdup(cam_name),
|
||||||
|
(GClosureNotify)g_free,
|
||||||
|
(GConnectFlags)0);
|
||||||
|
|
||||||
|
// ★★★ 关键补丁:阻止 preroll 卡死 v4l2 驱动,强制 PLAYING
|
||||||
|
GstElement *pipeline = gst_rtsp_media_get_element(media);
|
||||||
|
if (pipeline)
|
||||||
|
{
|
||||||
|
gst_element_set_state(pipeline, GST_STATE_PLAYING);
|
||||||
|
LOG_INFO(std::string("[RTSP] Force pipeline PLAYING for camera: ") + cam_name);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
LOG_WARN(std::string("[RTSP] Pipeline is NULL for camera: ") + cam_name);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void RTSPManager::on_media_unprepared(GstRTSPMedia *media, gpointer user_data)
|
void RTSPManager::on_media_unprepared(GstRTSPMedia *media, gpointer user_data)
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user