如何在代码中为argc和argv赋值并将它们传递给gst_init()

时间:2017-01-09 06:08:51

标签: qt gstreamer

我想在代码而不是main函数中声明和赋值给argc和argv,那么怎么做呢?我正在使用Qt。

1 个答案:

答案 0 :(得分:2)

// Works but wherever you use argv you should use * with it.
int argc = 2;
char* arg1[1] = {"gstreamer"}; // Program Name
char* arg2[1] = {"/home/1.ogg"};
char** argv[2] = { arg1 , arg2};

另一种方法:

// Works without any need for *
char  arg0[] = "gstreamer"; // Program Name
char  arg1[] = "/home/1.ogg";
char* argv[] = { &arg0[0], &arg1[0], NULL };
int   argc   = (int)(sizeof(argv) / sizeof(argv[0])) - 1;

参考文献:

How do I pass an array as a parameter?

Defining own main functions arguments argc and argv