forked from mirrors/gstreamer-rs
Clean-up VideoFrame API
There's a buffer() for immutable references on all types now, and a buffer_mut() for getting a mutable reference on the writable videoframe Also some minor other cleanup
This commit is contained in:
parent
70e031b729
commit
70688fd6a9
2 changed files with 15 additions and 23 deletions
|
@ -37,19 +37,6 @@ impl<T> VideoFrame<T> {
|
||||||
from_glib(self.0.flags)
|
from_glib(self.0.flags)
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn mut_buffer(&self) -> Option<&mut gst::BufferRef> {
|
|
||||||
unsafe {
|
|
||||||
let writable: bool = from_glib(gst_ffi::gst_mini_object_is_writable(
|
|
||||||
self.0.buffer as *const _,
|
|
||||||
));
|
|
||||||
if !writable {
|
|
||||||
return None;
|
|
||||||
}
|
|
||||||
|
|
||||||
Some(gst::BufferRef::from_mut_ptr(self.0.buffer))
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
pub fn id(&self) -> i32 {
|
pub fn id(&self) -> i32 {
|
||||||
self.0.id
|
self.0.id
|
||||||
}
|
}
|
||||||
|
@ -138,6 +125,10 @@ impl<T> VideoFrame<T> {
|
||||||
self.info().offset()
|
self.info().offset()
|
||||||
}
|
}
|
||||||
|
|
||||||
|
pub fn buffer(&self) -> &gst::BufferRef {
|
||||||
|
unsafe { gst::BufferRef::from_ptr(self.0.buffer) }
|
||||||
|
}
|
||||||
|
|
||||||
pub fn plane_data(&self, plane: u32) -> Option<&[u8]> {
|
pub fn plane_data(&self, plane: u32) -> Option<&[u8]> {
|
||||||
if plane >= self.n_planes() {
|
if plane >= self.n_planes() {
|
||||||
return None;
|
return None;
|
||||||
|
@ -228,10 +219,6 @@ impl VideoFrame<Readable> {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn buffer(&self) -> &gst::BufferRef {
|
|
||||||
unsafe { gst::BufferRef::from_ptr(self.0.buffer) }
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
impl VideoFrame<Writable> {
|
impl VideoFrame<Writable> {
|
||||||
|
@ -291,7 +278,7 @@ impl VideoFrame<Writable> {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn buffer(&mut self) -> &mut gst::BufferRef {
|
pub fn buffer_mut(&mut self) -> &mut gst::BufferRef {
|
||||||
unsafe { gst::BufferRef::from_mut_ptr(self.0.buffer) }
|
unsafe { gst::BufferRef::from_mut_ptr(self.0.buffer) }
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -152,7 +152,12 @@ impl str::FromStr for ::VideoColorimetry {
|
||||||
|
|
||||||
impl fmt::Debug for ::VideoColorimetry {
|
impl fmt::Debug for ::VideoColorimetry {
|
||||||
fn fmt(&self, f: &mut fmt::Formatter) -> Result<(), fmt::Error> {
|
fn fmt(&self, f: &mut fmt::Formatter) -> Result<(), fmt::Error> {
|
||||||
f.write_str(&self.to_string())
|
f.debug_struct("VideoColorimetry")
|
||||||
|
.field("range", &self.0.range)
|
||||||
|
.field("matrix", &self.0.matrix)
|
||||||
|
.field("transfer", &self.0.transfer)
|
||||||
|
.field("primaries", &self.0.primaries)
|
||||||
|
.finish()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -169,7 +174,9 @@ impl From<::VideoMultiviewFramePacking> for ::VideoMultiviewMode {
|
||||||
}
|
}
|
||||||
|
|
||||||
impl ::VideoMultiviewFramePacking {
|
impl ::VideoMultiviewFramePacking {
|
||||||
pub fn try_from(v: ::VideoMultiviewMode) -> Result<::VideoMultiviewFramePacking, ::VideoMultiviewMode> {
|
pub fn try_from(
|
||||||
|
v: ::VideoMultiviewMode,
|
||||||
|
) -> Result<::VideoMultiviewFramePacking, ::VideoMultiviewMode> {
|
||||||
let v2 = from_glib(v.to_glib());
|
let v2 = from_glib(v.to_glib());
|
||||||
|
|
||||||
if let ::VideoMultiviewFramePacking::__Unknown(_) = v2 {
|
if let ::VideoMultiviewFramePacking::__Unknown(_) = v2 {
|
||||||
|
@ -445,9 +452,7 @@ impl VideoInfo {
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn to_caps(&self) -> Option<gst::Caps> {
|
pub fn to_caps(&self) -> Option<gst::Caps> {
|
||||||
unsafe {
|
unsafe { from_glib_full(ffi::gst_video_info_to_caps(&self.0 as *const _ as *mut _)) }
|
||||||
from_glib_full(ffi::gst_video_info_to_caps(&self.0 as *const _ as *mut _))
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn format(&self) -> ::VideoFormat {
|
pub fn format(&self) -> ::VideoFormat {
|
||||||
|
|
Loading…
Reference in a new issue