-
Notifications
You must be signed in to change notification settings - Fork 30
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Road to GTK4 #105
Comments
The rust code can be compiled to be interoperable with C and Python, see the example A Rust and C version would be easier to make cross-platform than a Rust, C and Python version. OpenCV maybe another choice: |
@bkmgit In order to follow the gtksink.py example, we have to find a way to build gst-plugins-rs to *.so files and package them to *.deb files. Its README has a guide to build, but to make *.deb packages is unknown. The process involves When thinking about the Rust version, I can see the ability to build both CoBang and |
Many Fedora packages which use rust bundle dependencies as they are usually pinned to specific versions that are often incompatible. This is not great. https://apps.kde.org/qrca/ is built for KDE using Qt. MauiKit and WxWidgets are other options, there are other choices as well depending on how much change could be introduced to the code, and if using at most C/C++/Python/Rust is a constraint. There has been a port of gtksink for C, but it has not been merged in main tree. |
SDL3 has Python bindings https://github.com/Aermoss/PySDL3 Is there still interest in builds for mobile devices, in particular Android? |
This is a typical GTK4 app, and how it looks in GNOME. I want CoBang to be like it. Being GTK3, this is how CoBang looks currently: CoBang can be valuable for Linux phones, like Librem, but not Android, because there are already dozen of QR scanning apps on Android. I tried to make CoBang support Librem once, but failed because the phone uses a type of camera which was not supported by Video4Linux subsystem. There has been a new lib, libcamera, to support wide variants of camera. But its integration with GStreamer is still limited. On Ubuntu 24.04, if Pipewire and libcamera are installed, CoBang will fails to access webcam. |
Mostly use Fedora. Libcamera integrates with a wide variety of libraries. https://libcamera.org/getting-started.html |
May need pipewire-libcamera? Pipewire integration seems useful: |
Libcamera -> pipewire -> gtk4 seems feasible |
https://pypi.org/project/pipewire_python/ could be used for integration ModernGl or PyOpenGl are other options https://discourse.gnome.org/t/moderngl-python-with-gtk4/18826 |
An example with GTK4 https://github.com/yucefsourani/python-gtk4-examples/tree/main/small_programs/pyscanbc Maybe Cambalache could replace Glade? |
The I know that libcamera + PipeWire + GStreamer have been integrated together. It is just that the integration is not mature enough. CoBang source code has a block to handle this case, where it has to ignore the libcamera-based device that GStreamer reports. The data is private, no methods, attributes are exported for Python to handle. The pyscanbc example doesn't solve the problem. My problem is "packaging gst-plugins-rs as *.deb", not "how to use Python + GTK4 + GStreamer". The ModernGl is also not an appropriate approach. If you use OpenGL directly, its mean that you have to draw the window, the buttons, the dropdown, the tabs, the menu yourselves. Using OpenGL directly is appropriate when you are making video game. All the buttons in video games are specific to the game and don't need to follow style of your DE. Yes, dropping Glade is in my plan, when migrating to GTK4. |
Dino uses Vala and has video integration using gdk paintable https://github.com/dino/dino/blob/master/plugins/rtp/src/video_widget.vala Vala does not have packaging problems Rust has, and it is possible call from Python, see for example https://stackoverflow.com/questions/59987525/how-to-use-a-custom-gtk-widget-written-in-vala-from-python Vala ecosystem has a few problems, https://blogs.gnome.org/mcatanzaro/2017/02/19/on-problems-with-vala/ but seems a better choice than Rust if the aim is to use GTK4. |
gdkpaintable had Python bindings https://amolenaar.pages.gitlab.gnome.org/pygobject-docs/Gdk-4.0/interface-Paintable.html |
Good finding. Dino team is so strong that they implement a custom GStreamer sink themselves. This video_widget.vala is equivalent to the official Rust-based gst-plugin-gtk4. But, unfortunately, Dino doesn't distribute their video sink as an independent lib for other apps to use. This video sink is linked with other Dino specific code to build the /usr/lib/x86_64-linux-gnu/dino-im/plugins/rtp.so file, which is just specific to Dino, CoBang cannot use it. |
Will see if can implement a minimal Python example later this week. |
@bkmgit Great news, I found that the Gstreamer GTK4 plugin has been prebuilt for Ubuntu 24.10+. |
Still prefer to create custom plugin without rust dependencies. |
I don't know how it is for other distros, but for Debian / Ubuntu, the above prebuilt package is *.so file, we can use it without depending on Rust, just need to declare gstreamer1.0-gtk4 as one of dependencies. |
Rust dependencies are usually vendored and pinned at particular versions. They need not be updated if there are any problems, and one would need to keep checking the package dependencies independently, rather than checking for library upgrades. |
It is also in Fedora https://packages.fedoraproject.org/pkgs/rust-gst-plugin-gtk4/gstreamer1-plugin-gtk4/ but rust dependencies are all vendored. Would prefer not to use it and add necessary functionality if you are ok checking this. |
@bkmgit I believe you misunderstood the gstreamer1-plugin-gtk4 package in Fedora and the gstreamer1.0-gtk4 package in Ubuntu. Because Rust does not have stable API, there are two forms of packaging Rust libs (in Debian and Fedora, at least to my knowledge):
The 2nd option may not apply to Arch Linux, Gentoo because they seem to always build package from source when user want to install a package. |
The rust dependencies used to build the shared library are vendored. They only get used for building that library and are only updated when the library is updated. Typically, other dependencies are shared across the distribution, and consumed by any packages that use them. This leads to wider testing of the dependencies, and more reliable software but slows down development speeds. Something like xz library security bug would be harder to catch with rust dependencies. |
Agree with you, but "vendored" in Debian context are the |
The work of porting CoBang to GTK4 is in progress, at https://codeberg.org/quan/CoBangB |
Code for GTK4 has been copied to feature/gtk4 branch. |
Ok, will check. Can follow on Codeberg as well. |
v1.0 has been released to mark the migration to GTK4. |
GTK4 has been released for a while and GTK3 will be deprecated. CoBang should migrate to GTK4 before we add more features.
The roadblock is how to rendering video (from webcam) to GTK4 widget. There is no Python binding for gst-plugins-rs which provides Gstreamer Sink for GTK 4. The only way to use this plugin is to rewrite CoBang in Rust language. In Rust, we can also use aperture which simplify usage of GTK4 Sink.
The text was updated successfully, but these errors were encountered: