Implement MpegTs safe bindings

Adds safe bindings generated from Gir for the MpegTS library. Not all
object bindings are generated. This contains a subset of the
library that allows to use it's basic functionality.

Part of the API is written manually to add some extra methods like
setting struct field values and other useful features.
This commit is contained in:
Rafael Caricio 2022-05-04 14:45:39 +02:00 committed by Sebastian Dröge
parent 8d3ada5d89
commit 20a493ee49
8 changed files with 340 additions and 32 deletions

View file

@ -27,6 +27,7 @@ default-members = [
"gstreamer-check", "gstreamer-check",
"gstreamer-controller", "gstreamer-controller",
"gstreamer-editing-services", "gstreamer-editing-services",
"gstreamer-mpegts",
"gstreamer-net", "gstreamer-net",
"gstreamer-pbutils", "gstreamer-pbutils",
"gstreamer-play", "gstreamer-play",
@ -78,6 +79,7 @@ members = [
"gstreamer-gl/egl", "gstreamer-gl/egl",
"gstreamer-gl/wayland", "gstreamer-gl/wayland",
"gstreamer-gl/x11", "gstreamer-gl/x11",
"gstreamer-mpegts",
"gstreamer-net", "gstreamer-net",
"gstreamer-pbutils", "gstreamer-pbutils",
"gstreamer-play", "gstreamer-play",

View file

@ -0,0 +1,33 @@
[package]
name = "gstreamer-mpegts"
version = "0.19.0"
authors = ["Sebastian Dröge <sebastian@centricular.com>", "Rafael Caricio <rafael@caricio.com>"]
categories = ["api-bindings", "multimedia"]
description = "Rust bindings for GStreamer MpegTs library"
repository = "https://gitlab.freedesktop.org/gstreamer/gstreamer-rs"
license = "MIT OR Apache-2.0"
readme = "README.md"
homepage = "https://gstreamer.freedesktop.org"
documentation = "https://gstreamer.pages.freedesktop.org/gstreamer-rs/stable/latest/docs/gstreamer_mpegts/"
keywords = ["gstreamer", "multimedia", "audio", "video", "gnome"]
edition = "2021"
rust-version = "1.63"
[dependencies]
ffi = { package = "gstreamer-mpegts-sys", path = "sys" }
glib = { git = "https://github.com/gtk-rs/gtk-rs-core" }
gst = { package = "gstreamer", path = "../gstreamer" }
[dev-dependencies]
gir-format-check = "0.1"
[features]
default = []
v1_16 = ["gst/v1_16", "ffi/v1_16"]
v1_18 = ["gst/v1_18", "ffi/v1_18", "v1_16"]
v1_20 = ["gst/v1_20", "ffi/v1_20", "v1_18"]
v1_22 = ["gst/v1_22", "ffi/v1_22", "v1_20"]
dox = ["ffi/dox", "glib/dox", "gst/dox"]
[package.metadata.docs.rs]
features = ["dox"]

68
gstreamer-mpegts/Gir.toml Normal file
View file

@ -0,0 +1,68 @@
[options]
girs_directories = ["../gir-files", "../gst-gir-files"]
library = "GstMpegts"
version = "1.0"
min_cfg_version = "1.14"
work_mode = "normal"
target_path = "."
concurrency = "send+sync"
generate_safety_asserts = true
single_version_file = true
generate_display_trait = false
deprecate_by_min_version = true
trust_return_value_nullability = true
external_libraries = [
"GLib",
"GObject",
"Gst",
]
generate = []
manual = [
"GLib.Bytes",
"Gst.Element",
]
[[object]]
name = "GstMpegts.Section"
status = "generate"
version = "1.20"
[[object.function]]
name = "new"
ignore = true
[[object.function]]
name = "get_scte_sit"
ignore = true
[[object.function]]
name = "packetize"
# Invalid code generation for this function
ignore = true
[[object.function]]
name = "from_scte_sit"
# Invalid code generation for this function
ignore = true
[[object.function]]
name = "data"
[object.function.return]
nullable = true
nullable_return_is_error = "Failed to create section"
[[object.function]]
name = "get_tsdt"
# Invalid code generation for this function
ignore = true
[[object.function]]
name = "get_cat"
# Invalid code generation for this function
ignore = true
[[object.function]]
name = "send_event"
ignore = true

View file

@ -0,0 +1,11 @@
// 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(any(feature = "v1_20", feature = "dox"))]
#[cfg_attr(feature = "dox", doc(cfg(feature = "v1_20")))]
mod section;
#[cfg(any(feature = "v1_20", feature = "dox"))]
#[cfg_attr(feature = "dox", doc(cfg(feature = "v1_20")))]
pub use self::section::Section;

View file

@ -0,0 +1,159 @@
// 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 glib::translate::*;
glib::wrapper! {
#[derive(Debug, PartialEq, Eq, PartialOrd, Ord, Hash)]
pub struct Section(Boxed<ffi::GstMpegtsSection>);
match fn {
copy => |ptr| glib::gobject_ffi::g_boxed_copy(ffi::gst_mpegts_section_get_type(), ptr as *mut _) as *mut ffi::GstMpegtsSection,
free => |ptr| glib::gobject_ffi::g_boxed_free(ffi::gst_mpegts_section_get_type(), ptr as *mut _),
type_ => || ffi::gst_mpegts_section_get_type(),
}
}
impl Section {
//#[doc(alias = "gst_mpegts_section_get_atsc_cvct")]
//#[doc(alias = "get_atsc_cvct")]
//pub fn atsc_cvct(&mut self) -> /*Ignored*/AtscVCT {
// unsafe { TODO: call ffi:gst_mpegts_section_get_atsc_cvct() }
//}
//#[doc(alias = "gst_mpegts_section_get_atsc_eit")]
//#[doc(alias = "get_atsc_eit")]
//pub fn atsc_eit(&mut self) -> /*Ignored*/AtscEIT {
// unsafe { TODO: call ffi:gst_mpegts_section_get_atsc_eit() }
//}
//#[doc(alias = "gst_mpegts_section_get_atsc_ett")]
//#[doc(alias = "get_atsc_ett")]
//pub fn atsc_ett(&mut self) -> /*Ignored*/AtscETT {
// unsafe { TODO: call ffi:gst_mpegts_section_get_atsc_ett() }
//}
//#[doc(alias = "gst_mpegts_section_get_atsc_mgt")]
//#[doc(alias = "get_atsc_mgt")]
//pub fn atsc_mgt(&mut self) -> /*Ignored*/AtscMGT {
// unsafe { TODO: call ffi:gst_mpegts_section_get_atsc_mgt() }
//}
//#[doc(alias = "gst_mpegts_section_get_atsc_rrt")]
//#[doc(alias = "get_atsc_rrt")]
//pub fn atsc_rrt(&mut self) -> /*Ignored*/AtscRRT {
// unsafe { TODO: call ffi:gst_mpegts_section_get_atsc_rrt() }
//}
//#[doc(alias = "gst_mpegts_section_get_atsc_stt")]
//#[doc(alias = "get_atsc_stt")]
//pub fn atsc_stt(&mut self) -> /*Ignored*/AtscSTT {
// unsafe { TODO: call ffi:gst_mpegts_section_get_atsc_stt() }
//}
//#[doc(alias = "gst_mpegts_section_get_atsc_tvct")]
//#[doc(alias = "get_atsc_tvct")]
//pub fn atsc_tvct(&mut self) -> /*Ignored*/AtscVCT {
// unsafe { TODO: call ffi:gst_mpegts_section_get_atsc_tvct() }
//}
//#[doc(alias = "gst_mpegts_section_get_bat")]
//#[doc(alias = "get_bat")]
//pub fn bat(&mut self) -> /*Ignored*/BAT {
// unsafe { TODO: call ffi:gst_mpegts_section_get_bat() }
//}
#[doc(alias = "gst_mpegts_section_get_data")]
#[doc(alias = "get_data")]
pub fn data(&mut self) -> glib::Bytes {
unsafe { from_glib_full(ffi::gst_mpegts_section_get_data(self.to_glib_none_mut().0)) }
}
//#[doc(alias = "gst_mpegts_section_get_eit")]
//#[doc(alias = "get_eit")]
//pub fn eit(&mut self) -> /*Ignored*/EIT {
// unsafe { TODO: call ffi:gst_mpegts_section_get_eit() }
//}
//#[doc(alias = "gst_mpegts_section_get_nit")]
//#[doc(alias = "get_nit")]
//pub fn nit(&mut self) -> /*Ignored*/NIT {
// unsafe { TODO: call ffi:gst_mpegts_section_get_nit() }
//}
//#[doc(alias = "gst_mpegts_section_get_pat")]
//#[doc(alias = "get_pat")]
//pub fn pat(&mut self) -> /*Ignored*/Vec<PatProgram> {
// unsafe { TODO: call ffi:gst_mpegts_section_get_pat() }
//}
//#[doc(alias = "gst_mpegts_section_get_pmt")]
//#[doc(alias = "get_pmt")]
//pub fn pmt(&mut self) -> /*Ignored*/PMT {
// unsafe { TODO: call ffi:gst_mpegts_section_get_pmt() }
//}
//#[doc(alias = "gst_mpegts_section_get_sdt")]
//#[doc(alias = "get_sdt")]
//pub fn sdt(&mut self) -> /*Ignored*/SDT {
// unsafe { TODO: call ffi:gst_mpegts_section_get_sdt() }
//}
//#[doc(alias = "gst_mpegts_section_get_sit")]
//#[doc(alias = "get_sit")]
//pub fn sit(&mut self) -> /*Ignored*/SIT {
// unsafe { TODO: call ffi:gst_mpegts_section_get_sit() }
//}
//#[doc(alias = "gst_mpegts_section_get_tdt")]
//#[doc(alias = "get_tdt")]
//pub fn tdt(&mut self) -> /*Ignored*/gst::DateTime {
// unsafe { TODO: call ffi:gst_mpegts_section_get_tdt() }
//}
//#[doc(alias = "gst_mpegts_section_get_tot")]
//#[doc(alias = "get_tot")]
//pub fn tot(&mut self) -> /*Ignored*/TOT {
// unsafe { TODO: call ffi:gst_mpegts_section_get_tot() }
//}
//#[doc(alias = "gst_mpegts_section_from_atsc_mgt")]
//pub fn from_atsc_mgt(mgt: /*Ignored*/&mut AtscMGT) -> Section {
// unsafe { TODO: call ffi:gst_mpegts_section_from_atsc_mgt() }
//}
//#[doc(alias = "gst_mpegts_section_from_atsc_rrt")]
//pub fn from_atsc_rrt(rrt: /*Ignored*/&mut AtscRRT) -> Section {
// unsafe { TODO: call ffi:gst_mpegts_section_from_atsc_rrt() }
//}
//#[doc(alias = "gst_mpegts_section_from_atsc_stt")]
//pub fn from_atsc_stt(stt: /*Ignored*/&mut AtscSTT) -> Section {
// unsafe { TODO: call ffi:gst_mpegts_section_from_atsc_stt() }
//}
//#[doc(alias = "gst_mpegts_section_from_nit")]
//pub fn from_nit(nit: /*Ignored*/&mut NIT) -> Section {
// unsafe { TODO: call ffi:gst_mpegts_section_from_nit() }
//}
//#[doc(alias = "gst_mpegts_section_from_pat")]
//pub fn from_pat(programs: /*Ignored*/&[PatProgram], ts_id: u16) -> Section {
// unsafe { TODO: call ffi:gst_mpegts_section_from_pat() }
//}
//#[doc(alias = "gst_mpegts_section_from_pmt")]
//pub fn from_pmt(pmt: /*Ignored*/&mut PMT, pid: u16) -> Section {
// unsafe { TODO: call ffi:gst_mpegts_section_from_pmt() }
//}
//#[doc(alias = "gst_mpegts_section_from_sdt")]
//pub fn from_sdt(sdt: /*Ignored*/&mut SDT) -> Section {
// unsafe { TODO: call ffi:gst_mpegts_section_from_sdt() }
//}
}
unsafe impl Send for Section {}
unsafe impl Sync for Section {}

View file

@ -0,0 +1,3 @@
Generated by gir (https://github.com/gtk-rs/gir @ b3147f2b6043)
from gir-files (https://github.com/gtk-rs/gir-files @ 7fa401e3ee5d)
from gst-gir-files (https://gitlab.freedesktop.org/gstreamer/gir-files-rs.git @ 2860909848fa)

View file

@ -0,0 +1,32 @@
#![cfg_attr(feature = "dox", feature(doc_cfg))]
#![allow(clippy::missing_safety_doc)]
#![allow(clippy::non_send_fields_in_send_ty)]
pub use ffi::*;
pub use glib;
pub use gst;
use std::sync::Once;
static MPEGTS_INIT: Once = Once::new();
macro_rules! assert_initialized_main_thread {
() => {
if !gst::INITIALIZED.load(std::sync::atomic::Ordering::SeqCst) {
#[allow(unused_unsafe)]
if unsafe { gst::ffi::gst_is_initialized() } != glib::ffi::GTRUE {
panic!("GStreamer has not been initialized. Call `gst::init` first.");
} else {
gst::INITIALIZED.store(true, std::sync::atomic::Ordering::SeqCst);
}
}
crate::MPEGTS_INIT.call_once(|| unsafe { ffi::gst_mpegts_initialize() });
};
}
pub fn init() {
assert_initialized_main_thread!();
}
mod auto;
pub use crate::auto::*;

View file

@ -1,35 +1,3 @@
[build-dependencies]
system-deps = "6"
[dependencies]
libc = "0.2"
[dependencies.glib]
package = "glib-sys"
git = "https://github.com/gtk-rs/gtk-rs-core"
[dependencies.gst_base]
package = "gstreamer-base-sys"
path = "../../gstreamer-base/sys"
[dependencies.gst]
package = "gstreamer-sys"
path = "../../gstreamer/sys"
[dev-dependencies]
shell-words = "1.0.0"
tempfile = "3"
[features]
v1_16 = []
v1_18 = ["v1_16"]
v1_20 = ["v1_18"]
v1_22 = ["v1_20"]
dox = []
[lib]
name = "gstreamer_mpegts_sys"
[package] [package]
authors = ["Russel Winder <russel@winder.org.uk>", "Sebastian Dröge <sebastian@centricular.com>"] authors = ["Russel Winder <russel@winder.org.uk>", "Sebastian Dröge <sebastian@centricular.com>"]
build = "build.rs" build = "build.rs"
@ -61,3 +29,35 @@ version = "1.20"
[package.metadata.system-deps.gstreamer_mpegts_1_0.v1_22] [package.metadata.system-deps.gstreamer_mpegts_1_0.v1_22]
version = "1.21" version = "1.21"
[lib]
name = "gstreamer_mpegts_sys"
[build-dependencies]
system-deps = "6"
[dependencies]
libc = "0.2"
[dependencies.glib]
package = "glib-sys"
git = "https://github.com/gtk-rs/gtk-rs-core"
[dependencies.gst_base]
package = "gstreamer-base-sys"
path = "../../gstreamer-base/sys"
[dependencies.gst]
package = "gstreamer-sys"
path = "../../gstreamer/sys"
[dev-dependencies]
shell-words = "1.0.0"
tempfile = "3"
[features]
v1_16 = []
v1_18 = ["v1_16"]
v1_20 = ["v1_18"]
v1_22 = ["v1_20"]
dox = []