GStreamer GstVideoTestSrcPattern 枚举 - 它在哪里?

GStreamer GstVideoTestSrcPattern enum - where is it?

我正在尝试为我的 videotestsrc 设置 "pattern":

#include <gst/gst.h>

GstElement *pipeline, *source, *sink;
...
source = gst_element_factory_make("videotestsrc", "source");
g_object_set(source, "pattern", GST_VIDEO_TEST_SRC_BALL, NULL);

编译,得到:

error: ‘GST_VIDEO_TEST_SRC_BALL’ undeclared (first use in this function)

我需要包含哪些 header 才能包含 GstVideoTestSrcPattern 枚举的声明?我翻了一番也没找到。

GstVideoTestSrcPattern 枚举在 gst-plugins-base 中定义,在 gst/videotestsrc/gstvideotestsrc.h header 中。这是一个不以任何方式公开的 header(因为这意味着 GstVideoTestSrc 结构将成为 public API/ABI 的一部分)。因此,您不能使用实际的枚举符号。

要解决这个问题,您可以使用相应的整数值(在本例中为 18)。如果您实际上将 属性 设置为 gst-launch-1.0 或其 C 等价物 gst_parse_launch(),您实际上可以使用 videotestsrc pattern=ball,这也将起作用。

(注意:你甚至可以在 gst_value_deserialize() 的帮助下自己实现上述类型的字符串反序列化,但它仍然需要你输入一个未检查的字符串compile-time)

最后,如果您不确定枚举的各种值是什么,可以使用 gst-inspect-1.0 videotestsrc 作为作弊 sheet。