[rust] waylandsink with video overlay
Sebastian Dröge
sebastian at centricular.com
Thu Jan 28 17:26:07 UTC 2021
On Thu, 2021-01-28 at 08:57 -0800, Joel Winarske wrote:
>
> I'm down to https://github.com/jwinarske/waylandsink-with-video-overlay-rs/blob/main/src/main.rs#L59-L72
>
> error[E0277]: the trait bound `Value: SetValue` is not satisfied
> --> src/main.rs:70:25
> |
> 70 | s.set("handle", &value);
> | ^^^^^^ the trait `SetValue` is not implemented for `Value`
> |
> = note: required because of the requirements on the impl of `ToSendValue` for `Value`
It indeed needs a bit more massaging. The following code should do it.
{
let context = context.get_mut().unwrap();
let s = context.get_mut_structure();
let value = unsafe {
use gst::glib::translate::*;
use std::mem;
let handle = display.c_ptr();
let mut value = mem::MaybeUninit::zeroed();
gst::gobject_sys::g_value_init(value.as_mut_ptr(), gst::gobject_sys::G_TYPE_POINTER);
gst::gobject_sys::g_value_set_pointer(value.as_mut_ptr(), handle as *mut c_void);
gst::glib::SendValue::from_glib_none(&value.assume_init() as *const _)
};
s.set_value("handle", value);
}
Apart from everything else there's also the problem that you need to
tell the type system that your value is actually thread-safe. So the
easiest/shortest here is actually to just create the whole GValue like
we would be doing in C.
--
Sebastian Dröge, Centricular Ltd · https://www.centricular.com
More information about the gstreamer-devel
mailing list