我在第二个帖子中链接元素时遇到问题。 我在每个I创建管道中创建两个线程来存储IP摄像机流到文件。 当第二个线程尝试链接流元素(h264parse - > matroskamux)时,我收到了分段故障信号。
Gstreamer打印出一些错误:
(Cam_recorder:5529): GLib-GObject-WARNING **: cannot register existing type 'GstMatroskamuxPad'
(Cam_recorder:5529): GLib-GObject-CRITICAL **: g_object_new: assertion 'G_TYPE_IS_OBJECT (object_type)' failed
当我运行相同的代码并在执行线程之间添加了一些延迟(500ms)时,两个线程都正确地创建了管道并且程序工作。
任何人都可以帮助我吗?
编辑: 我的代码:
void Camera::Thread_function(){
GstElement *pipeline=NULL;
GstElement * temp_ele;
GstBus *bus=NULL;
GstMessage *msg=NULL;
GError *error = NULL;
STRING text;
DEBUG<<"Starting camera:"<<name<<END;
text=stream_uri;
DEBUG<< text <<END;
pipeline=gst_parse_launch(text.c_str(),&error);
if (error != NULL){
CRITICAL<<"Parse error: "<< error->message<<END;
g_error_free (error);
error=NULL;
goto STOP;
}
if(pipeline==NULL){
CRITICAL<<"Pipeline is NULL"<<END;
goto STOP;
}
gst_element_set_state (pipeline, GST_STATE_PLAYING);
loop = g_main_loop_new (NULL, FALSE);
gst_bus_add_watch (GST_ELEMENT_BUS (pipeline), bus_cb, loop);
g_timeout_add_seconds (1, CAM_REC::timeout_cb, this);
g_main_loop_run (loop);
g_main_loop_unref (loop);
STOP:
if (msg != NULL){
gst_message_unref (msg);
msg=NULL;
}
if(bus!=NULL){
gst_object_unref (bus);
bus=NULL;
}
if(pipeline){
gst_element_set_state (pipeline, GST_STATE_NULL);
gst_object_unref (pipeline);
pipeline=NULL;
}
//*/
INFO<<"Cam "<<name<<" end"<<END;
}
管道:
rtspsrc name=kam3_stream location=\"rtsp://192.168.0.107/stream1\" ! rtph264depay name=kam3_deplay ! h264parse name=kam3_parse ! matroskamux name=kam3_mux ! filesink location=x.mkv name=kamera3_file_sink
rtspsrc name=kam4_stream location=\"rtsp://admin:admin@192.168.0.108/\" ! rtph264depay name=kam4_deplay ! h264parse name=kam4_parse ! matroskamux name=kam4_mux ! filesink location=x2.mkv name=kamera4_file_sink
程序在函数gst_parse_launch()
中崩溃罐