mirror of
https://gitlab.freedesktop.org/gstreamer/gstreamer-rs.git
synced 2024-11-29 04:51:09 +00:00
gstreamer-net: Update manual code to 2018 edition
This commit is contained in:
parent
a8325694f5
commit
ef135d46d8
7 changed files with 31 additions and 55 deletions
|
@ -11,14 +11,12 @@ homepage = "https://gstreamer.freedesktop.org"
|
||||||
documentation = "https://gstreamer.pages.freedesktop.org/gstreamer-rs/gstreamer_net/"
|
documentation = "https://gstreamer.pages.freedesktop.org/gstreamer-rs/gstreamer_net/"
|
||||||
keywords = ["gstreamer", "multimedia", "audio", "video", "gnome"]
|
keywords = ["gstreamer", "multimedia", "audio", "video", "gnome"]
|
||||||
build = "build.rs"
|
build = "build.rs"
|
||||||
|
edition = "2018"
|
||||||
|
|
||||||
[dependencies]
|
[dependencies]
|
||||||
glib-sys = { git = "https://github.com/gtk-rs/gtk-rs" }
|
ffi = { package = "gstreamer-net-sys", path = "../gstreamer-net/sys", features = ["v1_8"] }
|
||||||
gobject-sys = { git = "https://github.com/gtk-rs/gtk-rs" }
|
|
||||||
gstreamer-sys = { path = "../gstreamer/sys", features = ["v1_8"] }
|
|
||||||
gstreamer-net-sys = { path = "../gstreamer-net/sys", features = ["v1_8"] }
|
|
||||||
glib = { git = "https://github.com/gtk-rs/gtk-rs" }
|
glib = { git = "https://github.com/gtk-rs/gtk-rs" }
|
||||||
gstreamer = { path = "../gstreamer" }
|
gst = { package = "gstreamer", path = "../gstreamer" }
|
||||||
gio = { git = "https://github.com/gtk-rs/gtk-rs" }
|
gio = { git = "https://github.com/gtk-rs/gtk-rs" }
|
||||||
|
|
||||||
[build-dependencies]
|
[build-dependencies]
|
||||||
|
@ -26,14 +24,14 @@ gstreamer-rs-lgpl-docs = { path = "../docs", optional = true }
|
||||||
|
|
||||||
[features]
|
[features]
|
||||||
default = []
|
default = []
|
||||||
v1_10 = ["gstreamer/v1_10", "gstreamer-net-sys/v1_10"]
|
v1_10 = ["gst/v1_10", "ffi/v1_10"]
|
||||||
v1_12 = ["gstreamer/v1_12", "gstreamer-net-sys/v1_12", "v1_10"]
|
v1_12 = ["gst/v1_12", "ffi/v1_12", "v1_10"]
|
||||||
v1_14 = ["gstreamer/v1_14", "gstreamer-net-sys/v1_14", "v1_12"]
|
v1_14 = ["gst/v1_14", "ffi/v1_14", "v1_12"]
|
||||||
v1_16 = ["gstreamer/v1_16", "gstreamer-net-sys/v1_16", "v1_14"]
|
v1_16 = ["gst/v1_16", "ffi/v1_16", "v1_14"]
|
||||||
v1_18 = ["gstreamer/v1_18", "gstreamer-net-sys/v1_18", "v1_16"]
|
v1_18 = ["gst/v1_18", "ffi/v1_18", "v1_16"]
|
||||||
embed-lgpl-docs = ["gstreamer-rs-lgpl-docs"]
|
embed-lgpl-docs = ["gstreamer-rs-lgpl-docs"]
|
||||||
purge-lgpl-docs = ["gstreamer-rs-lgpl-docs"]
|
purge-lgpl-docs = ["gstreamer-rs-lgpl-docs"]
|
||||||
dox = ["v1_18", "gstreamer-net-sys/dox", "glib/dox", "gio/dox", "gstreamer/dox"]
|
dox = ["v1_18", "ffi/dox", "glib/dox", "gio/dox", "gst/dox"]
|
||||||
|
|
||||||
[package.metadata.docs.rs]
|
[package.metadata.docs.rs]
|
||||||
features = ["dox", "embed-lgpl-docs"]
|
features = ["dox", "embed-lgpl-docs"]
|
||||||
|
|
|
@ -8,19 +8,11 @@
|
||||||
|
|
||||||
#![cfg_attr(feature = "dox", feature(doc_cfg))]
|
#![cfg_attr(feature = "dox", feature(doc_cfg))]
|
||||||
|
|
||||||
extern crate gio;
|
pub use ffi;
|
||||||
extern crate glib_sys;
|
|
||||||
extern crate gobject_sys;
|
|
||||||
extern crate gstreamer as gst;
|
|
||||||
extern crate gstreamer_net_sys as gst_net_sys;
|
|
||||||
extern crate gstreamer_sys as gst_sys;
|
|
||||||
|
|
||||||
#[macro_use]
|
|
||||||
extern crate glib;
|
|
||||||
|
|
||||||
macro_rules! assert_initialized_main_thread {
|
macro_rules! assert_initialized_main_thread {
|
||||||
() => {
|
() => {
|
||||||
if unsafe { ::gst_sys::gst_is_initialized() } != ::glib_sys::GTRUE {
|
if unsafe { gst::ffi::gst_is_initialized() } != glib::ffi::GTRUE {
|
||||||
panic!("GStreamer has not been initialized. Call `gst::init` first.");
|
panic!("GStreamer has not been initialized. Call `gst::init` first.");
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
@ -35,13 +27,13 @@ macro_rules! skip_assert_initialized {
|
||||||
#[allow(clippy::match_same_arms)]
|
#[allow(clippy::match_same_arms)]
|
||||||
#[allow(unused_imports)]
|
#[allow(unused_imports)]
|
||||||
mod auto;
|
mod auto;
|
||||||
pub use auto::*;
|
pub use crate::auto::*;
|
||||||
mod net_client_clock;
|
mod net_client_clock;
|
||||||
mod net_time_provider;
|
mod net_time_provider;
|
||||||
mod ntp_clock;
|
mod ntp_clock;
|
||||||
mod ptp_clock;
|
mod ptp_clock;
|
||||||
|
|
||||||
pub use net_address_meta::*;
|
pub use crate::net_address_meta::*;
|
||||||
mod net_address_meta;
|
mod net_address_meta;
|
||||||
|
|
||||||
// Re-export all the traits in a prelude module, so that applications
|
// Re-export all the traits in a prelude module, so that applications
|
||||||
|
@ -50,5 +42,5 @@ pub mod prelude {
|
||||||
pub use glib::prelude::*;
|
pub use glib::prelude::*;
|
||||||
pub use gst::prelude::*;
|
pub use gst::prelude::*;
|
||||||
|
|
||||||
pub use auto::traits::*;
|
pub use crate::auto::traits::*;
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,14 +1,10 @@
|
||||||
use std::fmt;
|
use std::fmt;
|
||||||
|
|
||||||
use gio;
|
|
||||||
use glib;
|
|
||||||
use glib::translate::*;
|
use glib::translate::*;
|
||||||
use gst;
|
|
||||||
use gst::prelude::*;
|
use gst::prelude::*;
|
||||||
use gst_net_sys;
|
|
||||||
|
|
||||||
#[repr(transparent)]
|
#[repr(transparent)]
|
||||||
pub struct NetAddressMeta(gst_net_sys::GstNetAddressMeta);
|
pub struct NetAddressMeta(ffi::GstNetAddressMeta);
|
||||||
|
|
||||||
unsafe impl Send for NetAddressMeta {}
|
unsafe impl Send for NetAddressMeta {}
|
||||||
unsafe impl Sync for NetAddressMeta {}
|
unsafe impl Sync for NetAddressMeta {}
|
||||||
|
@ -20,7 +16,7 @@ impl NetAddressMeta {
|
||||||
) -> gst::MetaRefMut<'a, Self, gst::meta::Standalone> {
|
) -> gst::MetaRefMut<'a, Self, gst::meta::Standalone> {
|
||||||
skip_assert_initialized!();
|
skip_assert_initialized!();
|
||||||
unsafe {
|
unsafe {
|
||||||
let meta = gst_net_sys::gst_buffer_add_net_address_meta(
|
let meta = ffi::gst_buffer_add_net_address_meta(
|
||||||
buffer.as_mut_ptr(),
|
buffer.as_mut_ptr(),
|
||||||
addr.as_ref().to_glib_none().0,
|
addr.as_ref().to_glib_none().0,
|
||||||
);
|
);
|
||||||
|
@ -35,17 +31,17 @@ impl NetAddressMeta {
|
||||||
pub fn set_addr<T: IsA<gio::SocketAddress>>(&mut self, addr: &T) {
|
pub fn set_addr<T: IsA<gio::SocketAddress>>(&mut self, addr: &T) {
|
||||||
#![allow(clippy::cast_ptr_alignment)]
|
#![allow(clippy::cast_ptr_alignment)]
|
||||||
unsafe {
|
unsafe {
|
||||||
gobject_sys::g_object_unref(self.0.addr as *mut _);
|
glib::gobject_ffi::g_object_unref(self.0.addr as *mut _);
|
||||||
self.0.addr = addr.as_ref().to_glib_full();
|
self.0.addr = addr.as_ref().to_glib_full();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
unsafe impl MetaAPI for NetAddressMeta {
|
unsafe impl MetaAPI for NetAddressMeta {
|
||||||
type GstType = gst_net_sys::GstNetAddressMeta;
|
type GstType = ffi::GstNetAddressMeta;
|
||||||
|
|
||||||
fn get_meta_api() -> glib::Type {
|
fn get_meta_api() -> glib::Type {
|
||||||
unsafe { from_glib(gst_net_sys::gst_net_address_meta_api_get_type()) }
|
unsafe { from_glib(ffi::gst_net_address_meta_api_get_type()) }
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -6,12 +6,10 @@
|
||||||
// option. This file may not be copied, modified, or distributed
|
// option. This file may not be copied, modified, or distributed
|
||||||
// except according to those terms.
|
// except according to those terms.
|
||||||
|
|
||||||
use gst_net_sys;
|
use crate::NetClientClock;
|
||||||
use NetClientClock;
|
|
||||||
|
|
||||||
use glib::object::Cast;
|
use glib::object::Cast;
|
||||||
use glib::translate::*;
|
use glib::translate::*;
|
||||||
use gst;
|
|
||||||
|
|
||||||
impl NetClientClock {
|
impl NetClientClock {
|
||||||
pub fn new(
|
pub fn new(
|
||||||
|
@ -25,7 +23,7 @@ impl NetClientClock {
|
||||||
let (major, minor, _, _) = gst::version();
|
let (major, minor, _, _) = gst::version();
|
||||||
if (major, minor) > (1, 12) {
|
if (major, minor) > (1, 12) {
|
||||||
unsafe {
|
unsafe {
|
||||||
gst::Clock::from_glib_full(gst_net_sys::gst_net_client_clock_new(
|
gst::Clock::from_glib_full(ffi::gst_net_client_clock_new(
|
||||||
name.0,
|
name.0,
|
||||||
remote_address.to_glib_none().0,
|
remote_address.to_glib_none().0,
|
||||||
remote_port,
|
remote_port,
|
||||||
|
@ -36,7 +34,7 @@ impl NetClientClock {
|
||||||
} else {
|
} else {
|
||||||
// Workaround for bad floating reference handling in 1.12. This issue was fixed for 1.13
|
// Workaround for bad floating reference handling in 1.12. This issue was fixed for 1.13
|
||||||
unsafe {
|
unsafe {
|
||||||
gst::Clock::from_glib_none(gst_net_sys::gst_net_client_clock_new(
|
gst::Clock::from_glib_none(ffi::gst_net_client_clock_new(
|
||||||
name.0,
|
name.0,
|
||||||
remote_address.to_glib_none().0,
|
remote_address.to_glib_none().0,
|
||||||
remote_port,
|
remote_port,
|
||||||
|
|
|
@ -6,12 +6,10 @@
|
||||||
// option. This file may not be copied, modified, or distributed
|
// option. This file may not be copied, modified, or distributed
|
||||||
// except according to those terms.
|
// except according to those terms.
|
||||||
|
|
||||||
use gst_net_sys;
|
use crate::NetTimeProvider;
|
||||||
use NetTimeProvider;
|
|
||||||
|
|
||||||
use glib::translate::*;
|
use glib::translate::*;
|
||||||
use glib::IsA;
|
use glib::IsA;
|
||||||
use gst;
|
|
||||||
|
|
||||||
impl NetTimeProvider {
|
impl NetTimeProvider {
|
||||||
pub fn new<P: IsA<gst::Clock>>(clock: &P, address: Option<&str>, port: i32) -> NetTimeProvider {
|
pub fn new<P: IsA<gst::Clock>>(clock: &P, address: Option<&str>, port: i32) -> NetTimeProvider {
|
||||||
|
@ -21,7 +19,7 @@ impl NetTimeProvider {
|
||||||
let (major, minor, _, _) = gst::version();
|
let (major, minor, _, _) = gst::version();
|
||||||
if (major, minor) > (1, 12) {
|
if (major, minor) > (1, 12) {
|
||||||
unsafe {
|
unsafe {
|
||||||
from_glib_full(gst_net_sys::gst_net_time_provider_new(
|
from_glib_full(ffi::gst_net_time_provider_new(
|
||||||
clock.as_ref().to_glib_none().0,
|
clock.as_ref().to_glib_none().0,
|
||||||
address.0,
|
address.0,
|
||||||
port,
|
port,
|
||||||
|
@ -30,7 +28,7 @@ impl NetTimeProvider {
|
||||||
} else {
|
} else {
|
||||||
// Workaround for bad floating reference handling in 1.12. This issue was fixed for 1.13
|
// Workaround for bad floating reference handling in 1.12. This issue was fixed for 1.13
|
||||||
unsafe {
|
unsafe {
|
||||||
from_glib_none(gst_net_sys::gst_net_time_provider_new(
|
from_glib_none(ffi::gst_net_time_provider_new(
|
||||||
clock.as_ref().to_glib_none().0,
|
clock.as_ref().to_glib_none().0,
|
||||||
address.0,
|
address.0,
|
||||||
port,
|
port,
|
||||||
|
|
|
@ -6,12 +6,10 @@
|
||||||
// option. This file may not be copied, modified, or distributed
|
// option. This file may not be copied, modified, or distributed
|
||||||
// except according to those terms.
|
// except according to those terms.
|
||||||
|
|
||||||
use gst_net_sys;
|
use crate::NtpClock;
|
||||||
use NtpClock;
|
|
||||||
|
|
||||||
use glib::object::Cast;
|
use glib::object::Cast;
|
||||||
use glib::translate::*;
|
use glib::translate::*;
|
||||||
use gst;
|
|
||||||
|
|
||||||
impl NtpClock {
|
impl NtpClock {
|
||||||
pub fn new(
|
pub fn new(
|
||||||
|
@ -25,7 +23,7 @@ impl NtpClock {
|
||||||
let (major, minor, _, _) = gst::version();
|
let (major, minor, _, _) = gst::version();
|
||||||
if (major, minor) > (1, 12) {
|
if (major, minor) > (1, 12) {
|
||||||
unsafe {
|
unsafe {
|
||||||
gst::Clock::from_glib_full(gst_net_sys::gst_ntp_clock_new(
|
gst::Clock::from_glib_full(ffi::gst_ntp_clock_new(
|
||||||
name.0,
|
name.0,
|
||||||
remote_address.to_glib_none().0,
|
remote_address.to_glib_none().0,
|
||||||
remote_port,
|
remote_port,
|
||||||
|
@ -36,7 +34,7 @@ impl NtpClock {
|
||||||
} else {
|
} else {
|
||||||
// Workaround for bad floating reference handling in 1.12. This issue was fixed for 1.13
|
// Workaround for bad floating reference handling in 1.12. This issue was fixed for 1.13
|
||||||
unsafe {
|
unsafe {
|
||||||
gst::Clock::from_glib_none(gst_net_sys::gst_ntp_clock_new(
|
gst::Clock::from_glib_none(ffi::gst_ntp_clock_new(
|
||||||
name.0,
|
name.0,
|
||||||
remote_address.to_glib_none().0,
|
remote_address.to_glib_none().0,
|
||||||
remote_port,
|
remote_port,
|
||||||
|
|
|
@ -6,12 +6,10 @@
|
||||||
// option. This file may not be copied, modified, or distributed
|
// option. This file may not be copied, modified, or distributed
|
||||||
// except according to those terms.
|
// except according to those terms.
|
||||||
|
|
||||||
use gst_net_sys;
|
use crate::PtpClock;
|
||||||
use PtpClock;
|
|
||||||
|
|
||||||
use glib::object::Cast;
|
use glib::object::Cast;
|
||||||
use glib::translate::*;
|
use glib::translate::*;
|
||||||
use gst;
|
|
||||||
|
|
||||||
impl PtpClock {
|
impl PtpClock {
|
||||||
pub fn new(name: Option<&str>, domain: u32) -> PtpClock {
|
pub fn new(name: Option<&str>, domain: u32) -> PtpClock {
|
||||||
|
@ -20,14 +18,12 @@ impl PtpClock {
|
||||||
let (major, minor, _, _) = gst::version();
|
let (major, minor, _, _) = gst::version();
|
||||||
if (major, minor) > (1, 12) {
|
if (major, minor) > (1, 12) {
|
||||||
unsafe {
|
unsafe {
|
||||||
gst::Clock::from_glib_full(gst_net_sys::gst_ptp_clock_new(name.0, domain))
|
gst::Clock::from_glib_full(ffi::gst_ptp_clock_new(name.0, domain)).unsafe_cast()
|
||||||
.unsafe_cast()
|
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
// Workaround for bad floating reference handling in 1.12. This issue was fixed for 1.13
|
// Workaround for bad floating reference handling in 1.12. This issue was fixed for 1.13
|
||||||
unsafe {
|
unsafe {
|
||||||
gst::Clock::from_glib_none(gst_net_sys::gst_ptp_clock_new(name.0, domain))
|
gst::Clock::from_glib_none(ffi::gst_ptp_clock_new(name.0, domain)).unsafe_cast()
|
||||||
.unsafe_cast()
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue