diff --git a/gstreamer-app-sys/Cargo.toml b/gstreamer-app-sys/Cargo.toml index 30826dab1..aec1d911b 100644 --- a/gstreamer-app-sys/Cargo.toml +++ b/gstreamer-app-sys/Cargo.toml @@ -11,6 +11,10 @@ path = "../gstreamer-sys" [dependencies.gstreamer-base-sys] path = "../gstreamer-base-sys" +[dev-dependencies] +shell-words = "0.1.0" +tempdir = "0.3" + [features] v1_2 = [] v1_4 = ["v1_2"] diff --git a/gstreamer-app-sys/src/lib.rs b/gstreamer-app-sys/src/lib.rs index 680ab4daf..e5435c290 100644 --- a/gstreamer-app-sys/src/lib.rs +++ b/gstreamer-app-sys/src/lib.rs @@ -1,4 +1,4 @@ -// This file was generated by gir (https://github.com/gtk-rs/gir @ fe7a6ff) +// This file was generated by gir (https://github.com/gtk-rs/gir @ 6855214) // from gir-files (https://github.com/gtk-rs/gir-files @ ???) // DO NOT EDIT diff --git a/gstreamer-app-sys/tests/abi.rs b/gstreamer-app-sys/tests/abi.rs new file mode 100644 index 000000000..58c40d4da --- /dev/null +++ b/gstreamer-app-sys/tests/abi.rs @@ -0,0 +1,249 @@ +// This file was generated by gir (https://github.com/gtk-rs/gir @ 6855214) +// from gir-files (https://github.com/gtk-rs/gir-files @ ???) +// DO NOT EDIT + +extern crate gstreamer_app_sys; +extern crate shell_words; +extern crate tempdir; +use std::env; +use std::error::Error; +use std::path::Path; +use std::mem::{align_of, size_of}; +use std::process::Command; +use std::str; +use gstreamer_app_sys::*; + +static PACKAGES: &[&str] = &["gstreamer-app-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 = tempdir::TempDir::new("abi").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 = tempdir::TempDir::new("abi").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()); + } + + Ok(str::from_utf8(&output.stdout)?.trim().to_owned()) +} + +const RUST_LAYOUTS: &[(&str, Layout)] = &[ + ("GstAppSink", Layout {size: size_of::(), alignment: align_of::()}), + ("GstAppSinkCallbacks", Layout {size: size_of::(), alignment: align_of::()}), + ("GstAppSinkClass", Layout {size: size_of::(), alignment: align_of::()}), + ("GstAppSrc", Layout {size: size_of::(), alignment: align_of::()}), + ("GstAppSrcCallbacks", Layout {size: size_of::(), alignment: align_of::()}), + ("GstAppSrcClass", Layout {size: size_of::(), alignment: align_of::()}), + ("GstAppStreamType", Layout {size: size_of::(), alignment: align_of::()}), +]; + +const RUST_CONSTANTS: &[(&str, &str)] = &[ + ("GST_APP_STREAM_TYPE_RANDOM_ACCESS", "2"), + ("GST_APP_STREAM_TYPE_SEEKABLE", "1"), + ("GST_APP_STREAM_TYPE_STREAM", "0"), +]; + + diff --git a/gstreamer-app-sys/tests/constant.c b/gstreamer-app-sys/tests/constant.c new file mode 100644 index 000000000..f95b609c2 --- /dev/null +++ b/gstreamer-app-sys/tests/constant.c @@ -0,0 +1,27 @@ +// This file was generated by gir (https://github.com/gtk-rs/gir @ 6855214) +// from gir-files (https://github.com/gtk-rs/gir-files @ ???) +// DO NOT EDIT + +#include "manual.h" +#include + +int main() { + printf(_Generic((ABI_CONSTANT_NAME), + char *: "%s", + const char *: "%s", + char: "%c", + signed char: "%hhd", + unsigned char: "%hhu", + short int: "%hd", + unsigned short int: "%hu", + int: "%d", + unsigned int: "%u", + long: "%ld", + unsigned long: "%lu", + long long: "%lld", + unsigned long long: "%llu", + double: "%f", + long double: "%ld"), + ABI_CONSTANT_NAME); + return 0; +} diff --git a/gstreamer-app-sys/tests/layout.c b/gstreamer-app-sys/tests/layout.c new file mode 100644 index 000000000..e4be962df --- /dev/null +++ b/gstreamer-app-sys/tests/layout.c @@ -0,0 +1,12 @@ +// This file was generated by gir (https://github.com/gtk-rs/gir @ 6855214) +// from gir-files (https://github.com/gtk-rs/gir-files @ ???) +// 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-app-sys/tests/manual.h b/gstreamer-app-sys/tests/manual.h new file mode 100644 index 000000000..379231276 --- /dev/null +++ b/gstreamer-app-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 diff --git a/gstreamer-audio-sys/Cargo.toml b/gstreamer-audio-sys/Cargo.toml index 82fa1a21b..bc70bd378 100644 --- a/gstreamer-audio-sys/Cargo.toml +++ b/gstreamer-audio-sys/Cargo.toml @@ -2,7 +2,6 @@ pkg-config = "0.3.7" [dependencies] -bitflags = "1.0" libc = "0.2" glib-sys = { git = "https://github.com/gtk-rs/sys" } gobject-sys = { git = "https://github.com/gtk-rs/sys" } @@ -13,6 +12,10 @@ path = "../gstreamer-sys" [dependencies.gstreamer-base-sys] path = "../gstreamer-base-sys" +[dev-dependencies] +shell-words = "0.1.0" +tempdir = "0.3" + [features] v1_2 = [] v1_4 = ["v1_2"] diff --git a/gstreamer-audio-sys/src/lib.rs b/gstreamer-audio-sys/src/lib.rs index 999a3e998..86a2c1d89 100644 --- a/gstreamer-audio-sys/src/lib.rs +++ b/gstreamer-audio-sys/src/lib.rs @@ -1,11 +1,10 @@ -// This file was generated by gir (https://github.com/gtk-rs/gir @ fe7a6ff) +// This file was generated by gir (https://github.com/gtk-rs/gir @ 6855214) // 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)] extern crate libc; -#[macro_use] extern crate bitflags; extern crate glib_sys as glib; extern crate gobject_sys as gobject; extern crate gstreamer_sys as gst; @@ -209,93 +208,42 @@ pub const GST_META_TAG_AUDIO_RATE_STR: *const c_char = b"rate\0" as *const u8 as pub const GST_META_TAG_AUDIO_STR: *const c_char = b"audio\0" as *const u8 as *const c_char; // Flags -bitflags! { - #[repr(C)] - pub struct GstAudioChannelMixerFlags: c_uint { - const NONE = 0; - const NON_INTERLEAVED_IN = 1; - const NON_INTERLEAVED_OUT = 2; - const UNPOSITIONED_IN = 4; - const UNPOSITIONED_OUT = 8; - } -} -pub const GST_AUDIO_CHANNEL_MIXER_FLAGS_NONE: GstAudioChannelMixerFlags = GstAudioChannelMixerFlags::NONE; -pub const GST_AUDIO_CHANNEL_MIXER_FLAGS_NON_INTERLEAVED_IN: GstAudioChannelMixerFlags = GstAudioChannelMixerFlags::NON_INTERLEAVED_IN; -pub const GST_AUDIO_CHANNEL_MIXER_FLAGS_NON_INTERLEAVED_OUT: GstAudioChannelMixerFlags = GstAudioChannelMixerFlags::NON_INTERLEAVED_OUT; -pub const GST_AUDIO_CHANNEL_MIXER_FLAGS_UNPOSITIONED_IN: GstAudioChannelMixerFlags = GstAudioChannelMixerFlags::UNPOSITIONED_IN; -pub const GST_AUDIO_CHANNEL_MIXER_FLAGS_UNPOSITIONED_OUT: GstAudioChannelMixerFlags = GstAudioChannelMixerFlags::UNPOSITIONED_OUT; +pub type GstAudioChannelMixerFlags = c_uint; +pub const GST_AUDIO_CHANNEL_MIXER_FLAGS_NONE: GstAudioChannelMixerFlags = 0; +pub const GST_AUDIO_CHANNEL_MIXER_FLAGS_NON_INTERLEAVED_IN: GstAudioChannelMixerFlags = 1; +pub const GST_AUDIO_CHANNEL_MIXER_FLAGS_NON_INTERLEAVED_OUT: GstAudioChannelMixerFlags = 2; +pub const GST_AUDIO_CHANNEL_MIXER_FLAGS_UNPOSITIONED_IN: GstAudioChannelMixerFlags = 4; +pub const GST_AUDIO_CHANNEL_MIXER_FLAGS_UNPOSITIONED_OUT: GstAudioChannelMixerFlags = 8; -bitflags! { - #[repr(C)] - pub struct GstAudioConverterFlags: c_uint { - const NONE = 0; - const IN_WRITABLE = 1; - const VARIABLE_RATE = 2; - } -} -pub const GST_AUDIO_CONVERTER_FLAG_NONE: GstAudioConverterFlags = GstAudioConverterFlags::NONE; -pub const GST_AUDIO_CONVERTER_FLAG_IN_WRITABLE: GstAudioConverterFlags = GstAudioConverterFlags::IN_WRITABLE; -pub const GST_AUDIO_CONVERTER_FLAG_VARIABLE_RATE: GstAudioConverterFlags = GstAudioConverterFlags::VARIABLE_RATE; +pub type GstAudioConverterFlags = c_uint; +pub const GST_AUDIO_CONVERTER_FLAG_NONE: GstAudioConverterFlags = 0; +pub const GST_AUDIO_CONVERTER_FLAG_IN_WRITABLE: GstAudioConverterFlags = 1; +pub const GST_AUDIO_CONVERTER_FLAG_VARIABLE_RATE: GstAudioConverterFlags = 2; -bitflags! { - #[repr(C)] - pub struct GstAudioFlags: c_uint { - const NONE = 0; - const UNPOSITIONED = 1; - } -} -pub const GST_AUDIO_FLAG_NONE: GstAudioFlags = GstAudioFlags::NONE; -pub const GST_AUDIO_FLAG_UNPOSITIONED: GstAudioFlags = GstAudioFlags::UNPOSITIONED; +pub type GstAudioFlags = c_uint; +pub const GST_AUDIO_FLAG_NONE: GstAudioFlags = 0; +pub const GST_AUDIO_FLAG_UNPOSITIONED: GstAudioFlags = 1; -bitflags! { - #[repr(C)] - pub struct GstAudioFormatFlags: c_uint { - const INTEGER = 1; - const FLOAT = 2; - const SIGNED = 4; - const COMPLEX = 16; - const UNPACK = 32; - } -} -pub const GST_AUDIO_FORMAT_FLAG_INTEGER: GstAudioFormatFlags = GstAudioFormatFlags::INTEGER; -pub const GST_AUDIO_FORMAT_FLAG_FLOAT: GstAudioFormatFlags = GstAudioFormatFlags::FLOAT; -pub const GST_AUDIO_FORMAT_FLAG_SIGNED: GstAudioFormatFlags = GstAudioFormatFlags::SIGNED; -pub const GST_AUDIO_FORMAT_FLAG_COMPLEX: GstAudioFormatFlags = GstAudioFormatFlags::COMPLEX; -pub const GST_AUDIO_FORMAT_FLAG_UNPACK: GstAudioFormatFlags = GstAudioFormatFlags::UNPACK; +pub type GstAudioFormatFlags = c_uint; +pub const GST_AUDIO_FORMAT_FLAG_INTEGER: GstAudioFormatFlags = 1; +pub const GST_AUDIO_FORMAT_FLAG_FLOAT: GstAudioFormatFlags = 2; +pub const GST_AUDIO_FORMAT_FLAG_SIGNED: GstAudioFormatFlags = 4; +pub const GST_AUDIO_FORMAT_FLAG_COMPLEX: GstAudioFormatFlags = 16; +pub const GST_AUDIO_FORMAT_FLAG_UNPACK: GstAudioFormatFlags = 32; -bitflags! { - #[repr(C)] - pub struct GstAudioPackFlags: c_uint { - const NONE = 0; - const TRUNCATE_RANGE = 1; - } -} -pub const GST_AUDIO_PACK_FLAG_NONE: GstAudioPackFlags = GstAudioPackFlags::NONE; -pub const GST_AUDIO_PACK_FLAG_TRUNCATE_RANGE: GstAudioPackFlags = GstAudioPackFlags::TRUNCATE_RANGE; +pub type GstAudioPackFlags = c_uint; +pub const GST_AUDIO_PACK_FLAG_NONE: GstAudioPackFlags = 0; +pub const GST_AUDIO_PACK_FLAG_TRUNCATE_RANGE: GstAudioPackFlags = 1; -bitflags! { - #[repr(C)] - pub struct GstAudioQuantizeFlags: c_uint { - const NONE = 0; - const NON_INTERLEAVED = 1; - } -} -pub const GST_AUDIO_QUANTIZE_FLAG_NONE: GstAudioQuantizeFlags = GstAudioQuantizeFlags::NONE; -pub const GST_AUDIO_QUANTIZE_FLAG_NON_INTERLEAVED: GstAudioQuantizeFlags = GstAudioQuantizeFlags::NON_INTERLEAVED; +pub type GstAudioQuantizeFlags = c_uint; +pub const GST_AUDIO_QUANTIZE_FLAG_NONE: GstAudioQuantizeFlags = 0; +pub const GST_AUDIO_QUANTIZE_FLAG_NON_INTERLEAVED: GstAudioQuantizeFlags = 1; -bitflags! { - #[repr(C)] - pub struct GstAudioResamplerFlags: c_uint { - const NONE = 0; - const NON_INTERLEAVED_IN = 1; - const NON_INTERLEAVED_OUT = 2; - const VARIABLE_RATE = 4; - } -} -pub const GST_AUDIO_RESAMPLER_FLAG_NONE: GstAudioResamplerFlags = GstAudioResamplerFlags::NONE; -pub const GST_AUDIO_RESAMPLER_FLAG_NON_INTERLEAVED_IN: GstAudioResamplerFlags = GstAudioResamplerFlags::NON_INTERLEAVED_IN; -pub const GST_AUDIO_RESAMPLER_FLAG_NON_INTERLEAVED_OUT: GstAudioResamplerFlags = GstAudioResamplerFlags::NON_INTERLEAVED_OUT; -pub const GST_AUDIO_RESAMPLER_FLAG_VARIABLE_RATE: GstAudioResamplerFlags = GstAudioResamplerFlags::VARIABLE_RATE; +pub type GstAudioResamplerFlags = c_uint; +pub const GST_AUDIO_RESAMPLER_FLAG_NONE: GstAudioResamplerFlags = 0; +pub const GST_AUDIO_RESAMPLER_FLAG_NON_INTERLEAVED_IN: GstAudioResamplerFlags = 1; +pub const GST_AUDIO_RESAMPLER_FLAG_NON_INTERLEAVED_OUT: GstAudioResamplerFlags = 2; +pub const GST_AUDIO_RESAMPLER_FLAG_VARIABLE_RATE: GstAudioResamplerFlags = 4; // Callbacks pub type GstAudioBaseSinkCustomSlavingCallback = Option; diff --git a/gstreamer-audio-sys/tests/abi.rs b/gstreamer-audio-sys/tests/abi.rs new file mode 100644 index 000000000..512758b2a --- /dev/null +++ b/gstreamer-audio-sys/tests/abi.rs @@ -0,0 +1,487 @@ +// This file was generated by gir (https://github.com/gtk-rs/gir @ 6855214) +// from gir-files (https://github.com/gtk-rs/gir-files @ ???) +// DO NOT EDIT + +extern crate gstreamer_audio_sys; +extern crate shell_words; +extern crate tempdir; +use std::env; +use std::error::Error; +use std::path::Path; +use std::mem::{align_of, size_of}; +use std::process::Command; +use std::str; +use gstreamer_audio_sys::*; + +static PACKAGES: &[&str] = &["gstreamer-audio-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 = tempdir::TempDir::new("abi").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 = tempdir::TempDir::new("abi").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()); + } + + Ok(str::from_utf8(&output.stdout)?.trim().to_owned()) +} + +const RUST_LAYOUTS: &[(&str, Layout)] = &[ + ("GstAudioAggregator", Layout {size: size_of::(), alignment: align_of::()}), + ("GstAudioAggregatorClass", Layout {size: size_of::(), alignment: align_of::()}), + ("GstAudioAggregatorConvertPad", Layout {size: size_of::(), alignment: align_of::()}), + ("GstAudioAggregatorConvertPadClass", Layout {size: size_of::(), alignment: align_of::()}), + ("GstAudioAggregatorPad", Layout {size: size_of::(), alignment: align_of::()}), + ("GstAudioAggregatorPadClass", Layout {size: size_of::(), alignment: align_of::()}), + ("GstAudioBaseSink", Layout {size: size_of::(), alignment: align_of::()}), + ("GstAudioBaseSinkClass", Layout {size: size_of::(), alignment: align_of::()}), + ("GstAudioBaseSinkDiscontReason", Layout {size: size_of::(), alignment: align_of::()}), + ("GstAudioBaseSinkSlaveMethod", Layout {size: size_of::(), alignment: align_of::()}), + ("GstAudioBaseSrc", Layout {size: size_of::(), alignment: align_of::()}), + ("GstAudioBaseSrcClass", Layout {size: size_of::(), alignment: align_of::()}), + ("GstAudioBaseSrcSlaveMethod", Layout {size: size_of::(), alignment: align_of::()}), + ("GstAudioCdSrc", Layout {size: size_of::(), alignment: align_of::()}), + ("GstAudioCdSrcClass", Layout {size: size_of::(), alignment: align_of::()}), + ("GstAudioCdSrcMode", Layout {size: size_of::(), alignment: align_of::()}), + ("GstAudioCdSrcTrack", Layout {size: size_of::(), alignment: align_of::()}), + ("GstAudioChannelMixerFlags", Layout {size: size_of::(), alignment: align_of::()}), + ("GstAudioChannelPosition", Layout {size: size_of::(), alignment: align_of::()}), + ("GstAudioClippingMeta", Layout {size: size_of::(), alignment: align_of::()}), + ("GstAudioClock", Layout {size: size_of::(), alignment: align_of::()}), + ("GstAudioClockClass", Layout {size: size_of::(), alignment: align_of::()}), + ("GstAudioConverterFlags", Layout {size: size_of::(), alignment: align_of::()}), + ("GstAudioDecoder", Layout {size: size_of::(), alignment: align_of::()}), + ("GstAudioDecoderClass", Layout {size: size_of::(), alignment: align_of::()}), + ("GstAudioDitherMethod", Layout {size: size_of::(), alignment: align_of::()}), + ("GstAudioDownmixMeta", Layout {size: size_of::(), alignment: align_of::()}), + ("GstAudioEncoder", Layout {size: size_of::(), alignment: align_of::()}), + ("GstAudioEncoderClass", Layout {size: size_of::(), alignment: align_of::()}), + ("GstAudioFilter", Layout {size: size_of::(), alignment: align_of::()}), + ("GstAudioFilterClass", Layout {size: size_of::(), alignment: align_of::()}), + ("GstAudioFlags", Layout {size: size_of::(), alignment: align_of::()}), + ("GstAudioFormat", Layout {size: size_of::(), alignment: align_of::()}), + ("GstAudioFormatFlags", Layout {size: size_of::(), alignment: align_of::()}), + ("GstAudioFormatInfo", Layout {size: size_of::(), alignment: align_of::()}), + ("GstAudioInfo", Layout {size: size_of::(), alignment: align_of::()}), + ("GstAudioLayout", Layout {size: size_of::(), alignment: align_of::()}), + ("GstAudioNoiseShapingMethod", Layout {size: size_of::(), alignment: align_of::()}), + ("GstAudioPackFlags", Layout {size: size_of::(), alignment: align_of::()}), + ("GstAudioQuantizeFlags", Layout {size: size_of::(), alignment: align_of::()}), + ("GstAudioResamplerFilterInterpolation", Layout {size: size_of::(), alignment: align_of::()}), + ("GstAudioResamplerFilterMode", Layout {size: size_of::(), alignment: align_of::()}), + ("GstAudioResamplerFlags", Layout {size: size_of::(), alignment: align_of::()}), + ("GstAudioResamplerMethod", Layout {size: size_of::(), alignment: align_of::()}), + ("GstAudioRingBuffer", Layout {size: size_of::(), alignment: align_of::()}), + ("GstAudioRingBufferClass", Layout {size: size_of::(), alignment: align_of::()}), + ("GstAudioRingBufferFormatType", Layout {size: size_of::(), alignment: align_of::()}), + ("GstAudioRingBufferSpec", Layout {size: size_of::(), alignment: align_of::()}), + ("GstAudioRingBufferState", Layout {size: size_of::(), alignment: align_of::()}), + ("GstAudioSink", Layout {size: size_of::(), alignment: align_of::()}), + ("GstAudioSinkClass", Layout {size: size_of::(), alignment: align_of::()}), + ("GstAudioSrc", Layout {size: size_of::(), alignment: align_of::()}), + ("GstAudioSrcClass", Layout {size: size_of::(), alignment: align_of::()}), + ("GstStreamVolumeFormat", Layout {size: size_of::(), alignment: align_of::()}), + ("GstStreamVolumeInterface", Layout {size: size_of::(), alignment: align_of::()}), +]; + +const RUST_CONSTANTS: &[(&str, &str)] = &[ + ("GST_AUDIO_BASE_SINK_DISCONT_REASON_ALIGNMENT", "4"), + ("GST_AUDIO_BASE_SINK_DISCONT_REASON_DEVICE_FAILURE", "5"), + ("GST_AUDIO_BASE_SINK_DISCONT_REASON_FLUSH", "2"), + ("GST_AUDIO_BASE_SINK_DISCONT_REASON_NEW_CAPS", "1"), + ("GST_AUDIO_BASE_SINK_DISCONT_REASON_NO_DISCONT", "0"), + ("GST_AUDIO_BASE_SINK_DISCONT_REASON_SYNC_LATENCY", "3"), + ("GST_AUDIO_BASE_SINK_SLAVE_CUSTOM", "3"), + ("GST_AUDIO_BASE_SINK_SLAVE_NONE", "2"), + ("GST_AUDIO_BASE_SINK_SLAVE_RESAMPLE", "0"), + ("GST_AUDIO_BASE_SINK_SLAVE_SKEW", "1"), + ("GST_AUDIO_BASE_SRC_SLAVE_NONE", "3"), + ("GST_AUDIO_BASE_SRC_SLAVE_RESAMPLE", "0"), + ("GST_AUDIO_BASE_SRC_SLAVE_RE_TIMESTAMP", "1"), + ("GST_AUDIO_BASE_SRC_SLAVE_SKEW", "2"), + ("GST_AUDIO_CD_SRC_MODE_CONTINUOUS", "1"), + ("GST_AUDIO_CD_SRC_MODE_NORMAL", "0"), + ("GST_AUDIO_CHANNELS_RANGE", "(int) [ 1, max ]"), + ("GST_AUDIO_CHANNEL_MIXER_FLAGS_NONE", "0"), + ("GST_AUDIO_CHANNEL_MIXER_FLAGS_NON_INTERLEAVED_IN", "1"), + ("GST_AUDIO_CHANNEL_MIXER_FLAGS_NON_INTERLEAVED_OUT", "2"), + ("GST_AUDIO_CHANNEL_MIXER_FLAGS_UNPOSITIONED_IN", "4"), + ("GST_AUDIO_CHANNEL_MIXER_FLAGS_UNPOSITIONED_OUT", "8"), + ("GST_AUDIO_CHANNEL_POSITION_BOTTOM_FRONT_CENTER", "21"), + ("GST_AUDIO_CHANNEL_POSITION_BOTTOM_FRONT_LEFT", "22"), + ("GST_AUDIO_CHANNEL_POSITION_BOTTOM_FRONT_RIGHT", "23"), + ("GST_AUDIO_CHANNEL_POSITION_FRONT_CENTER", "2"), + ("GST_AUDIO_CHANNEL_POSITION_FRONT_LEFT", "0"), + ("GST_AUDIO_CHANNEL_POSITION_FRONT_LEFT_OF_CENTER", "6"), + ("GST_AUDIO_CHANNEL_POSITION_FRONT_RIGHT", "1"), + ("GST_AUDIO_CHANNEL_POSITION_FRONT_RIGHT_OF_CENTER", "7"), + ("GST_AUDIO_CHANNEL_POSITION_INVALID", "-1"), + ("GST_AUDIO_CHANNEL_POSITION_LFE1", "3"), + ("GST_AUDIO_CHANNEL_POSITION_LFE2", "9"), + ("GST_AUDIO_CHANNEL_POSITION_MONO", "-2"), + ("GST_AUDIO_CHANNEL_POSITION_NONE", "-3"), + ("GST_AUDIO_CHANNEL_POSITION_REAR_CENTER", "8"), + ("GST_AUDIO_CHANNEL_POSITION_REAR_LEFT", "4"), + ("GST_AUDIO_CHANNEL_POSITION_REAR_RIGHT", "5"), + ("GST_AUDIO_CHANNEL_POSITION_SIDE_LEFT", "10"), + ("GST_AUDIO_CHANNEL_POSITION_SIDE_RIGHT", "11"), + ("GST_AUDIO_CHANNEL_POSITION_SURROUND_LEFT", "26"), + ("GST_AUDIO_CHANNEL_POSITION_SURROUND_RIGHT", "27"), + ("GST_AUDIO_CHANNEL_POSITION_TOP_CENTER", "15"), + ("GST_AUDIO_CHANNEL_POSITION_TOP_FRONT_CENTER", "14"), + ("GST_AUDIO_CHANNEL_POSITION_TOP_FRONT_LEFT", "12"), + ("GST_AUDIO_CHANNEL_POSITION_TOP_FRONT_RIGHT", "13"), + ("GST_AUDIO_CHANNEL_POSITION_TOP_REAR_CENTER", "20"), + ("GST_AUDIO_CHANNEL_POSITION_TOP_REAR_LEFT", "16"), + ("GST_AUDIO_CHANNEL_POSITION_TOP_REAR_RIGHT", "17"), + ("GST_AUDIO_CHANNEL_POSITION_TOP_SIDE_LEFT", "18"), + ("GST_AUDIO_CHANNEL_POSITION_TOP_SIDE_RIGHT", "19"), + ("GST_AUDIO_CHANNEL_POSITION_WIDE_LEFT", "24"), + ("GST_AUDIO_CHANNEL_POSITION_WIDE_RIGHT", "25"), + ("GST_AUDIO_CONVERTER_FLAG_IN_WRITABLE", "1"), + ("GST_AUDIO_CONVERTER_FLAG_NONE", "0"), + ("GST_AUDIO_CONVERTER_FLAG_VARIABLE_RATE", "2"), + ("GST_AUDIO_CONVERTER_OPT_DITHER_METHOD", "GstAudioConverter.dither-method"), + ("GST_AUDIO_CONVERTER_OPT_MIX_MATRIX", "GstAudioConverter.mix-matrix"), + ("GST_AUDIO_CONVERTER_OPT_NOISE_SHAPING_METHOD", "GstAudioConverter.noise-shaping-method"), + ("GST_AUDIO_CONVERTER_OPT_QUANTIZATION", "GstAudioConverter.quantization"), + ("GST_AUDIO_CONVERTER_OPT_RESAMPLER_METHOD", "GstAudioConverter.resampler-method"), + ("GST_AUDIO_DECODER_MAX_ERRORS", "10"), + ("GST_AUDIO_DECODER_SINK_NAME", "sink"), + ("GST_AUDIO_DECODER_SRC_NAME", "src"), + ("GST_AUDIO_DEF_CHANNELS", "2"), + ("GST_AUDIO_DEF_FORMAT", "S16LE"), + ("GST_AUDIO_DEF_RATE", "44100"), + ("GST_AUDIO_DITHER_NONE", "0"), + ("GST_AUDIO_DITHER_RPDF", "1"), + ("GST_AUDIO_DITHER_TPDF", "2"), + ("GST_AUDIO_DITHER_TPDF_HF", "3"), + ("GST_AUDIO_ENCODER_SINK_NAME", "sink"), + ("GST_AUDIO_ENCODER_SRC_NAME", "src"), + ("GST_AUDIO_FLAG_NONE", "0"), + ("GST_AUDIO_FLAG_UNPOSITIONED", "1"), + ("GST_AUDIO_FORMATS_ALL", " { S8, U8, S16LE, S16BE, U16LE, U16BE, S24_32LE, S24_32BE, U24_32LE, U24_32BE, S32LE, S32BE, U32LE, U32BE, S24LE, S24BE, U24LE, U24BE, S20LE, S20BE, U20LE, U20BE, S18LE, S18BE, U18LE, U18BE, F32LE, F32BE, F64LE, F64BE }"), + ("GST_AUDIO_FORMAT_ENCODED", "1"), + ("GST_AUDIO_FORMAT_F32", "28"), + ("GST_AUDIO_FORMAT_F32BE", "29"), + ("GST_AUDIO_FORMAT_F32LE", "28"), + ("GST_AUDIO_FORMAT_F64", "30"), + ("GST_AUDIO_FORMAT_F64BE", "31"), + ("GST_AUDIO_FORMAT_F64LE", "30"), + ("GST_AUDIO_FORMAT_FLAG_COMPLEX", "16"), + ("GST_AUDIO_FORMAT_FLAG_FLOAT", "2"), + ("GST_AUDIO_FORMAT_FLAG_INTEGER", "1"), + ("GST_AUDIO_FORMAT_FLAG_SIGNED", "4"), + ("GST_AUDIO_FORMAT_FLAG_UNPACK", "32"), + ("GST_AUDIO_FORMAT_S16", "4"), + ("GST_AUDIO_FORMAT_S16BE", "5"), + ("GST_AUDIO_FORMAT_S16LE", "4"), + ("GST_AUDIO_FORMAT_S18", "24"), + ("GST_AUDIO_FORMAT_S18BE", "25"), + ("GST_AUDIO_FORMAT_S18LE", "24"), + ("GST_AUDIO_FORMAT_S20", "20"), + ("GST_AUDIO_FORMAT_S20BE", "21"), + ("GST_AUDIO_FORMAT_S20LE", "20"), + ("GST_AUDIO_FORMAT_S24", "16"), + ("GST_AUDIO_FORMAT_S24BE", "17"), + ("GST_AUDIO_FORMAT_S24LE", "16"), + ("GST_AUDIO_FORMAT_S24_32", "8"), + ("GST_AUDIO_FORMAT_S24_32BE", "9"), + ("GST_AUDIO_FORMAT_S24_32LE", "8"), + ("GST_AUDIO_FORMAT_S32", "12"), + ("GST_AUDIO_FORMAT_S32BE", "13"), + ("GST_AUDIO_FORMAT_S32LE", "12"), + ("GST_AUDIO_FORMAT_S8", "2"), + ("GST_AUDIO_FORMAT_U16", "6"), + ("GST_AUDIO_FORMAT_U16BE", "7"), + ("GST_AUDIO_FORMAT_U16LE", "6"), + ("GST_AUDIO_FORMAT_U18", "26"), + ("GST_AUDIO_FORMAT_U18BE", "27"), + ("GST_AUDIO_FORMAT_U18LE", "26"), + ("GST_AUDIO_FORMAT_U20", "22"), + ("GST_AUDIO_FORMAT_U20BE", "23"), + ("GST_AUDIO_FORMAT_U20LE", "22"), + ("GST_AUDIO_FORMAT_U24", "18"), + ("GST_AUDIO_FORMAT_U24BE", "19"), + ("GST_AUDIO_FORMAT_U24LE", "18"), + ("GST_AUDIO_FORMAT_U24_32", "10"), + ("GST_AUDIO_FORMAT_U24_32BE", "11"), + ("GST_AUDIO_FORMAT_U24_32LE", "10"), + ("GST_AUDIO_FORMAT_U32", "14"), + ("GST_AUDIO_FORMAT_U32BE", "15"), + ("GST_AUDIO_FORMAT_U32LE", "14"), + ("GST_AUDIO_FORMAT_U8", "3"), + ("GST_AUDIO_FORMAT_UNKNOWN", "0"), + ("GST_AUDIO_LAYOUT_INTERLEAVED", "0"), + ("GST_AUDIO_LAYOUT_NON_INTERLEAVED", "1"), + ("GST_AUDIO_NOISE_SHAPING_ERROR_FEEDBACK", "1"), + ("GST_AUDIO_NOISE_SHAPING_HIGH", "4"), + ("GST_AUDIO_NOISE_SHAPING_MEDIUM", "3"), + ("GST_AUDIO_NOISE_SHAPING_NONE", "0"), + ("GST_AUDIO_NOISE_SHAPING_SIMPLE", "2"), + ("GST_AUDIO_PACK_FLAG_NONE", "0"), + ("GST_AUDIO_PACK_FLAG_TRUNCATE_RANGE", "1"), + ("GST_AUDIO_QUANTIZE_FLAG_NONE", "0"), + ("GST_AUDIO_QUANTIZE_FLAG_NON_INTERLEAVED", "1"), + ("GST_AUDIO_RATE_RANGE", "(int) [ 1, max ]"), + ("GST_AUDIO_RESAMPLER_FILTER_INTERPOLATION_CUBIC", "2"), + ("GST_AUDIO_RESAMPLER_FILTER_INTERPOLATION_LINEAR", "1"), + ("GST_AUDIO_RESAMPLER_FILTER_INTERPOLATION_NONE", "0"), + ("GST_AUDIO_RESAMPLER_FILTER_MODE_AUTO", "2"), + ("GST_AUDIO_RESAMPLER_FILTER_MODE_FULL", "1"), + ("GST_AUDIO_RESAMPLER_FILTER_MODE_INTERPOLATED", "0"), + ("GST_AUDIO_RESAMPLER_FLAG_NONE", "0"), + ("GST_AUDIO_RESAMPLER_FLAG_NON_INTERLEAVED_IN", "1"), + ("GST_AUDIO_RESAMPLER_FLAG_NON_INTERLEAVED_OUT", "2"), + ("GST_AUDIO_RESAMPLER_FLAG_VARIABLE_RATE", "4"), + ("GST_AUDIO_RESAMPLER_METHOD_BLACKMAN_NUTTALL", "3"), + ("GST_AUDIO_RESAMPLER_METHOD_CUBIC", "2"), + ("GST_AUDIO_RESAMPLER_METHOD_KAISER", "4"), + ("GST_AUDIO_RESAMPLER_METHOD_LINEAR", "1"), + ("GST_AUDIO_RESAMPLER_METHOD_NEAREST", "0"), + ("GST_AUDIO_RESAMPLER_OPT_CUBIC_B", "GstAudioResampler.cubic-b"), + ("GST_AUDIO_RESAMPLER_OPT_CUBIC_C", "GstAudioResampler.cubic-c"), + ("GST_AUDIO_RESAMPLER_OPT_CUTOFF", "GstAudioResampler.cutoff"), + ("GST_AUDIO_RESAMPLER_OPT_FILTER_INTERPOLATION", "GstAudioResampler.filter-interpolation"), + ("GST_AUDIO_RESAMPLER_OPT_FILTER_MODE", "GstAudioResampler.filter-mode"), + ("GST_AUDIO_RESAMPLER_OPT_FILTER_MODE_THRESHOLD", "GstAudioResampler.filter-mode-threshold"), + ("GST_AUDIO_RESAMPLER_OPT_FILTER_OVERSAMPLE", "GstAudioResampler.filter-oversample"), + ("GST_AUDIO_RESAMPLER_OPT_MAX_PHASE_ERROR", "GstAudioResampler.max-phase-error"), + ("GST_AUDIO_RESAMPLER_OPT_N_TAPS", "GstAudioResampler.n-taps"), + ("GST_AUDIO_RESAMPLER_OPT_STOP_ATTENUATION", "GstAudioResampler.stop-attenutation"), + ("GST_AUDIO_RESAMPLER_OPT_TRANSITION_BANDWIDTH", "GstAudioResampler.transition-bandwidth"), + ("GST_AUDIO_RESAMPLER_QUALITY_DEFAULT", "4"), + ("GST_AUDIO_RESAMPLER_QUALITY_MAX", "10"), + ("GST_AUDIO_RESAMPLER_QUALITY_MIN", "0"), + ("GST_AUDIO_RING_BUFFER_FORMAT_TYPE_AC3", "7"), + ("GST_AUDIO_RING_BUFFER_FORMAT_TYPE_A_LAW", "2"), + ("GST_AUDIO_RING_BUFFER_FORMAT_TYPE_DTS", "9"), + ("GST_AUDIO_RING_BUFFER_FORMAT_TYPE_EAC3", "8"), + ("GST_AUDIO_RING_BUFFER_FORMAT_TYPE_FLAC", "14"), + ("GST_AUDIO_RING_BUFFER_FORMAT_TYPE_GSM", "5"), + ("GST_AUDIO_RING_BUFFER_FORMAT_TYPE_IEC958", "6"), + ("GST_AUDIO_RING_BUFFER_FORMAT_TYPE_IMA_ADPCM", "3"), + ("GST_AUDIO_RING_BUFFER_FORMAT_TYPE_MPEG", "4"), + ("GST_AUDIO_RING_BUFFER_FORMAT_TYPE_MPEG2_AAC", "10"), + ("GST_AUDIO_RING_BUFFER_FORMAT_TYPE_MPEG2_AAC_RAW", "12"), + ("GST_AUDIO_RING_BUFFER_FORMAT_TYPE_MPEG4_AAC", "11"), + ("GST_AUDIO_RING_BUFFER_FORMAT_TYPE_MPEG4_AAC_RAW", "13"), + ("GST_AUDIO_RING_BUFFER_FORMAT_TYPE_MU_LAW", "1"), + ("GST_AUDIO_RING_BUFFER_FORMAT_TYPE_RAW", "0"), + ("GST_AUDIO_RING_BUFFER_STATE_ERROR", "3"), + ("GST_AUDIO_RING_BUFFER_STATE_PAUSED", "1"), + ("GST_AUDIO_RING_BUFFER_STATE_STARTED", "2"), + ("GST_AUDIO_RING_BUFFER_STATE_STOPPED", "0"), + ("GST_META_TAG_AUDIO_CHANNELS_STR", "channels"), + ("GST_META_TAG_AUDIO_RATE_STR", "rate"), + ("GST_META_TAG_AUDIO_STR", "audio"), + ("GST_STREAM_VOLUME_FORMAT_CUBIC", "1"), + ("GST_STREAM_VOLUME_FORMAT_DB", "2"), + ("GST_STREAM_VOLUME_FORMAT_LINEAR", "0"), +]; + + diff --git a/gstreamer-audio-sys/tests/constant.c b/gstreamer-audio-sys/tests/constant.c new file mode 100644 index 000000000..f95b609c2 --- /dev/null +++ b/gstreamer-audio-sys/tests/constant.c @@ -0,0 +1,27 @@ +// This file was generated by gir (https://github.com/gtk-rs/gir @ 6855214) +// from gir-files (https://github.com/gtk-rs/gir-files @ ???) +// DO NOT EDIT + +#include "manual.h" +#include + +int main() { + printf(_Generic((ABI_CONSTANT_NAME), + char *: "%s", + const char *: "%s", + char: "%c", + signed char: "%hhd", + unsigned char: "%hhu", + short int: "%hd", + unsigned short int: "%hu", + int: "%d", + unsigned int: "%u", + long: "%ld", + unsigned long: "%lu", + long long: "%lld", + unsigned long long: "%llu", + double: "%f", + long double: "%ld"), + ABI_CONSTANT_NAME); + return 0; +} diff --git a/gstreamer-audio-sys/tests/layout.c b/gstreamer-audio-sys/tests/layout.c new file mode 100644 index 000000000..e4be962df --- /dev/null +++ b/gstreamer-audio-sys/tests/layout.c @@ -0,0 +1,12 @@ +// This file was generated by gir (https://github.com/gtk-rs/gir @ 6855214) +// from gir-files (https://github.com/gtk-rs/gir-files @ ???) +// 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-audio-sys/tests/manual.h b/gstreamer-audio-sys/tests/manual.h new file mode 100644 index 000000000..6e81b7dfd --- /dev/null +++ b/gstreamer-audio-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 diff --git a/gstreamer-base-sys/Cargo.toml b/gstreamer-base-sys/Cargo.toml index f1e4ca2c2..c17ddf6f7 100644 --- a/gstreamer-base-sys/Cargo.toml +++ b/gstreamer-base-sys/Cargo.toml @@ -2,7 +2,6 @@ pkg-config = "0.3.7" [dependencies] -bitflags = "1.0" libc = "0.2" glib-sys = { git = "https://github.com/gtk-rs/sys" } gobject-sys = { git = "https://github.com/gtk-rs/sys" } @@ -10,6 +9,10 @@ gobject-sys = { git = "https://github.com/gtk-rs/sys" } [dependencies.gstreamer-sys] path = "../gstreamer-sys" +[dev-dependencies] +shell-words = "0.1.0" +tempdir = "0.3" + [features] v1_0_1 = [] v1_2 = ["v1_0_1"] diff --git a/gstreamer-base-sys/src/lib.rs b/gstreamer-base-sys/src/lib.rs index b027b1f94..f932fb805 100644 --- a/gstreamer-base-sys/src/lib.rs +++ b/gstreamer-base-sys/src/lib.rs @@ -1,11 +1,10 @@ -// This file was generated by gir (https://github.com/gtk-rs/gir @ fe7a6ff) +// This file was generated by gir (https://github.com/gtk-rs/gir @ 6855214) // 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)] extern crate libc; -#[macro_use] extern crate bitflags; extern crate glib_sys as glib; extern crate gobject_sys as gobject; extern crate gstreamer_sys as gst; @@ -25,51 +24,25 @@ pub const GST_BASE_TRANSFORM_SINK_NAME: *const c_char = b"sink\0" as *const u8 a pub const GST_BASE_TRANSFORM_SRC_NAME: *const c_char = b"src\0" as *const u8 as *const c_char; // Flags -bitflags! { - #[repr(C)] - pub struct GstBaseParseFrameFlags: c_uint { - const NONE = 0; - const NEW_FRAME = 1; - const NO_FRAME = 2; - const CLIP = 4; - const DROP = 8; - const QUEUE = 16; - } -} -pub const GST_BASE_PARSE_FRAME_FLAG_NONE: GstBaseParseFrameFlags = GstBaseParseFrameFlags::NONE; -pub const GST_BASE_PARSE_FRAME_FLAG_NEW_FRAME: GstBaseParseFrameFlags = GstBaseParseFrameFlags::NEW_FRAME; -pub const GST_BASE_PARSE_FRAME_FLAG_NO_FRAME: GstBaseParseFrameFlags = GstBaseParseFrameFlags::NO_FRAME; -pub const GST_BASE_PARSE_FRAME_FLAG_CLIP: GstBaseParseFrameFlags = GstBaseParseFrameFlags::CLIP; -pub const GST_BASE_PARSE_FRAME_FLAG_DROP: GstBaseParseFrameFlags = GstBaseParseFrameFlags::DROP; -pub const GST_BASE_PARSE_FRAME_FLAG_QUEUE: GstBaseParseFrameFlags = GstBaseParseFrameFlags::QUEUE; +pub type GstBaseParseFrameFlags = c_uint; +pub const GST_BASE_PARSE_FRAME_FLAG_NONE: GstBaseParseFrameFlags = 0; +pub const GST_BASE_PARSE_FRAME_FLAG_NEW_FRAME: GstBaseParseFrameFlags = 1; +pub const GST_BASE_PARSE_FRAME_FLAG_NO_FRAME: GstBaseParseFrameFlags = 2; +pub const GST_BASE_PARSE_FRAME_FLAG_CLIP: GstBaseParseFrameFlags = 4; +pub const GST_BASE_PARSE_FRAME_FLAG_DROP: GstBaseParseFrameFlags = 8; +pub const GST_BASE_PARSE_FRAME_FLAG_QUEUE: GstBaseParseFrameFlags = 16; -bitflags! { - #[repr(C)] - pub struct GstBaseSrcFlags: c_uint { - const STARTING = 16384; - const STARTED = 32768; - const LAST = 1048576; - } -} -pub const GST_BASE_SRC_FLAG_STARTING: GstBaseSrcFlags = GstBaseSrcFlags::STARTING; -pub const GST_BASE_SRC_FLAG_STARTED: GstBaseSrcFlags = GstBaseSrcFlags::STARTED; -pub const GST_BASE_SRC_FLAG_LAST: GstBaseSrcFlags = GstBaseSrcFlags::LAST; +pub type GstBaseSrcFlags = c_uint; +pub const GST_BASE_SRC_FLAG_STARTING: GstBaseSrcFlags = 16384; +pub const GST_BASE_SRC_FLAG_STARTED: GstBaseSrcFlags = 32768; +pub const GST_BASE_SRC_FLAG_LAST: GstBaseSrcFlags = 1048576; -bitflags! { - #[repr(C)] - pub struct GstCollectPadsStateFlags: c_uint { - const EOS = 1; - const FLUSHING = 2; - const NEW_SEGMENT = 4; - const WAITING = 8; - const LOCKED = 16; - } -} -pub const GST_COLLECT_PADS_STATE_EOS: GstCollectPadsStateFlags = GstCollectPadsStateFlags::EOS; -pub const GST_COLLECT_PADS_STATE_FLUSHING: GstCollectPadsStateFlags = GstCollectPadsStateFlags::FLUSHING; -pub const GST_COLLECT_PADS_STATE_NEW_SEGMENT: GstCollectPadsStateFlags = GstCollectPadsStateFlags::NEW_SEGMENT; -pub const GST_COLLECT_PADS_STATE_WAITING: GstCollectPadsStateFlags = GstCollectPadsStateFlags::WAITING; -pub const GST_COLLECT_PADS_STATE_LOCKED: GstCollectPadsStateFlags = GstCollectPadsStateFlags::LOCKED; +pub type GstCollectPadsStateFlags = c_uint; +pub const GST_COLLECT_PADS_STATE_EOS: GstCollectPadsStateFlags = 1; +pub const GST_COLLECT_PADS_STATE_FLUSHING: GstCollectPadsStateFlags = 2; +pub const GST_COLLECT_PADS_STATE_NEW_SEGMENT: GstCollectPadsStateFlags = 4; +pub const GST_COLLECT_PADS_STATE_WAITING: GstCollectPadsStateFlags = 8; +pub const GST_COLLECT_PADS_STATE_LOCKED: GstCollectPadsStateFlags = 16; // Unions #[repr(C)] diff --git a/gstreamer-base-sys/tests/abi.rs b/gstreamer-base-sys/tests/abi.rs new file mode 100644 index 000000000..4a7626fca --- /dev/null +++ b/gstreamer-base-sys/tests/abi.rs @@ -0,0 +1,285 @@ +// This file was generated by gir (https://github.com/gtk-rs/gir @ 6855214) +// from gir-files (https://github.com/gtk-rs/gir-files @ ???) +// DO NOT EDIT + +extern crate gstreamer_base_sys; +extern crate shell_words; +extern crate tempdir; +use std::env; +use std::error::Error; +use std::path::Path; +use std::mem::{align_of, size_of}; +use std::process::Command; +use std::str; +use gstreamer_base_sys::*; + +static PACKAGES: &[&str] = &["gstreamer-base-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 = tempdir::TempDir::new("abi").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 = tempdir::TempDir::new("abi").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()); + } + + Ok(str::from_utf8(&output.stdout)?.trim().to_owned()) +} + +const RUST_LAYOUTS: &[(&str, Layout)] = &[ + ("GstAggregator", Layout {size: size_of::(), alignment: align_of::()}), + ("GstAggregatorClass", Layout {size: size_of::(), alignment: align_of::()}), + ("GstAggregatorPad", Layout {size: size_of::(), alignment: align_of::()}), + ("GstAggregatorPadClass", Layout {size: size_of::(), alignment: align_of::()}), + ("GstBaseParse", Layout {size: size_of::(), alignment: align_of::()}), + ("GstBaseParseClass", Layout {size: size_of::(), alignment: align_of::()}), + ("GstBaseParseFrame", Layout {size: size_of::(), alignment: align_of::()}), + ("GstBaseParseFrameFlags", Layout {size: size_of::(), alignment: align_of::()}), + ("GstBaseSink", Layout {size: size_of::(), alignment: align_of::()}), + ("GstBaseSinkClass", Layout {size: size_of::(), alignment: align_of::()}), + ("GstBaseSrc", Layout {size: size_of::(), alignment: align_of::()}), + ("GstBaseSrcClass", Layout {size: size_of::(), alignment: align_of::()}), + ("GstBaseSrcFlags", Layout {size: size_of::(), alignment: align_of::()}), + ("GstBaseTransform", Layout {size: size_of::(), alignment: align_of::()}), + ("GstBaseTransformClass", Layout {size: size_of::(), alignment: align_of::()}), + ("GstBitReader", Layout {size: size_of::(), alignment: align_of::()}), + ("GstByteReader", Layout {size: size_of::(), alignment: align_of::()}), + ("GstByteWriter", Layout {size: size_of::(), alignment: align_of::()}), + ("GstCollectData", Layout {size: size_of::(), alignment: align_of::()}), + ("GstCollectPads", Layout {size: size_of::(), alignment: align_of::()}), + ("GstCollectPadsClass", Layout {size: size_of::(), alignment: align_of::()}), + ("GstCollectPadsStateFlags", Layout {size: size_of::(), alignment: align_of::()}), + ("GstDataQueue", Layout {size: size_of::(), alignment: align_of::()}), + ("GstDataQueueClass", Layout {size: size_of::(), alignment: align_of::()}), + ("GstDataQueueItem", Layout {size: size_of::(), alignment: align_of::()}), + ("GstDataQueueSize", Layout {size: size_of::(), alignment: align_of::()}), + ("GstPushSrc", Layout {size: size_of::(), alignment: align_of::()}), + ("GstPushSrcClass", Layout {size: size_of::(), alignment: align_of::()}), +]; + +const RUST_CONSTANTS: &[(&str, &str)] = &[ + ("GST_BASE_PARSE_FLAG_DRAINING", "2"), + ("GST_BASE_PARSE_FLAG_LOST_SYNC", "1"), + ("GST_BASE_PARSE_FRAME_FLAG_CLIP", "4"), + ("GST_BASE_PARSE_FRAME_FLAG_DROP", "8"), + ("GST_BASE_PARSE_FRAME_FLAG_NEW_FRAME", "1"), + ("GST_BASE_PARSE_FRAME_FLAG_NONE", "0"), + ("GST_BASE_PARSE_FRAME_FLAG_NO_FRAME", "2"), + ("GST_BASE_PARSE_FRAME_FLAG_QUEUE", "16"), + ("GST_BASE_SRC_FLAG_LAST", "1048576"), + ("GST_BASE_SRC_FLAG_STARTED", "32768"), + ("GST_BASE_SRC_FLAG_STARTING", "16384"), + ("GST_BASE_TRANSFORM_SINK_NAME", "sink"), + ("GST_BASE_TRANSFORM_SRC_NAME", "src"), + ("GST_COLLECT_PADS_STATE_EOS", "1"), + ("GST_COLLECT_PADS_STATE_FLUSHING", "2"), + ("GST_COLLECT_PADS_STATE_LOCKED", "16"), + ("GST_COLLECT_PADS_STATE_NEW_SEGMENT", "4"), + ("GST_COLLECT_PADS_STATE_WAITING", "8"), +]; + + diff --git a/gstreamer-base-sys/tests/constant.c b/gstreamer-base-sys/tests/constant.c new file mode 100644 index 000000000..f95b609c2 --- /dev/null +++ b/gstreamer-base-sys/tests/constant.c @@ -0,0 +1,27 @@ +// This file was generated by gir (https://github.com/gtk-rs/gir @ 6855214) +// from gir-files (https://github.com/gtk-rs/gir-files @ ???) +// DO NOT EDIT + +#include "manual.h" +#include + +int main() { + printf(_Generic((ABI_CONSTANT_NAME), + char *: "%s", + const char *: "%s", + char: "%c", + signed char: "%hhd", + unsigned char: "%hhu", + short int: "%hd", + unsigned short int: "%hu", + int: "%d", + unsigned int: "%u", + long: "%ld", + unsigned long: "%lu", + long long: "%lld", + unsigned long long: "%llu", + double: "%f", + long double: "%ld"), + ABI_CONSTANT_NAME); + return 0; +} diff --git a/gstreamer-base-sys/tests/layout.c b/gstreamer-base-sys/tests/layout.c new file mode 100644 index 000000000..e4be962df --- /dev/null +++ b/gstreamer-base-sys/tests/layout.c @@ -0,0 +1,12 @@ +// This file was generated by gir (https://github.com/gtk-rs/gir @ 6855214) +// from gir-files (https://github.com/gtk-rs/gir-files @ ???) +// 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-base-sys/tests/manual.h b/gstreamer-base-sys/tests/manual.h new file mode 100644 index 000000000..144bbeeed --- /dev/null +++ b/gstreamer-base-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 diff --git a/gstreamer-mpegts-sys/Cargo.toml b/gstreamer-mpegts-sys/Cargo.toml index 6d8c8a8f9..520e32d4c 100644 --- a/gstreamer-mpegts-sys/Cargo.toml +++ b/gstreamer-mpegts-sys/Cargo.toml @@ -16,6 +16,10 @@ path = "../gstreamer-base-sys" [dependencies.gstreamer-sys] path = "../gstreamer-sys" +[dev-dependencies] +shell-words = "0.1.0" +tempdir = "0.3" + [features] v1_2 = [] v1_4 = ["v1_2"] diff --git a/gstreamer-mpegts-sys/src/lib.rs b/gstreamer-mpegts-sys/src/lib.rs index e626dc991..32939215e 100644 --- a/gstreamer-mpegts-sys/src/lib.rs +++ b/gstreamer-mpegts-sys/src/lib.rs @@ -1,4 +1,4 @@ -// This file was generated by gir (https://github.com/gtk-rs/gir @ fe7a6ff) +// This file was generated by gir (https://github.com/gtk-rs/gir @ 6855214) // from gir-files (https://github.com/gtk-rs/gir-files @ ???) // DO NOT EDIT diff --git a/gstreamer-mpegts-sys/tests/abi.rs b/gstreamer-mpegts-sys/tests/abi.rs new file mode 100644 index 000000000..2e5321b75 --- /dev/null +++ b/gstreamer-mpegts-sys/tests/abi.rs @@ -0,0 +1,809 @@ +// This file was generated by gir (https://github.com/gtk-rs/gir @ 6855214) +// from gir-files (https://github.com/gtk-rs/gir-files @ ???) +// DO NOT EDIT + +extern crate gstreamer_mpegts_sys; +extern crate shell_words; +extern crate tempdir; +use std::env; +use std::error::Error; +use std::path::Path; +use std::mem::{align_of, size_of}; +use std::process::Command; +use std::str; +use gstreamer_mpegts_sys::*; + +static PACKAGES: &[&str] = &["gstreamer-mpegts-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 = tempdir::TempDir::new("abi").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 = tempdir::TempDir::new("abi").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()); + } + + Ok(str::from_utf8(&output.stdout)?.trim().to_owned()) +} + +const RUST_LAYOUTS: &[(&str, Layout)] = &[ + ("GstMpegtsATSCDescriptorType", Layout {size: size_of::(), alignment: align_of::()}), + ("GstMpegtsAtscEIT", Layout {size: size_of::(), alignment: align_of::()}), + ("GstMpegtsAtscEITEvent", Layout {size: size_of::(), alignment: align_of::()}), + ("GstMpegtsAtscETT", Layout {size: size_of::(), alignment: align_of::()}), + ("GstMpegtsAtscMGT", Layout {size: size_of::(), alignment: align_of::()}), + ("GstMpegtsAtscMGTTable", Layout {size: size_of::(), alignment: align_of::()}), + ("GstMpegtsAtscMGTTableType", Layout {size: size_of::(), alignment: align_of::()}), + ("GstMpegtsAtscMultString", Layout {size: size_of::(), alignment: align_of::()}), + ("GstMpegtsAtscSTT", Layout {size: size_of::(), alignment: align_of::()}), + ("GstMpegtsAtscStringSegment", Layout {size: size_of::(), alignment: align_of::()}), + ("GstMpegtsAtscVCT", Layout {size: size_of::(), alignment: align_of::()}), + ("GstMpegtsAtscVCTSource", Layout {size: size_of::(), alignment: align_of::()}), + ("GstMpegtsBAT", Layout {size: size_of::(), alignment: align_of::()}), + ("GstMpegtsBATStream", Layout {size: size_of::(), alignment: align_of::()}), + ("GstMpegtsCableDeliverySystemDescriptor", Layout {size: size_of::(), alignment: align_of::()}), + ("GstMpegtsCableOuterFECScheme", Layout {size: size_of::(), alignment: align_of::()}), + ("GstMpegtsComponentDescriptor", Layout {size: size_of::(), alignment: align_of::()}), + ("GstMpegtsComponentStreamContent", Layout {size: size_of::(), alignment: align_of::()}), + ("GstMpegtsContent", Layout {size: size_of::(), alignment: align_of::()}), + ("GstMpegtsContentNibbleHi", Layout {size: size_of::(), alignment: align_of::()}), + ("GstMpegtsDVBCodeRate", Layout {size: size_of::(), alignment: align_of::()}), + ("GstMpegtsDVBDescriptorType", Layout {size: size_of::(), alignment: align_of::()}), + ("GstMpegtsDVBExtendedDescriptorType", Layout {size: size_of::(), alignment: align_of::()}), + ("GstMpegtsDVBLinkageDescriptor", Layout {size: size_of::(), alignment: align_of::()}), + ("GstMpegtsDVBLinkageEvent", Layout {size: size_of::(), alignment: align_of::()}), + ("GstMpegtsDVBLinkageExtendedEvent", Layout {size: size_of::(), alignment: align_of::()}), + ("GstMpegtsDVBLinkageHandOverType", Layout {size: size_of::(), alignment: align_of::()}), + ("GstMpegtsDVBLinkageMobileHandOver", Layout {size: size_of::(), alignment: align_of::()}), + ("GstMpegtsDVBLinkageType", Layout {size: size_of::(), alignment: align_of::()}), + ("GstMpegtsDVBParentalRatingItem", Layout {size: size_of::(), alignment: align_of::()}), + ("GstMpegtsDVBScramblingModeType", Layout {size: size_of::(), alignment: align_of::()}), + ("GstMpegtsDVBServiceListItem", Layout {size: size_of::(), alignment: align_of::()}), + ("GstMpegtsDVBServiceType", Layout {size: size_of::(), alignment: align_of::()}), + ("GstMpegtsDVBTeletextType", Layout {size: size_of::(), alignment: align_of::()}), + ("GstMpegtsDataBroadcastDescriptor", Layout {size: size_of::(), alignment: align_of::()}), + ("GstMpegtsDescriptor", Layout {size: size_of::(), alignment: align_of::()}), + ("GstMpegtsDescriptorType", Layout {size: size_of::(), alignment: align_of::()}), + ("GstMpegtsDvbMultilingualBouquetNameItem", Layout {size: size_of::(), alignment: align_of::()}), + ("GstMpegtsDvbMultilingualComponentItem", Layout {size: size_of::(), alignment: align_of::()}), + ("GstMpegtsDvbMultilingualNetworkNameItem", Layout {size: size_of::(), alignment: align_of::()}), + ("GstMpegtsDvbMultilingualServiceNameItem", Layout {size: size_of::(), alignment: align_of::()}), + ("GstMpegtsEIT", Layout {size: size_of::(), alignment: align_of::()}), + ("GstMpegtsEITEvent", Layout {size: size_of::(), alignment: align_of::()}), + ("GstMpegtsExtendedEventDescriptor", Layout {size: size_of::(), alignment: align_of::()}), + ("GstMpegtsExtendedEventItem", Layout {size: size_of::(), alignment: align_of::()}), + ("GstMpegtsISDBDescriptorType", Layout {size: size_of::(), alignment: align_of::()}), + ("GstMpegtsISO639LanguageDescriptor", Layout {size: size_of::(), alignment: align_of::()}), + ("GstMpegtsIso639AudioType", Layout {size: size_of::(), alignment: align_of::()}), + ("GstMpegtsLogicalChannel", Layout {size: size_of::(), alignment: align_of::()}), + ("GstMpegtsLogicalChannelDescriptor", Layout {size: size_of::(), alignment: align_of::()}), + ("GstMpegtsMiscDescriptorType", Layout {size: size_of::(), alignment: align_of::()}), + ("GstMpegtsModulationType", Layout {size: size_of::(), alignment: align_of::()}), + ("GstMpegtsNIT", Layout {size: size_of::(), alignment: align_of::()}), + ("GstMpegtsNITStream", Layout {size: size_of::(), alignment: align_of::()}), + ("GstMpegtsPMT", Layout {size: size_of::(), alignment: align_of::()}), + ("GstMpegtsPMTStream", Layout {size: size_of::(), alignment: align_of::()}), + ("GstMpegtsPatProgram", Layout {size: size_of::(), alignment: align_of::()}), + ("GstMpegtsRunningStatus", Layout {size: size_of::(), alignment: align_of::()}), + ("GstMpegtsSDT", Layout {size: size_of::(), alignment: align_of::()}), + ("GstMpegtsSDTService", Layout {size: size_of::(), alignment: align_of::()}), + ("GstMpegtsSatelliteDeliverySystemDescriptor", Layout {size: size_of::(), alignment: align_of::()}), + ("GstMpegtsSatellitePolarizationType", Layout {size: size_of::(), alignment: align_of::()}), + ("GstMpegtsSatelliteRolloff", Layout {size: size_of::(), alignment: align_of::()}), + ("GstMpegtsScteStreamType", Layout {size: size_of::(), alignment: align_of::()}), + ("GstMpegtsSection", Layout {size: size_of::(), alignment: align_of::()}), + ("GstMpegtsSectionATSCTableID", Layout {size: size_of::(), alignment: align_of::()}), + ("GstMpegtsSectionDVBTableID", Layout {size: size_of::(), alignment: align_of::()}), + ("GstMpegtsSectionSCTETableID", Layout {size: size_of::(), alignment: align_of::()}), + ("GstMpegtsSectionTableID", Layout {size: size_of::(), alignment: align_of::()}), + ("GstMpegtsSectionType", Layout {size: size_of::(), alignment: align_of::()}), + ("GstMpegtsStreamType", Layout {size: size_of::(), alignment: align_of::()}), + ("GstMpegtsT2DeliverySystemCell", Layout {size: size_of::(), alignment: align_of::()}), + ("GstMpegtsT2DeliverySystemCellExtension", Layout {size: size_of::(), alignment: align_of::()}), + ("GstMpegtsT2DeliverySystemDescriptor", Layout {size: size_of::(), alignment: align_of::()}), + ("GstMpegtsTOT", Layout {size: size_of::(), alignment: align_of::()}), + ("GstMpegtsTerrestrialDeliverySystemDescriptor", Layout {size: size_of::(), alignment: align_of::()}), + ("GstMpegtsTerrestrialGuardInterval", Layout {size: size_of::(), alignment: align_of::()}), + ("GstMpegtsTerrestrialHierarchy", Layout {size: size_of::(), alignment: align_of::()}), + ("GstMpegtsTerrestrialTransmissionMode", Layout {size: size_of::(), alignment: align_of::()}), +]; + +const RUST_CONSTANTS: &[(&str, &str)] = &[ + ("ADDITIONAL_INFO_PAGE", "3"), + ("GST_DVB_SERVICE_ADVANCED_CODEC_DIGITAL_RADIO_SOUND", "10"), + ("GST_DVB_SERVICE_ADVANCED_CODEC_HD_DIGITAL_TELEVISION", "25"), + ("GST_DVB_SERVICE_ADVANCED_CODEC_HD_NVOD_REFERENCE", "27"), + ("GST_DVB_SERVICE_ADVANCED_CODEC_HD_NVOD_TIME_SHIFTED", "26"), + ("GST_DVB_SERVICE_ADVANCED_CODEC_MOSAIC", "11"), + ("GST_DVB_SERVICE_ADVANCED_CODEC_SD_DIGITAL_TELEVISION", "22"), + ("GST_DVB_SERVICE_ADVANCED_CODEC_SD_NVOD_REFERENCE", "24"), + ("GST_DVB_SERVICE_ADVANCED_CODEC_SD_NVOD_TIME_SHIFTED", "23"), + ("GST_DVB_SERVICE_ADVANCED_CODEC_STEREO_HD_DIGITAL_TELEVISION", "28"), + ("GST_DVB_SERVICE_ADVANCED_CODEC_STEREO_HD_NVOD_REFERENCE", "30"), + ("GST_DVB_SERVICE_ADVANCED_CODEC_STEREO_HD_NVOD_TIME_SHIFTED", "29"), + ("GST_DVB_SERVICE_DATA_BROADCAST", "12"), + ("GST_DVB_SERVICE_DIGITAL_RADIO_SOUND", "2"), + ("GST_DVB_SERVICE_DIGITAL_TELEVISION", "1"), + ("GST_DVB_SERVICE_DVB_MHP", "16"), + ("GST_DVB_SERVICE_DVB_SRM", "8"), + ("GST_DVB_SERVICE_FM_RADIO", "7"), + ("GST_DVB_SERVICE_MOSAIC", "6"), + ("GST_DVB_SERVICE_MPEG2_HD_DIGITAL_TELEVISION", "17"), + ("GST_DVB_SERVICE_NVOD_REFERENCE", "4"), + ("GST_DVB_SERVICE_NVOD_TIME_SHIFTED", "5"), + ("GST_DVB_SERVICE_RCS_FLS", "15"), + ("GST_DVB_SERVICE_RCS_MAP", "14"), + ("GST_DVB_SERVICE_RESERVED_00", "0"), + ("GST_DVB_SERVICE_RESERVED_09", "9"), + ("GST_DVB_SERVICE_RESERVED_0D_COMMON_INTERFACE", "13"), + ("GST_DVB_SERVICE_RESERVED_FF", "31"), + ("GST_DVB_SERVICE_TELETEXT", "3"), + ("GST_MPEGTS_ATSC_MGT_TABLE_TYPE_EIT0", "256"), + ("GST_MPEGTS_ATSC_MGT_TABLE_TYPE_EIT127", "383"), + ("GST_MPEGTS_ATSC_MGT_TABLE_TYPE_ETT0", "512"), + ("GST_MPEGTS_ATSC_MGT_TABLE_TYPE_ETT127", "639"), + ("GST_MPEGTS_AUDIO_TYPE_CLEAN_EFFECTS", "1"), + ("GST_MPEGTS_AUDIO_TYPE_HEARING_IMPAIRED", "2"), + ("GST_MPEGTS_AUDIO_TYPE_UNDEFINED", "0"), + ("GST_MPEGTS_AUDIO_TYPE_VISUAL_IMPAIRED_COMMENTARY", "3"), + ("GST_MPEGTS_CABLE_OUTER_FEC_NONE", "1"), + ("GST_MPEGTS_CABLE_OUTER_FEC_RS_204_188", "2"), + ("GST_MPEGTS_CABLE_OUTER_FEC_UNDEFINED", "0"), + ("GST_MPEGTS_CONTENT_ARTS_CULTURE", "7"), + ("GST_MPEGTS_CONTENT_CHILDREN_YOUTH_PROGRAM", "5"), + ("GST_MPEGTS_CONTENT_EDUCATION_SCIENCE_FACTUAL", "9"), + ("GST_MPEGTS_CONTENT_LEISURE_HOBBIES", "10"), + ("GST_MPEGTS_CONTENT_MOVIE_DRAMA", "1"), + ("GST_MPEGTS_CONTENT_MUSIC_BALLET_DANCE", "6"), + ("GST_MPEGTS_CONTENT_NEWS_CURRENT_AFFAIRS", "2"), + ("GST_MPEGTS_CONTENT_SHOW_GAME_SHOW", "3"), + ("GST_MPEGTS_CONTENT_SOCIAL_POLITICAL_ECONOMICS", "8"), + ("GST_MPEGTS_CONTENT_SPECIAL_CHARACTERISTICS", "11"), + ("GST_MPEGTS_CONTENT_SPORTS", "4"), + ("GST_MPEGTS_DVB_LINKAGE_CA_REPLACEMENT", "3"), + ("GST_MPEGTS_DVB_LINKAGE_DATA_BROADCAST", "6"), + ("GST_MPEGTS_DVB_LINKAGE_EPG", "2"), + ("GST_MPEGTS_DVB_LINKAGE_EVENT", "13"), + ("GST_MPEGTS_DVB_LINKAGE_EXTENDED_EVENT", "14"), + ("GST_MPEGTS_DVB_LINKAGE_HAND_OVER_ASSOCIATED", "3"), + ("GST_MPEGTS_DVB_LINKAGE_HAND_OVER_IDENTICAL", "1"), + ("GST_MPEGTS_DVB_LINKAGE_HAND_OVER_LOCAL_VARIATION", "2"), + ("GST_MPEGTS_DVB_LINKAGE_HAND_OVER_RESERVED", "0"), + ("GST_MPEGTS_DVB_LINKAGE_INFORMATION", "1"), + ("GST_MPEGTS_DVB_LINKAGE_IP_MAC_NOTIFICATION", "11"), + ("GST_MPEGTS_DVB_LINKAGE_MOBILE_HAND_OVER", "8"), + ("GST_MPEGTS_DVB_LINKAGE_RCS_MAP", "7"), + ("GST_MPEGTS_DVB_LINKAGE_RESERVED_00", "0"), + ("GST_MPEGTS_DVB_LINKAGE_SERVICE_REPLACEMENT", "5"), + ("GST_MPEGTS_DVB_LINKAGE_SYSTEM_SOFTWARE_UPDATE", "9"), + ("GST_MPEGTS_DVB_LINKAGE_TS_CONTAINING_COMPLETE_SI", "4"), + ("GST_MPEGTS_DVB_LINKAGE_TS_CONTAINING_INT", "12"), + ("GST_MPEGTS_DVB_LINKAGE_TS_CONTAINING_SSU", "10"), + ("GST_MPEGTS_DVB_SCRAMBLING_MODE_ATIS_0", "112"), + ("GST_MPEGTS_DVB_SCRAMBLING_MODE_ATIS_F", "127"), + ("GST_MPEGTS_DVB_SCRAMBLING_MODE_CISSA", "16"), + ("GST_MPEGTS_DVB_SCRAMBLING_MODE_CSA1", "1"), + ("GST_MPEGTS_DVB_SCRAMBLING_MODE_CSA2", "2"), + ("GST_MPEGTS_DVB_SCRAMBLING_MODE_CSA3_FULL_ENHANCED", "5"), + ("GST_MPEGTS_DVB_SCRAMBLING_MODE_CSA3_MINIMAL_ENHANCED", "4"), + ("GST_MPEGTS_DVB_SCRAMBLING_MODE_CSA3_STANDARD", "3"), + ("GST_MPEGTS_DVB_SCRAMBLING_MODE_RESERVED", "0"), + ("GST_MPEGTS_FEC_1_2", "1"), + ("GST_MPEGTS_FEC_2_3", "2"), + ("GST_MPEGTS_FEC_2_5", "12"), + ("GST_MPEGTS_FEC_3_4", "3"), + ("GST_MPEGTS_FEC_3_5", "10"), + ("GST_MPEGTS_FEC_4_5", "4"), + ("GST_MPEGTS_FEC_5_6", "5"), + ("GST_MPEGTS_FEC_6_7", "6"), + ("GST_MPEGTS_FEC_7_8", "7"), + ("GST_MPEGTS_FEC_8_9", "8"), + ("GST_MPEGTS_FEC_9_10", "11"), + ("GST_MPEGTS_FEC_AUTO", "9"), + ("GST_MPEGTS_FEC_NONE", "0"), + ("GST_MPEGTS_GUARD_INTERVAL_19_128", "6"), + ("GST_MPEGTS_GUARD_INTERVAL_19_256", "7"), + ("GST_MPEGTS_GUARD_INTERVAL_1_128", "5"), + ("GST_MPEGTS_GUARD_INTERVAL_1_16", "1"), + ("GST_MPEGTS_GUARD_INTERVAL_1_32", "0"), + ("GST_MPEGTS_GUARD_INTERVAL_1_4", "3"), + ("GST_MPEGTS_GUARD_INTERVAL_1_8", "2"), + ("GST_MPEGTS_GUARD_INTERVAL_AUTO", "4"), + ("GST_MPEGTS_GUARD_INTERVAL_PN420", "8"), + ("GST_MPEGTS_GUARD_INTERVAL_PN595", "9"), + ("GST_MPEGTS_GUARD_INTERVAL_PN945", "10"), + ("GST_MPEGTS_HIERARCHY_1", "1"), + ("GST_MPEGTS_HIERARCHY_2", "2"), + ("GST_MPEGTS_HIERARCHY_4", "3"), + ("GST_MPEGTS_HIERARCHY_AUTO", "4"), + ("GST_MPEGTS_HIERARCHY_NONE", "0"), + ("GST_MPEGTS_MODULATION_APSK_16", "10"), + ("GST_MPEGTS_MODULATION_APSK_32", "11"), + ("GST_MPEGTS_MODULATION_DQPSK", "12"), + ("GST_MPEGTS_MODULATION_NONE", "14"), + ("GST_MPEGTS_MODULATION_PSK_8", "9"), + ("GST_MPEGTS_MODULATION_QAM_128", "4"), + ("GST_MPEGTS_MODULATION_QAM_16", "1"), + ("GST_MPEGTS_MODULATION_QAM_256", "5"), + ("GST_MPEGTS_MODULATION_QAM_32", "2"), + ("GST_MPEGTS_MODULATION_QAM_4_NR_", "13"), + ("GST_MPEGTS_MODULATION_QAM_64", "3"), + ("GST_MPEGTS_MODULATION_QAM_AUTO", "6"), + ("GST_MPEGTS_MODULATION_QPSK", "0"), + ("GST_MPEGTS_MODULATION_VSB_16", "8"), + ("GST_MPEGTS_MODULATION_VSB_8", "7"), + ("GST_MPEGTS_POLARIZATION_CIRCULAR_LEFT", "2"), + ("GST_MPEGTS_POLARIZATION_CIRCULAR_RIGHT", "3"), + ("GST_MPEGTS_POLARIZATION_LINEAR_HORIZONTAL", "0"), + ("GST_MPEGTS_POLARIZATION_LINEAR_VERTICAL", "1"), + ("GST_MPEGTS_ROLLOFF_20", "1"), + ("GST_MPEGTS_ROLLOFF_25", "2"), + ("GST_MPEGTS_ROLLOFF_35", "0"), + ("GST_MPEGTS_ROLLOFF_AUTO", "4"), + ("GST_MPEGTS_ROLLOFF_RESERVED", "3"), + ("GST_MPEGTS_RUNNING_STATUS_NOT_RUNNING", "1"), + ("GST_MPEGTS_RUNNING_STATUS_OFF_AIR", "5"), + ("GST_MPEGTS_RUNNING_STATUS_PAUSING", "3"), + ("GST_MPEGTS_RUNNING_STATUS_RUNNING", "4"), + ("GST_MPEGTS_RUNNING_STATUS_STARTS_IN_FEW_SECONDS", "2"), + ("GST_MPEGTS_RUNNING_STATUS_UNDEFINED", "0"), + ("GST_MPEGTS_SECTION_ATSC_CVCT", "12"), + ("GST_MPEGTS_SECTION_ATSC_EIT", "15"), + ("GST_MPEGTS_SECTION_ATSC_ETT", "14"), + ("GST_MPEGTS_SECTION_ATSC_MGT", "13"), + ("GST_MPEGTS_SECTION_ATSC_STT", "16"), + ("GST_MPEGTS_SECTION_ATSC_TVCT", "11"), + ("GST_MPEGTS_SECTION_BAT", "7"), + ("GST_MPEGTS_SECTION_CAT", "3"), + ("GST_MPEGTS_SECTION_EIT", "5"), + ("GST_MPEGTS_SECTION_NIT", "6"), + ("GST_MPEGTS_SECTION_PAT", "1"), + ("GST_MPEGTS_SECTION_PMT", "2"), + ("GST_MPEGTS_SECTION_SDT", "8"), + ("GST_MPEGTS_SECTION_TDT", "9"), + ("GST_MPEGTS_SECTION_TOT", "10"), + ("GST_MPEGTS_SECTION_TSDT", "4"), + ("GST_MPEGTS_SECTION_UNKNOWN", "0"), + ("GST_MPEGTS_STREAM_CONTENT_AAC", "6"), + ("GST_MPEGTS_STREAM_CONTENT_AC_3", "4"), + ("GST_MPEGTS_STREAM_CONTENT_AVC", "5"), + ("GST_MPEGTS_STREAM_CONTENT_DTS", "7"), + ("GST_MPEGTS_STREAM_CONTENT_MPEG1_LAYER2_AUDIO", "2"), + ("GST_MPEGTS_STREAM_CONTENT_MPEG2_VIDEO", "1"), + ("GST_MPEGTS_STREAM_CONTENT_SRM_CPCM", "8"), + ("GST_MPEGTS_STREAM_CONTENT_TELETEXT_OR_SUBTITLE", "3"), + ("GST_MPEGTS_STREAM_TYPE_AUDIO_AAC_ADTS", "15"), + ("GST_MPEGTS_STREAM_TYPE_AUDIO_AAC_CLEAN", "28"), + ("GST_MPEGTS_STREAM_TYPE_AUDIO_AAC_LATM", "17"), + ("GST_MPEGTS_STREAM_TYPE_AUDIO_MPEG1", "3"), + ("GST_MPEGTS_STREAM_TYPE_AUDIO_MPEG2", "4"), + ("GST_MPEGTS_STREAM_TYPE_AUXILIARY", "14"), + ("GST_MPEGTS_STREAM_TYPE_DSMCC_A", "10"), + ("GST_MPEGTS_STREAM_TYPE_DSMCC_B", "11"), + ("GST_MPEGTS_STREAM_TYPE_DSMCC_C", "12"), + ("GST_MPEGTS_STREAM_TYPE_DSMCC_D", "13"), + ("GST_MPEGTS_STREAM_TYPE_DSM_CC", "8"), + ("GST_MPEGTS_STREAM_TYPE_H_222_1", "9"), + ("GST_MPEGTS_STREAM_TYPE_IPMP_STREAM", "127"), + ("GST_MPEGTS_STREAM_TYPE_METADATA_DATA_CAROUSEL", "23"), + ("GST_MPEGTS_STREAM_TYPE_METADATA_OBJECT_CAROUSEL", "24"), + ("GST_MPEGTS_STREAM_TYPE_METADATA_PES_PACKETS", "21"), + ("GST_MPEGTS_STREAM_TYPE_METADATA_SECTIONS", "22"), + ("GST_MPEGTS_STREAM_TYPE_METADATA_SYNCHRONIZED_DOWNLOAD", "25"), + ("GST_MPEGTS_STREAM_TYPE_MHEG", "7"), + ("GST_MPEGTS_STREAM_TYPE_MPEG2_IPMP", "26"), + ("GST_MPEGTS_STREAM_TYPE_MPEG4_TIMED_TEXT", "29"), + ("GST_MPEGTS_STREAM_TYPE_PRIVATE_PES_PACKETS", "6"), + ("GST_MPEGTS_STREAM_TYPE_PRIVATE_SECTIONS", "5"), + ("GST_MPEGTS_STREAM_TYPE_RESERVED_00", "0"), + ("GST_MPEGTS_STREAM_TYPE_SCTE_ASYNC_DATA", "195"), + ("GST_MPEGTS_STREAM_TYPE_SCTE_DSMCC_DCB", "176"), + ("GST_MPEGTS_STREAM_TYPE_SCTE_DST_NRT", "149"), + ("GST_MPEGTS_STREAM_TYPE_SCTE_ISOCH_DATA", "131"), + ("GST_MPEGTS_STREAM_TYPE_SCTE_SIGNALING", "192"), + ("GST_MPEGTS_STREAM_TYPE_SCTE_SUBTITLING", "130"), + ("GST_MPEGTS_STREAM_TYPE_SCTE_SYNC_DATA", "194"), + ("GST_MPEGTS_STREAM_TYPE_SL_FLEXMUX_PES_PACKETS", "18"), + ("GST_MPEGTS_STREAM_TYPE_SL_FLEXMUX_SECTIONS", "19"), + ("GST_MPEGTS_STREAM_TYPE_SYNCHRONIZED_DOWNLOAD", "20"), + ("GST_MPEGTS_STREAM_TYPE_VIDEO_H264", "27"), + ("GST_MPEGTS_STREAM_TYPE_VIDEO_H264_MVC_SUB_BITSTREAM", "32"), + ("GST_MPEGTS_STREAM_TYPE_VIDEO_H264_STEREO_ADDITIONAL_VIEW", "35"), + ("GST_MPEGTS_STREAM_TYPE_VIDEO_H264_SVC_SUB_BITSTREAM", "31"), + ("GST_MPEGTS_STREAM_TYPE_VIDEO_HEVC", "36"), + ("GST_MPEGTS_STREAM_TYPE_VIDEO_JP2K", "33"), + ("GST_MPEGTS_STREAM_TYPE_VIDEO_MPEG1", "1"), + ("GST_MPEGTS_STREAM_TYPE_VIDEO_MPEG2", "2"), + ("GST_MPEGTS_STREAM_TYPE_VIDEO_MPEG2_STEREO_ADDITIONAL_VIEW", "34"), + ("GST_MPEGTS_STREAM_TYPE_VIDEO_MPEG4", "16"), + ("GST_MPEGTS_STREAM_TYPE_VIDEO_RVC", "30"), + ("GST_MPEGTS_TRANSMISSION_MODE_16K", "5"), + ("GST_MPEGTS_TRANSMISSION_MODE_1K", "4"), + ("GST_MPEGTS_TRANSMISSION_MODE_2K", "0"), + ("GST_MPEGTS_TRANSMISSION_MODE_32K", "6"), + ("GST_MPEGTS_TRANSMISSION_MODE_4K", "3"), + ("GST_MPEGTS_TRANSMISSION_MODE_8K", "1"), + ("GST_MPEGTS_TRANSMISSION_MODE_AUTO", "2"), + ("GST_MPEGTS_TRANSMISSION_MODE_C1", "7"), + ("GST_MPEGTS_TRANSMISSION_MODE_C3780", "8"), + ("GST_MTS_DESC_AC3_AUDIO_STREAM", "129"), + ("GST_MTS_DESC_ATSC_AC3", "131"), + ("GST_MTS_DESC_ATSC_CAPTION_SERVICE", "134"), + ("GST_MTS_DESC_ATSC_COMPONENT_NAME", "163"), + ("GST_MTS_DESC_ATSC_CONTENT_ADVISORY", "135"), + ("GST_MTS_DESC_ATSC_CRC32", "181"), + ("GST_MTS_DESC_ATSC_DATA_SERVICE", "164"), + ("GST_MTS_DESC_ATSC_DCC_ARRIVING_REQUEST", "169"), + ("GST_MTS_DESC_ATSC_DCC_DEPARTING_REQUEST", "168"), + ("GST_MTS_DESC_ATSC_DOWNLOAD_DESCRIPTOR", "166"), + ("GST_MTS_DESC_ATSC_EAC3", "204"), + ("GST_MTS_DESC_ATSC_ENHANCED_SIGNALING", "178"), + ("GST_MTS_DESC_ATSC_EXTENDED_CHANNEL_NAME", "160"), + ("GST_MTS_DESC_ATSC_GENRE", "171"), + ("GST_MTS_DESC_ATSC_GROUP_LINK", "184"), + ("GST_MTS_DESC_ATSC_MODULE_LINK", "180"), + ("GST_MTS_DESC_ATSC_MULTIPROTOCOL_ENCAPSULATION", "167"), + ("GST_MTS_DESC_ATSC_PID_COUNT", "165"), + ("GST_MTS_DESC_ATSC_PRIVATE_INFORMATION", "173"), + ("GST_MTS_DESC_ATSC_REDISTRIBUTION_CONTROL", "170"), + ("GST_MTS_DESC_ATSC_SERVICE_LOCATION", "161"), + ("GST_MTS_DESC_ATSC_STUFFING", "128"), + ("GST_MTS_DESC_ATSC_TIME_SHIFTED_SERVICE", "162"), + ("GST_MTS_DESC_AUDIO_STREAM", "3"), + ("GST_MTS_DESC_AUXILIARY_VIDEO_STREAM", "47"), + ("GST_MTS_DESC_AVC_TIMING_AND_HRD", "42"), + ("GST_MTS_DESC_AVC_VIDEO", "40"), + ("GST_MTS_DESC_CA", "9"), + ("GST_MTS_DESC_CONTENT_LABELING", "36"), + ("GST_MTS_DESC_COPYRIGHT", "13"), + ("GST_MTS_DESC_DATA_STREAM_ALIGNMENT", "6"), + ("GST_MTS_DESC_DSMCC_ASSOCIATION_TAG", "20"), + ("GST_MTS_DESC_DSMCC_CAROUSEL_IDENTIFIER", "19"), + ("GST_MTS_DESC_DSMCC_DEFERRED_ASSOCIATION_TAG", "21"), + ("GST_MTS_DESC_DSMCC_NPT_ENDPOINT", "24"), + ("GST_MTS_DESC_DSMCC_NPT_REFERENCE", "23"), + ("GST_MTS_DESC_DSMCC_STREAM_EVENT", "26"), + ("GST_MTS_DESC_DSMCC_STREAM_MODE", "25"), + ("GST_MTS_DESC_DTG_LOGICAL_CHANNEL", "131"), + ("GST_MTS_DESC_DVB_AAC", "124"), + ("GST_MTS_DESC_DVB_AC3", "106"), + ("GST_MTS_DESC_DVB_ADAPTATION_FIELD_DATA", "112"), + ("GST_MTS_DESC_DVB_ANCILLARY_DATA", "107"), + ("GST_MTS_DESC_DVB_ANNOUNCEMENT_SUPPORT", "110"), + ("GST_MTS_DESC_DVB_APPLICATION_SIGNALLING", "111"), + ("GST_MTS_DESC_DVB_BOUQUET_NAME", "71"), + ("GST_MTS_DESC_DVB_CABLE_DELIVERY_SYSTEM", "68"), + ("GST_MTS_DESC_DVB_CA_IDENTIFIER", "83"), + ("GST_MTS_DESC_DVB_CELL_FREQUENCY_LINK", "109"), + ("GST_MTS_DESC_DVB_CELL_LIST", "108"), + ("GST_MTS_DESC_DVB_COMPONENT", "80"), + ("GST_MTS_DESC_DVB_CONTENT", "84"), + ("GST_MTS_DESC_DVB_CONTENT_IDENTIFIER", "118"), + ("GST_MTS_DESC_DVB_COUNTRY_AVAILABILITY", "73"), + ("GST_MTS_DESC_DVB_DATA_BROADCAST", "100"), + ("GST_MTS_DESC_DVB_DATA_BROADCAST_ID", "102"), + ("GST_MTS_DESC_DVB_DEFAULT_AUTHORITY", "115"), + ("GST_MTS_DESC_DVB_DSNG", "104"), + ("GST_MTS_DESC_DVB_DTS", "123"), + ("GST_MTS_DESC_DVB_ECM_REPETITION_RATE", "120"), + ("GST_MTS_DESC_DVB_ENHANCED_AC3", "122"), + ("GST_MTS_DESC_DVB_EXTENDED_EVENT", "78"), + ("GST_MTS_DESC_DVB_EXTENSION", "127"), + ("GST_MTS_DESC_DVB_FREQUENCY_LIST", "98"), + ("GST_MTS_DESC_DVB_FTA_CONTENT_MANAGEMENT", "126"), + ("GST_MTS_DESC_DVB_LINKAGE", "74"), + ("GST_MTS_DESC_DVB_LOCAL_TIME_OFFSET", "88"), + ("GST_MTS_DESC_DVB_MOSAIC", "81"), + ("GST_MTS_DESC_DVB_MULTILINGUAL_BOUQUET_NAME", "92"), + ("GST_MTS_DESC_DVB_MULTILINGUAL_COMPONENT", "94"), + ("GST_MTS_DESC_DVB_MULTILINGUAL_NETWORK_NAME", "91"), + ("GST_MTS_DESC_DVB_MULTILINGUAL_SERVICE_NAME", "93"), + ("GST_MTS_DESC_DVB_NETWORK_NAME", "64"), + ("GST_MTS_DESC_DVB_NVOD_REFERENCE", "75"), + ("GST_MTS_DESC_DVB_PARENTAL_RATING", "85"), + ("GST_MTS_DESC_DVB_PARTIAL_TRANSPORT_STREAM", "99"), + ("GST_MTS_DESC_DVB_PDC", "105"), + ("GST_MTS_DESC_DVB_PRIVATE_DATA_SPECIFIER", "95"), + ("GST_MTS_DESC_DVB_RELATED_CONTENT", "116"), + ("GST_MTS_DESC_DVB_S2_SATELLITE_DELIVERY_SYSTEM", "121"), + ("GST_MTS_DESC_DVB_SATELLITE_DELIVERY_SYSTEM", "67"), + ("GST_MTS_DESC_DVB_SCRAMBLING", "101"), + ("GST_MTS_DESC_DVB_SERVICE", "72"), + ("GST_MTS_DESC_DVB_SERVICE_AVAILABILITY", "114"), + ("GST_MTS_DESC_DVB_SERVICE_IDENTIFIER", "113"), + ("GST_MTS_DESC_DVB_SERVICE_LIST", "65"), + ("GST_MTS_DESC_DVB_SERVICE_MOVE", "96"), + ("GST_MTS_DESC_DVB_SHORT_EVENT", "77"), + ("GST_MTS_DESC_DVB_SHORT_SMOOTHING_BUFFER", "97"), + ("GST_MTS_DESC_DVB_STREAM_IDENTIFIER", "82"), + ("GST_MTS_DESC_DVB_STUFFING", "66"), + ("GST_MTS_DESC_DVB_SUBTITLING", "89"), + ("GST_MTS_DESC_DVB_TELEPHONE", "87"), + ("GST_MTS_DESC_DVB_TELETEXT", "86"), + ("GST_MTS_DESC_DVB_TERRESTRIAL_DELIVERY_SYSTEM", "90"), + ("GST_MTS_DESC_DVB_TIMESLICE_FEC_IDENTIFIER", "119"), + ("GST_MTS_DESC_DVB_TIME_SHIFTED_EVENT", "79"), + ("GST_MTS_DESC_DVB_TIME_SHIFTED_SERVICE", "76"), + ("GST_MTS_DESC_DVB_TRANSPORT_STREAM", "103"), + ("GST_MTS_DESC_DVB_TVA_ID", "117"), + ("GST_MTS_DESC_DVB_VBI_DATA", "69"), + ("GST_MTS_DESC_DVB_VBI_TELETEXT", "70"), + ("GST_MTS_DESC_DVB_XAIT_LOCATION", "125"), + ("GST_MTS_DESC_EXTERNAL_ES_ID", "32"), + ("GST_MTS_DESC_EXT_DVB_C2_DELIVERY_SYSTEM", "13"), + ("GST_MTS_DESC_EXT_DVB_CP", "2"), + ("GST_MTS_DESC_EXT_DVB_CPCM_DELIVERY_SIGNALLING", "1"), + ("GST_MTS_DESC_EXT_DVB_CP_IDENTIFIER", "3"), + ("GST_MTS_DESC_EXT_DVB_DTS_HD_AUDIO_STREAM", "14"), + ("GST_MTS_DESC_EXT_DVB_DTS_NEUTRAL", "15"), + ("GST_MTS_DESC_EXT_DVB_IMAGE_ICON", "0"), + ("GST_MTS_DESC_EXT_DVB_MESSAGE", "8"), + ("GST_MTS_DESC_EXT_DVB_NETWORK_CHANGE_NOTIFY", "7"), + ("GST_MTS_DESC_EXT_DVB_SERVICE_RELOCATED", "11"), + ("GST_MTS_DESC_EXT_DVB_SH_DELIVERY_SYSTEM", "5"), + ("GST_MTS_DESC_EXT_DVB_SUPPLEMENTARY_AUDIO", "6"), + ("GST_MTS_DESC_EXT_DVB_T2MI", "17"), + ("GST_MTS_DESC_EXT_DVB_T2_DELIVERY_SYSTEM", "4"), + ("GST_MTS_DESC_EXT_DVB_TARGET_REGION", "9"), + ("GST_MTS_DESC_EXT_DVB_TARGET_REGION_NAME", "10"), + ("GST_MTS_DESC_EXT_DVB_URI_LINKAGE", "19"), + ("GST_MTS_DESC_EXT_DVB_VIDEO_DEPTH_RANGE", "16"), + ("GST_MTS_DESC_EXT_DVB_XAIT_PID", "12"), + ("GST_MTS_DESC_FLEX_MUX_TIMING", "44"), + ("GST_MTS_DESC_FMC", "31"), + ("GST_MTS_DESC_FMX_BUFFER_SIZE", "34"), + ("GST_MTS_DESC_HIERARCHY", "4"), + ("GST_MTS_DESC_IBP", "18"), + ("GST_MTS_DESC_IOD", "29"), + ("GST_MTS_DESC_IPMP", "41"), + ("GST_MTS_DESC_ISDB_AUDIO_COMPONENT", "196"), + ("GST_MTS_DESC_ISDB_BASIC_LOCAL_EVENT", "208"), + ("GST_MTS_DESC_ISDB_BOARD_INFORMATION", "219"), + ("GST_MTS_DESC_ISDB_BROADCASTER_NAME", "216"), + ("GST_MTS_DESC_ISDB_CA_CONTRACT_INFORMATION", "203"), + ("GST_MTS_DESC_ISDB_CA_EMM_TS", "202"), + ("GST_MTS_DESC_ISDB_CA_SERVICE", "204"), + ("GST_MTS_DESC_ISDB_COMPONENT_GROUP", "217"), + ("GST_MTS_DESC_ISDB_CONNECTED_TRANSMISSION", "221"), + ("GST_MTS_DESC_ISDB_CONTENT_AVAILABILITY", "222"), + ("GST_MTS_DESC_ISDB_DATA_CONTENT", "199"), + ("GST_MTS_DESC_ISDB_DIGITAL_COPY_CONTROL", "193"), + ("GST_MTS_DESC_ISDB_DOWNLOAD_CONTENT", "201"), + ("GST_MTS_DESC_ISDB_EVENT_GROUP", "214"), + ("GST_MTS_DESC_ISDB_EXTENDED_BROADCASTER", "206"), + ("GST_MTS_DESC_ISDB_HIERARCHICAL_TRANSMISSION", "192"), + ("GST_MTS_DESC_ISDB_HYPERLINK", "197"), + ("GST_MTS_DESC_ISDB_LDT_LINKAGE", "220"), + ("GST_MTS_DESC_ISDB_LOGO_TRANSMISSION", "207"), + ("GST_MTS_DESC_ISDB_NETWORK_IDENTIFICATION", "194"), + ("GST_MTS_DESC_ISDB_NODE_RELATION", "210"), + ("GST_MTS_DESC_ISDB_PARTIAL_TS_TIME", "195"), + ("GST_MTS_DESC_ISDB_REFERENCE", "209"), + ("GST_MTS_DESC_ISDB_SERIES", "213"), + ("GST_MTS_DESC_ISDB_SERVICE_GROUP", "224"), + ("GST_MTS_DESC_ISDB_SHORT_NODE_INFORMATION", "211"), + ("GST_MTS_DESC_ISDB_SI_PARAMETER", "215"), + ("GST_MTS_DESC_ISDB_SI_PRIME_TS", "218"), + ("GST_MTS_DESC_ISDB_STC_REFERENCE", "212"), + ("GST_MTS_DESC_ISDB_TARGET_REGION", "198"), + ("GST_MTS_DESC_ISDB_TS_INFORMATION", "205"), + ("GST_MTS_DESC_ISDB_VIDEO_DECODE_CONTROL", "200"), + ("GST_MTS_DESC_ISO_639_LANGUAGE", "10"), + ("GST_MTS_DESC_J2K_VIDEO", "50"), + ("GST_MTS_DESC_MAXIMUM_BITRATE", "14"), + ("GST_MTS_DESC_METADATA", "38"), + ("GST_MTS_DESC_METADATA_POINTER", "37"), + ("GST_MTS_DESC_METADATA_STD", "39"), + ("GST_MTS_DESC_MPEG2_AAC_AUDIO", "43"), + ("GST_MTS_DESC_MPEG2_STEREOSCOPIC_VIDEO_FORMAT", "52"), + ("GST_MTS_DESC_MPEG4_AUDIO", "28"), + ("GST_MTS_DESC_MPEG4_AUDIO_EXTENSION", "46"), + ("GST_MTS_DESC_MPEG4_TEXT", "45"), + ("GST_MTS_DESC_MPEG4_VIDEO", "27"), + ("GST_MTS_DESC_MULTIPLEX_BUFFER", "35"), + ("GST_MTS_DESC_MULTIPLEX_BUFFER_UTILISATION", "12"), + ("GST_MTS_DESC_MUX_CODE", "33"), + ("GST_MTS_DESC_MVC_EXTENSION", "49"), + ("GST_MTS_DESC_MVC_OPERATION_POINT", "51"), + ("GST_MTS_DESC_PRIVATE_DATA_INDICATOR", "15"), + ("GST_MTS_DESC_REGISTRATION", "5"), + ("GST_MTS_DESC_RESERVED_00", "0"), + ("GST_MTS_DESC_RESERVED_01", "1"), + ("GST_MTS_DESC_SL", "30"), + ("GST_MTS_DESC_SMOOTHING_BUFFER", "16"), + ("GST_MTS_DESC_STD", "17"), + ("GST_MTS_DESC_STEREOSCOPIC_PROGRAM_INFO", "53"), + ("GST_MTS_DESC_STEREOSCOPIC_VIDEO_INFO", "54"), + ("GST_MTS_DESC_SVC_EXTENSION", "48"), + ("GST_MTS_DESC_SYSTEM_CLOCK", "11"), + ("GST_MTS_DESC_TARGET_BACKGROUND_GRID", "7"), + ("GST_MTS_DESC_VIDEO_STREAM", "2"), + ("GST_MTS_DESC_VIDEO_WINDOW", "8"), + ("GST_MTS_TABLE_ID_14496_OBJET_DESCRIPTOR", "5"), + ("GST_MTS_TABLE_ID_14496_SCENE_DESCRIPTION", "4"), + ("GST_MTS_TABLE_ID_APPLICATION_INFORMATION_TABLE", "116"), + ("GST_MTS_TABLE_ID_ATSC_AGGREGATE_DATA_EVENT", "217"), + ("GST_MTS_TABLE_ID_ATSC_AGGREGATE_EVENT_INFORMATION", "214"), + ("GST_MTS_TABLE_ID_ATSC_AGGREGATE_EXTENDED_TEXT", "215"), + ("GST_MTS_TABLE_ID_ATSC_CABLE_VIRTUAL_CHANNEL", "201"), + ("GST_MTS_TABLE_ID_ATSC_CHANNEL_OR_EVENT_EXTENDED_TEXT", "204"), + ("GST_MTS_TABLE_ID_ATSC_DATA_EVENT", "206"), + ("GST_MTS_TABLE_ID_ATSC_DATA_SERVICE", "207"), + ("GST_MTS_TABLE_ID_ATSC_DIRECTED_CHANNEL_CHANGE", "211"), + ("GST_MTS_TABLE_ID_ATSC_DIRECTED_CHANNEL_CHANGE_SECTION_CODE", "212"), + ("GST_MTS_TABLE_ID_ATSC_EVENT_INFORMATION", "203"), + ("GST_MTS_TABLE_ID_ATSC_LONG_TERM_SERVICE", "210"), + ("GST_MTS_TABLE_ID_ATSC_MASTER_GUIDE", "199"), + ("GST_MTS_TABLE_ID_ATSC_NETWORK_RESOURCE", "209"), + ("GST_MTS_TABLE_ID_ATSC_RATING_REGION", "202"), + ("GST_MTS_TABLE_ID_ATSC_SATELLITE_VIRTUAL_CHANNEL", "218"), + ("GST_MTS_TABLE_ID_ATSC_SYSTEM_TIME", "205"), + ("GST_MTS_TABLE_ID_ATSC_TERRESTRIAL_VIRTUAL_CHANNEL", "200"), + ("GST_MTS_TABLE_ID_BOUQUET_ASSOCIATION", "74"), + ("GST_MTS_TABLE_ID_CA_MESSAGE_ECM_0", "128"), + ("GST_MTS_TABLE_ID_CA_MESSAGE_ECM_1", "129"), + ("GST_MTS_TABLE_ID_CA_MESSAGE_SYSTEM_PRIVATE_1", "130"), + ("GST_MTS_TABLE_ID_CA_MESSAGE_SYSTEM_PRIVATE_N", "143"), + ("GST_MTS_TABLE_ID_CMT", "164"), + ("GST_MTS_TABLE_ID_CONDITIONAL_ACCESS", "1"), + ("GST_MTS_TABLE_ID_CONTAINER", "117"), + ("GST_MTS_TABLE_ID_CONTENT_IDENTIFIER", "119"), + ("GST_MTS_TABLE_ID_DISCONTINUITY_INFORMATION", "126"), + ("GST_MTS_TABLE_ID_DSM_CC_ADDRESSABLE_SECTIONS", "63"), + ("GST_MTS_TABLE_ID_DSM_CC_DOWNLOAD_DATA_MESSAGES", "60"), + ("GST_MTS_TABLE_ID_DSM_CC_MULTIPROTO_ENCAPSULATED_DATA", "58"), + ("GST_MTS_TABLE_ID_DSM_CC_PRIVATE_DATA", "62"), + ("GST_MTS_TABLE_ID_DSM_CC_STREAM_DESCRIPTORS", "61"), + ("GST_MTS_TABLE_ID_DSM_CC_U_N_MESSAGES", "59"), + ("GST_MTS_TABLE_ID_EVENT_INFORMATION_ACTUAL_TS_PRESENT", "78"), + ("GST_MTS_TABLE_ID_EVENT_INFORMATION_ACTUAL_TS_SCHEDULE_1", "80"), + ("GST_MTS_TABLE_ID_EVENT_INFORMATION_ACTUAL_TS_SCHEDULE_N", "95"), + ("GST_MTS_TABLE_ID_EVENT_INFORMATION_OTHER_TS_PRESENT", "79"), + ("GST_MTS_TABLE_ID_EVENT_INFORMATION_OTHER_TS_SCHEDULE_1", "96"), + ("GST_MTS_TABLE_ID_EVENT_INFORMATION_OTHER_TS_SCHEDULE_N", "111"), + ("GST_MTS_TABLE_ID_FCT", "161"), + ("GST_MTS_TABLE_ID_IPMP_CONTROL_INFORMATION", "7"), + ("GST_MTS_TABLE_ID_LL_FEC_PARITY_DATA_TABLE", "177"), + ("GST_MTS_TABLE_ID_METADATA", "6"), + ("GST_MTS_TABLE_ID_MPE_FEC", "120"), + ("GST_MTS_TABLE_ID_MPE_IFEC", "122"), + ("GST_MTS_TABLE_ID_NETWORK_INFORMATION_ACTUAL_NETWORK", "64"), + ("GST_MTS_TABLE_ID_NETWORK_INFORMATION_OTHER_NETWORK", "65"), + ("GST_MTS_TABLE_ID_PCR_PACKET_PAYLOAD", "166"), + ("GST_MTS_TABLE_ID_PROGRAM_ASSOCIATION", "0"), + ("GST_MTS_TABLE_ID_RELATED_CONTENT", "118"), + ("GST_MTS_TABLE_ID_RESOLUTION_NOTIFICATION", "121"), + ("GST_MTS_TABLE_ID_RUNNING_STATUS", "113"), + ("GST_MTS_TABLE_ID_SCT", "160"), + ("GST_MTS_TABLE_ID_SCTE_DDB", "228"), + ("GST_MTS_TABLE_ID_SCTE_DII", "227"), + ("GST_MTS_TABLE_ID_SCTE_EAS", "216"), + ("GST_MTS_TABLE_ID_SCTE_EBIF", "224"), + ("GST_MTS_TABLE_ID_SCTE_EISS", "226"), + ("GST_MTS_TABLE_ID_SCTE_RESERVED", "225"), + ("GST_MTS_TABLE_ID_SCTE_SPLICE", "252"), + ("GST_MTS_TABLE_ID_SELECTION_INFORMATION", "127"), + ("GST_MTS_TABLE_ID_SERVICE_DESCRIPTION_ACTUAL_TS", "66"), + ("GST_MTS_TABLE_ID_SERVICE_DESCRIPTION_OTHER_TS", "70"), + ("GST_MTS_TABLE_ID_SPT", "163"), + ("GST_MTS_TABLE_ID_STUFFING", "114"), + ("GST_MTS_TABLE_ID_TBTP", "165"), + ("GST_MTS_TABLE_ID_TCT", "162"), + ("GST_MTS_TABLE_ID_TIM", "176"), + ("GST_MTS_TABLE_ID_TIME_DATE", "112"), + ("GST_MTS_TABLE_ID_TIME_OFFSET", "115"), + ("GST_MTS_TABLE_ID_TRANSMISSION_MODE_SUPPORT_PAYLOAD", "170"), + ("GST_MTS_TABLE_ID_TS_DESCRIPTION", "3"), + ("GST_MTS_TABLE_ID_TS_PROGRAM_MAP", "2"), + ("GST_MTS_TABLE_ID_UNSET", "255"), + ("HEARING_IMPAIRED_PAGE", "5"), + ("INITIAL_PAGE", "1"), + ("PROGRAMME_SCHEDULE_PAGE", "4"), + ("SUBTITLE_PAGE", "2"), +]; + + diff --git a/gstreamer-mpegts-sys/tests/constant.c b/gstreamer-mpegts-sys/tests/constant.c new file mode 100644 index 000000000..f95b609c2 --- /dev/null +++ b/gstreamer-mpegts-sys/tests/constant.c @@ -0,0 +1,27 @@ +// This file was generated by gir (https://github.com/gtk-rs/gir @ 6855214) +// from gir-files (https://github.com/gtk-rs/gir-files @ ???) +// DO NOT EDIT + +#include "manual.h" +#include + +int main() { + printf(_Generic((ABI_CONSTANT_NAME), + char *: "%s", + const char *: "%s", + char: "%c", + signed char: "%hhd", + unsigned char: "%hhu", + short int: "%hd", + unsigned short int: "%hu", + int: "%d", + unsigned int: "%u", + long: "%ld", + unsigned long: "%lu", + long long: "%lld", + unsigned long long: "%llu", + double: "%f", + long double: "%ld"), + ABI_CONSTANT_NAME); + return 0; +} diff --git a/gstreamer-mpegts-sys/tests/layout.c b/gstreamer-mpegts-sys/tests/layout.c new file mode 100644 index 000000000..e4be962df --- /dev/null +++ b/gstreamer-mpegts-sys/tests/layout.c @@ -0,0 +1,12 @@ +// This file was generated by gir (https://github.com/gtk-rs/gir @ 6855214) +// from gir-files (https://github.com/gtk-rs/gir-files @ ???) +// 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-mpegts-sys/tests/manual.h b/gstreamer-mpegts-sys/tests/manual.h new file mode 100644 index 000000000..f6d179eb8 --- /dev/null +++ b/gstreamer-mpegts-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 diff --git a/gstreamer-net-sys/Cargo.toml b/gstreamer-net-sys/Cargo.toml index e6fd569dd..96dcff5ed 100644 --- a/gstreamer-net-sys/Cargo.toml +++ b/gstreamer-net-sys/Cargo.toml @@ -10,6 +10,10 @@ gio-sys = { git = "https://github.com/gtk-rs/sys" } [dependencies.gstreamer-sys] path = "../gstreamer-sys" +[dev-dependencies] +shell-words = "0.1.0" +tempdir = "0.3" + [features] v1_2 = [] v1_4 = ["v1_2"] diff --git a/gstreamer-net-sys/src/lib.rs b/gstreamer-net-sys/src/lib.rs index 063b2a8d4..f38a7357e 100644 --- a/gstreamer-net-sys/src/lib.rs +++ b/gstreamer-net-sys/src/lib.rs @@ -1,4 +1,4 @@ -// This file was generated by gir (https://github.com/gtk-rs/gir @ fe7a6ff) +// This file was generated by gir (https://github.com/gtk-rs/gir @ 6855214) // from gir-files (https://github.com/gtk-rs/gir-files @ ???) // DO NOT EDIT diff --git a/gstreamer-net-sys/tests/abi.rs b/gstreamer-net-sys/tests/abi.rs new file mode 100644 index 000000000..28d791cc5 --- /dev/null +++ b/gstreamer-net-sys/tests/abi.rs @@ -0,0 +1,256 @@ +// This file was generated by gir (https://github.com/gtk-rs/gir @ 6855214) +// from gir-files (https://github.com/gtk-rs/gir-files @ ???) +// DO NOT EDIT + +extern crate gstreamer_net_sys; +extern crate shell_words; +extern crate tempdir; +use std::env; +use std::error::Error; +use std::path::Path; +use std::mem::{align_of, size_of}; +use std::process::Command; +use std::str; +use gstreamer_net_sys::*; + +static PACKAGES: &[&str] = &["gstreamer-net-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 = tempdir::TempDir::new("abi").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 = tempdir::TempDir::new("abi").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()); + } + + Ok(str::from_utf8(&output.stdout)?.trim().to_owned()) +} + +const RUST_LAYOUTS: &[(&str, Layout)] = &[ + ("GstNetAddressMeta", Layout {size: size_of::(), alignment: align_of::()}), + ("GstNetClientClock", Layout {size: size_of::(), alignment: align_of::()}), + ("GstNetClientClockClass", Layout {size: size_of::(), alignment: align_of::()}), + ("GstNetControlMessageMeta", Layout {size: size_of::(), alignment: align_of::()}), + ("GstNetTimePacket", Layout {size: size_of::(), alignment: align_of::()}), + ("GstNetTimeProvider", Layout {size: size_of::(), alignment: align_of::()}), + ("GstNetTimeProviderClass", Layout {size: size_of::(), alignment: align_of::()}), + ("GstNtpClock", Layout {size: size_of::(), alignment: align_of::()}), + ("GstNtpClockClass", Layout {size: size_of::(), alignment: align_of::()}), + ("GstPtpClock", Layout {size: size_of::(), alignment: align_of::()}), + ("GstPtpClockClass", Layout {size: size_of::(), alignment: align_of::()}), +]; + +const RUST_CONSTANTS: &[(&str, &str)] = &[ + ("GST_NET_TIME_PACKET_SIZE", "16"), + ("GST_PTP_CLOCK_ID_NONE", "18446744073709551615"), + ("GST_PTP_STATISTICS_BEST_MASTER_CLOCK_SELECTED", "GstPtpStatisticsBestMasterClockSelected"), + ("GST_PTP_STATISTICS_NEW_DOMAIN_FOUND", "GstPtpStatisticsNewDomainFound"), + ("GST_PTP_STATISTICS_PATH_DELAY_MEASURED", "GstPtpStatisticsPathDelayMeasured"), + ("GST_PTP_STATISTICS_TIME_UPDATED", "GstPtpStatisticsTimeUpdated"), +]; + + diff --git a/gstreamer-net-sys/tests/constant.c b/gstreamer-net-sys/tests/constant.c new file mode 100644 index 000000000..f95b609c2 --- /dev/null +++ b/gstreamer-net-sys/tests/constant.c @@ -0,0 +1,27 @@ +// This file was generated by gir (https://github.com/gtk-rs/gir @ 6855214) +// from gir-files (https://github.com/gtk-rs/gir-files @ ???) +// DO NOT EDIT + +#include "manual.h" +#include + +int main() { + printf(_Generic((ABI_CONSTANT_NAME), + char *: "%s", + const char *: "%s", + char: "%c", + signed char: "%hhd", + unsigned char: "%hhu", + short int: "%hd", + unsigned short int: "%hu", + int: "%d", + unsigned int: "%u", + long: "%ld", + unsigned long: "%lu", + long long: "%lld", + unsigned long long: "%llu", + double: "%f", + long double: "%ld"), + ABI_CONSTANT_NAME); + return 0; +} diff --git a/gstreamer-net-sys/tests/layout.c b/gstreamer-net-sys/tests/layout.c new file mode 100644 index 000000000..e4be962df --- /dev/null +++ b/gstreamer-net-sys/tests/layout.c @@ -0,0 +1,12 @@ +// This file was generated by gir (https://github.com/gtk-rs/gir @ 6855214) +// from gir-files (https://github.com/gtk-rs/gir-files @ ???) +// 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-net-sys/tests/manual.h b/gstreamer-net-sys/tests/manual.h new file mode 100644 index 000000000..3a86ae8cd --- /dev/null +++ b/gstreamer-net-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 diff --git a/gstreamer-pbutils-sys/Cargo.toml b/gstreamer-pbutils-sys/Cargo.toml index 802de9ee1..4d862932a 100644 --- a/gstreamer-pbutils-sys/Cargo.toml +++ b/gstreamer-pbutils-sys/Cargo.toml @@ -2,7 +2,6 @@ pkg-config = "0.3.7" [dependencies] -bitflags = "1.0" libc = "0.2" glib-sys = { git = "https://github.com/gtk-rs/sys" } gobject-sys = { git = "https://github.com/gtk-rs/sys" } @@ -16,6 +15,10 @@ path = "../gstreamer-audio-sys" [dependencies.gstreamer-video-sys] path = "../gstreamer-video-sys" +[dev-dependencies] +shell-words = "0.1.0" +tempdir = "0.3" + [features] v1_2 = [] v1_4 = ["v1_2"] diff --git a/gstreamer-pbutils-sys/src/lib.rs b/gstreamer-pbutils-sys/src/lib.rs index 1da2940f0..ddb26429b 100644 --- a/gstreamer-pbutils-sys/src/lib.rs +++ b/gstreamer-pbutils-sys/src/lib.rs @@ -1,11 +1,10 @@ -// This file was generated by gir (https://github.com/gtk-rs/gir @ fe7a6ff) +// This file was generated by gir (https://github.com/gtk-rs/gir @ 6855214) // 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)] extern crate libc; -#[macro_use] extern crate bitflags; extern crate glib_sys as glib; extern crate gobject_sys as gobject; extern crate gstreamer_sys as gst; @@ -75,21 +74,12 @@ pub const GST_PLUGINS_BASE_VERSION_MINOR: c_int = 14; pub const GST_PLUGINS_BASE_VERSION_NANO: c_int = 0; // Flags -bitflags! { - #[repr(C)] - pub struct GstDiscovererSerializeFlags: c_uint { - const BASIC = 0; - const CAPS = 1; - const TAGS = 2; - const MISC = 4; - const ALL = 7; - } -} -pub const GST_DISCOVERER_SERIALIZE_BASIC: GstDiscovererSerializeFlags = GstDiscovererSerializeFlags::BASIC; -pub const GST_DISCOVERER_SERIALIZE_CAPS: GstDiscovererSerializeFlags = GstDiscovererSerializeFlags::CAPS; -pub const GST_DISCOVERER_SERIALIZE_TAGS: GstDiscovererSerializeFlags = GstDiscovererSerializeFlags::TAGS; -pub const GST_DISCOVERER_SERIALIZE_MISC: GstDiscovererSerializeFlags = GstDiscovererSerializeFlags::MISC; -pub const GST_DISCOVERER_SERIALIZE_ALL: GstDiscovererSerializeFlags = GstDiscovererSerializeFlags::ALL; +pub type GstDiscovererSerializeFlags = c_uint; +pub const GST_DISCOVERER_SERIALIZE_BASIC: GstDiscovererSerializeFlags = 0; +pub const GST_DISCOVERER_SERIALIZE_CAPS: GstDiscovererSerializeFlags = 1; +pub const GST_DISCOVERER_SERIALIZE_TAGS: GstDiscovererSerializeFlags = 2; +pub const GST_DISCOVERER_SERIALIZE_MISC: GstDiscovererSerializeFlags = 4; +pub const GST_DISCOVERER_SERIALIZE_ALL: GstDiscovererSerializeFlags = 7; // Callbacks pub type GstAudioVisualizerShaderFunc = Option; @@ -545,7 +535,7 @@ extern "C" { pub fn gst_encoding_target_get_type() -> GType; pub fn gst_encoding_target_new(name: *const c_char, category: *const c_char, description: *const c_char, profiles: *const glib::GList) -> *mut GstEncodingTarget; pub fn gst_encoding_target_load(name: *const c_char, category: *const c_char, error: *mut *mut glib::GError) -> *mut GstEncodingTarget; - pub fn gst_encoding_target_load_from_file(filepath: *mut c_char, error: *mut *mut glib::GError) -> *mut GstEncodingTarget; + pub fn gst_encoding_target_load_from_file(filepath: *const c_char, error: *mut *mut glib::GError) -> *mut GstEncodingTarget; pub fn gst_encoding_target_add_profile(target: *mut GstEncodingTarget, profile: *mut GstEncodingProfile) -> gboolean; pub fn gst_encoding_target_get_category(target: *mut GstEncodingTarget) -> *const c_char; pub fn gst_encoding_target_get_description(target: *mut GstEncodingTarget) -> *const c_char; @@ -553,7 +543,7 @@ extern "C" { pub fn gst_encoding_target_get_profile(target: *mut GstEncodingTarget, name: *const c_char) -> *mut GstEncodingProfile; pub fn gst_encoding_target_get_profiles(target: *mut GstEncodingTarget) -> *const glib::GList; pub fn gst_encoding_target_save(target: *mut GstEncodingTarget, error: *mut *mut glib::GError) -> gboolean; - pub fn gst_encoding_target_save_to_file(target: *mut GstEncodingTarget, filepath: *mut c_char, error: *mut *mut glib::GError) -> gboolean; + pub fn gst_encoding_target_save_to_file(target: *mut GstEncodingTarget, filepath: *const c_char, error: *mut *mut glib::GError) -> gboolean; //========================================================================= // GstEncodingVideoProfile diff --git a/gstreamer-pbutils-sys/tests/abi.rs b/gstreamer-pbutils-sys/tests/abi.rs new file mode 100644 index 000000000..884ec3094 --- /dev/null +++ b/gstreamer-pbutils-sys/tests/abi.rs @@ -0,0 +1,295 @@ +// This file was generated by gir (https://github.com/gtk-rs/gir @ 6855214) +// from gir-files (https://github.com/gtk-rs/gir-files @ ???) +// DO NOT EDIT + +extern crate gstreamer_pbutils_sys; +extern crate shell_words; +extern crate tempdir; +use std::env; +use std::error::Error; +use std::path::Path; +use std::mem::{align_of, size_of}; +use std::process::Command; +use std::str; +use gstreamer_pbutils_sys::*; + +static PACKAGES: &[&str] = &["gstreamer-pbutils-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 = tempdir::TempDir::new("abi").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 = tempdir::TempDir::new("abi").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()); + } + + Ok(str::from_utf8(&output.stdout)?.trim().to_owned()) +} + +const RUST_LAYOUTS: &[(&str, Layout)] = &[ + ("GstAudioVisualizer", Layout {size: size_of::(), alignment: align_of::()}), + ("GstAudioVisualizerClass", Layout {size: size_of::(), alignment: align_of::()}), + ("GstAudioVisualizerShader", Layout {size: size_of::(), alignment: align_of::()}), + ("GstDiscoverer", Layout {size: size_of::(), alignment: align_of::()}), + ("GstDiscovererAudioInfoClass", Layout {size: size_of::(), alignment: align_of::()}), + ("GstDiscovererClass", Layout {size: size_of::(), alignment: align_of::()}), + ("GstDiscovererContainerInfoClass", Layout {size: size_of::(), alignment: align_of::()}), + ("GstDiscovererInfoClass", Layout {size: size_of::(), alignment: align_of::()}), + ("GstDiscovererResult", Layout {size: size_of::(), alignment: align_of::()}), + ("GstDiscovererSerializeFlags", Layout {size: size_of::(), alignment: align_of::()}), + ("GstDiscovererStreamInfoClass", Layout {size: size_of::(), alignment: align_of::()}), + ("GstDiscovererSubtitleInfoClass", Layout {size: size_of::(), alignment: align_of::()}), + ("GstDiscovererVideoInfoClass", Layout {size: size_of::(), alignment: align_of::()}), + ("GstEncodingTargetClass", Layout {size: size_of::(), alignment: align_of::()}), + ("GstInstallPluginsReturn", Layout {size: size_of::(), alignment: align_of::()}), +]; + +const RUST_CONSTANTS: &[(&str, &str)] = &[ + ("GST_AUDIO_VISUALIZER_SHADER_FADE", "1"), + ("GST_AUDIO_VISUALIZER_SHADER_FADE_AND_MOVE_DOWN", "3"), + ("GST_AUDIO_VISUALIZER_SHADER_FADE_AND_MOVE_HORIZ_IN", "7"), + ("GST_AUDIO_VISUALIZER_SHADER_FADE_AND_MOVE_HORIZ_OUT", "6"), + ("GST_AUDIO_VISUALIZER_SHADER_FADE_AND_MOVE_LEFT", "4"), + ("GST_AUDIO_VISUALIZER_SHADER_FADE_AND_MOVE_RIGHT", "5"), + ("GST_AUDIO_VISUALIZER_SHADER_FADE_AND_MOVE_UP", "2"), + ("GST_AUDIO_VISUALIZER_SHADER_FADE_AND_MOVE_VERT_IN", "9"), + ("GST_AUDIO_VISUALIZER_SHADER_FADE_AND_MOVE_VERT_OUT", "8"), + ("GST_AUDIO_VISUALIZER_SHADER_NONE", "0"), + ("GST_DISCOVERER_BUSY", "4"), + ("GST_DISCOVERER_ERROR", "2"), + ("GST_DISCOVERER_MISSING_PLUGINS", "5"), + ("GST_DISCOVERER_OK", "0"), + ("GST_DISCOVERER_SERIALIZE_ALL", "7"), + ("GST_DISCOVERER_SERIALIZE_BASIC", "0"), + ("GST_DISCOVERER_SERIALIZE_CAPS", "1"), + ("GST_DISCOVERER_SERIALIZE_MISC", "4"), + ("GST_DISCOVERER_SERIALIZE_TAGS", "2"), + ("GST_DISCOVERER_TIMEOUT", "3"), + ("GST_DISCOVERER_URI_INVALID", "1"), + ("GST_ENCODING_CATEGORY_CAPTURE", "capture"), + ("GST_ENCODING_CATEGORY_DEVICE", "device"), + ("GST_ENCODING_CATEGORY_FILE_EXTENSION", "file-extension"), + ("GST_ENCODING_CATEGORY_ONLINE_SERVICE", "online-service"), + ("GST_ENCODING_CATEGORY_STORAGE_EDITING", "storage-editing"), + ("GST_INSTALL_PLUGINS_CRASHED", "100"), + ("GST_INSTALL_PLUGINS_ERROR", "2"), + ("GST_INSTALL_PLUGINS_HELPER_MISSING", "202"), + ("GST_INSTALL_PLUGINS_INSTALL_IN_PROGRESS", "203"), + ("GST_INSTALL_PLUGINS_INTERNAL_FAILURE", "201"), + ("GST_INSTALL_PLUGINS_INVALID", "101"), + ("GST_INSTALL_PLUGINS_NOT_FOUND", "1"), + ("GST_INSTALL_PLUGINS_PARTIAL_SUCCESS", "3"), + ("GST_INSTALL_PLUGINS_STARTED_OK", "200"), + ("GST_INSTALL_PLUGINS_SUCCESS", "0"), + ("GST_INSTALL_PLUGINS_USER_ABORT", "4"), + ("GST_PLUGINS_BASE_VERSION_MAJOR", "1"), + ("GST_PLUGINS_BASE_VERSION_MICRO", "0"), + ("GST_PLUGINS_BASE_VERSION_MINOR", "14"), + ("GST_PLUGINS_BASE_VERSION_NANO", "0"), +]; + + diff --git a/gstreamer-pbutils-sys/tests/constant.c b/gstreamer-pbutils-sys/tests/constant.c new file mode 100644 index 000000000..f95b609c2 --- /dev/null +++ b/gstreamer-pbutils-sys/tests/constant.c @@ -0,0 +1,27 @@ +// This file was generated by gir (https://github.com/gtk-rs/gir @ 6855214) +// from gir-files (https://github.com/gtk-rs/gir-files @ ???) +// DO NOT EDIT + +#include "manual.h" +#include + +int main() { + printf(_Generic((ABI_CONSTANT_NAME), + char *: "%s", + const char *: "%s", + char: "%c", + signed char: "%hhd", + unsigned char: "%hhu", + short int: "%hd", + unsigned short int: "%hu", + int: "%d", + unsigned int: "%u", + long: "%ld", + unsigned long: "%lu", + long long: "%lld", + unsigned long long: "%llu", + double: "%f", + long double: "%ld"), + ABI_CONSTANT_NAME); + return 0; +} diff --git a/gstreamer-pbutils-sys/tests/layout.c b/gstreamer-pbutils-sys/tests/layout.c new file mode 100644 index 000000000..e4be962df --- /dev/null +++ b/gstreamer-pbutils-sys/tests/layout.c @@ -0,0 +1,12 @@ +// This file was generated by gir (https://github.com/gtk-rs/gir @ 6855214) +// from gir-files (https://github.com/gtk-rs/gir-files @ ???) +// 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-pbutils-sys/tests/manual.h b/gstreamer-pbutils-sys/tests/manual.h new file mode 100644 index 000000000..cbe4526d6 --- /dev/null +++ b/gstreamer-pbutils-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 diff --git a/gstreamer-player-sys/Cargo.toml b/gstreamer-player-sys/Cargo.toml index 869d218df..64ad78863 100644 --- a/gstreamer-player-sys/Cargo.toml +++ b/gstreamer-player-sys/Cargo.toml @@ -12,6 +12,10 @@ path = "../gstreamer-sys" [dependencies.gstreamer-video-sys] path = "../gstreamer-video-sys" +[dev-dependencies] +shell-words = "0.1.0" +tempdir = "0.3" + [features] v1_12 = [] v1_14 = ["v1_12"] diff --git a/gstreamer-player-sys/src/lib.rs b/gstreamer-player-sys/src/lib.rs index 73c8e16f6..d858647d2 100644 --- a/gstreamer-player-sys/src/lib.rs +++ b/gstreamer-player-sys/src/lib.rs @@ -1,4 +1,4 @@ -// This file was generated by gir (https://github.com/gtk-rs/gir @ fe7a6ff) +// This file was generated by gir (https://github.com/gtk-rs/gir @ 6855214) // from gir-files (https://github.com/gtk-rs/gir-files @ ???) // DO NOT EDIT diff --git a/gstreamer-player-sys/tests/abi.rs b/gstreamer-player-sys/tests/abi.rs new file mode 100644 index 000000000..d9bae110f --- /dev/null +++ b/gstreamer-player-sys/tests/abi.rs @@ -0,0 +1,260 @@ +// This file was generated by gir (https://github.com/gtk-rs/gir @ 6855214) +// from gir-files (https://github.com/gtk-rs/gir-files @ ???) +// DO NOT EDIT + +extern crate gstreamer_player_sys; +extern crate shell_words; +extern crate tempdir; +use std::env; +use std::error::Error; +use std::path::Path; +use std::mem::{align_of, size_of}; +use std::process::Command; +use std::str; +use gstreamer_player_sys::*; + +static PACKAGES: &[&str] = &["gstreamer-player-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 = tempdir::TempDir::new("abi").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 = tempdir::TempDir::new("abi").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()); + } + + Ok(str::from_utf8(&output.stdout)?.trim().to_owned()) +} + +const RUST_LAYOUTS: &[(&str, Layout)] = &[ + ("GstPlayerColorBalanceType", Layout {size: size_of::(), alignment: align_of::()}), + ("GstPlayerError", Layout {size: size_of::(), alignment: align_of::()}), + ("GstPlayerSignalDispatcherInterface", Layout {size: size_of::(), alignment: align_of::()}), + ("GstPlayerSnapshotFormat", Layout {size: size_of::(), alignment: align_of::()}), + ("GstPlayerState", Layout {size: size_of::(), alignment: align_of::()}), + ("GstPlayerVideoRendererInterface", Layout {size: size_of::(), alignment: align_of::()}), + ("GstPlayerVisualization", Layout {size: size_of::(), alignment: align_of::()}), +]; + +const RUST_CONSTANTS: &[(&str, &str)] = &[ + ("GST_PLAYER_COLOR_BALANCE_BRIGHTNESS", "0"), + ("GST_PLAYER_COLOR_BALANCE_CONTRAST", "1"), + ("GST_PLAYER_COLOR_BALANCE_HUE", "3"), + ("GST_PLAYER_COLOR_BALANCE_SATURATION", "2"), + ("GST_PLAYER_ERROR_FAILED", "0"), + ("GST_PLAYER_STATE_BUFFERING", "1"), + ("GST_PLAYER_STATE_PAUSED", "2"), + ("GST_PLAYER_STATE_PLAYING", "3"), + ("GST_PLAYER_STATE_STOPPED", "0"), + ("GST_PLAYER_THUMBNAIL_JPG", "3"), + ("GST_PLAYER_THUMBNAIL_PNG", "4"), + ("GST_PLAYER_THUMBNAIL_RAW_BGRx", "2"), + ("GST_PLAYER_THUMBNAIL_RAW_NATIVE", "0"), + ("GST_PLAYER_THUMBNAIL_RAW_xRGB", "1"), +]; + + diff --git a/gstreamer-player-sys/tests/constant.c b/gstreamer-player-sys/tests/constant.c new file mode 100644 index 000000000..f95b609c2 --- /dev/null +++ b/gstreamer-player-sys/tests/constant.c @@ -0,0 +1,27 @@ +// This file was generated by gir (https://github.com/gtk-rs/gir @ 6855214) +// from gir-files (https://github.com/gtk-rs/gir-files @ ???) +// DO NOT EDIT + +#include "manual.h" +#include + +int main() { + printf(_Generic((ABI_CONSTANT_NAME), + char *: "%s", + const char *: "%s", + char: "%c", + signed char: "%hhd", + unsigned char: "%hhu", + short int: "%hd", + unsigned short int: "%hu", + int: "%d", + unsigned int: "%u", + long: "%ld", + unsigned long: "%lu", + long long: "%lld", + unsigned long long: "%llu", + double: "%f", + long double: "%ld"), + ABI_CONSTANT_NAME); + return 0; +} diff --git a/gstreamer-player-sys/tests/layout.c b/gstreamer-player-sys/tests/layout.c new file mode 100644 index 000000000..e4be962df --- /dev/null +++ b/gstreamer-player-sys/tests/layout.c @@ -0,0 +1,12 @@ +// This file was generated by gir (https://github.com/gtk-rs/gir @ 6855214) +// from gir-files (https://github.com/gtk-rs/gir-files @ ???) +// 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-player-sys/tests/manual.h b/gstreamer-player-sys/tests/manual.h new file mode 100644 index 000000000..bd826c2f0 --- /dev/null +++ b/gstreamer-player-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 diff --git a/gstreamer-rtsp-server-sys/Cargo.toml b/gstreamer-rtsp-server-sys/Cargo.toml index 38204abcf..ea4535b19 100644 --- a/gstreamer-rtsp-server-sys/Cargo.toml +++ b/gstreamer-rtsp-server-sys/Cargo.toml @@ -6,7 +6,6 @@ repository = "sdroege/gstreamer-sys" pkg-config = "0.3.7" [dependencies] -bitflags = "1.0" libc = "0.2" glib-sys = { git = "https://github.com/gtk-rs/sys" } gobject-sys = { git = "https://github.com/gtk-rs/sys" } @@ -24,6 +23,10 @@ path = "../gstreamer-sdp-sys" [dependencies.gstreamer-sys] path = "../gstreamer-sys" +[dev-dependencies] +shell-words = "0.1.0" +tempdir = "0.3" + [features] dox = [] v1_4 = [] diff --git a/gstreamer-rtsp-server-sys/src/lib.rs b/gstreamer-rtsp-server-sys/src/lib.rs index b13942d94..b15661a3d 100644 --- a/gstreamer-rtsp-server-sys/src/lib.rs +++ b/gstreamer-rtsp-server-sys/src/lib.rs @@ -1,11 +1,10 @@ -// This file was generated by gir (https://github.com/gtk-rs/gir @ fe7a6ff) +// This file was generated by gir (https://github.com/gtk-rs/gir @ 6855214) // 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)] extern crate libc; -#[macro_use] extern crate bitflags; extern crate glib_sys as glib; extern crate gobject_sys as gobject; extern crate gio_sys as gio; @@ -72,33 +71,17 @@ pub const GST_RTSP_TOKEN_MEDIA_FACTORY_ROLE: *const c_char = b"media.factory.rol pub const GST_RTSP_TOKEN_TRANSPORT_CLIENT_SETTINGS: *const c_char = b"transport.client-settings\0" as *const u8 as *const c_char; // Flags -bitflags! { - #[repr(C)] - pub struct GstRTSPAddressFlags: c_uint { - const NONE = 0; - const IPV4 = 1; - const IPV6 = 2; - const EVEN_PORT = 4; - const MULTICAST = 8; - const UNICAST = 16; - } -} -pub const GST_RTSP_ADDRESS_FLAG_NONE: GstRTSPAddressFlags = GstRTSPAddressFlags::NONE; -pub const GST_RTSP_ADDRESS_FLAG_IPV4: GstRTSPAddressFlags = GstRTSPAddressFlags::IPV4; -pub const GST_RTSP_ADDRESS_FLAG_IPV6: GstRTSPAddressFlags = GstRTSPAddressFlags::IPV6; -pub const GST_RTSP_ADDRESS_FLAG_EVEN_PORT: GstRTSPAddressFlags = GstRTSPAddressFlags::EVEN_PORT; -pub const GST_RTSP_ADDRESS_FLAG_MULTICAST: GstRTSPAddressFlags = GstRTSPAddressFlags::MULTICAST; -pub const GST_RTSP_ADDRESS_FLAG_UNICAST: GstRTSPAddressFlags = GstRTSPAddressFlags::UNICAST; +pub type GstRTSPAddressFlags = c_uint; +pub const GST_RTSP_ADDRESS_FLAG_NONE: GstRTSPAddressFlags = 0; +pub const GST_RTSP_ADDRESS_FLAG_IPV4: GstRTSPAddressFlags = 1; +pub const GST_RTSP_ADDRESS_FLAG_IPV6: GstRTSPAddressFlags = 2; +pub const GST_RTSP_ADDRESS_FLAG_EVEN_PORT: GstRTSPAddressFlags = 4; +pub const GST_RTSP_ADDRESS_FLAG_MULTICAST: GstRTSPAddressFlags = 8; +pub const GST_RTSP_ADDRESS_FLAG_UNICAST: GstRTSPAddressFlags = 16; -bitflags! { - #[repr(C)] - pub struct GstRTSPTransportMode: c_uint { - const PLAY = 1; - const RECORD = 2; - } -} -pub const GST_RTSP_TRANSPORT_MODE_PLAY: GstRTSPTransportMode = GstRTSPTransportMode::PLAY; -pub const GST_RTSP_TRANSPORT_MODE_RECORD: GstRTSPTransportMode = GstRTSPTransportMode::RECORD; +pub type GstRTSPTransportMode = c_uint; +pub const GST_RTSP_TRANSPORT_MODE_PLAY: GstRTSPTransportMode = 1; +pub const GST_RTSP_TRANSPORT_MODE_RECORD: GstRTSPTransportMode = 2; // Callbacks pub type GstRTSPClientSendFunc = Option gboolean>; diff --git a/gstreamer-rtsp-server-sys/tests/abi.rs b/gstreamer-rtsp-server-sys/tests/abi.rs new file mode 100644 index 000000000..988c7d128 --- /dev/null +++ b/gstreamer-rtsp-server-sys/tests/abi.rs @@ -0,0 +1,331 @@ +// This file was generated by gir (https://github.com/gtk-rs/gir @ 6855214) +// from gir-files (https://github.com/gtk-rs/gir-files @ ???) +// DO NOT EDIT + +extern crate gstreamer_rtsp_server_sys; +extern crate shell_words; +extern crate tempdir; +use std::env; +use std::error::Error; +use std::path::Path; +use std::mem::{align_of, size_of}; +use std::process::Command; +use std::str; +use gstreamer_rtsp_server_sys::*; + +static PACKAGES: &[&str] = &["gstreamer-rtsp-server-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 = tempdir::TempDir::new("abi").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 = tempdir::TempDir::new("abi").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()); + } + + Ok(str::from_utf8(&output.stdout)?.trim().to_owned()) +} + +const RUST_LAYOUTS: &[(&str, Layout)] = &[ + ("GstRTSPAddress", Layout {size: size_of::(), alignment: align_of::()}), + ("GstRTSPAddressFlags", Layout {size: size_of::(), alignment: align_of::()}), + ("GstRTSPAddressPool", Layout {size: size_of::(), alignment: align_of::()}), + ("GstRTSPAddressPoolClass", Layout {size: size_of::(), alignment: align_of::()}), + ("GstRTSPAddressPoolResult", Layout {size: size_of::(), alignment: align_of::()}), + ("GstRTSPAuth", Layout {size: size_of::(), alignment: align_of::()}), + ("GstRTSPAuthClass", Layout {size: size_of::(), alignment: align_of::()}), + ("GstRTSPClient", Layout {size: size_of::(), alignment: align_of::()}), + ("GstRTSPClientClass", Layout {size: size_of::(), alignment: align_of::()}), + ("GstRTSPContext", Layout {size: size_of::(), alignment: align_of::()}), + ("GstRTSPFilterResult", Layout {size: size_of::(), alignment: align_of::()}), + ("GstRTSPMedia", Layout {size: size_of::(), alignment: align_of::()}), + ("GstRTSPMediaClass", Layout {size: size_of::(), alignment: align_of::()}), + ("GstRTSPMediaFactory", Layout {size: size_of::(), alignment: align_of::()}), + ("GstRTSPMediaFactoryClass", Layout {size: size_of::(), alignment: align_of::()}), + ("GstRTSPMediaFactoryURI", Layout {size: size_of::(), alignment: align_of::()}), + ("GstRTSPMediaFactoryURIClass", Layout {size: size_of::(), alignment: align_of::()}), + ("GstRTSPMediaStatus", Layout {size: size_of::(), alignment: align_of::()}), + ("GstRTSPMountPoints", Layout {size: size_of::(), alignment: align_of::()}), + ("GstRTSPMountPointsClass", Layout {size: size_of::(), alignment: align_of::()}), + ("GstRTSPOnvifClient", Layout {size: size_of::(), alignment: align_of::()}), + ("GstRTSPOnvifClientClass", Layout {size: size_of::(), alignment: align_of::()}), + ("GstRTSPOnvifMedia", Layout {size: size_of::(), alignment: align_of::()}), + ("GstRTSPOnvifMediaClass", Layout {size: size_of::(), alignment: align_of::()}), + ("GstRTSPOnvifMediaFactory", Layout {size: size_of::(), alignment: align_of::()}), + ("GstRTSPOnvifMediaFactoryClass", Layout {size: size_of::(), alignment: align_of::()}), + ("GstRTSPOnvifServer", Layout {size: size_of::(), alignment: align_of::()}), + ("GstRTSPOnvifServerClass", Layout {size: size_of::(), alignment: align_of::()}), + ("GstRTSPPermissions", Layout {size: size_of::(), alignment: align_of::()}), + ("GstRTSPPublishClockMode", Layout {size: size_of::(), alignment: align_of::()}), + ("GstRTSPServer", Layout {size: size_of::(), alignment: align_of::()}), + ("GstRTSPServerClass", Layout {size: size_of::(), alignment: align_of::()}), + ("GstRTSPSession", Layout {size: size_of::(), alignment: align_of::()}), + ("GstRTSPSessionClass", Layout {size: size_of::(), alignment: align_of::()}), + ("GstRTSPSessionMedia", Layout {size: size_of::(), alignment: align_of::()}), + ("GstRTSPSessionMediaClass", Layout {size: size_of::(), alignment: align_of::()}), + ("GstRTSPSessionPool", Layout {size: size_of::(), alignment: align_of::()}), + ("GstRTSPSessionPoolClass", Layout {size: size_of::(), alignment: align_of::()}), + ("GstRTSPStream", Layout {size: size_of::(), alignment: align_of::()}), + ("GstRTSPStreamClass", Layout {size: size_of::(), alignment: align_of::()}), + ("GstRTSPStreamTransport", Layout {size: size_of::(), alignment: align_of::()}), + ("GstRTSPStreamTransportClass", Layout {size: size_of::(), alignment: align_of::()}), + ("GstRTSPSuspendMode", Layout {size: size_of::(), alignment: align_of::()}), + ("GstRTSPThread", Layout {size: size_of::(), alignment: align_of::()}), + ("GstRTSPThreadPool", Layout {size: size_of::(), alignment: align_of::()}), + ("GstRTSPThreadPoolClass", Layout {size: size_of::(), alignment: align_of::()}), + ("GstRTSPThreadType", Layout {size: size_of::(), alignment: align_of::()}), + ("GstRTSPToken", Layout {size: size_of::(), alignment: align_of::()}), + ("GstRTSPTransportMode", Layout {size: size_of::(), alignment: align_of::()}), + ("GstSDPInfo", Layout {size: size_of::(), alignment: align_of::()}), +]; + +const RUST_CONSTANTS: &[(&str, &str)] = &[ + ("GST_RTSP_ADDRESS_FLAG_EVEN_PORT", "4"), + ("GST_RTSP_ADDRESS_FLAG_IPV4", "1"), + ("GST_RTSP_ADDRESS_FLAG_IPV6", "2"), + ("GST_RTSP_ADDRESS_FLAG_MULTICAST", "8"), + ("GST_RTSP_ADDRESS_FLAG_NONE", "0"), + ("GST_RTSP_ADDRESS_FLAG_UNICAST", "16"), + ("GST_RTSP_ADDRESS_POOL_ANY_IPV4", "0.0.0.0"), + ("GST_RTSP_ADDRESS_POOL_ANY_IPV6", "::"), + ("GST_RTSP_ADDRESS_POOL_EINVAL", "-1"), + ("GST_RTSP_ADDRESS_POOL_ELAST", "-4"), + ("GST_RTSP_ADDRESS_POOL_ERANGE", "-3"), + ("GST_RTSP_ADDRESS_POOL_ERESERVED", "-2"), + ("GST_RTSP_ADDRESS_POOL_OK", "0"), + ("GST_RTSP_AUTH_CHECK_CONNECT", "auth.check.connect"), + ("GST_RTSP_AUTH_CHECK_MEDIA_FACTORY_ACCESS", "auth.check.media.factory.access"), + ("GST_RTSP_AUTH_CHECK_MEDIA_FACTORY_CONSTRUCT", "auth.check.media.factory.construct"), + ("GST_RTSP_AUTH_CHECK_TRANSPORT_CLIENT_SETTINGS", "auth.check.transport.client-settings"), + ("GST_RTSP_AUTH_CHECK_URL", "auth.check.url"), + ("GST_RTSP_FILTER_KEEP", "1"), + ("GST_RTSP_FILTER_REF", "2"), + ("GST_RTSP_FILTER_REMOVE", "0"), + ("GST_RTSP_MEDIA_STATUS_ERROR", "5"), + ("GST_RTSP_MEDIA_STATUS_PREPARED", "3"), + ("GST_RTSP_MEDIA_STATUS_PREPARING", "2"), + ("GST_RTSP_MEDIA_STATUS_SUSPENDED", "4"), + ("GST_RTSP_MEDIA_STATUS_UNPREPARED", "0"), + ("GST_RTSP_MEDIA_STATUS_UNPREPARING", "1"), + ("GST_RTSP_ONVIF_BACKCHANNEL_REQUIREMENT", "www.onvif.org/ver20/backchannel"), + ("GST_RTSP_PERM_MEDIA_FACTORY_ACCESS", "media.factory.access"), + ("GST_RTSP_PERM_MEDIA_FACTORY_CONSTRUCT", "media.factory.construct"), + ("GST_RTSP_PUBLISH_CLOCK_MODE_CLOCK", "1"), + ("GST_RTSP_PUBLISH_CLOCK_MODE_CLOCK_AND_OFFSET", "2"), + ("GST_RTSP_PUBLISH_CLOCK_MODE_NONE", "0"), + ("GST_RTSP_SUSPEND_MODE_NONE", "0"), + ("GST_RTSP_SUSPEND_MODE_PAUSE", "1"), + ("GST_RTSP_SUSPEND_MODE_RESET", "2"), + ("GST_RTSP_THREAD_TYPE_CLIENT", "0"), + ("GST_RTSP_THREAD_TYPE_MEDIA", "1"), + ("GST_RTSP_TOKEN_MEDIA_FACTORY_ROLE", "media.factory.role"), + ("GST_RTSP_TOKEN_TRANSPORT_CLIENT_SETTINGS", "transport.client-settings"), + ("GST_RTSP_TRANSPORT_MODE_PLAY", "1"), + ("GST_RTSP_TRANSPORT_MODE_RECORD", "2"), +]; + + diff --git a/gstreamer-rtsp-server-sys/tests/constant.c b/gstreamer-rtsp-server-sys/tests/constant.c new file mode 100644 index 000000000..f95b609c2 --- /dev/null +++ b/gstreamer-rtsp-server-sys/tests/constant.c @@ -0,0 +1,27 @@ +// This file was generated by gir (https://github.com/gtk-rs/gir @ 6855214) +// from gir-files (https://github.com/gtk-rs/gir-files @ ???) +// DO NOT EDIT + +#include "manual.h" +#include + +int main() { + printf(_Generic((ABI_CONSTANT_NAME), + char *: "%s", + const char *: "%s", + char: "%c", + signed char: "%hhd", + unsigned char: "%hhu", + short int: "%hd", + unsigned short int: "%hu", + int: "%d", + unsigned int: "%u", + long: "%ld", + unsigned long: "%lu", + long long: "%lld", + unsigned long long: "%llu", + double: "%f", + long double: "%ld"), + ABI_CONSTANT_NAME); + return 0; +} diff --git a/gstreamer-rtsp-server-sys/tests/layout.c b/gstreamer-rtsp-server-sys/tests/layout.c new file mode 100644 index 000000000..e4be962df --- /dev/null +++ b/gstreamer-rtsp-server-sys/tests/layout.c @@ -0,0 +1,12 @@ +// This file was generated by gir (https://github.com/gtk-rs/gir @ 6855214) +// from gir-files (https://github.com/gtk-rs/gir-files @ ???) +// 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-rtsp-server-sys/tests/manual.h b/gstreamer-rtsp-server-sys/tests/manual.h new file mode 100644 index 000000000..76d26ad2b --- /dev/null +++ b/gstreamer-rtsp-server-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 diff --git a/gstreamer-rtsp-sys/Cargo.toml b/gstreamer-rtsp-sys/Cargo.toml index fe336aa95..6b68271d5 100644 --- a/gstreamer-rtsp-sys/Cargo.toml +++ b/gstreamer-rtsp-sys/Cargo.toml @@ -2,7 +2,6 @@ pkg-config = "0.3.7" [dependencies] -bitflags = "1.0" libc = "0.2" glib-sys = { git = "https://github.com/gtk-rs/sys" } gobject-sys = { git = "https://github.com/gtk-rs/sys" } @@ -14,6 +13,10 @@ path = "../gstreamer-sdp-sys" [dependencies.gstreamer-sys] path = "../gstreamer-sys" +[dev-dependencies] +shell-words = "0.1.0" +tempdir = "0.3" + [features] dox = [] v1_2 = [] diff --git a/gstreamer-rtsp-sys/src/lib.rs b/gstreamer-rtsp-sys/src/lib.rs index 958acd14b..b419ba536 100644 --- a/gstreamer-rtsp-sys/src/lib.rs +++ b/gstreamer-rtsp-sys/src/lib.rs @@ -1,11 +1,10 @@ -// This file was generated by gir (https://github.com/gtk-rs/gir @ fe7a6ff) +// This file was generated by gir (https://github.com/gtk-rs/gir @ 6855214) // 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)] extern crate libc; -#[macro_use] extern crate bitflags; extern crate glib_sys as glib; extern crate gobject_sys as gobject; extern crate gio_sys as gio; @@ -229,95 +228,45 @@ pub const GST_RTSP_VERSION_2_0: GstRTSPVersion = 32; pub const GST_RTSP_DEFAULT_PORT: c_int = 554; // Flags -bitflags! { - #[repr(C)] - pub struct GstRTSPEvent: c_uint { - const READ = 1; - const WRITE = 2; - } -} -pub const GST_RTSP_EV_READ: GstRTSPEvent = GstRTSPEvent::READ; -pub const GST_RTSP_EV_WRITE: GstRTSPEvent = GstRTSPEvent::WRITE; +pub type GstRTSPEvent = c_uint; +pub const GST_RTSP_EV_READ: GstRTSPEvent = 1; +pub const GST_RTSP_EV_WRITE: GstRTSPEvent = 2; -bitflags! { - #[repr(C)] - pub struct GstRTSPLowerTrans: c_uint { - const UNKNOWN = 0; - const UDP = 1; - const UDP_MCAST = 2; - const TCP = 4; - const HTTP = 16; - const TLS = 32; - } -} -pub const GST_RTSP_LOWER_TRANS_UNKNOWN: GstRTSPLowerTrans = GstRTSPLowerTrans::UNKNOWN; -pub const GST_RTSP_LOWER_TRANS_UDP: GstRTSPLowerTrans = GstRTSPLowerTrans::UDP; -pub const GST_RTSP_LOWER_TRANS_UDP_MCAST: GstRTSPLowerTrans = GstRTSPLowerTrans::UDP_MCAST; -pub const GST_RTSP_LOWER_TRANS_TCP: GstRTSPLowerTrans = GstRTSPLowerTrans::TCP; -pub const GST_RTSP_LOWER_TRANS_HTTP: GstRTSPLowerTrans = GstRTSPLowerTrans::HTTP; -pub const GST_RTSP_LOWER_TRANS_TLS: GstRTSPLowerTrans = GstRTSPLowerTrans::TLS; +pub type GstRTSPLowerTrans = c_uint; +pub const GST_RTSP_LOWER_TRANS_UNKNOWN: GstRTSPLowerTrans = 0; +pub const GST_RTSP_LOWER_TRANS_UDP: GstRTSPLowerTrans = 1; +pub const GST_RTSP_LOWER_TRANS_UDP_MCAST: GstRTSPLowerTrans = 2; +pub const GST_RTSP_LOWER_TRANS_TCP: GstRTSPLowerTrans = 4; +pub const GST_RTSP_LOWER_TRANS_HTTP: GstRTSPLowerTrans = 16; +pub const GST_RTSP_LOWER_TRANS_TLS: GstRTSPLowerTrans = 32; -bitflags! { - #[repr(C)] - pub struct GstRTSPMethod: c_uint { - const INVALID = 0; - const DESCRIBE = 1; - const ANNOUNCE = 2; - const GET_PARAMETER = 4; - const OPTIONS = 8; - const PAUSE = 16; - const PLAY = 32; - const RECORD = 64; - const REDIRECT = 128; - const SETUP = 256; - const SET_PARAMETER = 512; - const TEARDOWN = 1024; - const GET = 2048; - const POST = 4096; - } -} -pub const GST_RTSP_INVALID: GstRTSPMethod = GstRTSPMethod::INVALID; -pub const GST_RTSP_DESCRIBE: GstRTSPMethod = GstRTSPMethod::DESCRIBE; -pub const GST_RTSP_ANNOUNCE: GstRTSPMethod = GstRTSPMethod::ANNOUNCE; -pub const GST_RTSP_GET_PARAMETER: GstRTSPMethod = GstRTSPMethod::GET_PARAMETER; -pub const GST_RTSP_OPTIONS: GstRTSPMethod = GstRTSPMethod::OPTIONS; -pub const GST_RTSP_PAUSE: GstRTSPMethod = GstRTSPMethod::PAUSE; -pub const GST_RTSP_PLAY: GstRTSPMethod = GstRTSPMethod::PLAY; -pub const GST_RTSP_RECORD: GstRTSPMethod = GstRTSPMethod::RECORD; -pub const GST_RTSP_REDIRECT: GstRTSPMethod = GstRTSPMethod::REDIRECT; -pub const GST_RTSP_SETUP: GstRTSPMethod = GstRTSPMethod::SETUP; -pub const GST_RTSP_SET_PARAMETER: GstRTSPMethod = GstRTSPMethod::SET_PARAMETER; -pub const GST_RTSP_TEARDOWN: GstRTSPMethod = GstRTSPMethod::TEARDOWN; -pub const GST_RTSP_GET: GstRTSPMethod = GstRTSPMethod::GET; -pub const GST_RTSP_POST: GstRTSPMethod = GstRTSPMethod::POST; +pub type GstRTSPMethod = c_uint; +pub const GST_RTSP_INVALID: GstRTSPMethod = 0; +pub const GST_RTSP_DESCRIBE: GstRTSPMethod = 1; +pub const GST_RTSP_ANNOUNCE: GstRTSPMethod = 2; +pub const GST_RTSP_GET_PARAMETER: GstRTSPMethod = 4; +pub const GST_RTSP_OPTIONS: GstRTSPMethod = 8; +pub const GST_RTSP_PAUSE: GstRTSPMethod = 16; +pub const GST_RTSP_PLAY: GstRTSPMethod = 32; +pub const GST_RTSP_RECORD: GstRTSPMethod = 64; +pub const GST_RTSP_REDIRECT: GstRTSPMethod = 128; +pub const GST_RTSP_SETUP: GstRTSPMethod = 256; +pub const GST_RTSP_SET_PARAMETER: GstRTSPMethod = 512; +pub const GST_RTSP_TEARDOWN: GstRTSPMethod = 1024; +pub const GST_RTSP_GET: GstRTSPMethod = 2048; +pub const GST_RTSP_POST: GstRTSPMethod = 4096; -bitflags! { - #[repr(C)] - pub struct GstRTSPProfile: c_uint { - const UNKNOWN = 0; - const AVP = 1; - const SAVP = 2; - const AVPF = 4; - const SAVPF = 8; - } -} -pub const GST_RTSP_PROFILE_UNKNOWN: GstRTSPProfile = GstRTSPProfile::UNKNOWN; -pub const GST_RTSP_PROFILE_AVP: GstRTSPProfile = GstRTSPProfile::AVP; -pub const GST_RTSP_PROFILE_SAVP: GstRTSPProfile = GstRTSPProfile::SAVP; -pub const GST_RTSP_PROFILE_AVPF: GstRTSPProfile = GstRTSPProfile::AVPF; -pub const GST_RTSP_PROFILE_SAVPF: GstRTSPProfile = GstRTSPProfile::SAVPF; +pub type GstRTSPProfile = c_uint; +pub const GST_RTSP_PROFILE_UNKNOWN: GstRTSPProfile = 0; +pub const GST_RTSP_PROFILE_AVP: GstRTSPProfile = 1; +pub const GST_RTSP_PROFILE_SAVP: GstRTSPProfile = 2; +pub const GST_RTSP_PROFILE_AVPF: GstRTSPProfile = 4; +pub const GST_RTSP_PROFILE_SAVPF: GstRTSPProfile = 8; -bitflags! { - #[repr(C)] - pub struct GstRTSPTransMode: c_uint { - const UNKNOWN = 0; - const RTP = 1; - const RDT = 2; - } -} -pub const GST_RTSP_TRANS_UNKNOWN: GstRTSPTransMode = GstRTSPTransMode::UNKNOWN; -pub const GST_RTSP_TRANS_RTP: GstRTSPTransMode = GstRTSPTransMode::RTP; -pub const GST_RTSP_TRANS_RDT: GstRTSPTransMode = GstRTSPTransMode::RDT; +pub type GstRTSPTransMode = c_uint; +pub const GST_RTSP_TRANS_UNKNOWN: GstRTSPTransMode = 0; +pub const GST_RTSP_TRANS_RTP: GstRTSPTransMode = 1; +pub const GST_RTSP_TRANS_RDT: GstRTSPTransMode = 2; // Unions #[repr(C)] diff --git a/gstreamer-rtsp-sys/tests/abi.rs b/gstreamer-rtsp-sys/tests/abi.rs new file mode 100644 index 000000000..a525545ef --- /dev/null +++ b/gstreamer-rtsp-sys/tests/abi.rs @@ -0,0 +1,480 @@ +// This file was generated by gir (https://github.com/gtk-rs/gir @ 6855214) +// from gir-files (https://github.com/gtk-rs/gir-files @ ???) +// DO NOT EDIT + +extern crate gstreamer_rtsp_sys; +extern crate shell_words; +extern crate tempdir; +use std::env; +use std::error::Error; +use std::path::Path; +use std::mem::{align_of, size_of}; +use std::process::Command; +use std::str; +use gstreamer_rtsp_sys::*; + +static PACKAGES: &[&str] = &["gstreamer-rtsp-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 = tempdir::TempDir::new("abi").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 = tempdir::TempDir::new("abi").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()); + } + + Ok(str::from_utf8(&output.stdout)?.trim().to_owned()) +} + +const RUST_LAYOUTS: &[(&str, Layout)] = &[ + ("GstRTSPAuthCredential", Layout {size: size_of::(), alignment: align_of::()}), + ("GstRTSPAuthMethod", Layout {size: size_of::(), alignment: align_of::()}), + ("GstRTSPAuthParam", Layout {size: size_of::(), alignment: align_of::()}), + ("GstRTSPEvent", Layout {size: size_of::(), alignment: align_of::()}), + ("GstRTSPExtensionInterface", Layout {size: size_of::(), alignment: align_of::()}), + ("GstRTSPFamily", Layout {size: size_of::(), alignment: align_of::()}), + ("GstRTSPHeaderField", Layout {size: size_of::(), alignment: align_of::()}), + ("GstRTSPLowerTrans", Layout {size: size_of::(), alignment: align_of::()}), + ("GstRTSPMessage", Layout {size: size_of::(), alignment: align_of::()}), + ("GstRTSPMethod", Layout {size: size_of::(), alignment: align_of::()}), + ("GstRTSPMsgType", Layout {size: size_of::(), alignment: align_of::()}), + ("GstRTSPProfile", Layout {size: size_of::(), alignment: align_of::()}), + ("GstRTSPRange", Layout {size: size_of::(), alignment: align_of::()}), + ("GstRTSPRangeUnit", Layout {size: size_of::(), alignment: align_of::()}), + ("GstRTSPResult", Layout {size: size_of::(), alignment: align_of::()}), + ("GstRTSPState", Layout {size: size_of::(), alignment: align_of::()}), + ("GstRTSPStatusCode", Layout {size: size_of::(), alignment: align_of::()}), + ("GstRTSPTime", Layout {size: size_of::(), alignment: align_of::()}), + ("GstRTSPTime2", Layout {size: size_of::(), alignment: align_of::()}), + ("GstRTSPTimeRange", Layout {size: size_of::(), alignment: align_of::()}), + ("GstRTSPTimeType", Layout {size: size_of::(), alignment: align_of::()}), + ("GstRTSPTransMode", Layout {size: size_of::(), alignment: align_of::()}), + ("GstRTSPTransport", Layout {size: size_of::(), alignment: align_of::()}), + ("GstRTSPUrl", Layout {size: size_of::(), alignment: align_of::()}), + ("GstRTSPVersion", Layout {size: size_of::(), alignment: align_of::()}), + ("GstRTSPWatchFuncs", Layout {size: size_of::(), alignment: align_of::()}), +]; + +const RUST_CONSTANTS: &[(&str, &str)] = &[ + ("GST_RTSP_ANNOUNCE", "2"), + ("GST_RTSP_AUTH_BASIC", "1"), + ("GST_RTSP_AUTH_DIGEST", "2"), + ("GST_RTSP_AUTH_NONE", "0"), + ("GST_RTSP_DEFAULT_PORT", "554"), + ("GST_RTSP_DESCRIBE", "1"), + ("GST_RTSP_EEOF", "-11"), + ("GST_RTSP_EINTR", "-3"), + ("GST_RTSP_EINVAL", "-2"), + ("GST_RTSP_ELAST", "-17"), + ("GST_RTSP_ENET", "-12"), + ("GST_RTSP_ENOMEM", "-4"), + ("GST_RTSP_ENOTIMPL", "-6"), + ("GST_RTSP_ENOTIP", "-13"), + ("GST_RTSP_EPARSE", "-8"), + ("GST_RTSP_ERESOLV", "-5"), + ("GST_RTSP_ERROR", "-1"), + ("GST_RTSP_ESYS", "-7"), + ("GST_RTSP_ETGET", "-15"), + ("GST_RTSP_ETIMEOUT", "-14"), + ("GST_RTSP_ETPOST", "-16"), + ("GST_RTSP_EV_READ", "1"), + ("GST_RTSP_EV_WRITE", "2"), + ("GST_RTSP_EWSASTART", "-9"), + ("GST_RTSP_EWSAVERSION", "-10"), + ("GST_RTSP_FAM_INET", "1"), + ("GST_RTSP_FAM_INET6", "2"), + ("GST_RTSP_FAM_NONE", "0"), + ("GST_RTSP_GET", "2048"), + ("GST_RTSP_GET_PARAMETER", "4"), + ("GST_RTSP_HDR_ACCEPT", "1"), + ("GST_RTSP_HDR_ACCEPT_CHARSET", "56"), + ("GST_RTSP_HDR_ACCEPT_ENCODING", "2"), + ("GST_RTSP_HDR_ACCEPT_LANGUAGE", "3"), + ("GST_RTSP_HDR_ACCEPT_RANGES", "86"), + ("GST_RTSP_HDR_ALERT", "45"), + ("GST_RTSP_HDR_ALLOW", "4"), + ("GST_RTSP_HDR_AUTHENTICATION_INFO", "76"), + ("GST_RTSP_HDR_AUTHORIZATION", "5"), + ("GST_RTSP_HDR_BANDWIDTH", "6"), + ("GST_RTSP_HDR_BLOCKSIZE", "7"), + ("GST_RTSP_HDR_CACHE_CONTROL", "8"), + ("GST_RTSP_HDR_CLIENT_CHALLENGE", "40"), + ("GST_RTSP_HDR_CLIENT_ID", "46"), + ("GST_RTSP_HDR_COMPANY_ID", "47"), + ("GST_RTSP_HDR_CONFERENCE", "9"), + ("GST_RTSP_HDR_CONNECTION", "10"), + ("GST_RTSP_HDR_CONTENT_BASE", "11"), + ("GST_RTSP_HDR_CONTENT_ENCODING", "12"), + ("GST_RTSP_HDR_CONTENT_LANGUAGE", "13"), + ("GST_RTSP_HDR_CONTENT_LENGTH", "14"), + ("GST_RTSP_HDR_CONTENT_LOCATION", "15"), + ("GST_RTSP_HDR_CONTENT_TYPE", "16"), + ("GST_RTSP_HDR_CSEQ", "17"), + ("GST_RTSP_HDR_DATE", "18"), + ("GST_RTSP_HDR_ETAG", "54"), + ("GST_RTSP_HDR_EXPIRES", "19"), + ("GST_RTSP_HDR_FROM", "20"), + ("GST_RTSP_HDR_GUID", "48"), + ("GST_RTSP_HDR_HOST", "77"), + ("GST_RTSP_HDR_IF_MATCH", "55"), + ("GST_RTSP_HDR_IF_MODIFIED_SINCE", "21"), + ("GST_RTSP_HDR_INVALID", "0"), + ("GST_RTSP_HDR_KEYMGMT", "82"), + ("GST_RTSP_HDR_LANGUAGE", "51"), + ("GST_RTSP_HDR_LAST", "87"), + ("GST_RTSP_HDR_LAST_MODIFIED", "22"), + ("GST_RTSP_HDR_LOCATION", "53"), + ("GST_RTSP_HDR_MAX_ASM_WIDTH", "50"), + ("GST_RTSP_HDR_MEDIA_PROPERTIES", "84"), + ("GST_RTSP_HDR_PIPELINED_REQUESTS", "83"), + ("GST_RTSP_HDR_PLAYER_START_TIME", "52"), + ("GST_RTSP_HDR_PRAGMA", "78"), + ("GST_RTSP_HDR_PROXY_AUTHENTICATE", "23"), + ("GST_RTSP_HDR_PROXY_REQUIRE", "24"), + ("GST_RTSP_HDR_PUBLIC", "25"), + ("GST_RTSP_HDR_RANGE", "26"), + ("GST_RTSP_HDR_REAL_CHALLENGE1", "41"), + ("GST_RTSP_HDR_REAL_CHALLENGE2", "42"), + ("GST_RTSP_HDR_REAL_CHALLENGE3", "43"), + ("GST_RTSP_HDR_REFERER", "27"), + ("GST_RTSP_HDR_REGION_DATA", "49"), + ("GST_RTSP_HDR_REQUIRE", "28"), + ("GST_RTSP_HDR_RETRY_AFTER", "29"), + ("GST_RTSP_HDR_RTCP_INTERVAL", "81"), + ("GST_RTSP_HDR_RTP_INFO", "30"), + ("GST_RTSP_HDR_SCALE", "31"), + ("GST_RTSP_HDR_SEEK_STYLE", "85"), + ("GST_RTSP_HDR_SERVER", "33"), + ("GST_RTSP_HDR_SESSION", "32"), + ("GST_RTSP_HDR_SPEED", "34"), + ("GST_RTSP_HDR_SUBSCRIBE", "44"), + ("GST_RTSP_HDR_SUPPORTED", "57"), + ("GST_RTSP_HDR_TIMESTAMP", "75"), + ("GST_RTSP_HDR_TRANSPORT", "35"), + ("GST_RTSP_HDR_UNSUPPORTED", "36"), + ("GST_RTSP_HDR_USER_AGENT", "37"), + ("GST_RTSP_HDR_VARY", "58"), + ("GST_RTSP_HDR_VIA", "38"), + ("GST_RTSP_HDR_WWW_AUTHENTICATE", "39"), + ("GST_RTSP_HDR_X_ACCELERATE_STREAMING", "59"), + ("GST_RTSP_HDR_X_ACCEPT_AUTHENT", "60"), + ("GST_RTSP_HDR_X_ACCEPT_PROXY_AUTHENT", "61"), + ("GST_RTSP_HDR_X_BROADCAST_ID", "62"), + ("GST_RTSP_HDR_X_BURST_STREAMING", "63"), + ("GST_RTSP_HDR_X_NOTICE", "64"), + ("GST_RTSP_HDR_X_PLAYER_LAG_TIME", "65"), + ("GST_RTSP_HDR_X_PLAYLIST", "66"), + ("GST_RTSP_HDR_X_PLAYLIST_CHANGE_NOTICE", "67"), + ("GST_RTSP_HDR_X_PLAYLIST_GEN_ID", "68"), + ("GST_RTSP_HDR_X_PLAYLIST_SEEK_ID", "69"), + ("GST_RTSP_HDR_X_PROXY_CLIENT_AGENT", "70"), + ("GST_RTSP_HDR_X_PROXY_CLIENT_VERB", "71"), + ("GST_RTSP_HDR_X_RECEDING_PLAYLISTCHANGE", "72"), + ("GST_RTSP_HDR_X_RTP_INFO", "73"), + ("GST_RTSP_HDR_X_SERVER_IP_ADDRESS", "79"), + ("GST_RTSP_HDR_X_SESSIONCOOKIE", "80"), + ("GST_RTSP_HDR_X_STARTUPPROFILE", "74"), + ("GST_RTSP_INVALID", "0"), + ("GST_RTSP_LOWER_TRANS_HTTP", "16"), + ("GST_RTSP_LOWER_TRANS_TCP", "4"), + ("GST_RTSP_LOWER_TRANS_TLS", "32"), + ("GST_RTSP_LOWER_TRANS_UDP", "1"), + ("GST_RTSP_LOWER_TRANS_UDP_MCAST", "2"), + ("GST_RTSP_LOWER_TRANS_UNKNOWN", "0"), + ("GST_RTSP_MESSAGE_DATA", "5"), + ("GST_RTSP_MESSAGE_HTTP_REQUEST", "3"), + ("GST_RTSP_MESSAGE_HTTP_RESPONSE", "4"), + ("GST_RTSP_MESSAGE_INVALID", "0"), + ("GST_RTSP_MESSAGE_REQUEST", "1"), + ("GST_RTSP_MESSAGE_RESPONSE", "2"), + ("GST_RTSP_OK", "0"), + ("GST_RTSP_OPTIONS", "8"), + ("GST_RTSP_PAUSE", "16"), + ("GST_RTSP_PLAY", "32"), + ("GST_RTSP_POST", "4096"), + ("GST_RTSP_PROFILE_AVP", "1"), + ("GST_RTSP_PROFILE_AVPF", "4"), + ("GST_RTSP_PROFILE_SAVP", "2"), + ("GST_RTSP_PROFILE_SAVPF", "8"), + ("GST_RTSP_PROFILE_UNKNOWN", "0"), + ("GST_RTSP_RANGE_CLOCK", "4"), + ("GST_RTSP_RANGE_NPT", "3"), + ("GST_RTSP_RANGE_SMPTE", "0"), + ("GST_RTSP_RANGE_SMPTE_25", "2"), + ("GST_RTSP_RANGE_SMPTE_30_DROP", "1"), + ("GST_RTSP_RECORD", "64"), + ("GST_RTSP_REDIRECT", "128"), + ("GST_RTSP_SETUP", "256"), + ("GST_RTSP_SET_PARAMETER", "512"), + ("GST_RTSP_STATE_INIT", "1"), + ("GST_RTSP_STATE_INVALID", "0"), + ("GST_RTSP_STATE_PLAYING", "4"), + ("GST_RTSP_STATE_READY", "2"), + ("GST_RTSP_STATE_RECORDING", "5"), + ("GST_RTSP_STATE_SEEKING", "3"), + ("GST_RTSP_STS_AGGREGATE_OPERATION_NOT_ALLOWED", "459"), + ("GST_RTSP_STS_BAD_GATEWAY", "502"), + ("GST_RTSP_STS_BAD_REQUEST", "400"), + ("GST_RTSP_STS_CONFERENCE_NOT_FOUND", "452"), + ("GST_RTSP_STS_CONTINUE", "100"), + ("GST_RTSP_STS_CREATED", "201"), + ("GST_RTSP_STS_DESTINATION_UNREACHABLE", "462"), + ("GST_RTSP_STS_FORBIDDEN", "403"), + ("GST_RTSP_STS_GATEWAY_TIMEOUT", "504"), + ("GST_RTSP_STS_GONE", "410"), + ("GST_RTSP_STS_HEADER_FIELD_NOT_VALID_FOR_RESOURCE", "456"), + ("GST_RTSP_STS_INTERNAL_SERVER_ERROR", "500"), + ("GST_RTSP_STS_INVALID", "0"), + ("GST_RTSP_STS_INVALID_RANGE", "457"), + ("GST_RTSP_STS_KEY_MANAGEMENT_FAILURE", "463"), + ("GST_RTSP_STS_LENGTH_REQUIRED", "411"), + ("GST_RTSP_STS_LOW_ON_STORAGE", "250"), + ("GST_RTSP_STS_METHOD_NOT_ALLOWED", "405"), + ("GST_RTSP_STS_METHOD_NOT_VALID_IN_THIS_STATE", "455"), + ("GST_RTSP_STS_MOVED_PERMANENTLY", "301"), + ("GST_RTSP_STS_MOVE_TEMPORARILY", "302"), + ("GST_RTSP_STS_MULTIPLE_CHOICES", "300"), + ("GST_RTSP_STS_NOT_ACCEPTABLE", "406"), + ("GST_RTSP_STS_NOT_ENOUGH_BANDWIDTH", "453"), + ("GST_RTSP_STS_NOT_FOUND", "404"), + ("GST_RTSP_STS_NOT_IMPLEMENTED", "501"), + ("GST_RTSP_STS_NOT_MODIFIED", "304"), + ("GST_RTSP_STS_OK", "200"), + ("GST_RTSP_STS_ONLY_AGGREGATE_OPERATION_ALLOWED", "460"), + ("GST_RTSP_STS_OPTION_NOT_SUPPORTED", "551"), + ("GST_RTSP_STS_PARAMETER_IS_READONLY", "458"), + ("GST_RTSP_STS_PARAMETER_NOT_UNDERSTOOD", "451"), + ("GST_RTSP_STS_PAYMENT_REQUIRED", "402"), + ("GST_RTSP_STS_PRECONDITION_FAILED", "412"), + ("GST_RTSP_STS_PROXY_AUTH_REQUIRED", "407"), + ("GST_RTSP_STS_REQUEST_ENTITY_TOO_LARGE", "413"), + ("GST_RTSP_STS_REQUEST_TIMEOUT", "408"), + ("GST_RTSP_STS_REQUEST_URI_TOO_LARGE", "414"), + ("GST_RTSP_STS_RTSP_VERSION_NOT_SUPPORTED", "505"), + ("GST_RTSP_STS_SEE_OTHER", "303"), + ("GST_RTSP_STS_SERVICE_UNAVAILABLE", "503"), + ("GST_RTSP_STS_SESSION_NOT_FOUND", "454"), + ("GST_RTSP_STS_UNAUTHORIZED", "401"), + ("GST_RTSP_STS_UNSUPPORTED_MEDIA_TYPE", "415"), + ("GST_RTSP_STS_UNSUPPORTED_TRANSPORT", "461"), + ("GST_RTSP_STS_USE_PROXY", "305"), + ("GST_RTSP_TEARDOWN", "1024"), + ("GST_RTSP_TIME_END", "2"), + ("GST_RTSP_TIME_FRAMES", "3"), + ("GST_RTSP_TIME_NOW", "1"), + ("GST_RTSP_TIME_SECONDS", "0"), + ("GST_RTSP_TIME_UTC", "4"), + ("GST_RTSP_TRANS_RDT", "2"), + ("GST_RTSP_TRANS_RTP", "1"), + ("GST_RTSP_TRANS_UNKNOWN", "0"), + ("GST_RTSP_VERSION_1_0", "16"), + ("GST_RTSP_VERSION_1_1", "17"), + ("GST_RTSP_VERSION_2_0", "32"), + ("GST_RTSP_VERSION_INVALID", "0"), +]; + + diff --git a/gstreamer-rtsp-sys/tests/constant.c b/gstreamer-rtsp-sys/tests/constant.c new file mode 100644 index 000000000..f95b609c2 --- /dev/null +++ b/gstreamer-rtsp-sys/tests/constant.c @@ -0,0 +1,27 @@ +// This file was generated by gir (https://github.com/gtk-rs/gir @ 6855214) +// from gir-files (https://github.com/gtk-rs/gir-files @ ???) +// DO NOT EDIT + +#include "manual.h" +#include + +int main() { + printf(_Generic((ABI_CONSTANT_NAME), + char *: "%s", + const char *: "%s", + char: "%c", + signed char: "%hhd", + unsigned char: "%hhu", + short int: "%hd", + unsigned short int: "%hu", + int: "%d", + unsigned int: "%u", + long: "%ld", + unsigned long: "%lu", + long long: "%lld", + unsigned long long: "%llu", + double: "%f", + long double: "%ld"), + ABI_CONSTANT_NAME); + return 0; +} diff --git a/gstreamer-rtsp-sys/tests/layout.c b/gstreamer-rtsp-sys/tests/layout.c new file mode 100644 index 000000000..e4be962df --- /dev/null +++ b/gstreamer-rtsp-sys/tests/layout.c @@ -0,0 +1,12 @@ +// This file was generated by gir (https://github.com/gtk-rs/gir @ 6855214) +// from gir-files (https://github.com/gtk-rs/gir-files @ ???) +// 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-rtsp-sys/tests/manual.h b/gstreamer-rtsp-sys/tests/manual.h new file mode 100644 index 000000000..faebe64fb --- /dev/null +++ b/gstreamer-rtsp-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 diff --git a/gstreamer-sdp-sys/Cargo.toml b/gstreamer-sdp-sys/Cargo.toml index 1313caed6..85989ccef 100644 --- a/gstreamer-sdp-sys/Cargo.toml +++ b/gstreamer-sdp-sys/Cargo.toml @@ -9,6 +9,10 @@ gobject-sys = { git = "https://github.com/gtk-rs/sys" } [dependencies.gstreamer-sys] path = "../gstreamer-sys" +[dev-dependencies] +shell-words = "0.1.0" +tempdir = "0.3" + [features] dox = [] v1_2 = [] diff --git a/gstreamer-sdp-sys/src/lib.rs b/gstreamer-sdp-sys/src/lib.rs index c8a1126ef..14d25208b 100644 --- a/gstreamer-sdp-sys/src/lib.rs +++ b/gstreamer-sdp-sys/src/lib.rs @@ -1,4 +1,4 @@ -// This file was generated by gir (https://github.com/gtk-rs/gir @ fe7a6ff) +// This file was generated by gir (https://github.com/gtk-rs/gir @ 6855214) // from gir-files (https://github.com/gtk-rs/gir-files @ ???) // DO NOT EDIT diff --git a/gstreamer-sdp-sys/tests/abi.rs b/gstreamer-sdp-sys/tests/abi.rs new file mode 100644 index 000000000..70bc07af3 --- /dev/null +++ b/gstreamer-sdp-sys/tests/abi.rs @@ -0,0 +1,335 @@ +// This file was generated by gir (https://github.com/gtk-rs/gir @ 6855214) +// from gir-files (https://github.com/gtk-rs/gir-files @ ???) +// DO NOT EDIT + +extern crate gstreamer_sdp_sys; +extern crate shell_words; +extern crate tempdir; +use std::env; +use std::error::Error; +use std::path::Path; +use std::mem::{align_of, size_of}; +use std::process::Command; +use std::str; +use gstreamer_sdp_sys::*; + +static PACKAGES: &[&str] = &["gstreamer-sdp-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 = tempdir::TempDir::new("abi").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 = tempdir::TempDir::new("abi").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()); + } + + Ok(str::from_utf8(&output.stdout)?.trim().to_owned()) +} + +const RUST_LAYOUTS: &[(&str, Layout)] = &[ + ("GstMIKEYCacheType", Layout {size: size_of::(), alignment: align_of::()}), + ("GstMIKEYEncAlg", Layout {size: size_of::(), alignment: align_of::()}), + ("GstMIKEYKVType", Layout {size: size_of::(), alignment: align_of::()}), + ("GstMIKEYKeyDataType", Layout {size: size_of::(), alignment: align_of::()}), + ("GstMIKEYMacAlg", Layout {size: size_of::(), alignment: align_of::()}), + ("GstMIKEYMapSRTP", Layout {size: size_of::(), alignment: align_of::()}), + ("GstMIKEYMapType", Layout {size: size_of::(), alignment: align_of::()}), + ("GstMIKEYMessage", Layout {size: size_of::(), alignment: align_of::()}), + ("GstMIKEYPRFFunc", Layout {size: size_of::(), alignment: align_of::()}), + ("GstMIKEYPayload", Layout {size: size_of::(), alignment: align_of::()}), + ("GstMIKEYPayloadKEMAC", Layout {size: size_of::(), alignment: align_of::()}), + ("GstMIKEYPayloadKeyData", Layout {size: size_of::(), alignment: align_of::()}), + ("GstMIKEYPayloadPKE", Layout {size: size_of::(), alignment: align_of::()}), + ("GstMIKEYPayloadRAND", Layout {size: size_of::(), alignment: align_of::()}), + ("GstMIKEYPayloadSP", Layout {size: size_of::(), alignment: align_of::()}), + ("GstMIKEYPayloadSPParam", Layout {size: size_of::(), alignment: align_of::()}), + ("GstMIKEYPayloadT", Layout {size: size_of::(), alignment: align_of::()}), + ("GstMIKEYPayloadType", Layout {size: size_of::(), alignment: align_of::()}), + ("GstMIKEYSecProto", Layout {size: size_of::(), alignment: align_of::()}), + ("GstMIKEYSecSRTP", Layout {size: size_of::(), alignment: align_of::()}), + ("GstMIKEYTSType", Layout {size: size_of::(), alignment: align_of::()}), + ("GstMIKEYType", Layout {size: size_of::(), alignment: align_of::()}), + ("GstSDPAttribute", Layout {size: size_of::(), alignment: align_of::()}), + ("GstSDPBandwidth", Layout {size: size_of::(), alignment: align_of::()}), + ("GstSDPConnection", Layout {size: size_of::(), alignment: align_of::()}), + ("GstSDPKey", Layout {size: size_of::(), alignment: align_of::()}), + ("GstSDPMedia", Layout {size: size_of::(), alignment: align_of::()}), + ("GstSDPMessage", Layout {size: size_of::(), alignment: align_of::()}), + ("GstSDPOrigin", Layout {size: size_of::(), alignment: align_of::()}), + ("GstSDPResult", Layout {size: size_of::(), alignment: align_of::()}), + ("GstSDPTime", Layout {size: size_of::(), alignment: align_of::()}), + ("GstSDPZone", Layout {size: size_of::(), alignment: align_of::()}), +]; + +const RUST_CONSTANTS: &[(&str, &str)] = &[ + ("GST_MIKEY_CACHE_ALWAYS", "1"), + ("GST_MIKEY_CACHE_FOR_CSB", "2"), + ("GST_MIKEY_CACHE_NONE", "0"), + ("GST_MIKEY_ENC_AES_CM_128", "1"), + ("GST_MIKEY_ENC_AES_KW_128", "2"), + ("GST_MIKEY_ENC_NULL", "0"), + ("GST_MIKEY_KD_TEK", "2"), + ("GST_MIKEY_KD_TGK", "0"), + ("GST_MIKEY_KV_INTERVAL", "2"), + ("GST_MIKEY_KV_NULL", "0"), + ("GST_MIKEY_KV_SPI", "1"), + ("GST_MIKEY_MAC_HMAC_SHA_1_160", "1"), + ("GST_MIKEY_MAC_NULL", "0"), + ("GST_MIKEY_MAP_TYPE_SRTP", "0"), + ("GST_MIKEY_PRF_MIKEY_1", "0"), + ("GST_MIKEY_PT_CERT", "7"), + ("GST_MIKEY_PT_CHASH", "8"), + ("GST_MIKEY_PT_DH", "3"), + ("GST_MIKEY_PT_ERR", "12"), + ("GST_MIKEY_PT_GEN_EXT", "21"), + ("GST_MIKEY_PT_ID", "6"), + ("GST_MIKEY_PT_KEMAC", "1"), + ("GST_MIKEY_PT_KEY_DATA", "20"), + ("GST_MIKEY_PT_LAST", "0"), + ("GST_MIKEY_PT_PKE", "2"), + ("GST_MIKEY_PT_RAND", "11"), + ("GST_MIKEY_PT_SIGN", "4"), + ("GST_MIKEY_PT_SP", "10"), + ("GST_MIKEY_PT_T", "5"), + ("GST_MIKEY_PT_V", "9"), + ("GST_MIKEY_SEC_PROTO_SRTP", "0"), + ("GST_MIKEY_SP_SRTP_AUTH_ALG", "2"), + ("GST_MIKEY_SP_SRTP_AUTH_KEY_LEN", "3"), + ("GST_MIKEY_SP_SRTP_AUTH_TAG_LEN", "11"), + ("GST_MIKEY_SP_SRTP_ENC_ALG", "0"), + ("GST_MIKEY_SP_SRTP_ENC_KEY_LEN", "1"), + ("GST_MIKEY_SP_SRTP_FEC_ORDER", "9"), + ("GST_MIKEY_SP_SRTP_KEY_DERIV_RATE", "6"), + ("GST_MIKEY_SP_SRTP_PRF", "5"), + ("GST_MIKEY_SP_SRTP_SALT_KEY_LEN", "4"), + ("GST_MIKEY_SP_SRTP_SRTCP_ENC", "8"), + ("GST_MIKEY_SP_SRTP_SRTP_AUTH", "10"), + ("GST_MIKEY_SP_SRTP_SRTP_ENC", "7"), + ("GST_MIKEY_SP_SRTP_SRTP_PREFIX_LEN", "12"), + ("GST_MIKEY_TS_TYPE_COUNTER", "2"), + ("GST_MIKEY_TS_TYPE_NTP", "1"), + ("GST_MIKEY_TS_TYPE_NTP_UTC", "0"), + ("GST_MIKEY_TYPE_DH_INIT", "4"), + ("GST_MIKEY_TYPE_DH_RESP", "5"), + ("GST_MIKEY_TYPE_ERROR", "6"), + ("GST_MIKEY_TYPE_INVALID", "-1"), + ("GST_MIKEY_TYPE_PK_INIT", "2"), + ("GST_MIKEY_TYPE_PK_VERIFY", "3"), + ("GST_MIKEY_TYPE_PSK_INIT", "0"), + ("GST_MIKEY_TYPE_PSK_VERIFY", "1"), + ("GST_MIKEY_VERSION", "1"), + ("GST_SDP_BWTYPE_AS", "AS"), + ("GST_SDP_BWTYPE_CT", "CT"), + ("GST_SDP_BWTYPE_EXT_PREFIX", "X-"), + ("GST_SDP_BWTYPE_RR", "RR"), + ("GST_SDP_BWTYPE_RS", "RS"), + ("GST_SDP_BWTYPE_TIAS", "TIAS"), + ("GST_SDP_EINVAL", "-1"), + ("GST_SDP_OK", "0"), +]; + + diff --git a/gstreamer-sdp-sys/tests/constant.c b/gstreamer-sdp-sys/tests/constant.c new file mode 100644 index 000000000..f95b609c2 --- /dev/null +++ b/gstreamer-sdp-sys/tests/constant.c @@ -0,0 +1,27 @@ +// This file was generated by gir (https://github.com/gtk-rs/gir @ 6855214) +// from gir-files (https://github.com/gtk-rs/gir-files @ ???) +// DO NOT EDIT + +#include "manual.h" +#include + +int main() { + printf(_Generic((ABI_CONSTANT_NAME), + char *: "%s", + const char *: "%s", + char: "%c", + signed char: "%hhd", + unsigned char: "%hhu", + short int: "%hd", + unsigned short int: "%hu", + int: "%d", + unsigned int: "%u", + long: "%ld", + unsigned long: "%lu", + long long: "%lld", + unsigned long long: "%llu", + double: "%f", + long double: "%ld"), + ABI_CONSTANT_NAME); + return 0; +} diff --git a/gstreamer-sdp-sys/tests/layout.c b/gstreamer-sdp-sys/tests/layout.c new file mode 100644 index 000000000..e4be962df --- /dev/null +++ b/gstreamer-sdp-sys/tests/layout.c @@ -0,0 +1,12 @@ +// This file was generated by gir (https://github.com/gtk-rs/gir @ 6855214) +// from gir-files (https://github.com/gtk-rs/gir-files @ ???) +// 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-sdp-sys/tests/manual.h b/gstreamer-sdp-sys/tests/manual.h new file mode 100644 index 000000000..fc92e3dbe --- /dev/null +++ b/gstreamer-sdp-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 diff --git a/gstreamer-sys/Cargo.toml b/gstreamer-sys/Cargo.toml index 44aa7d329..eb4083a86 100644 --- a/gstreamer-sys/Cargo.toml +++ b/gstreamer-sys/Cargo.toml @@ -2,11 +2,14 @@ pkg-config = "0.3.7" [dependencies] -bitflags = "1.0" libc = "0.2" glib-sys = { git = "https://github.com/gtk-rs/sys" } gobject-sys = { git = "https://github.com/gtk-rs/sys" } +[dev-dependencies] +shell-words = "0.1.0" +tempdir = "0.3" + [features] v1_0_10 = [] v1_2 = ["v1_0_10"] diff --git a/gstreamer-sys/src/lib.rs b/gstreamer-sys/src/lib.rs index 925d6b4e6..bbbbc71d7 100644 --- a/gstreamer-sys/src/lib.rs +++ b/gstreamer-sys/src/lib.rs @@ -1,11 +1,10 @@ -// This file was generated by gir (https://github.com/gtk-rs/gir @ fe7a6ff) +// This file was generated by gir (https://github.com/gtk-rs/gir @ 6855214) // 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)] extern crate libc; -#[macro_use] extern crate bitflags; extern crate glib_sys as glib; extern crate gobject_sys as gobject; @@ -412,8 +411,8 @@ pub const GST_URI_SRC: GstURIType = 2; // Constants pub const GST_ALLOCATOR_SYSMEM: *const c_char = b"SystemMemory\0" as *const u8 as *const c_char; -pub const GST_BUFFER_COPY_ALL: GstBufferCopyFlags = GstBufferCopyFlags { bits: 15 }; -pub const GST_BUFFER_COPY_METADATA: GstBufferCopyFlags = GstBufferCopyFlags { bits: 7 }; +pub const GST_BUFFER_COPY_ALL: GstBufferCopyFlags = 15; +pub const GST_BUFFER_COPY_METADATA: GstBufferCopyFlags = 7; pub const GST_BUFFER_OFFSET_NONE: u64 = 18446744073709551615; pub const GST_CAN_INLINE: c_int = 1; pub const GST_CAPS_FEATURE_MEMORY_SYSTEM_MEMORY: *const c_char = b"memory:SystemMemory\0" as *const u8 as *const c_char; @@ -441,7 +440,7 @@ pub const GST_ELEMENT_FACTORY_KLASS_SRC: *const c_char = b"Source\0" as *const u pub const GST_ELEMENT_FACTORY_TYPE_ANY: GstElementFactoryListType = 562949953421311; pub const GST_ELEMENT_FACTORY_TYPE_AUDIOVIDEO_SINKS: GstElementFactoryListType = 3940649673949188; pub const GST_ELEMENT_FACTORY_TYPE_AUDIO_ENCODER: GstElementFactoryListType = 1125899906842626; -pub const GST_ELEMENT_FACTORY_TYPE_DECODABLE: GstElementFactoryListType = 353; +pub const GST_ELEMENT_FACTORY_TYPE_DECODABLE: GstElementFactoryListType = 1377; pub const GST_ELEMENT_FACTORY_TYPE_DECODER: GstElementFactoryListType = 1; pub const GST_ELEMENT_FACTORY_TYPE_DECRYPTOR: GstElementFactoryListType = 1024; pub const GST_ELEMENT_FACTORY_TYPE_DEMUXER: GstElementFactoryListType = 32; @@ -470,27 +469,27 @@ pub const GST_ELEMENT_METADATA_KLASS: *const c_char = b"klass\0" as *const u8 as pub const GST_ELEMENT_METADATA_LONGNAME: *const c_char = b"long-name\0" as *const u8 as *const c_char; pub const GST_ERROR_SYSTEM: *const c_char = b"system error: %s\0" as *const u8 as *const c_char; pub const GST_EVENT_NUM_SHIFT: c_int = 8; -pub const GST_EVENT_TYPE_BOTH: GstEventTypeFlags = GstEventTypeFlags { bits: 3 }; +pub const GST_EVENT_TYPE_BOTH: GstEventTypeFlags = 3; pub const GST_FLAG_SET_MASK_EXACT: c_uint = 4294967295; pub const GST_FORMAT_PERCENT_MAX: i64 = 1000000; pub const GST_FORMAT_PERCENT_SCALE: i64 = 10000; pub const GST_FOURCC_FORMAT: *const c_char = b"c%c%c%c\0" as *const u8 as *const c_char; pub const GST_GROUP_ID_INVALID: c_int = 0; pub const GST_LICENSE_UNKNOWN: *const c_char = b"unknown\0" as *const u8 as *const c_char; -pub const GST_LOCK_FLAG_READWRITE: GstLockFlags = GstLockFlags { bits: 3 }; -pub const GST_MAP_READWRITE: GstMapFlags = GstMapFlags { bits: 3 }; +pub const GST_LOCK_FLAG_READWRITE: GstLockFlags = 3; +pub const GST_MAP_READWRITE: GstMapFlags = 3; pub const GST_META_TAG_MEMORY_STR: *const c_char = b"memory\0" as *const u8 as *const c_char; pub const GST_MSECOND: GstClockTimeDiff = 1000000; pub const GST_NSECOND: GstClockTimeDiff = 1; -pub const GST_PARAM_CONTROLLABLE: c_int = 2; -pub const GST_PARAM_MUTABLE_PAUSED: c_int = 8; -pub const GST_PARAM_MUTABLE_PLAYING: c_int = 16; -pub const GST_PARAM_MUTABLE_READY: c_int = 4; -pub const GST_PARAM_USER_SHIFT: c_int = 256; +pub const GST_PARAM_CONTROLLABLE: c_int = 512; +pub const GST_PARAM_MUTABLE_PAUSED: c_int = 2048; +pub const GST_PARAM_MUTABLE_PLAYING: c_int = 4096; +pub const GST_PARAM_MUTABLE_READY: c_int = 1024; +pub const GST_PARAM_USER_SHIFT: c_int = 65536; pub const GST_PROTECTION_SYSTEM_ID_CAPS_FIELD: *const c_char = b"protection-system\0" as *const u8 as *const c_char; pub const GST_PTR_FORMAT: *const c_char = b"paA\0" as *const u8 as *const c_char; pub const GST_QUERY_NUM_SHIFT: c_int = 8; -pub const GST_QUERY_TYPE_BOTH: GstQueryTypeFlags = GstQueryTypeFlags { bits: 3 }; +pub const GST_QUERY_TYPE_BOTH: GstQueryTypeFlags = 3; pub const GST_SECOND: GstClockTimeDiff = 1000000000; pub const GST_SEGMENT_FORMAT: *const c_char = b"paB\0" as *const u8 as *const c_char; pub const GST_SEQNUM_INVALID: c_int = 0; @@ -594,693 +593,314 @@ pub const GST_VERSION_MINOR: c_int = 14; pub const GST_VERSION_NANO: c_int = 0; // Flags -bitflags! { - #[repr(C)] - pub struct GstAllocatorFlags: c_uint { - const CUSTOM_ALLOC = 16; - const LAST = 1048576; - } -} -pub const GST_ALLOCATOR_FLAG_CUSTOM_ALLOC: GstAllocatorFlags = GstAllocatorFlags::CUSTOM_ALLOC; -pub const GST_ALLOCATOR_FLAG_LAST: GstAllocatorFlags = GstAllocatorFlags::LAST; +pub type GstAllocatorFlags = c_uint; +pub const GST_ALLOCATOR_FLAG_CUSTOM_ALLOC: GstAllocatorFlags = 16; +pub const GST_ALLOCATOR_FLAG_LAST: GstAllocatorFlags = 1048576; -bitflags! { - #[repr(C)] - pub struct GstBinFlags: c_uint { - const NO_RESYNC = 16384; - const STREAMS_AWARE = 32768; - const LAST = 524288; - } -} -pub const GST_BIN_FLAG_NO_RESYNC: GstBinFlags = GstBinFlags::NO_RESYNC; -pub const GST_BIN_FLAG_STREAMS_AWARE: GstBinFlags = GstBinFlags::STREAMS_AWARE; -pub const GST_BIN_FLAG_LAST: GstBinFlags = GstBinFlags::LAST; +pub type GstBinFlags = c_uint; +pub const GST_BIN_FLAG_NO_RESYNC: GstBinFlags = 16384; +pub const GST_BIN_FLAG_STREAMS_AWARE: GstBinFlags = 32768; +pub const GST_BIN_FLAG_LAST: GstBinFlags = 524288; -bitflags! { - #[repr(C)] - pub struct GstBufferCopyFlags: c_uint { - const NONE = 0; - const FLAGS = 1; - const TIMESTAMPS = 2; - const META = 4; - const MEMORY = 8; - const MERGE = 16; - const DEEP = 32; - } -} -pub const GST_BUFFER_COPY_NONE: GstBufferCopyFlags = GstBufferCopyFlags::NONE; -pub const GST_BUFFER_COPY_FLAGS: GstBufferCopyFlags = GstBufferCopyFlags::FLAGS; -pub const GST_BUFFER_COPY_TIMESTAMPS: GstBufferCopyFlags = GstBufferCopyFlags::TIMESTAMPS; -pub const GST_BUFFER_COPY_META: GstBufferCopyFlags = GstBufferCopyFlags::META; -pub const GST_BUFFER_COPY_MEMORY: GstBufferCopyFlags = GstBufferCopyFlags::MEMORY; -pub const GST_BUFFER_COPY_MERGE: GstBufferCopyFlags = GstBufferCopyFlags::MERGE; -pub const GST_BUFFER_COPY_DEEP: GstBufferCopyFlags = GstBufferCopyFlags::DEEP; +pub type GstBufferCopyFlags = c_uint; +pub const GST_BUFFER_COPY_NONE: GstBufferCopyFlags = 0; +pub const GST_BUFFER_COPY_FLAGS: GstBufferCopyFlags = 1; +pub const GST_BUFFER_COPY_TIMESTAMPS: GstBufferCopyFlags = 2; +pub const GST_BUFFER_COPY_META: GstBufferCopyFlags = 4; +pub const GST_BUFFER_COPY_MEMORY: GstBufferCopyFlags = 8; +pub const GST_BUFFER_COPY_MERGE: GstBufferCopyFlags = 16; +pub const GST_BUFFER_COPY_DEEP: GstBufferCopyFlags = 32; -bitflags! { - #[repr(C)] - pub struct GstBufferFlags: c_uint { - const LIVE = 16; - const DECODE_ONLY = 32; - const DISCONT = 64; - const RESYNC = 128; - const CORRUPTED = 256; - const MARKER = 512; - const HEADER = 1024; - const GAP = 2048; - const DROPPABLE = 4096; - const DELTA_UNIT = 8192; - const TAG_MEMORY = 16384; - const SYNC_AFTER = 32768; - const NON_DROPPABLE = 65536; - const LAST = 1048576; - } -} -pub const GST_BUFFER_FLAG_LIVE: GstBufferFlags = GstBufferFlags::LIVE; -pub const GST_BUFFER_FLAG_DECODE_ONLY: GstBufferFlags = GstBufferFlags::DECODE_ONLY; -pub const GST_BUFFER_FLAG_DISCONT: GstBufferFlags = GstBufferFlags::DISCONT; -pub const GST_BUFFER_FLAG_RESYNC: GstBufferFlags = GstBufferFlags::RESYNC; -pub const GST_BUFFER_FLAG_CORRUPTED: GstBufferFlags = GstBufferFlags::CORRUPTED; -pub const GST_BUFFER_FLAG_MARKER: GstBufferFlags = GstBufferFlags::MARKER; -pub const GST_BUFFER_FLAG_HEADER: GstBufferFlags = GstBufferFlags::HEADER; -pub const GST_BUFFER_FLAG_GAP: GstBufferFlags = GstBufferFlags::GAP; -pub const GST_BUFFER_FLAG_DROPPABLE: GstBufferFlags = GstBufferFlags::DROPPABLE; -pub const GST_BUFFER_FLAG_DELTA_UNIT: GstBufferFlags = GstBufferFlags::DELTA_UNIT; -pub const GST_BUFFER_FLAG_TAG_MEMORY: GstBufferFlags = GstBufferFlags::TAG_MEMORY; -pub const GST_BUFFER_FLAG_SYNC_AFTER: GstBufferFlags = GstBufferFlags::SYNC_AFTER; -pub const GST_BUFFER_FLAG_NON_DROPPABLE: GstBufferFlags = GstBufferFlags::NON_DROPPABLE; -pub const GST_BUFFER_FLAG_LAST: GstBufferFlags = GstBufferFlags::LAST; +pub type GstBufferFlags = c_uint; +pub const GST_BUFFER_FLAG_LIVE: GstBufferFlags = 16; +pub const GST_BUFFER_FLAG_DECODE_ONLY: GstBufferFlags = 32; +pub const GST_BUFFER_FLAG_DISCONT: GstBufferFlags = 64; +pub const GST_BUFFER_FLAG_RESYNC: GstBufferFlags = 128; +pub const GST_BUFFER_FLAG_CORRUPTED: GstBufferFlags = 256; +pub const GST_BUFFER_FLAG_MARKER: GstBufferFlags = 512; +pub const GST_BUFFER_FLAG_HEADER: GstBufferFlags = 1024; +pub const GST_BUFFER_FLAG_GAP: GstBufferFlags = 2048; +pub const GST_BUFFER_FLAG_DROPPABLE: GstBufferFlags = 4096; +pub const GST_BUFFER_FLAG_DELTA_UNIT: GstBufferFlags = 8192; +pub const GST_BUFFER_FLAG_TAG_MEMORY: GstBufferFlags = 16384; +pub const GST_BUFFER_FLAG_SYNC_AFTER: GstBufferFlags = 32768; +pub const GST_BUFFER_FLAG_NON_DROPPABLE: GstBufferFlags = 65536; +pub const GST_BUFFER_FLAG_LAST: GstBufferFlags = 1048576; -bitflags! { - #[repr(C)] - pub struct GstBufferPoolAcquireFlags: c_uint { - const NONE = 0; - const KEY_UNIT = 1; - const DONTWAIT = 2; - const DISCONT = 4; - const LAST = 65536; - } -} -pub const GST_BUFFER_POOL_ACQUIRE_FLAG_NONE: GstBufferPoolAcquireFlags = GstBufferPoolAcquireFlags::NONE; -pub const GST_BUFFER_POOL_ACQUIRE_FLAG_KEY_UNIT: GstBufferPoolAcquireFlags = GstBufferPoolAcquireFlags::KEY_UNIT; -pub const GST_BUFFER_POOL_ACQUIRE_FLAG_DONTWAIT: GstBufferPoolAcquireFlags = GstBufferPoolAcquireFlags::DONTWAIT; -pub const GST_BUFFER_POOL_ACQUIRE_FLAG_DISCONT: GstBufferPoolAcquireFlags = GstBufferPoolAcquireFlags::DISCONT; -pub const GST_BUFFER_POOL_ACQUIRE_FLAG_LAST: GstBufferPoolAcquireFlags = GstBufferPoolAcquireFlags::LAST; +pub type GstBufferPoolAcquireFlags = c_uint; +pub const GST_BUFFER_POOL_ACQUIRE_FLAG_NONE: GstBufferPoolAcquireFlags = 0; +pub const GST_BUFFER_POOL_ACQUIRE_FLAG_KEY_UNIT: GstBufferPoolAcquireFlags = 1; +pub const GST_BUFFER_POOL_ACQUIRE_FLAG_DONTWAIT: GstBufferPoolAcquireFlags = 2; +pub const GST_BUFFER_POOL_ACQUIRE_FLAG_DISCONT: GstBufferPoolAcquireFlags = 4; +pub const GST_BUFFER_POOL_ACQUIRE_FLAG_LAST: GstBufferPoolAcquireFlags = 65536; -bitflags! { - #[repr(C)] - pub struct GstBusFlags: c_uint { - const FLUSHING = 16; - const FLAG_LAST = 32; - } -} -pub const GST_BUS_FLUSHING: GstBusFlags = GstBusFlags::FLUSHING; -pub const GST_BUS_FLAG_LAST: GstBusFlags = GstBusFlags::FLAG_LAST; +pub type GstBusFlags = c_uint; +pub const GST_BUS_FLUSHING: GstBusFlags = 16; +pub const GST_BUS_FLAG_LAST: GstBusFlags = 32; -bitflags! { - #[repr(C)] - pub struct GstCapsFlags: c_uint { - const ANY = 16; - } -} -pub const GST_CAPS_FLAG_ANY: GstCapsFlags = GstCapsFlags::ANY; +pub type GstCapsFlags = c_uint; +pub const GST_CAPS_FLAG_ANY: GstCapsFlags = 16; -bitflags! { - #[repr(C)] - pub struct GstClockFlags: c_uint { - const CAN_DO_SINGLE_SYNC = 16; - const CAN_DO_SINGLE_ASYNC = 32; - const CAN_DO_PERIODIC_SYNC = 64; - const CAN_DO_PERIODIC_ASYNC = 128; - const CAN_SET_RESOLUTION = 256; - const CAN_SET_MASTER = 512; - const NEEDS_STARTUP_SYNC = 1024; - const LAST = 4096; - } -} -pub const GST_CLOCK_FLAG_CAN_DO_SINGLE_SYNC: GstClockFlags = GstClockFlags::CAN_DO_SINGLE_SYNC; -pub const GST_CLOCK_FLAG_CAN_DO_SINGLE_ASYNC: GstClockFlags = GstClockFlags::CAN_DO_SINGLE_ASYNC; -pub const GST_CLOCK_FLAG_CAN_DO_PERIODIC_SYNC: GstClockFlags = GstClockFlags::CAN_DO_PERIODIC_SYNC; -pub const GST_CLOCK_FLAG_CAN_DO_PERIODIC_ASYNC: GstClockFlags = GstClockFlags::CAN_DO_PERIODIC_ASYNC; -pub const GST_CLOCK_FLAG_CAN_SET_RESOLUTION: GstClockFlags = GstClockFlags::CAN_SET_RESOLUTION; -pub const GST_CLOCK_FLAG_CAN_SET_MASTER: GstClockFlags = GstClockFlags::CAN_SET_MASTER; -pub const GST_CLOCK_FLAG_NEEDS_STARTUP_SYNC: GstClockFlags = GstClockFlags::NEEDS_STARTUP_SYNC; -pub const GST_CLOCK_FLAG_LAST: GstClockFlags = GstClockFlags::LAST; +pub type GstClockFlags = c_uint; +pub const GST_CLOCK_FLAG_CAN_DO_SINGLE_SYNC: GstClockFlags = 16; +pub const GST_CLOCK_FLAG_CAN_DO_SINGLE_ASYNC: GstClockFlags = 32; +pub const GST_CLOCK_FLAG_CAN_DO_PERIODIC_SYNC: GstClockFlags = 64; +pub const GST_CLOCK_FLAG_CAN_DO_PERIODIC_ASYNC: GstClockFlags = 128; +pub const GST_CLOCK_FLAG_CAN_SET_RESOLUTION: GstClockFlags = 256; +pub const GST_CLOCK_FLAG_CAN_SET_MASTER: GstClockFlags = 512; +pub const GST_CLOCK_FLAG_NEEDS_STARTUP_SYNC: GstClockFlags = 1024; +pub const GST_CLOCK_FLAG_LAST: GstClockFlags = 4096; -bitflags! { - #[repr(C)] - pub struct GstDebugColorFlags: c_uint { - const FG_BLACK = 0; - const FG_RED = 1; - const FG_GREEN = 2; - const FG_YELLOW = 3; - const FG_BLUE = 4; - const FG_MAGENTA = 5; - const FG_CYAN = 6; - const FG_WHITE = 7; - const BG_BLACK = 0; - const BG_RED = 16; - const BG_GREEN = 32; - const BG_YELLOW = 48; - const BG_BLUE = 64; - const BG_MAGENTA = 80; - const BG_CYAN = 96; - const BG_WHITE = 112; - const BOLD = 256; - const UNDERLINE = 512; - } -} -pub const GST_DEBUG_FG_BLACK: GstDebugColorFlags = GstDebugColorFlags::BG_BLACK; -pub const GST_DEBUG_FG_RED: GstDebugColorFlags = GstDebugColorFlags::FG_RED; -pub const GST_DEBUG_FG_GREEN: GstDebugColorFlags = GstDebugColorFlags::FG_GREEN; -pub const GST_DEBUG_FG_YELLOW: GstDebugColorFlags = GstDebugColorFlags::FG_YELLOW; -pub const GST_DEBUG_FG_BLUE: GstDebugColorFlags = GstDebugColorFlags::FG_BLUE; -pub const GST_DEBUG_FG_MAGENTA: GstDebugColorFlags = GstDebugColorFlags::FG_MAGENTA; -pub const GST_DEBUG_FG_CYAN: GstDebugColorFlags = GstDebugColorFlags::FG_CYAN; -pub const GST_DEBUG_FG_WHITE: GstDebugColorFlags = GstDebugColorFlags::FG_WHITE; -pub const GST_DEBUG_BG_BLACK: GstDebugColorFlags = GstDebugColorFlags::BG_BLACK; -pub const GST_DEBUG_BG_RED: GstDebugColorFlags = GstDebugColorFlags::BG_RED; -pub const GST_DEBUG_BG_GREEN: GstDebugColorFlags = GstDebugColorFlags::BG_GREEN; -pub const GST_DEBUG_BG_YELLOW: GstDebugColorFlags = GstDebugColorFlags::BG_YELLOW; -pub const GST_DEBUG_BG_BLUE: GstDebugColorFlags = GstDebugColorFlags::BG_BLUE; -pub const GST_DEBUG_BG_MAGENTA: GstDebugColorFlags = GstDebugColorFlags::BG_MAGENTA; -pub const GST_DEBUG_BG_CYAN: GstDebugColorFlags = GstDebugColorFlags::BG_CYAN; -pub const GST_DEBUG_BG_WHITE: GstDebugColorFlags = GstDebugColorFlags::BG_WHITE; -pub const GST_DEBUG_BOLD: GstDebugColorFlags = GstDebugColorFlags::BOLD; -pub const GST_DEBUG_UNDERLINE: GstDebugColorFlags = GstDebugColorFlags::UNDERLINE; +pub type GstDebugColorFlags = c_uint; +pub const GST_DEBUG_FG_BLACK: GstDebugColorFlags = 0; +pub const GST_DEBUG_FG_RED: GstDebugColorFlags = 1; +pub const GST_DEBUG_FG_GREEN: GstDebugColorFlags = 2; +pub const GST_DEBUG_FG_YELLOW: GstDebugColorFlags = 3; +pub const GST_DEBUG_FG_BLUE: GstDebugColorFlags = 4; +pub const GST_DEBUG_FG_MAGENTA: GstDebugColorFlags = 5; +pub const GST_DEBUG_FG_CYAN: GstDebugColorFlags = 6; +pub const GST_DEBUG_FG_WHITE: GstDebugColorFlags = 7; +pub const GST_DEBUG_BG_BLACK: GstDebugColorFlags = 0; +pub const GST_DEBUG_BG_RED: GstDebugColorFlags = 16; +pub const GST_DEBUG_BG_GREEN: GstDebugColorFlags = 32; +pub const GST_DEBUG_BG_YELLOW: GstDebugColorFlags = 48; +pub const GST_DEBUG_BG_BLUE: GstDebugColorFlags = 64; +pub const GST_DEBUG_BG_MAGENTA: GstDebugColorFlags = 80; +pub const GST_DEBUG_BG_CYAN: GstDebugColorFlags = 96; +pub const GST_DEBUG_BG_WHITE: GstDebugColorFlags = 112; +pub const GST_DEBUG_BOLD: GstDebugColorFlags = 256; +pub const GST_DEBUG_UNDERLINE: GstDebugColorFlags = 512; -bitflags! { - #[repr(C)] - pub struct GstDebugGraphDetails: c_uint { - const MEDIA_TYPE = 1; - const CAPS_DETAILS = 2; - const NON_DEFAULT_PARAMS = 4; - const STATES = 8; - const FULL_PARAMS = 16; - const ALL = 15; - const VERBOSE = 4294967295; - } -} -pub const GST_DEBUG_GRAPH_SHOW_MEDIA_TYPE: GstDebugGraphDetails = GstDebugGraphDetails::MEDIA_TYPE; -pub const GST_DEBUG_GRAPH_SHOW_CAPS_DETAILS: GstDebugGraphDetails = GstDebugGraphDetails::CAPS_DETAILS; -pub const GST_DEBUG_GRAPH_SHOW_NON_DEFAULT_PARAMS: GstDebugGraphDetails = GstDebugGraphDetails::NON_DEFAULT_PARAMS; -pub const GST_DEBUG_GRAPH_SHOW_STATES: GstDebugGraphDetails = GstDebugGraphDetails::STATES; -pub const GST_DEBUG_GRAPH_SHOW_FULL_PARAMS: GstDebugGraphDetails = GstDebugGraphDetails::FULL_PARAMS; -pub const GST_DEBUG_GRAPH_SHOW_ALL: GstDebugGraphDetails = GstDebugGraphDetails::ALL; -pub const GST_DEBUG_GRAPH_SHOW_VERBOSE: GstDebugGraphDetails = GstDebugGraphDetails::VERBOSE; +pub type GstDebugGraphDetails = c_uint; +pub const GST_DEBUG_GRAPH_SHOW_MEDIA_TYPE: GstDebugGraphDetails = 1; +pub const GST_DEBUG_GRAPH_SHOW_CAPS_DETAILS: GstDebugGraphDetails = 2; +pub const GST_DEBUG_GRAPH_SHOW_NON_DEFAULT_PARAMS: GstDebugGraphDetails = 4; +pub const GST_DEBUG_GRAPH_SHOW_STATES: GstDebugGraphDetails = 8; +pub const GST_DEBUG_GRAPH_SHOW_FULL_PARAMS: GstDebugGraphDetails = 16; +pub const GST_DEBUG_GRAPH_SHOW_ALL: GstDebugGraphDetails = 15; +pub const GST_DEBUG_GRAPH_SHOW_VERBOSE: GstDebugGraphDetails = 4294967295; -bitflags! { - #[repr(C)] - pub struct GstElementFlags: c_uint { - const LOCKED_STATE = 16; - const SINK = 32; - const SOURCE = 64; - const PROVIDE_CLOCK = 128; - const REQUIRE_CLOCK = 256; - const INDEXABLE = 512; - const LAST = 16384; - } -} -pub const GST_ELEMENT_FLAG_LOCKED_STATE: GstElementFlags = GstElementFlags::LOCKED_STATE; -pub const GST_ELEMENT_FLAG_SINK: GstElementFlags = GstElementFlags::SINK; -pub const GST_ELEMENT_FLAG_SOURCE: GstElementFlags = GstElementFlags::SOURCE; -pub const GST_ELEMENT_FLAG_PROVIDE_CLOCK: GstElementFlags = GstElementFlags::PROVIDE_CLOCK; -pub const GST_ELEMENT_FLAG_REQUIRE_CLOCK: GstElementFlags = GstElementFlags::REQUIRE_CLOCK; -pub const GST_ELEMENT_FLAG_INDEXABLE: GstElementFlags = GstElementFlags::INDEXABLE; -pub const GST_ELEMENT_FLAG_LAST: GstElementFlags = GstElementFlags::LAST; +pub type GstElementFlags = c_uint; +pub const GST_ELEMENT_FLAG_LOCKED_STATE: GstElementFlags = 16; +pub const GST_ELEMENT_FLAG_SINK: GstElementFlags = 32; +pub const GST_ELEMENT_FLAG_SOURCE: GstElementFlags = 64; +pub const GST_ELEMENT_FLAG_PROVIDE_CLOCK: GstElementFlags = 128; +pub const GST_ELEMENT_FLAG_REQUIRE_CLOCK: GstElementFlags = 256; +pub const GST_ELEMENT_FLAG_INDEXABLE: GstElementFlags = 512; +pub const GST_ELEMENT_FLAG_LAST: GstElementFlags = 16384; -bitflags! { - #[repr(C)] - pub struct GstEventTypeFlags: c_uint { - const UPSTREAM = 1; - const DOWNSTREAM = 2; - const SERIALIZED = 4; - const STICKY = 8; - const STICKY_MULTI = 16; - } -} -pub const GST_EVENT_TYPE_UPSTREAM: GstEventTypeFlags = GstEventTypeFlags::UPSTREAM; -pub const GST_EVENT_TYPE_DOWNSTREAM: GstEventTypeFlags = GstEventTypeFlags::DOWNSTREAM; -pub const GST_EVENT_TYPE_SERIALIZED: GstEventTypeFlags = GstEventTypeFlags::SERIALIZED; -pub const GST_EVENT_TYPE_STICKY: GstEventTypeFlags = GstEventTypeFlags::STICKY; -pub const GST_EVENT_TYPE_STICKY_MULTI: GstEventTypeFlags = GstEventTypeFlags::STICKY_MULTI; +pub type GstEventTypeFlags = c_uint; +pub const GST_EVENT_TYPE_UPSTREAM: GstEventTypeFlags = 1; +pub const GST_EVENT_TYPE_DOWNSTREAM: GstEventTypeFlags = 2; +pub const GST_EVENT_TYPE_SERIALIZED: GstEventTypeFlags = 4; +pub const GST_EVENT_TYPE_STICKY: GstEventTypeFlags = 8; +pub const GST_EVENT_TYPE_STICKY_MULTI: GstEventTypeFlags = 16; -bitflags! { - #[repr(C)] - pub struct GstLockFlags: c_uint { - const READ = 1; - const WRITE = 2; - const EXCLUSIVE = 4; - const LAST = 256; - } -} -pub const GST_LOCK_FLAG_READ: GstLockFlags = GstLockFlags::READ; -pub const GST_LOCK_FLAG_WRITE: GstLockFlags = GstLockFlags::WRITE; -pub const GST_LOCK_FLAG_EXCLUSIVE: GstLockFlags = GstLockFlags::EXCLUSIVE; -pub const GST_LOCK_FLAG_LAST: GstLockFlags = GstLockFlags::LAST; +pub type GstLockFlags = c_uint; +pub const GST_LOCK_FLAG_READ: GstLockFlags = 1; +pub const GST_LOCK_FLAG_WRITE: GstLockFlags = 2; +pub const GST_LOCK_FLAG_EXCLUSIVE: GstLockFlags = 4; +pub const GST_LOCK_FLAG_LAST: GstLockFlags = 256; -bitflags! { - #[repr(C)] - pub struct GstMapFlags: c_uint { - const READ = 1; - const WRITE = 2; - const FLAG_LAST = 65536; - } -} -pub const GST_MAP_READ: GstMapFlags = GstMapFlags::READ; -pub const GST_MAP_WRITE: GstMapFlags = GstMapFlags::WRITE; -pub const GST_MAP_FLAG_LAST: GstMapFlags = GstMapFlags::FLAG_LAST; +pub type GstMapFlags = c_uint; +pub const GST_MAP_READ: GstMapFlags = 1; +pub const GST_MAP_WRITE: GstMapFlags = 2; +pub const GST_MAP_FLAG_LAST: GstMapFlags = 65536; -bitflags! { - #[repr(C)] - pub struct GstMemoryFlags: c_uint { - const READONLY = 2; - const NO_SHARE = 16; - const ZERO_PREFIXED = 32; - const ZERO_PADDED = 64; - const PHYSICALLY_CONTIGUOUS = 128; - const NOT_MAPPABLE = 256; - const LAST = 1048576; - } -} -pub const GST_MEMORY_FLAG_READONLY: GstMemoryFlags = GstMemoryFlags::READONLY; -pub const GST_MEMORY_FLAG_NO_SHARE: GstMemoryFlags = GstMemoryFlags::NO_SHARE; -pub const GST_MEMORY_FLAG_ZERO_PREFIXED: GstMemoryFlags = GstMemoryFlags::ZERO_PREFIXED; -pub const GST_MEMORY_FLAG_ZERO_PADDED: GstMemoryFlags = GstMemoryFlags::ZERO_PADDED; -pub const GST_MEMORY_FLAG_PHYSICALLY_CONTIGUOUS: GstMemoryFlags = GstMemoryFlags::PHYSICALLY_CONTIGUOUS; -pub const GST_MEMORY_FLAG_NOT_MAPPABLE: GstMemoryFlags = GstMemoryFlags::NOT_MAPPABLE; -pub const GST_MEMORY_FLAG_LAST: GstMemoryFlags = GstMemoryFlags::LAST; +pub type GstMemoryFlags = c_uint; +pub const GST_MEMORY_FLAG_READONLY: GstMemoryFlags = 2; +pub const GST_MEMORY_FLAG_NO_SHARE: GstMemoryFlags = 16; +pub const GST_MEMORY_FLAG_ZERO_PREFIXED: GstMemoryFlags = 32; +pub const GST_MEMORY_FLAG_ZERO_PADDED: GstMemoryFlags = 64; +pub const GST_MEMORY_FLAG_PHYSICALLY_CONTIGUOUS: GstMemoryFlags = 128; +pub const GST_MEMORY_FLAG_NOT_MAPPABLE: GstMemoryFlags = 256; +pub const GST_MEMORY_FLAG_LAST: GstMemoryFlags = 1048576; -bitflags! { - #[repr(C)] - pub struct GstMessageType: c_uint { - const UNKNOWN = 0; - const EOS = 1; - const ERROR = 2; - const WARNING = 4; - const INFO = 8; - const TAG = 16; - const BUFFERING = 32; - const STATE_CHANGED = 64; - const STATE_DIRTY = 128; - const STEP_DONE = 256; - const CLOCK_PROVIDE = 512; - const CLOCK_LOST = 1024; - const NEW_CLOCK = 2048; - const STRUCTURE_CHANGE = 4096; - const STREAM_STATUS = 8192; - const APPLICATION = 16384; - const ELEMENT = 32768; - const SEGMENT_START = 65536; - const SEGMENT_DONE = 131072; - const DURATION_CHANGED = 262144; - const LATENCY = 524288; - const ASYNC_START = 1048576; - const ASYNC_DONE = 2097152; - const REQUEST_STATE = 4194304; - const STEP_START = 8388608; - const QOS = 16777216; - const PROGRESS = 33554432; - const TOC = 67108864; - const RESET_TIME = 134217728; - const STREAM_START = 268435456; - const NEED_CONTEXT = 536870912; - const HAVE_CONTEXT = 1073741824; - const EXTENDED = 2147483648; - const DEVICE_ADDED = 2147483649; - const DEVICE_REMOVED = 2147483650; - const PROPERTY_NOTIFY = 2147483651; - const STREAM_COLLECTION = 2147483652; - const STREAMS_SELECTED = 2147483653; - const REDIRECT = 2147483654; - const ANY = 4294967295; - } -} -pub const GST_MESSAGE_UNKNOWN: GstMessageType = GstMessageType::UNKNOWN; -pub const GST_MESSAGE_EOS: GstMessageType = GstMessageType::EOS; -pub const GST_MESSAGE_ERROR: GstMessageType = GstMessageType::ERROR; -pub const GST_MESSAGE_WARNING: GstMessageType = GstMessageType::WARNING; -pub const GST_MESSAGE_INFO: GstMessageType = GstMessageType::INFO; -pub const GST_MESSAGE_TAG: GstMessageType = GstMessageType::TAG; -pub const GST_MESSAGE_BUFFERING: GstMessageType = GstMessageType::BUFFERING; -pub const GST_MESSAGE_STATE_CHANGED: GstMessageType = GstMessageType::STATE_CHANGED; -pub const GST_MESSAGE_STATE_DIRTY: GstMessageType = GstMessageType::STATE_DIRTY; -pub const GST_MESSAGE_STEP_DONE: GstMessageType = GstMessageType::STEP_DONE; -pub const GST_MESSAGE_CLOCK_PROVIDE: GstMessageType = GstMessageType::CLOCK_PROVIDE; -pub const GST_MESSAGE_CLOCK_LOST: GstMessageType = GstMessageType::CLOCK_LOST; -pub const GST_MESSAGE_NEW_CLOCK: GstMessageType = GstMessageType::NEW_CLOCK; -pub const GST_MESSAGE_STRUCTURE_CHANGE: GstMessageType = GstMessageType::STRUCTURE_CHANGE; -pub const GST_MESSAGE_STREAM_STATUS: GstMessageType = GstMessageType::STREAM_STATUS; -pub const GST_MESSAGE_APPLICATION: GstMessageType = GstMessageType::APPLICATION; -pub const GST_MESSAGE_ELEMENT: GstMessageType = GstMessageType::ELEMENT; -pub const GST_MESSAGE_SEGMENT_START: GstMessageType = GstMessageType::SEGMENT_START; -pub const GST_MESSAGE_SEGMENT_DONE: GstMessageType = GstMessageType::SEGMENT_DONE; -pub const GST_MESSAGE_DURATION_CHANGED: GstMessageType = GstMessageType::DURATION_CHANGED; -pub const GST_MESSAGE_LATENCY: GstMessageType = GstMessageType::LATENCY; -pub const GST_MESSAGE_ASYNC_START: GstMessageType = GstMessageType::ASYNC_START; -pub const GST_MESSAGE_ASYNC_DONE: GstMessageType = GstMessageType::ASYNC_DONE; -pub const GST_MESSAGE_REQUEST_STATE: GstMessageType = GstMessageType::REQUEST_STATE; -pub const GST_MESSAGE_STEP_START: GstMessageType = GstMessageType::STEP_START; -pub const GST_MESSAGE_QOS: GstMessageType = GstMessageType::QOS; -pub const GST_MESSAGE_PROGRESS: GstMessageType = GstMessageType::PROGRESS; -pub const GST_MESSAGE_TOC: GstMessageType = GstMessageType::TOC; -pub const GST_MESSAGE_RESET_TIME: GstMessageType = GstMessageType::RESET_TIME; -pub const GST_MESSAGE_STREAM_START: GstMessageType = GstMessageType::STREAM_START; -pub const GST_MESSAGE_NEED_CONTEXT: GstMessageType = GstMessageType::NEED_CONTEXT; -pub const GST_MESSAGE_HAVE_CONTEXT: GstMessageType = GstMessageType::HAVE_CONTEXT; -pub const GST_MESSAGE_EXTENDED: GstMessageType = GstMessageType::EXTENDED; -pub const GST_MESSAGE_DEVICE_ADDED: GstMessageType = GstMessageType::DEVICE_ADDED; -pub const GST_MESSAGE_DEVICE_REMOVED: GstMessageType = GstMessageType::DEVICE_REMOVED; -pub const GST_MESSAGE_PROPERTY_NOTIFY: GstMessageType = GstMessageType::PROPERTY_NOTIFY; -pub const GST_MESSAGE_STREAM_COLLECTION: GstMessageType = GstMessageType::STREAM_COLLECTION; -pub const GST_MESSAGE_STREAMS_SELECTED: GstMessageType = GstMessageType::STREAMS_SELECTED; -pub const GST_MESSAGE_REDIRECT: GstMessageType = GstMessageType::REDIRECT; -pub const GST_MESSAGE_ANY: GstMessageType = GstMessageType::ANY; +pub type GstMessageType = c_uint; +pub const GST_MESSAGE_UNKNOWN: GstMessageType = 0; +pub const GST_MESSAGE_EOS: GstMessageType = 1; +pub const GST_MESSAGE_ERROR: GstMessageType = 2; +pub const GST_MESSAGE_WARNING: GstMessageType = 4; +pub const GST_MESSAGE_INFO: GstMessageType = 8; +pub const GST_MESSAGE_TAG: GstMessageType = 16; +pub const GST_MESSAGE_BUFFERING: GstMessageType = 32; +pub const GST_MESSAGE_STATE_CHANGED: GstMessageType = 64; +pub const GST_MESSAGE_STATE_DIRTY: GstMessageType = 128; +pub const GST_MESSAGE_STEP_DONE: GstMessageType = 256; +pub const GST_MESSAGE_CLOCK_PROVIDE: GstMessageType = 512; +pub const GST_MESSAGE_CLOCK_LOST: GstMessageType = 1024; +pub const GST_MESSAGE_NEW_CLOCK: GstMessageType = 2048; +pub const GST_MESSAGE_STRUCTURE_CHANGE: GstMessageType = 4096; +pub const GST_MESSAGE_STREAM_STATUS: GstMessageType = 8192; +pub const GST_MESSAGE_APPLICATION: GstMessageType = 16384; +pub const GST_MESSAGE_ELEMENT: GstMessageType = 32768; +pub const GST_MESSAGE_SEGMENT_START: GstMessageType = 65536; +pub const GST_MESSAGE_SEGMENT_DONE: GstMessageType = 131072; +pub const GST_MESSAGE_DURATION_CHANGED: GstMessageType = 262144; +pub const GST_MESSAGE_LATENCY: GstMessageType = 524288; +pub const GST_MESSAGE_ASYNC_START: GstMessageType = 1048576; +pub const GST_MESSAGE_ASYNC_DONE: GstMessageType = 2097152; +pub const GST_MESSAGE_REQUEST_STATE: GstMessageType = 4194304; +pub const GST_MESSAGE_STEP_START: GstMessageType = 8388608; +pub const GST_MESSAGE_QOS: GstMessageType = 16777216; +pub const GST_MESSAGE_PROGRESS: GstMessageType = 33554432; +pub const GST_MESSAGE_TOC: GstMessageType = 67108864; +pub const GST_MESSAGE_RESET_TIME: GstMessageType = 134217728; +pub const GST_MESSAGE_STREAM_START: GstMessageType = 268435456; +pub const GST_MESSAGE_NEED_CONTEXT: GstMessageType = 536870912; +pub const GST_MESSAGE_HAVE_CONTEXT: GstMessageType = 1073741824; +pub const GST_MESSAGE_EXTENDED: GstMessageType = 2147483648; +pub const GST_MESSAGE_DEVICE_ADDED: GstMessageType = 2147483649; +pub const GST_MESSAGE_DEVICE_REMOVED: GstMessageType = 2147483650; +pub const GST_MESSAGE_PROPERTY_NOTIFY: GstMessageType = 2147483651; +pub const GST_MESSAGE_STREAM_COLLECTION: GstMessageType = 2147483652; +pub const GST_MESSAGE_STREAMS_SELECTED: GstMessageType = 2147483653; +pub const GST_MESSAGE_REDIRECT: GstMessageType = 2147483654; +pub const GST_MESSAGE_ANY: GstMessageType = 4294967295; -bitflags! { - #[repr(C)] - pub struct GstMetaFlags: c_uint { - const NONE = 0; - const READONLY = 1; - const POOLED = 2; - const LOCKED = 4; - const LAST = 65536; - } -} -pub const GST_META_FLAG_NONE: GstMetaFlags = GstMetaFlags::NONE; -pub const GST_META_FLAG_READONLY: GstMetaFlags = GstMetaFlags::READONLY; -pub const GST_META_FLAG_POOLED: GstMetaFlags = GstMetaFlags::POOLED; -pub const GST_META_FLAG_LOCKED: GstMetaFlags = GstMetaFlags::LOCKED; -pub const GST_META_FLAG_LAST: GstMetaFlags = GstMetaFlags::LAST; +pub type GstMetaFlags = c_uint; +pub const GST_META_FLAG_NONE: GstMetaFlags = 0; +pub const GST_META_FLAG_READONLY: GstMetaFlags = 1; +pub const GST_META_FLAG_POOLED: GstMetaFlags = 2; +pub const GST_META_FLAG_LOCKED: GstMetaFlags = 4; +pub const GST_META_FLAG_LAST: GstMetaFlags = 65536; -bitflags! { - #[repr(C)] - pub struct GstMiniObjectFlags: c_uint { - const LOCKABLE = 1; - const LOCK_READONLY = 2; - const MAY_BE_LEAKED = 4; - const LAST = 16; - } -} -pub const GST_MINI_OBJECT_FLAG_LOCKABLE: GstMiniObjectFlags = GstMiniObjectFlags::LOCKABLE; -pub const GST_MINI_OBJECT_FLAG_LOCK_READONLY: GstMiniObjectFlags = GstMiniObjectFlags::LOCK_READONLY; -pub const GST_MINI_OBJECT_FLAG_MAY_BE_LEAKED: GstMiniObjectFlags = GstMiniObjectFlags::MAY_BE_LEAKED; -pub const GST_MINI_OBJECT_FLAG_LAST: GstMiniObjectFlags = GstMiniObjectFlags::LAST; +pub type GstMiniObjectFlags = c_uint; +pub const GST_MINI_OBJECT_FLAG_LOCKABLE: GstMiniObjectFlags = 1; +pub const GST_MINI_OBJECT_FLAG_LOCK_READONLY: GstMiniObjectFlags = 2; +pub const GST_MINI_OBJECT_FLAG_MAY_BE_LEAKED: GstMiniObjectFlags = 4; +pub const GST_MINI_OBJECT_FLAG_LAST: GstMiniObjectFlags = 16; -bitflags! { - #[repr(C)] - pub struct GstObjectFlags: c_uint { - const MAY_BE_LEAKED = 1; - const LAST = 16; - } -} -pub const GST_OBJECT_FLAG_MAY_BE_LEAKED: GstObjectFlags = GstObjectFlags::MAY_BE_LEAKED; -pub const GST_OBJECT_FLAG_LAST: GstObjectFlags = GstObjectFlags::LAST; +pub type GstObjectFlags = c_uint; +pub const GST_OBJECT_FLAG_MAY_BE_LEAKED: GstObjectFlags = 1; +pub const GST_OBJECT_FLAG_LAST: GstObjectFlags = 16; -bitflags! { - #[repr(C)] - pub struct GstPadFlags: c_uint { - const BLOCKED = 16; - const FLUSHING = 32; - const EOS = 64; - const BLOCKING = 128; - const NEED_PARENT = 256; - const NEED_RECONFIGURE = 512; - const PENDING_EVENTS = 1024; - const FIXED_CAPS = 2048; - const PROXY_CAPS = 4096; - const PROXY_ALLOCATION = 8192; - const PROXY_SCHEDULING = 16384; - const ACCEPT_INTERSECT = 32768; - const ACCEPT_TEMPLATE = 65536; - const LAST = 1048576; - } -} -pub const GST_PAD_FLAG_BLOCKED: GstPadFlags = GstPadFlags::BLOCKED; -pub const GST_PAD_FLAG_FLUSHING: GstPadFlags = GstPadFlags::FLUSHING; -pub const GST_PAD_FLAG_EOS: GstPadFlags = GstPadFlags::EOS; -pub const GST_PAD_FLAG_BLOCKING: GstPadFlags = GstPadFlags::BLOCKING; -pub const GST_PAD_FLAG_NEED_PARENT: GstPadFlags = GstPadFlags::NEED_PARENT; -pub const GST_PAD_FLAG_NEED_RECONFIGURE: GstPadFlags = GstPadFlags::NEED_RECONFIGURE; -pub const GST_PAD_FLAG_PENDING_EVENTS: GstPadFlags = GstPadFlags::PENDING_EVENTS; -pub const GST_PAD_FLAG_FIXED_CAPS: GstPadFlags = GstPadFlags::FIXED_CAPS; -pub const GST_PAD_FLAG_PROXY_CAPS: GstPadFlags = GstPadFlags::PROXY_CAPS; -pub const GST_PAD_FLAG_PROXY_ALLOCATION: GstPadFlags = GstPadFlags::PROXY_ALLOCATION; -pub const GST_PAD_FLAG_PROXY_SCHEDULING: GstPadFlags = GstPadFlags::PROXY_SCHEDULING; -pub const GST_PAD_FLAG_ACCEPT_INTERSECT: GstPadFlags = GstPadFlags::ACCEPT_INTERSECT; -pub const GST_PAD_FLAG_ACCEPT_TEMPLATE: GstPadFlags = GstPadFlags::ACCEPT_TEMPLATE; -pub const GST_PAD_FLAG_LAST: GstPadFlags = GstPadFlags::LAST; +pub type GstPadFlags = c_uint; +pub const GST_PAD_FLAG_BLOCKED: GstPadFlags = 16; +pub const GST_PAD_FLAG_FLUSHING: GstPadFlags = 32; +pub const GST_PAD_FLAG_EOS: GstPadFlags = 64; +pub const GST_PAD_FLAG_BLOCKING: GstPadFlags = 128; +pub const GST_PAD_FLAG_NEED_PARENT: GstPadFlags = 256; +pub const GST_PAD_FLAG_NEED_RECONFIGURE: GstPadFlags = 512; +pub const GST_PAD_FLAG_PENDING_EVENTS: GstPadFlags = 1024; +pub const GST_PAD_FLAG_FIXED_CAPS: GstPadFlags = 2048; +pub const GST_PAD_FLAG_PROXY_CAPS: GstPadFlags = 4096; +pub const GST_PAD_FLAG_PROXY_ALLOCATION: GstPadFlags = 8192; +pub const GST_PAD_FLAG_PROXY_SCHEDULING: GstPadFlags = 16384; +pub const GST_PAD_FLAG_ACCEPT_INTERSECT: GstPadFlags = 32768; +pub const GST_PAD_FLAG_ACCEPT_TEMPLATE: GstPadFlags = 65536; +pub const GST_PAD_FLAG_LAST: GstPadFlags = 1048576; -bitflags! { - #[repr(C)] - pub struct GstPadLinkCheck: c_uint { - const NOTHING = 0; - const HIERARCHY = 1; - const TEMPLATE_CAPS = 2; - const CAPS = 4; - const NO_RECONFIGURE = 8; - const DEFAULT = 5; - } -} -pub const GST_PAD_LINK_CHECK_NOTHING: GstPadLinkCheck = GstPadLinkCheck::NOTHING; -pub const GST_PAD_LINK_CHECK_HIERARCHY: GstPadLinkCheck = GstPadLinkCheck::HIERARCHY; -pub const GST_PAD_LINK_CHECK_TEMPLATE_CAPS: GstPadLinkCheck = GstPadLinkCheck::TEMPLATE_CAPS; -pub const GST_PAD_LINK_CHECK_CAPS: GstPadLinkCheck = GstPadLinkCheck::CAPS; -pub const GST_PAD_LINK_CHECK_NO_RECONFIGURE: GstPadLinkCheck = GstPadLinkCheck::NO_RECONFIGURE; -pub const GST_PAD_LINK_CHECK_DEFAULT: GstPadLinkCheck = GstPadLinkCheck::DEFAULT; +pub type GstPadLinkCheck = c_uint; +pub const GST_PAD_LINK_CHECK_NOTHING: GstPadLinkCheck = 0; +pub const GST_PAD_LINK_CHECK_HIERARCHY: GstPadLinkCheck = 1; +pub const GST_PAD_LINK_CHECK_TEMPLATE_CAPS: GstPadLinkCheck = 2; +pub const GST_PAD_LINK_CHECK_CAPS: GstPadLinkCheck = 4; +pub const GST_PAD_LINK_CHECK_NO_RECONFIGURE: GstPadLinkCheck = 8; +pub const GST_PAD_LINK_CHECK_DEFAULT: GstPadLinkCheck = 5; -bitflags! { - #[repr(C)] - pub struct GstPadProbeType: c_uint { - const INVALID = 0; - const IDLE = 1; - const BLOCK = 2; - const BUFFER = 16; - const BUFFER_LIST = 32; - const EVENT_DOWNSTREAM = 64; - const EVENT_UPSTREAM = 128; - const EVENT_FLUSH = 256; - const QUERY_DOWNSTREAM = 512; - const QUERY_UPSTREAM = 1024; - const PUSH = 4096; - const PULL = 8192; - const BLOCKING = 3; - const DATA_DOWNSTREAM = 112; - const DATA_UPSTREAM = 128; - const DATA_BOTH = 240; - const BLOCK_DOWNSTREAM = 114; - const BLOCK_UPSTREAM = 130; - const EVENT_BOTH = 192; - const QUERY_BOTH = 1536; - const ALL_BOTH = 1776; - const SCHEDULING = 12288; - } -} -pub const GST_PAD_PROBE_TYPE_INVALID: GstPadProbeType = GstPadProbeType::INVALID; -pub const GST_PAD_PROBE_TYPE_IDLE: GstPadProbeType = GstPadProbeType::IDLE; -pub const GST_PAD_PROBE_TYPE_BLOCK: GstPadProbeType = GstPadProbeType::BLOCK; -pub const GST_PAD_PROBE_TYPE_BUFFER: GstPadProbeType = GstPadProbeType::BUFFER; -pub const GST_PAD_PROBE_TYPE_BUFFER_LIST: GstPadProbeType = GstPadProbeType::BUFFER_LIST; -pub const GST_PAD_PROBE_TYPE_EVENT_DOWNSTREAM: GstPadProbeType = GstPadProbeType::EVENT_DOWNSTREAM; -pub const GST_PAD_PROBE_TYPE_EVENT_UPSTREAM: GstPadProbeType = GstPadProbeType::DATA_UPSTREAM; -pub const GST_PAD_PROBE_TYPE_EVENT_FLUSH: GstPadProbeType = GstPadProbeType::EVENT_FLUSH; -pub const GST_PAD_PROBE_TYPE_QUERY_DOWNSTREAM: GstPadProbeType = GstPadProbeType::QUERY_DOWNSTREAM; -pub const GST_PAD_PROBE_TYPE_QUERY_UPSTREAM: GstPadProbeType = GstPadProbeType::QUERY_UPSTREAM; -pub const GST_PAD_PROBE_TYPE_PUSH: GstPadProbeType = GstPadProbeType::PUSH; -pub const GST_PAD_PROBE_TYPE_PULL: GstPadProbeType = GstPadProbeType::PULL; -pub const GST_PAD_PROBE_TYPE_BLOCKING: GstPadProbeType = GstPadProbeType::BLOCKING; -pub const GST_PAD_PROBE_TYPE_DATA_DOWNSTREAM: GstPadProbeType = GstPadProbeType::DATA_DOWNSTREAM; -pub const GST_PAD_PROBE_TYPE_DATA_UPSTREAM: GstPadProbeType = GstPadProbeType::DATA_UPSTREAM; -pub const GST_PAD_PROBE_TYPE_DATA_BOTH: GstPadProbeType = GstPadProbeType::DATA_BOTH; -pub const GST_PAD_PROBE_TYPE_BLOCK_DOWNSTREAM: GstPadProbeType = GstPadProbeType::BLOCK_DOWNSTREAM; -pub const GST_PAD_PROBE_TYPE_BLOCK_UPSTREAM: GstPadProbeType = GstPadProbeType::BLOCK_UPSTREAM; -pub const GST_PAD_PROBE_TYPE_EVENT_BOTH: GstPadProbeType = GstPadProbeType::EVENT_BOTH; -pub const GST_PAD_PROBE_TYPE_QUERY_BOTH: GstPadProbeType = GstPadProbeType::QUERY_BOTH; -pub const GST_PAD_PROBE_TYPE_ALL_BOTH: GstPadProbeType = GstPadProbeType::ALL_BOTH; -pub const GST_PAD_PROBE_TYPE_SCHEDULING: GstPadProbeType = GstPadProbeType::SCHEDULING; +pub type GstPadProbeType = c_uint; +pub const GST_PAD_PROBE_TYPE_INVALID: GstPadProbeType = 0; +pub const GST_PAD_PROBE_TYPE_IDLE: GstPadProbeType = 1; +pub const GST_PAD_PROBE_TYPE_BLOCK: GstPadProbeType = 2; +pub const GST_PAD_PROBE_TYPE_BUFFER: GstPadProbeType = 16; +pub const GST_PAD_PROBE_TYPE_BUFFER_LIST: GstPadProbeType = 32; +pub const GST_PAD_PROBE_TYPE_EVENT_DOWNSTREAM: GstPadProbeType = 64; +pub const GST_PAD_PROBE_TYPE_EVENT_UPSTREAM: GstPadProbeType = 128; +pub const GST_PAD_PROBE_TYPE_EVENT_FLUSH: GstPadProbeType = 256; +pub const GST_PAD_PROBE_TYPE_QUERY_DOWNSTREAM: GstPadProbeType = 512; +pub const GST_PAD_PROBE_TYPE_QUERY_UPSTREAM: GstPadProbeType = 1024; +pub const GST_PAD_PROBE_TYPE_PUSH: GstPadProbeType = 4096; +pub const GST_PAD_PROBE_TYPE_PULL: GstPadProbeType = 8192; +pub const GST_PAD_PROBE_TYPE_BLOCKING: GstPadProbeType = 3; +pub const GST_PAD_PROBE_TYPE_DATA_DOWNSTREAM: GstPadProbeType = 112; +pub const GST_PAD_PROBE_TYPE_DATA_UPSTREAM: GstPadProbeType = 128; +pub const GST_PAD_PROBE_TYPE_DATA_BOTH: GstPadProbeType = 240; +pub const GST_PAD_PROBE_TYPE_BLOCK_DOWNSTREAM: GstPadProbeType = 114; +pub const GST_PAD_PROBE_TYPE_BLOCK_UPSTREAM: GstPadProbeType = 130; +pub const GST_PAD_PROBE_TYPE_EVENT_BOTH: GstPadProbeType = 192; +pub const GST_PAD_PROBE_TYPE_QUERY_BOTH: GstPadProbeType = 1536; +pub const GST_PAD_PROBE_TYPE_ALL_BOTH: GstPadProbeType = 1776; +pub const GST_PAD_PROBE_TYPE_SCHEDULING: GstPadProbeType = 12288; -bitflags! { - #[repr(C)] - pub struct GstPadTemplateFlags: c_uint { - const LAST = 256; - } -} -pub const GST_PAD_TEMPLATE_FLAG_LAST: GstPadTemplateFlags = GstPadTemplateFlags::LAST; +pub type GstPadTemplateFlags = c_uint; +pub const GST_PAD_TEMPLATE_FLAG_LAST: GstPadTemplateFlags = 256; -bitflags! { - #[repr(C)] - pub struct GstParseFlags: c_uint { - const NONE = 0; - const FATAL_ERRORS = 1; - const NO_SINGLE_ELEMENT_BINS = 2; - const PLACE_IN_BIN = 4; - } -} -pub const GST_PARSE_FLAG_NONE: GstParseFlags = GstParseFlags::NONE; -pub const GST_PARSE_FLAG_FATAL_ERRORS: GstParseFlags = GstParseFlags::FATAL_ERRORS; -pub const GST_PARSE_FLAG_NO_SINGLE_ELEMENT_BINS: GstParseFlags = GstParseFlags::NO_SINGLE_ELEMENT_BINS; -pub const GST_PARSE_FLAG_PLACE_IN_BIN: GstParseFlags = GstParseFlags::PLACE_IN_BIN; +pub type GstParseFlags = c_uint; +pub const GST_PARSE_FLAG_NONE: GstParseFlags = 0; +pub const GST_PARSE_FLAG_FATAL_ERRORS: GstParseFlags = 1; +pub const GST_PARSE_FLAG_NO_SINGLE_ELEMENT_BINS: GstParseFlags = 2; +pub const GST_PARSE_FLAG_PLACE_IN_BIN: GstParseFlags = 4; -bitflags! { - #[repr(C)] - pub struct GstPipelineFlags: c_uint { - const FIXED_CLOCK = 524288; - const LAST = 8388608; - } -} -pub const GST_PIPELINE_FLAG_FIXED_CLOCK: GstPipelineFlags = GstPipelineFlags::FIXED_CLOCK; -pub const GST_PIPELINE_FLAG_LAST: GstPipelineFlags = GstPipelineFlags::LAST; +pub type GstPipelineFlags = c_uint; +pub const GST_PIPELINE_FLAG_FIXED_CLOCK: GstPipelineFlags = 524288; +pub const GST_PIPELINE_FLAG_LAST: GstPipelineFlags = 8388608; -bitflags! { - #[repr(C)] - pub struct GstPluginDependencyFlags: c_uint { - const NONE = 0; - const RECURSE = 1; - const PATHS_ARE_DEFAULT_ONLY = 2; - const FILE_NAME_IS_SUFFIX = 4; - const FILE_NAME_IS_PREFIX = 8; - const PATHS_ARE_RELATIVE_TO_EXE = 16; - } -} -pub const GST_PLUGIN_DEPENDENCY_FLAG_NONE: GstPluginDependencyFlags = GstPluginDependencyFlags::NONE; -pub const GST_PLUGIN_DEPENDENCY_FLAG_RECURSE: GstPluginDependencyFlags = GstPluginDependencyFlags::RECURSE; -pub const GST_PLUGIN_DEPENDENCY_FLAG_PATHS_ARE_DEFAULT_ONLY: GstPluginDependencyFlags = GstPluginDependencyFlags::PATHS_ARE_DEFAULT_ONLY; -pub const GST_PLUGIN_DEPENDENCY_FLAG_FILE_NAME_IS_SUFFIX: GstPluginDependencyFlags = GstPluginDependencyFlags::FILE_NAME_IS_SUFFIX; -pub const GST_PLUGIN_DEPENDENCY_FLAG_FILE_NAME_IS_PREFIX: GstPluginDependencyFlags = GstPluginDependencyFlags::FILE_NAME_IS_PREFIX; -pub const GST_PLUGIN_DEPENDENCY_FLAG_PATHS_ARE_RELATIVE_TO_EXE: GstPluginDependencyFlags = GstPluginDependencyFlags::PATHS_ARE_RELATIVE_TO_EXE; +pub type GstPluginDependencyFlags = c_uint; +pub const GST_PLUGIN_DEPENDENCY_FLAG_NONE: GstPluginDependencyFlags = 0; +pub const GST_PLUGIN_DEPENDENCY_FLAG_RECURSE: GstPluginDependencyFlags = 1; +pub const GST_PLUGIN_DEPENDENCY_FLAG_PATHS_ARE_DEFAULT_ONLY: GstPluginDependencyFlags = 2; +pub const GST_PLUGIN_DEPENDENCY_FLAG_FILE_NAME_IS_SUFFIX: GstPluginDependencyFlags = 4; +pub const GST_PLUGIN_DEPENDENCY_FLAG_FILE_NAME_IS_PREFIX: GstPluginDependencyFlags = 8; +pub const GST_PLUGIN_DEPENDENCY_FLAG_PATHS_ARE_RELATIVE_TO_EXE: GstPluginDependencyFlags = 16; -bitflags! { - #[repr(C)] - pub struct GstPluginFlags: c_uint { - const CACHED = 16; - const BLACKLISTED = 32; - } -} -pub const GST_PLUGIN_FLAG_CACHED: GstPluginFlags = GstPluginFlags::CACHED; -pub const GST_PLUGIN_FLAG_BLACKLISTED: GstPluginFlags = GstPluginFlags::BLACKLISTED; +pub type GstPluginFlags = c_uint; +pub const GST_PLUGIN_FLAG_CACHED: GstPluginFlags = 16; +pub const GST_PLUGIN_FLAG_BLACKLISTED: GstPluginFlags = 32; -bitflags! { - #[repr(C)] - pub struct GstQueryTypeFlags: c_uint { - const UPSTREAM = 1; - const DOWNSTREAM = 2; - const SERIALIZED = 4; - } -} -pub const GST_QUERY_TYPE_UPSTREAM: GstQueryTypeFlags = GstQueryTypeFlags::UPSTREAM; -pub const GST_QUERY_TYPE_DOWNSTREAM: GstQueryTypeFlags = GstQueryTypeFlags::DOWNSTREAM; -pub const GST_QUERY_TYPE_SERIALIZED: GstQueryTypeFlags = GstQueryTypeFlags::SERIALIZED; +pub type GstQueryTypeFlags = c_uint; +pub const GST_QUERY_TYPE_UPSTREAM: GstQueryTypeFlags = 1; +pub const GST_QUERY_TYPE_DOWNSTREAM: GstQueryTypeFlags = 2; +pub const GST_QUERY_TYPE_SERIALIZED: GstQueryTypeFlags = 4; -bitflags! { - #[repr(C)] - pub struct GstSchedulingFlags: c_uint { - const SEEKABLE = 1; - const SEQUENTIAL = 2; - const BANDWIDTH_LIMITED = 4; - } -} -pub const GST_SCHEDULING_FLAG_SEEKABLE: GstSchedulingFlags = GstSchedulingFlags::SEEKABLE; -pub const GST_SCHEDULING_FLAG_SEQUENTIAL: GstSchedulingFlags = GstSchedulingFlags::SEQUENTIAL; -pub const GST_SCHEDULING_FLAG_BANDWIDTH_LIMITED: GstSchedulingFlags = GstSchedulingFlags::BANDWIDTH_LIMITED; +pub type GstSchedulingFlags = c_uint; +pub const GST_SCHEDULING_FLAG_SEEKABLE: GstSchedulingFlags = 1; +pub const GST_SCHEDULING_FLAG_SEQUENTIAL: GstSchedulingFlags = 2; +pub const GST_SCHEDULING_FLAG_BANDWIDTH_LIMITED: GstSchedulingFlags = 4; -bitflags! { - #[repr(C)] - pub struct GstSeekFlags: c_uint { - const NONE = 0; - const FLUSH = 1; - const ACCURATE = 2; - const KEY_UNIT = 4; - const SEGMENT = 8; - const TRICKMODE = 16; - const SKIP = 16; - const SNAP_BEFORE = 32; - const SNAP_AFTER = 64; - const SNAP_NEAREST = 96; - const TRICKMODE_KEY_UNITS = 128; - const TRICKMODE_NO_AUDIO = 256; - } -} -pub const GST_SEEK_FLAG_NONE: GstSeekFlags = GstSeekFlags::NONE; -pub const GST_SEEK_FLAG_FLUSH: GstSeekFlags = GstSeekFlags::FLUSH; -pub const GST_SEEK_FLAG_ACCURATE: GstSeekFlags = GstSeekFlags::ACCURATE; -pub const GST_SEEK_FLAG_KEY_UNIT: GstSeekFlags = GstSeekFlags::KEY_UNIT; -pub const GST_SEEK_FLAG_SEGMENT: GstSeekFlags = GstSeekFlags::SEGMENT; -pub const GST_SEEK_FLAG_TRICKMODE: GstSeekFlags = GstSeekFlags::SKIP; -pub const GST_SEEK_FLAG_SKIP: GstSeekFlags = GstSeekFlags::SKIP; -pub const GST_SEEK_FLAG_SNAP_BEFORE: GstSeekFlags = GstSeekFlags::SNAP_BEFORE; -pub const GST_SEEK_FLAG_SNAP_AFTER: GstSeekFlags = GstSeekFlags::SNAP_AFTER; -pub const GST_SEEK_FLAG_SNAP_NEAREST: GstSeekFlags = GstSeekFlags::SNAP_NEAREST; -pub const GST_SEEK_FLAG_TRICKMODE_KEY_UNITS: GstSeekFlags = GstSeekFlags::TRICKMODE_KEY_UNITS; -pub const GST_SEEK_FLAG_TRICKMODE_NO_AUDIO: GstSeekFlags = GstSeekFlags::TRICKMODE_NO_AUDIO; +pub type GstSeekFlags = c_uint; +pub const GST_SEEK_FLAG_NONE: GstSeekFlags = 0; +pub const GST_SEEK_FLAG_FLUSH: GstSeekFlags = 1; +pub const GST_SEEK_FLAG_ACCURATE: GstSeekFlags = 2; +pub const GST_SEEK_FLAG_KEY_UNIT: GstSeekFlags = 4; +pub const GST_SEEK_FLAG_SEGMENT: GstSeekFlags = 8; +pub const GST_SEEK_FLAG_TRICKMODE: GstSeekFlags = 16; +pub const GST_SEEK_FLAG_SKIP: GstSeekFlags = 16; +pub const GST_SEEK_FLAG_SNAP_BEFORE: GstSeekFlags = 32; +pub const GST_SEEK_FLAG_SNAP_AFTER: GstSeekFlags = 64; +pub const GST_SEEK_FLAG_SNAP_NEAREST: GstSeekFlags = 96; +pub const GST_SEEK_FLAG_TRICKMODE_KEY_UNITS: GstSeekFlags = 128; +pub const GST_SEEK_FLAG_TRICKMODE_NO_AUDIO: GstSeekFlags = 256; -bitflags! { - #[repr(C)] - pub struct GstSegmentFlags: c_uint { - const NONE = 0; - const RESET = 1; - const TRICKMODE = 16; - const SKIP = 16; - const SEGMENT = 8; - const TRICKMODE_KEY_UNITS = 128; - const TRICKMODE_NO_AUDIO = 256; - } -} -pub const GST_SEGMENT_FLAG_NONE: GstSegmentFlags = GstSegmentFlags::NONE; -pub const GST_SEGMENT_FLAG_RESET: GstSegmentFlags = GstSegmentFlags::RESET; -pub const GST_SEGMENT_FLAG_TRICKMODE: GstSegmentFlags = GstSegmentFlags::SKIP; -pub const GST_SEGMENT_FLAG_SKIP: GstSegmentFlags = GstSegmentFlags::SKIP; -pub const GST_SEGMENT_FLAG_SEGMENT: GstSegmentFlags = GstSegmentFlags::SEGMENT; -pub const GST_SEGMENT_FLAG_TRICKMODE_KEY_UNITS: GstSegmentFlags = GstSegmentFlags::TRICKMODE_KEY_UNITS; -pub const GST_SEGMENT_FLAG_TRICKMODE_NO_AUDIO: GstSegmentFlags = GstSegmentFlags::TRICKMODE_NO_AUDIO; +pub type GstSegmentFlags = c_uint; +pub const GST_SEGMENT_FLAG_NONE: GstSegmentFlags = 0; +pub const GST_SEGMENT_FLAG_RESET: GstSegmentFlags = 1; +pub const GST_SEGMENT_FLAG_TRICKMODE: GstSegmentFlags = 16; +pub const GST_SEGMENT_FLAG_SKIP: GstSegmentFlags = 16; +pub const GST_SEGMENT_FLAG_SEGMENT: GstSegmentFlags = 8; +pub const GST_SEGMENT_FLAG_TRICKMODE_KEY_UNITS: GstSegmentFlags = 128; +pub const GST_SEGMENT_FLAG_TRICKMODE_NO_AUDIO: GstSegmentFlags = 256; -bitflags! { - #[repr(C)] - pub struct GstStackTraceFlags: c_uint { - const FULL = 1; - } -} -pub const GST_STACK_TRACE_SHOW_FULL: GstStackTraceFlags = GstStackTraceFlags::FULL; +pub type GstStackTraceFlags = c_uint; +pub const GST_STACK_TRACE_SHOW_FULL: GstStackTraceFlags = 1; -bitflags! { - #[repr(C)] - pub struct GstStreamFlags: c_uint { - const NONE = 0; - const SPARSE = 1; - const SELECT = 2; - const UNSELECT = 4; - } -} -pub const GST_STREAM_FLAG_NONE: GstStreamFlags = GstStreamFlags::NONE; -pub const GST_STREAM_FLAG_SPARSE: GstStreamFlags = GstStreamFlags::SPARSE; -pub const GST_STREAM_FLAG_SELECT: GstStreamFlags = GstStreamFlags::SELECT; -pub const GST_STREAM_FLAG_UNSELECT: GstStreamFlags = GstStreamFlags::UNSELECT; +pub type GstStreamFlags = c_uint; +pub const GST_STREAM_FLAG_NONE: GstStreamFlags = 0; +pub const GST_STREAM_FLAG_SPARSE: GstStreamFlags = 1; +pub const GST_STREAM_FLAG_SELECT: GstStreamFlags = 2; +pub const GST_STREAM_FLAG_UNSELECT: GstStreamFlags = 4; -bitflags! { - #[repr(C)] - pub struct GstStreamType: c_uint { - const UNKNOWN = 1; - const AUDIO = 2; - const VIDEO = 4; - const CONTAINER = 8; - const TEXT = 16; - } -} -pub const GST_STREAM_TYPE_UNKNOWN: GstStreamType = GstStreamType::UNKNOWN; -pub const GST_STREAM_TYPE_AUDIO: GstStreamType = GstStreamType::AUDIO; -pub const GST_STREAM_TYPE_VIDEO: GstStreamType = GstStreamType::VIDEO; -pub const GST_STREAM_TYPE_CONTAINER: GstStreamType = GstStreamType::CONTAINER; -pub const GST_STREAM_TYPE_TEXT: GstStreamType = GstStreamType::TEXT; +pub type GstStreamType = c_uint; +pub const GST_STREAM_TYPE_UNKNOWN: GstStreamType = 1; +pub const GST_STREAM_TYPE_AUDIO: GstStreamType = 2; +pub const GST_STREAM_TYPE_VIDEO: GstStreamType = 4; +pub const GST_STREAM_TYPE_CONTAINER: GstStreamType = 8; +pub const GST_STREAM_TYPE_TEXT: GstStreamType = 16; -bitflags! { - #[repr(C)] - pub struct GstTracerValueFlags: c_uint { - const NONE = 0; - const OPTIONAL = 1; - const AGGREGATED = 2; - } -} -pub const GST_TRACER_VALUE_FLAGS_NONE: GstTracerValueFlags = GstTracerValueFlags::NONE; -pub const GST_TRACER_VALUE_FLAGS_OPTIONAL: GstTracerValueFlags = GstTracerValueFlags::OPTIONAL; -pub const GST_TRACER_VALUE_FLAGS_AGGREGATED: GstTracerValueFlags = GstTracerValueFlags::AGGREGATED; +pub type GstTracerValueFlags = c_uint; +pub const GST_TRACER_VALUE_FLAGS_NONE: GstTracerValueFlags = 0; +pub const GST_TRACER_VALUE_FLAGS_OPTIONAL: GstTracerValueFlags = 1; +pub const GST_TRACER_VALUE_FLAGS_AGGREGATED: GstTracerValueFlags = 2; // Unions #[repr(C)] @@ -6128,14 +5748,14 @@ extern "C" { pub fn gst_plugin_get_type() -> GType; pub fn gst_plugin_list_free(list: *mut glib::GList); pub fn gst_plugin_load_by_name(name: *const c_char) -> *mut GstPlugin; - pub fn gst_plugin_load_file(filename: *mut c_char, error: *mut *mut glib::GError) -> *mut GstPlugin; + pub fn gst_plugin_load_file(filename: *const c_char, error: *mut *mut glib::GError) -> *mut GstPlugin; pub fn gst_plugin_register_static(major_version: c_int, minor_version: c_int, name: *const c_char, description: *const c_char, init_func: GstPluginInitFunc, version: *const c_char, license: *const c_char, source: *const c_char, package: *const c_char, origin: *const c_char) -> gboolean; pub fn gst_plugin_register_static_full(major_version: c_int, minor_version: c_int, name: *const c_char, description: *const c_char, init_full_func: GstPluginInitFullFunc, version: *const c_char, license: *const c_char, source: *const c_char, package: *const c_char, origin: *const c_char, user_data: gpointer) -> gboolean; pub fn gst_plugin_add_dependency(plugin: *mut GstPlugin, env_vars: *mut *mut c_char, paths: *mut *mut c_char, names: *mut *mut c_char, flags: GstPluginDependencyFlags); pub fn gst_plugin_add_dependency_simple(plugin: *mut GstPlugin, env_vars: *const c_char, paths: *const c_char, names: *const c_char, flags: GstPluginDependencyFlags); pub fn gst_plugin_get_cache_data(plugin: *mut GstPlugin) -> *const GstStructure; pub fn gst_plugin_get_description(plugin: *mut GstPlugin) -> *const c_char; - pub fn gst_plugin_get_filename(plugin: *mut GstPlugin) -> *mut c_char; + pub fn gst_plugin_get_filename(plugin: *mut GstPlugin) -> *const c_char; pub fn gst_plugin_get_license(plugin: *mut GstPlugin) -> *const c_char; pub fn gst_plugin_get_name(plugin: *mut GstPlugin) -> *const c_char; pub fn gst_plugin_get_origin(plugin: *mut GstPlugin) -> *const c_char; @@ -6195,7 +5815,7 @@ extern "C" { pub fn gst_registry_plugin_filter(registry: *mut GstRegistry, filter: GstPluginFilter, first: gboolean, user_data: gpointer) -> *mut glib::GList; pub fn gst_registry_remove_feature(registry: *mut GstRegistry, feature: *mut GstPluginFeature); pub fn gst_registry_remove_plugin(registry: *mut GstRegistry, plugin: *mut GstPlugin); - pub fn gst_registry_scan_path(registry: *mut GstRegistry, path: *mut c_char) -> gboolean; + pub fn gst_registry_scan_path(registry: *mut GstRegistry, path: *const c_char) -> gboolean; //========================================================================= // GstStream @@ -6347,8 +5967,8 @@ extern "C" { // GstPreset //========================================================================= pub fn gst_preset_get_type() -> GType; - pub fn gst_preset_get_app_dir() -> *mut c_char; - pub fn gst_preset_set_app_dir(app_dir: *mut c_char) -> gboolean; + pub fn gst_preset_get_app_dir() -> *const c_char; + pub fn gst_preset_set_app_dir(app_dir: *const c_char) -> gboolean; pub fn gst_preset_delete_preset(preset: *mut GstPreset, name: *const c_char) -> gboolean; pub fn gst_preset_get_meta(preset: *mut GstPreset, name: *const c_char, tag: *const c_char, value: *mut *mut c_char) -> gboolean; pub fn gst_preset_get_preset_names(preset: *mut GstPreset) -> *mut *mut c_char; @@ -6401,8 +6021,8 @@ extern "C" { #[cfg(any(feature = "v1_14", feature = "dox"))] pub fn gst_debug_add_ring_buffer_logger(max_size_per_thread: c_uint, thread_timeout: c_uint); pub fn gst_debug_bin_to_dot_data(bin: *mut GstBin, details: GstDebugGraphDetails) -> *mut c_char; - pub fn gst_debug_bin_to_dot_file(bin: *mut GstBin, details: GstDebugGraphDetails, file_name: *mut c_char); - pub fn gst_debug_bin_to_dot_file_with_ts(bin: *mut GstBin, details: GstDebugGraphDetails, file_name: *mut c_char); + pub fn gst_debug_bin_to_dot_file(bin: *mut GstBin, details: GstDebugGraphDetails, file_name: *const c_char); + pub fn gst_debug_bin_to_dot_file_with_ts(bin: *mut GstBin, details: GstDebugGraphDetails, file_name: *const c_char); pub fn gst_debug_construct_term_color(colorinfo: c_uint) -> *mut c_char; pub fn gst_debug_construct_win_color(colorinfo: c_uint) -> c_int; pub fn gst_debug_get_all_categories() -> *mut glib::GSList; @@ -6437,7 +6057,7 @@ extern "C" { pub fn gst_deinit(); pub fn gst_dynamic_type_register(plugin: *mut GstPlugin, type_: GType) -> gboolean; pub fn gst_error_get_message(domain: glib::GQuark, code: c_int) -> *mut c_char; - pub fn gst_filename_to_uri(filename: *mut c_char, error: *mut *mut glib::GError) -> *mut c_char; + pub fn gst_filename_to_uri(filename: *const c_char, error: *mut *mut glib::GError) -> *mut c_char; pub fn gst_flow_get_name(ret: GstFlowReturn) -> *const c_char; pub fn gst_flow_to_quark(ret: GstFlowReturn) -> glib::GQuark; pub fn gst_formats_contains(formats: *mut GstFormat, format: GstFormat) -> gboolean; diff --git a/gstreamer-sys/tests/abi.rs b/gstreamer-sys/tests/abi.rs new file mode 100644 index 000000000..fd03f7e55 --- /dev/null +++ b/gstreamer-sys/tests/abi.rs @@ -0,0 +1,1124 @@ +// This file was generated by gir (https://github.com/gtk-rs/gir @ 6855214) +// from gir-files (https://github.com/gtk-rs/gir-files @ ???) +// DO NOT EDIT + +extern crate gstreamer_sys; +extern crate shell_words; +extern crate tempdir; +use std::env; +use std::error::Error; +use std::path::Path; +use std::mem::{align_of, size_of}; +use std::process::Command; +use std::str; +use gstreamer_sys::*; + +static PACKAGES: &[&str] = &["gstreamer-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 = tempdir::TempDir::new("abi").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 = tempdir::TempDir::new("abi").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()); + } + + Ok(str::from_utf8(&output.stdout)?.trim().to_owned()) +} + +const RUST_LAYOUTS: &[(&str, Layout)] = &[ + ("GstAllocationParams", Layout {size: size_of::(), alignment: align_of::()}), + ("GstAllocator", Layout {size: size_of::(), alignment: align_of::()}), + ("GstAllocatorClass", Layout {size: size_of::(), alignment: align_of::()}), + ("GstAllocatorFlags", Layout {size: size_of::(), alignment: align_of::()}), + ("GstBin", Layout {size: size_of::(), alignment: align_of::()}), + ("GstBinClass", Layout {size: size_of::(), alignment: align_of::()}), + ("GstBinFlags", Layout {size: size_of::(), alignment: align_of::()}), + ("GstBuffer", Layout {size: size_of::(), alignment: align_of::()}), + ("GstBufferCopyFlags", Layout {size: size_of::(), alignment: align_of::()}), + ("GstBufferFlags", Layout {size: size_of::(), alignment: align_of::()}), + ("GstBufferPool", Layout {size: size_of::(), alignment: align_of::()}), + ("GstBufferPoolAcquireFlags", Layout {size: size_of::(), alignment: align_of::()}), + ("GstBufferPoolAcquireParams", Layout {size: size_of::(), alignment: align_of::()}), + ("GstBufferPoolClass", Layout {size: size_of::(), alignment: align_of::()}), + ("GstBufferingMode", Layout {size: size_of::(), alignment: align_of::()}), + ("GstBus", Layout {size: size_of::(), alignment: align_of::()}), + ("GstBusClass", Layout {size: size_of::(), alignment: align_of::()}), + ("GstBusFlags", Layout {size: size_of::(), alignment: align_of::()}), + ("GstBusSyncReply", Layout {size: size_of::(), alignment: align_of::()}), + ("GstCaps", Layout {size: size_of::(), alignment: align_of::()}), + ("GstCapsFlags", Layout {size: size_of::(), alignment: align_of::()}), + ("GstCapsIntersectMode", Layout {size: size_of::(), alignment: align_of::()}), + ("GstChildProxyInterface", Layout {size: size_of::(), alignment: align_of::()}), + ("GstClock", Layout {size: size_of::(), alignment: align_of::()}), + ("GstClockClass", Layout {size: size_of::(), alignment: align_of::()}), + ("GstClockEntry", Layout {size: size_of::(), alignment: align_of::()}), + ("GstClockEntryType", Layout {size: size_of::(), alignment: align_of::()}), + ("GstClockFlags", Layout {size: size_of::(), alignment: align_of::()}), + ("GstClockID", Layout {size: size_of::(), alignment: align_of::()}), + ("GstClockReturn", Layout {size: size_of::(), alignment: align_of::()}), + ("GstClockTime", Layout {size: size_of::(), alignment: align_of::()}), + ("GstClockTimeDiff", Layout {size: size_of::(), alignment: align_of::()}), + ("GstClockType", Layout {size: size_of::(), alignment: align_of::()}), + ("GstControlBinding", Layout {size: size_of::(), alignment: align_of::()}), + ("GstControlBindingClass", Layout {size: size_of::(), alignment: align_of::()}), + ("GstControlSource", Layout {size: size_of::(), alignment: align_of::()}), + ("GstControlSourceClass", Layout {size: size_of::(), alignment: align_of::()}), + ("GstCoreError", Layout {size: size_of::(), alignment: align_of::()}), + ("GstDebugCategory", Layout {size: size_of::(), alignment: align_of::()}), + ("GstDebugColorFlags", Layout {size: size_of::(), alignment: align_of::()}), + ("GstDebugColorMode", Layout {size: size_of::(), alignment: align_of::()}), + ("GstDebugGraphDetails", Layout {size: size_of::(), alignment: align_of::()}), + ("GstDebugLevel", Layout {size: size_of::(), alignment: align_of::()}), + ("GstDevice", Layout {size: size_of::(), alignment: align_of::()}), + ("GstDeviceClass", Layout {size: size_of::(), alignment: align_of::()}), + ("GstDeviceMonitor", Layout {size: size_of::(), alignment: align_of::()}), + ("GstDeviceMonitorClass", Layout {size: size_of::(), alignment: align_of::()}), + ("GstDeviceProvider", Layout {size: size_of::(), alignment: align_of::()}), + ("GstDeviceProviderClass", Layout {size: size_of::(), alignment: align_of::()}), + ("GstElement", Layout {size: size_of::(), alignment: align_of::()}), + ("GstElementClass", Layout {size: size_of::(), alignment: align_of::()}), + ("GstElementFactoryListType", Layout {size: size_of::(), alignment: align_of::()}), + ("GstElementFlags", Layout {size: size_of::(), alignment: align_of::()}), + ("GstEvent", Layout {size: size_of::(), alignment: align_of::()}), + ("GstEventType", Layout {size: size_of::(), alignment: align_of::()}), + ("GstEventTypeFlags", Layout {size: size_of::(), alignment: align_of::()}), + ("GstFlowReturn", Layout {size: size_of::(), alignment: align_of::()}), + ("GstFormat", Layout {size: size_of::(), alignment: align_of::()}), + ("GstFormatDefinition", Layout {size: size_of::(), alignment: align_of::()}), + ("GstGhostPad", Layout {size: size_of::(), alignment: align_of::()}), + ("GstGhostPadClass", Layout {size: size_of::(), alignment: align_of::()}), + ("GstIterator", Layout {size: size_of::(), alignment: align_of::()}), + ("GstIteratorItem", Layout {size: size_of::(), alignment: align_of::()}), + ("GstIteratorResult", Layout {size: size_of::(), alignment: align_of::()}), + ("GstLibraryError", Layout {size: size_of::(), alignment: align_of::()}), + ("GstLockFlags", Layout {size: size_of::(), alignment: align_of::()}), + ("GstMapFlags", Layout {size: size_of::(), alignment: align_of::()}), + ("GstMapInfo", Layout {size: size_of::(), alignment: align_of::()}), + ("GstMemory", Layout {size: size_of::(), alignment: align_of::()}), + ("GstMemoryFlags", Layout {size: size_of::(), alignment: align_of::()}), + ("GstMessage", Layout {size: size_of::(), alignment: align_of::()}), + ("GstMessageType", Layout {size: size_of::(), alignment: align_of::()}), + ("GstMeta", Layout {size: size_of::(), alignment: align_of::()}), + ("GstMetaFlags", Layout {size: size_of::(), alignment: align_of::()}), + ("GstMetaInfo", Layout {size: size_of::(), alignment: align_of::()}), + ("GstMetaTransformCopy", Layout {size: size_of::(), alignment: align_of::()}), + ("GstMiniObject", Layout {size: size_of::(), alignment: align_of::()}), + ("GstMiniObjectFlags", Layout {size: size_of::(), alignment: align_of::()}), + ("GstObject", Layout {size: size_of::(), alignment: align_of::()}), + ("GstObjectClass", Layout {size: size_of::(), alignment: align_of::()}), + ("GstObjectFlags", Layout {size: size_of::(), alignment: align_of::()}), + ("GstPad", Layout {size: size_of::(), alignment: align_of::()}), + ("GstPadClass", Layout {size: size_of::(), alignment: align_of::()}), + ("GstPadDirection", Layout {size: size_of::(), alignment: align_of::()}), + ("GstPadFlags", Layout {size: size_of::(), alignment: align_of::()}), + ("GstPadLinkCheck", Layout {size: size_of::(), alignment: align_of::()}), + ("GstPadLinkReturn", Layout {size: size_of::(), alignment: align_of::()}), + ("GstPadMode", Layout {size: size_of::(), alignment: align_of::()}), + ("GstPadPresence", Layout {size: size_of::(), alignment: align_of::()}), + ("GstPadProbeInfo", Layout {size: size_of::(), alignment: align_of::()}), + ("GstPadProbeReturn", Layout {size: size_of::(), alignment: align_of::()}), + ("GstPadProbeType", Layout {size: size_of::(), alignment: align_of::()}), + ("GstPadTemplate", Layout {size: size_of::(), alignment: align_of::()}), + ("GstPadTemplateClass", Layout {size: size_of::(), alignment: align_of::()}), + ("GstPadTemplateFlags", Layout {size: size_of::(), alignment: align_of::()}), + ("GstParamSpecArray", Layout {size: size_of::(), alignment: align_of::()}), + ("GstParamSpecFraction", Layout {size: size_of::(), alignment: align_of::()}), + ("GstParentBufferMeta", Layout {size: size_of::(), alignment: align_of::()}), + ("GstParseError", Layout {size: size_of::(), alignment: align_of::()}), + ("GstParseFlags", Layout {size: size_of::(), alignment: align_of::()}), + ("GstPipeline", Layout {size: size_of::(), alignment: align_of::()}), + ("GstPipelineClass", Layout {size: size_of::(), alignment: align_of::()}), + ("GstPipelineFlags", Layout {size: size_of::(), alignment: align_of::()}), + ("GstPluginDependencyFlags", Layout {size: size_of::(), alignment: align_of::()}), + ("GstPluginDesc", Layout {size: size_of::(), alignment: align_of::()}), + ("GstPluginError", Layout {size: size_of::(), alignment: align_of::()}), + ("GstPluginFlags", Layout {size: size_of::(), alignment: align_of::()}), + ("GstPollFD", Layout {size: size_of::(), alignment: align_of::()}), + ("GstPresetInterface", Layout {size: size_of::(), alignment: align_of::()}), + ("GstProgressType", Layout {size: size_of::(), alignment: align_of::()}), + ("GstPromise", Layout {size: size_of::(), alignment: align_of::()}), + ("GstPromiseResult", Layout {size: size_of::(), alignment: align_of::()}), + ("GstProtectionMeta", Layout {size: size_of::(), alignment: align_of::()}), + ("GstProxyPad", Layout {size: size_of::(), alignment: align_of::()}), + ("GstProxyPadClass", Layout {size: size_of::(), alignment: align_of::()}), + ("GstQOSType", Layout {size: size_of::(), alignment: align_of::()}), + ("GstQuery", Layout {size: size_of::(), alignment: align_of::()}), + ("GstQueryType", Layout {size: size_of::(), alignment: align_of::()}), + ("GstQueryTypeFlags", Layout {size: size_of::(), alignment: align_of::()}), + ("GstRank", Layout {size: size_of::(), alignment: align_of::()}), + ("GstReferenceTimestampMeta", Layout {size: size_of::(), alignment: align_of::()}), + ("GstRegistry", Layout {size: size_of::(), alignment: align_of::()}), + ("GstRegistryClass", Layout {size: size_of::(), alignment: align_of::()}), + ("GstResourceError", Layout {size: size_of::(), alignment: align_of::()}), + ("GstSchedulingFlags", Layout {size: size_of::(), alignment: align_of::()}), + ("GstSearchMode", Layout {size: size_of::(), alignment: align_of::()}), + ("GstSeekFlags", Layout {size: size_of::(), alignment: align_of::()}), + ("GstSeekType", Layout {size: size_of::(), alignment: align_of::()}), + ("GstSegment", Layout {size: size_of::(), alignment: align_of::()}), + ("GstSegmentFlags", Layout {size: size_of::(), alignment: align_of::()}), + ("GstStackTraceFlags", Layout {size: size_of::(), alignment: align_of::()}), + ("GstState", Layout {size: size_of::(), alignment: align_of::()}), + ("GstStateChange", Layout {size: size_of::(), alignment: align_of::()}), + ("GstStateChangeReturn", Layout {size: size_of::(), alignment: align_of::()}), + ("GstStaticCaps", Layout {size: size_of::(), alignment: align_of::()}), + ("GstStaticPadTemplate", Layout {size: size_of::(), alignment: align_of::()}), + ("GstStream", Layout {size: size_of::(), alignment: align_of::()}), + ("GstStreamClass", Layout {size: size_of::(), alignment: align_of::()}), + ("GstStreamCollection", Layout {size: size_of::(), alignment: align_of::()}), + ("GstStreamCollectionClass", Layout {size: size_of::(), alignment: align_of::()}), + ("GstStreamError", Layout {size: size_of::(), alignment: align_of::()}), + ("GstStreamFlags", Layout {size: size_of::(), alignment: align_of::()}), + ("GstStreamStatusType", Layout {size: size_of::(), alignment: align_of::()}), + ("GstStreamType", Layout {size: size_of::(), alignment: align_of::()}), + ("GstStructure", Layout {size: size_of::(), alignment: align_of::()}), + ("GstStructureChangeType", Layout {size: size_of::(), alignment: align_of::()}), + ("GstSystemClock", Layout {size: size_of::(), alignment: align_of::()}), + ("GstSystemClockClass", Layout {size: size_of::(), alignment: align_of::()}), + ("GstTagFlag", Layout {size: size_of::(), alignment: align_of::()}), + ("GstTagList", Layout {size: size_of::(), alignment: align_of::()}), + ("GstTagMergeMode", Layout {size: size_of::(), alignment: align_of::()}), + ("GstTagScope", Layout {size: size_of::(), alignment: align_of::()}), + ("GstTagSetterInterface", Layout {size: size_of::(), alignment: align_of::()}), + ("GstTask", Layout {size: size_of::(), alignment: align_of::()}), + ("GstTaskClass", Layout {size: size_of::(), alignment: align_of::()}), + ("GstTaskPool", Layout {size: size_of::(), alignment: align_of::()}), + ("GstTaskPoolClass", Layout {size: size_of::(), alignment: align_of::()}), + ("GstTaskState", Layout {size: size_of::(), alignment: align_of::()}), + ("GstTimedValue", Layout {size: size_of::(), alignment: align_of::()}), + ("GstTocEntryType", Layout {size: size_of::(), alignment: align_of::()}), + ("GstTocLoopType", Layout {size: size_of::(), alignment: align_of::()}), + ("GstTocScope", Layout {size: size_of::(), alignment: align_of::()}), + ("GstTocSetterInterface", Layout {size: size_of::(), alignment: align_of::()}), + ("GstTracer", Layout {size: size_of::(), alignment: align_of::()}), + ("GstTracerClass", Layout {size: size_of::(), alignment: align_of::()}), + ("GstTracerValueFlags", Layout {size: size_of::(), alignment: align_of::()}), + ("GstTracerValueScope", Layout {size: size_of::(), alignment: align_of::()}), + ("GstTypeFind", Layout {size: size_of::(), alignment: align_of::()}), + ("GstTypeFindProbability", Layout {size: size_of::(), alignment: align_of::()}), + ("GstURIError", Layout {size: size_of::(), alignment: align_of::()}), + ("GstURIHandlerInterface", Layout {size: size_of::(), alignment: align_of::()}), + ("GstURIType", Layout {size: size_of::(), alignment: align_of::()}), + ("GstValueTable", Layout {size: size_of::(), alignment: align_of::()}), +]; + +const RUST_CONSTANTS: &[(&str, &str)] = &[ + ("GST_ALLOCATOR_FLAG_CUSTOM_ALLOC", "16"), + ("GST_ALLOCATOR_FLAG_LAST", "1048576"), + ("GST_ALLOCATOR_SYSMEM", "SystemMemory"), + ("GST_BIN_FLAG_LAST", "524288"), + ("GST_BIN_FLAG_NO_RESYNC", "16384"), + ("GST_BIN_FLAG_STREAMS_AWARE", "32768"), + ("GST_BUFFERING_DOWNLOAD", "1"), + ("GST_BUFFERING_LIVE", "3"), + ("GST_BUFFERING_STREAM", "0"), + ("GST_BUFFERING_TIMESHIFT", "2"), + ("GST_BUFFER_COPY_ALL", "15"), + ("GST_BUFFER_COPY_DEEP", "32"), + ("GST_BUFFER_COPY_FLAGS", "1"), + ("GST_BUFFER_COPY_MEMORY", "8"), + ("GST_BUFFER_COPY_MERGE", "16"), + ("GST_BUFFER_COPY_META", "4"), + ("GST_BUFFER_COPY_METADATA", "7"), + ("GST_BUFFER_COPY_NONE", "0"), + ("GST_BUFFER_COPY_TIMESTAMPS", "2"), + ("GST_BUFFER_FLAG_CORRUPTED", "256"), + ("GST_BUFFER_FLAG_DECODE_ONLY", "32"), + ("GST_BUFFER_FLAG_DELTA_UNIT", "8192"), + ("GST_BUFFER_FLAG_DISCONT", "64"), + ("GST_BUFFER_FLAG_DROPPABLE", "4096"), + ("GST_BUFFER_FLAG_GAP", "2048"), + ("GST_BUFFER_FLAG_HEADER", "1024"), + ("GST_BUFFER_FLAG_LAST", "1048576"), + ("GST_BUFFER_FLAG_LIVE", "16"), + ("GST_BUFFER_FLAG_MARKER", "512"), + ("GST_BUFFER_FLAG_NON_DROPPABLE", "65536"), + ("GST_BUFFER_FLAG_RESYNC", "128"), + ("GST_BUFFER_FLAG_SYNC_AFTER", "32768"), + ("GST_BUFFER_FLAG_TAG_MEMORY", "16384"), + ("GST_BUFFER_OFFSET_NONE", "18446744073709551615"), + ("GST_BUFFER_POOL_ACQUIRE_FLAG_DISCONT", "4"), + ("GST_BUFFER_POOL_ACQUIRE_FLAG_DONTWAIT", "2"), + ("GST_BUFFER_POOL_ACQUIRE_FLAG_KEY_UNIT", "1"), + ("GST_BUFFER_POOL_ACQUIRE_FLAG_LAST", "65536"), + ("GST_BUFFER_POOL_ACQUIRE_FLAG_NONE", "0"), + ("GST_BUS_ASYNC", "2"), + ("GST_BUS_DROP", "0"), + ("GST_BUS_FLAG_LAST", "32"), + ("GST_BUS_FLUSHING", "16"), + ("GST_BUS_PASS", "1"), + ("GST_CAN_INLINE", "1"), + ("GST_CAPS_FEATURE_MEMORY_SYSTEM_MEMORY", "memory:SystemMemory"), + ("GST_CAPS_FLAG_ANY", "16"), + ("GST_CAPS_INTERSECT_FIRST", "1"), + ("GST_CAPS_INTERSECT_ZIG_ZAG", "0"), + ("GST_CLOCK_BADTIME", "4"), + ("GST_CLOCK_BUSY", "3"), + ("GST_CLOCK_DONE", "7"), + ("GST_CLOCK_EARLY", "1"), + ("GST_CLOCK_ENTRY_PERIODIC", "1"), + ("GST_CLOCK_ENTRY_SINGLE", "0"), + ("GST_CLOCK_ERROR", "5"), + ("GST_CLOCK_FLAG_CAN_DO_PERIODIC_ASYNC", "128"), + ("GST_CLOCK_FLAG_CAN_DO_PERIODIC_SYNC", "64"), + ("GST_CLOCK_FLAG_CAN_DO_SINGLE_ASYNC", "32"), + ("GST_CLOCK_FLAG_CAN_DO_SINGLE_SYNC", "16"), + ("GST_CLOCK_FLAG_CAN_SET_MASTER", "512"), + ("GST_CLOCK_FLAG_CAN_SET_RESOLUTION", "256"), + ("GST_CLOCK_FLAG_LAST", "4096"), + ("GST_CLOCK_FLAG_NEEDS_STARTUP_SYNC", "1024"), + ("GST_CLOCK_OK", "0"), + ("GST_CLOCK_TIME_NONE", "18446744073709551615"), + ("GST_CLOCK_TYPE_MONOTONIC", "1"), + ("GST_CLOCK_TYPE_OTHER", "2"), + ("GST_CLOCK_TYPE_REALTIME", "0"), + ("GST_CLOCK_UNSCHEDULED", "2"), + ("GST_CLOCK_UNSUPPORTED", "6"), + ("GST_CORE_ERROR_CAPS", "10"), + ("GST_CORE_ERROR_CLOCK", "13"), + ("GST_CORE_ERROR_DISABLED", "14"), + ("GST_CORE_ERROR_EVENT", "8"), + ("GST_CORE_ERROR_FAILED", "1"), + ("GST_CORE_ERROR_MISSING_PLUGIN", "12"), + ("GST_CORE_ERROR_NEGOTIATION", "7"), + ("GST_CORE_ERROR_NOT_IMPLEMENTED", "3"), + ("GST_CORE_ERROR_NUM_ERRORS", "15"), + ("GST_CORE_ERROR_PAD", "5"), + ("GST_CORE_ERROR_SEEK", "9"), + ("GST_CORE_ERROR_STATE_CHANGE", "4"), + ("GST_CORE_ERROR_TAG", "11"), + ("GST_CORE_ERROR_THREAD", "6"), + ("GST_CORE_ERROR_TOO_LAZY", "2"), + ("GST_DEBUG_BG_BLACK", "0"), + ("GST_DEBUG_BG_BLUE", "64"), + ("GST_DEBUG_BG_CYAN", "96"), + ("GST_DEBUG_BG_GREEN", "32"), + ("GST_DEBUG_BG_MAGENTA", "80"), + ("GST_DEBUG_BG_MASK", "240"), + ("GST_DEBUG_BG_RED", "16"), + ("GST_DEBUG_BG_WHITE", "112"), + ("GST_DEBUG_BG_YELLOW", "48"), + ("GST_DEBUG_BOLD", "256"), + ("GST_DEBUG_COLOR_MODE_OFF", "0"), + ("GST_DEBUG_COLOR_MODE_ON", "1"), + ("GST_DEBUG_COLOR_MODE_UNIX", "2"), + ("GST_DEBUG_FG_BLACK", "0"), + ("GST_DEBUG_FG_BLUE", "4"), + ("GST_DEBUG_FG_CYAN", "6"), + ("GST_DEBUG_FG_GREEN", "2"), + ("GST_DEBUG_FG_MAGENTA", "5"), + ("GST_DEBUG_FG_MASK", "15"), + ("GST_DEBUG_FG_RED", "1"), + ("GST_DEBUG_FG_WHITE", "7"), + ("GST_DEBUG_FG_YELLOW", "3"), + ("GST_DEBUG_FORMAT_MASK", "65280"), + ("GST_DEBUG_GRAPH_SHOW_ALL", "15"), + ("GST_DEBUG_GRAPH_SHOW_CAPS_DETAILS", "2"), + ("GST_DEBUG_GRAPH_SHOW_FULL_PARAMS", "16"), + ("GST_DEBUG_GRAPH_SHOW_MEDIA_TYPE", "1"), + ("GST_DEBUG_GRAPH_SHOW_NON_DEFAULT_PARAMS", "4"), + ("GST_DEBUG_GRAPH_SHOW_STATES", "8"), + ("GST_DEBUG_GRAPH_SHOW_VERBOSE", "-1"), + ("GST_DEBUG_UNDERLINE", "512"), + ("GST_ELEMENT_FACTORY_KLASS_DECODER", "Decoder"), + ("GST_ELEMENT_FACTORY_KLASS_DECRYPTOR", "Decryptor"), + ("GST_ELEMENT_FACTORY_KLASS_DEMUXER", "Demuxer"), + ("GST_ELEMENT_FACTORY_KLASS_DEPAYLOADER", "Depayloader"), + ("GST_ELEMENT_FACTORY_KLASS_ENCODER", "Encoder"), + ("GST_ELEMENT_FACTORY_KLASS_ENCRYPTOR", "Encryptor"), + ("GST_ELEMENT_FACTORY_KLASS_FORMATTER", "Formatter"), + ("GST_ELEMENT_FACTORY_KLASS_MEDIA_AUDIO", "Audio"), + ("GST_ELEMENT_FACTORY_KLASS_MEDIA_IMAGE", "Image"), + ("GST_ELEMENT_FACTORY_KLASS_MEDIA_METADATA", "Metadata"), + ("GST_ELEMENT_FACTORY_KLASS_MEDIA_SUBTITLE", "Subtitle"), + ("GST_ELEMENT_FACTORY_KLASS_MEDIA_VIDEO", "Video"), + ("GST_ELEMENT_FACTORY_KLASS_MUXER", "Muxer"), + ("GST_ELEMENT_FACTORY_KLASS_PARSER", "Parser"), + ("GST_ELEMENT_FACTORY_KLASS_PAYLOADER", "Payloader"), + ("GST_ELEMENT_FACTORY_KLASS_SINK", "Sink"), + ("GST_ELEMENT_FACTORY_KLASS_SRC", "Source"), + ("GST_ELEMENT_FACTORY_TYPE_ANY", "562949953421311"), + ("GST_ELEMENT_FACTORY_TYPE_AUDIOVIDEO_SINKS", "3940649673949188"), + ("GST_ELEMENT_FACTORY_TYPE_AUDIO_ENCODER", "1125899906842626"), + ("GST_ELEMENT_FACTORY_TYPE_DECODABLE", "1377"), + ("GST_ELEMENT_FACTORY_TYPE_DECODER", "1"), + ("GST_ELEMENT_FACTORY_TYPE_DECRYPTOR", "1024"), + ("GST_ELEMENT_FACTORY_TYPE_DEMUXER", "32"), + ("GST_ELEMENT_FACTORY_TYPE_DEPAYLOADER", "256"), + ("GST_ELEMENT_FACTORY_TYPE_ENCODER", "2"), + ("GST_ELEMENT_FACTORY_TYPE_ENCRYPTOR", "2048"), + ("GST_ELEMENT_FACTORY_TYPE_FORMATTER", "512"), + ("GST_ELEMENT_FACTORY_TYPE_MAX_ELEMENTS", "281474976710656"), + ("GST_ELEMENT_FACTORY_TYPE_MEDIA_ANY", "18446462598732840960"), + ("GST_ELEMENT_FACTORY_TYPE_MEDIA_AUDIO", "1125899906842624"), + ("GST_ELEMENT_FACTORY_TYPE_MEDIA_IMAGE", "2251799813685248"), + ("GST_ELEMENT_FACTORY_TYPE_MEDIA_METADATA", "9007199254740992"), + ("GST_ELEMENT_FACTORY_TYPE_MEDIA_SUBTITLE", "4503599627370496"), + ("GST_ELEMENT_FACTORY_TYPE_MEDIA_VIDEO", "562949953421312"), + ("GST_ELEMENT_FACTORY_TYPE_MUXER", "16"), + ("GST_ELEMENT_FACTORY_TYPE_PARSER", "64"), + ("GST_ELEMENT_FACTORY_TYPE_PAYLOADER", "128"), + ("GST_ELEMENT_FACTORY_TYPE_SINK", "4"), + ("GST_ELEMENT_FACTORY_TYPE_SRC", "8"), + ("GST_ELEMENT_FACTORY_TYPE_VIDEO_ENCODER", "2814749767106562"), + ("GST_ELEMENT_FLAG_INDEXABLE", "512"), + ("GST_ELEMENT_FLAG_LAST", "16384"), + ("GST_ELEMENT_FLAG_LOCKED_STATE", "16"), + ("GST_ELEMENT_FLAG_PROVIDE_CLOCK", "128"), + ("GST_ELEMENT_FLAG_REQUIRE_CLOCK", "256"), + ("GST_ELEMENT_FLAG_SINK", "32"), + ("GST_ELEMENT_FLAG_SOURCE", "64"), + ("GST_ELEMENT_METADATA_AUTHOR", "author"), + ("GST_ELEMENT_METADATA_DESCRIPTION", "description"), + ("GST_ELEMENT_METADATA_DOC_URI", "doc-uri"), + ("GST_ELEMENT_METADATA_ICON_NAME", "icon-name"), + ("GST_ELEMENT_METADATA_KLASS", "klass"), + ("GST_ELEMENT_METADATA_LONGNAME", "long-name"), + ("GST_ERROR_SYSTEM", "system error: %s"), + ("GST_EVENT_BUFFERSIZE", "23054"), + ("GST_EVENT_CAPS", "12814"), + ("GST_EVENT_CUSTOM_BOTH", "79367"), + ("GST_EVENT_CUSTOM_BOTH_OOB", "81923"), + ("GST_EVENT_CUSTOM_DOWNSTREAM", "71686"), + ("GST_EVENT_CUSTOM_DOWNSTREAM_OOB", "74242"), + ("GST_EVENT_CUSTOM_DOWNSTREAM_STICKY", "76830"), + ("GST_EVENT_CUSTOM_UPSTREAM", "69121"), + ("GST_EVENT_EOS", "28174"), + ("GST_EVENT_FLUSH_START", "2563"), + ("GST_EVENT_FLUSH_STOP", "5127"), + ("GST_EVENT_GAP", "40966"), + ("GST_EVENT_LATENCY", "56321"), + ("GST_EVENT_NAVIGATION", "53761"), + ("GST_EVENT_NUM_SHIFT", "8"), + ("GST_EVENT_PROTECTION", "33310"), + ("GST_EVENT_QOS", "48641"), + ("GST_EVENT_RECONFIGURE", "61441"), + ("GST_EVENT_SEEK", "51201"), + ("GST_EVENT_SEGMENT", "17934"), + ("GST_EVENT_SEGMENT_DONE", "38406"), + ("GST_EVENT_SELECT_STREAMS", "66561"), + ("GST_EVENT_SINK_MESSAGE", "25630"), + ("GST_EVENT_STEP", "58881"), + ("GST_EVENT_STREAM_COLLECTION", "19230"), + ("GST_EVENT_STREAM_GROUP_DONE", "26894"), + ("GST_EVENT_STREAM_START", "10254"), + ("GST_EVENT_TAG", "20510"), + ("GST_EVENT_TOC", "30750"), + ("GST_EVENT_TOC_SELECT", "64001"), + ("GST_EVENT_TYPE_BOTH", "3"), + ("GST_EVENT_TYPE_DOWNSTREAM", "2"), + ("GST_EVENT_TYPE_SERIALIZED", "4"), + ("GST_EVENT_TYPE_STICKY", "8"), + ("GST_EVENT_TYPE_STICKY_MULTI", "16"), + ("GST_EVENT_TYPE_UPSTREAM", "1"), + ("GST_EVENT_UNKNOWN", "0"), + ("GST_FLAG_SET_MASK_EXACT", "4294967295"), + ("GST_FLOW_CUSTOM_ERROR", "-100"), + ("GST_FLOW_CUSTOM_ERROR_1", "-101"), + ("GST_FLOW_CUSTOM_ERROR_2", "-102"), + ("GST_FLOW_CUSTOM_SUCCESS", "100"), + ("GST_FLOW_CUSTOM_SUCCESS_1", "101"), + ("GST_FLOW_CUSTOM_SUCCESS_2", "102"), + ("GST_FLOW_EOS", "-3"), + ("GST_FLOW_ERROR", "-5"), + ("GST_FLOW_FLUSHING", "-2"), + ("GST_FLOW_NOT_LINKED", "-1"), + ("GST_FLOW_NOT_NEGOTIATED", "-4"), + ("GST_FLOW_NOT_SUPPORTED", "-6"), + ("GST_FLOW_OK", "0"), + ("GST_FORMAT_BUFFERS", "4"), + ("GST_FORMAT_BYTES", "2"), + ("GST_FORMAT_DEFAULT", "1"), + ("GST_FORMAT_PERCENT", "5"), + ("GST_FORMAT_PERCENT_MAX", "1000000"), + ("GST_FORMAT_PERCENT_SCALE", "10000"), + ("GST_FORMAT_TIME", "3"), + ("GST_FORMAT_UNDEFINED", "0"), + ("GST_FOURCC_FORMAT", "c%c%c%c"), + ("GST_GROUP_ID_INVALID", "0"), + ("GST_ITERATOR_DONE", "0"), + ("GST_ITERATOR_ERROR", "3"), + ("GST_ITERATOR_ITEM_END", "2"), + ("GST_ITERATOR_ITEM_PASS", "1"), + ("GST_ITERATOR_ITEM_SKIP", "0"), + ("GST_ITERATOR_OK", "1"), + ("GST_ITERATOR_RESYNC", "2"), + ("GST_LEVEL_COUNT", "10"), + ("GST_LEVEL_DEBUG", "5"), + ("GST_LEVEL_ERROR", "1"), + ("GST_LEVEL_FIXME", "3"), + ("GST_LEVEL_INFO", "4"), + ("GST_LEVEL_LOG", "6"), + ("GST_LEVEL_MEMDUMP", "9"), + ("GST_LEVEL_NONE", "0"), + ("GST_LEVEL_TRACE", "7"), + ("GST_LEVEL_WARNING", "2"), + ("GST_LIBRARY_ERROR_ENCODE", "6"), + ("GST_LIBRARY_ERROR_FAILED", "1"), + ("GST_LIBRARY_ERROR_INIT", "3"), + ("GST_LIBRARY_ERROR_NUM_ERRORS", "7"), + ("GST_LIBRARY_ERROR_SETTINGS", "5"), + ("GST_LIBRARY_ERROR_SHUTDOWN", "4"), + ("GST_LIBRARY_ERROR_TOO_LAZY", "2"), + ("GST_LICENSE_UNKNOWN", "unknown"), + ("GST_LOCK_FLAG_EXCLUSIVE", "4"), + ("GST_LOCK_FLAG_LAST", "256"), + ("GST_LOCK_FLAG_READ", "1"), + ("GST_LOCK_FLAG_READWRITE", "3"), + ("GST_LOCK_FLAG_WRITE", "2"), + ("GST_MAP_FLAG_LAST", "65536"), + ("GST_MAP_READ", "1"), + ("GST_MAP_READWRITE", "3"), + ("GST_MAP_WRITE", "2"), + ("GST_MEMORY_FLAG_LAST", "1048576"), + ("GST_MEMORY_FLAG_NOT_MAPPABLE", "256"), + ("GST_MEMORY_FLAG_NO_SHARE", "16"), + ("GST_MEMORY_FLAG_PHYSICALLY_CONTIGUOUS", "128"), + ("GST_MEMORY_FLAG_READONLY", "2"), + ("GST_MEMORY_FLAG_ZERO_PADDED", "64"), + ("GST_MEMORY_FLAG_ZERO_PREFIXED", "32"), + ("GST_MESSAGE_ANY", "4294967295"), + ("GST_MESSAGE_APPLICATION", "16384"), + ("GST_MESSAGE_ASYNC_DONE", "2097152"), + ("GST_MESSAGE_ASYNC_START", "1048576"), + ("GST_MESSAGE_BUFFERING", "32"), + ("GST_MESSAGE_CLOCK_LOST", "1024"), + ("GST_MESSAGE_CLOCK_PROVIDE", "512"), + ("GST_MESSAGE_DEVICE_ADDED", "2147483649"), + ("GST_MESSAGE_DEVICE_REMOVED", "2147483650"), + ("GST_MESSAGE_DURATION_CHANGED", "262144"), + ("GST_MESSAGE_ELEMENT", "32768"), + ("GST_MESSAGE_EOS", "1"), + ("GST_MESSAGE_ERROR", "2"), + ("GST_MESSAGE_EXTENDED", "2147483648"), + ("GST_MESSAGE_HAVE_CONTEXT", "1073741824"), + ("GST_MESSAGE_INFO", "8"), + ("GST_MESSAGE_LATENCY", "524288"), + ("GST_MESSAGE_NEED_CONTEXT", "536870912"), + ("GST_MESSAGE_NEW_CLOCK", "2048"), + ("GST_MESSAGE_PROGRESS", "33554432"), + ("GST_MESSAGE_PROPERTY_NOTIFY", "2147483651"), + ("GST_MESSAGE_QOS", "16777216"), + ("GST_MESSAGE_REDIRECT", "2147483654"), + ("GST_MESSAGE_REQUEST_STATE", "4194304"), + ("GST_MESSAGE_RESET_TIME", "134217728"), + ("GST_MESSAGE_SEGMENT_DONE", "131072"), + ("GST_MESSAGE_SEGMENT_START", "65536"), + ("GST_MESSAGE_STATE_CHANGED", "64"), + ("GST_MESSAGE_STATE_DIRTY", "128"), + ("GST_MESSAGE_STEP_DONE", "256"), + ("GST_MESSAGE_STEP_START", "8388608"), + ("GST_MESSAGE_STREAMS_SELECTED", "2147483653"), + ("GST_MESSAGE_STREAM_COLLECTION", "2147483652"), + ("GST_MESSAGE_STREAM_START", "268435456"), + ("GST_MESSAGE_STREAM_STATUS", "8192"), + ("GST_MESSAGE_STRUCTURE_CHANGE", "4096"), + ("GST_MESSAGE_TAG", "16"), + ("GST_MESSAGE_TOC", "67108864"), + ("GST_MESSAGE_UNKNOWN", "0"), + ("GST_MESSAGE_WARNING", "4"), + ("GST_META_FLAG_LAST", "65536"), + ("GST_META_FLAG_LOCKED", "4"), + ("GST_META_FLAG_NONE", "0"), + ("GST_META_FLAG_POOLED", "2"), + ("GST_META_FLAG_READONLY", "1"), + ("GST_META_TAG_MEMORY_STR", "memory"), + ("GST_MINI_OBJECT_FLAG_LAST", "16"), + ("GST_MINI_OBJECT_FLAG_LOCKABLE", "1"), + ("GST_MINI_OBJECT_FLAG_LOCK_READONLY", "2"), + ("GST_MINI_OBJECT_FLAG_MAY_BE_LEAKED", "4"), + ("GST_MSECOND", "1000000"), + ("GST_NSECOND", "1"), + ("GST_OBJECT_FLAG_LAST", "16"), + ("GST_OBJECT_FLAG_MAY_BE_LEAKED", "1"), + ("GST_PAD_ALWAYS", "0"), + ("GST_PAD_FLAG_ACCEPT_INTERSECT", "32768"), + ("GST_PAD_FLAG_ACCEPT_TEMPLATE", "65536"), + ("GST_PAD_FLAG_BLOCKED", "16"), + ("GST_PAD_FLAG_BLOCKING", "128"), + ("GST_PAD_FLAG_EOS", "64"), + ("GST_PAD_FLAG_FIXED_CAPS", "2048"), + ("GST_PAD_FLAG_FLUSHING", "32"), + ("GST_PAD_FLAG_LAST", "1048576"), + ("GST_PAD_FLAG_NEED_PARENT", "256"), + ("GST_PAD_FLAG_NEED_RECONFIGURE", "512"), + ("GST_PAD_FLAG_PENDING_EVENTS", "1024"), + ("GST_PAD_FLAG_PROXY_ALLOCATION", "8192"), + ("GST_PAD_FLAG_PROXY_CAPS", "4096"), + ("GST_PAD_FLAG_PROXY_SCHEDULING", "16384"), + ("GST_PAD_LINK_CHECK_CAPS", "4"), + ("GST_PAD_LINK_CHECK_DEFAULT", "5"), + ("GST_PAD_LINK_CHECK_HIERARCHY", "1"), + ("GST_PAD_LINK_CHECK_NOTHING", "0"), + ("GST_PAD_LINK_CHECK_NO_RECONFIGURE", "8"), + ("GST_PAD_LINK_CHECK_TEMPLATE_CAPS", "2"), + ("GST_PAD_LINK_NOFORMAT", "-4"), + ("GST_PAD_LINK_NOSCHED", "-5"), + ("GST_PAD_LINK_OK", "0"), + ("GST_PAD_LINK_REFUSED", "-6"), + ("GST_PAD_LINK_WAS_LINKED", "-2"), + ("GST_PAD_LINK_WRONG_DIRECTION", "-3"), + ("GST_PAD_LINK_WRONG_HIERARCHY", "-1"), + ("GST_PAD_MODE_NONE", "0"), + ("GST_PAD_MODE_PULL", "2"), + ("GST_PAD_MODE_PUSH", "1"), + ("GST_PAD_PROBE_DROP", "0"), + ("GST_PAD_PROBE_HANDLED", "4"), + ("GST_PAD_PROBE_OK", "1"), + ("GST_PAD_PROBE_PASS", "3"), + ("GST_PAD_PROBE_REMOVE", "2"), + ("GST_PAD_PROBE_TYPE_ALL_BOTH", "1776"), + ("GST_PAD_PROBE_TYPE_BLOCK", "2"), + ("GST_PAD_PROBE_TYPE_BLOCKING", "3"), + ("GST_PAD_PROBE_TYPE_BLOCK_DOWNSTREAM", "114"), + ("GST_PAD_PROBE_TYPE_BLOCK_UPSTREAM", "130"), + ("GST_PAD_PROBE_TYPE_BUFFER", "16"), + ("GST_PAD_PROBE_TYPE_BUFFER_LIST", "32"), + ("GST_PAD_PROBE_TYPE_DATA_BOTH", "240"), + ("GST_PAD_PROBE_TYPE_DATA_DOWNSTREAM", "112"), + ("GST_PAD_PROBE_TYPE_DATA_UPSTREAM", "128"), + ("GST_PAD_PROBE_TYPE_EVENT_BOTH", "192"), + ("GST_PAD_PROBE_TYPE_EVENT_DOWNSTREAM", "64"), + ("GST_PAD_PROBE_TYPE_EVENT_FLUSH", "256"), + ("GST_PAD_PROBE_TYPE_EVENT_UPSTREAM", "128"), + ("GST_PAD_PROBE_TYPE_IDLE", "1"), + ("GST_PAD_PROBE_TYPE_INVALID", "0"), + ("GST_PAD_PROBE_TYPE_PULL", "8192"), + ("GST_PAD_PROBE_TYPE_PUSH", "4096"), + ("GST_PAD_PROBE_TYPE_QUERY_BOTH", "1536"), + ("GST_PAD_PROBE_TYPE_QUERY_DOWNSTREAM", "512"), + ("GST_PAD_PROBE_TYPE_QUERY_UPSTREAM", "1024"), + ("GST_PAD_PROBE_TYPE_SCHEDULING", "12288"), + ("GST_PAD_REQUEST", "2"), + ("GST_PAD_SINK", "2"), + ("GST_PAD_SOMETIMES", "1"), + ("GST_PAD_SRC", "1"), + ("GST_PAD_TEMPLATE_FLAG_LAST", "256"), + ("GST_PAD_UNKNOWN", "0"), + ("GST_PARAM_CONTROLLABLE", "512"), + ("GST_PARAM_MUTABLE_PAUSED", "2048"), + ("GST_PARAM_MUTABLE_PLAYING", "4096"), + ("GST_PARAM_MUTABLE_READY", "1024"), + ("GST_PARAM_USER_SHIFT", "65536"), + ("GST_PARSE_ERROR_COULD_NOT_SET_PROPERTY", "4"), + ("GST_PARSE_ERROR_DELAYED_LINK", "7"), + ("GST_PARSE_ERROR_EMPTY", "6"), + ("GST_PARSE_ERROR_EMPTY_BIN", "5"), + ("GST_PARSE_ERROR_LINK", "3"), + ("GST_PARSE_ERROR_NO_SUCH_ELEMENT", "1"), + ("GST_PARSE_ERROR_NO_SUCH_PROPERTY", "2"), + ("GST_PARSE_ERROR_SYNTAX", "0"), + ("GST_PARSE_FLAG_FATAL_ERRORS", "1"), + ("GST_PARSE_FLAG_NONE", "0"), + ("GST_PARSE_FLAG_NO_SINGLE_ELEMENT_BINS", "2"), + ("GST_PARSE_FLAG_PLACE_IN_BIN", "4"), + ("GST_PIPELINE_FLAG_FIXED_CLOCK", "524288"), + ("GST_PIPELINE_FLAG_LAST", "8388608"), + ("GST_PLUGIN_DEPENDENCY_FLAG_FILE_NAME_IS_PREFIX", "8"), + ("GST_PLUGIN_DEPENDENCY_FLAG_FILE_NAME_IS_SUFFIX", "4"), + ("GST_PLUGIN_DEPENDENCY_FLAG_NONE", "0"), + ("GST_PLUGIN_DEPENDENCY_FLAG_PATHS_ARE_DEFAULT_ONLY", "2"), + ("GST_PLUGIN_DEPENDENCY_FLAG_PATHS_ARE_RELATIVE_TO_EXE", "16"), + ("GST_PLUGIN_DEPENDENCY_FLAG_RECURSE", "1"), + ("GST_PLUGIN_ERROR_DEPENDENCIES", "1"), + ("GST_PLUGIN_ERROR_MODULE", "0"), + ("GST_PLUGIN_ERROR_NAME_MISMATCH", "2"), + ("GST_PLUGIN_FLAG_BLACKLISTED", "32"), + ("GST_PLUGIN_FLAG_CACHED", "16"), + ("GST_PROGRESS_TYPE_CANCELED", "3"), + ("GST_PROGRESS_TYPE_COMPLETE", "2"), + ("GST_PROGRESS_TYPE_CONTINUE", "1"), + ("GST_PROGRESS_TYPE_ERROR", "4"), + ("GST_PROGRESS_TYPE_START", "0"), + ("GST_PROMISE_RESULT_EXPIRED", "3"), + ("GST_PROMISE_RESULT_INTERRUPTED", "1"), + ("GST_PROMISE_RESULT_PENDING", "0"), + ("GST_PROMISE_RESULT_REPLIED", "2"), + ("GST_PROTECTION_SYSTEM_ID_CAPS_FIELD", "protection-system"), + ("GST_PTR_FORMAT", "paA"), + ("GST_QOS_TYPE_OVERFLOW", "0"), + ("GST_QOS_TYPE_THROTTLE", "2"), + ("GST_QOS_TYPE_UNDERFLOW", "1"), + ("GST_QUERY_ACCEPT_CAPS", "40963"), + ("GST_QUERY_ALLOCATION", "35846"), + ("GST_QUERY_BUFFERING", "28163"), + ("GST_QUERY_CAPS", "43523"), + ("GST_QUERY_CONTEXT", "48643"), + ("GST_QUERY_CONVERT", "20483"), + ("GST_QUERY_CUSTOM", "30723"), + ("GST_QUERY_DRAIN", "46086"), + ("GST_QUERY_DURATION", "5123"), + ("GST_QUERY_FORMATS", "23043"), + ("GST_QUERY_JITTER", "10243"), + ("GST_QUERY_LATENCY", "7683"), + ("GST_QUERY_NUM_SHIFT", "8"), + ("GST_QUERY_POSITION", "2563"), + ("GST_QUERY_RATE", "12803"), + ("GST_QUERY_SCHEDULING", "38401"), + ("GST_QUERY_SEEKING", "15363"), + ("GST_QUERY_SEGMENT", "17923"), + ("GST_QUERY_TYPE_BOTH", "3"), + ("GST_QUERY_TYPE_DOWNSTREAM", "2"), + ("GST_QUERY_TYPE_SERIALIZED", "4"), + ("GST_QUERY_TYPE_UPSTREAM", "1"), + ("GST_QUERY_UNKNOWN", "0"), + ("GST_QUERY_URI", "33283"), + ("GST_RANK_MARGINAL", "64"), + ("GST_RANK_NONE", "0"), + ("GST_RANK_PRIMARY", "256"), + ("GST_RANK_SECONDARY", "128"), + ("GST_RESOURCE_ERROR_BUSY", "4"), + ("GST_RESOURCE_ERROR_CLOSE", "8"), + ("GST_RESOURCE_ERROR_FAILED", "1"), + ("GST_RESOURCE_ERROR_NOT_AUTHORIZED", "15"), + ("GST_RESOURCE_ERROR_NOT_FOUND", "3"), + ("GST_RESOURCE_ERROR_NO_SPACE_LEFT", "14"), + ("GST_RESOURCE_ERROR_NUM_ERRORS", "16"), + ("GST_RESOURCE_ERROR_OPEN_READ", "5"), + ("GST_RESOURCE_ERROR_OPEN_READ_WRITE", "7"), + ("GST_RESOURCE_ERROR_OPEN_WRITE", "6"), + ("GST_RESOURCE_ERROR_READ", "9"), + ("GST_RESOURCE_ERROR_SEEK", "11"), + ("GST_RESOURCE_ERROR_SETTINGS", "13"), + ("GST_RESOURCE_ERROR_SYNC", "12"), + ("GST_RESOURCE_ERROR_TOO_LAZY", "2"), + ("GST_RESOURCE_ERROR_WRITE", "10"), + ("GST_SCHEDULING_FLAG_BANDWIDTH_LIMITED", "4"), + ("GST_SCHEDULING_FLAG_SEEKABLE", "1"), + ("GST_SCHEDULING_FLAG_SEQUENTIAL", "2"), + ("GST_SEARCH_MODE_AFTER", "2"), + ("GST_SEARCH_MODE_BEFORE", "1"), + ("GST_SEARCH_MODE_EXACT", "0"), + ("GST_SECOND", "1000000000"), + ("GST_SEEK_FLAG_ACCURATE", "2"), + ("GST_SEEK_FLAG_FLUSH", "1"), + ("GST_SEEK_FLAG_KEY_UNIT", "4"), + ("GST_SEEK_FLAG_NONE", "0"), + ("GST_SEEK_FLAG_SEGMENT", "8"), + ("GST_SEEK_FLAG_SKIP", "16"), + ("GST_SEEK_FLAG_SNAP_AFTER", "64"), + ("GST_SEEK_FLAG_SNAP_BEFORE", "32"), + ("GST_SEEK_FLAG_SNAP_NEAREST", "96"), + ("GST_SEEK_FLAG_TRICKMODE", "16"), + ("GST_SEEK_FLAG_TRICKMODE_KEY_UNITS", "128"), + ("GST_SEEK_FLAG_TRICKMODE_NO_AUDIO", "256"), + ("GST_SEEK_TYPE_END", "2"), + ("GST_SEEK_TYPE_NONE", "0"), + ("GST_SEEK_TYPE_SET", "1"), + ("GST_SEGMENT_FLAG_NONE", "0"), + ("GST_SEGMENT_FLAG_RESET", "1"), + ("GST_SEGMENT_FLAG_SEGMENT", "8"), + ("GST_SEGMENT_FLAG_SKIP", "16"), + ("GST_SEGMENT_FLAG_TRICKMODE", "16"), + ("GST_SEGMENT_FLAG_TRICKMODE_KEY_UNITS", "128"), + ("GST_SEGMENT_FLAG_TRICKMODE_NO_AUDIO", "256"), + ("GST_SEGMENT_FORMAT", "paB"), + ("GST_SEQNUM_INVALID", "0"), + ("GST_STACK_TRACE_SHOW_FULL", "1"), + ("GST_STATE_CHANGE_ASYNC", "2"), + ("GST_STATE_CHANGE_FAILURE", "0"), + ("GST_STATE_CHANGE_NO_PREROLL", "3"), + ("GST_STATE_CHANGE_NULL_TO_NULL", "9"), + ("GST_STATE_CHANGE_NULL_TO_READY", "10"), + ("GST_STATE_CHANGE_PAUSED_TO_PAUSED", "27"), + ("GST_STATE_CHANGE_PAUSED_TO_PLAYING", "28"), + ("GST_STATE_CHANGE_PAUSED_TO_READY", "26"), + ("GST_STATE_CHANGE_PLAYING_TO_PAUSED", "35"), + ("GST_STATE_CHANGE_PLAYING_TO_PLAYING", "36"), + ("GST_STATE_CHANGE_READY_TO_NULL", "17"), + ("GST_STATE_CHANGE_READY_TO_PAUSED", "19"), + ("GST_STATE_CHANGE_READY_TO_READY", "18"), + ("GST_STATE_CHANGE_SUCCESS", "1"), + ("GST_STATE_NULL", "1"), + ("GST_STATE_PAUSED", "3"), + ("GST_STATE_PLAYING", "4"), + ("GST_STATE_READY", "2"), + ("GST_STATE_VOID_PENDING", "0"), + ("GST_STIME_FORMAT", "c%"), + ("GST_STREAM_ERROR_CODEC_NOT_FOUND", "6"), + ("GST_STREAM_ERROR_DECODE", "7"), + ("GST_STREAM_ERROR_DECRYPT", "12"), + ("GST_STREAM_ERROR_DECRYPT_NOKEY", "13"), + ("GST_STREAM_ERROR_DEMUX", "9"), + ("GST_STREAM_ERROR_ENCODE", "8"), + ("GST_STREAM_ERROR_FAILED", "1"), + ("GST_STREAM_ERROR_FORMAT", "11"), + ("GST_STREAM_ERROR_MUX", "10"), + ("GST_STREAM_ERROR_NOT_IMPLEMENTED", "3"), + ("GST_STREAM_ERROR_NUM_ERRORS", "14"), + ("GST_STREAM_ERROR_TOO_LAZY", "2"), + ("GST_STREAM_ERROR_TYPE_NOT_FOUND", "4"), + ("GST_STREAM_ERROR_WRONG_TYPE", "5"), + ("GST_STREAM_FLAG_NONE", "0"), + ("GST_STREAM_FLAG_SELECT", "2"), + ("GST_STREAM_FLAG_SPARSE", "1"), + ("GST_STREAM_FLAG_UNSELECT", "4"), + ("GST_STREAM_STATUS_TYPE_CREATE", "0"), + ("GST_STREAM_STATUS_TYPE_DESTROY", "3"), + ("GST_STREAM_STATUS_TYPE_ENTER", "1"), + ("GST_STREAM_STATUS_TYPE_LEAVE", "2"), + ("GST_STREAM_STATUS_TYPE_PAUSE", "9"), + ("GST_STREAM_STATUS_TYPE_START", "8"), + ("GST_STREAM_STATUS_TYPE_STOP", "10"), + ("GST_STREAM_TYPE_AUDIO", "2"), + ("GST_STREAM_TYPE_CONTAINER", "8"), + ("GST_STREAM_TYPE_TEXT", "16"), + ("GST_STREAM_TYPE_UNKNOWN", "1"), + ("GST_STREAM_TYPE_VIDEO", "4"), + ("GST_STRUCTURE_CHANGE_TYPE_PAD_LINK", "0"), + ("GST_STRUCTURE_CHANGE_TYPE_PAD_UNLINK", "1"), + ("GST_TAG_ALBUM", "album"), + ("GST_TAG_ALBUM_ARTIST", "album-artist"), + ("GST_TAG_ALBUM_ARTIST_SORTNAME", "album-artist-sortname"), + ("GST_TAG_ALBUM_GAIN", "replaygain-album-gain"), + ("GST_TAG_ALBUM_PEAK", "replaygain-album-peak"), + ("GST_TAG_ALBUM_SORTNAME", "album-sortname"), + ("GST_TAG_ALBUM_VOLUME_COUNT", "album-disc-count"), + ("GST_TAG_ALBUM_VOLUME_NUMBER", "album-disc-number"), + ("GST_TAG_APPLICATION_DATA", "application-data"), + ("GST_TAG_APPLICATION_NAME", "application-name"), + ("GST_TAG_ARTIST", "artist"), + ("GST_TAG_ARTIST_SORTNAME", "artist-sortname"), + ("GST_TAG_ATTACHMENT", "attachment"), + ("GST_TAG_AUDIO_CODEC", "audio-codec"), + ("GST_TAG_BEATS_PER_MINUTE", "beats-per-minute"), + ("GST_TAG_BITRATE", "bitrate"), + ("GST_TAG_CODEC", "codec"), + ("GST_TAG_COMMENT", "comment"), + ("GST_TAG_COMPOSER", "composer"), + ("GST_TAG_COMPOSER_SORTNAME", "composer-sortname"), + ("GST_TAG_CONDUCTOR", "conductor"), + ("GST_TAG_CONTACT", "contact"), + ("GST_TAG_CONTAINER_FORMAT", "container-format"), + ("GST_TAG_COPYRIGHT", "copyright"), + ("GST_TAG_COPYRIGHT_URI", "copyright-uri"), + ("GST_TAG_DATE", "date"), + ("GST_TAG_DATE_TIME", "datetime"), + ("GST_TAG_DESCRIPTION", "description"), + ("GST_TAG_DEVICE_MANUFACTURER", "device-manufacturer"), + ("GST_TAG_DEVICE_MODEL", "device-model"), + ("GST_TAG_DURATION", "duration"), + ("GST_TAG_ENCODED_BY", "encoded-by"), + ("GST_TAG_ENCODER", "encoder"), + ("GST_TAG_ENCODER_VERSION", "encoder-version"), + ("GST_TAG_EXTENDED_COMMENT", "extended-comment"), + ("GST_TAG_FLAG_COUNT", "4"), + ("GST_TAG_FLAG_DECODED", "3"), + ("GST_TAG_FLAG_ENCODED", "2"), + ("GST_TAG_FLAG_META", "1"), + ("GST_TAG_FLAG_UNDEFINED", "0"), + ("GST_TAG_GENRE", "genre"), + ("GST_TAG_GEO_LOCATION_CAPTURE_DIRECTION", "geo-location-capture-direction"), + ("GST_TAG_GEO_LOCATION_CITY", "geo-location-city"), + ("GST_TAG_GEO_LOCATION_COUNTRY", "geo-location-country"), + ("GST_TAG_GEO_LOCATION_ELEVATION", "geo-location-elevation"), + ("GST_TAG_GEO_LOCATION_HORIZONTAL_ERROR", "geo-location-horizontal-error"), + ("GST_TAG_GEO_LOCATION_LATITUDE", "geo-location-latitude"), + ("GST_TAG_GEO_LOCATION_LONGITUDE", "geo-location-longitude"), + ("GST_TAG_GEO_LOCATION_MOVEMENT_DIRECTION", "geo-location-movement-direction"), + ("GST_TAG_GEO_LOCATION_MOVEMENT_SPEED", "geo-location-movement-speed"), + ("GST_TAG_GEO_LOCATION_NAME", "geo-location-name"), + ("GST_TAG_GEO_LOCATION_SUBLOCATION", "geo-location-sublocation"), + ("GST_TAG_GROUPING", "grouping"), + ("GST_TAG_HOMEPAGE", "homepage"), + ("GST_TAG_IMAGE", "image"), + ("GST_TAG_IMAGE_ORIENTATION", "image-orientation"), + ("GST_TAG_INTERPRETED_BY", "interpreted-by"), + ("GST_TAG_ISRC", "isrc"), + ("GST_TAG_KEYWORDS", "keywords"), + ("GST_TAG_LANGUAGE_CODE", "language-code"), + ("GST_TAG_LANGUAGE_NAME", "language-name"), + ("GST_TAG_LICENSE", "license"), + ("GST_TAG_LICENSE_URI", "license-uri"), + ("GST_TAG_LOCATION", "location"), + ("GST_TAG_LYRICS", "lyrics"), + ("GST_TAG_MAXIMUM_BITRATE", "maximum-bitrate"), + ("GST_TAG_MERGE_APPEND", "3"), + ("GST_TAG_MERGE_COUNT", "7"), + ("GST_TAG_MERGE_KEEP", "5"), + ("GST_TAG_MERGE_KEEP_ALL", "6"), + ("GST_TAG_MERGE_PREPEND", "4"), + ("GST_TAG_MERGE_REPLACE", "2"), + ("GST_TAG_MERGE_REPLACE_ALL", "1"), + ("GST_TAG_MERGE_UNDEFINED", "0"), + ("GST_TAG_MIDI_BASE_NOTE", "midi-base-note"), + ("GST_TAG_MINIMUM_BITRATE", "minimum-bitrate"), + ("GST_TAG_NOMINAL_BITRATE", "nominal-bitrate"), + ("GST_TAG_ORGANIZATION", "organization"), + ("GST_TAG_PERFORMER", "performer"), + ("GST_TAG_PREVIEW_IMAGE", "preview-image"), + ("GST_TAG_PRIVATE_DATA", "private-data"), + ("GST_TAG_PUBLISHER", "publisher"), + ("GST_TAG_REFERENCE_LEVEL", "replaygain-reference-level"), + ("GST_TAG_SCOPE_GLOBAL", "1"), + ("GST_TAG_SCOPE_STREAM", "0"), + ("GST_TAG_SERIAL", "serial"), + ("GST_TAG_SHOW_EPISODE_NUMBER", "show-episode-number"), + ("GST_TAG_SHOW_NAME", "show-name"), + ("GST_TAG_SHOW_SEASON_NUMBER", "show-season-number"), + ("GST_TAG_SHOW_SORTNAME", "show-sortname"), + ("GST_TAG_SUBTITLE_CODEC", "subtitle-codec"), + ("GST_TAG_TITLE", "title"), + ("GST_TAG_TITLE_SORTNAME", "title-sortname"), + ("GST_TAG_TRACK_COUNT", "track-count"), + ("GST_TAG_TRACK_GAIN", "replaygain-track-gain"), + ("GST_TAG_TRACK_NUMBER", "track-number"), + ("GST_TAG_TRACK_PEAK", "replaygain-track-peak"), + ("GST_TAG_USER_RATING", "user-rating"), + ("GST_TAG_VERSION", "version"), + ("GST_TAG_VIDEO_CODEC", "video-codec"), + ("GST_TASK_PAUSED", "2"), + ("GST_TASK_STARTED", "0"), + ("GST_TASK_STOPPED", "1"), + ("GST_TIME_FORMAT", "u:%02u:%02u.%09u"), + ("GST_TOC_ENTRY_TYPE_ANGLE", "-3"), + ("GST_TOC_ENTRY_TYPE_CHAPTER", "3"), + ("GST_TOC_ENTRY_TYPE_EDITION", "-1"), + ("GST_TOC_ENTRY_TYPE_INVALID", "0"), + ("GST_TOC_ENTRY_TYPE_TITLE", "1"), + ("GST_TOC_ENTRY_TYPE_TRACK", "2"), + ("GST_TOC_ENTRY_TYPE_VERSION", "-2"), + ("GST_TOC_LOOP_FORWARD", "1"), + ("GST_TOC_LOOP_NONE", "0"), + ("GST_TOC_LOOP_PING_PONG", "3"), + ("GST_TOC_LOOP_REVERSE", "2"), + ("GST_TOC_REPEAT_COUNT_INFINITE", "-1"), + ("GST_TOC_SCOPE_CURRENT", "2"), + ("GST_TOC_SCOPE_GLOBAL", "1"), + ("GST_TRACER_VALUE_FLAGS_AGGREGATED", "2"), + ("GST_TRACER_VALUE_FLAGS_NONE", "0"), + ("GST_TRACER_VALUE_FLAGS_OPTIONAL", "1"), + ("GST_TRACER_VALUE_SCOPE_ELEMENT", "2"), + ("GST_TRACER_VALUE_SCOPE_PAD", "3"), + ("GST_TRACER_VALUE_SCOPE_PROCESS", "0"), + ("GST_TRACER_VALUE_SCOPE_THREAD", "1"), + ("GST_TYPE_FIND_LIKELY", "80"), + ("GST_TYPE_FIND_MAXIMUM", "100"), + ("GST_TYPE_FIND_MINIMUM", "1"), + ("GST_TYPE_FIND_NEARLY_CERTAIN", "99"), + ("GST_TYPE_FIND_NONE", "0"), + ("GST_TYPE_FIND_POSSIBLE", "50"), + ("GST_URI_ERROR_BAD_REFERENCE", "3"), + ("GST_URI_ERROR_BAD_STATE", "2"), + ("GST_URI_ERROR_BAD_URI", "1"), + ("GST_URI_ERROR_UNSUPPORTED_PROTOCOL", "0"), + ("GST_URI_NO_PORT", "0"), + ("GST_URI_SINK", "1"), + ("GST_URI_SRC", "2"), + ("GST_URI_UNKNOWN", "0"), + ("GST_USECOND", "1000"), + ("GST_VALUE_EQUAL", "0"), + ("GST_VALUE_GREATER_THAN", "1"), + ("GST_VALUE_LESS_THAN", "-1"), + ("GST_VALUE_UNORDERED", "2"), + ("GST_VERSION_MAJOR", "1"), + ("GST_VERSION_MICRO", "0"), + ("GST_VERSION_MINOR", "14"), + ("GST_VERSION_NANO", "0"), +]; + + diff --git a/gstreamer-sys/tests/constant.c b/gstreamer-sys/tests/constant.c new file mode 100644 index 000000000..f95b609c2 --- /dev/null +++ b/gstreamer-sys/tests/constant.c @@ -0,0 +1,27 @@ +// This file was generated by gir (https://github.com/gtk-rs/gir @ 6855214) +// from gir-files (https://github.com/gtk-rs/gir-files @ ???) +// DO NOT EDIT + +#include "manual.h" +#include + +int main() { + printf(_Generic((ABI_CONSTANT_NAME), + char *: "%s", + const char *: "%s", + char: "%c", + signed char: "%hhd", + unsigned char: "%hhu", + short int: "%hd", + unsigned short int: "%hu", + int: "%d", + unsigned int: "%u", + long: "%ld", + unsigned long: "%lu", + long long: "%lld", + unsigned long long: "%llu", + double: "%f", + long double: "%ld"), + ABI_CONSTANT_NAME); + return 0; +} diff --git a/gstreamer-sys/tests/layout.c b/gstreamer-sys/tests/layout.c new file mode 100644 index 000000000..e4be962df --- /dev/null +++ b/gstreamer-sys/tests/layout.c @@ -0,0 +1,12 @@ +// This file was generated by gir (https://github.com/gtk-rs/gir @ 6855214) +// from gir-files (https://github.com/gtk-rs/gir-files @ ???) +// 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-sys/tests/manual.h b/gstreamer-sys/tests/manual.h new file mode 100644 index 000000000..ed4ee6d1c --- /dev/null +++ b/gstreamer-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 diff --git a/gstreamer-tag-sys/Cargo.toml b/gstreamer-tag-sys/Cargo.toml index f0d314703..0090e7b9b 100644 --- a/gstreamer-tag-sys/Cargo.toml +++ b/gstreamer-tag-sys/Cargo.toml @@ -2,7 +2,6 @@ pkg-config = "0.3.7" [dependencies] -bitflags = "1.0" libc = "0.2" glib-sys = { git = "https://github.com/gtk-rs/sys" } gobject-sys = { git = "https://github.com/gtk-rs/sys" } @@ -12,6 +11,10 @@ path = "../gstreamer-sys" [dependencies.gstreamer-base-sys] path = "../gstreamer-base-sys" +[dev-dependencies] +shell-words = "0.1.0" +tempdir = "0.3" + [features] v1_2 = [] v1_4 = ["v1_2"] diff --git a/gstreamer-tag-sys/src/lib.rs b/gstreamer-tag-sys/src/lib.rs index cb43fc071..c6e664e6d 100644 --- a/gstreamer-tag-sys/src/lib.rs +++ b/gstreamer-tag-sys/src/lib.rs @@ -1,11 +1,10 @@ -// This file was generated by gir (https://github.com/gtk-rs/gir @ fe7a6ff) +// This file was generated by gir (https://github.com/gtk-rs/gir @ 6855214) // 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)] extern crate libc; -#[macro_use] extern crate bitflags; extern crate glib_sys as glib; extern crate gobject_sys as gobject; extern crate gstreamer_sys as gst; @@ -85,39 +84,21 @@ pub const GST_TAG_MUSICBRAINZ_TRACKID: *const c_char = b"musicbrainz-trackid\0" pub const GST_TAG_MUSICBRAINZ_TRMID: *const c_char = b"musicbrainz-trmid\0" as *const u8 as *const c_char; // Flags -bitflags! { - #[repr(C)] - pub struct GstTagLicenseFlags: c_uint { - const PERMITS_REPRODUCTION = 1; - const PERMITS_DISTRIBUTION = 2; - const PERMITS_DERIVATIVE_WORKS = 4; - const PERMITS_SHARING = 8; - const REQUIRES_NOTICE = 256; - const REQUIRES_ATTRIBUTION = 512; - const REQUIRES_SHARE_ALIKE = 1024; - const REQUIRES_SOURCE_CODE = 2048; - const REQUIRES_COPYLEFT = 4096; - const REQUIRES_LESSER_COPYLEFT = 8192; - const PROHIBITS_COMMERCIAL_USE = 65536; - const PROHIBITS_HIGH_INCOME_NATION_USE = 131072; - const CREATIVE_COMMONS_LICENSE = 16777216; - const FREE_SOFTWARE_FOUNDATION_LICENSE = 33554432; - } -} -pub const GST_TAG_LICENSE_PERMITS_REPRODUCTION: GstTagLicenseFlags = GstTagLicenseFlags::PERMITS_REPRODUCTION; -pub const GST_TAG_LICENSE_PERMITS_DISTRIBUTION: GstTagLicenseFlags = GstTagLicenseFlags::PERMITS_DISTRIBUTION; -pub const GST_TAG_LICENSE_PERMITS_DERIVATIVE_WORKS: GstTagLicenseFlags = GstTagLicenseFlags::PERMITS_DERIVATIVE_WORKS; -pub const GST_TAG_LICENSE_PERMITS_SHARING: GstTagLicenseFlags = GstTagLicenseFlags::PERMITS_SHARING; -pub const GST_TAG_LICENSE_REQUIRES_NOTICE: GstTagLicenseFlags = GstTagLicenseFlags::REQUIRES_NOTICE; -pub const GST_TAG_LICENSE_REQUIRES_ATTRIBUTION: GstTagLicenseFlags = GstTagLicenseFlags::REQUIRES_ATTRIBUTION; -pub const GST_TAG_LICENSE_REQUIRES_SHARE_ALIKE: GstTagLicenseFlags = GstTagLicenseFlags::REQUIRES_SHARE_ALIKE; -pub const GST_TAG_LICENSE_REQUIRES_SOURCE_CODE: GstTagLicenseFlags = GstTagLicenseFlags::REQUIRES_SOURCE_CODE; -pub const GST_TAG_LICENSE_REQUIRES_COPYLEFT: GstTagLicenseFlags = GstTagLicenseFlags::REQUIRES_COPYLEFT; -pub const GST_TAG_LICENSE_REQUIRES_LESSER_COPYLEFT: GstTagLicenseFlags = GstTagLicenseFlags::REQUIRES_LESSER_COPYLEFT; -pub const GST_TAG_LICENSE_PROHIBITS_COMMERCIAL_USE: GstTagLicenseFlags = GstTagLicenseFlags::PROHIBITS_COMMERCIAL_USE; -pub const GST_TAG_LICENSE_PROHIBITS_HIGH_INCOME_NATION_USE: GstTagLicenseFlags = GstTagLicenseFlags::PROHIBITS_HIGH_INCOME_NATION_USE; -pub const GST_TAG_LICENSE_CREATIVE_COMMONS_LICENSE: GstTagLicenseFlags = GstTagLicenseFlags::CREATIVE_COMMONS_LICENSE; -pub const GST_TAG_LICENSE_FREE_SOFTWARE_FOUNDATION_LICENSE: GstTagLicenseFlags = GstTagLicenseFlags::FREE_SOFTWARE_FOUNDATION_LICENSE; +pub type GstTagLicenseFlags = c_uint; +pub const GST_TAG_LICENSE_PERMITS_REPRODUCTION: GstTagLicenseFlags = 1; +pub const GST_TAG_LICENSE_PERMITS_DISTRIBUTION: GstTagLicenseFlags = 2; +pub const GST_TAG_LICENSE_PERMITS_DERIVATIVE_WORKS: GstTagLicenseFlags = 4; +pub const GST_TAG_LICENSE_PERMITS_SHARING: GstTagLicenseFlags = 8; +pub const GST_TAG_LICENSE_REQUIRES_NOTICE: GstTagLicenseFlags = 256; +pub const GST_TAG_LICENSE_REQUIRES_ATTRIBUTION: GstTagLicenseFlags = 512; +pub const GST_TAG_LICENSE_REQUIRES_SHARE_ALIKE: GstTagLicenseFlags = 1024; +pub const GST_TAG_LICENSE_REQUIRES_SOURCE_CODE: GstTagLicenseFlags = 2048; +pub const GST_TAG_LICENSE_REQUIRES_COPYLEFT: GstTagLicenseFlags = 4096; +pub const GST_TAG_LICENSE_REQUIRES_LESSER_COPYLEFT: GstTagLicenseFlags = 8192; +pub const GST_TAG_LICENSE_PROHIBITS_COMMERCIAL_USE: GstTagLicenseFlags = 65536; +pub const GST_TAG_LICENSE_PROHIBITS_HIGH_INCOME_NATION_USE: GstTagLicenseFlags = 131072; +pub const GST_TAG_LICENSE_CREATIVE_COMMONS_LICENSE: GstTagLicenseFlags = 16777216; +pub const GST_TAG_LICENSE_FREE_SOFTWARE_FOUNDATION_LICENSE: GstTagLicenseFlags = 33554432; // Records #[repr(C)] diff --git a/gstreamer-tag-sys/tests/abi.rs b/gstreamer-tag-sys/tests/abi.rs new file mode 100644 index 000000000..c001711d4 --- /dev/null +++ b/gstreamer-tag-sys/tests/abi.rs @@ -0,0 +1,319 @@ +// This file was generated by gir (https://github.com/gtk-rs/gir @ 6855214) +// from gir-files (https://github.com/gtk-rs/gir-files @ ???) +// DO NOT EDIT + +extern crate gstreamer_tag_sys; +extern crate shell_words; +extern crate tempdir; +use std::env; +use std::error::Error; +use std::path::Path; +use std::mem::{align_of, size_of}; +use std::process::Command; +use std::str; +use gstreamer_tag_sys::*; + +static PACKAGES: &[&str] = &["gstreamer-tag-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 = tempdir::TempDir::new("abi").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 = tempdir::TempDir::new("abi").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()); + } + + Ok(str::from_utf8(&output.stdout)?.trim().to_owned()) +} + +const RUST_LAYOUTS: &[(&str, Layout)] = &[ + ("GstTagDemux", Layout {size: size_of::(), alignment: align_of::()}), + ("GstTagDemuxClass", Layout {size: size_of::(), alignment: align_of::()}), + ("GstTagDemuxResult", Layout {size: size_of::(), alignment: align_of::()}), + ("GstTagImageType", Layout {size: size_of::(), alignment: align_of::()}), + ("GstTagLicenseFlags", Layout {size: size_of::(), alignment: align_of::()}), + ("GstTagMux", Layout {size: size_of::(), alignment: align_of::()}), + ("GstTagMuxClass", Layout {size: size_of::(), alignment: align_of::()}), + ("GstTagXmpWriterInterface", Layout {size: size_of::(), alignment: align_of::()}), +]; + +const RUST_CONSTANTS: &[(&str, &str)] = &[ + ("GST_TAG_CAPTURING_CONTRAST", "capturing-contrast"), + ("GST_TAG_CAPTURING_DIGITAL_ZOOM_RATIO", "capturing-digital-zoom-ratio"), + ("GST_TAG_CAPTURING_EXPOSURE_COMPENSATION", "capturing-exposure-compensation"), + ("GST_TAG_CAPTURING_EXPOSURE_MODE", "capturing-exposure-mode"), + ("GST_TAG_CAPTURING_EXPOSURE_PROGRAM", "capturing-exposure-program"), + ("GST_TAG_CAPTURING_FLASH_FIRED", "capturing-flash-fired"), + ("GST_TAG_CAPTURING_FLASH_MODE", "capturing-flash-mode"), + ("GST_TAG_CAPTURING_FOCAL_LENGTH", "capturing-focal-length"), + ("GST_TAG_CAPTURING_FOCAL_LENGTH_35_MM", "capturing-focal-length-35mm"), + ("GST_TAG_CAPTURING_FOCAL_RATIO", "capturing-focal-ratio"), + ("GST_TAG_CAPTURING_GAIN_ADJUSTMENT", "capturing-gain-adjustment"), + ("GST_TAG_CAPTURING_ISO_SPEED", "capturing-iso-speed"), + ("GST_TAG_CAPTURING_METERING_MODE", "capturing-metering-mode"), + ("GST_TAG_CAPTURING_SATURATION", "capturing-saturation"), + ("GST_TAG_CAPTURING_SCENE_CAPTURE_TYPE", "capturing-scene-capture-type"), + ("GST_TAG_CAPTURING_SHARPNESS", "capturing-sharpness"), + ("GST_TAG_CAPTURING_SHUTTER_SPEED", "capturing-shutter-speed"), + ("GST_TAG_CAPTURING_SOURCE", "capturing-source"), + ("GST_TAG_CAPTURING_WHITE_BALANCE", "capturing-white-balance"), + ("GST_TAG_CDDA_CDDB_DISCID", "discid"), + ("GST_TAG_CDDA_CDDB_DISCID_FULL", "discid-full"), + ("GST_TAG_CDDA_MUSICBRAINZ_DISCID", "musicbrainz-discid"), + ("GST_TAG_CDDA_MUSICBRAINZ_DISCID_FULL", "musicbrainz-discid-full"), + ("GST_TAG_CMML_CLIP", "cmml-clip"), + ("GST_TAG_CMML_HEAD", "cmml-head"), + ("GST_TAG_CMML_STREAM", "cmml-stream"), + ("GST_TAG_DEMUX_RESULT_AGAIN", "1"), + ("GST_TAG_DEMUX_RESULT_BROKEN_TAG", "0"), + ("GST_TAG_DEMUX_RESULT_OK", "2"), + ("GST_TAG_ID3V2_HEADER_SIZE", "10"), + ("GST_TAG_IMAGE_HORIZONTAL_PPI", "image-horizontal-ppi"), + ("GST_TAG_IMAGE_TYPE_ARTIST", "6"), + ("GST_TAG_IMAGE_TYPE_BACK_COVER", "2"), + ("GST_TAG_IMAGE_TYPE_BAND_ARTIST_LOGO", "17"), + ("GST_TAG_IMAGE_TYPE_BAND_ORCHESTRA", "8"), + ("GST_TAG_IMAGE_TYPE_COMPOSER", "9"), + ("GST_TAG_IMAGE_TYPE_CONDUCTOR", "7"), + ("GST_TAG_IMAGE_TYPE_DURING_PERFORMANCE", "13"), + ("GST_TAG_IMAGE_TYPE_DURING_RECORDING", "12"), + ("GST_TAG_IMAGE_TYPE_FISH", "15"), + ("GST_TAG_IMAGE_TYPE_FRONT_COVER", "1"), + ("GST_TAG_IMAGE_TYPE_ILLUSTRATION", "16"), + ("GST_TAG_IMAGE_TYPE_LEAD_ARTIST", "5"), + ("GST_TAG_IMAGE_TYPE_LEAFLET_PAGE", "3"), + ("GST_TAG_IMAGE_TYPE_LYRICIST", "10"), + ("GST_TAG_IMAGE_TYPE_MEDIUM", "4"), + ("GST_TAG_IMAGE_TYPE_NONE", "-1"), + ("GST_TAG_IMAGE_TYPE_PUBLISHER_STUDIO_LOGO", "18"), + ("GST_TAG_IMAGE_TYPE_RECORDING_LOCATION", "11"), + ("GST_TAG_IMAGE_TYPE_UNDEFINED", "0"), + ("GST_TAG_IMAGE_TYPE_VIDEO_CAPTURE", "14"), + ("GST_TAG_IMAGE_VERTICAL_PPI", "image-vertical-ppi"), + ("GST_TAG_LICENSE_CREATIVE_COMMONS_LICENSE", "16777216"), + ("GST_TAG_LICENSE_FREE_SOFTWARE_FOUNDATION_LICENSE", "33554432"), + ("GST_TAG_LICENSE_PERMITS_DERIVATIVE_WORKS", "4"), + ("GST_TAG_LICENSE_PERMITS_DISTRIBUTION", "2"), + ("GST_TAG_LICENSE_PERMITS_REPRODUCTION", "1"), + ("GST_TAG_LICENSE_PERMITS_SHARING", "8"), + ("GST_TAG_LICENSE_PROHIBITS_COMMERCIAL_USE", "65536"), + ("GST_TAG_LICENSE_PROHIBITS_HIGH_INCOME_NATION_USE", "131072"), + ("GST_TAG_LICENSE_REQUIRES_ATTRIBUTION", "512"), + ("GST_TAG_LICENSE_REQUIRES_COPYLEFT", "4096"), + ("GST_TAG_LICENSE_REQUIRES_LESSER_COPYLEFT", "8192"), + ("GST_TAG_LICENSE_REQUIRES_NOTICE", "256"), + ("GST_TAG_LICENSE_REQUIRES_SHARE_ALIKE", "1024"), + ("GST_TAG_LICENSE_REQUIRES_SOURCE_CODE", "2048"), + ("GST_TAG_MUSICAL_KEY", "musical-key"), + ("GST_TAG_MUSICBRAINZ_ALBUMARTISTID", "musicbrainz-albumartistid"), + ("GST_TAG_MUSICBRAINZ_ALBUMID", "musicbrainz-albumid"), + ("GST_TAG_MUSICBRAINZ_ARTISTID", "musicbrainz-artistid"), + ("GST_TAG_MUSICBRAINZ_TRACKID", "musicbrainz-trackid"), + ("GST_TAG_MUSICBRAINZ_TRMID", "musicbrainz-trmid"), +]; + + diff --git a/gstreamer-tag-sys/tests/constant.c b/gstreamer-tag-sys/tests/constant.c new file mode 100644 index 000000000..f95b609c2 --- /dev/null +++ b/gstreamer-tag-sys/tests/constant.c @@ -0,0 +1,27 @@ +// This file was generated by gir (https://github.com/gtk-rs/gir @ 6855214) +// from gir-files (https://github.com/gtk-rs/gir-files @ ???) +// DO NOT EDIT + +#include "manual.h" +#include + +int main() { + printf(_Generic((ABI_CONSTANT_NAME), + char *: "%s", + const char *: "%s", + char: "%c", + signed char: "%hhd", + unsigned char: "%hhu", + short int: "%hd", + unsigned short int: "%hu", + int: "%d", + unsigned int: "%u", + long: "%ld", + unsigned long: "%lu", + long long: "%lld", + unsigned long long: "%llu", + double: "%f", + long double: "%ld"), + ABI_CONSTANT_NAME); + return 0; +} diff --git a/gstreamer-tag-sys/tests/layout.c b/gstreamer-tag-sys/tests/layout.c new file mode 100644 index 000000000..e4be962df --- /dev/null +++ b/gstreamer-tag-sys/tests/layout.c @@ -0,0 +1,12 @@ +// This file was generated by gir (https://github.com/gtk-rs/gir @ 6855214) +// from gir-files (https://github.com/gtk-rs/gir-files @ ???) +// 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-tag-sys/tests/manual.h b/gstreamer-tag-sys/tests/manual.h new file mode 100644 index 000000000..0b0cb9401 --- /dev/null +++ b/gstreamer-tag-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 diff --git a/gstreamer-video-sys/Cargo.toml b/gstreamer-video-sys/Cargo.toml index 78231074f..a71cd3043 100644 --- a/gstreamer-video-sys/Cargo.toml +++ b/gstreamer-video-sys/Cargo.toml @@ -2,7 +2,6 @@ pkg-config = "0.3.7" [dependencies] -bitflags = "1.0" libc = "0.2" glib-sys = { git = "https://github.com/gtk-rs/sys" } gobject-sys = { git = "https://github.com/gtk-rs/sys" } @@ -13,6 +12,10 @@ path = "../gstreamer-sys" [dependencies.gstreamer-base-sys] path = "../gstreamer-base-sys" +[dev-dependencies] +shell-words = "0.1.0" +tempdir = "0.3" + [features] v1_0_3 = [] v1_2 = ["v1_0_3"] diff --git a/gstreamer-video-sys/src/lib.rs b/gstreamer-video-sys/src/lib.rs index ec2533eb2..aab229c49 100644 --- a/gstreamer-video-sys/src/lib.rs +++ b/gstreamer-video-sys/src/lib.rs @@ -1,11 +1,10 @@ -// This file was generated by gir (https://github.com/gtk-rs/gir @ fe7a6ff) +// This file was generated by gir (https://github.com/gtk-rs/gir @ 6855214) // 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)] extern crate libc; -#[macro_use] extern crate bitflags; extern crate glib_sys as glib; extern crate gobject_sys as gobject; extern crate gstreamer_sys as gst; @@ -374,223 +373,103 @@ pub const GST_VIDEO_RESAMPLER_OPT_SHARPEN: *const c_char = b"GstVideoResampler.s pub const GST_VIDEO_RESAMPLER_OPT_SHARPNESS: *const c_char = b"GstVideoResampler.sharpness\0" as *const u8 as *const c_char; pub const GST_VIDEO_SCALER_OPT_DITHER_METHOD: *const c_char = b"GstVideoScaler.dither-method\0" as *const u8 as *const c_char; pub const GST_VIDEO_SIZE_RANGE: *const c_char = b"(int) [ 1, max ]\0" as *const u8 as *const c_char; -pub const GST_VIDEO_TILE_TYPE_MASK: c_int = 0; +pub const GST_VIDEO_TILE_TYPE_MASK: c_int = 65535; pub const GST_VIDEO_TILE_TYPE_SHIFT: c_int = 16; -pub const GST_VIDEO_TILE_X_TILES_MASK: c_int = 0; +pub const GST_VIDEO_TILE_X_TILES_MASK: c_int = 65535; pub const GST_VIDEO_TILE_Y_TILES_SHIFT: c_int = 16; // Flags -bitflags! { - #[repr(C)] - pub struct GstVideoBufferFlags: c_uint { - const INTERLACED = 1048576; - const TFF = 2097152; - const RFF = 4194304; - const ONEFIELD = 8388608; - const MULTIPLE_VIEW = 16777216; - const FIRST_IN_BUNDLE = 33554432; - const LAST = 268435456; - } -} -pub const GST_VIDEO_BUFFER_FLAG_INTERLACED: GstVideoBufferFlags = GstVideoBufferFlags::INTERLACED; -pub const GST_VIDEO_BUFFER_FLAG_TFF: GstVideoBufferFlags = GstVideoBufferFlags::TFF; -pub const GST_VIDEO_BUFFER_FLAG_RFF: GstVideoBufferFlags = GstVideoBufferFlags::RFF; -pub const GST_VIDEO_BUFFER_FLAG_ONEFIELD: GstVideoBufferFlags = GstVideoBufferFlags::ONEFIELD; -pub const GST_VIDEO_BUFFER_FLAG_MULTIPLE_VIEW: GstVideoBufferFlags = GstVideoBufferFlags::MULTIPLE_VIEW; -pub const GST_VIDEO_BUFFER_FLAG_FIRST_IN_BUNDLE: GstVideoBufferFlags = GstVideoBufferFlags::FIRST_IN_BUNDLE; -pub const GST_VIDEO_BUFFER_FLAG_LAST: GstVideoBufferFlags = GstVideoBufferFlags::LAST; +pub type GstVideoBufferFlags = c_uint; +pub const GST_VIDEO_BUFFER_FLAG_INTERLACED: GstVideoBufferFlags = 1048576; +pub const GST_VIDEO_BUFFER_FLAG_TFF: GstVideoBufferFlags = 2097152; +pub const GST_VIDEO_BUFFER_FLAG_RFF: GstVideoBufferFlags = 4194304; +pub const GST_VIDEO_BUFFER_FLAG_ONEFIELD: GstVideoBufferFlags = 8388608; +pub const GST_VIDEO_BUFFER_FLAG_MULTIPLE_VIEW: GstVideoBufferFlags = 16777216; +pub const GST_VIDEO_BUFFER_FLAG_FIRST_IN_BUNDLE: GstVideoBufferFlags = 33554432; +pub const GST_VIDEO_BUFFER_FLAG_LAST: GstVideoBufferFlags = 268435456; -bitflags! { - #[repr(C)] - pub struct GstVideoChromaFlags: c_uint { - const NONE = 0; - const INTERLACED = 1; - } -} -pub const GST_VIDEO_CHROMA_FLAG_NONE: GstVideoChromaFlags = GstVideoChromaFlags::NONE; -pub const GST_VIDEO_CHROMA_FLAG_INTERLACED: GstVideoChromaFlags = GstVideoChromaFlags::INTERLACED; +pub type GstVideoChromaFlags = c_uint; +pub const GST_VIDEO_CHROMA_FLAG_NONE: GstVideoChromaFlags = 0; +pub const GST_VIDEO_CHROMA_FLAG_INTERLACED: GstVideoChromaFlags = 1; -bitflags! { - #[repr(C)] - pub struct GstVideoChromaSite: c_uint { - const UNKNOWN = 0; - const NONE = 1; - const H_COSITED = 2; - const V_COSITED = 4; - const ALT_LINE = 8; - const COSITED = 6; - const JPEG = 1; - const MPEG2 = 2; - const DV = 14; - } -} -pub const GST_VIDEO_CHROMA_SITE_UNKNOWN: GstVideoChromaSite = GstVideoChromaSite::UNKNOWN; -pub const GST_VIDEO_CHROMA_SITE_NONE: GstVideoChromaSite = GstVideoChromaSite::JPEG; -pub const GST_VIDEO_CHROMA_SITE_H_COSITED: GstVideoChromaSite = GstVideoChromaSite::MPEG2; -pub const GST_VIDEO_CHROMA_SITE_V_COSITED: GstVideoChromaSite = GstVideoChromaSite::V_COSITED; -pub const GST_VIDEO_CHROMA_SITE_ALT_LINE: GstVideoChromaSite = GstVideoChromaSite::ALT_LINE; -pub const GST_VIDEO_CHROMA_SITE_COSITED: GstVideoChromaSite = GstVideoChromaSite::COSITED; -pub const GST_VIDEO_CHROMA_SITE_JPEG: GstVideoChromaSite = GstVideoChromaSite::JPEG; -pub const GST_VIDEO_CHROMA_SITE_MPEG2: GstVideoChromaSite = GstVideoChromaSite::MPEG2; -pub const GST_VIDEO_CHROMA_SITE_DV: GstVideoChromaSite = GstVideoChromaSite::DV; +pub type GstVideoChromaSite = c_uint; +pub const GST_VIDEO_CHROMA_SITE_UNKNOWN: GstVideoChromaSite = 0; +pub const GST_VIDEO_CHROMA_SITE_NONE: GstVideoChromaSite = 1; +pub const GST_VIDEO_CHROMA_SITE_H_COSITED: GstVideoChromaSite = 2; +pub const GST_VIDEO_CHROMA_SITE_V_COSITED: GstVideoChromaSite = 4; +pub const GST_VIDEO_CHROMA_SITE_ALT_LINE: GstVideoChromaSite = 8; +pub const GST_VIDEO_CHROMA_SITE_COSITED: GstVideoChromaSite = 6; +pub const GST_VIDEO_CHROMA_SITE_JPEG: GstVideoChromaSite = 1; +pub const GST_VIDEO_CHROMA_SITE_MPEG2: GstVideoChromaSite = 2; +pub const GST_VIDEO_CHROMA_SITE_DV: GstVideoChromaSite = 14; -bitflags! { - #[repr(C)] - pub struct GstVideoCodecFrameFlags: c_uint { - const DECODE_ONLY = 1; - const SYNC_POINT = 2; - const FORCE_KEYFRAME = 4; - const FORCE_KEYFRAME_HEADERS = 8; - } -} -pub const GST_VIDEO_CODEC_FRAME_FLAG_DECODE_ONLY: GstVideoCodecFrameFlags = GstVideoCodecFrameFlags::DECODE_ONLY; -pub const GST_VIDEO_CODEC_FRAME_FLAG_SYNC_POINT: GstVideoCodecFrameFlags = GstVideoCodecFrameFlags::SYNC_POINT; -pub const GST_VIDEO_CODEC_FRAME_FLAG_FORCE_KEYFRAME: GstVideoCodecFrameFlags = GstVideoCodecFrameFlags::FORCE_KEYFRAME; -pub const GST_VIDEO_CODEC_FRAME_FLAG_FORCE_KEYFRAME_HEADERS: GstVideoCodecFrameFlags = GstVideoCodecFrameFlags::FORCE_KEYFRAME_HEADERS; +pub type GstVideoCodecFrameFlags = c_uint; +pub const GST_VIDEO_CODEC_FRAME_FLAG_DECODE_ONLY: GstVideoCodecFrameFlags = 1; +pub const GST_VIDEO_CODEC_FRAME_FLAG_SYNC_POINT: GstVideoCodecFrameFlags = 2; +pub const GST_VIDEO_CODEC_FRAME_FLAG_FORCE_KEYFRAME: GstVideoCodecFrameFlags = 4; +pub const GST_VIDEO_CODEC_FRAME_FLAG_FORCE_KEYFRAME_HEADERS: GstVideoCodecFrameFlags = 8; -bitflags! { - #[repr(C)] - pub struct GstVideoDitherFlags: c_uint { - const NONE = 0; - const INTERLACED = 1; - const QUANTIZE = 2; - } -} -pub const GST_VIDEO_DITHER_FLAG_NONE: GstVideoDitherFlags = GstVideoDitherFlags::NONE; -pub const GST_VIDEO_DITHER_FLAG_INTERLACED: GstVideoDitherFlags = GstVideoDitherFlags::INTERLACED; -pub const GST_VIDEO_DITHER_FLAG_QUANTIZE: GstVideoDitherFlags = GstVideoDitherFlags::QUANTIZE; +pub type GstVideoDitherFlags = c_uint; +pub const GST_VIDEO_DITHER_FLAG_NONE: GstVideoDitherFlags = 0; +pub const GST_VIDEO_DITHER_FLAG_INTERLACED: GstVideoDitherFlags = 1; +pub const GST_VIDEO_DITHER_FLAG_QUANTIZE: GstVideoDitherFlags = 2; -bitflags! { - #[repr(C)] - pub struct GstVideoFlags: c_uint { - const NONE = 0; - const VARIABLE_FPS = 1; - const PREMULTIPLIED_ALPHA = 2; - } -} -pub const GST_VIDEO_FLAG_NONE: GstVideoFlags = GstVideoFlags::NONE; -pub const GST_VIDEO_FLAG_VARIABLE_FPS: GstVideoFlags = GstVideoFlags::VARIABLE_FPS; -pub const GST_VIDEO_FLAG_PREMULTIPLIED_ALPHA: GstVideoFlags = GstVideoFlags::PREMULTIPLIED_ALPHA; +pub type GstVideoFlags = c_uint; +pub const GST_VIDEO_FLAG_NONE: GstVideoFlags = 0; +pub const GST_VIDEO_FLAG_VARIABLE_FPS: GstVideoFlags = 1; +pub const GST_VIDEO_FLAG_PREMULTIPLIED_ALPHA: GstVideoFlags = 2; -bitflags! { - #[repr(C)] - pub struct GstVideoFormatFlags: c_uint { - const YUV = 1; - const RGB = 2; - const GRAY = 4; - const ALPHA = 8; - const LE = 16; - const PALETTE = 32; - const COMPLEX = 64; - const UNPACK = 128; - const TILED = 256; - } -} -pub const GST_VIDEO_FORMAT_FLAG_YUV: GstVideoFormatFlags = GstVideoFormatFlags::YUV; -pub const GST_VIDEO_FORMAT_FLAG_RGB: GstVideoFormatFlags = GstVideoFormatFlags::RGB; -pub const GST_VIDEO_FORMAT_FLAG_GRAY: GstVideoFormatFlags = GstVideoFormatFlags::GRAY; -pub const GST_VIDEO_FORMAT_FLAG_ALPHA: GstVideoFormatFlags = GstVideoFormatFlags::ALPHA; -pub const GST_VIDEO_FORMAT_FLAG_LE: GstVideoFormatFlags = GstVideoFormatFlags::LE; -pub const GST_VIDEO_FORMAT_FLAG_PALETTE: GstVideoFormatFlags = GstVideoFormatFlags::PALETTE; -pub const GST_VIDEO_FORMAT_FLAG_COMPLEX: GstVideoFormatFlags = GstVideoFormatFlags::COMPLEX; -pub const GST_VIDEO_FORMAT_FLAG_UNPACK: GstVideoFormatFlags = GstVideoFormatFlags::UNPACK; -pub const GST_VIDEO_FORMAT_FLAG_TILED: GstVideoFormatFlags = GstVideoFormatFlags::TILED; +pub type GstVideoFormatFlags = c_uint; +pub const GST_VIDEO_FORMAT_FLAG_YUV: GstVideoFormatFlags = 1; +pub const GST_VIDEO_FORMAT_FLAG_RGB: GstVideoFormatFlags = 2; +pub const GST_VIDEO_FORMAT_FLAG_GRAY: GstVideoFormatFlags = 4; +pub const GST_VIDEO_FORMAT_FLAG_ALPHA: GstVideoFormatFlags = 8; +pub const GST_VIDEO_FORMAT_FLAG_LE: GstVideoFormatFlags = 16; +pub const GST_VIDEO_FORMAT_FLAG_PALETTE: GstVideoFormatFlags = 32; +pub const GST_VIDEO_FORMAT_FLAG_COMPLEX: GstVideoFormatFlags = 64; +pub const GST_VIDEO_FORMAT_FLAG_UNPACK: GstVideoFormatFlags = 128; +pub const GST_VIDEO_FORMAT_FLAG_TILED: GstVideoFormatFlags = 256; -bitflags! { - #[repr(C)] - pub struct GstVideoFrameFlags: c_uint { - const NONE = 0; - const INTERLACED = 1; - const TFF = 2; - const RFF = 4; - const ONEFIELD = 8; - const MULTIPLE_VIEW = 16; - const FIRST_IN_BUNDLE = 32; - } -} -pub const GST_VIDEO_FRAME_FLAG_NONE: GstVideoFrameFlags = GstVideoFrameFlags::NONE; -pub const GST_VIDEO_FRAME_FLAG_INTERLACED: GstVideoFrameFlags = GstVideoFrameFlags::INTERLACED; -pub const GST_VIDEO_FRAME_FLAG_TFF: GstVideoFrameFlags = GstVideoFrameFlags::TFF; -pub const GST_VIDEO_FRAME_FLAG_RFF: GstVideoFrameFlags = GstVideoFrameFlags::RFF; -pub const GST_VIDEO_FRAME_FLAG_ONEFIELD: GstVideoFrameFlags = GstVideoFrameFlags::ONEFIELD; -pub const GST_VIDEO_FRAME_FLAG_MULTIPLE_VIEW: GstVideoFrameFlags = GstVideoFrameFlags::MULTIPLE_VIEW; -pub const GST_VIDEO_FRAME_FLAG_FIRST_IN_BUNDLE: GstVideoFrameFlags = GstVideoFrameFlags::FIRST_IN_BUNDLE; +pub type GstVideoFrameFlags = c_uint; +pub const GST_VIDEO_FRAME_FLAG_NONE: GstVideoFrameFlags = 0; +pub const GST_VIDEO_FRAME_FLAG_INTERLACED: GstVideoFrameFlags = 1; +pub const GST_VIDEO_FRAME_FLAG_TFF: GstVideoFrameFlags = 2; +pub const GST_VIDEO_FRAME_FLAG_RFF: GstVideoFrameFlags = 4; +pub const GST_VIDEO_FRAME_FLAG_ONEFIELD: GstVideoFrameFlags = 8; +pub const GST_VIDEO_FRAME_FLAG_MULTIPLE_VIEW: GstVideoFrameFlags = 16; +pub const GST_VIDEO_FRAME_FLAG_FIRST_IN_BUNDLE: GstVideoFrameFlags = 32; -bitflags! { - #[repr(C)] - pub struct GstVideoFrameMapFlags: c_uint { - const NO_REF = 65536; - const LAST = 16777216; - } -} -pub const GST_VIDEO_FRAME_MAP_FLAG_NO_REF: GstVideoFrameMapFlags = GstVideoFrameMapFlags::NO_REF; -pub const GST_VIDEO_FRAME_MAP_FLAG_LAST: GstVideoFrameMapFlags = GstVideoFrameMapFlags::LAST; +pub type GstVideoFrameMapFlags = c_uint; +pub const GST_VIDEO_FRAME_MAP_FLAG_NO_REF: GstVideoFrameMapFlags = 65536; +pub const GST_VIDEO_FRAME_MAP_FLAG_LAST: GstVideoFrameMapFlags = 16777216; -bitflags! { - #[repr(C)] - pub struct GstVideoMultiviewFlags: c_uint { - const NONE = 0; - const RIGHT_VIEW_FIRST = 1; - const LEFT_FLIPPED = 2; - const LEFT_FLOPPED = 4; - const RIGHT_FLIPPED = 8; - const RIGHT_FLOPPED = 16; - const HALF_ASPECT = 16384; - const MIXED_MONO = 32768; - } -} -pub const GST_VIDEO_MULTIVIEW_FLAGS_NONE: GstVideoMultiviewFlags = GstVideoMultiviewFlags::NONE; -pub const GST_VIDEO_MULTIVIEW_FLAGS_RIGHT_VIEW_FIRST: GstVideoMultiviewFlags = GstVideoMultiviewFlags::RIGHT_VIEW_FIRST; -pub const GST_VIDEO_MULTIVIEW_FLAGS_LEFT_FLIPPED: GstVideoMultiviewFlags = GstVideoMultiviewFlags::LEFT_FLIPPED; -pub const GST_VIDEO_MULTIVIEW_FLAGS_LEFT_FLOPPED: GstVideoMultiviewFlags = GstVideoMultiviewFlags::LEFT_FLOPPED; -pub const GST_VIDEO_MULTIVIEW_FLAGS_RIGHT_FLIPPED: GstVideoMultiviewFlags = GstVideoMultiviewFlags::RIGHT_FLIPPED; -pub const GST_VIDEO_MULTIVIEW_FLAGS_RIGHT_FLOPPED: GstVideoMultiviewFlags = GstVideoMultiviewFlags::RIGHT_FLOPPED; -pub const GST_VIDEO_MULTIVIEW_FLAGS_HALF_ASPECT: GstVideoMultiviewFlags = GstVideoMultiviewFlags::HALF_ASPECT; -pub const GST_VIDEO_MULTIVIEW_FLAGS_MIXED_MONO: GstVideoMultiviewFlags = GstVideoMultiviewFlags::MIXED_MONO; +pub type GstVideoMultiviewFlags = c_uint; +pub const GST_VIDEO_MULTIVIEW_FLAGS_NONE: GstVideoMultiviewFlags = 0; +pub const GST_VIDEO_MULTIVIEW_FLAGS_RIGHT_VIEW_FIRST: GstVideoMultiviewFlags = 1; +pub const GST_VIDEO_MULTIVIEW_FLAGS_LEFT_FLIPPED: GstVideoMultiviewFlags = 2; +pub const GST_VIDEO_MULTIVIEW_FLAGS_LEFT_FLOPPED: GstVideoMultiviewFlags = 4; +pub const GST_VIDEO_MULTIVIEW_FLAGS_RIGHT_FLIPPED: GstVideoMultiviewFlags = 8; +pub const GST_VIDEO_MULTIVIEW_FLAGS_RIGHT_FLOPPED: GstVideoMultiviewFlags = 16; +pub const GST_VIDEO_MULTIVIEW_FLAGS_HALF_ASPECT: GstVideoMultiviewFlags = 16384; +pub const GST_VIDEO_MULTIVIEW_FLAGS_MIXED_MONO: GstVideoMultiviewFlags = 32768; -bitflags! { - #[repr(C)] - pub struct GstVideoPackFlags: c_uint { - const NONE = 0; - const TRUNCATE_RANGE = 1; - const INTERLACED = 2; - } -} -pub const GST_VIDEO_PACK_FLAG_NONE: GstVideoPackFlags = GstVideoPackFlags::NONE; -pub const GST_VIDEO_PACK_FLAG_TRUNCATE_RANGE: GstVideoPackFlags = GstVideoPackFlags::TRUNCATE_RANGE; -pub const GST_VIDEO_PACK_FLAG_INTERLACED: GstVideoPackFlags = GstVideoPackFlags::INTERLACED; +pub type GstVideoPackFlags = c_uint; +pub const GST_VIDEO_PACK_FLAG_NONE: GstVideoPackFlags = 0; +pub const GST_VIDEO_PACK_FLAG_TRUNCATE_RANGE: GstVideoPackFlags = 1; +pub const GST_VIDEO_PACK_FLAG_INTERLACED: GstVideoPackFlags = 2; -bitflags! { - #[repr(C)] - pub struct GstVideoResamplerFlags: c_uint { - const NONE = 0; - const HALF_TAPS = 1; - } -} -pub const GST_VIDEO_RESAMPLER_FLAG_NONE: GstVideoResamplerFlags = GstVideoResamplerFlags::NONE; -pub const GST_VIDEO_RESAMPLER_FLAG_HALF_TAPS: GstVideoResamplerFlags = GstVideoResamplerFlags::HALF_TAPS; +pub type GstVideoResamplerFlags = c_uint; +pub const GST_VIDEO_RESAMPLER_FLAG_NONE: GstVideoResamplerFlags = 0; +pub const GST_VIDEO_RESAMPLER_FLAG_HALF_TAPS: GstVideoResamplerFlags = 1; -bitflags! { - #[repr(C)] - pub struct GstVideoScalerFlags: c_uint { - const NONE = 0; - const INTERLACED = 1; - } -} -pub const GST_VIDEO_SCALER_FLAG_NONE: GstVideoScalerFlags = GstVideoScalerFlags::NONE; -pub const GST_VIDEO_SCALER_FLAG_INTERLACED: GstVideoScalerFlags = GstVideoScalerFlags::INTERLACED; +pub type GstVideoScalerFlags = c_uint; +pub const GST_VIDEO_SCALER_FLAG_NONE: GstVideoScalerFlags = 0; +pub const GST_VIDEO_SCALER_FLAG_INTERLACED: GstVideoScalerFlags = 1; -bitflags! { - #[repr(C)] - pub struct GstVideoTimeCodeFlags: c_uint { - const NONE = 0; - const DROP_FRAME = 1; - const INTERLACED = 2; - } -} -pub const GST_VIDEO_TIME_CODE_FLAGS_NONE: GstVideoTimeCodeFlags = GstVideoTimeCodeFlags::NONE; -pub const GST_VIDEO_TIME_CODE_FLAGS_DROP_FRAME: GstVideoTimeCodeFlags = GstVideoTimeCodeFlags::DROP_FRAME; -pub const GST_VIDEO_TIME_CODE_FLAGS_INTERLACED: GstVideoTimeCodeFlags = GstVideoTimeCodeFlags::INTERLACED; +pub type GstVideoTimeCodeFlags = c_uint; +pub const GST_VIDEO_TIME_CODE_FLAGS_NONE: GstVideoTimeCodeFlags = 0; +pub const GST_VIDEO_TIME_CODE_FLAGS_DROP_FRAME: GstVideoTimeCodeFlags = 1; +pub const GST_VIDEO_TIME_CODE_FLAGS_INTERLACED: GstVideoTimeCodeFlags = 2; // Unions #[repr(C)] diff --git a/gstreamer-video-sys/tests/abi.rs b/gstreamer-video-sys/tests/abi.rs new file mode 100644 index 000000000..36823829b --- /dev/null +++ b/gstreamer-video-sys/tests/abi.rs @@ -0,0 +1,683 @@ +// This file was generated by gir (https://github.com/gtk-rs/gir @ 6855214) +// from gir-files (https://github.com/gtk-rs/gir-files @ ???) +// DO NOT EDIT + +extern crate gstreamer_video_sys; +extern crate shell_words; +extern crate tempdir; +use std::env; +use std::error::Error; +use std::path::Path; +use std::mem::{align_of, size_of}; +use std::process::Command; +use std::str; +use gstreamer_video_sys::*; + +static PACKAGES: &[&str] = &["gstreamer-video-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 = tempdir::TempDir::new("abi").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 = tempdir::TempDir::new("abi").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()); + } + + Ok(str::from_utf8(&output.stdout)?.trim().to_owned()) +} + +const RUST_LAYOUTS: &[(&str, Layout)] = &[ + ("GstColorBalanceChannel", Layout {size: size_of::(), alignment: align_of::()}), + ("GstColorBalanceChannelClass", Layout {size: size_of::(), alignment: align_of::()}), + ("GstColorBalanceInterface", Layout {size: size_of::(), alignment: align_of::()}), + ("GstColorBalanceType", Layout {size: size_of::(), alignment: align_of::()}), + ("GstNavigationCommand", Layout {size: size_of::(), alignment: align_of::()}), + ("GstNavigationEventType", Layout {size: size_of::(), alignment: align_of::()}), + ("GstNavigationInterface", Layout {size: size_of::(), alignment: align_of::()}), + ("GstNavigationMessageType", Layout {size: size_of::(), alignment: align_of::()}), + ("GstNavigationQueryType", Layout {size: size_of::(), alignment: align_of::()}), + ("GstVideoAffineTransformationMeta", Layout {size: size_of::(), alignment: align_of::()}), + ("GstVideoAlignment", Layout {size: size_of::(), alignment: align_of::()}), + ("GstVideoAlphaMode", Layout {size: size_of::(), alignment: align_of::()}), + ("GstVideoBufferFlags", Layout {size: size_of::(), alignment: align_of::()}), + ("GstVideoBufferPool", Layout {size: size_of::(), alignment: align_of::()}), + ("GstVideoBufferPoolClass", Layout {size: size_of::(), alignment: align_of::()}), + ("GstVideoChromaFlags", Layout {size: size_of::(), alignment: align_of::()}), + ("GstVideoChromaMethod", Layout {size: size_of::(), alignment: align_of::()}), + ("GstVideoChromaMode", Layout {size: size_of::(), alignment: align_of::()}), + ("GstVideoChromaSite", Layout {size: size_of::(), alignment: align_of::()}), + ("GstVideoCodecFrame", Layout {size: size_of::(), alignment: align_of::()}), + ("GstVideoCodecFrameFlags", Layout {size: size_of::(), alignment: align_of::()}), + ("GstVideoCodecState", Layout {size: size_of::(), alignment: align_of::()}), + ("GstVideoColorMatrix", Layout {size: size_of::(), alignment: align_of::()}), + ("GstVideoColorPrimaries", Layout {size: size_of::(), alignment: align_of::()}), + ("GstVideoColorPrimariesInfo", Layout {size: size_of::(), alignment: align_of::()}), + ("GstVideoColorRange", Layout {size: size_of::(), alignment: align_of::()}), + ("GstVideoColorimetry", Layout {size: size_of::(), alignment: align_of::()}), + ("GstVideoCropMeta", Layout {size: size_of::(), alignment: align_of::()}), + ("GstVideoDecoder", Layout {size: size_of::(), alignment: align_of::()}), + ("GstVideoDecoderClass", Layout {size: size_of::(), alignment: align_of::()}), + ("GstVideoDirectionInterface", Layout {size: size_of::(), alignment: align_of::()}), + ("GstVideoDitherFlags", Layout {size: size_of::(), alignment: align_of::()}), + ("GstVideoDitherMethod", Layout {size: size_of::(), alignment: align_of::()}), + ("GstVideoEncoder", Layout {size: size_of::(), alignment: align_of::()}), + ("GstVideoEncoderClass", Layout {size: size_of::(), alignment: align_of::()}), + ("GstVideoFieldOrder", Layout {size: size_of::(), alignment: align_of::()}), + ("GstVideoFilter", Layout {size: size_of::(), alignment: align_of::()}), + ("GstVideoFilterClass", Layout {size: size_of::(), alignment: align_of::()}), + ("GstVideoFlags", Layout {size: size_of::(), alignment: align_of::()}), + ("GstVideoFormat", Layout {size: size_of::(), alignment: align_of::()}), + ("GstVideoFormatFlags", Layout {size: size_of::(), alignment: align_of::()}), + ("GstVideoFormatInfo", Layout {size: size_of::(), alignment: align_of::()}), + ("GstVideoFrame", Layout {size: size_of::(), alignment: align_of::()}), + ("GstVideoFrameFlags", Layout {size: size_of::(), alignment: align_of::()}), + ("GstVideoFrameMapFlags", Layout {size: size_of::(), alignment: align_of::()}), + ("GstVideoGLTextureOrientation", Layout {size: size_of::(), alignment: align_of::()}), + ("GstVideoGLTextureType", Layout {size: size_of::(), alignment: align_of::()}), + ("GstVideoGLTextureUploadMeta", Layout {size: size_of::(), alignment: align_of::()}), + ("GstVideoGammaMode", Layout {size: size_of::(), alignment: align_of::()}), + ("GstVideoInfo", Layout {size: size_of::(), alignment: align_of::()}), + ("GstVideoInterlaceMode", Layout {size: size_of::(), alignment: align_of::()}), + ("GstVideoMatrixMode", Layout {size: size_of::(), alignment: align_of::()}), + ("GstVideoMeta", Layout {size: size_of::(), alignment: align_of::()}), + ("GstVideoMetaTransform", Layout {size: size_of::(), alignment: align_of::()}), + ("GstVideoMultiviewFlags", Layout {size: size_of::(), alignment: align_of::()}), + ("GstVideoMultiviewFramePacking", Layout {size: size_of::(), alignment: align_of::()}), + ("GstVideoMultiviewMode", Layout {size: size_of::(), alignment: align_of::()}), + ("GstVideoOrientationInterface", Layout {size: size_of::(), alignment: align_of::()}), + ("GstVideoOrientationMethod", Layout {size: size_of::(), alignment: align_of::()}), + ("GstVideoOverlayCompositionMeta", Layout {size: size_of::(), alignment: align_of::()}), + ("GstVideoOverlayFormatFlags", Layout {size: size_of::(), alignment: align_of::()}), + ("GstVideoOverlayInterface", Layout {size: size_of::(), alignment: align_of::()}), + ("GstVideoPackFlags", Layout {size: size_of::(), alignment: align_of::()}), + ("GstVideoPrimariesMode", Layout {size: size_of::(), alignment: align_of::()}), + ("GstVideoRectangle", Layout {size: size_of::(), alignment: align_of::()}), + ("GstVideoRegionOfInterestMeta", Layout {size: size_of::(), alignment: align_of::()}), + ("GstVideoResampler", Layout {size: size_of::(), alignment: align_of::()}), + ("GstVideoResamplerFlags", Layout {size: size_of::(), alignment: align_of::()}), + ("GstVideoResamplerMethod", Layout {size: size_of::(), alignment: align_of::()}), + ("GstVideoScalerFlags", Layout {size: size_of::(), alignment: align_of::()}), + ("GstVideoSink", Layout {size: size_of::(), alignment: align_of::()}), + ("GstVideoSinkClass", Layout {size: size_of::(), alignment: align_of::()}), + ("GstVideoTileMode", Layout {size: size_of::(), alignment: align_of::()}), + ("GstVideoTileType", Layout {size: size_of::(), alignment: align_of::()}), + ("GstVideoTimeCode", Layout {size: size_of::(), alignment: align_of::()}), + ("GstVideoTimeCodeConfig", Layout {size: size_of::(), alignment: align_of::()}), + ("GstVideoTimeCodeFlags", Layout {size: size_of::(), alignment: align_of::()}), + ("GstVideoTimeCodeInterval", Layout {size: size_of::(), alignment: align_of::()}), + ("GstVideoTimeCodeMeta", Layout {size: size_of::(), alignment: align_of::()}), + ("GstVideoTransferFunction", Layout {size: size_of::(), alignment: align_of::()}), +]; + +const RUST_CONSTANTS: &[(&str, &str)] = &[ + ("GST_BUFFER_POOL_OPTION_VIDEO_AFFINE_TRANSFORMATION_META", "GstBufferPoolOptionVideoAffineTransformation"), + ("GST_BUFFER_POOL_OPTION_VIDEO_ALIGNMENT", "GstBufferPoolOptionVideoAlignment"), + ("GST_BUFFER_POOL_OPTION_VIDEO_GL_TEXTURE_UPLOAD_META", "GstBufferPoolOptionVideoGLTextureUploadMeta"), + ("GST_BUFFER_POOL_OPTION_VIDEO_META", "GstBufferPoolOptionVideoMeta"), + ("GST_CAPS_FEATURE_META_GST_VIDEO_AFFINE_TRANSFORMATION_META", "meta:GstVideoAffineTransformation"), + ("GST_CAPS_FEATURE_META_GST_VIDEO_GL_TEXTURE_UPLOAD_META", "meta:GstVideoGLTextureUploadMeta"), + ("GST_CAPS_FEATURE_META_GST_VIDEO_META", "meta:GstVideoMeta"), + ("GST_CAPS_FEATURE_META_GST_VIDEO_OVERLAY_COMPOSITION", "meta:GstVideoOverlayComposition"), + ("GST_COLOR_BALANCE_HARDWARE", "0"), + ("GST_COLOR_BALANCE_SOFTWARE", "1"), + ("GST_META_TAG_VIDEO_COLORSPACE_STR", "colorspace"), + ("GST_META_TAG_VIDEO_ORIENTATION_STR", "orientation"), + ("GST_META_TAG_VIDEO_SIZE_STR", "size"), + ("GST_META_TAG_VIDEO_STR", "video"), + ("GST_NAVIGATION_COMMAND_ACTIVATE", "24"), + ("GST_NAVIGATION_COMMAND_DOWN", "23"), + ("GST_NAVIGATION_COMMAND_INVALID", "0"), + ("GST_NAVIGATION_COMMAND_LEFT", "20"), + ("GST_NAVIGATION_COMMAND_MENU1", "1"), + ("GST_NAVIGATION_COMMAND_MENU2", "2"), + ("GST_NAVIGATION_COMMAND_MENU3", "3"), + ("GST_NAVIGATION_COMMAND_MENU4", "4"), + ("GST_NAVIGATION_COMMAND_MENU5", "5"), + ("GST_NAVIGATION_COMMAND_MENU6", "6"), + ("GST_NAVIGATION_COMMAND_MENU7", "7"), + ("GST_NAVIGATION_COMMAND_NEXT_ANGLE", "31"), + ("GST_NAVIGATION_COMMAND_PREV_ANGLE", "30"), + ("GST_NAVIGATION_COMMAND_RIGHT", "21"), + ("GST_NAVIGATION_COMMAND_UP", "22"), + ("GST_NAVIGATION_EVENT_COMMAND", "6"), + ("GST_NAVIGATION_EVENT_INVALID", "0"), + ("GST_NAVIGATION_EVENT_KEY_PRESS", "1"), + ("GST_NAVIGATION_EVENT_KEY_RELEASE", "2"), + ("GST_NAVIGATION_EVENT_MOUSE_BUTTON_PRESS", "3"), + ("GST_NAVIGATION_EVENT_MOUSE_BUTTON_RELEASE", "4"), + ("GST_NAVIGATION_EVENT_MOUSE_MOVE", "5"), + ("GST_NAVIGATION_MESSAGE_ANGLES_CHANGED", "3"), + ("GST_NAVIGATION_MESSAGE_COMMANDS_CHANGED", "2"), + ("GST_NAVIGATION_MESSAGE_EVENT", "4"), + ("GST_NAVIGATION_MESSAGE_INVALID", "0"), + ("GST_NAVIGATION_MESSAGE_MOUSE_OVER", "1"), + ("GST_NAVIGATION_QUERY_ANGLES", "2"), + ("GST_NAVIGATION_QUERY_COMMANDS", "1"), + ("GST_NAVIGATION_QUERY_INVALID", "0"), + ("GST_VIDEO_ALPHA_MODE_COPY", "0"), + ("GST_VIDEO_ALPHA_MODE_MULT", "2"), + ("GST_VIDEO_ALPHA_MODE_SET", "1"), + ("GST_VIDEO_BUFFER_FLAG_FIRST_IN_BUNDLE", "33554432"), + ("GST_VIDEO_BUFFER_FLAG_INTERLACED", "1048576"), + ("GST_VIDEO_BUFFER_FLAG_LAST", "268435456"), + ("GST_VIDEO_BUFFER_FLAG_MULTIPLE_VIEW", "16777216"), + ("GST_VIDEO_BUFFER_FLAG_ONEFIELD", "8388608"), + ("GST_VIDEO_BUFFER_FLAG_RFF", "4194304"), + ("GST_VIDEO_BUFFER_FLAG_TFF", "2097152"), + ("GST_VIDEO_CHROMA_FLAG_INTERLACED", "1"), + ("GST_VIDEO_CHROMA_FLAG_NONE", "0"), + ("GST_VIDEO_CHROMA_METHOD_LINEAR", "1"), + ("GST_VIDEO_CHROMA_METHOD_NEAREST", "0"), + ("GST_VIDEO_CHROMA_MODE_DOWNSAMPLE_ONLY", "2"), + ("GST_VIDEO_CHROMA_MODE_FULL", "0"), + ("GST_VIDEO_CHROMA_MODE_NONE", "3"), + ("GST_VIDEO_CHROMA_MODE_UPSAMPLE_ONLY", "1"), + ("GST_VIDEO_CHROMA_SITE_ALT_LINE", "8"), + ("GST_VIDEO_CHROMA_SITE_COSITED", "6"), + ("GST_VIDEO_CHROMA_SITE_DV", "14"), + ("GST_VIDEO_CHROMA_SITE_H_COSITED", "2"), + ("GST_VIDEO_CHROMA_SITE_JPEG", "1"), + ("GST_VIDEO_CHROMA_SITE_MPEG2", "2"), + ("GST_VIDEO_CHROMA_SITE_NONE", "1"), + ("GST_VIDEO_CHROMA_SITE_UNKNOWN", "0"), + ("GST_VIDEO_CHROMA_SITE_V_COSITED", "4"), + ("GST_VIDEO_CODEC_FRAME_FLAG_DECODE_ONLY", "1"), + ("GST_VIDEO_CODEC_FRAME_FLAG_FORCE_KEYFRAME", "4"), + ("GST_VIDEO_CODEC_FRAME_FLAG_FORCE_KEYFRAME_HEADERS", "8"), + ("GST_VIDEO_CODEC_FRAME_FLAG_SYNC_POINT", "2"), + ("GST_VIDEO_COLORIMETRY_BT2020", "bt2020"), + ("GST_VIDEO_COLORIMETRY_BT601", "bt601"), + ("GST_VIDEO_COLORIMETRY_BT709", "bt709"), + ("GST_VIDEO_COLORIMETRY_SMPTE240M", "smpte240m"), + ("GST_VIDEO_COLORIMETRY_SRGB", "sRGB"), + ("GST_VIDEO_COLOR_MATRIX_BT2020", "6"), + ("GST_VIDEO_COLOR_MATRIX_BT601", "4"), + ("GST_VIDEO_COLOR_MATRIX_BT709", "3"), + ("GST_VIDEO_COLOR_MATRIX_FCC", "2"), + ("GST_VIDEO_COLOR_MATRIX_RGB", "1"), + ("GST_VIDEO_COLOR_MATRIX_SMPTE240M", "5"), + ("GST_VIDEO_COLOR_MATRIX_UNKNOWN", "0"), + ("GST_VIDEO_COLOR_PRIMARIES_ADOBERGB", "8"), + ("GST_VIDEO_COLOR_PRIMARIES_BT2020", "7"), + ("GST_VIDEO_COLOR_PRIMARIES_BT470BG", "3"), + ("GST_VIDEO_COLOR_PRIMARIES_BT470M", "2"), + ("GST_VIDEO_COLOR_PRIMARIES_BT709", "1"), + ("GST_VIDEO_COLOR_PRIMARIES_FILM", "6"), + ("GST_VIDEO_COLOR_PRIMARIES_SMPTE170M", "4"), + ("GST_VIDEO_COLOR_PRIMARIES_SMPTE240M", "5"), + ("GST_VIDEO_COLOR_PRIMARIES_UNKNOWN", "0"), + ("GST_VIDEO_COLOR_RANGE_0_255", "1"), + ("GST_VIDEO_COLOR_RANGE_16_235", "2"), + ("GST_VIDEO_COLOR_RANGE_UNKNOWN", "0"), + ("GST_VIDEO_COMP_A", "3"), + ("GST_VIDEO_COMP_B", "2"), + ("GST_VIDEO_COMP_G", "1"), + ("GST_VIDEO_COMP_INDEX", "0"), + ("GST_VIDEO_COMP_PALETTE", "1"), + ("GST_VIDEO_COMP_R", "0"), + ("GST_VIDEO_COMP_U", "1"), + ("GST_VIDEO_COMP_V", "2"), + ("GST_VIDEO_COMP_Y", "0"), + ("GST_VIDEO_CONVERTER_OPT_ALPHA_MODE", "GstVideoConverter.alpha-mode"), + ("GST_VIDEO_CONVERTER_OPT_ALPHA_VALUE", "GstVideoConverter.alpha-value"), + ("GST_VIDEO_CONVERTER_OPT_BORDER_ARGB", "GstVideoConverter.border-argb"), + ("GST_VIDEO_CONVERTER_OPT_CHROMA_MODE", "GstVideoConverter.chroma-mode"), + ("GST_VIDEO_CONVERTER_OPT_CHROMA_RESAMPLER_METHOD", "GstVideoConverter.chroma-resampler-method"), + ("GST_VIDEO_CONVERTER_OPT_DEST_HEIGHT", "GstVideoConverter.dest-height"), + ("GST_VIDEO_CONVERTER_OPT_DEST_WIDTH", "GstVideoConverter.dest-width"), + ("GST_VIDEO_CONVERTER_OPT_DEST_X", "GstVideoConverter.dest-x"), + ("GST_VIDEO_CONVERTER_OPT_DEST_Y", "GstVideoConverter.dest-y"), + ("GST_VIDEO_CONVERTER_OPT_DITHER_METHOD", "GstVideoConverter.dither-method"), + ("GST_VIDEO_CONVERTER_OPT_DITHER_QUANTIZATION", "GstVideoConverter.dither-quantization"), + ("GST_VIDEO_CONVERTER_OPT_FILL_BORDER", "GstVideoConverter.fill-border"), + ("GST_VIDEO_CONVERTER_OPT_GAMMA_MODE", "GstVideoConverter.gamma-mode"), + ("GST_VIDEO_CONVERTER_OPT_MATRIX_MODE", "GstVideoConverter.matrix-mode"), + ("GST_VIDEO_CONVERTER_OPT_PRIMARIES_MODE", "GstVideoConverter.primaries-mode"), + ("GST_VIDEO_CONVERTER_OPT_RESAMPLER_METHOD", "GstVideoConverter.resampler-method"), + ("GST_VIDEO_CONVERTER_OPT_RESAMPLER_TAPS", "GstVideoConverter.resampler-taps"), + ("GST_VIDEO_CONVERTER_OPT_SRC_HEIGHT", "GstVideoConverter.src-height"), + ("GST_VIDEO_CONVERTER_OPT_SRC_WIDTH", "GstVideoConverter.src-width"), + ("GST_VIDEO_CONVERTER_OPT_SRC_X", "GstVideoConverter.src-x"), + ("GST_VIDEO_CONVERTER_OPT_SRC_Y", "GstVideoConverter.src-y"), + ("GST_VIDEO_CONVERTER_OPT_THREADS", "GstVideoConverter.threads"), + ("GST_VIDEO_DECODER_MAX_ERRORS", "10"), + ("GST_VIDEO_DECODER_SINK_NAME", "sink"), + ("GST_VIDEO_DECODER_SRC_NAME", "src"), + ("GST_VIDEO_DITHER_BAYER", "4"), + ("GST_VIDEO_DITHER_FLAG_INTERLACED", "1"), + ("GST_VIDEO_DITHER_FLAG_NONE", "0"), + ("GST_VIDEO_DITHER_FLAG_QUANTIZE", "2"), + ("GST_VIDEO_DITHER_FLOYD_STEINBERG", "2"), + ("GST_VIDEO_DITHER_NONE", "0"), + ("GST_VIDEO_DITHER_SIERRA_LITE", "3"), + ("GST_VIDEO_DITHER_VERTERR", "1"), + ("GST_VIDEO_ENCODER_SINK_NAME", "sink"), + ("GST_VIDEO_ENCODER_SRC_NAME", "src"), + ("GST_VIDEO_FIELD_ORDER_BOTTOM_FIELD_FIRST", "2"), + ("GST_VIDEO_FIELD_ORDER_TOP_FIELD_FIRST", "1"), + ("GST_VIDEO_FIELD_ORDER_UNKNOWN", "0"), + ("GST_VIDEO_FLAG_NONE", "0"), + ("GST_VIDEO_FLAG_PREMULTIPLIED_ALPHA", "2"), + ("GST_VIDEO_FLAG_VARIABLE_FPS", "1"), + ("GST_VIDEO_FORMATS_ALL", "{ I420, YV12, YUY2, UYVY, AYUV, RGBx, BGRx, xRGB, xBGR, RGBA, BGRA, ARGB, ABGR, RGB, BGR, Y41B, Y42B, YVYU, Y444, v210, v216, NV12, NV21, GRAY8, GRAY16_BE, GRAY16_LE, v308, RGB16, BGR16, RGB15, BGR15, UYVP, A420, RGB8P, YUV9, YVU9, IYU1, ARGB64, AYUV64, r210, I420_10BE, I420_10LE, I422_10BE, I422_10LE, Y444_10BE, Y444_10LE, GBR, GBR_10BE, GBR_10LE, NV16, NV24, NV12_64Z32, A420_10BE, A420_10LE, A422_10BE, A422_10LE, A444_10BE, A444_10LE, NV61, P010_10BE, P010_10LE, IYU2, VYUY, GBRA, GBRA_10BE, GBRA_10LE, GBR_12BE, GBR_12LE, GBRA_12BE, GBRA_12LE, I420_12BE, I420_12LE, I422_12BE, I422_12LE, Y444_12BE, Y444_12LE, GRAY10_LE32, NV12_10LE32, NV16_10LE32 }"), + ("GST_VIDEO_FORMAT_A420", "34"), + ("GST_VIDEO_FORMAT_A420_10BE", "54"), + ("GST_VIDEO_FORMAT_A420_10LE", "55"), + ("GST_VIDEO_FORMAT_A422_10BE", "56"), + ("GST_VIDEO_FORMAT_A422_10LE", "57"), + ("GST_VIDEO_FORMAT_A444_10BE", "58"), + ("GST_VIDEO_FORMAT_A444_10LE", "59"), + ("GST_VIDEO_FORMAT_ABGR", "14"), + ("GST_VIDEO_FORMAT_ARGB", "13"), + ("GST_VIDEO_FORMAT_ARGB64", "39"), + ("GST_VIDEO_FORMAT_AYUV", "6"), + ("GST_VIDEO_FORMAT_AYUV64", "40"), + ("GST_VIDEO_FORMAT_BGR", "16"), + ("GST_VIDEO_FORMAT_BGR15", "32"), + ("GST_VIDEO_FORMAT_BGR16", "30"), + ("GST_VIDEO_FORMAT_BGRA", "12"), + ("GST_VIDEO_FORMAT_BGRx", "8"), + ("GST_VIDEO_FORMAT_ENCODED", "1"), + ("GST_VIDEO_FORMAT_FLAG_ALPHA", "8"), + ("GST_VIDEO_FORMAT_FLAG_COMPLEX", "64"), + ("GST_VIDEO_FORMAT_FLAG_GRAY", "4"), + ("GST_VIDEO_FORMAT_FLAG_LE", "16"), + ("GST_VIDEO_FORMAT_FLAG_PALETTE", "32"), + ("GST_VIDEO_FORMAT_FLAG_RGB", "2"), + ("GST_VIDEO_FORMAT_FLAG_TILED", "256"), + ("GST_VIDEO_FORMAT_FLAG_UNPACK", "128"), + ("GST_VIDEO_FORMAT_FLAG_YUV", "1"), + ("GST_VIDEO_FORMAT_GBR", "48"), + ("GST_VIDEO_FORMAT_GBRA", "65"), + ("GST_VIDEO_FORMAT_GBRA_10BE", "66"), + ("GST_VIDEO_FORMAT_GBRA_10LE", "67"), + ("GST_VIDEO_FORMAT_GBRA_12BE", "70"), + ("GST_VIDEO_FORMAT_GBRA_12LE", "71"), + ("GST_VIDEO_FORMAT_GBR_10BE", "49"), + ("GST_VIDEO_FORMAT_GBR_10LE", "50"), + ("GST_VIDEO_FORMAT_GBR_12BE", "68"), + ("GST_VIDEO_FORMAT_GBR_12LE", "69"), + ("GST_VIDEO_FORMAT_GRAY10_LE32", "78"), + ("GST_VIDEO_FORMAT_GRAY16_BE", "26"), + ("GST_VIDEO_FORMAT_GRAY16_LE", "27"), + ("GST_VIDEO_FORMAT_GRAY8", "25"), + ("GST_VIDEO_FORMAT_I420", "2"), + ("GST_VIDEO_FORMAT_I420_10BE", "42"), + ("GST_VIDEO_FORMAT_I420_10LE", "43"), + ("GST_VIDEO_FORMAT_I420_12BE", "72"), + ("GST_VIDEO_FORMAT_I420_12LE", "73"), + ("GST_VIDEO_FORMAT_I422_10BE", "44"), + ("GST_VIDEO_FORMAT_I422_10LE", "45"), + ("GST_VIDEO_FORMAT_I422_12BE", "74"), + ("GST_VIDEO_FORMAT_I422_12LE", "75"), + ("GST_VIDEO_FORMAT_IYU1", "38"), + ("GST_VIDEO_FORMAT_IYU2", "63"), + ("GST_VIDEO_FORMAT_NV12", "23"), + ("GST_VIDEO_FORMAT_NV12_10LE32", "79"), + ("GST_VIDEO_FORMAT_NV12_64Z32", "53"), + ("GST_VIDEO_FORMAT_NV16", "51"), + ("GST_VIDEO_FORMAT_NV16_10LE32", "80"), + ("GST_VIDEO_FORMAT_NV21", "24"), + ("GST_VIDEO_FORMAT_NV24", "52"), + ("GST_VIDEO_FORMAT_NV61", "60"), + ("GST_VIDEO_FORMAT_P010_10BE", "61"), + ("GST_VIDEO_FORMAT_P010_10LE", "62"), + ("GST_VIDEO_FORMAT_RGB", "15"), + ("GST_VIDEO_FORMAT_RGB15", "31"), + ("GST_VIDEO_FORMAT_RGB16", "29"), + ("GST_VIDEO_FORMAT_RGB8P", "35"), + ("GST_VIDEO_FORMAT_RGBA", "11"), + ("GST_VIDEO_FORMAT_RGBx", "7"), + ("GST_VIDEO_FORMAT_UNKNOWN", "0"), + ("GST_VIDEO_FORMAT_UYVP", "33"), + ("GST_VIDEO_FORMAT_UYVY", "5"), + ("GST_VIDEO_FORMAT_VYUY", "64"), + ("GST_VIDEO_FORMAT_Y41B", "17"), + ("GST_VIDEO_FORMAT_Y42B", "18"), + ("GST_VIDEO_FORMAT_Y444", "20"), + ("GST_VIDEO_FORMAT_Y444_10BE", "46"), + ("GST_VIDEO_FORMAT_Y444_10LE", "47"), + ("GST_VIDEO_FORMAT_Y444_12BE", "76"), + ("GST_VIDEO_FORMAT_Y444_12LE", "77"), + ("GST_VIDEO_FORMAT_YUV9", "36"), + ("GST_VIDEO_FORMAT_YUY2", "4"), + ("GST_VIDEO_FORMAT_YV12", "3"), + ("GST_VIDEO_FORMAT_YVU9", "37"), + ("GST_VIDEO_FORMAT_YVYU", "19"), + ("GST_VIDEO_FORMAT_r210", "41"), + ("GST_VIDEO_FORMAT_v210", "21"), + ("GST_VIDEO_FORMAT_v216", "22"), + ("GST_VIDEO_FORMAT_v308", "28"), + ("GST_VIDEO_FORMAT_xBGR", "10"), + ("GST_VIDEO_FORMAT_xRGB", "9"), + ("GST_VIDEO_FPS_RANGE", "(fraction) [ 0, max ]"), + ("GST_VIDEO_FRAME_FLAG_FIRST_IN_BUNDLE", "32"), + ("GST_VIDEO_FRAME_FLAG_INTERLACED", "1"), + ("GST_VIDEO_FRAME_FLAG_MULTIPLE_VIEW", "16"), + ("GST_VIDEO_FRAME_FLAG_NONE", "0"), + ("GST_VIDEO_FRAME_FLAG_ONEFIELD", "8"), + ("GST_VIDEO_FRAME_FLAG_RFF", "4"), + ("GST_VIDEO_FRAME_FLAG_TFF", "2"), + ("GST_VIDEO_FRAME_MAP_FLAG_LAST", "16777216"), + ("GST_VIDEO_FRAME_MAP_FLAG_NO_REF", "65536"), + ("GST_VIDEO_GAMMA_MODE_NONE", "0"), + ("GST_VIDEO_GAMMA_MODE_REMAP", "1"), + ("GST_VIDEO_GL_TEXTURE_ORIENTATION_X_FLIP_Y_FLIP", "3"), + ("GST_VIDEO_GL_TEXTURE_ORIENTATION_X_FLIP_Y_NORMAL", "2"), + ("GST_VIDEO_GL_TEXTURE_ORIENTATION_X_NORMAL_Y_FLIP", "1"), + ("GST_VIDEO_GL_TEXTURE_ORIENTATION_X_NORMAL_Y_NORMAL", "0"), + ("GST_VIDEO_GL_TEXTURE_TYPE_LUMINANCE", "0"), + ("GST_VIDEO_GL_TEXTURE_TYPE_LUMINANCE_ALPHA", "1"), + ("GST_VIDEO_GL_TEXTURE_TYPE_R", "5"), + ("GST_VIDEO_GL_TEXTURE_TYPE_RG", "6"), + ("GST_VIDEO_GL_TEXTURE_TYPE_RGB", "3"), + ("GST_VIDEO_GL_TEXTURE_TYPE_RGB16", "2"), + ("GST_VIDEO_GL_TEXTURE_TYPE_RGBA", "4"), + ("GST_VIDEO_INTERLACE_MODE_FIELDS", "3"), + ("GST_VIDEO_INTERLACE_MODE_INTERLEAVED", "1"), + ("GST_VIDEO_INTERLACE_MODE_MIXED", "2"), + ("GST_VIDEO_INTERLACE_MODE_PROGRESSIVE", "0"), + ("GST_VIDEO_MATRIX_MODE_FULL", "0"), + ("GST_VIDEO_MATRIX_MODE_INPUT_ONLY", "1"), + ("GST_VIDEO_MATRIX_MODE_NONE", "3"), + ("GST_VIDEO_MATRIX_MODE_OUTPUT_ONLY", "2"), + ("GST_VIDEO_MAX_COMPONENTS", "4"), + ("GST_VIDEO_MAX_PLANES", "4"), + ("GST_VIDEO_MULTIVIEW_FLAGS_HALF_ASPECT", "16384"), + ("GST_VIDEO_MULTIVIEW_FLAGS_LEFT_FLIPPED", "2"), + ("GST_VIDEO_MULTIVIEW_FLAGS_LEFT_FLOPPED", "4"), + ("GST_VIDEO_MULTIVIEW_FLAGS_MIXED_MONO", "32768"), + ("GST_VIDEO_MULTIVIEW_FLAGS_NONE", "0"), + ("GST_VIDEO_MULTIVIEW_FLAGS_RIGHT_FLIPPED", "8"), + ("GST_VIDEO_MULTIVIEW_FLAGS_RIGHT_FLOPPED", "16"), + ("GST_VIDEO_MULTIVIEW_FLAGS_RIGHT_VIEW_FIRST", "1"), + ("GST_VIDEO_MULTIVIEW_FRAME_PACKING_CHECKERBOARD", "8"), + ("GST_VIDEO_MULTIVIEW_FRAME_PACKING_COLUMN_INTERLEAVED", "5"), + ("GST_VIDEO_MULTIVIEW_FRAME_PACKING_LEFT", "1"), + ("GST_VIDEO_MULTIVIEW_FRAME_PACKING_MONO", "0"), + ("GST_VIDEO_MULTIVIEW_FRAME_PACKING_NONE", "-1"), + ("GST_VIDEO_MULTIVIEW_FRAME_PACKING_RIGHT", "2"), + ("GST_VIDEO_MULTIVIEW_FRAME_PACKING_ROW_INTERLEAVED", "6"), + ("GST_VIDEO_MULTIVIEW_FRAME_PACKING_SIDE_BY_SIDE", "3"), + ("GST_VIDEO_MULTIVIEW_FRAME_PACKING_SIDE_BY_SIDE_QUINCUNX", "4"), + ("GST_VIDEO_MULTIVIEW_FRAME_PACKING_TOP_BOTTOM", "7"), + ("GST_VIDEO_MULTIVIEW_MODE_CHECKERBOARD", "8"), + ("GST_VIDEO_MULTIVIEW_MODE_COLUMN_INTERLEAVED", "5"), + ("GST_VIDEO_MULTIVIEW_MODE_FRAME_BY_FRAME", "32"), + ("GST_VIDEO_MULTIVIEW_MODE_LEFT", "1"), + ("GST_VIDEO_MULTIVIEW_MODE_MONO", "0"), + ("GST_VIDEO_MULTIVIEW_MODE_MULTIVIEW_FRAME_BY_FRAME", "33"), + ("GST_VIDEO_MULTIVIEW_MODE_NONE", "-1"), + ("GST_VIDEO_MULTIVIEW_MODE_RIGHT", "2"), + ("GST_VIDEO_MULTIVIEW_MODE_ROW_INTERLEAVED", "6"), + ("GST_VIDEO_MULTIVIEW_MODE_SEPARATED", "34"), + ("GST_VIDEO_MULTIVIEW_MODE_SIDE_BY_SIDE", "3"), + ("GST_VIDEO_MULTIVIEW_MODE_SIDE_BY_SIDE_QUINCUNX", "4"), + ("GST_VIDEO_MULTIVIEW_MODE_TOP_BOTTOM", "7"), + ("GST_VIDEO_ORIENTATION_180", "2"), + ("GST_VIDEO_ORIENTATION_90L", "3"), + ("GST_VIDEO_ORIENTATION_90R", "1"), + ("GST_VIDEO_ORIENTATION_AUTO", "8"), + ("GST_VIDEO_ORIENTATION_CUSTOM", "9"), + ("GST_VIDEO_ORIENTATION_HORIZ", "4"), + ("GST_VIDEO_ORIENTATION_IDENTITY", "0"), + ("GST_VIDEO_ORIENTATION_UL_LR", "6"), + ("GST_VIDEO_ORIENTATION_UR_LL", "7"), + ("GST_VIDEO_ORIENTATION_VERT", "5"), + ("GST_VIDEO_OVERLAY_COMPOSITION_BLEND_FORMATS", "{ BGRx, RGBx, xRGB, xBGR, RGBA, BGRA, ARGB, ABGR, RGB, BGR, I420, YV12, AYUV, YUY2, UYVY, v308, Y41B, Y42B, Y444, NV12, NV21, A420, YUV9, YVU9, IYU1, GRAY8 }"), + ("GST_VIDEO_OVERLAY_FORMAT_FLAG_GLOBAL_ALPHA", "2"), + ("GST_VIDEO_OVERLAY_FORMAT_FLAG_NONE", "0"), + ("GST_VIDEO_OVERLAY_FORMAT_FLAG_PREMULTIPLIED_ALPHA", "1"), + ("GST_VIDEO_PACK_FLAG_INTERLACED", "2"), + ("GST_VIDEO_PACK_FLAG_NONE", "0"), + ("GST_VIDEO_PACK_FLAG_TRUNCATE_RANGE", "1"), + ("GST_VIDEO_PRIMARIES_MODE_FAST", "2"), + ("GST_VIDEO_PRIMARIES_MODE_MERGE_ONLY", "1"), + ("GST_VIDEO_PRIMARIES_MODE_NONE", "0"), + ("GST_VIDEO_RESAMPLER_FLAG_HALF_TAPS", "1"), + ("GST_VIDEO_RESAMPLER_FLAG_NONE", "0"), + ("GST_VIDEO_RESAMPLER_METHOD_CUBIC", "2"), + ("GST_VIDEO_RESAMPLER_METHOD_LANCZOS", "4"), + ("GST_VIDEO_RESAMPLER_METHOD_LINEAR", "1"), + ("GST_VIDEO_RESAMPLER_METHOD_NEAREST", "0"), + ("GST_VIDEO_RESAMPLER_METHOD_SINC", "3"), + ("GST_VIDEO_RESAMPLER_OPT_CUBIC_B", "GstVideoResampler.cubic-b"), + ("GST_VIDEO_RESAMPLER_OPT_CUBIC_C", "GstVideoResampler.cubic-c"), + ("GST_VIDEO_RESAMPLER_OPT_ENVELOPE", "GstVideoResampler.envelope"), + ("GST_VIDEO_RESAMPLER_OPT_MAX_TAPS", "GstVideoResampler.max-taps"), + ("GST_VIDEO_RESAMPLER_OPT_SHARPEN", "GstVideoResampler.sharpen"), + ("GST_VIDEO_RESAMPLER_OPT_SHARPNESS", "GstVideoResampler.sharpness"), + ("GST_VIDEO_SCALER_FLAG_INTERLACED", "1"), + ("GST_VIDEO_SCALER_FLAG_NONE", "0"), + ("GST_VIDEO_SCALER_OPT_DITHER_METHOD", "GstVideoScaler.dither-method"), + ("GST_VIDEO_SIZE_RANGE", "(int) [ 1, max ]"), + ("GST_VIDEO_TILE_MODE_UNKNOWN", "0"), + ("GST_VIDEO_TILE_MODE_ZFLIPZ_2X2", "65536"), + ("GST_VIDEO_TILE_TYPE_INDEXED", "0"), + ("GST_VIDEO_TILE_TYPE_MASK", "65535"), + ("GST_VIDEO_TILE_TYPE_SHIFT", "16"), + ("GST_VIDEO_TILE_X_TILES_MASK", "65535"), + ("GST_VIDEO_TILE_Y_TILES_SHIFT", "16"), + ("GST_VIDEO_TIME_CODE_FLAGS_DROP_FRAME", "1"), + ("GST_VIDEO_TIME_CODE_FLAGS_INTERLACED", "2"), + ("GST_VIDEO_TIME_CODE_FLAGS_NONE", "0"), + ("GST_VIDEO_TRANSFER_ADOBERGB", "12"), + ("GST_VIDEO_TRANSFER_BT2020_12", "11"), + ("GST_VIDEO_TRANSFER_BT709", "5"), + ("GST_VIDEO_TRANSFER_GAMMA10", "1"), + ("GST_VIDEO_TRANSFER_GAMMA18", "2"), + ("GST_VIDEO_TRANSFER_GAMMA20", "3"), + ("GST_VIDEO_TRANSFER_GAMMA22", "4"), + ("GST_VIDEO_TRANSFER_GAMMA28", "8"), + ("GST_VIDEO_TRANSFER_LOG100", "9"), + ("GST_VIDEO_TRANSFER_LOG316", "10"), + ("GST_VIDEO_TRANSFER_SMPTE240M", "6"), + ("GST_VIDEO_TRANSFER_SRGB", "7"), + ("GST_VIDEO_TRANSFER_UNKNOWN", "0"), +]; + + diff --git a/gstreamer-video-sys/tests/constant.c b/gstreamer-video-sys/tests/constant.c new file mode 100644 index 000000000..f95b609c2 --- /dev/null +++ b/gstreamer-video-sys/tests/constant.c @@ -0,0 +1,27 @@ +// This file was generated by gir (https://github.com/gtk-rs/gir @ 6855214) +// from gir-files (https://github.com/gtk-rs/gir-files @ ???) +// DO NOT EDIT + +#include "manual.h" +#include + +int main() { + printf(_Generic((ABI_CONSTANT_NAME), + char *: "%s", + const char *: "%s", + char: "%c", + signed char: "%hhd", + unsigned char: "%hhu", + short int: "%hd", + unsigned short int: "%hu", + int: "%d", + unsigned int: "%u", + long: "%ld", + unsigned long: "%lu", + long long: "%lld", + unsigned long long: "%llu", + double: "%f", + long double: "%ld"), + ABI_CONSTANT_NAME); + return 0; +} diff --git a/gstreamer-video-sys/tests/layout.c b/gstreamer-video-sys/tests/layout.c new file mode 100644 index 000000000..e4be962df --- /dev/null +++ b/gstreamer-video-sys/tests/layout.c @@ -0,0 +1,12 @@ +// This file was generated by gir (https://github.com/gtk-rs/gir @ 6855214) +// from gir-files (https://github.com/gtk-rs/gir-files @ ???) +// 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-video-sys/tests/manual.h b/gstreamer-video-sys/tests/manual.h new file mode 100644 index 000000000..c48a7e612 --- /dev/null +++ b/gstreamer-video-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 diff --git a/gstreamer-webrtc-sys/Cargo.toml b/gstreamer-webrtc-sys/Cargo.toml index 8dd4362a5..2a5d7a731 100644 --- a/gstreamer-webrtc-sys/Cargo.toml +++ b/gstreamer-webrtc-sys/Cargo.toml @@ -12,6 +12,10 @@ path = "../gstreamer-sys" [dependencies.gstreamer-sdp-sys] path = "../gstreamer-sdp-sys" +[dev-dependencies] +shell-words = "0.1.0" +tempdir = "0.3" + [features] dox = [] diff --git a/gstreamer-webrtc-sys/src/lib.rs b/gstreamer-webrtc-sys/src/lib.rs index c1f2fcf10..5fee8185b 100644 --- a/gstreamer-webrtc-sys/src/lib.rs +++ b/gstreamer-webrtc-sys/src/lib.rs @@ -1,4 +1,4 @@ -// This file was generated by gir (https://github.com/gtk-rs/gir @ fe7a6ff) +// This file was generated by gir (https://github.com/gtk-rs/gir @ 6855214) // from gir-files (https://github.com/gtk-rs/gir-files @ ???) // DO NOT EDIT diff --git a/gstreamer-webrtc-sys/tests/abi.rs b/gstreamer-webrtc-sys/tests/abi.rs new file mode 100644 index 000000000..748799a4b --- /dev/null +++ b/gstreamer-webrtc-sys/tests/abi.rs @@ -0,0 +1,319 @@ +// This file was generated by gir (https://github.com/gtk-rs/gir @ 6855214) +// from gir-files (https://github.com/gtk-rs/gir-files @ ???) +// DO NOT EDIT + +extern crate gstreamer_webrtc_sys; +extern crate shell_words; +extern crate tempdir; +use std::env; +use std::error::Error; +use std::path::Path; +use std::mem::{align_of, size_of}; +use std::process::Command; +use std::str; +use gstreamer_webrtc_sys::*; + +static PACKAGES: &[&str] = &["gstreamer-webrtc-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 = tempdir::TempDir::new("abi").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 = tempdir::TempDir::new("abi").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()); + } + + Ok(str::from_utf8(&output.stdout)?.trim().to_owned()) +} + +const RUST_LAYOUTS: &[(&str, Layout)] = &[ + ("GstWebRTCDTLSSetup", Layout {size: size_of::(), alignment: align_of::()}), + ("GstWebRTCDTLSTransport", Layout {size: size_of::(), alignment: align_of::()}), + ("GstWebRTCDTLSTransportClass", Layout {size: size_of::(), alignment: align_of::()}), + ("GstWebRTCDTLSTransportState", Layout {size: size_of::(), alignment: align_of::()}), + ("GstWebRTCICEComponent", Layout {size: size_of::(), alignment: align_of::()}), + ("GstWebRTCICEConnectionState", Layout {size: size_of::(), alignment: align_of::()}), + ("GstWebRTCICEGatheringState", Layout {size: size_of::(), alignment: align_of::()}), + ("GstWebRTCICERole", Layout {size: size_of::(), alignment: align_of::()}), + ("GstWebRTCICETransport", Layout {size: size_of::(), alignment: align_of::()}), + ("GstWebRTCICETransportClass", Layout {size: size_of::(), alignment: align_of::()}), + ("GstWebRTCPeerConnectionState", Layout {size: size_of::(), alignment: align_of::()}), + ("GstWebRTCRTPReceiver", Layout {size: size_of::(), alignment: align_of::()}), + ("GstWebRTCRTPReceiverClass", Layout {size: size_of::(), alignment: align_of::()}), + ("GstWebRTCRTPSender", Layout {size: size_of::(), alignment: align_of::()}), + ("GstWebRTCRTPSenderClass", Layout {size: size_of::(), alignment: align_of::()}), + ("GstWebRTCRTPTransceiver", Layout {size: size_of::(), alignment: align_of::()}), + ("GstWebRTCRTPTransceiverClass", Layout {size: size_of::(), alignment: align_of::()}), + ("GstWebRTCRTPTransceiverDirection", Layout {size: size_of::(), alignment: align_of::()}), + ("GstWebRTCSDPType", Layout {size: size_of::(), alignment: align_of::()}), + ("GstWebRTCSessionDescription", Layout {size: size_of::(), alignment: align_of::()}), + ("GstWebRTCSignalingState", Layout {size: size_of::(), alignment: align_of::()}), + ("GstWebRTCStatsType", Layout {size: size_of::(), alignment: align_of::()}), +]; + +const RUST_CONSTANTS: &[(&str, &str)] = &[ + ("GST_WEBRTC_DTLS_SETUP_ACTIVE", "2"), + ("GST_WEBRTC_DTLS_SETUP_ACTPASS", "1"), + ("GST_WEBRTC_DTLS_SETUP_NONE", "0"), + ("GST_WEBRTC_DTLS_SETUP_PASSIVE", "3"), + ("GST_WEBRTC_DTLS_TRANSPORT_STATE_CLOSED", "1"), + ("GST_WEBRTC_DTLS_TRANSPORT_STATE_CONNECTED", "4"), + ("GST_WEBRTC_DTLS_TRANSPORT_STATE_CONNECTING", "3"), + ("GST_WEBRTC_DTLS_TRANSPORT_STATE_FAILED", "2"), + ("GST_WEBRTC_DTLS_TRANSPORT_STATE_NEW", "0"), + ("GST_WEBRTC_ICE_COMPONENT_RTCP", "1"), + ("GST_WEBRTC_ICE_COMPONENT_RTP", "0"), + ("GST_WEBRTC_ICE_CONNECTION_STATE_CHECKING", "1"), + ("GST_WEBRTC_ICE_CONNECTION_STATE_CLOSED", "6"), + ("GST_WEBRTC_ICE_CONNECTION_STATE_COMPLETED", "3"), + ("GST_WEBRTC_ICE_CONNECTION_STATE_CONNECTED", "2"), + ("GST_WEBRTC_ICE_CONNECTION_STATE_DISCONNECTED", "5"), + ("GST_WEBRTC_ICE_CONNECTION_STATE_FAILED", "4"), + ("GST_WEBRTC_ICE_CONNECTION_STATE_NEW", "0"), + ("GST_WEBRTC_ICE_GATHERING_STATE_COMPLETE", "2"), + ("GST_WEBRTC_ICE_GATHERING_STATE_GATHERING", "1"), + ("GST_WEBRTC_ICE_GATHERING_STATE_NEW", "0"), + ("GST_WEBRTC_ICE_ROLE_CONTROLLED", "0"), + ("GST_WEBRTC_ICE_ROLE_CONTROLLING", "1"), + ("GST_WEBRTC_PEER_CONNECTION_STATE_CLOSED", "5"), + ("GST_WEBRTC_PEER_CONNECTION_STATE_CONNECTED", "2"), + ("GST_WEBRTC_PEER_CONNECTION_STATE_CONNECTING", "1"), + ("GST_WEBRTC_PEER_CONNECTION_STATE_DISCONNECTED", "3"), + ("GST_WEBRTC_PEER_CONNECTION_STATE_FAILED", "4"), + ("GST_WEBRTC_PEER_CONNECTION_STATE_NEW", "0"), + ("GST_WEBRTC_RTP_TRANSCEIVER_DIRECTION_INACTIVE", "1"), + ("GST_WEBRTC_RTP_TRANSCEIVER_DIRECTION_NONE", "0"), + ("GST_WEBRTC_RTP_TRANSCEIVER_DIRECTION_RECVONLY", "3"), + ("GST_WEBRTC_RTP_TRANSCEIVER_DIRECTION_SENDONLY", "2"), + ("GST_WEBRTC_RTP_TRANSCEIVER_DIRECTION_SENDRECV", "4"), + ("GST_WEBRTC_SDP_TYPE_ANSWER", "3"), + ("GST_WEBRTC_SDP_TYPE_OFFER", "1"), + ("GST_WEBRTC_SDP_TYPE_PRANSWER", "2"), + ("GST_WEBRTC_SDP_TYPE_ROLLBACK", "4"), + ("GST_WEBRTC_SIGNALING_STATE_CLOSED", "1"), + ("GST_WEBRTC_SIGNALING_STATE_HAVE_LOCAL_OFFER", "2"), + ("GST_WEBRTC_SIGNALING_STATE_HAVE_LOCAL_PRANSWER", "4"), + ("GST_WEBRTC_SIGNALING_STATE_HAVE_REMOTE_OFFER", "3"), + ("GST_WEBRTC_SIGNALING_STATE_HAVE_REMOTE_PRANSWER", "5"), + ("GST_WEBRTC_SIGNALING_STATE_STABLE", "0"), + ("GST_WEBRTC_STATS_CANDIDATE_PAIR", "11"), + ("GST_WEBRTC_STATS_CERTIFICATE", "14"), + ("GST_WEBRTC_STATS_CODEC", "1"), + ("GST_WEBRTC_STATS_CSRC", "6"), + ("GST_WEBRTC_STATS_DATA_CHANNEL", "8"), + ("GST_WEBRTC_STATS_INBOUND_RTP", "2"), + ("GST_WEBRTC_STATS_LOCAL_CANDIDATE", "12"), + ("GST_WEBRTC_STATS_OUTBOUND_RTP", "3"), + ("GST_WEBRTC_STATS_PEER_CONNECTION", "7"), + ("GST_WEBRTC_STATS_REMOTE_CANDIDATE", "13"), + ("GST_WEBRTC_STATS_REMOTE_INBOUND_RTP", "4"), + ("GST_WEBRTC_STATS_REMOTE_OUTBOUND_RTP", "5"), + ("GST_WEBRTC_STATS_STREAM", "9"), + ("GST_WEBRTC_STATS_TRANSPORT", "10"), +]; + + diff --git a/gstreamer-webrtc-sys/tests/constant.c b/gstreamer-webrtc-sys/tests/constant.c new file mode 100644 index 000000000..f95b609c2 --- /dev/null +++ b/gstreamer-webrtc-sys/tests/constant.c @@ -0,0 +1,27 @@ +// This file was generated by gir (https://github.com/gtk-rs/gir @ 6855214) +// from gir-files (https://github.com/gtk-rs/gir-files @ ???) +// DO NOT EDIT + +#include "manual.h" +#include + +int main() { + printf(_Generic((ABI_CONSTANT_NAME), + char *: "%s", + const char *: "%s", + char: "%c", + signed char: "%hhd", + unsigned char: "%hhu", + short int: "%hd", + unsigned short int: "%hu", + int: "%d", + unsigned int: "%u", + long: "%ld", + unsigned long: "%lu", + long long: "%lld", + unsigned long long: "%llu", + double: "%f", + long double: "%ld"), + ABI_CONSTANT_NAME); + return 0; +} diff --git a/gstreamer-webrtc-sys/tests/layout.c b/gstreamer-webrtc-sys/tests/layout.c new file mode 100644 index 000000000..e4be962df --- /dev/null +++ b/gstreamer-webrtc-sys/tests/layout.c @@ -0,0 +1,12 @@ +// This file was generated by gir (https://github.com/gtk-rs/gir @ 6855214) +// from gir-files (https://github.com/gtk-rs/gir-files @ ???) +// 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-webrtc-sys/tests/manual.h b/gstreamer-webrtc-sys/tests/manual.h new file mode 100644 index 000000000..eab295695 --- /dev/null +++ b/gstreamer-webrtc-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