Possible to get a mutable and immutable references to the same mini object reference
let buffer1 = gst::Buffer::new();
let buffer1_mut_ref: &mut gst::BufferRef = buffer1.get_mut().unwrap();
let buffer2: gst::Buffer = buffer1_mut_ref.to_owned();
let buffer2_ref: &gst::BufferRef = buffer2.as_ref();
The problem here is that to_owned()
gives us a new refcounting wrapper and can also be called on mutable reference, and the new refcounting wrapper always allows us to get an immutable reference.
Similar problem exists for example with the gst::Sample
constructor and other functions that take only a &gst::BufferRef
(or any other mini object reference) but then store the reference themselves somewhere (and gst_mini_object_ref()
them) and allow to give back access to the mini object.
let buffer1 = gst::Buffer::new();
let buffer1_mut_ref: &mut gst::BufferRef = buffer1.get_mut().unwrap();
let sample = gst::Sample::new(Some(buffer1_mut_ref), ...);
let buffer2_ref: &gst::BufferRef = sample.get_buffer().unwrap();
Edited by Sebastian Dröge