mirror of
https://gitlab.freedesktop.org/gstreamer/gstreamer-rs.git
synced 2024-11-22 01:21:05 +00:00
analytics: Manually implement FFI GstTensor because of flexible array member
Part-of: <https://gitlab.freedesktop.org/gstreamer/gstreamer-rs/-/merge_requests/1591>
This commit is contained in:
parent
44006bc4f1
commit
8ba700301d
3 changed files with 41 additions and 28 deletions
|
@ -50,3 +50,7 @@ boxed_inline = true
|
||||||
name = "GstAnalytics.Mtd"
|
name = "GstAnalytics.Mtd"
|
||||||
status = "generate"
|
status = "generate"
|
||||||
boxed_inline = true
|
boxed_inline = true
|
||||||
|
|
||||||
|
[[object]]
|
||||||
|
name = "GstAnalytics.Tensor"
|
||||||
|
status = "manual"
|
||||||
|
|
|
@ -15,6 +15,10 @@
|
||||||
use glib_sys as glib;
|
use glib_sys as glib;
|
||||||
use gstreamer_sys as gst;
|
use gstreamer_sys as gst;
|
||||||
|
|
||||||
|
mod manual;
|
||||||
|
|
||||||
|
pub use manual::*;
|
||||||
|
|
||||||
#[cfg(unix)]
|
#[cfg(unix)]
|
||||||
#[allow(unused_imports)]
|
#[allow(unused_imports)]
|
||||||
use libc::{dev_t, gid_t, pid_t, socklen_t, uid_t};
|
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)]
|
#[derive(Copy, Clone)]
|
||||||
#[repr(C)]
|
#[repr(C)]
|
||||||
pub struct GstTensorDim {
|
pub struct GstTensorDim {
|
||||||
|
|
33
gstreamer-analytics/sys/src/manual.rs
Normal file
33
gstreamer-analytics/sys/src/manual.rs
Normal file
|
@ -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()
|
||||||
|
}
|
||||||
|
}
|
Loading…
Reference in a new issue