Set opusenc properties in Rust

Hi all,

I am currently experimenting with gstreamer and rust, but I have encountered a small issue while trying to set some properties of the opusenc element.

        let opusenc = gst::ElementFactory::make("opusenc")
            .property("audio-type", "restricted-lowdelay")
            .property("frame-size", 10)
            .build()
            .unwrap();
        self.pipeline.add(&opusenc).unwrap();
thread 'main' panicked at ...:
property 'audio-type' of type 'GstOpusEnc' can't be set from the given type (expected: 'GstOpusEncAudioType', got: 'gchararray')

or

thread 'main' panicked at ...:
property 'frame-size' of type 'GstOpusEnc' can't be set from the given type (expected: 'GstOpusEncFrameSize', got: 'gint')

I suspect that I am missing an import, but I am unable to determine where to find the necessary GstOpusEnc types.

Thanks for your help!

Try:

        let opusenc = gst::ElementFactory::make("opusenc")
            .property_from_str("audio-type", "restricted-lowdelay")
            .build();

(reason is that “audio-type” is an enum which like flags expects an integer value as property, but with property_from_str you can pass a nickname like in gst-launch`)

Thanks that works^^ Any idea for the frame-size?

property_from_str() should work for frame-size too since it’s an enum too (in C you could pass the value as int, but seems like that’s not possible in the Rust bindings).

(well, property_from_str() always works, even if it’s not an enum)