当前位置:网站首页>Practical guide to GStreamer application development (III)
Practical guide to GStreamer application development (III)
2022-06-09 05:35:00 【Geek. Fan】
One 、 be based on GStreamer Application initialization for
Elements ,pad And buffer is GStreamer The basic concepts and the most commonly used objects . We use visual representations of these objects , So that more complex pipelines can be simply built later . A preliminary understanding GStreamer API in the future , Basically enough for us to build basic applications , The following is an introduction based on GStreamer The building process of the application .

1、 initialization GStreamer
Writing GStreamer Application time , We just need to simply include gst/gst.h To access library functions . besides , We also need to initialize GStreamer library .
When available GStreamer Before Library , Must be called from the main application gst_init Perform the necessary initialization of the library , And parse specific to GStreamer Command line options for .
A typical GStreamer Application initialization GStreamer Code for , As shown below :
#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;
}Use GST_VERSION_MAJOR, GST_VERSION_MINOR and GST_VERSION_MICRO The macro gets the GStreamer edition , Or use functions gst_version Get the version that your application links to .
GStreamer In the current scheme , Versions with the same major and minor versions are the same as API and ABI compatible .
You can also call... With two empty arguments gst_init function , under these circumstances ,GStreamer No command line options will be parsed .
2、GOption Interface
In addition to the above methods , We can also use GoOption Table initializes its own parameters , As shown in the following example :
#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;
}As shown in this procedure , We can use GOption Table to define application specific command line options , And compare this table with the gst_init_get_option_group The option group returned by the function is passed to GLib Initialization function . In addition to standard GStreamer Beyond the options , It will also parse your application options .
The code for this example is automatically extracted from the document , And in GStreamer tarball Medium tests/examples/manual Next build .
边栏推荐
- Source code analysis of reentrantreadwritelock of AQS
- Finding JS in the two-dimensional array of sword fingers (clear version)
- On input function of istream input stream object CIN
- TCP error control, flow control, congestion control
- MySQL add field or create table SQL statement
- Leetcode 929.独特的电子邮件地址
- STM32 FreeRTOS task Basics
- In latex, \cdots is followed by a sentence. What's wrong with the format of the following sentence.
- When classical music meets NFT
- (Application of reflection + introspection mechanism) processing the result set of JDBC
猜你喜欢

好榛子出辽阳!

Load research of Marathon LB

Data inconsistency between the reids cache and the database, cache expiration and deletion

Design owlook network novel recommendation system

Windows10 installs both MySQL 5 and MySQL 8

Swagger basic use quick start

In 2022, the database audit manufacturer will choose cloud housekeeper! Powerful!

使用MAT进行内存问题定位

Morsel-Driven Parallelism: 一种NUMA感知的并行Query Execution框架

reids 缓存与数据库数据不一致、缓存过期删除问题
随机推荐
Gstreamer应用开发实战指南(三)
Yolov5-6.0系列 | yolov5的模型网络构建
Apache Devlake 代码库导览
力扣今日题-1037. 有效的回旋镖
Heap and priority queues
2021 national vocational skills competition Liaoning "Cyberspace Security Competition" and its analysis (ultra detailed)
Basic knowledge of deep learning: face based common expression recognition (1)
爬取html入mysql插入失败
内网渗透 - 哈希传递攻击
FPGA based TDC Research Report
Intranet penetration hash delivery attack
Lambda anonymous function
Cuijian hasn't changed. BAIC Jihu should make a change
Thinking of reading
冒泡排序,打印菱形,打印直角三角形,打印倒三角,打印等边三角形,打印九九乘法表
Class related difficulties
In latex, \cdots is followed by a sentence. What's wrong with the format of the following sentence.
Windows uses php to start ThinkPHP project and deploy configuration
Web page capture software
Alibaba cloud AI training camp MySQL foundation 1: