diff --git a/gstreamer-analytics/sys/Gir.toml b/gstreamer-analytics/sys/Gir.toml index c7a17f828..9da416b43 100644 --- a/gstreamer-analytics/sys/Gir.toml +++ b/gstreamer-analytics/sys/Gir.toml @@ -50,3 +50,7 @@ boxed_inline = true name = "GstAnalytics.Mtd" status = "generate" boxed_inline = true + +[[object]] +name = "GstAnalytics.Tensor" +status = "manual" diff --git a/gstreamer-analytics/sys/src/lib.rs b/gstreamer-analytics/sys/src/lib.rs index fed96b543..086fcc93b 100644 --- a/gstreamer-analytics/sys/src/lib.rs +++ b/gstreamer-analytics/sys/src/lib.rs @@ -15,6 +15,10 @@ use glib_sys as glib; use gstreamer_sys as gst; +mod manual; + +pub use manual::*; + #[cfg(unix)] #[allow(unused_imports)] use libc::{dev_t, gid_t, pid_t, socklen_t, uid_t}; @@ -206,34 +210,6 @@ impl ::std::fmt::Debug for GstAnalyticsTrackingMtd { } } -#[repr(C)] -#[allow(dead_code)] -pub struct GstTensor { - pub id: glib::GQuark, - pub layout: GstTensorLayout, - pub data_type: GstTensorDataType, - pub batch_size: size_t, - pub data: *mut gst::GstBuffer, - pub dims_order: GstTensorDimOrder, - pub num_dims: size_t, - _truncated_record_marker: c_void, - // /*Ignored*/field dims has empty c:type -} - -impl ::std::fmt::Debug for GstTensor { - fn fmt(&self, f: &mut ::std::fmt::Formatter) -> ::std::fmt::Result { - f.debug_struct(&format!("GstTensor @ {self:p}")) - .field("id", &self.id) - .field("layout", &self.layout) - .field("data_type", &self.data_type) - .field("batch_size", &self.batch_size) - .field("data", &self.data) - .field("dims_order", &self.dims_order) - .field("num_dims", &self.num_dims) - .finish() - } -} - #[derive(Copy, Clone)] #[repr(C)] pub struct GstTensorDim { diff --git a/gstreamer-analytics/sys/src/manual.rs b/gstreamer-analytics/sys/src/manual.rs new file mode 100644 index 000000000..be3f2eb17 --- /dev/null +++ b/gstreamer-analytics/sys/src/manual.rs @@ -0,0 +1,33 @@ +use gstreamer_sys as gst_sys; +use libc::size_t; + +use crate::{GstTensorDataType, GstTensorDim, GstTensorDimOrder, GstTensorLayout}; + +#[repr(C)] +pub struct GstTensor { + pub id: glib_sys::GQuark, + pub layout: GstTensorLayout, + pub data_type: GstTensorDataType, + pub batch_size: size_t, + pub data: *mut gst_sys::GstBuffer, + pub dims_order: GstTensorDimOrder, + pub num_dims: size_t, + pub dims: [GstTensorDim; 0], +} + +impl ::std::fmt::Debug for GstTensor { + fn fmt(&self, f: &mut ::std::fmt::Formatter) -> ::std::fmt::Result { + f.debug_struct(&format!("GstTensor @ {self:p}")) + .field("id", &self.id) + .field("layout", &self.layout) + .field("data_type", &self.data_type) + .field("batch_size", &self.batch_size) + .field("data", &self.data) + .field("dims_order", &self.dims_order) + .field("num_dims", &self.num_dims) + .field("dims", &unsafe { + ::std::slice::from_raw_parts(self.dims.as_ptr(), self.num_dims) + }) + .finish() + } +}