1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
// This file was generated by gir (https://github.com/gtk-rs/gir)
// from gir-files (https://github.com/gtk-rs/gir-files)
// from gst-gir-files (https://gitlab.freedesktop.org/gstreamer/gir-files-rs.git)
// DO NOT EDIT

#![allow(non_camel_case_types, non_upper_case_globals, non_snake_case)]
#![allow(
    clippy::approx_constant,
    clippy::type_complexity,
    clippy::unreadable_literal,
    clippy::upper_case_acronyms
)]
#![cfg_attr(docsrs, feature(doc_cfg))]

use glib_sys as glib;
use gstreamer_sys as gst;

#[allow(unused_imports)]
use libc::{
    c_char, c_double, c_float, c_int, c_long, c_short, c_uchar, c_uint, c_ulong, c_ushort, c_void,
    intptr_t, off_t, size_t, ssize_t, time_t, uintptr_t, FILE,
};
#[cfg(unix)]
#[allow(unused_imports)]
use libc::{dev_t, gid_t, pid_t, socklen_t, uid_t};

#[allow(unused_imports)]
use glib::{gboolean, gconstpointer, gpointer, GType};

// Aliases
pub type GstAnalyticsMtdType = uintptr_t;

// Constants
pub const GST_INF_RELATION_SPAN: c_int = -1;
pub const GST_ANALYTICS_MTD_TYPE_ANY: c_int = 0;

// Flags
pub type GstAnalyticsRelTypes = c_uint;
pub const GST_ANALYTICS_REL_TYPE_NONE: GstAnalyticsRelTypes = 0;
pub const GST_ANALYTICS_REL_TYPE_IS_PART_OF: GstAnalyticsRelTypes = 2;
pub const GST_ANALYTICS_REL_TYPE_CONTAIN: GstAnalyticsRelTypes = 4;
pub const GST_ANALYTICS_REL_TYPE_RELATE_TO: GstAnalyticsRelTypes = 8;
pub const GST_ANALYTICS_REL_TYPE_LAST: GstAnalyticsRelTypes = 16;
pub const GST_ANALYTICS_REL_TYPE_ANY: GstAnalyticsRelTypes = 2147483647;

// Records
#[derive(Copy, Clone)]
#[repr(C)]
pub struct GstAnalyticsClsMtd {
    pub id: c_uint,
    pub meta: *mut GstAnalyticsRelationMeta,
}

impl ::std::fmt::Debug for GstAnalyticsClsMtd {
    fn fmt(&self, f: &mut ::std::fmt::Formatter) -> ::std::fmt::Result {
        f.debug_struct(&format!("GstAnalyticsClsMtd @ {self:p}"))
            .field("id", &self.id)
            .field("meta", &self.meta)
            .finish()
    }
}

#[derive(Copy, Clone)]
#[repr(C)]
pub struct GstAnalyticsMtd {
    pub id: c_uint,
    pub meta: *mut GstAnalyticsRelationMeta,
}

impl ::std::fmt::Debug for GstAnalyticsMtd {
    fn fmt(&self, f: &mut ::std::fmt::Formatter) -> ::std::fmt::Result {
        f.debug_struct(&format!("GstAnalyticsMtd @ {self:p}"))
            .field("id", &self.id)
            .field("meta", &self.meta)
            .finish()
    }
}

#[derive(Copy, Clone)]
#[repr(C)]
pub struct GstAnalyticsMtdImpl {
    pub name: *const c_char,
    pub mtd_meta_transform: Option<
        unsafe extern "C" fn(
            *mut gst::GstBuffer,
            *mut GstAnalyticsMtd,
            *mut gst::GstBuffer,
            glib::GQuark,
            gpointer,
        ) -> gboolean,
    >,
    pub _reserved: [gpointer; 20],
}

impl ::std::fmt::Debug for GstAnalyticsMtdImpl {
    fn fmt(&self, f: &mut ::std::fmt::Formatter) -> ::std::fmt::Result {
        f.debug_struct(&format!("GstAnalyticsMtdImpl @ {self:p}"))
            .field("name", &self.name)
            .field("mtd_meta_transform", &self.mtd_meta_transform)
            .finish()
    }
}

#[derive(Copy, Clone)]
#[repr(C)]
pub struct GstAnalyticsODMtd {
    pub id: c_uint,
    pub meta: *mut GstAnalyticsRelationMeta,
}

impl ::std::fmt::Debug for GstAnalyticsODMtd {
    fn fmt(&self, f: &mut ::std::fmt::Formatter) -> ::std::fmt::Result {
        f.debug_struct(&format!("GstAnalyticsODMtd @ {self:p}"))
            .field("id", &self.id)
            .field("meta", &self.meta)
            .finish()
    }
}

#[repr(C)]
pub struct _GstAnalyticsRelationMeta {
    _data: [u8; 0],
    _marker: core::marker::PhantomData<(*mut u8, core::marker::PhantomPinned)>,
}

