尝试使用大写创建过滤器:
GMainLoop *loop;
GstElement *pipeline, *source, *demuxer, *decoder, *typefind, *conv, *sink;;
GstBus *bus;
guint bus_watch_id;
loop = g_main_loop_new(NULL, FALSE);
pipeline = gst_pipeline_new ("audio-player");
source = gst_element_factory_make ("filesrc", "file-source");
typefind = gst_element_factory_make ("typefind", "typefinder");
demuxer = gst_element_factory_make ("oggdemux", "ogg-demuxer");
decoder = gst_element_factory_make ("vorbisdec", "vorbis-decoder");
conv = gst_element_factory_make ("audioconvert", "converter");
sink = gst_element_factory_make ("autoaudiosink", "audio-output");
if (!pipeline || !source || !demuxer || !decoder || !conv || !sink) {
return -1;
}
g_signal_connect (typefind, "have-type", G_CALLBACK (cb_typefound), loop);
g_object_set(G_OBJECT(source), "location", name_of_file, NULL);
bus = gst_pipeline_get_bus(GST_PIPELINE(pipeline));
bus_watch_id = gst_bus_add_watch(bus, bus_call, loop);
gst_object_unref(bus);
gst_bin_add_many(GST_BIN(pipeline), source, typefind, demuxer, decoder, conv, sink, NULL);
GstCaps *my_caps = gst_caps_new_simple ("audio/x-raw","rate", G_TYPE_INT, 384,NULL);
gboolean test=false;
test = gst_element_link_filtered(source,typefind, my_caps);
test = gst_element_link(typefind, demuxer);
test = gst_element_link_many(decoder, conv,sink, NULL);
g_signal_connect(demuxer, "pad-added", G_CALLBACK(on_pad_added), decoder);
......
调试:gsttypefindelement.c(1169):gst_type_find_element_loop():/ GstPipeline:a UDIO播放/ GstTypeFindElement:typefinder: 流已停止,原因未链接
在pst_element_link_filtered之后Var test == 1(source,typefind, my_caps);
在gst_element_link之后测试== 0(typefind,demuxer);
在gst_element_link_many(decode,conv,sink,NULL)之后测试== 1;
如果我只是在gst_element_link上更改gst_element_link_filtered,一切正常,文件播放。 我究竟做错了什么?
答案 0 :(得分:0)
您似乎也将此帖子发布到gst-devel邮件列表中,并在那里得到回复:
http://gstreamer-devel.966125.n4.nabble.com/GstCaps-filter-issue-td4672796.html
当您似乎想要播放OGG文件时,在filesrc和demuxer之间设置原始音频的过滤器上限是错误的。你应该更好地解释你想做什么,以便我们提供更精确的指导。