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
// This file was generated by gir (https://github.com/gtk-rs/gir @ b5ea065)
// from gir-files (https://github.com/gtk-rs/gir-files @ ???)
// DO NOT EDIT

#![allow(non_camel_case_types, non_upper_case_globals, non_snake_case)]
#![cfg_attr(feature = "cargo-clippy", allow(approx_constant, type_complexity, unreadable_literal))]

extern crate libc;
extern crate glib_sys as glib;
extern crate gobject_sys as gobject;
extern crate gio_sys as gio;
extern crate gstreamer_sys as gst;

#[allow(unused_imports)]
use libc::{c_int, c_char, c_uchar, c_float, c_uint, c_double,
    c_short, c_ushort, c_long, c_ulong,
    c_void, size_t, ssize_t, intptr_t, uintptr_t, time_t, FILE};

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

// Constants
pub const GST_NET_TIME_PACKET_SIZE: c_int = 16;
pub const GST_PTP_CLOCK_ID_NONE: u64 = 18446744073709551615;
pub const GST_PTP_STATISTICS_BEST_MASTER_CLOCK_SELECTED: *const c_char = b"GstPtpStatisticsBestMasterClockSelected\0" as *const u8 as *const c_char;
pub const GST_PTP_STATISTICS_NEW_DOMAIN_FOUND: *const c_char = b"GstPtpStatisticsNewDomainFound\0" as *const u8 as *const c_char;
pub const GST_PTP_STATISTICS_PATH_DELAY_MEASURED: *const c_char = b"GstPtpStatisticsPathDelayMeasured\0" as *const u8 as *const c_char;
pub const GST_PTP_STATISTICS_TIME_UPDATED: *const c_char = b"GstPtpStatisticsTimeUpdated\0" as *const u8 as *const c_char;

// Callbacks
pub type GstPtpStatisticsCallback = Option<unsafe extern "C" fn(u8, *const gst::GstStructure, gpointer) -> gboolean>;

// Records
#[repr(C)]
#[derive(Copy, Clone)]
pub struct GstNetAddressMeta {
    pub meta: gst::GstMeta,
    pub addr: *mut gio::GSocketAddress,
}

impl ::std::fmt::Debug for GstNetAddressMeta {
    fn fmt(&self, f: &mut ::std::fmt::Formatter) -> ::std::fmt::Result {
        f.debug_struct(&format!("GstNetAddressMeta @ {:?}", self as *const _))
         .field("meta", &self.meta)
         .field("addr", &self.addr)
         .finish()
    }
}

#[repr(C)]
#[derive(Copy, Clone)]
pub struct GstNetClientClockClass {
    pub parent_class: gst::GstSystemClockClass,
    pub _gst_reserved: [gpointer; 4],
}

impl ::std::fmt::Debug for GstNetClientClockClass {
    fn fmt(&self, f: &mut ::std::fmt::Formatter) -> ::std::fmt::Result {
        f.debug_struct(&format!("GstNetClientClockClass @ {:?}", self as *const _))
         .field("parent_class", &self.parent_class)
         .finish()
    }
}

#[repr(C)]
pub struct GstNetClientClockPrivate(c_void);

impl ::std::fmt::Debug for GstNetClientClockPrivate {
    fn fmt(&self, f: &mut ::std::fmt::Formatter) -> ::std::fmt::Result {
        f.debug_struct(&format!("GstNetClientClockPrivate @ {:?}", self as *const _))
         .finish()
    }
}

#[repr(C)]
#[derive(Copy, Clone)]
pub struct GstNetControlMessageMeta {
    pub meta: gst::GstMeta,
    pub message: *mut gio::GSocketControlMessage,
}

impl ::std::fmt::Debug for GstNetControlMessageMeta {
    fn fmt(&self, f: &mut ::std::fmt::Formatter) -> ::std::fmt::Result {
        f.debug_struct(&format!("GstNetControlMessageMeta @ {:?}", self as *const _))
         .field("meta", &self.meta)
         .field("message", &self.message)
         .finish()
    }
}

#[repr(C)]
#[derive(Copy, Clone)]
pub struct GstNetTimePacket {
    pub local_time: gst::GstClockTime,
    pub remote_time: gst::GstClockTime,
}

impl ::std::fmt::Debug for GstNetTimePacket {
    fn fmt(&self, f: &mut ::std::fmt::Formatter) -> ::std::fmt::Result {
        f.debug_struct(&format!("GstNetTimePacket @ {:?}", self as *const _))
         .field("local_time", &self.local_time)
         .field("remote_time", &self.remote_time)
         .finish()
    }
}

