'Getting and setting Gstreamer element properties using C++

I'm writing a minimal C++ wrapper around the Gstreamer library. I have a class Element, which represents an Gstreamer element.

class Element
{
private:
    property* properties; 
public:
    gchar* name;
    GstElement* type; //represents the actual element
    Element();
    Element(gchar* name, gchar* type);
    Element(gchar * type);
    ~Element();
    void set_property(gchar* name, gchar* value);
    void set_property(gchar* name, gint value);
    void set_property(gchar* name, gfloat value);
    void get_property(gchar* name);
    int link_with(Element& e);   
};

set_property is straight forward:

    void Element::set_property(gchar* name, gchar* value) {
        g_object_set(this->type, name, value, NULL);
        // include further validations
    }
  1. I'm overloading the methods set_property because of the different value types that can occour. Is this the way to go? Or is there a way to unify the value parameter?

  2. How do I get a property without knowing its value type? The documentation suggest this example:

     gint intval;
     gchar *strval;
     GObject *objval;
     //my_object would be the Gstreamer element
      g_object_get (my_object,
                    "int-property", &intval,
                    "str-property", &strval,
                    "property-name", &objval,
                    NULL);
    
      // Do something with intval, strval, objval
    
      g_free (strval);
      g_object_unref (objval);
    

How do I check which variable intval, strval, objval was set?

PS: I can't use the official Gstreamer C++ wrapper, since it's not in active development and there is no real documentation about the usage.



Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source