From 57c58f255e87af38952d059aac0ae9009d6681d0 Mon Sep 17 00:00:00 2001 From: Alexey Galakhov Date: Tue, 9 Jun 2020 00:11:08 +0200 Subject: [PATCH] Add generation files for gstreamer-controller-sys --- .gitlab-ci.yml | 3 +- Cargo.toml | 1 + Gir_GstController.toml | 25 + gir-files/GstController-1.0.gir | 1075 +++++++++++++++++++++ gstreamer-controller-sys/CHANGELOG.md | 181 ++++ gstreamer-controller-sys/Cargo.toml | 63 ++ gstreamer-controller-sys/README.md | 33 + gstreamer-controller-sys/build.rs | 24 + gstreamer-controller-sys/src/lib.rs | 555 +++++++++++ gstreamer-controller-sys/tests/abi.rs | 386 ++++++++ gstreamer-controller-sys/tests/constant.c | 27 + gstreamer-controller-sys/tests/layout.c | 12 + gstreamer-controller-sys/tests/manual.h | 3 + 13 files changed, 2387 insertions(+), 1 deletion(-) create mode 100644 Gir_GstController.toml create mode 100644 gir-files/GstController-1.0.gir create mode 100644 gstreamer-controller-sys/CHANGELOG.md create mode 100644 gstreamer-controller-sys/Cargo.toml create mode 100644 gstreamer-controller-sys/README.md create mode 100644 gstreamer-controller-sys/build.rs create mode 100644 gstreamer-controller-sys/src/lib.rs create mode 100644 gstreamer-controller-sys/tests/abi.rs create mode 100644 gstreamer-controller-sys/tests/constant.c create mode 100644 gstreamer-controller-sys/tests/layout.c create mode 100644 gstreamer-controller-sys/tests/manual.h diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml index 381dc4fae..83992e814 100644 --- a/.gitlab-ci.yml +++ b/.gitlab-ci.yml @@ -73,7 +73,8 @@ stages: gstreamer-sys \ gstreamer-tag-sys \ gstreamer-video-sys \ - gstreamer-webrtc-sys; \ + gstreamer-webrtc-sys \ + gstreamer-controller-sys; \ do \ cargo test --locked -p $crate; \ done diff --git a/Cargo.toml b/Cargo.toml index e846c9918..43286d90e 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -19,4 +19,5 @@ members = [ "gstreamer-editing-services-sys", "gstreamer-check-sys", "gstreamer-rtp-sys", + "gstreamer-controller-sys", ] diff --git a/Gir_GstController.toml b/Gir_GstController.toml new file mode 100644 index 000000000..7689ecfdf --- /dev/null +++ b/Gir_GstController.toml @@ -0,0 +1,25 @@ +[options] +girs_dir = "gir-files" +library = "GstController" +version = "1.0" +min_cfg_version = "1.8" +target_path = "gstreamer-controller-sys" +work_mode = "sys" + +external_libraries = [ + "GLib", + "GObject", +] + +extra_versions = [ + "1.18", + "1.16", + "1.14", + "1.12", + "1.10", + "1.8", +] + +[external_libraries] +gstreamer="Gst" +gstreamer_base="GstBase" diff --git a/gir-files/GstController-1.0.gir b/gir-files/GstController-1.0.gir new file mode 100644 index 000000000..bd8460f3a --- /dev/null +++ b/gir-files/GstController-1.0.gir @@ -0,0 +1,1075 @@ + + + + + + + + + + + + A value mapping object that attaches multiple control sources to a guint +gobject properties representing a color. A control value of 0.0 will turn the +color component off and a value of 1.0 will be the color level. + + + Create a new control-binding that attaches the given #GstControlSource to the +#GObject property. + + + the new #GstARGBControlBinding + + + + + the object of the property + + + + the property-name to attach the control source + + + + the control source for the alpha channel + + + + the control source for the red channel + + + + the control source for the green channel + + + + the control source for the blue channel + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + The class structure of #GstARGBControlBinding. + + + Parent class + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + An internal structure for value+time and various temporary +values used for interpolation. This "inherits" from +GstTimedValue. + + + timestamp of the value change + + + + the new value + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + Copies a #GstControlPoint + + + A copy of @cp + + + + + The control point to copy + + + + + + Frees all data allocated by a #GstControlPoint instance. + + + + + + + the object to free + + + + + + + + + + + + + + + + + + + + + + + + + + + + A value mapping object that attaches control sources to gobject properties. It +will map the control values directly to the target property range. If a +non-absolute direct control binding is used, the value range [0.0 ... 1.0] +is mapped to full target property range, and all values outside the range +will be clipped. An absolute control binding will not do any value +transformations. + + + Create a new control-binding that attaches the #GstControlSource to the +#GObject property. It will map the control source range [0.0 ... 1.0] to +the full target property range, and clip all values outside this range. + + + the new #GstDirectControlBinding + + + + + the object of the property + + + + the property-name to attach the control source + + + + the control source + + + + + + Create a new control-binding that attaches the #GstControlSource to the +#GObject property. It will directly map the control source values to the +target property range without any transformations. + + + the new #GstDirectControlBinding + + + + + the object of the property + + + + the property-name to attach the control source + + + + the control source + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + The class structure of #GstDirectControlBinding. + + + Parent class + + + + + + + + + + Function to map a control-value to the target GValue. + + + + + + + the #GstDirectControlBinding instance + + + + the value returned by the cotnrol source + + + + the target GValue + + + + + + Function to map a control-value to the target plain data type. + + + + + + + the #GstDirectControlBinding instance + + + + the value returned by the cotnrol source + + + + the target location + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + #GstInterpolationControlSource is a #GstControlSource, that interpolates values between user-given +control points. It supports several interpolation modes and property types. + +To use #GstInterpolationControlSource get a new instance by calling +gst_interpolation_control_source_new(), bind it to a #GParamSpec and set some +control points by calling gst_timed_value_control_source_set(). + +All functions are MT-safe. + + + This returns a new, unbound #GstInterpolationControlSource. + + + a new, unbound #GstInterpolationControlSource. + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + The various interpolation modes available. + + steps-like interpolation, default + + + linear interpolation + + + cubic interpolation (natural), may overshoot + the min or max values set by the control point, but is more 'curvy' + + + monotonic cubic interpolation, will not + produce any values outside of the min-max range set by the control points + (Since: 1.8) + + + + #GstLFOControlSource is a #GstControlSource, that provides several periodic +waveforms as control values. + +To use #GstLFOControlSource get a new instance by calling +gst_lfo_control_source_new(), bind it to a #GParamSpec and set the relevant +properties. + +All functions are MT-safe. + + + This returns a new, unbound #GstLFOControlSource. + + + a new, unbound #GstLFOControlSource. + + + + + Specifies the amplitude for the waveform of this #GstLFOControlSource. + + + + Specifies the frequency that should be used for the waveform +of this #GstLFOControlSource. It should be large enough +so that the period is longer than one nanosecond. + + + + Specifies the value offset for the waveform of this #GstLFOControlSource. + + + + Specifies the timeshift to the right that should be used for the waveform +of this #GstLFOControlSource in nanoseconds. + +To get a n nanosecond shift to the left use +"(GST_SECOND / frequency) - n". + + + + Specifies the waveform that should be used for this #GstLFOControlSource. + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + The various waveform modes available. + + sine waveform + + + square waveform + + + saw waveform + + + reverse saw waveform + + + triangle waveform + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + A #GstControlBinding that forwards requests to another #GstControlBinding + + + #GstProxyControlBinding forwards all access to data or `sync_values()` +requests from @property_name on @object to the control binding at +@ref_property_name on @ref_object. + + + a new #GstControlBinding that proxies the control interface between +properties on different #GstObject's + + + + + a #GstObject + + + + the property name in @object to control + + + + a #GstObject to forward all + #GstControlBinding requests to + + + + the property_name in @ref_object to control + + + + + + + + + + + + + + + + + + + + + Opaque #GstProxyControlBindingClass struct + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + Base class for #GstControlSource that use time-stamped values. + +When overriding bind, chain up first to give this bind implementation a +chance to setup things. + +All functions are MT-safe. + + + Find last value before given timestamp in control point list. +If all values in the control point list come after the given +timestamp or no values exist, %NULL is returned. + +For use in control source implementations. + + + the found #GSequenceIter or %NULL + + + + + the control source to search in + + + + the search key + + + + + + Returns a read-only copy of the list of #GstTimedValue for the given property. +Free the list after done with it. + + + a copy +of the list, or %NULL if the property isn't handled by the controller + + + + + + + the #GstTimedValueControlSource to get the list from + + + + + + Get the number of control points that are set. + + + the number of control points that are set. + + + + + the #GstTimedValueControlSource to get the number of values from + + + + + + Set the value of given controller-handled property at a certain time. + + + FALSE if the values couldn't be set, TRUE otherwise. + + + + + the #GstTimedValueControlSource object + + + + the time the control-change is scheduled for + + + + the control-value + + + + + + Sets multiple timed values at once. + + + FALSE if the values couldn't be set, TRUE otherwise. + + + + + the #GstTimedValueControlSource object + + + + a list +with #GstTimedValue items + + + + + + + + Used to remove the value of given controller-handled property at a certain +time. + + + FALSE if the value couldn't be unset (i.e. not found, TRUE otherwise. + + + + + the #GstTimedValueControlSource object + + + + the time the control-change should be removed from + + + + + + Used to remove all time-stamped values of given controller-handled property + + + + + + + the #GstTimedValueControlSource object + + + + + + + + + + + + + + + + + + + + + + + + + + + + + Emitted right after the new value has been added to @self + + + + + + The newly added #GstTimedValue + + + + + + Emitted right after the new value has been set on @timed_signals + + + + + + The #GstTimedValue where the value changed + + + + + + Emitted when @timed_value is removed from @self + + + + + + The removed #GstTimedValue + + + + + + + + + + + + + + + + + + + + + #GstTriggerControlSource is a #GstControlSource, that returns values from user-given +control points. It allows for a tolerance on the time-stamps. + +To use #GstTriggerControlSource get a new instance by calling +gst_trigger_control_source_new(), bind it to a #GParamSpec and set some +control points by calling gst_timed_value_control_source_set(). + +All functions are MT-safe. + + + This returns a new, unbound #GstTriggerControlSource. + + + a new, unbound #GstTriggerControlSource. + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + Reset the controlled value cache. + + + + + + + the #GstTimedValueControlSource + + + + + + diff --git a/gstreamer-controller-sys/CHANGELOG.md b/gstreamer-controller-sys/CHANGELOG.md new file mode 100644 index 000000000..ca04a635e --- /dev/null +++ b/gstreamer-controller-sys/CHANGELOG.md @@ -0,0 +1,181 @@ +# Changelog +All notable changes to this project will be documented in this file. + +The format is based on [Keep a Changelog](http://keepachangelog.com/en/1.0.0/) +and this project adheres to [Semantic Versioning](http://semver.org/spec/v2.0.0.html), +specifically the [variant used by Rust](http://doc.crates.io/manifest.html#the-version-field). + +## [0.9.1] - 2020-09-08 +### Changed +- Updated bindings to 1.18.0. This stabilized GStreamer 1.18 support and any + API behind the "v1_18" feature is considered stable now. + +## [0.9.0] - 2020-07-05 +### Added +- Updated bindings to 1.17.2, adding experimental 1.18 support. This can be + opted-in via the "v1_18" feature flag but there might still be API changes + in the newly added API. + +### Changed +- Minimum supported GStreamer version is 1.8 now. +- The `system-deps` crate is now used for declaring the dependency on the C + libraries instead of directly using `pkg-config`. + +### Fixed +- Various missing version markers were added, which should allow compilation + against GStreamer 1.8 on Windows again. On Windows missing symbols are + apparently an error even if they're not used. +- `AUDIO/VIDEO_FORMATS_ALL` are ignored now as they're endian-dependent. + +## [0.8.1] - 2019-12-16 +### Added +- GStreamer RTP bindings + +### Changed +- Update minimum supported Rust version to 1.36 +- Update introspection data to GStreamer 1.16.2 release + +## [0.8.0] - 2019-06-24 +### Added +- GstGLDisplayX11 and GstGLDisplayWayland were added to gstreamer-gl-sys in + addition to GstGLDisplayEGL that existed before + +### Changed +- Updated to GStreamer 1.16.0 .gir files, plus backported fixes +- Updated to latest gir +- Run all code through rustfmt after code generation + +## [0.7.0] - 2019-02-22 +### Added +- GstGL (OpenGL/GLES) bindings + +### Changed +- Switch to Rust 1.31 as minimum supported version +- Generate GstVideoOverlayFormatFlags as flags type instead of enum +- Updates GstMpegts with various annotation fixes from GStreamer git master + +## [0.6.1] - 2018-11-10 +### Added +- GstCheck and GES (gstreamer editing services) bindings + +### Changed +- Updated .gir files to 1.14.4 release +- All references were updated from GitHub to freedesktop.org GitLab +- Various functions take \*const instead of \*mut as parameters now + +### Fixed +- Various functions and structs having pointer-of-array parameters/fields have + now fixed types. They were previously flat arrays instead of + pointer-of-arrays. +- Set gstreamer-webrtc-sys minimum version to 1.14. It did not exist before + that + +## [0.6.0] - 2018-09-08 +### Changed +- Updated everything to GStreamer 1.14.2 +- Various fixes to how the code generator is used +- Regenerate with latest GIR code generator + +### Fixed +- WebRTCICETransport and WebRTCDTLSTransport have the correct parent class + struct +- gstreamer-webrtc-sys correctly depends/links to gstreamer-sys +- Removed unneeded dependencies from the code generator configuration files + +## [0.5.0] - 2018-03-20 +### Changed +- Updated everything to GStreamer 1.14.0 + +### Added +- GstSdp, GstRtsp, GstRtspServer and GstWebRTC bindings + +### Fixed +- Use external_libraries feature of gir to require less manual editing +- Remove some unused crates from dependencies +- Disale print_system_libs in calls to pkg-config to work better with + non-system installs of GStreamer + +## [0.4.1] - 2018-02-18 +### Fixed +- Fix native library name of GstNet bindings + +## [0.4.0] - 2017-12-23 +### Added +- GstNet bindings +- Debug impls for basically every type +- Script to automatically regenerate everything + +### Changed +- gst_player_[sg]et_multiview_mode() argument types were changed from + GstMultiviewMode to GstMultiviewFramePacking, which is the correct subset + of the former that is allowed here +- gst_plugin_add_dependency() takes *mut *mut c_char as argument type instead + of *mut *const c_char + +## [0.3.0] - 2017-11-26 +### Added +- GstMpegTs bindings + +### Changed +- GstDebugColorFlags from an enum to a bitfield +- Updated to bitflags 1.0 +- Added support for the "dox" feature to generate documentation for all + possible versions +- Depend on glib-sys/gobject-sys 0.5 + +### Fixes +- GstStackTraceFlags, gst_flow_combiner_ref/unref are only available since + 1.12 and 1.12.1 respectively +- All C enums are represented as integers + constants now to prevent undefined + behaviour when out-of-range values are received + +## [0.2.1] - 2017-09-10 +### Changed +- Add README.md to all crates directly + +### Fixed +- Fix various compiler warnings +- Fix versioning/feature mess. Now each library has features for all major + versions and for the correct minor versions that added API. +- Removed Cargo.lock from GIT + +## [0.2.0] - 2017-08-28 +### Added +- Add GstPlayer bindings + +### Changed +- Depend on bitflags 0.9 +- Update GIR files to 1.12.1 release +- Fix various errors in the GIR files, backported from GStreamer GIT master +- Depend on gobject-sys/glib-sys 0.4.0 for various improvements +- Regenerated everything with latest GIR + +## [0.1.1] - 2017-05-10 +### Added +- Add GstTag and GstApp bindings +- Add lots of missing fields to all the structs thanks to GIR improvements + +### Changed +- Update GIR files to 1.12.0 release +- Depend on gobject-sys/glib-sys 0.3.4 release for more complete structs +- Regenerated everything with latest GIR + +## 0.1.0 - 2017-04-09 + +- Initial release of the autogenerated GStreamer FFI bindings. + +[Unreleased]: https://gitlab.freedesktop.org/gstreamer/gstreamer-rs-sys/compare/0.9.1...HEAD +[0.9.1]: https://gitlab.freedesktop.org/gstreamer/gstreamer-rs-sys/compare/0.9.0...0.9.1 +[0.9.0]: https://gitlab.freedesktop.org/gstreamer/gstreamer-rs-sys/compare/0.8.1...0.9.0 +[0.8.1]: https://gitlab.freedesktop.org/gstreamer/gstreamer-rs-sys/compare/0.8.0...0.8.1 +[0.8.0]: https://gitlab.freedesktop.org/gstreamer/gstreamer-rs-sys/compare/0.7.0...0.8.0 +[0.7.0]: https://gitlab.freedesktop.org/gstreamer/gstreamer-rs-sys/compare/0.6.1...0.7.0 +[0.6.1]: https://gitlab.freedesktop.org/gstreamer/gstreamer-rs-sys/compare/0.6.0...0.6.1 +[0.6.0]: https://gitlab.freedesktop.org/gstreamer/gstreamer-rs-sys/compare/0.5.0...0.6.0 +[0.5.0]: https://gitlab.freedesktop.org/gstreamer/gstreamer-rs-sys/compare/0.4.1...0.5.0 +[0.4.1]: https://gitlab.freedesktop.org/gstreamer/gstreamer-rs-sys/compare/0.4.0...0.4.1 +[0.4.0]: https://gitlab.freedesktop.org/gstreamer/gstreamer-rs-sys/compare/0.3.0...0.4.0 +[0.3.0]: https://gitlab.freedesktop.org/gstreamer/gstreamer-rs-sys/compare/0.2.1...0.3.0 +[0.2.1]: https://gitlab.freedesktop.org/gstreamer/gstreamer-rs-sys/compare/0.2.0...0.2.1 +[0.2.0]: https://gitlab.freedesktop.org/gstreamer/gstreamer-rs-sys/compare/0.1.1...0.2.0 +[0.1.1]: https://gitlab.freedesktop.org/gstreamer/gstreamer-rs-sys/compare/0.1.0...0.1.1 diff --git a/gstreamer-controller-sys/Cargo.toml b/gstreamer-controller-sys/Cargo.toml new file mode 100644 index 000000000..8037ac3d9 --- /dev/null +++ b/gstreamer-controller-sys/Cargo.toml @@ -0,0 +1,63 @@ +[build-dependencies] +pkg-config = "0.3.7" +system-deps = "1.3" + +[dependencies] +libc = "0.2" + +[dependencies.glib-sys] +git = "https://github.com/gtk-rs/sys" + +[dependencies.gobject-sys] +git = "https://github.com/gtk-rs/sys" + +[dependencies.gstreamer-base-sys] +path = "../gstreamer-base-sys" + +[dependencies.gstreamer-sys] +path = "../gstreamer-sys" + +[dev-dependencies] +shell-words = "0.1.0" +tempfile = "3" + +[features] +v1_2 = [] +v1_4 = ["v1_2"] +v1_6 = ["v1_4"] +v1_8 = [] +v1_10 = ["v1_8"] +v1_12 = ["v1_10"] +v1_14 = ["v1_12"] +v1_16 = ["v1_14"] +v1_18 = ["v1_16"] +dox = [] + +[lib] +name = "gstreamer_controller_sys" + +[package] +authors = ["Alexey Galakhov "] +build = "build.rs" +description = "FFI bindings to libgstcontroller-1.0" +documentation = "https://slomo.pages.freedesktop.org/rustdocs/gstreamer-sys/gstreamer_app_sys/" +homepage = "https://gstreamer.freedesktop.org" +keywords = ["ffi", "gstreamer", "gnome", "multimedia"] +license = "MIT" +links = "gstcontroller-1.0" +name = "gstreamer-controller-sys" +readme = "README.md" +repository = "https://gitlab.freedesktop.org/gstreamer/gstreamer-rs-sys" +version = "0.10.0" +[package.metadata.docs.rs] +features = ["dox"] +[package.metadata.system-deps.gstreamer_controller_1_0] +name = "gstreamer-controller-1.0" +version = "1.8" + +[package.metadata.system-deps.gstreamer_controller_1_0.feature-versions] +v1_10 = "1.10" +v1_12 = "1.12" +v1_14 = "1.14" +v1_16 = "1.16" +v1_18 = "1.18" diff --git a/gstreamer-controller-sys/README.md b/gstreamer-controller-sys/README.md new file mode 100644 index 000000000..45e2e7977 --- /dev/null +++ b/gstreamer-controller-sys/README.md @@ -0,0 +1,33 @@ +# NOTE: The canonical repository for gstreamer-sys has moved to [freedesktop.org GitLab](https://gitlab.freedesktop.org/gstreamer/gstreamer-rs-sys)! + +# gstreamer-sys [![crates.io](https://img.shields.io/crates/v/gstreamer-audio-sys.svg)](https://crates.io/crates/gstreamer-audio-sys) [![pipeline status](https://gitlab.freedesktop.org/gstreamer/gstreamer-rs-sys/badges/master/pipeline.svg)](https://gitlab.freedesktop.org/gstreamer/gstreamer-rs-sys/commits/master) + +[GStreamer](https://gstreamer.freedesktop.org/) (Audio library) FFI bindings for Rust. + +These bindings are providing unsafe FFI API that can be used to interface with +GStreamer. Generally they are meant to be used as the building block for +higher-level abstractions like: + + * Bindings for GStreamer applications and plugins: https://gitlab.freedesktop.org/gstreamer/gstreamer-rs + * Various GStreamer plugins written in Rust: https://gitlab.freedesktop.org/gstreamer/gst-plugins-rs + +The bindings are autogenerated with [gir](https://github.com/gtk-rs/gir/) +based on the [GObject-Introspection](https://wiki.gnome.org/Projects/GObjectIntrospection/) +API metadata provided by the GStreamer project. + +## LICENSE + +gstreamer-sys and all crates contained here are licensed under the MIT +license ([LICENSE](LICENSE) or http://opensource.org/licenses/MIT). + +GStreamer itself is licensed under the Lesser General Public License version +2.1 or (at your option) any later version: +https://www.gnu.org/licenses/lgpl-2.1.html + +## Contribution + +Any kinds of contributions are welcome as a pull request. + +Unless you explicitly state otherwise, any contribution intentionally submitted +for inclusion in gstreamer-rs by you shall be licensed under the MIT license as above, +without any additional terms or conditions. diff --git a/gstreamer-controller-sys/build.rs b/gstreamer-controller-sys/build.rs new file mode 100644 index 000000000..9bc1bf9be --- /dev/null +++ b/gstreamer-controller-sys/build.rs @@ -0,0 +1,24 @@ +// This file was generated by gir (https://github.com/gtk-rs/gir @ 60cbef0) +// from gir-files (https://github.com/gtk-rs/gir-files @ 91e1ef0) +// DO NOT EDIT + +#[cfg(not(feature = "dox"))] +extern crate system_deps; + +#[cfg(not(feature = "dox"))] +use std::io; +#[cfg(not(feature = "dox"))] +use std::io::prelude::*; +#[cfg(not(feature = "dox"))] +use std::process; + +#[cfg(feature = "dox")] +fn main() {} // prevent linking libraries to avoid documentation failure + +#[cfg(not(feature = "dox"))] +fn main() { + if let Err(s) = system_deps::Config::new().probe() { + let _ = eprintln!("{}", s); + process::exit(1); + } +} diff --git a/gstreamer-controller-sys/src/lib.rs b/gstreamer-controller-sys/src/lib.rs new file mode 100644 index 000000000..1a0bfb9fa --- /dev/null +++ b/gstreamer-controller-sys/src/lib.rs @@ -0,0 +1,555 @@ +// This file was generated by gir (https://github.com/gtk-rs/gir @ 60cbef0) +// from gir-files (https://github.com/gtk-rs/gir-files @ 91e1ef0) +// 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 +)] + +extern crate glib_sys as glib; +extern crate gobject_sys as gobject; +extern crate gstreamer_base_sys as gst_base; +extern crate gstreamer_sys as gst; +extern crate libc; + +#[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, size_t, ssize_t, time_t, uintptr_t, FILE, +}; + +#[allow(unused_imports)] +use glib::{gboolean, gconstpointer, gpointer, GType}; + +// Enums +pub type GstInterpolationMode = c_int; +pub const GST_INTERPOLATION_MODE_NONE: GstInterpolationMode = 0; +pub const GST_INTERPOLATION_MODE_LINEAR: GstInterpolationMode = 1; +pub const GST_INTERPOLATION_MODE_CUBIC: GstInterpolationMode = 2; +pub const GST_INTERPOLATION_MODE_CUBIC_MONOTONIC: GstInterpolationMode = 3; + +pub type GstLFOWaveform = c_int; +pub const GST_LFO_WAVEFORM_SINE: GstLFOWaveform = 0; +pub const GST_LFO_WAVEFORM_SQUARE: GstLFOWaveform = 1; +pub const GST_LFO_WAVEFORM_SAW: GstLFOWaveform = 2; +pub const GST_LFO_WAVEFORM_REVERSE_SAW: GstLFOWaveform = 3; +pub const GST_LFO_WAVEFORM_TRIANGLE: GstLFOWaveform = 4; + +// Unions +#[repr(C)] +#[derive(Copy, Clone)] +pub union GstControlPoint_cache { + pub cubic: GstControlPoint_cache_cubic, + pub cubic_monotonic: GstControlPoint_cache_cubic_monotonic, + pub _gst_reserved: [u8; 64], +} + +impl ::std::fmt::Debug for GstControlPoint_cache { + fn fmt(&self, f: &mut ::std::fmt::Formatter) -> ::std::fmt::Result { + f.debug_struct(&format!("GstControlPoint_cache @ {:?}", self as *const _)) + .field("cubic", unsafe { &self.cubic }) + .field("cubic_monotonic", unsafe { &self.cubic_monotonic }) + .finish() + } +} + +#[repr(C)] +#[derive(Copy, Clone)] +pub union GstDirectControlBinding_ABI { + pub _gst_reserved: [gpointer; 4], + pub abi: GstDirectControlBinding_ABI_abi, +} + +impl ::std::fmt::Debug for GstDirectControlBinding_ABI { + fn fmt(&self, f: &mut ::std::fmt::Formatter) -> ::std::fmt::Result { + f.debug_struct(&format!( + "GstDirectControlBinding_ABI @ {:?}", + self as *const _ + )) + .field("_gst_reserved", unsafe { &self._gst_reserved }) + .field("abi", unsafe { &self.abi }) + .finish() + } +} + +// Callbacks +pub type GstDirectControlBindingConvertGValue = + Option; +pub type GstDirectControlBindingConvertValue = + Option; + +// Records +#[repr(C)] +#[derive(Copy, Clone)] +pub struct GstARGBControlBindingClass { + pub parent_class: gst::GstControlBindingClass, + pub _gst_reserved: [gpointer; 4], +} + +impl ::std::fmt::Debug for GstARGBControlBindingClass { + fn fmt(&self, f: &mut ::std::fmt::Formatter) -> ::std::fmt::Result { + f.debug_struct(&format!( + "GstARGBControlBindingClass @ {:?}", + self as *const _ + )) + .field("parent_class", &self.parent_class) + .finish() + } +} + +#[repr(C)] +#[derive(Copy, Clone)] +pub struct GstControlPoint { + pub timestamp: gst::GstClockTime, + pub value: c_double, + pub cache: GstControlPoint_cache, +} + +impl ::std::fmt::Debug for GstControlPoint { + fn fmt(&self, f: &mut ::std::fmt::Formatter) -> ::std::fmt::Result { + f.debug_struct(&format!("GstControlPoint @ {:?}", self as *const _)) + .field("timestamp", &self.timestamp) + .field("value", &self.value) + .field("cache", &self.cache) + .finish() + } +} + +#[repr(C)] +#[derive(Copy, Clone)] +pub struct GstControlPoint_cache_cubic { + pub h: c_double, + pub z: c_double, +} + +impl ::std::fmt::Debug for GstControlPoint_cache_cubic { + fn fmt(&self, f: &mut ::std::fmt::Formatter) -> ::std::fmt::Result { + f.debug_struct(&format!( + "GstControlPoint_cache_cubic @ {:?}", + self as *const _ + )) + .field("h", &self.h) + .field("z", &self.z) + .finish() + } +} + +#[repr(C)] +#[derive(Copy, Clone)] +pub struct GstControlPoint_cache_cubic_monotonic { + pub c1s: c_double, + pub c2s: c_double, + pub c3s: c_double, +} + +impl ::std::fmt::Debug for GstControlPoint_cache_cubic_monotonic { + fn fmt(&self, f: &mut ::std::fmt::Formatter) -> ::std::fmt::Result { + f.debug_struct(&format!( + "GstControlPoint_cache_cubic_monotonic @ {:?}", + self as *const _ + )) + .field("c1s", &self.c1s) + .field("c2s", &self.c2s) + .field("c3s", &self.c3s) + .finish() + } +} + +#[repr(C)] +#[derive(Copy, Clone)] +pub struct GstDirectControlBindingClass { + pub parent_class: gst::GstControlBindingClass, + pub _gst_reserved: [gpointer; 4], +} + +impl ::std::fmt::Debug for GstDirectControlBindingClass { + fn fmt(&self, f: &mut ::std::fmt::Formatter) -> ::std::fmt::Result { + f.debug_struct(&format!( + "GstDirectControlBindingClass @ {:?}", + self as *const _ + )) + .field("parent_class", &self.parent_class) + .finish() + } +} + +#[repr(C)] +#[derive(Copy, Clone)] +pub struct GstDirectControlBinding_ABI_abi { + pub want_absolute: gboolean, +} + +impl ::std::fmt::Debug for GstDirectControlBinding_ABI_abi { + fn fmt(&self, f: &mut ::std::fmt::Formatter) -> ::std::fmt::Result { + f.debug_struct(&format!( + "GstDirectControlBinding_ABI_abi @ {:?}", + self as *const _ + )) + .field("want_absolute", &self.want_absolute) + .finish() + } +} + +#[repr(C)] +#[derive(Copy, Clone)] +pub struct GstInterpolationControlSourceClass { + pub parent_class: GstTimedValueControlSourceClass, + pub _gst_reserved: [gpointer; 4], +} + +impl ::std::fmt::Debug for GstInterpolationControlSourceClass { + fn fmt(&self, f: &mut ::std::fmt::Formatter) -> ::std::fmt::Result { + f.debug_struct(&format!( + "GstInterpolationControlSourceClass @ {:?}", + self as *const _ + )) + .field("parent_class", &self.parent_class) + .finish() + } +} + +#[repr(C)] +pub struct _GstInterpolationControlSourcePrivate(c_void); + +pub type GstInterpolationControlSourcePrivate = *mut _GstInterpolationControlSourcePrivate; + +#[repr(C)] +#[derive(Copy, Clone)] +pub struct GstLFOControlSourceClass { + pub parent_class: gst::GstControlSourceClass, + pub _gst_reserved: [gpointer; 4], +} + +impl ::std::fmt::Debug for GstLFOControlSourceClass { + fn fmt(&self, f: &mut ::std::fmt::Formatter) -> ::std::fmt::Result { + f.debug_struct(&format!( + "GstLFOControlSourceClass @ {:?}", + self as *const _ + )) + .field("parent_class", &self.parent_class) + .finish() + } +} + +#[repr(C)] +pub struct _GstLFOControlSourcePrivate(c_void); + +pub type GstLFOControlSourcePrivate = *mut _GstLFOControlSourcePrivate; + +#[repr(C)] +#[derive(Copy, Clone)] +pub struct GstProxyControlBindingClass { + pub parent_class: gst::GstControlBindingClass, + pub _padding: [gpointer; 4], +} + +impl ::std::fmt::Debug for GstProxyControlBindingClass { + fn fmt(&self, f: &mut ::std::fmt::Formatter) -> ::std::fmt::Result { + f.debug_struct(&format!( + "GstProxyControlBindingClass @ {:?}", + self as *const _ + )) + .finish() + } +} + +#[repr(C)] +#[derive(Copy, Clone)] +pub struct GstTimedValueControlSourceClass { + pub parent_class: gst::GstControlSourceClass, + pub _gst_reserved: [gpointer; 4], +} + +impl ::std::fmt::Debug for GstTimedValueControlSourceClass { + fn fmt(&self, f: &mut ::std::fmt::Formatter) -> ::std::fmt::Result { + f.debug_struct(&format!( + "GstTimedValueControlSourceClass @ {:?}", + self as *const _ + )) + .field("parent_class", &self.parent_class) + .finish() + } +} + +#[repr(C)] +pub struct _GstTimedValueControlSourcePrivate(c_void); + +pub type GstTimedValueControlSourcePrivate = *mut _GstTimedValueControlSourcePrivate; + +#[repr(C)] +#[derive(Copy, Clone)] +pub struct GstTriggerControlSourceClass { + pub parent_class: GstTimedValueControlSourceClass, + pub _gst_reserved: [gpointer; 4], +} + +impl ::std::fmt::Debug for GstTriggerControlSourceClass { + fn fmt(&self, f: &mut ::std::fmt::Formatter) -> ::std::fmt::Result { + f.debug_struct(&format!( + "GstTriggerControlSourceClass @ {:?}", + self as *const _ + )) + .field("parent_class", &self.parent_class) + .finish() + } +} + +#[repr(C)] +pub struct _GstTriggerControlSourcePrivate(c_void); + +pub type GstTriggerControlSourcePrivate = *mut _GstTriggerControlSourcePrivate; + +// Classes +#[repr(C)] +#[derive(Copy, Clone)] +pub struct GstARGBControlBinding { + pub parent: gst::GstControlBinding, + pub cs_a: *mut gst::GstControlSource, + pub cs_r: *mut gst::GstControlSource, + pub cs_g: *mut gst::GstControlSource, + pub cs_b: *mut gst::GstControlSource, + pub cur_value: gobject::GValue, + pub last_value: u32, + pub _gst_reserved: [gpointer; 4], +} + +impl ::std::fmt::Debug for GstARGBControlBinding { + fn fmt(&self, f: &mut ::std::fmt::Formatter) -> ::std::fmt::Result { + f.debug_struct(&format!("GstARGBControlBinding @ {:?}", self as *const _)) + .field("parent", &self.parent) + .finish() + } +} + +#[repr(C)] +#[derive(Copy, Clone)] +pub struct GstDirectControlBinding { + pub parent: gst::GstControlBinding, + pub cs: *mut gst::GstControlSource, + pub cur_value: gobject::GValue, + pub last_value: c_double, + pub byte_size: c_int, + pub convert_value: GstDirectControlBindingConvertValue, + pub convert_g_value: GstDirectControlBindingConvertGValue, + pub ABI: GstDirectControlBinding_ABI, +} + +impl ::std::fmt::Debug for GstDirectControlBinding { + fn fmt(&self, f: &mut ::std::fmt::Formatter) -> ::std::fmt::Result { + f.debug_struct(&format!("GstDirectControlBinding @ {:?}", self as *const _)) + .field("parent", &self.parent) + .field("ABI", &self.ABI) + .finish() + } +} + +#[repr(C)] +#[derive(Copy, Clone)] +pub struct GstInterpolationControlSource { + pub parent: GstTimedValueControlSource, + pub priv_: *mut GstInterpolationControlSourcePrivate, + pub _gst_reserved: [gpointer; 4], +} + +impl ::std::fmt::Debug for GstInterpolationControlSource { + fn fmt(&self, f: &mut ::std::fmt::Formatter) -> ::std::fmt::Result { + f.debug_struct(&format!( + "GstInterpolationControlSource @ {:?}", + self as *const _ + )) + .field("parent", &self.parent) + .finish() + } +} + +#[repr(C)] +#[derive(Copy, Clone)] +pub struct GstLFOControlSource { + pub parent: gst::GstControlSource, + pub priv_: *mut GstLFOControlSourcePrivate, + pub lock: glib::GMutex, + pub _gst_reserved: [gpointer; 4], +} + +impl ::std::fmt::Debug for GstLFOControlSource { + fn fmt(&self, f: &mut ::std::fmt::Formatter) -> ::std::fmt::Result { + f.debug_struct(&format!("GstLFOControlSource @ {:?}", self as *const _)) + .field("parent", &self.parent) + .finish() + } +} + +#[repr(C)] +#[derive(Copy, Clone)] +pub struct GstProxyControlBinding { + pub parent: gst::GstControlBinding, + pub ref_object: gobject::GWeakRef, + pub property_name: *mut c_char, + pub _padding: [gpointer; 4], +} + +impl ::std::fmt::Debug for GstProxyControlBinding { + fn fmt(&self, f: &mut ::std::fmt::Formatter) -> ::std::fmt::Result { + f.debug_struct(&format!("GstProxyControlBinding @ {:?}", self as *const _)) + .finish() + } +} + +#[repr(C)] +#[derive(Copy, Clone)] +pub struct GstTimedValueControlSource { + pub parent: gst::GstControlSource, + pub lock: glib::GMutex, + pub values: *mut glib::GSequence, + pub nvalues: c_int, + pub valid_cache: gboolean, + pub priv_: *mut GstTimedValueControlSourcePrivate, + pub _gst_reserved: [gpointer; 4], +} + +impl ::std::fmt::Debug for GstTimedValueControlSource { + fn fmt(&self, f: &mut ::std::fmt::Formatter) -> ::std::fmt::Result { + f.debug_struct(&format!( + "GstTimedValueControlSource @ {:?}", + self as *const _ + )) + .field("parent", &self.parent) + .field("lock", &self.lock) + .field("values", &self.values) + .field("nvalues", &self.nvalues) + .field("valid_cache", &self.valid_cache) + .finish() + } +} + +#[repr(C)] +#[derive(Copy, Clone)] +pub struct GstTriggerControlSource { + pub parent: GstTimedValueControlSource, + pub priv_: *mut GstTriggerControlSourcePrivate, + pub _gst_reserved: [gpointer; 4], +} + +impl ::std::fmt::Debug for GstTriggerControlSource { + fn fmt(&self, f: &mut ::std::fmt::Formatter) -> ::std::fmt::Result { + f.debug_struct(&format!("GstTriggerControlSource @ {:?}", self as *const _)) + .field("parent", &self.parent) + .finish() + } +} + +extern "C" { + + //========================================================================= + // GstInterpolationMode + //========================================================================= + pub fn gst_interpolation_mode_get_type() -> GType; + + //========================================================================= + // GstLFOWaveform + //========================================================================= + pub fn gst_lfo_waveform_get_type() -> GType; + + //========================================================================= + // GstControlPoint + //========================================================================= + pub fn gst_control_point_get_type() -> GType; + pub fn gst_control_point_copy(cp: *mut GstControlPoint) -> *mut GstControlPoint; + pub fn gst_control_point_free(cp: *mut GstControlPoint); + + //========================================================================= + // GstARGBControlBinding + //========================================================================= + pub fn gst_argb_control_binding_get_type() -> GType; + pub fn gst_argb_control_binding_new( + object: *mut gst::GstObject, + property_name: *const c_char, + cs_a: *mut gst::GstControlSource, + cs_r: *mut gst::GstControlSource, + cs_g: *mut gst::GstControlSource, + cs_b: *mut gst::GstControlSource, + ) -> *mut gst::GstControlBinding; + + //========================================================================= + // GstDirectControlBinding + //========================================================================= + pub fn gst_direct_control_binding_get_type() -> GType; + pub fn gst_direct_control_binding_new( + object: *mut gst::GstObject, + property_name: *const c_char, + cs: *mut gst::GstControlSource, + ) -> *mut gst::GstControlBinding; + pub fn gst_direct_control_binding_new_absolute( + object: *mut gst::GstObject, + property_name: *const c_char, + cs: *mut gst::GstControlSource, + ) -> *mut gst::GstControlBinding; + + //========================================================================= + // GstInterpolationControlSource + //========================================================================= + pub fn gst_interpolation_control_source_get_type() -> GType; + pub fn gst_interpolation_control_source_new() -> *mut gst::GstControlSource; + + //========================================================================= + // GstLFOControlSource + //========================================================================= + pub fn gst_lfo_control_source_get_type() -> GType; + pub fn gst_lfo_control_source_new() -> *mut gst::GstControlSource; + + //========================================================================= + // GstProxyControlBinding + //========================================================================= + pub fn gst_proxy_control_binding_get_type() -> GType; + #[cfg(any(feature = "v1_12", feature = "dox"))] + pub fn gst_proxy_control_binding_new( + object: *mut gst::GstObject, + property_name: *const c_char, + ref_object: *mut gst::GstObject, + ref_property_name: *const c_char, + ) -> *mut gst::GstControlBinding; + + //========================================================================= + // GstTimedValueControlSource + //========================================================================= + pub fn gst_timed_value_control_source_get_type() -> GType; + pub fn gst_timed_value_control_source_find_control_point_iter( + self_: *mut GstTimedValueControlSource, + timestamp: gst::GstClockTime, + ) -> *mut glib::GSequenceIter; + pub fn gst_timed_value_control_source_get_all( + self_: *mut GstTimedValueControlSource, + ) -> *mut glib::GList; + pub fn gst_timed_value_control_source_get_count( + self_: *mut GstTimedValueControlSource, + ) -> c_int; + pub fn gst_timed_value_control_source_set( + self_: *mut GstTimedValueControlSource, + timestamp: gst::GstClockTime, + value: c_double, + ) -> gboolean; + pub fn gst_timed_value_control_source_set_from_list( + self_: *mut GstTimedValueControlSource, + timedvalues: *const glib::GSList, + ) -> gboolean; + pub fn gst_timed_value_control_source_unset( + self_: *mut GstTimedValueControlSource, + timestamp: gst::GstClockTime, + ) -> gboolean; + pub fn gst_timed_value_control_source_unset_all(self_: *mut GstTimedValueControlSource); + + //========================================================================= + // GstTriggerControlSource + //========================================================================= + pub fn gst_trigger_control_source_get_type() -> GType; + pub fn gst_trigger_control_source_new() -> *mut gst::GstControlSource; + + //========================================================================= + // Other functions + //========================================================================= + pub fn gst_timed_value_control_invalidate_cache(self_: *mut GstTimedValueControlSource); + +} diff --git a/gstreamer-controller-sys/tests/abi.rs b/gstreamer-controller-sys/tests/abi.rs new file mode 100644 index 000000000..074df1f1b --- /dev/null +++ b/gstreamer-controller-sys/tests/abi.rs @@ -0,0 +1,386 @@ +// This file was generated by gir (https://github.com/gtk-rs/gir @ 60cbef0) +// from gir-files (https://github.com/gtk-rs/gir-files @ 91e1ef0) +// DO NOT EDIT + +extern crate gstreamer_controller_sys; +extern crate shell_words; +extern crate tempfile; +use gstreamer_controller_sys::*; +use std::env; +use std::error::Error; +use std::mem::{align_of, size_of}; +use std::path::Path; +use std::process::Command; +use std::str; +use tempfile::Builder; + +static PACKAGES: &[&str] = &["gstreamer-controller-1.0"]; + +#[derive(Clone, Debug)] +struct Compiler { + pub args: Vec, +} + +impl Compiler { + pub fn new() -> Result> { + let mut args = get_var("CC", "cc")?; + args.push("-Wno-deprecated-declarations".to_owned()); + // For %z support in printf when using MinGW. + args.push("-D__USE_MINGW_ANSI_STDIO".to_owned()); + args.extend(get_var("CFLAGS", "")?); + args.extend(get_var("CPPFLAGS", "")?); + args.extend(pkg_config_cflags(PACKAGES)?); + Ok(Compiler { args }) + } + + pub fn define<'a, V: Into>>(&mut self, var: &str, val: V) { + let arg = match val.into() { + None => format!("-D{}", var), + Some(val) => format!("-D{}={}", var, val), + }; + self.args.push(arg); + } + + pub fn compile(&self, src: &Path, out: &Path) -> Result<(), Box> { + let mut cmd = self.to_command(); + cmd.arg(src); + cmd.arg("-o"); + cmd.arg(out); + let status = cmd.spawn()?.wait()?; + if !status.success() { + return Err(format!("compilation command {:?} failed, {}", &cmd, status).into()); + } + Ok(()) + } + + fn to_command(&self) -> Command { + let mut cmd = Command::new(&self.args[0]); + cmd.args(&self.args[1..]); + cmd + } +} + +fn get_var(name: &str, default: &str) -> Result, Box> { + match env::var(name) { + Ok(value) => Ok(shell_words::split(&value)?), + Err(env::VarError::NotPresent) => Ok(shell_words::split(default)?), + Err(err) => Err(format!("{} {}", name, err).into()), + } +} + +fn pkg_config_cflags(packages: &[&str]) -> Result, Box> { + if packages.is_empty() { + return Ok(Vec::new()); + } + let mut cmd = Command::new("pkg-config"); + cmd.arg("--cflags"); + cmd.args(packages); + let out = cmd.output()?; + if !out.status.success() { + return Err(format!("command {:?} returned {}", &cmd, out.status).into()); + } + let stdout = str::from_utf8(&out.stdout)?; + Ok(shell_words::split(stdout.trim())?) +} + +#[derive(Copy, Clone, Debug, Eq, PartialEq)] +struct Layout { + size: usize, + alignment: usize, +} + +#[derive(Copy, Clone, Debug, Default, Eq, PartialEq)] +struct Results { + /// Number of successfully completed tests. + passed: usize, + /// Total number of failed tests (including those that failed to compile). + failed: usize, + /// Number of tests that failed to compile. + failed_to_compile: usize, +} + +impl Results { + fn record_passed(&mut self) { + self.passed += 1; + } + fn record_failed(&mut self) { + self.failed += 1; + } + fn record_failed_to_compile(&mut self) { + self.failed += 1; + self.failed_to_compile += 1; + } + fn summary(&self) -> String { + format!( + "{} passed; {} failed (compilation errors: {})", + self.passed, self.failed, self.failed_to_compile + ) + } + fn expect_total_success(&self) { + if self.failed == 0 { + println!("OK: {}", self.summary()); + } else { + panic!("FAILED: {}", self.summary()); + }; + } +} + +#[test] +fn cross_validate_constants_with_c() { + let tmpdir = Builder::new() + .prefix("abi") + .tempdir() + .expect("temporary directory"); + let cc = Compiler::new().expect("configured compiler"); + + assert_eq!( + "1", + get_c_value(tmpdir.path(), &cc, "1").expect("C constant"), + "failed to obtain correct constant value for 1" + ); + + let mut results: Results = Default::default(); + for (i, &(name, rust_value)) in RUST_CONSTANTS.iter().enumerate() { + match get_c_value(tmpdir.path(), &cc, name) { + Err(e) => { + results.record_failed_to_compile(); + eprintln!("{}", e); + } + Ok(ref c_value) => { + if rust_value == c_value { + results.record_passed(); + } else { + results.record_failed(); + eprintln!( + "Constant value mismatch for {}\nRust: {:?}\nC: {:?}", + name, rust_value, c_value + ); + } + } + }; + if (i + 1) % 25 == 0 { + println!("constants ... {}", results.summary()); + } + } + results.expect_total_success(); +} + +#[test] +fn cross_validate_layout_with_c() { + let tmpdir = Builder::new() + .prefix("abi") + .tempdir() + .expect("temporary directory"); + let cc = Compiler::new().expect("configured compiler"); + + assert_eq!( + Layout { + size: 1, + alignment: 1 + }, + get_c_layout(tmpdir.path(), &cc, "char").expect("C layout"), + "failed to obtain correct layout for char type" + ); + + let mut results: Results = Default::default(); + for (i, &(name, rust_layout)) in RUST_LAYOUTS.iter().enumerate() { + match get_c_layout(tmpdir.path(), &cc, name) { + Err(e) => { + results.record_failed_to_compile(); + eprintln!("{}", e); + } + Ok(c_layout) => { + if rust_layout == c_layout { + results.record_passed(); + } else { + results.record_failed(); + eprintln!( + "Layout mismatch for {}\nRust: {:?}\nC: {:?}", + name, rust_layout, &c_layout + ); + } + } + }; + if (i + 1) % 25 == 0 { + println!("layout ... {}", results.summary()); + } + } + results.expect_total_success(); +} + +fn get_c_layout(dir: &Path, cc: &Compiler, name: &str) -> Result> { + let exe = dir.join("layout"); + let mut cc = cc.clone(); + cc.define("ABI_TYPE_NAME", name); + cc.compile(Path::new("tests/layout.c"), &exe)?; + + let mut abi_cmd = Command::new(exe); + let output = abi_cmd.output()?; + if !output.status.success() { + return Err(format!("command {:?} failed, {:?}", &abi_cmd, &output).into()); + } + + let stdout = str::from_utf8(&output.stdout)?; + let mut words = stdout.trim().split_whitespace(); + let size = words.next().unwrap().parse().unwrap(); + let alignment = words.next().unwrap().parse().unwrap(); + Ok(Layout { size, alignment }) +} + +fn get_c_value(dir: &Path, cc: &Compiler, name: &str) -> Result> { + let exe = dir.join("constant"); + let mut cc = cc.clone(); + cc.define("ABI_CONSTANT_NAME", name); + cc.compile(Path::new("tests/constant.c"), &exe)?; + + let mut abi_cmd = Command::new(exe); + let output = abi_cmd.output()?; + if !output.status.success() { + return Err(format!("command {:?} failed, {:?}", &abi_cmd, &output).into()); + } + + let output = str::from_utf8(&output.stdout)?.trim(); + if !output.starts_with("###gir test###") || !output.ends_with("###gir test###") { + return Err(format!( + "command {:?} return invalid output, {:?}", + &abi_cmd, &output + ) + .into()); + } + + Ok(String::from(&output[14..(output.len() - 14)])) +} + +const RUST_LAYOUTS: &[(&str, Layout)] = &[ + ( + "GstARGBControlBinding", + Layout { + size: size_of::(), + alignment: align_of::(), + }, + ), + ( + "GstARGBControlBindingClass", + Layout { + size: size_of::(), + alignment: align_of::(), + }, + ), + ( + "GstControlPoint", + Layout { + size: size_of::(), + alignment: align_of::(), + }, + ), + ( + "GstDirectControlBinding", + Layout { + size: size_of::(), + alignment: align_of::(), + }, + ), + ( + "GstDirectControlBindingClass", + Layout { + size: size_of::(), + alignment: align_of::(), + }, + ), + ( + "GstInterpolationControlSource", + Layout { + size: size_of::(), + alignment: align_of::(), + }, + ), + ( + "GstInterpolationControlSourceClass", + Layout { + size: size_of::(), + alignment: align_of::(), + }, + ), + ( + "GstInterpolationMode", + Layout { + size: size_of::(), + alignment: align_of::(), + }, + ), + ( + "GstLFOControlSource", + Layout { + size: size_of::(), + alignment: align_of::(), + }, + ), + ( + "GstLFOControlSourceClass", + Layout { + size: size_of::(), + alignment: align_of::(), + }, + ), + ( + "GstLFOWaveform", + Layout { + size: size_of::(), + alignment: align_of::(), + }, + ), + ( + "GstProxyControlBinding", + Layout { + size: size_of::(), + alignment: align_of::(), + }, + ), + ( + "GstProxyControlBindingClass", + Layout { + size: size_of::(), + alignment: align_of::(), + }, + ), + ( + "GstTimedValueControlSource", + Layout { + size: size_of::(), + alignment: align_of::(), + }, + ), + ( + "GstTimedValueControlSourceClass", + Layout { + size: size_of::(), + alignment: align_of::(), + }, + ), + ( + "GstTriggerControlSource", + Layout { + size: size_of::(), + alignment: align_of::(), + }, + ), + ( + "GstTriggerControlSourceClass", + Layout { + size: size_of::(), + alignment: align_of::(), + }, + ), +]; + +const RUST_CONSTANTS: &[(&str, &str)] = &[ + ("(gint) GST_INTERPOLATION_MODE_CUBIC", "2"), + ("(gint) GST_INTERPOLATION_MODE_CUBIC_MONOTONIC", "3"), + ("(gint) GST_INTERPOLATION_MODE_LINEAR", "1"), + ("(gint) GST_INTERPOLATION_MODE_NONE", "0"), + ("(gint) GST_LFO_WAVEFORM_REVERSE_SAW", "3"), + ("(gint) GST_LFO_WAVEFORM_SAW", "2"), + ("(gint) GST_LFO_WAVEFORM_SINE", "0"), + ("(gint) GST_LFO_WAVEFORM_SQUARE", "1"), + ("(gint) GST_LFO_WAVEFORM_TRIANGLE", "4"), +]; diff --git a/gstreamer-controller-sys/tests/constant.c b/gstreamer-controller-sys/tests/constant.c new file mode 100644 index 000000000..7bc0a3b60 --- /dev/null +++ b/gstreamer-controller-sys/tests/constant.c @@ -0,0 +1,27 @@ +// This file was generated by gir (https://github.com/gtk-rs/gir @ 60cbef0) +// from gir-files (https://github.com/gtk-rs/gir-files @ 91e1ef0) +// DO NOT EDIT + +#include "manual.h" +#include + +int main() { + printf(_Generic((ABI_CONSTANT_NAME), + char *: "###gir test###%s###gir test###\n", + const char *: "###gir test###%s###gir test###\n", + char: "###gir test###%c###gir test###\n", + signed char: "###gir test###%hhd###gir test###\n", + unsigned char: "###gir test###%hhu###gir test###\n", + short int: "###gir test###%hd###gir test###\n", + unsigned short int: "###gir test###%hu###gir test###\n", + int: "###gir test###%d###gir test###\n", + unsigned int: "###gir test###%u###gir test###\n", + long: "###gir test###%ld###gir test###\n", + unsigned long: "###gir test###%lu###gir test###\n", + long long: "###gir test###%lld###gir test###\n", + unsigned long long: "###gir test###%llu###gir test###\n", + double: "###gir test###%f###gir test###\n", + long double: "###gir test###%ld###gir test###\n"), + ABI_CONSTANT_NAME); + return 0; +} diff --git a/gstreamer-controller-sys/tests/layout.c b/gstreamer-controller-sys/tests/layout.c new file mode 100644 index 000000000..b4ede79a5 --- /dev/null +++ b/gstreamer-controller-sys/tests/layout.c @@ -0,0 +1,12 @@ +// This file was generated by gir (https://github.com/gtk-rs/gir @ 60cbef0) +// from gir-files (https://github.com/gtk-rs/gir-files @ 91e1ef0) +// DO NOT EDIT + +#include "manual.h" +#include +#include + +int main() { + printf("%zu\n%zu", sizeof(ABI_TYPE_NAME), alignof(ABI_TYPE_NAME)); + return 0; +} diff --git a/gstreamer-controller-sys/tests/manual.h b/gstreamer-controller-sys/tests/manual.h new file mode 100644 index 000000000..19378716e --- /dev/null +++ b/gstreamer-controller-sys/tests/manual.h @@ -0,0 +1,3 @@ +// Feel free to edit this file, it won't be regenerated by gir generator unless removed. + +#include