Files
netris-warp/wayland-display-core/README.md
Wanjohi 9140dbf081 init
2023-11-25 18:16:42 +03:00

70 lines
1.8 KiB
Markdown

# gst-wayland-display
A micro Wayland compositor that can be used as a Gstreamer plugin
## Install
see [cargo-c](https://github.com/lu-zero/cargo-c)
```bash
git clone ...
cd gst-wayland-display
cargo cinstall --prefix=/usr/local
```
## GStreamer plugin
TODO
## C Bindings
CmakeLists.txt
```cmake
pkg_check_modules(libgstwaylanddisplay REQUIRED IMPORTED_TARGET libgstwaylanddisplay)
target_link_libraries(<YOUR_PROJECT_HERE> PUBLIC PkgConfig::libgstwaylanddisplay)
```
Include in your code:
```c
#include <libgstwaylanddisplay/libgstwaylanddisplay.h>
```
Example usage:
```c++
auto w_state = display_init("/dev/dri/renderD128"); // Pass a render node
display_add_input_device(w_state, "/dev/input/event20"); // Mouse
display_add_input_device(w_state, "/dev/input/event21"); // Keyboard
// Setting video as 1920x1080@60
auto video_info = gst_caps_new_simple("video/x-raw",
"width", G_TYPE_INT, 1920,
"height", G_TYPE_INT, 1080,
"framerate", GST_TYPE_FRACTION, 60, 1,
"format", G_TYPE_STRING, "RGBx",
NULL);
display_set_video_info(w_state, video_info);
// Get a list of the devices needed, ex: ["/dev/dri/renderD128", "/dev/dri/card0"]
auto n_devices = display_get_devices_len(w_state);
const char *devs[n_devices];
display_get_devices(w_state, devs, n_devices);
// Get a list of the env vars needed, notably the wayland socket
// ex: ["WAYLAND_DISPLAY=wayland-1"]
auto n_envs = display_get_envvars_len(w_state);
const char *envs[n_envs];
display_get_envvars(w_state, envs, n_envs);
// Example of polling for new video data
GstBuffer * v_buffer;
while(true){
v_buffer = display_get_frame(w_state);
// TODO: do something with the video data
}
display_finish(w_state); // Cleanup
```