我正在尝试练习GStreamer教程3: https://gstreamer.freedesktop.org/documentation/tutorials/basic/dynamic-pipelines.html?gi-language=c#exercise
在Ubuntu 18.04上工作
我已添加并链接了autovideosink和videoconvert:
data.videosink = gst_element_factory_make("autovideosink", "videosink");
data.videoconvert = gst_element_factory_make("videoconvert", "videoconvert");
并修改了回调:
if (g_str_has_prefix (new_pad_type, "audio/x-raw")) {
sink_pad = gst_element_get_static_pad (data->convert, "sink");
}
else if (g_str_has_prefix (new_pad_type, "video/x-raw")){
sink_pad = gst_element_get_static_pad (data->videoconvert, "sink");
}
else
{
g_print ("It has type '%s' which is not raw audio. Ignoring.\n",
new_pad_type);
goto exit;
}
/* If our converter is already linked, we have nothing to do here */
if (gst_pad_is_linked (sink_pad)) {
g_print ("We are already linked. Ignoring.\n");
goto exit;
}
/* Attempt the link */
ret = gst_pad_link (new_pad, sink_pad);
if (GST_PAD_LINK_FAILED (ret)) {
g_print ("Type is '%s' but link failed.\n", new_pad_type);
} else {
g_print ("Link succeeded (type '%s').\n", new_pad_type);
}
但是我无法链接视频键盘: 类型为“视频/ x原始”,但链接失败。
我尝试检查垫是否可以链接,并且返回false。 我可以得到更多的设置或更多关于打击垫之间兼容性的信息吗?
答案 0 :(得分:0)
首先,谢谢,因为代码的正确部分帮助我解决了问题。
实际上您所做的所有更改都是正确的,我在这里运行了。但是还有其他要更改的地方,让我们验证一下:
-首先,我们必须验证所有内容并将其添加到bin:
if (!data.pipeline || !data.source || !data.convert || !data.sink || !data.videoconvert || !data.videosink) {
g_printerr ("Not all elements could be created.\n");
return -1;
}
gst_bin_add_many (GST_BIN (data.pipeline), data.source, data.convert , data.sink, data.videoconvert , data.videosink, NULL);
if (!gst_element_link (data.convert, data.sink)) {
g_printerr ("Elements could not be linked.\n");
gst_object_unref (data.pipeline);
return -1;
}
if (!gst_element_link (data.videoconvert, data.videosink)) {
g_printerr ("Elements could not be linked.\n");
gst_object_unref (data.pipeline);
return -1;
}
-在修改之前,请确保您的回调函数具有定义:
GstPad *sink_pad = gst_element_get_static_pad (data->convert, "sink");
GstPadLinkReturn ret;
GstCaps *new_pad_caps = NULL;
GstStructure *new_pad_struct = NULL;
const gchar *new_pad_type = NULL;
g_print ("Received new pad '%s' from '%s':\n", GST_PAD_NAME (new_pad), GST_ELEMENT_NAME (src));
new_pad_caps = gst_pad_get_current_caps (new_pad);
new_pad_struct = gst_caps_get_structure (new_pad_caps, 0);
new_pad_type = gst_structure_get_name (new_pad_struct);
-而且,在回调的末尾有释放内存的部分。
此代码正在运行,我希望我能为您提供帮助,并验证您的连接,因为这些代码是从Internet流式传输的。
答案 1 :(得分:0)
run