mirror of
https://gitlab.freedesktop.org/gstreamer/gstreamer-rs.git
synced 2025-09-01 01:13:48 +00:00
Merge branch 'batch-simplify' into 'main'
Draft: batchmeta: Remove Buffer structure See merge request gstreamer/gstreamer-rs!1777
This commit is contained in:
commit
1abf9bcad7
5 changed files with 55 additions and 169 deletions
|
@ -1 +1 @@
|
|||
Subproject commit a412eb7cb7fe816040ab15e590ace6e75e490968
|
||||
Subproject commit 4009b43abc52bc73cbe50f0018f6e1a303c05a9d
|
|
@ -88,41 +88,6 @@ impl AnalyticsBatchStream {
|
|||
self.0.index
|
||||
}
|
||||
|
||||
pub fn buffers(&self) -> &[AnalyticsBatchBuffer] {
|
||||
unsafe {
|
||||
if self.0.buffers.is_null() {
|
||||
&[]
|
||||
} else {
|
||||
slice::from_raw_parts(self.0.buffers as *const _, self.0.n_buffers)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
pub fn buffers_mut(&mut self) -> &mut [AnalyticsBatchBuffer] {
|
||||
unsafe {
|
||||
if self.0.buffers.is_null() {
|
||||
&mut []
|
||||
} else {
|
||||
slice::from_raw_parts_mut(self.0.buffers as *mut _, self.0.n_buffers)
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
impl fmt::Debug for AnalyticsBatchStream {
|
||||
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
|
||||
f.debug_struct("AnalyticsBatchStream")
|
||||
.field("index", &self.index())
|
||||
.field("buffers", &self.buffers())
|
||||
.finish()
|
||||
}
|
||||
}
|
||||
|
||||
#[repr(transparent)]
|
||||
#[doc(alias = "GstAnalyticsBatchBuffer")]
|
||||
pub struct AnalyticsBatchBuffer(ffi::GstAnalyticsBatchBuffer);
|
||||
|
||||
impl AnalyticsBatchBuffer {
|
||||
pub fn sticky_events(&self) -> &[gst::Event] {
|
||||
unsafe {
|
||||
if self.0.sticky_events.is_null() {
|
||||
|
@ -133,107 +98,58 @@ impl AnalyticsBatchBuffer {
|
|||
}
|
||||
}
|
||||
|
||||
pub fn serialized_events(&self) -> &[gst::Event] {
|
||||
pub fn sticky_events_mut(&mut self) -> &mut [gst::Event] {
|
||||
unsafe {
|
||||
if self.0.serialized_events.is_null() {
|
||||
if self.0.sticky_events.is_null() {
|
||||
&mut []
|
||||
} else {
|
||||
slice::from_raw_parts_mut(self.0.sticky_events as *mut _, self.0.n_sticky_events)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
pub fn objects(&self) -> &[gst::MiniObject] {
|
||||
unsafe {
|
||||
if self.0.objects.is_null() {
|
||||
&[]
|
||||
} else {
|
||||
slice::from_raw_parts(
|
||||
self.0.serialized_events as *const _,
|
||||
self.0.n_serialized_events,
|
||||
)
|
||||
slice::from_raw_parts(self.0.objects as *const _, self.0.n_objects)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
pub fn buffer(&self) -> Option<&gst::BufferRef> {
|
||||
pub fn objects_mut(&mut self) -> &mut [gst::MiniObject] {
|
||||
unsafe {
|
||||
if self.0.buffer.is_null() {
|
||||
None
|
||||
if self.0.objects.is_null() {
|
||||
&mut []
|
||||
} else {
|
||||
Some(gst::BufferRef::from_ptr(self.0.buffer))
|
||||
slice::from_raw_parts_mut(self.0.objects as *mut _, self.0.n_objects)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
pub fn buffer_owned(&self) -> Option<gst::Buffer> {
|
||||
unsafe {
|
||||
if self.0.buffer.is_null() {
|
||||
None
|
||||
} else {
|
||||
Some(gst::Buffer::from_glib_none(self.0.buffer))
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
pub fn buffer_mut(&mut self) -> Option<&mut gst::BufferRef> {
|
||||
unsafe {
|
||||
if self.0.serialized_events.is_null() {
|
||||
None
|
||||
} else {
|
||||
self.0.buffer = gst::ffi::gst_mini_object_make_writable(
|
||||
self.0.buffer as *mut gst::ffi::GstMiniObject,
|
||||
) as *mut gst::ffi::GstBuffer;
|
||||
Some(gst::BufferRef::from_mut_ptr(self.0.buffer))
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
pub fn buffer_list(&self) -> Option<&gst::BufferListRef> {
|
||||
unsafe {
|
||||
if self.0.buffer_list.is_null() {
|
||||
None
|
||||
} else {
|
||||
Some(gst::BufferListRef::from_ptr(self.0.buffer_list))
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
pub fn buffer_list_owned(&self) -> Option<gst::BufferList> {
|
||||
unsafe {
|
||||
if self.0.buffer_list.is_null() {
|
||||
None
|
||||
} else {
|
||||
Some(gst::BufferList::from_glib_none(self.0.buffer_list))
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
pub fn buffer_list_mut(&mut self) -> Option<&mut gst::BufferListRef> {
|
||||
unsafe {
|
||||
if self.0.serialized_events.is_null() {
|
||||
None
|
||||
} else {
|
||||
self.0.buffer_list = gst::ffi::gst_mini_object_make_writable(
|
||||
self.0.buffer_list as *mut gst::ffi::GstMiniObject,
|
||||
) as *mut gst::ffi::GstBufferList;
|
||||
Some(gst::BufferListRef::from_mut_ptr(self.0.buffer_list))
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
#[doc(alias = "gst_analytics_batch_buffer_get_caps")]
|
||||
#[doc(alias = "gst_analytics_batch_stream_get_caps")]
|
||||
pub fn caps(&self) -> Option<gst::Caps> {
|
||||
unsafe {
|
||||
from_glib_none(ffi::gst_analytics_batch_buffer_get_caps(mut_override(
|
||||
from_glib_none(ffi::gst_analytics_batch_stream_get_caps(mut_override(
|
||||
&self.0,
|
||||
)))
|
||||
}
|
||||
}
|
||||
|
||||
#[doc(alias = "gst_analytics_batch_buffer_get_segment")]
|
||||
#[doc(alias = "gst_analytics_batch_stream_get_segment")]
|
||||
pub fn segment(&self) -> Option<gst::Segment> {
|
||||
unsafe {
|
||||
from_glib_none(ffi::gst_analytics_batch_buffer_get_segment(mut_override(
|
||||
from_glib_none(ffi::gst_analytics_batch_stream_get_segment(mut_override(
|
||||
&self.0,
|
||||
)))
|
||||
}
|
||||
}
|
||||
|
||||
#[doc(alias = "gst_analytics_batch_buffer_get_stream_id")]
|
||||
#[doc(alias = "gst_analytics_batch_stream_get_stream_id")]
|
||||
pub fn stream_id(&self) -> Option<&glib::GStr> {
|
||||
unsafe {
|
||||
let res = ffi::gst_analytics_batch_buffer_get_stream_id(mut_override(&self.0));
|
||||
let res = ffi::gst_analytics_batch_stream_get_stream_id(mut_override(&self.0));
|
||||
|
||||
if res.is_null() {
|
||||
None
|
||||
|
@ -244,12 +160,11 @@ impl AnalyticsBatchBuffer {
|
|||
}
|
||||
}
|
||||
|
||||
impl fmt::Debug for AnalyticsBatchBuffer {
|
||||
impl fmt::Debug for AnalyticsBatchStream {
|
||||
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
|
||||
f.debug_struct("AnalyticsBatchBuffer")
|
||||
.field("sticky_events", &self.sticky_events())
|
||||
.field("serialized_events", &self.serialized_events())
|
||||
.field("buffer", &self.buffer())
|
||||
f.debug_struct("AnalyticsBatchStream")
|
||||
.field("index", &self.index())
|
||||
.field("objects", &self.objects())
|
||||
.finish()
|
||||
}
|
||||
}
|
||||
|
|
|
@ -104,31 +104,6 @@ pub const GST_ANALYTICS_REL_TYPE_N_TO_N: GstAnalyticsRelTypes = 16;
|
|||
pub const GST_ANALYTICS_REL_TYPE_ANY: GstAnalyticsRelTypes = 2147483647;
|
||||
|
||||
// Records
|
||||
#[derive(Copy, Clone)]
|
||||
#[repr(C)]
|
||||
pub struct GstAnalyticsBatchBuffer {
|
||||
pub sticky_events: *mut *mut gst::GstEvent,
|
||||
pub n_sticky_events: size_t,
|
||||
pub serialized_events: *mut *mut gst::GstEvent,
|
||||
pub n_serialized_events: size_t,
|
||||
pub buffer: *mut gst::GstBuffer,
|
||||
pub buffer_list: *mut gst::GstBufferList,
|
||||
pub padding: [gpointer; 4],
|
||||
}
|
||||
|
||||
impl ::std::fmt::Debug for GstAnalyticsBatchBuffer {
|
||||
fn fmt(&self, f: &mut ::std::fmt::Formatter) -> ::std::fmt::Result {
|
||||
f.debug_struct(&format!("GstAnalyticsBatchBuffer @ {self:p}"))
|
||||
.field("sticky_events", &self.sticky_events)
|
||||
.field("n_sticky_events", &self.n_sticky_events)
|
||||
.field("serialized_events", &self.serialized_events)
|
||||
.field("n_serialized_events", &self.n_serialized_events)
|
||||
.field("buffer", &self.buffer)
|
||||
.field("buffer_list", &self.buffer_list)
|
||||
.finish()
|
||||
}
|
||||
}
|
||||
|
||||
#[derive(Copy, Clone)]
|
||||
#[repr(C)]
|
||||
pub struct GstAnalyticsBatchMeta {
|
||||
|
@ -151,8 +126,10 @@ impl ::std::fmt::Debug for GstAnalyticsBatchMeta {
|
|||
#[repr(C)]
|
||||
pub struct GstAnalyticsBatchStream {
|
||||
pub index: c_uint,
|
||||
pub buffers: *mut GstAnalyticsBatchBuffer,
|
||||
pub n_buffers: size_t,
|
||||
pub sticky_events: *mut *mut gst::GstEvent,
|
||||
pub n_sticky_events: size_t,
|
||||
pub objects: *mut *mut gst::GstMiniObject,
|
||||
pub n_objects: size_t,
|
||||
pub padding: [gpointer; 4],
|
||||
}
|
||||
|
||||
|
@ -160,8 +137,10 @@ impl ::std::fmt::Debug for GstAnalyticsBatchStream {
|
|||
fn fmt(&self, f: &mut ::std::fmt::Formatter) -> ::std::fmt::Result {
|
||||
f.debug_struct(&format!("GstAnalyticsBatchStream @ {self:p}"))
|
||||
.field("index", &self.index)
|
||||
.field("buffers", &self.buffers)
|
||||
.field("n_buffers", &self.n_buffers)
|
||||
.field("sticky_events", &self.sticky_events)
|
||||
.field("n_sticky_events", &self.n_sticky_events)
|
||||
.field("objects", &self.objects)
|
||||
.field("n_objects", &self.n_objects)
|
||||
.finish()
|
||||
}
|
||||
}
|
||||
|
@ -318,25 +297,6 @@ impl ::std::fmt::Debug for GstTensorMeta {
|
|||
|
||||
extern "C" {
|
||||
|
||||
//=========================================================================
|
||||
// GstAnalyticsBatchBuffer
|
||||
//=========================================================================
|
||||
#[cfg(feature = "v1_28")]
|
||||
#[cfg_attr(docsrs, doc(cfg(feature = "v1_28")))]
|
||||
pub fn gst_analytics_batch_buffer_get_caps(
|
||||
buffer: *mut GstAnalyticsBatchBuffer,
|
||||
) -> *mut gst::GstCaps;
|
||||
#[cfg(feature = "v1_28")]
|
||||
#[cfg_attr(docsrs, doc(cfg(feature = "v1_28")))]
|
||||
pub fn gst_analytics_batch_buffer_get_segment(
|
||||
buffer: *mut GstAnalyticsBatchBuffer,
|
||||
) -> *const gst::GstSegment;
|
||||
#[cfg(feature = "v1_28")]
|
||||
#[cfg_attr(docsrs, doc(cfg(feature = "v1_28")))]
|
||||
pub fn gst_analytics_batch_buffer_get_stream_id(
|
||||
buffer: *mut GstAnalyticsBatchBuffer,
|
||||
) -> *const c_char;
|
||||
|
||||
//=========================================================================
|
||||
// GstAnalyticsBatchMeta
|
||||
//=========================================================================
|
||||
|
@ -344,6 +304,25 @@ extern "C" {
|
|||
#[cfg_attr(docsrs, doc(cfg(feature = "v1_28")))]
|
||||
pub fn gst_analytics_batch_meta_get_info() -> *const gst::GstMetaInfo;
|
||||
|
||||
//=========================================================================
|
||||
// GstAnalyticsBatchStream
|
||||
//=========================================================================
|
||||
#[cfg(feature = "v1_28")]
|
||||
#[cfg_attr(docsrs, doc(cfg(feature = "v1_28")))]
|
||||
pub fn gst_analytics_batch_stream_get_caps(
|
||||
stream: *mut GstAnalyticsBatchStream,
|
||||
) -> *mut gst::GstCaps;
|
||||
#[cfg(feature = "v1_28")]
|
||||
#[cfg_attr(docsrs, doc(cfg(feature = "v1_28")))]
|
||||
pub fn gst_analytics_batch_stream_get_segment(
|
||||
stream: *mut GstAnalyticsBatchStream,
|
||||
) -> *const gst::GstSegment;
|
||||
#[cfg(feature = "v1_28")]
|
||||
#[cfg_attr(docsrs, doc(cfg(feature = "v1_28")))]
|
||||
pub fn gst_analytics_batch_stream_get_stream_id(
|
||||
stream: *mut GstAnalyticsBatchStream,
|
||||
) -> *const c_char;
|
||||
|
||||
//=========================================================================
|
||||
// GstAnalyticsClsMtd
|
||||
//=========================================================================
|
||||
|
|
|
@ -202,13 +202,6 @@ fn get_c_output(name: &str) -> Result<String, Box<dyn Error>> {
|
|||
}
|
||||
|
||||
const RUST_LAYOUTS: &[(&str, Layout)] = &[
|
||||
(
|
||||
"GstAnalyticsBatchBuffer",
|
||||
Layout {
|
||||
size: size_of::<GstAnalyticsBatchBuffer>(),
|
||||
alignment: align_of::<GstAnalyticsBatchBuffer>(),
|
||||
},
|
||||
),
|
||||
(
|
||||
"GstAnalyticsBatchMeta",
|
||||
Layout {
|
||||
|
|
|
@ -8,7 +8,6 @@
|
|||
#include <stdio.h>
|
||||
|
||||
int main() {
|
||||
printf("%s;%zu;%zu\n", "GstAnalyticsBatchBuffer", sizeof(GstAnalyticsBatchBuffer), alignof(GstAnalyticsBatchBuffer));
|
||||
printf("%s;%zu;%zu\n", "GstAnalyticsBatchMeta", sizeof(GstAnalyticsBatchMeta), alignof(GstAnalyticsBatchMeta));
|
||||
printf("%s;%zu;%zu\n", "GstAnalyticsBatchStream", sizeof(GstAnalyticsBatchStream), alignof(GstAnalyticsBatchStream));
|
||||
printf("%s;%zu;%zu\n", "GstAnalyticsClsMtd", sizeof(GstAnalyticsClsMtd), alignof(GstAnalyticsClsMtd));
|
||||
|
|
Loading…
Reference in a new issue