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

How to assign values to argc and argv in code and pass them to gst_init()

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

// 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