On Fri, Apr 18, 2025 at 01:29:48PM +0200, Dietmar Maurer wrote: > The search list is currently hardcoded to: ["x264enc", "openh264enc"] > > x264enc: is probably the best available software encoder > openh264enc: lower quality, but available on more systems. > > We restrict encoders to a known list because each encoder requires > fine tuning to get reasonable/usable results. > > Signed-off-by: Dietmar Maurer <diet...@proxmox.com> > --- > ui/vnc-enc-h264.c | 89 +++++++++++++++++++++++++++++++++++++++-------- > ui/vnc.h | 1 + > 2 files changed, 75 insertions(+), 15 deletions(-) > > diff --git a/ui/vnc-enc-h264.c b/ui/vnc-enc-h264.c > index 3abe6a1528..047f4a3128 100644 > --- a/ui/vnc-enc-h264.c > +++ b/ui/vnc-enc-h264.c > @@ -27,6 +27,68 @@ > > #include <gst/gst.h> > > +const char *encoder_list[] = { "x264enc", "openh264enc", NULL }; > + > +static const char *get_available_encoder(void) > +{ > + int i = 0; > + do { > + const char *encoder_name = encoder_list[i]; > + if (encoder_name == NULL) { > + break; > + } > + GstElement *element = gst_element_factory_make( > + encoder_name, "video-encoder"); > + if (element != NULL) { > + gst_object_unref(element); > + return encoder_name; > + } > + i = i + 1; > + } while (true);
This while loop is incredibly verbose as written. for (int i = 0; i < G_N_ELEMENTS(encoder_list); i++) { GstElement *element = gst_element_factory_make( encoder_list[i], "video-encoder"); if (element != NULL) { gst_object_unref(element); return encoder_list[i]; } } and get rid of the trailing "NULL" in encoder_list as it isn't required > + > + return NULL; > +} > + With regards, Daniel -- |: https://berrange.com -o- https://www.flickr.com/photos/dberrange :| |: https://libvirt.org -o- https://fstop138.berrange.com :| |: https://entangle-photo.org -o- https://www.instagram.com/dberrange :|