GStreamer 애플리케이션을 작성할 때 gst/gst.h를 포함하면 라이브러리 기능에 액세스할 수 있습니다. 그 외에도 GStreamer 라이브러리를 초기화해야 합니다.
간단한 초기화
GStreamer 라이브러리를 사용하려면 먼저 기본 애플리케이션에서 gst_init를 호출해야 합니다. 이 호출은 필요한 라이브러리 초기화를 수행하고 GStreamer 관련 명령줄 옵션을 구문 분석합니다.
일반적인 프로그램 [1]에는 다음과 같은 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 및 GST_VERSION_MICRO 매크로를 사용하여 빌드 중인 GStreamer 버전을 가져오거나, gst_version 함수를 사용하여 애플리케이션에 연결된 버전을 가져옵니다. GStreamer는 현재 주 버전과 부 버전이 동일한 버전이 API 및 ABI와 호환되는 구성표를 사용합니다.
두 개의 NULL 인수를 사용하여 gst_init 함수를 호출하는 것도 가능합니다. 이 경우 GStreamer는 명령줄 옵션을 구문 분석하지 않습니다.
GOption 인터페이스
다음 예와 같이 GOption 테이블을 사용하여 고유한 매개변수를 초기화할 수도 있습니다.
#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의 test/examples/manual 아래에 빌드됩니다.
Initializing GStreamer
Initializing GStreamer When writing a GStreamer application, you can simply include gst/gst.h to get access to the library functions. Besides that, you will also need to initialize the GStreamer library. Simple initialization Before the GStreamer libraries
gstreamer.freedesktop.org
'IT와 개발 > GStreamer Study' 카테고리의 다른 글
Bins (1) | 2024.04.12 |
---|---|
Elements (0) | 2024.04.05 |
Application Development Manual: Foundations (1) | 2024.03.22 |
디자인 원칙 (0) | 2024.03.20 |
GStreamer 란? (0) | 2024.03.17 |