如何测试我的 gstreamer 插件?是否有用于 gstreamer 插件测试的标准测试套件?

Jee*_*tel 4 c linux multimedia gstreamer media-player

假设我已经制作了基于 gstreamer 的插件。我已经安装了它并且它可以与 gst-launch 应用程序一起正常工作。

但现在我想测试我的 gstreamer 插件。那么是否有用于此类插件测试的标准测试套件?

是否有任何使用 gstreamer 组件构建的媒体播放器,以便我可以用我的插件替换该组件并测试它?

Dav*_*own 5

我不确定 GStreamer 0.10,考虑到它的年龄,我认为这个问题是关于它的。但对于为 GStreamer 1.0 编写插件的任何人来说,这里有一个非常简单的单元测试套件,它利用 GS​​treamer 的内置Check 框架GstCheck 模块

// This header will include some GStreamer-specific test utilities, as well as
// the internal Check API
#include <gst/check/gstcheck.h>

// Surround your tests with the GST_START_TEST and GST_END_TEST macros, then
// use the GstCheck and Check APIs
GST_START_TEST(my_test)
{
    ck_assert(0);
}
GST_END_TEST;

// This is a suite initialization function where you should register your tests.
// It must end with "_suite" and traditionally starts with your plugin's
// namespace.
Suite *gst_myplugin_suite(void) {
    Suite *s = suite_create("GstMyPlugin");
    TCase *tc = tcase_create("general");
    tcase_add_test(tc, my_test);
    // Add more tests with tcase_add_test(tc, test_function_name)
    suite_add_tcase(s, tc);
    return s;
}

// This generates an entry point that executes your test suite. The argument
// should be the name of your suite intialization function without "_suite".
GST_CHECK_MAIN(gst_myplugin);
Run Code Online (Sandbox Code Playgroud)

构建测试时,您需要链接插件*和gstcheck-1.0库。使用pkg-config可以让事情变得更容易:

gcc -o gstmyplugintests `pkg-config --cflags --libs gstreamer-check-1.0` gstmyplugin.so gstmyplugintests.c
Run Code Online (Sandbox Code Playgroud)

运行测试时,请记住告诉 GStreamer 在哪里寻找您的插件:

GST_PLUGIN_PATH=. ./gstmyplugintests
Run Code Online (Sandbox Code Playgroud)

这应该就是全部了!

* 编辑:实际上,如果您的测试访问其内部数据结构和功能,您只需要链接到您的插件。