#[repr(C)]
#[derive(Copy, Clone)]
pub struct GstNetTimeProviderClass {
    pub parent_class: gst::GstObjectClass,
    pub _gst_reserved: [gpointer; 4],
}

impl ::std::fmt::Debug for GstNetTimeProviderClass {
    fn fmt(&self, f: &mut ::std::fmt::Formatter) -> ::std::fmt::Result {
        f.debug_struct(&format!("GstNetTimeProviderClass @ {:?}", self as *const _))
         .field("parent_class", &self.parent_class)
         .field("_gst_reserved", &self._gst_reserved)
         .finish()
    }
}

#[repr(C)]
pub struct GstNetTimeProviderPrivate(c_void);

impl ::std::fmt::Debug for GstNetTimeProviderPrivate {
    fn fmt(&self, f: &mut ::std::fmt::Formatter) -> ::std::fmt::Result {
        f.debug_struct(&format!("GstNetTimeProviderPrivate @ {:?}", self as *const _))
         .finish()
    }
}

#[repr(C)]
#[derive(Copy, Clone)]
pub struct GstNtpClockClass {
    pub parent_class: gst::GstSystemClockClass,
    pub _gst_reserved: [gpointer; 4],
}

impl ::std::fmt::Debug for GstNtpClockClass {
    fn fmt(&self, f: &mut ::std::fmt::Formatter) -> ::std::fmt::Result {
        f.debug_struct(&format!("GstNtpClockClass @ {:?}", self as *const _))
         .field("parent_class", &self.parent_class)
         .finish()
    }
}

#[repr(C)]
#[derive(Copy, Clone)]
pub struct GstPtpClockClass {
    pub parent_class: gst::GstSystemClockClass,
    pub _gst_reserved: [gpointer; 4],
}

impl ::std::fmt::Debug for GstPtpClockClass {
    fn fmt(&self, f: &mut ::std::fmt::Formatter) -> ::std::fmt::Result {
        f.debug_struct(&format!("GstPtpClockClass @ {:?}", self as *const _))
         .field("parent_class", &self.parent_class)
         .finish()
    }
}

#[repr(C)]
pub struct GstPtpClockPrivate(c_void);

impl ::std::fmt::Debug for GstPtpClockPrivate {
    fn fmt(&self, f: &mut ::std::fmt::Formatter) -> ::std::fmt::Result {
        f.debug_struct(&format!("GstPtpClockPrivate @ {:?}", self as *const _))
         .finish()
    }
}

// Classes
#[repr(C)]
#[derive(Copy, Clone)]
pub struct GstNetClientClock {
    pub clock: gst::GstSystemClock,
    pub priv_: *mut GstNetClientClockPrivate,
    pub _gst_reserved: [gpointer; 4],
}

impl ::std::fmt::Debug for GstNetClientClock {
    fn fmt(&self, f: &mut ::std::fmt::Formatter) -> ::std::fmt::Result {
        f.debug_struct(&format!("GstNetClientClock @ {:?}", self as *const _))
         .field("clock", &self.clock)
         .finish()
    }
}

#[repr(C)]
#[derive(Copy, Clone)]
pub struct GstNetTimeProvider {
    pub parent: gst::GstObject,
    pub priv_: *mut GstNetTimeProviderPrivate,
    pub _gst_reserved: [gpointer; 4],
}

impl ::std::fmt::Debug for GstNetTimeProvider {
    fn fmt(&self, f: &mut ::std::fmt::Formatter) -> ::std::fmt::Result {
        f.debug_struct(&format!("GstNetTimeProvider @ {:?}", self as *const _))
         .field("parent", &self.parent)
         .finish()
    }
}

#[repr(C)]
#[derive(Copy, Clone)]
pub struct GstNtpClock {
    pub clock: gst::GstSystemClock,
    pub priv_: *mut GstNetClientClockPrivate,
    pub _gst_reserved: [gpointer; 4],
}

impl ::std::fmt::Debug for GstNtpClock {
    fn fmt(&self, f: &mut ::std::fmt::Formatter) -> ::std::fmt::Result {
        f.debug_struct(&format!("GstNtpClock @ {:?}", self as *const _))
         .field("clock", &self.clock)
         .finish()
    }
}

#[repr(C)]
#[derive(Copy, Clone)]
pub struct GstPtpClock {
    pub clock: gst::GstSystemClock,
    pub priv_: *mut GstPtpClockPrivate,
    pub _gst_reserved: [gpointer; 4],
}