pub type GstAnalyticsRelationMeta = _GstAnalyticsRelationMeta;

#[derive(Copy, Clone)]
#[repr(C)]
pub struct GstAnalyticsRelationMetaInitParams {
    pub initial_relation_order: size_t,
    pub initial_buf_size: size_t,
}

impl ::std::fmt::Debug for GstAnalyticsRelationMetaInitParams {
    fn fmt(&self, f: &mut ::std::fmt::Formatter) -> ::std::fmt::Result {
        f.debug_struct(&format!("GstAnalyticsRelationMetaInitParams @ {self:p}"))
            .field("initial_relation_order", &self.initial_relation_order)
            .field("initial_buf_size", &self.initial_buf_size)
            .finish()
    }
}

#[derive(Copy, Clone)]
#[repr(C)]
pub struct GstAnalyticsTrackingMtd {
    pub id: c_uint,
    pub meta: *mut GstAnalyticsRelationMeta,
}

impl ::std::fmt::Debug for GstAnalyticsTrackingMtd {
    fn fmt(&self, f: &mut ::std::fmt::Formatter) -> ::std::fmt::Result {
        f.debug_struct(&format!("GstAnalyticsTrackingMtd @ {self:p}"))
            .field("id", &self.id)
            .field("meta", &self.meta)
            .finish()
    }
}

