原文:Basic tutorial 2: GStreamer concepts
目标
前一个教程展示了怎么自动构建一个pipeline。现在我们通过实例化每一个element,然后把他们链接到一起来手动创建一个pipeline。这个过程中,我们会学到:
- 什么是element,怎么创建一个element
- 怎么连接elements
- 怎么定制一个element的行为
- 如何观察总线(bus)的错误情况,并从消息(message)中解析信息
手动的“Hello World”
#include <gst/gst.h>
int
main (int argc, char *argv[])
{
GstElement *pipeline, *source, *sink;
GstBus *bus;
GstMessage *msg;
GstStateChangeReturn ret;
/* Initialize GStreamer */
gst_init (&argc, &argv);
/* Create the elements */
source = gst_element_factory_make ("videotestsrc", "source");
sink = gst_element_factory_make ("autovideosink", "sink");
/* Create the empty pipeline */
pipeline = gst_pipeline_new ("test-pipeline");
if (!pipeline || !source || !sink) {
g_printerr ("Not all elements could be created.\n");
return -1;
}
/* Build the pipeline */
gst_bin_add_many (GST_BIN (pipeline), source, sink, NULL);
if (gst_element_link (source, sink) != TRUE) {
g_printerr ("Elements could not be linked.\n");
gst_object_unref (pipeline);
return -1;
}
/* Modify the source's properties */
g_object_set (source, "pattern", 0, NULL);
/* Start playing */
ret = gst_element_set_state (pipeline, GST_STATE_PLAYING);

——基础教程2:GStreamer概念&spm=1001.2101.3001.5002&articleId=135560326&d=1&t=3&u=2c6fb1cd210d4c279cc6731f147bc8c7)
1100

被折叠的 条评论
为什么被折叠?