impl ::std::fmt::Debug for GstPtpClock {
    fn fmt(&self, f: &mut ::std::fmt::Formatter) -> ::std::fmt::Result {
        f.debug_struct(&format!("GstPtpClock @ {:?}", self as *const _))
         .field("clock", &self.clock)
         .finish()
    }
}

extern "C" {

    //=========================================================================
    // GstNetAddressMeta
    //=========================================================================
    pub fn gst_net_address_meta_get_info() -> *const gst::GstMetaInfo;

    //=========================================================================
    // GstNetControlMessageMeta
    //=========================================================================
    pub fn gst_net_control_message_meta_get_info() -> *const gst::GstMetaInfo;

    //=========================================================================
    // GstNetTimePacket
    //=========================================================================
    pub fn gst_net_time_packet_get_type() -> GType;
    pub fn gst_net_time_packet_new(buffer: *const u8) -> *mut GstNetTimePacket;
    pub fn gst_net_time_packet_copy(packet: *const GstNetTimePacket) -> *mut GstNetTimePacket;
    pub fn gst_net_time_packet_free(packet: *mut GstNetTimePacket);
    pub fn gst_net_time_packet_send(packet: *const GstNetTimePacket, socket: *mut gio::GSocket, dest_address: *mut gio::GSocketAddress, error: *mut *mut glib::GError) -> gboolean;
    pub fn gst_net_time_packet_serialize(packet: *const GstNetTimePacket) -> *mut u8;
    pub fn gst_net_time_packet_receive(socket: *mut gio::GSocket, src_address: *mut *mut gio::GSocketAddress, error: *mut *mut glib::GError) -> *mut GstNetTimePacket;

    //=========================================================================
    // GstNetClientClock
    //=========================================================================
    pub fn gst_net_client_clock_get_type() -> GType;
    pub fn gst_net_client_clock_new(name: *const c_char, remote_address: *const c_char, remote_port: c_int, base_time: gst::GstClockTime) -> *mut gst::GstClock;

    //=========================================================================
    // GstNetTimeProvider
    //=========================================================================
    pub fn gst_net_time_provider_get_type() -> GType;
    pub fn gst_net_time_provider_new(clock: *mut gst::GstClock, address: *const c_char, port: c_int) -> *mut GstNetTimeProvider;

    //=========================================================================
    // GstNtpClock
    //=========================================================================
    pub fn gst_ntp_clock_get_type() -> GType;
    #[cfg(any(feature = "v1_6", feature = "dox"))]
    pub fn gst_ntp_clock_new(name: *const c_char, remote_address: *const c_char, remote_port: c_int, base_time: gst::GstClockTime) -> *mut gst::GstClock;

    //=========================================================================
    // GstPtpClock
    //=========================================================================
    pub fn gst_ptp_clock_get_type() -> GType;
    #[cfg(any(feature = "v1_6", feature = "dox"))]
    pub fn gst_ptp_clock_new(name: *const c_char, domain: c_uint) -> *mut gst::GstClock;

    //=========================================================================
    // Other functions
    //=========================================================================
    pub fn gst_buffer_add_net_address_meta(buffer: *mut gst::GstBuffer, addr: *mut gio::GSocketAddress) -> *mut GstNetAddressMeta;
    pub fn gst_buffer_add_net_control_message_meta(buffer: *mut gst::GstBuffer, message: *mut gio::GSocketControlMessage) -> *mut GstNetControlMessageMeta;
    pub fn gst_buffer_get_net_address_meta(buffer: *mut gst::GstBuffer) -> *mut GstNetAddressMeta;
    pub fn gst_net_address_meta_api_get_type() -> GType;
    pub fn gst_net_control_message_meta_api_get_type() -> GType;
    #[cfg(any(feature = "v1_6", feature = "dox"))]
    pub fn gst_ptp_deinit();
    #[cfg(any(feature = "v1_6", feature = "dox"))]
    pub fn gst_ptp_init(clock_id: u64, interfaces: *mut *mut c_char) -> gboolean;
    #[cfg(any(feature = "v1_6", feature = "dox"))]
    pub fn gst_ptp_is_initialized() -> gboolean;
    #[cfg(any(feature = "v1_6", feature = "dox"))]
    pub fn gst_ptp_is_supported() -> gboolean;
    #[cfg(any(feature = "v1_6", feature = "dox"))]
    pub fn gst_ptp_statistics_callback_add(callback: GstPtpStatisticsCallback, user_data: gpointer, destroy_data: glib::GDestroyNotify) -> c_ulong;
    #[cfg(any(feature = "v1_6", feature = "dox"))]
    pub fn gst_ptp_statistics_callback_remove(id: c_ulong);

}