#[link(name = "gstanalytics-1.0")]
extern "C" {

    //=========================================================================
    // GstAnalyticsClsMtd
    //=========================================================================
    pub fn gst_analytics_cls_mtd_get_index_by_quark(
        handle: *mut GstAnalyticsClsMtd,
        quark: glib::GQuark,
    ) -> c_int;
    pub fn gst_analytics_cls_mtd_get_length(handle: *mut GstAnalyticsClsMtd) -> size_t;
    pub fn gst_analytics_cls_mtd_get_level(
        handle: *mut GstAnalyticsClsMtd,
        index: size_t,
    ) -> c_float;
    pub fn gst_analytics_cls_mtd_get_quark(
        handle: *mut GstAnalyticsClsMtd,
        index: size_t,
    ) -> glib::GQuark;
    pub fn gst_analytics_cls_mtd_get_mtd_type() -> GstAnalyticsMtdType;

    //=========================================================================
    // GstAnalyticsMtd
    //=========================================================================
    pub fn gst_analytics_mtd_get_id(instance: *mut GstAnalyticsMtd) -> c_uint;
    pub fn gst_analytics_mtd_get_mtd_type(instance: *mut GstAnalyticsMtd) -> GstAnalyticsMtdType;
    pub fn gst_analytics_mtd_get_size(instance: *mut GstAnalyticsMtd) -> size_t;
    pub fn gst_analytics_mtd_type_get_name(type_: GstAnalyticsMtdType) -> *const c_char;

    //=========================================================================
    // GstAnalyticsODMtd
    //=========================================================================
    pub fn gst_analytics_od_mtd_get_confidence_lvl(
        instance: *mut GstAnalyticsODMtd,
        loc_conf_lvl: *mut c_float,
    ) -> gboolean;
    pub fn gst_analytics_od_mtd_get_location(
        instance: *mut GstAnalyticsODMtd,
        x: *mut c_int,
        y: *mut c_int,
        w: *mut c_int,
        h: *mut c_int,
        loc_conf_lvl: *mut c_float,
    ) -> gboolean;
    pub fn gst_analytics_od_mtd_get_obj_type(handle: *mut GstAnalyticsODMtd) -> glib::GQuark;
    pub fn gst_analytics_od_mtd_get_mtd_type() -> GstAnalyticsMtdType;

    //=========================================================================
    // GstAnalyticsRelationMeta
    //=========================================================================
    pub fn gst_analytics_relation_meta_add_cls_mtd(
        instance: *mut GstAnalyticsRelationMeta,
        length: size_t,
        confidence_levels: *mut c_float,
        class_quarks: *mut glib::GQuark,
        cls_mtd: *mut GstAnalyticsClsMtd,
    ) -> gboolean;
    pub fn gst_analytics_relation_meta_add_mtd(
        meta: *mut GstAnalyticsRelationMeta,
        impl_: *const GstAnalyticsMtdImpl,
        size: size_t,
        rlt_mtd: *mut GstAnalyticsMtd,
    ) -> gpointer;
    pub fn gst_analytics_relation_meta_add_od_mtd(
        instance: *mut GstAnalyticsRelationMeta,
        type_: glib::GQuark,
        x: c_int,
        y: c_int,
        w: c_int,
        h: c_int,
        loc_conf_lvl: c_float,
        od_mtd: *mut GstAnalyticsODMtd,
    ) -> gboolean;
    pub fn gst_analytics_relation_meta_add_one_cls_mtd(
        instance: *mut GstAnalyticsRelationMeta,
        confidence_level: c_float,
        class_quark: glib::GQuark,
        cls_mtd: *mut GstAnalyticsClsMtd,
    ) -> gboolean;
    pub fn gst_analytics_relation_meta_add_tracking_mtd(
        instance: *mut GstAnalyticsRelationMeta,
        tracking_id: u64,
        tracking_first_seen: gst::GstClockTime,
        trk_mtd: *mut GstAnalyticsTrackingMtd,
    ) -> gboolean;
    pub fn gst_analytics_relation_meta_exist(
        rmeta: *mut GstAnalyticsRelationMeta,
        an_meta_first_id: c_uint,
        an_meta_second_id: c_uint,
        max_relation_span: c_int,
        cond_types: GstAnalyticsRelTypes,
        relations_path: *mut *mut glib::GArray,
    ) -> gboolean;
    pub fn gst_analytics_relation_meta_get_cls_mtd(
        meta: *mut GstAnalyticsRelationMeta,
        an_meta_id: c_uint,
        rlt: *mut GstAnalyticsClsMtd,
    ) -> gboolean;
    pub fn gst_analytics_relation_meta_get_direct_related(
        meta: *mut GstAnalyticsRelationMeta,
        an_meta_id: c_uint,
        relation_type: GstAnalyticsRelTypes,
        type_: GstAnalyticsMtdType,
        state: *mut gpointer,
        rlt_mtd: *mut GstAnalyticsMtd,
    ) -> gboolean;
    pub fn gst_analytics_relation_meta_get_mtd(
        meta: *mut GstAnalyticsRelationMeta,
        an_meta_id: c_uint,
        type_: GstAnalyticsMtdType,
        rlt: *mut GstAnalyticsMtd,
    ) -> gboolean;
    pub fn gst_analytics_relation_meta_get_mtd_data(
        meta: *mut GstAnalyticsRelationMeta,
        an_meta_id: c_uint,
    ) -> gpointer;
    pub fn gst_analytics_relation_meta_get_od_mtd(
        meta: *mut GstAnalyticsRelationMeta,
        an_meta_id: c_uint,
        rlt: *mut GstAnalyticsODMtd,
    ) -> gboolean;
    pub fn gst_analytics_relation_meta_get_relation(
        meta: *mut GstAnalyticsRelationMeta,
        an_meta_first_id: c_uint,
        an_meta_second_id: c_uint,
    ) -> GstAnalyticsRelTypes;
    pub fn gst_analytics_relation_meta_get_tracking_mtd(
        meta: *mut GstAnalyticsRelationMeta,
        an_meta_id: c_uint,
        rlt: *mut GstAnalyticsTrackingMtd,
    ) -> gboolean;
    pub fn gst_analytics_relation_meta_iterate(
        meta: *mut GstAnalyticsRelationMeta,
        state: *mut gpointer,
        type_: GstAnalyticsMtdType,
        rlt_mtd: *mut GstAnalyticsMtd,
    ) -> gboolean;
    pub fn gst_analytics_relation_meta_set_relation(
        meta: *mut GstAnalyticsRelationMeta,
        type_: GstAnalyticsRelTypes,
        an_meta_first_id: c_uint,
        an_meta_second_id: c_uint,
    ) -> gboolean;
    pub fn gst_analytics_relation_meta_get_info() -> *const gst::GstMetaInfo;

    //=========================================================================
    // GstAnalyticsTrackingMtd
    //=========================================================================
    pub fn gst_analytics_tracking_mtd_get_info(
        instance: *mut GstAnalyticsTrackingMtd,
        tracking_id: *mut u64,
        tracking_first_seen: *mut gst::GstClockTime,
        tracking_last_seen: *mut gst::GstClockTime,
        tracking_lost: *mut gboolean,
    ) -> gboolean;
    pub fn gst_analytics_tracking_mtd_set_lost(instance: *mut GstAnalyticsTrackingMtd) -> gboolean;
    pub fn gst_analytics_tracking_mtd_update_last_seen(
        instance: *mut GstAnalyticsTrackingMtd,
        last_seen: gst::GstClockTime,
    ) -> gboolean;
    pub fn gst_analytics_tracking_mtd_get_mtd_type() -> GstAnalyticsMtdType;

    //=========================================================================
    // Other functions
    //=========================================================================
    pub fn gst_buffer_add_analytics_relation_meta(
        buffer: *mut gst::GstBuffer,
    ) -> *mut GstAnalyticsRelationMeta;
    pub fn gst_buffer_add_analytics_relation_meta_full(
        buffer: *mut gst::GstBuffer,
        init_params: *mut GstAnalyticsRelationMetaInitParams,
    ) -> *mut GstAnalyticsRelationMeta;
    pub fn gst_buffer_get_analytics_relation_meta(
        buffer: *mut gst::GstBuffer,
    ) -> *mut GstAnalyticsRelationMeta;
    pub fn gst_analytics_relation_get_length(instance: *mut GstAnalyticsRelationMeta) -> size_t;
    pub fn gst_analytics_relation_meta_api_get_type() -> GType;

}