Skip to content

Support retrieving GstStructure values from GValuelist #211

Closed
@czaurel

Description

@czaurel

The facedetect plugin from gst-plugins-bad posts bus messages about detected faces which contain value lists of structures.

Trying to get the values via Structure.getValues(Class<T> type, String fieldName) results in an exception:

if (message.getStructure() != null && message.getStructure().hasField("faces")) {
    List<Structure> faces = message.getStructure().getValues(Structure.class, "faces");
}
->
org.freedesktop.gstreamer.Structure$InvalidFieldException: Structure does not contain Structure field 'faces'
	at org.freedesktop.gstreamer.Structure.getValues(Structure.java:462)

My current workaround was to use register(TypeRegistration<?> registration) for adding a registration like this: Natives.<Structure>registration(Structure.class, "GstStructure", Structure::new). This requires using a non-public API though.

If there is no other reason for omitting it, Gst.init() should probably register a type adapter like this in Gst.loadAllClasses(). I'm not exactly sure which TypeProvider should provide it though.

If this seems like a good idea, I'll throw together a PR.

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions