GStreamer API学习记录(五)

GStreamer API学习记录(五)

前言
GST API的学习由:GST官网(一、二)---->QT源码中的GST(三、四)---->blogs中的GST资料(五~)。
资料地址

零散函数知识点

可以通过gst_clock_get_time()函数获取。

Gstreamer 预滚(Preroll):bin的状态从ready到paused的中间状态。不丢帧的准备数据。

gst_element_query_position(pipeline, &m_format,&m_position):查询播放的进度。


启动Pipeline就是一个Gst的应用程序。

启动方法:
1、gst_parse_launch启动
本项目中用pipeline = gst_parse_launch (qPrintable(cmd), &error);的方法把所有元件事先写好在cmd,然后一起启动pipeline。
这种方法简洁,适合与元件没有变化的情况。


2、gst_bin_add_many的方式
适合差异话的封装,便于模块化的代码组织

   GstElement *pipeline = gst_pipeline_new (NULL);
    GstElement *src = gst_element_factory_make ("videotestsrc", NULL);
    GstElement *glupload = gst_element_factory_make ("glupload", NULL);
    /* the plugin must be loaded before loading the qml file to register the
     * GstGLVideoItem qml item */
    GstElement *sink = gst_element_factory_make ("qmlglsink", NULL);

    g_assert (src && glupload && sink);

    gst_bin_add_many (GST_BIN (pipeline), src, glupload, sink, NULL);
    gst_element_link_many (src, glupload, sink, NULL);

//通过gst_bin_add_many就组成完整的pipeline,后面直接设置pipeline的状态就行。

QT的gst插件就是用方法二封装的,便于pipeline的模块化组成和修改。

posted @ 2021-03-04 14:19  wuya178  阅读(635)  评论(0)    收藏  举报