当前位置:网站首页>Gstreamer应用开发实战指南(三)
Gstreamer应用开发实战指南(三)
2022-06-09 05:22:00 【Geek.Fan】
一、基于GStreamer的应用程序初始化
元素,pad和缓冲区是GStreamer的基本概念和最常用的对象。我们使用这些对象的可视化表示形式,以便于后面可以简单地构建的更复杂的管道。初步了解GStreamer API以后,基本上足够我们构建基本应用程序了,下面介绍一下基于GStreamer的应用程序的构建过程。

1、初始化GStreamer
在编写 GStreamer 应用程序时,我们只需要简单地包含gst/gst.h以访问库函数。除此之外,我们还需要初始化GStreamer库。
在可以使用 GStreamer 库之前,必须从主应用程序调用gst_init执行库的必要初始化,并解析特定于GStreamer 的命令行选项。
一个典型的GStreamer应用程序的初始化 GStreamer 的代码,如下所示:
#include <stdio.h>
#include <gst/gst.h>
int main (int argc, char *argv[])
{
const gchar *nano_str;
guint major, minor, micro, nano;
gst_init (&argc, &argv);
gst_version (&major, &minor, µ, &nano);
if (nano == 1)
nano_str = "(CVS)";
else if (nano == 2)
nano_str = "(Prerelease)";
else
nano_str = "";
printf ("This program is linked against GStreamer %d.%d.%d %s\n",
major, minor, micro, nano_str);
return 0;
}使用GST_VERSION_MAJOR, GST_VERSION_MINOR and GST_VERSION_MICRO 宏获取您正在构建的GStreamer版本,或使用函数 gst_version获取您的应用程序链接所依据的版本。
GStreamer目前使用的方案中,主版本和次版本相同的版本与API和ABI兼容。
还可以使用两个空参数调用gst_init函数,在这种情况下,GStreamer不会解析任何命令行选项。
2、GOption接口
除以上方法外,我们还可以使用GoOption表初始化自己的参数,如下一个示例所示:
#include <gst/gst.h>
int main (int argc, char *argv[])
{
gboolean silent = FALSE;
gchar *savefile = NULL;
GOptionContext *ctx;
GError *err = NULL;
GOptionEntry entries[] = {
{ "silent", 's', 0, G_OPTION_ARG_NONE, &silent, "do not output status information", NULL },
{ "output", 'o', 0, G_OPTION_ARG_STRING, &savefile, "save xml representation of pipeline to FILE and exit", "FILE" },
{ NULL }
};
ctx = g_option_context_new ("- Your application");
g_option_context_add_main_entries (ctx, entries, NULL);
g_option_context_add_group (ctx, gst_init_get_option_group ());
if (!g_option_context_parse (ctx, &argc, &argv, &err)) {
g_print ("Failed to initialize: %s\n", err->message);
g_clear_error (&err);
g_option_context_free (ctx);
return 1;
}
g_option_context_free (ctx);
printf ("Run me with --help to see the Application options appended.\n");
return 0;
}如本段程序所示,我们可以使用 GOption 表来定义特定于应用程序的命令行选项,并将此表与从gst_init_get_option_group函数返回的选项组一起传递给 GLib 初始化函数。除了标准 GStreamer 选项之外,还将解析您的应用程序选项。
此示例的代码自动从文档中提取,并在GStreamer tarball中的tests/examples/manual下构建。
边栏推荐
猜你喜欢

Pull down the new project code and make it red

MRNA factory| quantitative detection of LNP encapsulated RNA content by ribogreen
![[it] Fuxin PDF Keeping Tool Selection](/img/1e/87dbd435e830c139bc3d5cf86d6d57.png)
[it] Fuxin PDF Keeping Tool Selection

MQ消息丢失,消息一致性,重复消费解决方案

The difference between traditional method and lean method

queue

June 2022 Tsinghua Management Tsinghua University Ning Xiangdong

Mécanisme de mise en cache dans le transformateur

TCP explanation (Wireshark packet capturing analysis TCP three handshakes and TCP four waves)

Xtrabackup backup and recovery
随机推荐
Alibaba cloud AI training camp -sql basics 5: window functions, etc
Yolov5-6.0系列 | yolov5的模型网络构建
Transaction code qc51 of SAP QM preliminary level creates quality certificate for purchase order
好榛子出辽阳!
Data summit 2022 conference information sharing (23 in total)
基础集群部署 - kubernetes-simple
Requests segmented downloading of files and multi-threaded downloading
Windows uses php to start ThinkPHP project and deploy configuration
崔健没变,北汽极狐该做出改变了
Marathon环境下fastdfs和vsftpd和miniIo文件服务器搭建的方式
Transformer裏面的緩存機制
redis 缓存雪崩、穿透、击穿问题
validate-npm-package-name
关于全局异常捕获的思考-真正的全局异常捕获
pytorch with Automatic Mixed Precision(AMP)
Summary of Android Engineer interview experience with 5 years' work experience, summary of real interview questions of Ali + Tencent + byte jump
Good hazelnut comes from Liaoyang!
PS how to add white edges to images
Xtrabackup backup and recovery
Deque of STL