diff --git a/Cargo.lock b/Cargo.lock index 7d98def0d..24361a534 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -875,6 +875,18 @@ dependencies = [ "system-deps", ] +[[package]] +name = "gst-mse-sys" +version = "0.0.1" +dependencies = [ + "glib-sys", + "gstreamer-sys", + "libc", + "shell-words", + "system-deps", + "tempfile", +] + [[package]] name = "gstreamer" version = "0.24.0" diff --git a/Cargo.toml b/Cargo.toml index da44ffd5c..f0e13a31f 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -11,6 +11,7 @@ default-members = [ "gstreamer-controller/sys", "gstreamer-editing-services/sys", "gstreamer-mpegts/sys", + "gstreamer-mse/sys", "gstreamer-net/sys", "gstreamer-pbutils/sys", "gstreamer-play/sys", @@ -61,6 +62,7 @@ members = [ "gstreamer-gl/wayland/sys", "gstreamer-gl/x11/sys", "gstreamer-mpegts/sys", + "gstreamer-mse/sys", "gstreamer-net/sys", "gstreamer-pbutils/sys", "gstreamer-play/sys", @@ -136,6 +138,7 @@ gstreamer-gl-wayland-sys = { path = "./gstreamer-gl/wayland/sys"} gstreamer-gl-x11-sys = { path = "./gstreamer-gl/x11/sys"} gstreamer-gl-sys = { path = "./gstreamer-gl/sys"} gstreamer-mpegts-sys = { path = "./gstreamer-mpegts/sys"} +gstreamer-mse-sys = { path = "./gstreamer-mse/sys"} gstreamer-net-sys = { path = "./gstreamer-net/sys"} gstreamer-pbutils-sys = { path = "./gstreamer-pbutils/sys"} gstreamer-play-sys = { path = "./gstreamer-play/sys" } diff --git a/gstreamer-mse/src/auto/enums.rs b/gstreamer-mse/src/auto/enums.rs new file mode 100644 index 000000000..12055030f --- /dev/null +++ b/gstreamer-mse/src/auto/enums.rs @@ -0,0 +1,542 @@ +// This file was generated by gir (https://github.com/gtk-rs/gir) +// from gir-files (https://github.com/gtk-rs/gir-files) +// from gst-gir-files (https://gitlab.freedesktop.org/gstreamer/gir-files-rs.git) +// DO NOT EDIT + +use crate::ffi; +use glib::{prelude::*, translate::*}; + +#[derive(Debug, Eq, PartialEq, Ord, PartialOrd, Hash, Clone, Copy)] +#[non_exhaustive] +#[doc(alias = "GstMediaSourceEOSError")] +pub enum MediaSourceEOSError { + #[doc(alias = "GST_MEDIA_SOURCE_EOS_ERROR_NONE")] + None, + #[doc(alias = "GST_MEDIA_SOURCE_EOS_ERROR_NETWORK")] + Network, + #[doc(alias = "GST_MEDIA_SOURCE_EOS_ERROR_DECODE")] + Decode, + #[doc(hidden)] + __Unknown(i32), +} + +#[doc(hidden)] +impl IntoGlib for MediaSourceEOSError { + type GlibType = ffi::GstMediaSourceEOSError; + + #[inline] + fn into_glib(self) -> ffi::GstMediaSourceEOSError { + match self { + Self::None => ffi::GST_MEDIA_SOURCE_EOS_ERROR_NONE, + Self::Network => ffi::GST_MEDIA_SOURCE_EOS_ERROR_NETWORK, + Self::Decode => ffi::GST_MEDIA_SOURCE_EOS_ERROR_DECODE, + Self::__Unknown(value) => value, + } + } +} + +#[doc(hidden)] +impl FromGlib for MediaSourceEOSError { + #[inline] + unsafe fn from_glib(value: ffi::GstMediaSourceEOSError) -> Self { + skip_assert_initialized!(); + + match value { + ffi::GST_MEDIA_SOURCE_EOS_ERROR_NONE => Self::None, + ffi::GST_MEDIA_SOURCE_EOS_ERROR_NETWORK => Self::Network, + ffi::GST_MEDIA_SOURCE_EOS_ERROR_DECODE => Self::Decode, + value => Self::__Unknown(value), + } + } +} + +impl StaticType for MediaSourceEOSError { + #[inline] + #[doc(alias = "gst_media_source_eos_error_get_type")] + fn static_type() -> glib::Type { + unsafe { from_glib(ffi::gst_media_source_eos_error_get_type()) } + } +} + +impl glib::HasParamSpec for MediaSourceEOSError { + type ParamSpec = glib::ParamSpecEnum; + type SetValue = Self; + type BuilderFn = fn(&str, Self) -> glib::ParamSpecEnumBuilder; + + fn param_spec_builder() -> Self::BuilderFn { + Self::ParamSpec::builder_with_default + } +} + +impl glib::value::ValueType for MediaSourceEOSError { + type Type = Self; +} + +unsafe impl<'a> glib::value::FromValue<'a> for MediaSourceEOSError { + type Checker = glib::value::GenericValueTypeChecker; + + #[inline] + unsafe fn from_value(value: &'a glib::Value) -> Self { + skip_assert_initialized!(); + from_glib(glib::gobject_ffi::g_value_get_enum(value.to_glib_none().0)) + } +} + +impl ToValue for MediaSourceEOSError { + #[inline] + fn to_value(&self) -> glib::Value { + let mut value = glib::Value::for_value_type::(); + unsafe { + glib::gobject_ffi::g_value_set_enum(value.to_glib_none_mut().0, self.into_glib()); + } + value + } + + #[inline] + fn value_type(&self) -> glib::Type { + Self::static_type() + } +} + +impl From for glib::Value { + #[inline] + fn from(v: MediaSourceEOSError) -> Self { + skip_assert_initialized!(); + ToValue::to_value(&v) + } +} + +#[derive(Debug, Eq, PartialEq, Ord, PartialOrd, Hash, Clone, Copy)] +#[non_exhaustive] +#[doc(alias = "GstMediaSourceError")] +pub enum MediaSourceError { + #[doc(alias = "GST_MEDIA_SOURCE_ERROR_INVALID_STATE")] + InvalidState, + #[doc(alias = "GST_MEDIA_SOURCE_ERROR_TYPE")] + Type, + #[doc(alias = "GST_MEDIA_SOURCE_ERROR_NOT_SUPPORTED")] + NotSupported, + #[doc(alias = "GST_MEDIA_SOURCE_ERROR_NOT_FOUND")] + NotFound, + #[doc(alias = "GST_MEDIA_SOURCE_ERROR_QUOTA_EXCEEDED")] + QuotaExceeded, + #[doc(hidden)] + __Unknown(i32), +} + +#[doc(hidden)] +impl IntoGlib for MediaSourceError { + type GlibType = ffi::GstMediaSourceError; + + #[inline] + fn into_glib(self) -> ffi::GstMediaSourceError { + match self { + Self::InvalidState => ffi::GST_MEDIA_SOURCE_ERROR_INVALID_STATE, + Self::Type => ffi::GST_MEDIA_SOURCE_ERROR_TYPE, + Self::NotSupported => ffi::GST_MEDIA_SOURCE_ERROR_NOT_SUPPORTED, + Self::NotFound => ffi::GST_MEDIA_SOURCE_ERROR_NOT_FOUND, + Self::QuotaExceeded => ffi::GST_MEDIA_SOURCE_ERROR_QUOTA_EXCEEDED, + Self::__Unknown(value) => value, + } + } +} + +#[doc(hidden)] +impl FromGlib for MediaSourceError { + #[inline] + unsafe fn from_glib(value: ffi::GstMediaSourceError) -> Self { + skip_assert_initialized!(); + + match value { + ffi::GST_MEDIA_SOURCE_ERROR_INVALID_STATE => Self::InvalidState, + ffi::GST_MEDIA_SOURCE_ERROR_TYPE => Self::Type, + ffi::GST_MEDIA_SOURCE_ERROR_NOT_SUPPORTED => Self::NotSupported, + ffi::GST_MEDIA_SOURCE_ERROR_NOT_FOUND => Self::NotFound, + ffi::GST_MEDIA_SOURCE_ERROR_QUOTA_EXCEEDED => Self::QuotaExceeded, + value => Self::__Unknown(value), + } + } +} + +impl glib::error::ErrorDomain for MediaSourceError { + #[inline] + fn domain() -> glib::Quark { + skip_assert_initialized!(); + + unsafe { from_glib(ffi::gst_media_source_error_quark()) } + } + + #[inline] + fn code(self) -> i32 { + self.into_glib() + } + + #[inline] + #[allow(clippy::match_single_binding)] + fn from(code: i32) -> Option { + skip_assert_initialized!(); + match unsafe { from_glib(code) } { + value => Some(value), + } + } +} + +impl StaticType for MediaSourceError { + #[inline] + #[doc(alias = "gst_media_source_error_get_type")] + fn static_type() -> glib::Type { + unsafe { from_glib(ffi::gst_media_source_error_get_type()) } + } +} + +impl glib::HasParamSpec for MediaSourceError { + type ParamSpec = glib::ParamSpecEnum; + type SetValue = Self; + type BuilderFn = fn(&str, Self) -> glib::ParamSpecEnumBuilder; + + fn param_spec_builder() -> Self::BuilderFn { + Self::ParamSpec::builder_with_default + } +} + +impl glib::value::ValueType for MediaSourceError { + type Type = Self; +} + +unsafe impl<'a> glib::value::FromValue<'a> for MediaSourceError { + type Checker = glib::value::GenericValueTypeChecker; + + #[inline] + unsafe fn from_value(value: &'a glib::Value) -> Self { + skip_assert_initialized!(); + from_glib(glib::gobject_ffi::g_value_get_enum(value.to_glib_none().0)) + } +} + +impl ToValue for MediaSourceError { + #[inline] + fn to_value(&self) -> glib::Value { + let mut value = glib::Value::for_value_type::(); + unsafe { + glib::gobject_ffi::g_value_set_enum(value.to_glib_none_mut().0, self.into_glib()); + } + value + } + + #[inline] + fn value_type(&self) -> glib::Type { + Self::static_type() + } +} + +impl From for glib::Value { + #[inline] + fn from(v: MediaSourceError) -> Self { + skip_assert_initialized!(); + ToValue::to_value(&v) + } +} + +#[derive(Debug, Eq, PartialEq, Ord, PartialOrd, Hash, Clone, Copy)] +#[non_exhaustive] +#[doc(alias = "GstMediaSourceReadyState")] +pub enum MediaSourceReadyState { + #[doc(alias = "GST_MEDIA_SOURCE_READY_STATE_CLOSED")] + Closed, + #[doc(alias = "GST_MEDIA_SOURCE_READY_STATE_OPEN")] + Open, + #[doc(alias = "GST_MEDIA_SOURCE_READY_STATE_ENDED")] + Ended, + #[doc(hidden)] + __Unknown(i32), +} + +#[doc(hidden)] +impl IntoGlib for MediaSourceReadyState { + type GlibType = ffi::GstMediaSourceReadyState; + + #[inline] + fn into_glib(self) -> ffi::GstMediaSourceReadyState { + match self { + Self::Closed => ffi::GST_MEDIA_SOURCE_READY_STATE_CLOSED, + Self::Open => ffi::GST_MEDIA_SOURCE_READY_STATE_OPEN, + Self::Ended => ffi::GST_MEDIA_SOURCE_READY_STATE_ENDED, + Self::__Unknown(value) => value, + } + } +} + +#[doc(hidden)] +impl FromGlib for MediaSourceReadyState { + #[inline] + unsafe fn from_glib(value: ffi::GstMediaSourceReadyState) -> Self { + skip_assert_initialized!(); + + match value { + ffi::GST_MEDIA_SOURCE_READY_STATE_CLOSED => Self::Closed, + ffi::GST_MEDIA_SOURCE_READY_STATE_OPEN => Self::Open, + ffi::GST_MEDIA_SOURCE_READY_STATE_ENDED => Self::Ended, + value => Self::__Unknown(value), + } + } +} + +impl StaticType for MediaSourceReadyState { + #[inline] + #[doc(alias = "gst_media_source_ready_state_get_type")] + fn static_type() -> glib::Type { + unsafe { from_glib(ffi::gst_media_source_ready_state_get_type()) } + } +} + +impl glib::HasParamSpec for MediaSourceReadyState { + type ParamSpec = glib::ParamSpecEnum; + type SetValue = Self; + type BuilderFn = fn(&str, Self) -> glib::ParamSpecEnumBuilder; + + fn param_spec_builder() -> Self::BuilderFn { + Self::ParamSpec::builder_with_default + } +} + +impl glib::value::ValueType for MediaSourceReadyState { + type Type = Self; +} + +unsafe impl<'a> glib::value::FromValue<'a> for MediaSourceReadyState { + type Checker = glib::value::GenericValueTypeChecker; + + #[inline] + unsafe fn from_value(value: &'a glib::Value) -> Self { + skip_assert_initialized!(); + from_glib(glib::gobject_ffi::g_value_get_enum(value.to_glib_none().0)) + } +} + +impl ToValue for MediaSourceReadyState { + #[inline] + fn to_value(&self) -> glib::Value { + let mut value = glib::Value::for_value_type::(); + unsafe { + glib::gobject_ffi::g_value_set_enum(value.to_glib_none_mut().0, self.into_glib()); + } + value + } + + #[inline] + fn value_type(&self) -> glib::Type { + Self::static_type() + } +} + +impl From for glib::Value { + #[inline] + fn from(v: MediaSourceReadyState) -> Self { + skip_assert_initialized!(); + ToValue::to_value(&v) + } +} + +#[derive(Debug, Eq, PartialEq, Ord, PartialOrd, Hash, Clone, Copy)] +#[non_exhaustive] +#[doc(alias = "GstMseSrcReadyState")] +pub enum MseSrcReadyState { + #[doc(alias = "GST_MSE_SRC_READY_STATE_HAVE_NOTHING")] + Nothing, + #[doc(alias = "GST_MSE_SRC_READY_STATE_HAVE_METADATA")] + Metadata, + #[doc(alias = "GST_MSE_SRC_READY_STATE_HAVE_CURRENT_DATA")] + CurrentData, + #[doc(alias = "GST_MSE_SRC_READY_STATE_HAVE_FUTURE_DATA")] + FutureData, + #[doc(alias = "GST_MSE_SRC_READY_STATE_HAVE_ENOUGH_DATA")] + EnoughData, + #[doc(hidden)] + __Unknown(i32), +} + +#[doc(hidden)] +impl IntoGlib for MseSrcReadyState { + type GlibType = ffi::GstMseSrcReadyState; + + #[inline] + fn into_glib(self) -> ffi::GstMseSrcReadyState { + match self { + Self::Nothing => ffi::GST_MSE_SRC_READY_STATE_HAVE_NOTHING, + Self::Metadata => ffi::GST_MSE_SRC_READY_STATE_HAVE_METADATA, + Self::CurrentData => ffi::GST_MSE_SRC_READY_STATE_HAVE_CURRENT_DATA, + Self::FutureData => ffi::GST_MSE_SRC_READY_STATE_HAVE_FUTURE_DATA, + Self::EnoughData => ffi::GST_MSE_SRC_READY_STATE_HAVE_ENOUGH_DATA, + Self::__Unknown(value) => value, + } + } +} + +#[doc(hidden)] +impl FromGlib for MseSrcReadyState { + #[inline] + unsafe fn from_glib(value: ffi::GstMseSrcReadyState) -> Self { + skip_assert_initialized!(); + + match value { + ffi::GST_MSE_SRC_READY_STATE_HAVE_NOTHING => Self::Nothing, + ffi::GST_MSE_SRC_READY_STATE_HAVE_METADATA => Self::Metadata, + ffi::GST_MSE_SRC_READY_STATE_HAVE_CURRENT_DATA => Self::CurrentData, + ffi::GST_MSE_SRC_READY_STATE_HAVE_FUTURE_DATA => Self::FutureData, + ffi::GST_MSE_SRC_READY_STATE_HAVE_ENOUGH_DATA => Self::EnoughData, + value => Self::__Unknown(value), + } + } +} + +impl StaticType for MseSrcReadyState { + #[inline] + #[doc(alias = "gst_mse_src_ready_state_get_type")] + fn static_type() -> glib::Type { + unsafe { from_glib(ffi::gst_mse_src_ready_state_get_type()) } + } +} + +impl glib::HasParamSpec for MseSrcReadyState { + type ParamSpec = glib::ParamSpecEnum; + type SetValue = Self; + type BuilderFn = fn(&str, Self) -> glib::ParamSpecEnumBuilder; + + fn param_spec_builder() -> Self::BuilderFn { + Self::ParamSpec::builder_with_default + } +} + +impl glib::value::ValueType for MseSrcReadyState { + type Type = Self; +} + +unsafe impl<'a> glib::value::FromValue<'a> for MseSrcReadyState { + type Checker = glib::value::GenericValueTypeChecker; + + #[inline] + unsafe fn from_value(value: &'a glib::Value) -> Self { + skip_assert_initialized!(); + from_glib(glib::gobject_ffi::g_value_get_enum(value.to_glib_none().0)) + } +} + +impl ToValue for MseSrcReadyState { + #[inline] + fn to_value(&self) -> glib::Value { + let mut value = glib::Value::for_value_type::(); + unsafe { + glib::gobject_ffi::g_value_set_enum(value.to_glib_none_mut().0, self.into_glib()); + } + value + } + + #[inline] + fn value_type(&self) -> glib::Type { + Self::static_type() + } +} + +impl From for glib::Value { + #[inline] + fn from(v: MseSrcReadyState) -> Self { + skip_assert_initialized!(); + ToValue::to_value(&v) + } +} + +#[derive(Debug, Eq, PartialEq, Ord, PartialOrd, Hash, Clone, Copy)] +#[non_exhaustive] +#[doc(alias = "GstSourceBufferAppendMode")] +pub enum SourceBufferAppendMode { + #[doc(alias = "GST_SOURCE_BUFFER_APPEND_MODE_SEGMENTS")] + Segments, + #[doc(alias = "GST_SOURCE_BUFFER_APPEND_MODE_SEQUENCE")] + Sequence, + #[doc(hidden)] + __Unknown(i32), +} + +#[doc(hidden)] +impl IntoGlib for SourceBufferAppendMode { + type GlibType = ffi::GstSourceBufferAppendMode; + + #[inline] + fn into_glib(self) -> ffi::GstSourceBufferAppendMode { + match self { + Self::Segments => ffi::GST_SOURCE_BUFFER_APPEND_MODE_SEGMENTS, + Self::Sequence => ffi::GST_SOURCE_BUFFER_APPEND_MODE_SEQUENCE, + Self::__Unknown(value) => value, + } + } +} + +#[doc(hidden)] +impl FromGlib for SourceBufferAppendMode { + #[inline] + unsafe fn from_glib(value: ffi::GstSourceBufferAppendMode) -> Self { + skip_assert_initialized!(); + + match value { + ffi::GST_SOURCE_BUFFER_APPEND_MODE_SEGMENTS => Self::Segments, + ffi::GST_SOURCE_BUFFER_APPEND_MODE_SEQUENCE => Self::Sequence, + value => Self::__Unknown(value), + } + } +} + +impl StaticType for SourceBufferAppendMode { + #[inline] + #[doc(alias = "gst_source_buffer_append_mode_get_type")] + fn static_type() -> glib::Type { + unsafe { from_glib(ffi::gst_source_buffer_append_mode_get_type()) } + } +} + +impl glib::HasParamSpec for SourceBufferAppendMode { + type ParamSpec = glib::ParamSpecEnum; + type SetValue = Self; + type BuilderFn = fn(&str, Self) -> glib::ParamSpecEnumBuilder; + + fn param_spec_builder() -> Self::BuilderFn { + Self::ParamSpec::builder_with_default + } +} + +impl glib::value::ValueType for SourceBufferAppendMode { + type Type = Self; +} + +unsafe impl<'a> glib::value::FromValue<'a> for SourceBufferAppendMode { + type Checker = glib::value::GenericValueTypeChecker; + + #[inline] + unsafe fn from_value(value: &'a glib::Value) -> Self { + skip_assert_initialized!(); + from_glib(glib::gobject_ffi::g_value_get_enum(value.to_glib_none().0)) + } +} + +impl ToValue for SourceBufferAppendMode { + #[inline] + fn to_value(&self) -> glib::Value { + let mut value = glib::Value::for_value_type::(); + unsafe { + glib::gobject_ffi::g_value_set_enum(value.to_glib_none_mut().0, self.into_glib()); + } + value + } + + #[inline] + fn value_type(&self) -> glib::Type { + Self::static_type() + } +} + +impl From for glib::Value { + #[inline] + fn from(v: SourceBufferAppendMode) -> Self { + skip_assert_initialized!(); + ToValue::to_value(&v) + } +} diff --git a/gstreamer-mse/sys/Cargo.toml b/gstreamer-mse/sys/Cargo.toml new file mode 100644 index 000000000..757d3875f --- /dev/null +++ b/gstreamer-mse/sys/Cargo.toml @@ -0,0 +1,41 @@ +[package] +name = "gstreamer-mse-sys" +version = "0.0.1" +edition = "2021" +build = "build.rs" +authors = ["Sebastian Dröge ", "Simon Wülker "] +description = "FFI bindings to libgstmse-1.0" +documentation = "https://gstreamer.pages.freedesktop.org/gstreamer-rs/stable/latest/docs/gstreamer_mse_sys/" +keywords = ["ffi", "gstreamer", "gnome", "multimedia"] +readme = "README.md" + +[package.metadata.system-deps.gstreamer_mse_1_0] +name = "gstreamer-mse-1.0" +version = "1.26" + +[package.metadata.docs.rs] +rustc-args = ["--cfg", "docsrs"] +rustdoc-args = ["--cfg", "docsrs", "--generate-link-to-definition"] +all-features = true + +[lib] +name = "gstreamer_mse_sys" + +[dependencies] +libc = "0.2" + +[dependencies.glib-sys] +workspace = true + +[dependencies.gstreamer-sys] +workspace = true + +[build-dependencies] +system-deps = "7" + +[dev-dependencies] +shell-words = "1.0.0" +tempfile = "3" + +[features] +v1_24 = [] diff --git a/gstreamer-mse/sys/Gir.toml b/gstreamer-mse/sys/Gir.toml new file mode 100644 index 000000000..450c91daa --- /dev/null +++ b/gstreamer-mse/sys/Gir.toml @@ -0,0 +1,22 @@ +[options] +girs_directories = ["../../gir-files", "../../gst-gir-files"] +library = "GstMse" +version = "1.0" +min_cfg_version = "1.26" +work_mode = "sys" +single_version_file = true + +external_libraries = [ + "GLib", +] + +generate = [ +] + +manual = [ + "Gst.Element", + "Gst.Pad", +] + +[external_libraries] +gstreamer="Gst" diff --git a/gstreamer-mse/sys/build.rs b/gstreamer-mse/sys/build.rs new file mode 100644 index 000000000..29420c9ee --- /dev/null +++ b/gstreamer-mse/sys/build.rs @@ -0,0 +1,18 @@ +// This file was generated by gir (https://github.com/gtk-rs/gir) +// from gir-files (https://github.com/gtk-rs/gir-files) +// from gst-gir-files (https://gitlab.freedesktop.org/gstreamer/gir-files-rs.git) +// DO NOT EDIT + +#[cfg(not(docsrs))] +use std::process; + +#[cfg(docsrs)] +fn main() {} // prevent linking libraries to avoid documentation failure + +#[cfg(not(docsrs))] +fn main() { + if let Err(s) = system_deps::Config::new().probe() { + println!("cargo:warning={s}"); + process::exit(1); + } +} diff --git a/gstreamer-mse/sys/src/auto/versions.txt b/gstreamer-mse/sys/src/auto/versions.txt new file mode 100644 index 000000000..5cb83d42b --- /dev/null +++ b/gstreamer-mse/sys/src/auto/versions.txt @@ -0,0 +1,3 @@ +Generated by gir (https://github.com/gtk-rs/gir @ 491114ad76bd) +from gir-files (https://github.com/gtk-rs/gir-files @ 56728a5eb215) +from gst-gir-files (https://gitlab.freedesktop.org/gstreamer/gir-files-rs.git @ ce667eb782d7) diff --git a/gstreamer-mse/sys/src/lib.rs b/gstreamer-mse/sys/src/lib.rs new file mode 100644 index 000000000..8c09bae29 --- /dev/null +++ b/gstreamer-mse/sys/src/lib.rs @@ -0,0 +1,401 @@ +// This file was generated by gir (https://github.com/gtk-rs/gir) +// from gir-files (https://github.com/gtk-rs/gir-files) +// from gst-gir-files (https://gitlab.freedesktop.org/gstreamer/gir-files-rs.git) +// DO NOT EDIT + +#![allow(non_camel_case_types, non_upper_case_globals, non_snake_case)] +#![allow( + clippy::approx_constant, + clippy::type_complexity, + clippy::unreadable_literal, + clippy::upper_case_acronyms +)] +#![cfg_attr(docsrs, feature(doc_cfg))] + +use glib_sys as glib; +use gstreamer_sys as gst; + +#[cfg(unix)] +#[allow(unused_imports)] +use libc::{dev_t, gid_t, pid_t, socklen_t, uid_t}; +#[allow(unused_imports)] +use libc::{intptr_t, off_t, size_t, ssize_t, time_t, uintptr_t, FILE}; +#[allow(unused_imports)] +use std::ffi::{ + c_char, c_double, c_float, c_int, c_long, c_short, c_uchar, c_uint, c_ulong, c_ushort, c_void, +}; + +#[allow(unused_imports)] +use glib::{gboolean, gconstpointer, gpointer, GType}; + +// Enums +pub type GstMediaSourceEOSError = c_int; +pub const GST_MEDIA_SOURCE_EOS_ERROR_NONE: GstMediaSourceEOSError = 0; +pub const GST_MEDIA_SOURCE_EOS_ERROR_NETWORK: GstMediaSourceEOSError = 1; +pub const GST_MEDIA_SOURCE_EOS_ERROR_DECODE: GstMediaSourceEOSError = 2; + +pub type GstMediaSourceError = c_int; +pub const GST_MEDIA_SOURCE_ERROR_INVALID_STATE: GstMediaSourceError = 0; +pub const GST_MEDIA_SOURCE_ERROR_TYPE: GstMediaSourceError = 1; +pub const GST_MEDIA_SOURCE_ERROR_NOT_SUPPORTED: GstMediaSourceError = 2; +pub const GST_MEDIA_SOURCE_ERROR_NOT_FOUND: GstMediaSourceError = 3; +pub const GST_MEDIA_SOURCE_ERROR_QUOTA_EXCEEDED: GstMediaSourceError = 4; + +pub type GstMediaSourceReadyState = c_int; +pub const GST_MEDIA_SOURCE_READY_STATE_CLOSED: GstMediaSourceReadyState = 0; +pub const GST_MEDIA_SOURCE_READY_STATE_OPEN: GstMediaSourceReadyState = 1; +pub const GST_MEDIA_SOURCE_READY_STATE_ENDED: GstMediaSourceReadyState = 2; + +pub type GstMseSrcReadyState = c_int; +pub const GST_MSE_SRC_READY_STATE_HAVE_NOTHING: GstMseSrcReadyState = 0; +pub const GST_MSE_SRC_READY_STATE_HAVE_METADATA: GstMseSrcReadyState = 1; +pub const GST_MSE_SRC_READY_STATE_HAVE_CURRENT_DATA: GstMseSrcReadyState = 2; +pub const GST_MSE_SRC_READY_STATE_HAVE_FUTURE_DATA: GstMseSrcReadyState = 3; +pub const GST_MSE_SRC_READY_STATE_HAVE_ENOUGH_DATA: GstMseSrcReadyState = 4; + +pub type GstSourceBufferAppendMode = c_int; +pub const GST_SOURCE_BUFFER_APPEND_MODE_SEGMENTS: GstSourceBufferAppendMode = 0; +pub const GST_SOURCE_BUFFER_APPEND_MODE_SEQUENCE: GstSourceBufferAppendMode = 1; + +// Records +#[derive(Copy, Clone)] +#[repr(C)] +pub struct GstMediaSourceClass { + pub parent_class: gst::GstObjectClass, +} + +impl ::std::fmt::Debug for GstMediaSourceClass { + fn fmt(&self, f: &mut ::std::fmt::Formatter) -> ::std::fmt::Result { + f.debug_struct(&format!("GstMediaSourceClass @ {self:p}")) + .field("parent_class", &self.parent_class) + .finish() + } +} + +#[derive(Copy, Clone)] +#[repr(C)] +pub struct GstMediaSourceRange { + pub start: gst::GstClockTime, + pub end: gst::GstClockTime, +} + +impl ::std::fmt::Debug for GstMediaSourceRange { + fn fmt(&self, f: &mut ::std::fmt::Formatter) -> ::std::fmt::Result { + f.debug_struct(&format!("GstMediaSourceRange @ {self:p}")) + .field("start", &self.start) + .field("end", &self.end) + .finish() + } +} + +#[derive(Copy, Clone)] +#[repr(C)] +pub struct GstMseSrcClass { + pub parent_class: gst::GstElementClass, +} + +impl ::std::fmt::Debug for GstMseSrcClass { + fn fmt(&self, f: &mut ::std::fmt::Formatter) -> ::std::fmt::Result { + f.debug_struct(&format!("GstMseSrcClass @ {self:p}")) + .field("parent_class", &self.parent_class) + .finish() + } +} + +#[derive(Copy, Clone)] +#[repr(C)] +pub struct GstMseSrcPadClass { + pub parent_class: gst::GstPadClass, +} + +impl ::std::fmt::Debug for GstMseSrcPadClass { + fn fmt(&self, f: &mut ::std::fmt::Formatter) -> ::std::fmt::Result { + f.debug_struct(&format!("GstMseSrcPadClass @ {self:p}")) + .field("parent_class", &self.parent_class) + .finish() + } +} + +#[derive(Copy, Clone)] +#[repr(C)] +pub struct GstSourceBufferClass { + pub parent_class: gst::GstObjectClass, +} + +impl ::std::fmt::Debug for GstSourceBufferClass { + fn fmt(&self, f: &mut ::std::fmt::Formatter) -> ::std::fmt::Result { + f.debug_struct(&format!("GstSourceBufferClass @ {self:p}")) + .field("parent_class", &self.parent_class) + .finish() + } +} + +#[derive(Copy, Clone)] +#[repr(C)] +pub struct GstSourceBufferInterval { + pub start: gst::GstClockTime, + pub end: gst::GstClockTime, +} + +impl ::std::fmt::Debug for GstSourceBufferInterval { + fn fmt(&self, f: &mut ::std::fmt::Formatter) -> ::std::fmt::Result { + f.debug_struct(&format!("GstSourceBufferInterval @ {self:p}")) + .field("start", &self.start) + .field("end", &self.end) + .finish() + } +} + +#[derive(Copy, Clone)] +#[repr(C)] +pub struct GstSourceBufferListClass { + pub parent_class: gst::GstObjectClass, +} + +impl ::std::fmt::Debug for GstSourceBufferListClass { + fn fmt(&self, f: &mut ::std::fmt::Formatter) -> ::std::fmt::Result { + f.debug_struct(&format!("GstSourceBufferListClass @ {self:p}")) + .field("parent_class", &self.parent_class) + .finish() + } +} + +// Classes +#[repr(C)] +#[allow(dead_code)] +pub struct GstMediaSource { + _data: [u8; 0], + _marker: core::marker::PhantomData<(*mut u8, core::marker::PhantomPinned)>, +} + +impl ::std::fmt::Debug for GstMediaSource { + fn fmt(&self, f: &mut ::std::fmt::Formatter) -> ::std::fmt::Result { + f.debug_struct(&format!("GstMediaSource @ {self:p}")) + .finish() + } +} + +#[repr(C)] +#[allow(dead_code)] +pub struct GstMseSrc { + _data: [u8; 0], + _marker: core::marker::PhantomData<(*mut u8, core::marker::PhantomPinned)>, +} + +impl ::std::fmt::Debug for GstMseSrc { + fn fmt(&self, f: &mut ::std::fmt::Formatter) -> ::std::fmt::Result { + f.debug_struct(&format!("GstMseSrc @ {self:p}")).finish() + } +} + +#[repr(C)] +#[allow(dead_code)] +pub struct GstMseSrcPad { + _data: [u8; 0], + _marker: core::marker::PhantomData<(*mut u8, core::marker::PhantomPinned)>, +} + +impl ::std::fmt::Debug for GstMseSrcPad { + fn fmt(&self, f: &mut ::std::fmt::Formatter) -> ::std::fmt::Result { + f.debug_struct(&format!("GstMseSrcPad @ {self:p}")).finish() + } +} + +#[repr(C)] +#[allow(dead_code)] +pub struct GstSourceBuffer { + _data: [u8; 0], + _marker: core::marker::PhantomData<(*mut u8, core::marker::PhantomPinned)>, +} + +impl ::std::fmt::Debug for GstSourceBuffer { + fn fmt(&self, f: &mut ::std::fmt::Formatter) -> ::std::fmt::Result { + f.debug_struct(&format!("GstSourceBuffer @ {self:p}")) + .finish() + } +} + +#[repr(C)] +#[allow(dead_code)] +pub struct GstSourceBufferList { + _data: [u8; 0], + _marker: core::marker::PhantomData<(*mut u8, core::marker::PhantomPinned)>, +} + +impl ::std::fmt::Debug for GstSourceBufferList { + fn fmt(&self, f: &mut ::std::fmt::Formatter) -> ::std::fmt::Result { + f.debug_struct(&format!("GstSourceBufferList @ {self:p}")) + .finish() + } +} + +extern "C" { + + //========================================================================= + // GstMediaSourceEOSError + //========================================================================= + pub fn gst_media_source_eos_error_get_type() -> GType; + + //========================================================================= + // GstMediaSourceError + //========================================================================= + pub fn gst_media_source_error_get_type() -> GType; + pub fn gst_media_source_error_quark() -> glib::GQuark; + + //========================================================================= + // GstMediaSourceReadyState + //========================================================================= + pub fn gst_media_source_ready_state_get_type() -> GType; + + //========================================================================= + // GstMseSrcReadyState + //========================================================================= + pub fn gst_mse_src_ready_state_get_type() -> GType; + + //========================================================================= + // GstSourceBufferAppendMode + //========================================================================= + pub fn gst_source_buffer_append_mode_get_type() -> GType; + + //========================================================================= + // GstMediaSource + //========================================================================= + pub fn gst_media_source_get_type() -> GType; + pub fn gst_media_source_new() -> *mut GstMediaSource; + pub fn gst_media_source_is_type_supported(type_: *const c_char) -> gboolean; + pub fn gst_media_source_add_source_buffer( + self_: *mut GstMediaSource, + type_: *const c_char, + error: *mut *mut glib::GError, + ) -> *mut GstSourceBuffer; + pub fn gst_media_source_attach(self_: *mut GstMediaSource, element: *mut GstMseSrc); + pub fn gst_media_source_clear_live_seekable_range( + self_: *mut GstMediaSource, + error: *mut *mut glib::GError, + ) -> gboolean; + pub fn gst_media_source_detach(self_: *mut GstMediaSource); + pub fn gst_media_source_end_of_stream( + self_: *mut GstMediaSource, + eos_error: GstMediaSourceEOSError, + error: *mut *mut glib::GError, + ) -> gboolean; + pub fn gst_media_source_get_active_source_buffers( + self_: *mut GstMediaSource, + ) -> *mut GstSourceBufferList; + pub fn gst_media_source_get_duration(self_: *mut GstMediaSource) -> gst::GstClockTime; + pub fn gst_media_source_get_live_seekable_range( + self_: *mut GstMediaSource, + range: *mut GstMediaSourceRange, + ); + pub fn gst_media_source_get_position(self_: *mut GstMediaSource) -> gst::GstClockTime; + pub fn gst_media_source_get_ready_state(self_: *mut GstMediaSource) + -> GstMediaSourceReadyState; + pub fn gst_media_source_get_source_buffers( + self_: *mut GstMediaSource, + ) -> *mut GstSourceBufferList; + pub fn gst_media_source_remove_source_buffer( + self_: *mut GstMediaSource, + buffer: *mut GstSourceBuffer, + error: *mut *mut glib::GError, + ) -> gboolean; + pub fn gst_media_source_set_duration( + self_: *mut GstMediaSource, + duration: gst::GstClockTime, + error: *mut *mut glib::GError, + ) -> gboolean; + pub fn gst_media_source_set_live_seekable_range( + self_: *mut GstMediaSource, + start: gst::GstClockTime, + end: gst::GstClockTime, + error: *mut *mut glib::GError, + ) -> gboolean; + + //========================================================================= + // GstMseSrc + //========================================================================= + pub fn gst_mse_src_get_type() -> GType; + pub fn gst_mse_src_get_duration(self_: *mut GstMseSrc) -> gst::GstClockTime; + pub fn gst_mse_src_get_n_audio(self_: *mut GstMseSrc) -> c_uint; + pub fn gst_mse_src_get_n_text(self_: *mut GstMseSrc) -> c_uint; + pub fn gst_mse_src_get_n_video(self_: *mut GstMseSrc) -> c_uint; + pub fn gst_mse_src_get_position(self_: *mut GstMseSrc) -> gst::GstClockTime; + pub fn gst_mse_src_get_ready_state(self_: *mut GstMseSrc) -> GstMseSrcReadyState; + + //========================================================================= + // GstMseSrcPad + //========================================================================= + pub fn gst_mse_src_pad_get_type() -> GType; + + //========================================================================= + // GstSourceBuffer + //========================================================================= + pub fn gst_source_buffer_get_type() -> GType; + pub fn gst_source_buffer_abort( + self_: *mut GstSourceBuffer, + error: *mut *mut glib::GError, + ) -> gboolean; + pub fn gst_source_buffer_append_buffer( + self_: *mut GstSourceBuffer, + buf: *mut gst::GstBuffer, + error: *mut *mut glib::GError, + ) -> gboolean; + pub fn gst_source_buffer_change_content_type( + self_: *mut GstSourceBuffer, + type_: *const c_char, + error: *mut *mut glib::GError, + ) -> gboolean; + pub fn gst_source_buffer_get_append_mode( + self_: *mut GstSourceBuffer, + ) -> GstSourceBufferAppendMode; + pub fn gst_source_buffer_get_append_window_end( + self_: *mut GstSourceBuffer, + ) -> gst::GstClockTime; + pub fn gst_source_buffer_get_append_window_start( + self_: *mut GstSourceBuffer, + ) -> gst::GstClockTime; + pub fn gst_source_buffer_get_buffered( + self_: *mut GstSourceBuffer, + error: *mut *mut glib::GError, + ) -> *mut glib::GArray; + pub fn gst_source_buffer_get_content_type(self_: *mut GstSourceBuffer) -> *mut c_char; + pub fn gst_source_buffer_get_timestamp_offset(self_: *mut GstSourceBuffer) + -> gst::GstClockTime; + pub fn gst_source_buffer_get_updating(self_: *mut GstSourceBuffer) -> gboolean; + pub fn gst_source_buffer_remove( + self_: *mut GstSourceBuffer, + start: gst::GstClockTime, + end: gst::GstClockTime, + error: *mut *mut glib::GError, + ) -> gboolean; + pub fn gst_source_buffer_set_append_mode( + self_: *mut GstSourceBuffer, + mode: GstSourceBufferAppendMode, + error: *mut *mut glib::GError, + ) -> gboolean; + pub fn gst_source_buffer_set_append_window_end( + self_: *mut GstSourceBuffer, + end: gst::GstClockTime, + error: *mut *mut glib::GError, + ) -> gboolean; + pub fn gst_source_buffer_set_append_window_start( + self_: *mut GstSourceBuffer, + start: gst::GstClockTime, + error: *mut *mut glib::GError, + ) -> gboolean; + pub fn gst_source_buffer_set_timestamp_offset( + self_: *mut GstSourceBuffer, + offset: gst::GstClockTime, + error: *mut *mut glib::GError, + ) -> gboolean; + + //========================================================================= + // GstSourceBufferList + //========================================================================= + pub fn gst_source_buffer_list_get_type() -> GType; + pub fn gst_source_buffer_list_get_length(self_: *mut GstSourceBufferList) -> c_uint; + pub fn gst_source_buffer_list_index( + self_: *mut GstSourceBufferList, + index: c_uint, + ) -> *mut GstSourceBuffer; + +} diff --git a/gstreamer-mse/sys/tests/abi.rs b/gstreamer-mse/sys/tests/abi.rs new file mode 100644 index 000000000..09597dd25 --- /dev/null +++ b/gstreamer-mse/sys/tests/abi.rs @@ -0,0 +1,310 @@ +// This file was generated by gir (https://github.com/gtk-rs/gir) +// from gir-files (https://github.com/gtk-rs/gir-files) +// from gst-gir-files (https://gitlab.freedesktop.org/gstreamer/gir-files-rs.git) +// DO NOT EDIT + +#![cfg(unix)] + +use gstreamer_mse_sys::*; +use std::env; +use std::error::Error; +use std::ffi::OsString; +use std::mem::{align_of, size_of}; +use std::path::Path; +use std::process::{Command, Stdio}; +use std::str; +use tempfile::Builder; + +static PACKAGES: &[&str] = &["gstreamer-mse-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 _Generic + args.push("-std=c11".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(Self { args }) + } + + 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 {cmd:?} failed, {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 pkg_config = env::var_os("PKG_CONFIG").unwrap_or_else(|| OsString::from("pkg-config")); + let mut cmd = Command::new(pkg_config); + cmd.arg("--cflags"); + cmd.args(packages); + cmd.stderr(Stdio::inherit()); + let out = cmd.output()?; + if !out.status.success() { + let (status, stdout) = (out.status, String::from_utf8_lossy(&out.stdout)); + return Err(format!("command {cmd:?} failed, {status:?}\nstdout: {stdout}").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, +} + +impl Results { + fn record_passed(&mut self) { + self.passed += 1; + } + fn record_failed(&mut self) { + self.failed += 1; + } + fn summary(&self) -> String { + format!("{} passed; {} failed", self.passed, self.failed) + } + 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 mut c_constants: Vec<(String, String)> = Vec::new(); + + for l in get_c_output("constant").unwrap().lines() { + let (name, value) = l.split_once(';').expect("Missing ';' separator"); + c_constants.push((name.to_owned(), value.to_owned())); + } + + let mut results = Results::default(); + + for ((rust_name, rust_value), (c_name, c_value)) in + RUST_CONSTANTS.iter().zip(c_constants.iter()) + { + if rust_name != c_name { + results.record_failed(); + eprintln!("Name mismatch:\nRust: {rust_name:?}\nC: {c_name:?}"); + continue; + } + + if rust_value != c_value { + results.record_failed(); + eprintln!( + "Constant value mismatch for {rust_name}\nRust: {rust_value:?}\nC: {c_value:?}", + ); + continue; + } + + results.record_passed(); + } + + results.expect_total_success(); +} + +#[test] +fn cross_validate_layout_with_c() { + let mut c_layouts = Vec::new(); + + for l in get_c_output("layout").unwrap().lines() { + let (name, value) = l.split_once(';').expect("Missing first ';' separator"); + let (size, alignment) = value.split_once(';').expect("Missing second ';' separator"); + let size = size.parse().expect("Failed to parse size"); + let alignment = alignment.parse().expect("Failed to parse alignment"); + c_layouts.push((name.to_owned(), Layout { size, alignment })); + } + + let mut results = Results::default(); + + for ((rust_name, rust_layout), (c_name, c_layout)) in RUST_LAYOUTS.iter().zip(c_layouts.iter()) + { + if rust_name != c_name { + results.record_failed(); + eprintln!("Name mismatch:\nRust: {rust_name:?}\nC: {c_name:?}"); + continue; + } + + if rust_layout != c_layout { + results.record_failed(); + eprintln!("Layout mismatch for {rust_name}\nRust: {rust_layout:?}\nC: {c_layout:?}",); + continue; + } + + results.record_passed(); + } + + results.expect_total_success(); +} + +fn get_c_output(name: &str) -> Result> { + let tmpdir = Builder::new().prefix("abi").tempdir()?; + let exe = tmpdir.path().join(name); + let c_file = Path::new("tests").join(name).with_extension("c"); + + let cc = Compiler::new().expect("configured compiler"); + cc.compile(&c_file, &exe)?; + + let mut cmd = Command::new(exe); + cmd.stderr(Stdio::inherit()); + let out = cmd.output()?; + if !out.status.success() { + let (status, stdout) = (out.status, String::from_utf8_lossy(&out.stdout)); + return Err(format!("command {cmd:?} failed, {status:?}\nstdout: {stdout}").into()); + } + + Ok(String::from_utf8(out.stdout)?) +} + +const RUST_LAYOUTS: &[(&str, Layout)] = &[ + ( + "GstMediaSourceClass", + Layout { + size: size_of::(), + alignment: align_of::(), + }, + ), + ( + "GstMediaSourceEOSError", + Layout { + size: size_of::(), + alignment: align_of::(), + }, + ), + ( + "GstMediaSourceError", + Layout { + size: size_of::(), + alignment: align_of::(), + }, + ), + ( + "GstMediaSourceRange", + Layout { + size: size_of::(), + alignment: align_of::(), + }, + ), + ( + "GstMediaSourceReadyState", + Layout { + size: size_of::(), + alignment: align_of::(), + }, + ), + ( + "GstMseSrcClass", + Layout { + size: size_of::(), + alignment: align_of::(), + }, + ), + ( + "GstMseSrcPadClass", + Layout { + size: size_of::(), + alignment: align_of::(), + }, + ), + ( + "GstMseSrcReadyState", + Layout { + size: size_of::(), + alignment: align_of::(), + }, + ), + ( + "GstSourceBufferAppendMode", + Layout { + size: size_of::(), + alignment: align_of::(), + }, + ), + ( + "GstSourceBufferClass", + Layout { + size: size_of::(), + alignment: align_of::(), + }, + ), + ( + "GstSourceBufferInterval", + Layout { + size: size_of::(), + alignment: align_of::(), + }, + ), + ( + "GstSourceBufferListClass", + Layout { + size: size_of::(), + alignment: align_of::(), + }, + ), +]; + +const RUST_CONSTANTS: &[(&str, &str)] = &[ + ("(gint) GST_MEDIA_SOURCE_EOS_ERROR_DECODE", "2"), + ("(gint) GST_MEDIA_SOURCE_EOS_ERROR_NETWORK", "1"), + ("(gint) GST_MEDIA_SOURCE_EOS_ERROR_NONE", "0"), + ("(gint) GST_MEDIA_SOURCE_ERROR_INVALID_STATE", "0"), + ("(gint) GST_MEDIA_SOURCE_ERROR_NOT_FOUND", "3"), + ("(gint) GST_MEDIA_SOURCE_ERROR_NOT_SUPPORTED", "2"), + ("(gint) GST_MEDIA_SOURCE_ERROR_QUOTA_EXCEEDED", "4"), + ("(gint) GST_MEDIA_SOURCE_ERROR_TYPE", "1"), + ("(gint) GST_MEDIA_SOURCE_READY_STATE_CLOSED", "0"), + ("(gint) GST_MEDIA_SOURCE_READY_STATE_ENDED", "2"), + ("(gint) GST_MEDIA_SOURCE_READY_STATE_OPEN", "1"), + ("(gint) GST_MSE_SRC_READY_STATE_HAVE_CURRENT_DATA", "2"), + ("(gint) GST_MSE_SRC_READY_STATE_HAVE_ENOUGH_DATA", "4"), + ("(gint) GST_MSE_SRC_READY_STATE_HAVE_FUTURE_DATA", "3"), + ("(gint) GST_MSE_SRC_READY_STATE_HAVE_METADATA", "1"), + ("(gint) GST_MSE_SRC_READY_STATE_HAVE_NOTHING", "0"), + ("(gint) GST_SOURCE_BUFFER_APPEND_MODE_SEGMENTS", "0"), + ("(gint) GST_SOURCE_BUFFER_APPEND_MODE_SEQUENCE", "1"), +]; diff --git a/gstreamer-mse/sys/tests/constant.c b/gstreamer-mse/sys/tests/constant.c new file mode 100644 index 000000000..62c27be42 --- /dev/null +++ b/gstreamer-mse/sys/tests/constant.c @@ -0,0 +1,51 @@ +// This file was generated by gir (https://github.com/gtk-rs/gir) +// from gir-files (https://github.com/gtk-rs/gir-files) +// from gst-gir-files (https://gitlab.freedesktop.org/gstreamer/gir-files-rs.git) +// DO NOT EDIT + +#include "manual.h" +#include + +#define PRINT_CONSTANT(CONSTANT_NAME) \ + printf("%s;", #CONSTANT_NAME); \ + printf(_Generic((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", \ + float: "%f", \ + double: "%f", \ + long double: "%ld"), \ + CONSTANT_NAME); \ + printf("\n"); + +int main() { + PRINT_CONSTANT((gint) GST_MEDIA_SOURCE_EOS_ERROR_DECODE); + PRINT_CONSTANT((gint) GST_MEDIA_SOURCE_EOS_ERROR_NETWORK); + PRINT_CONSTANT((gint) GST_MEDIA_SOURCE_EOS_ERROR_NONE); + PRINT_CONSTANT((gint) GST_MEDIA_SOURCE_ERROR_INVALID_STATE); + PRINT_CONSTANT((gint) GST_MEDIA_SOURCE_ERROR_NOT_FOUND); + PRINT_CONSTANT((gint) GST_MEDIA_SOURCE_ERROR_NOT_SUPPORTED); + PRINT_CONSTANT((gint) GST_MEDIA_SOURCE_ERROR_QUOTA_EXCEEDED); + PRINT_CONSTANT((gint) GST_MEDIA_SOURCE_ERROR_TYPE); + PRINT_CONSTANT((gint) GST_MEDIA_SOURCE_READY_STATE_CLOSED); + PRINT_CONSTANT((gint) GST_MEDIA_SOURCE_READY_STATE_ENDED); + PRINT_CONSTANT((gint) GST_MEDIA_SOURCE_READY_STATE_OPEN); + PRINT_CONSTANT((gint) GST_MSE_SRC_READY_STATE_HAVE_CURRENT_DATA); + PRINT_CONSTANT((gint) GST_MSE_SRC_READY_STATE_HAVE_ENOUGH_DATA); + PRINT_CONSTANT((gint) GST_MSE_SRC_READY_STATE_HAVE_FUTURE_DATA); + PRINT_CONSTANT((gint) GST_MSE_SRC_READY_STATE_HAVE_METADATA); + PRINT_CONSTANT((gint) GST_MSE_SRC_READY_STATE_HAVE_NOTHING); + PRINT_CONSTANT((gint) GST_SOURCE_BUFFER_APPEND_MODE_SEGMENTS); + PRINT_CONSTANT((gint) GST_SOURCE_BUFFER_APPEND_MODE_SEQUENCE); + return 0; +} diff --git a/gstreamer-mse/sys/tests/layout.c b/gstreamer-mse/sys/tests/layout.c new file mode 100644 index 000000000..23730f099 --- /dev/null +++ b/gstreamer-mse/sys/tests/layout.c @@ -0,0 +1,24 @@ +// This file was generated by gir (https://github.com/gtk-rs/gir) +// from gir-files (https://github.com/gtk-rs/gir-files) +// from gst-gir-files (https://gitlab.freedesktop.org/gstreamer/gir-files-rs.git) +// DO NOT EDIT + +#include "manual.h" +#include +#include + +int main() { + printf("%s;%zu;%zu\n", "GstMediaSourceClass", sizeof(GstMediaSourceClass), alignof(GstMediaSourceClass)); + printf("%s;%zu;%zu\n", "GstMediaSourceEOSError", sizeof(GstMediaSourceEOSError), alignof(GstMediaSourceEOSError)); + printf("%s;%zu;%zu\n", "GstMediaSourceError", sizeof(GstMediaSourceError), alignof(GstMediaSourceError)); + printf("%s;%zu;%zu\n", "GstMediaSourceRange", sizeof(GstMediaSourceRange), alignof(GstMediaSourceRange)); + printf("%s;%zu;%zu\n", "GstMediaSourceReadyState", sizeof(GstMediaSourceReadyState), alignof(GstMediaSourceReadyState)); + printf("%s;%zu;%zu\n", "GstMseSrcClass", sizeof(GstMseSrcClass), alignof(GstMseSrcClass)); + printf("%s;%zu;%zu\n", "GstMseSrcPadClass", sizeof(GstMseSrcPadClass), alignof(GstMseSrcPadClass)); + printf("%s;%zu;%zu\n", "GstMseSrcReadyState", sizeof(GstMseSrcReadyState), alignof(GstMseSrcReadyState)); + printf("%s;%zu;%zu\n", "GstSourceBufferAppendMode", sizeof(GstSourceBufferAppendMode), alignof(GstSourceBufferAppendMode)); + printf("%s;%zu;%zu\n", "GstSourceBufferClass", sizeof(GstSourceBufferClass), alignof(GstSourceBufferClass)); + printf("%s;%zu;%zu\n", "GstSourceBufferInterval", sizeof(GstSourceBufferInterval), alignof(GstSourceBufferInterval)); + printf("%s;%zu;%zu\n", "GstSourceBufferListClass", sizeof(GstSourceBufferListClass), alignof(GstSourceBufferListClass)); + return 0; +} diff --git a/gstreamer-mse/sys/tests/manual.h b/gstreamer-mse/sys/tests/manual.h new file mode 100644 index 000000000..f99a766fb --- /dev/null +++ b/gstreamer-mse/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