zoukankan      html  css  js  c++  java
  • [gstreamer] goption

    ■ The GOption interface:

    goption.c

     1 #include <gst/gst.h>
     2 #include <stdio.h>
     3 int
     4 main (int   argc,
     5       char *argv[])
     6 {
     7   gboolean silent = FALSE;
     8   gchar *savefile = NULL;
     9   GOptionContext *ctx;
    10   GError *err = NULL;
    11   GOptionEntry entries[] = {
    12     { "silent", 's', 0, G_OPTION_ARG_NONE, &silent,
    13       "do not output status information", NULL },
    14     { "output", 'o', 0, G_OPTION_ARG_STRING, &savefile,
    15       "save xml representation of pipeline to FILE and exit", "FILE" },
    16     { NULL }
    17   };
    18 
    19   ctx = g_option_context_new ("- Your application");
    20   g_option_context_add_main_entries (ctx, entries, NULL);
    21   g_option_context_add_group (ctx, gst_init_get_option_group ());
    22   if (!g_option_context_parse (ctx, &argc, &argv, &err)) {
    23     g_print ("Failed to initialize: %s
    ", err->message);
    24     g_clear_error (&err);
    25     g_option_context_free (ctx);
    26     return 1;
    27   }
    28   g_option_context_free (ctx);
    29 
    30   printf ("Run me with --help to see the Application options appended.
    ");
    31   printf ("silent = %d savefile=%s.
    ", silent, savefile);
    32 
    33   return 0;
    34 }

    ■ 编译

    gcc goption.c -o goption `pkg-config --cflags --libs gstreamer-1.0`

    ■ 运行结果

    renhl@renhl:~/share/1/goption$ ./goption -o test.txt
    Run me with --help to see the Application options appended.
    silent = 0 savefile=test.txt.
    renhl@renhl:~/share/1/goption$ ./goption -s 1  -o test.txt
    Run me with --help to see the Application options appended.
    silent = 1 savefile=test.txt.
    renhl@renhl:~/share/1/goption$ vim goption.c

    ■ 参考

    https://developer.gnome.org/glib/stable/glib-Commandline-option-parser.html

    https://gstreamer.freedesktop.org/documentation/application-development/basics/init.html#the-goption-interface

  • 相关阅读:
    sql.srcipt
    sowmodaldialog
    4) 删除虚拟应用程序
    JavaScript读写Cookies
    第5章 脚本运行期库对象
    npm serve md 工具 [MD]
    cleanmark 清除格式 博客内容提取 [MD]
    Hex编码 十六进制编码
    Windows Server AppFabric(Codename:"Dublin&Velocity")介绍
    WF4设计器模型:编辑范围ModelEditingScope
  • 原文地址:https://www.cnblogs.com/renhl/p/10743760.html
Copyright © 2011-2022 走看看