Search code examples
cgstreamer-1.0

GStreamer GstVideoTestSrcPattern enum - where is it?


I'm trying to set the "pattern" for my videotestsrc:

#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);

Compiling, I get:

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

What header do I need to include to have a declaration for the GstVideoTestSrcPattern enum? I've grepped around a bit and can't find it.


Solution

  • The GstVideoTestSrcPattern enum is defined in gst-plugins-base, in the gst/videotestsrc/gstvideotestsrc.h header. This is a header that is not exposed in any way (since it would mean that the GstVideoTestSrc struct would become part of the public API/ABI). As such, you can't use the actual enum symbol.

    To solve this, you can use the corresponding integer value (in this case, 18). If you're actually setting the property with something like gst-launch-1.0 or its C equivalent gst_parse_launch(), you can actually use videotestsrc pattern=ball, which will also work.

    (Note: you could even implement the aforementioned kind of string deserialization yourself with the help of gst_value_deserialize(), but it would still require you to put in a string that is not checked at compile-time)

    Finally, if you're unsure what the various values of the enum are, you can use gst-inspect-1.0 videotestsrc as a cheat sheet.