forked from mirrors/gstreamer-rs
Update everything for glib macro renamings
This commit is contained in:
parent
d0b0006d27
commit
ce1148b474
70 changed files with 234 additions and 279 deletions
|
@ -9,9 +9,6 @@
|
||||||
|
|
||||||
use gst_rtsp_server::prelude::*;
|
use gst_rtsp_server::prelude::*;
|
||||||
|
|
||||||
use glib::glib_object_subclass;
|
|
||||||
use glib::glib_wrapper;
|
|
||||||
|
|
||||||
use anyhow::Error;
|
use anyhow::Error;
|
||||||
use derive_more::{Display, Error};
|
use derive_more::{Display, Error};
|
||||||
|
|
||||||
|
@ -104,7 +101,7 @@ mod media_factory {
|
||||||
type Class = subclass::simple::ClassStruct<Self>;
|
type Class = subclass::simple::ClassStruct<Self>;
|
||||||
|
|
||||||
// This macro provides some boilerplate
|
// This macro provides some boilerplate
|
||||||
glib_object_subclass!();
|
glib::object_subclass!();
|
||||||
|
|
||||||
// Called when a new instance is to be created. We need to return an instance
|
// Called when a new instance is to be created. We need to return an instance
|
||||||
// of our struct here.
|
// of our struct here.
|
||||||
|
@ -156,7 +153,7 @@ mod media_factory {
|
||||||
|
|
||||||
// This here defines the public interface of our factory and implements
|
// This here defines the public interface of our factory and implements
|
||||||
// the corresponding traits so that it behaves like any other RTSPMediaFactory
|
// the corresponding traits so that it behaves like any other RTSPMediaFactory
|
||||||
glib_wrapper! {
|
glib::wrapper! {
|
||||||
pub struct Factory(ObjectSubclass<imp::Factory>) @extends gst_rtsp_server::RTSPMediaFactory;
|
pub struct Factory(ObjectSubclass<imp::Factory>) @extends gst_rtsp_server::RTSPMediaFactory;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -174,8 +171,6 @@ mod media_factory {
|
||||||
|
|
||||||
// Our custom media subclass that adds a custom attribute to the SDP returned by DESCRIBE
|
// Our custom media subclass that adds a custom attribute to the SDP returned by DESCRIBE
|
||||||
mod media {
|
mod media {
|
||||||
use super::*;
|
|
||||||
|
|
||||||
use glib::subclass;
|
use glib::subclass;
|
||||||
use glib::subclass::prelude::*;
|
use glib::subclass::prelude::*;
|
||||||
|
|
||||||
|
@ -199,7 +194,7 @@ mod media {
|
||||||
type Class = subclass::simple::ClassStruct<Self>;
|
type Class = subclass::simple::ClassStruct<Self>;
|
||||||
|
|
||||||
// This macro provides some boilerplate
|
// This macro provides some boilerplate
|
||||||
glib_object_subclass!();
|
glib::object_subclass!();
|
||||||
|
|
||||||
// Called when a new instance is to be created. We need to return an instance
|
// Called when a new instance is to be created. We need to return an instance
|
||||||
// of our struct here.
|
// of our struct here.
|
||||||
|
@ -230,7 +225,7 @@ mod media {
|
||||||
|
|
||||||
// This here defines the public interface of our factory and implements
|
// This here defines the public interface of our factory and implements
|
||||||
// the corresponding traits so that it behaves like any other RTSPMedia
|
// the corresponding traits so that it behaves like any other RTSPMedia
|
||||||
glib_wrapper! {
|
glib::wrapper! {
|
||||||
pub struct Media(ObjectSubclass<imp::Media>) @extends gst_rtsp_server::RTSPMedia;
|
pub struct Media(ObjectSubclass<imp::Media>) @extends gst_rtsp_server::RTSPMedia;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -267,7 +262,7 @@ mod server {
|
||||||
type Class = subclass::simple::ClassStruct<Self>;
|
type Class = subclass::simple::ClassStruct<Self>;
|
||||||
|
|
||||||
// This macro provides some boilerplate
|
// This macro provides some boilerplate
|
||||||
glib_object_subclass!();
|
glib::object_subclass!();
|
||||||
|
|
||||||
// Called when a new instance is to be created. We need to return an instance
|
// Called when a new instance is to be created. We need to return an instance
|
||||||
// of our struct here.
|
// of our struct here.
|
||||||
|
@ -302,7 +297,7 @@ mod server {
|
||||||
|
|
||||||
// This here defines the public interface of our factory and implements
|
// This here defines the public interface of our factory and implements
|
||||||
// the corresponding traits so that it behaves like any other RTSPServer
|
// the corresponding traits so that it behaves like any other RTSPServer
|
||||||
glib_wrapper! {
|
glib::wrapper! {
|
||||||
pub struct Server(ObjectSubclass<imp::Server>) @extends gst_rtsp_server::RTSPServer;
|
pub struct Server(ObjectSubclass<imp::Server>) @extends gst_rtsp_server::RTSPServer;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -320,8 +315,6 @@ mod server {
|
||||||
|
|
||||||
// Our custom RTSP client subclass.
|
// Our custom RTSP client subclass.
|
||||||
mod client {
|
mod client {
|
||||||
use super::*;
|
|
||||||
|
|
||||||
use glib::subclass;
|
use glib::subclass;
|
||||||
use glib::subclass::prelude::*;
|
use glib::subclass::prelude::*;
|
||||||
|
|
||||||
|
@ -345,7 +338,7 @@ mod client {
|
||||||
type Class = subclass::simple::ClassStruct<Self>;
|
type Class = subclass::simple::ClassStruct<Self>;
|
||||||
|
|
||||||
// This macro provides some boilerplate
|
// This macro provides some boilerplate
|
||||||
glib_object_subclass!();
|
glib::object_subclass!();
|
||||||
|
|
||||||
// Called when a new instance is to be created. We need to return an instance
|
// Called when a new instance is to be created. We need to return an instance
|
||||||
// of our struct here.
|
// of our struct here.
|
||||||
|
@ -368,7 +361,7 @@ mod client {
|
||||||
|
|
||||||
// This here defines the public interface of our factory and implements
|
// This here defines the public interface of our factory and implements
|
||||||
// the corresponding traits so that it behaves like any other RTSPClient
|
// the corresponding traits so that it behaves like any other RTSPClient
|
||||||
glib_wrapper! {
|
glib::wrapper! {
|
||||||
pub struct Client(ObjectSubclass<imp::Client>) @extends gst_rtsp_server::RTSPClient;
|
pub struct Client(ObjectSubclass<imp::Client>) @extends gst_rtsp_server::RTSPClient;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -6,9 +6,6 @@
|
||||||
// Our filter can only handle F32 mono and acts as a FIR filter. The filter impulse response /
|
// Our filter can only handle F32 mono and acts as a FIR filter. The filter impulse response /
|
||||||
// coefficients are provided via Rust API on the filter as a Vec<f32>.
|
// coefficients are provided via Rust API on the filter as a Vec<f32>.
|
||||||
|
|
||||||
use glib::glib_object_subclass;
|
|
||||||
use glib::glib_wrapper;
|
|
||||||
|
|
||||||
use gst::gst_element_error;
|
use gst::gst_element_error;
|
||||||
use gst::gst_info;
|
use gst::gst_info;
|
||||||
use gst::gst_trace;
|
use gst::gst_trace;
|
||||||
|
@ -68,7 +65,7 @@ mod fir_filter {
|
||||||
type Class = subclass::simple::ClassStruct<Self>;
|
type Class = subclass::simple::ClassStruct<Self>;
|
||||||
|
|
||||||
// This macro provides some boilerplate
|
// This macro provides some boilerplate
|
||||||
glib_object_subclass!();
|
glib::object_subclass!();
|
||||||
|
|
||||||
// Called when a new instance is to be created. We need to return an instance
|
// Called when a new instance is to be created. We need to return an instance
|
||||||
// of our struct here.
|
// of our struct here.
|
||||||
|
@ -245,7 +242,7 @@ mod fir_filter {
|
||||||
|
|
||||||
// This here defines the public interface of our element and implements
|
// This here defines the public interface of our element and implements
|
||||||
// the corresponding traits so that it behaves like any other gst::Element
|
// the corresponding traits so that it behaves like any other gst::Element
|
||||||
glib_wrapper! {
|
glib::wrapper! {
|
||||||
pub struct FirFilter(ObjectSubclass<imp::FirFilter>) @extends gst_base::BaseTransform, gst::Element, gst::Object;
|
pub struct FirFilter(ObjectSubclass<imp::FirFilter>) @extends gst_base::BaseTransform, gst::Element, gst::Object;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -102,7 +102,7 @@ impl<T> AudioBuffer<T> {
|
||||||
|
|
||||||
pub fn plane_data(&self, plane: u32) -> Result<&[u8], glib::BoolError> {
|
pub fn plane_data(&self, plane: u32) -> Result<&[u8], glib::BoolError> {
|
||||||
if plane >= self.n_planes() {
|
if plane >= self.n_planes() {
|
||||||
return Err(glib::glib_bool_error!(
|
return Err(glib::bool_error!(
|
||||||
"Plane index higher than number of planes"
|
"Plane index higher than number of planes"
|
||||||
));
|
));
|
||||||
}
|
}
|
||||||
|
@ -213,7 +213,7 @@ impl AudioBuffer<Writable> {
|
||||||
|
|
||||||
pub fn plane_data_mut(&mut self, plane: u32) -> Result<&mut [u8], glib::BoolError> {
|
pub fn plane_data_mut(&mut self, plane: u32) -> Result<&mut [u8], glib::BoolError> {
|
||||||
if plane >= self.n_planes() {
|
if plane >= self.n_planes() {
|
||||||
return Err(glib::glib_bool_error!(
|
return Err(glib::bool_error!(
|
||||||
"Plane index higher than number of planes"
|
"Plane index higher than number of planes"
|
||||||
));
|
));
|
||||||
}
|
}
|
||||||
|
@ -336,7 +336,7 @@ impl<T> AudioBufferRef<T> {
|
||||||
|
|
||||||
pub fn plane_data(&self, plane: u32) -> Result<&[u8], glib::BoolError> {
|
pub fn plane_data(&self, plane: u32) -> Result<&[u8], glib::BoolError> {
|
||||||
if plane >= self.n_planes() {
|
if plane >= self.n_planes() {
|
||||||
return Err(glib::glib_bool_error!(
|
return Err(glib::bool_error!(
|
||||||
"Plane index higher than number of planes"
|
"Plane index higher than number of planes"
|
||||||
));
|
));
|
||||||
}
|
}
|
||||||
|
@ -390,7 +390,7 @@ impl<'a> AudioBufferRef<&'a gst::BufferRef> {
|
||||||
));
|
));
|
||||||
|
|
||||||
if !res {
|
if !res {
|
||||||
Err(glib::glib_bool_error!("Failed to map AudioBuffer"))
|
Err(glib::bool_error!("Failed to map AudioBuffer"))
|
||||||
} else {
|
} else {
|
||||||
let info = crate::AudioInfo::from_glib_none(
|
let info = crate::AudioInfo::from_glib_none(
|
||||||
&audio_buffer.info as *const _ as *mut ffi::GstAudioInfo,
|
&audio_buffer.info as *const _ as *mut ffi::GstAudioInfo,
|
||||||
|
@ -444,7 +444,7 @@ impl<'a> AudioBufferRef<&'a mut gst::BufferRef> {
|
||||||
));
|
));
|
||||||
|
|
||||||
if !res {
|
if !res {
|
||||||
Err(glib::glib_bool_error!("Failed to map AudioBuffer"))
|
Err(glib::bool_error!("Failed to map AudioBuffer"))
|
||||||
} else {
|
} else {
|
||||||
let info = crate::AudioInfo::from_glib_none(
|
let info = crate::AudioInfo::from_glib_none(
|
||||||
&audio_buffer.info as *const _ as *mut ffi::GstAudioInfo,
|
&audio_buffer.info as *const _ as *mut ffi::GstAudioInfo,
|
||||||
|
@ -465,7 +465,7 @@ impl<'a> AudioBufferRef<&'a mut gst::BufferRef> {
|
||||||
|
|
||||||
pub fn plane_data_mut(&mut self, plane: u32) -> Result<&mut [u8], glib::BoolError> {
|
pub fn plane_data_mut(&mut self, plane: u32) -> Result<&mut [u8], glib::BoolError> {
|
||||||
if plane >= self.n_planes() {
|
if plane >= self.n_planes() {
|
||||||
return Err(glib::glib_bool_error!(
|
return Err(glib::bool_error!(
|
||||||
"Plane index higher than number of planes"
|
"Plane index higher than number of planes"
|
||||||
));
|
));
|
||||||
}
|
}
|
||||||
|
|
|
@ -24,7 +24,7 @@ impl AudioChannelPosition {
|
||||||
|
|
||||||
let len = positions.len();
|
let len = positions.len();
|
||||||
if len > 64 {
|
if len > 64 {
|
||||||
return Err(glib::glib_bool_error!("Invalid number of channels"));
|
return Err(glib::bool_error!("Invalid number of channels"));
|
||||||
}
|
}
|
||||||
|
|
||||||
let positions_raw: [ffi::GstAudioChannelPosition; 64] = array_init::array_init(|i| {
|
let positions_raw: [ffi::GstAudioChannelPosition; 64] = array_init::array_init(|i| {
|
||||||
|
@ -46,7 +46,7 @@ impl AudioChannelPosition {
|
||||||
if valid {
|
if valid {
|
||||||
Ok(mask.assume_init())
|
Ok(mask.assume_init())
|
||||||
} else {
|
} else {
|
||||||
Err(glib::glib_bool_error!(
|
Err(glib::bool_error!(
|
||||||
"Couldn't convert channel positions to mask"
|
"Couldn't convert channel positions to mask"
|
||||||
))
|
))
|
||||||
}
|
}
|
||||||
|
@ -60,7 +60,7 @@ impl AudioChannelPosition {
|
||||||
assert_initialized_main_thread!();
|
assert_initialized_main_thread!();
|
||||||
|
|
||||||
if positions.len() > 64 {
|
if positions.len() > 64 {
|
||||||
return Err(glib::glib_bool_error!("Invalid number of channels"));
|
return Err(glib::bool_error!("Invalid number of channels"));
|
||||||
}
|
}
|
||||||
|
|
||||||
let len = positions.len();
|
let len = positions.len();
|
||||||
|
@ -80,7 +80,7 @@ impl AudioChannelPosition {
|
||||||
}
|
}
|
||||||
Ok(())
|
Ok(())
|
||||||
} else {
|
} else {
|
||||||
Err(glib::glib_bool_error!(
|
Err(glib::bool_error!(
|
||||||
"Couldn't convert channel positions to mask",
|
"Couldn't convert channel positions to mask",
|
||||||
))
|
))
|
||||||
}
|
}
|
||||||
|
@ -92,7 +92,7 @@ impl AudioChannelPosition {
|
||||||
assert_initialized_main_thread!();
|
assert_initialized_main_thread!();
|
||||||
|
|
||||||
if positions.len() > 64 {
|
if positions.len() > 64 {
|
||||||
return Err(glib::glib_bool_error!("Invalid number of channels"));
|
return Err(glib::bool_error!("Invalid number of channels"));
|
||||||
}
|
}
|
||||||
|
|
||||||
let len = positions.len();
|
let len = positions.len();
|
||||||
|
@ -117,7 +117,7 @@ impl AudioChannelPosition {
|
||||||
}
|
}
|
||||||
Ok(())
|
Ok(())
|
||||||
} else {
|
} else {
|
||||||
Err(glib::glib_bool_error!(
|
Err(glib::bool_error!(
|
||||||
"Couldn't convert channel positions to mask",
|
"Couldn't convert channel positions to mask",
|
||||||
))
|
))
|
||||||
}
|
}
|
||||||
|
@ -168,7 +168,7 @@ pub fn buffer_reorder_channels(
|
||||||
assert_initialized_main_thread!();
|
assert_initialized_main_thread!();
|
||||||
|
|
||||||
if from.len() != to.len() || from.len() > 64 {
|
if from.len() != to.len() || from.len() > 64 {
|
||||||
return Err(glib::glib_bool_error!("Invalid number of channels"));
|
return Err(glib::bool_error!("Invalid number of channels"));
|
||||||
}
|
}
|
||||||
|
|
||||||
let from_len = from.len();
|
let from_len = from.len();
|
||||||
|
@ -203,7 +203,7 @@ pub fn buffer_reorder_channels(
|
||||||
if valid {
|
if valid {
|
||||||
Ok(())
|
Ok(())
|
||||||
} else {
|
} else {
|
||||||
Err(glib::glib_bool_error!("Failed to reorder channels"))
|
Err(glib::bool_error!("Failed to reorder channels"))
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -217,7 +217,7 @@ pub fn reorder_channels(
|
||||||
assert_initialized_main_thread!();
|
assert_initialized_main_thread!();
|
||||||
|
|
||||||
if from.len() != to.len() || from.len() > 64 {
|
if from.len() != to.len() || from.len() > 64 {
|
||||||
return Err(glib::glib_bool_error!("Invalid number of channels"));
|
return Err(glib::bool_error!("Invalid number of channels"));
|
||||||
}
|
}
|
||||||
|
|
||||||
let from_len = from.len();
|
let from_len = from.len();
|
||||||
|
@ -253,7 +253,7 @@ pub fn reorder_channels(
|
||||||
if valid {
|
if valid {
|
||||||
Ok(())
|
Ok(())
|
||||||
} else {
|
} else {
|
||||||
Err(glib::glib_bool_error!("Failed to reorder channels"))
|
Err(glib::bool_error!("Failed to reorder channels"))
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -265,7 +265,7 @@ pub fn get_channel_reorder_map(
|
||||||
assert_initialized_main_thread!();
|
assert_initialized_main_thread!();
|
||||||
|
|
||||||
if from.len() != to.len() || from.len() != reorder_map.len() || from.len() > 64 {
|
if from.len() != to.len() || from.len() != reorder_map.len() || from.len() > 64 {
|
||||||
return Err(glib::glib_bool_error!("Invalid number of channels"));
|
return Err(glib::bool_error!("Invalid number of channels"));
|
||||||
}
|
}
|
||||||
|
|
||||||
let from_len = from.len();
|
let from_len = from.len();
|
||||||
|
@ -303,6 +303,6 @@ pub fn get_channel_reorder_map(
|
||||||
}
|
}
|
||||||
Ok(())
|
Ok(())
|
||||||
} else {
|
} else {
|
||||||
Err(glib::glib_bool_error!("Failed to reorder channels"))
|
Err(glib::bool_error!("Failed to reorder channels"))
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -140,7 +140,7 @@ impl str::FromStr for crate::AudioFormat {
|
||||||
|
|
||||||
let fmt = Self::from_string(s);
|
let fmt = Self::from_string(s);
|
||||||
if fmt == Self::Unknown {
|
if fmt == Self::Unknown {
|
||||||
Err(glib::glib_bool_error!(
|
Err(glib::bool_error!(
|
||||||
"Failed to parse audio format from string"
|
"Failed to parse audio format from string"
|
||||||
))
|
))
|
||||||
} else {
|
} else {
|
||||||
|
|
|
@ -41,7 +41,7 @@ impl<'a> AudioInfoBuilder<'a> {
|
||||||
|
|
||||||
let positions = if let Some(p) = self.positions {
|
let positions = if let Some(p) = self.positions {
|
||||||
if p.len() != self.channels as usize || p.len() > 64 {
|
if p.len() != self.channels as usize || p.len() > 64 {
|
||||||
return Err(glib::glib_bool_error!("Invalid positions length"));
|
return Err(glib::bool_error!("Invalid positions length"));
|
||||||
}
|
}
|
||||||
|
|
||||||
let positions: [ffi::GstAudioChannelPosition; 64] = array_init::array_init(|i| {
|
let positions: [ffi::GstAudioChannelPosition; 64] = array_init::array_init(|i| {
|
||||||
|
@ -58,7 +58,7 @@ impl<'a> AudioInfoBuilder<'a> {
|
||||||
true.to_glib(),
|
true.to_glib(),
|
||||||
));
|
));
|
||||||
if !valid {
|
if !valid {
|
||||||
return Err(glib::glib_bool_error!("channel positions are invalid"));
|
return Err(glib::bool_error!("channel positions are invalid"));
|
||||||
}
|
}
|
||||||
|
|
||||||
Some(positions)
|
Some(positions)
|
||||||
|
@ -82,7 +82,7 @@ impl<'a> AudioInfoBuilder<'a> {
|
||||||
let mut info = info.assume_init();
|
let mut info = info.assume_init();
|
||||||
|
|
||||||
if info.finfo.is_null() || info.rate <= 0 || info.channels <= 0 {
|
if info.finfo.is_null() || info.rate <= 0 || info.channels <= 0 {
|
||||||
return Err(glib::glib_bool_error!("Failed to build AudioInfo"));
|
return Err(glib::bool_error!("Failed to build AudioInfo"));
|
||||||
}
|
}
|
||||||
|
|
||||||
if let Some(flags) = self.flags {
|
if let Some(flags) = self.flags {
|
||||||
|
@ -155,9 +155,7 @@ impl AudioInfo {
|
||||||
let positions = array_init::array_init(|i| from_glib(info.position[i]));
|
let positions = array_init::array_init(|i| from_glib(info.position[i]));
|
||||||
Ok(AudioInfo(info, positions))
|
Ok(AudioInfo(info, positions))
|
||||||
} else {
|
} else {
|
||||||
Err(glib::glib_bool_error!(
|
Err(glib::bool_error!("Failed to create AudioInfo from caps"))
|
||||||
"Failed to create AudioInfo from caps"
|
|
||||||
))
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -167,9 +165,7 @@ impl AudioInfo {
|
||||||
let result = from_glib_full(ffi::gst_audio_info_to_caps(&self.0));
|
let result = from_glib_full(ffi::gst_audio_info_to_caps(&self.0));
|
||||||
match result {
|
match result {
|
||||||
Some(c) => Ok(c),
|
Some(c) => Ok(c),
|
||||||
None => Err(glib::glib_bool_error!(
|
None => Err(glib::bool_error!("Failed to create caps from AudioInfo")),
|
||||||
"Failed to create caps from AudioInfo"
|
|
||||||
)),
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -92,7 +92,7 @@ impl AudioMeta {
|
||||||
skip_assert_initialized!();
|
skip_assert_initialized!();
|
||||||
|
|
||||||
if !info.is_valid() {
|
if !info.is_valid() {
|
||||||
return Err(glib::glib_bool_error!("Invalid audio info"));
|
return Err(glib::bool_error!("Invalid audio info"));
|
||||||
}
|
}
|
||||||
|
|
||||||
if info.rate() == 0
|
if info.rate() == 0
|
||||||
|
@ -100,20 +100,17 @@ impl AudioMeta {
|
||||||
|| info.format() == crate::AudioFormat::Unknown
|
|| info.format() == crate::AudioFormat::Unknown
|
||||||
|| info.format() == crate::AudioFormat::Encoded
|
|| info.format() == crate::AudioFormat::Encoded
|
||||||
{
|
{
|
||||||
return Err(glib::glib_bool_error!(
|
return Err(glib::bool_error!("Unsupported audio format {:?}", info));
|
||||||
"Unsupported audio format {:?}",
|
|
||||||
info
|
|
||||||
));
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if !offsets.is_empty() && info.layout() != crate::AudioLayout::NonInterleaved {
|
if !offsets.is_empty() && info.layout() != crate::AudioLayout::NonInterleaved {
|
||||||
return Err(glib::glib_bool_error!(
|
return Err(glib::bool_error!(
|
||||||
"Channel offsets only supported for non-interleaved audio"
|
"Channel offsets only supported for non-interleaved audio"
|
||||||
));
|
));
|
||||||
}
|
}
|
||||||
|
|
||||||
if !offsets.is_empty() && offsets.len() != info.channels() as usize {
|
if !offsets.is_empty() && offsets.len() != info.channels() as usize {
|
||||||
return Err(glib::glib_bool_error!(
|
return Err(glib::bool_error!(
|
||||||
"Number of channel offsets different than number of channels ({} != {})",
|
"Number of channel offsets different than number of channels ({} != {})",
|
||||||
offsets.len(),
|
offsets.len(),
|
||||||
info.channels()
|
info.channels()
|
||||||
|
@ -139,7 +136,7 @@ impl AudioMeta {
|
||||||
&& !(other_offset + plane_size <= offset
|
&& !(other_offset + plane_size <= offset
|
||||||
|| offset + plane_size <= other_offset)
|
|| offset + plane_size <= other_offset)
|
||||||
{
|
{
|
||||||
return Err(glib::glib_bool_error!("Overlapping audio channel offsets: offset {} for channel {} and offset {} for channel {} with a plane size of {}", offset, i, other_offset, j, plane_size));
|
return Err(glib::bool_error!("Overlapping audio channel offsets: offset {} for channel {} and offset {} for channel {} with a plane size of {}", offset, i, other_offset, j, plane_size));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -148,7 +145,7 @@ impl AudioMeta {
|
||||||
};
|
};
|
||||||
|
|
||||||
if max_offset + plane_size > buffer.get_size() {
|
if max_offset + plane_size > buffer.get_size() {
|
||||||
return Err(glib::glib_bool_error!("Audio channel offsets out of bounds: max offset {} with plane size {} and buffer size {}", max_offset, plane_size, buffer.get_size()));
|
return Err(glib::bool_error!("Audio channel offsets out of bounds: max offset {} with plane size {} and buffer size {}", max_offset, plane_size, buffer.get_size()));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -165,7 +162,7 @@ impl AudioMeta {
|
||||||
);
|
);
|
||||||
|
|
||||||
if meta.is_null() {
|
if meta.is_null() {
|
||||||
return Err(glib::glib_bool_error!("Failed to add audio meta"));
|
return Err(glib::bool_error!("Failed to add audio meta"));
|
||||||
}
|
}
|
||||||
|
|
||||||
Ok(Self::from_mut_ptr(buffer, meta))
|
Ok(Self::from_mut_ptr(buffer, meta))
|
||||||
|
|
|
@ -66,7 +66,7 @@ impl Adapter {
|
||||||
|
|
||||||
unsafe {
|
unsafe {
|
||||||
Option::<_>::from_glib_full(ffi::gst_adapter_get_buffer(self.to_glib_none().0, nbytes))
|
Option::<_>::from_glib_full(ffi::gst_adapter_get_buffer(self.to_glib_none().0, nbytes))
|
||||||
.ok_or_else(|| glib::glib_bool_error!("Failed to get buffer"))
|
.ok_or_else(|| glib::bool_error!("Failed to get buffer"))
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -79,7 +79,7 @@ impl Adapter {
|
||||||
self.to_glib_none().0,
|
self.to_glib_none().0,
|
||||||
nbytes,
|
nbytes,
|
||||||
))
|
))
|
||||||
.ok_or_else(|| glib::glib_bool_error!("Failed to get buffer"))
|
.ok_or_else(|| glib::bool_error!("Failed to get buffer"))
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -92,7 +92,7 @@ impl Adapter {
|
||||||
self.to_glib_none().0,
|
self.to_glib_none().0,
|
||||||
nbytes,
|
nbytes,
|
||||||
))
|
))
|
||||||
.ok_or_else(|| glib::glib_bool_error!("Failed to get buffer list"))
|
.ok_or_else(|| glib::bool_error!("Failed to get buffer list"))
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -173,7 +173,7 @@ impl Adapter {
|
||||||
|
|
||||||
unsafe {
|
unsafe {
|
||||||
Option::<_>::from_glib_full(ffi::gst_adapter_take_buffer(self.to_glib_none().0, nbytes))
|
Option::<_>::from_glib_full(ffi::gst_adapter_take_buffer(self.to_glib_none().0, nbytes))
|
||||||
.ok_or_else(|| glib::glib_bool_error!("Failed to take buffer"))
|
.ok_or_else(|| glib::bool_error!("Failed to take buffer"))
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -186,7 +186,7 @@ impl Adapter {
|
||||||
self.to_glib_none().0,
|
self.to_glib_none().0,
|
||||||
nbytes,
|
nbytes,
|
||||||
))
|
))
|
||||||
.ok_or_else(|| glib::glib_bool_error!("Failed to take buffer"))
|
.ok_or_else(|| glib::bool_error!("Failed to take buffer"))
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -199,7 +199,7 @@ impl Adapter {
|
||||||
self.to_glib_none().0,
|
self.to_glib_none().0,
|
||||||
nbytes,
|
nbytes,
|
||||||
))
|
))
|
||||||
.ok_or_else(|| glib::glib_bool_error!("Failed to take buffer list"))
|
.ok_or_else(|| glib::bool_error!("Failed to take buffer list"))
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -395,7 +395,7 @@ impl UniqueAdapter {
|
||||||
unsafe {
|
unsafe {
|
||||||
let ptr = ffi::gst_adapter_map(self.0.to_glib_none().0, nbytes);
|
let ptr = ffi::gst_adapter_map(self.0.to_glib_none().0, nbytes);
|
||||||
if ptr.is_null() {
|
if ptr.is_null() {
|
||||||
Err(glib::glib_bool_error!("size bytes are not available"))
|
Err(glib::bool_error!("size bytes are not available"))
|
||||||
} else {
|
} else {
|
||||||
Ok(UniqueAdapterMap(
|
Ok(UniqueAdapterMap(
|
||||||
self,
|
self,
|
||||||
|
|
|
@ -105,7 +105,7 @@ impl<O: IsA<BaseSink>> BaseSinkExtManual for O {
|
||||||
from_glib(max_latency),
|
from_glib(max_latency),
|
||||||
))
|
))
|
||||||
} else {
|
} else {
|
||||||
Err(glib::glib_bool_error!("Failed to query latency"))
|
Err(glib::bool_error!("Failed to query latency"))
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -90,7 +90,7 @@ impl<O: IsA<BaseSrc>> BaseSrcExtManual for O {
|
||||||
from_glib(max_latency),
|
from_glib(max_latency),
|
||||||
))
|
))
|
||||||
} else {
|
} else {
|
||||||
Err(glib::glib_bool_error!("Failed to query latency"))
|
Err(glib::bool_error!("Failed to query latency"))
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -107,7 +107,7 @@ impl<O: IsA<BaseSrc>> BaseSrcExtManual for O {
|
||||||
if ret {
|
if ret {
|
||||||
Ok(())
|
Ok(())
|
||||||
} else {
|
} else {
|
||||||
Err(glib::glib_bool_error!("Failed to configure new segment"))
|
Err(glib::bool_error!("Failed to configure new segment"))
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -3,7 +3,7 @@
|
||||||
use glib::object::IsA;
|
use glib::object::IsA;
|
||||||
use glib::translate::*;
|
use glib::translate::*;
|
||||||
|
|
||||||
glib::glib_wrapper! {
|
glib::wrapper! {
|
||||||
#[derive(Debug, PartialEq, Eq, PartialOrd, Ord, Hash)]
|
#[derive(Debug, PartialEq, Eq, PartialOrd, Ord, Hash)]
|
||||||
pub struct FlowCombiner(Shared<ffi::GstFlowCombiner>);
|
pub struct FlowCombiner(Shared<ffi::GstFlowCombiner>);
|
||||||
|
|
||||||
|
|
|
@ -20,7 +20,7 @@ pub fn type_find_helper_for_data<P: IsA<gst::Object>, R: AsRef<[u8]>>(
|
||||||
prob.as_mut_ptr(),
|
prob.as_mut_ptr(),
|
||||||
);
|
);
|
||||||
if ret.is_null() {
|
if ret.is_null() {
|
||||||
Err(glib::glib_bool_error!("No type could be found"))
|
Err(glib::bool_error!("No type could be found"))
|
||||||
} else {
|
} else {
|
||||||
Ok((from_glib_full(ret), from_glib(prob.assume_init())))
|
Ok((from_glib_full(ret), from_glib(prob.assume_init())))
|
||||||
}
|
}
|
||||||
|
@ -47,7 +47,7 @@ pub fn type_find_helper_for_data_with_extension<P: IsA<gst::Object>, R: AsRef<[u
|
||||||
prob.as_mut_ptr(),
|
prob.as_mut_ptr(),
|
||||||
);
|
);
|
||||||
if ret.is_null() {
|
if ret.is_null() {
|
||||||
Err(glib::glib_bool_error!("No type could be found"))
|
Err(glib::bool_error!("No type could be found"))
|
||||||
} else {
|
} else {
|
||||||
Ok((from_glib_full(ret), from_glib(prob.assume_init())))
|
Ok((from_glib_full(ret), from_glib(prob.assume_init())))
|
||||||
}
|
}
|
||||||
|
@ -67,7 +67,7 @@ pub fn type_find_helper_for_buffer<P: IsA<gst::Object>>(
|
||||||
prob.as_mut_ptr(),
|
prob.as_mut_ptr(),
|
||||||
);
|
);
|
||||||
if ret.is_null() {
|
if ret.is_null() {
|
||||||
Err(glib::glib_bool_error!("No type could be found"))
|
Err(glib::bool_error!("No type could be found"))
|
||||||
} else {
|
} else {
|
||||||
Ok((from_glib_full(ret), from_glib(prob.assume_init())))
|
Ok((from_glib_full(ret), from_glib(prob.assume_init())))
|
||||||
}
|
}
|
||||||
|
@ -91,7 +91,7 @@ pub fn type_find_helper_for_buffer_with_extension<P: IsA<gst::Object>>(
|
||||||
prob.as_mut_ptr(),
|
prob.as_mut_ptr(),
|
||||||
);
|
);
|
||||||
if ret.is_null() {
|
if ret.is_null() {
|
||||||
Err(glib::glib_bool_error!("No type could be found"))
|
Err(glib::bool_error!("No type could be found"))
|
||||||
} else {
|
} else {
|
||||||
Ok((from_glib_full(ret), from_glib(prob.assume_init())))
|
Ok((from_glib_full(ret), from_glib(prob.assume_init())))
|
||||||
}
|
}
|
||||||
|
|
|
@ -157,7 +157,7 @@ impl Harness {
|
||||||
|
|
||||||
pub fn crank_multiple_clock_waits(&mut self, waits: u32) -> Result<(), glib::BoolError> {
|
pub fn crank_multiple_clock_waits(&mut self, waits: u32) -> Result<(), glib::BoolError> {
|
||||||
unsafe {
|
unsafe {
|
||||||
glib::glib_result_from_gboolean!(
|
glib::result_from_gboolean!(
|
||||||
ffi::gst_harness_crank_multiple_clock_waits(self.0.as_ptr(), waits),
|
ffi::gst_harness_crank_multiple_clock_waits(self.0.as_ptr(), waits),
|
||||||
"Failed to crank multiple clock waits",
|
"Failed to crank multiple clock waits",
|
||||||
)
|
)
|
||||||
|
@ -166,7 +166,7 @@ impl Harness {
|
||||||
|
|
||||||
pub fn crank_single_clock_wait(&mut self) -> Result<(), glib::BoolError> {
|
pub fn crank_single_clock_wait(&mut self) -> Result<(), glib::BoolError> {
|
||||||
unsafe {
|
unsafe {
|
||||||
glib::glib_result_from_gboolean!(
|
glib::result_from_gboolean!(
|
||||||
ffi::gst_harness_crank_single_clock_wait(self.0.as_ptr()),
|
ffi::gst_harness_crank_single_clock_wait(self.0.as_ptr()),
|
||||||
"Failed to crank single clock wait",
|
"Failed to crank single clock wait",
|
||||||
)
|
)
|
||||||
|
@ -176,7 +176,7 @@ impl Harness {
|
||||||
pub fn create_buffer(&mut self, size: usize) -> Result<gst::Buffer, glib::BoolError> {
|
pub fn create_buffer(&mut self, size: usize) -> Result<gst::Buffer, glib::BoolError> {
|
||||||
unsafe {
|
unsafe {
|
||||||
Option::<_>::from_glib_full(ffi::gst_harness_create_buffer(self.0.as_ptr(), size))
|
Option::<_>::from_glib_full(ffi::gst_harness_create_buffer(self.0.as_ptr(), size))
|
||||||
.ok_or_else(|| glib::glib_bool_error!("Failed to create new buffer"))
|
.ok_or_else(|| glib::bool_error!("Failed to create new buffer"))
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -238,21 +238,21 @@ impl Harness {
|
||||||
pub fn pull(&mut self) -> Result<gst::Buffer, glib::BoolError> {
|
pub fn pull(&mut self) -> Result<gst::Buffer, glib::BoolError> {
|
||||||
unsafe {
|
unsafe {
|
||||||
Option::<_>::from_glib_full(ffi::gst_harness_pull(self.0.as_ptr()))
|
Option::<_>::from_glib_full(ffi::gst_harness_pull(self.0.as_ptr()))
|
||||||
.ok_or_else(|| glib::glib_bool_error!("Failed to pull buffer"))
|
.ok_or_else(|| glib::bool_error!("Failed to pull buffer"))
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn pull_event(&mut self) -> Result<gst::Event, glib::BoolError> {
|
pub fn pull_event(&mut self) -> Result<gst::Event, glib::BoolError> {
|
||||||
unsafe {
|
unsafe {
|
||||||
Option::<_>::from_glib_full(ffi::gst_harness_pull_event(self.0.as_ptr()))
|
Option::<_>::from_glib_full(ffi::gst_harness_pull_event(self.0.as_ptr()))
|
||||||
.ok_or_else(|| glib::glib_bool_error!("Failed to pull event"))
|
.ok_or_else(|| glib::bool_error!("Failed to pull event"))
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn pull_upstream_event(&mut self) -> Result<gst::Event, glib::BoolError> {
|
pub fn pull_upstream_event(&mut self) -> Result<gst::Event, glib::BoolError> {
|
||||||
unsafe {
|
unsafe {
|
||||||
Option::<_>::from_glib_full(ffi::gst_harness_pull_upstream_event(self.0.as_ptr()))
|
Option::<_>::from_glib_full(ffi::gst_harness_pull_upstream_event(self.0.as_ptr()))
|
||||||
.ok_or_else(|| glib::glib_bool_error!("Failed to pull event"))
|
.ok_or_else(|| glib::bool_error!("Failed to pull event"))
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -268,7 +268,7 @@ impl Harness {
|
||||||
self.0.as_ptr(),
|
self.0.as_ptr(),
|
||||||
buffer.into_ptr(),
|
buffer.into_ptr(),
|
||||||
))
|
))
|
||||||
.ok_or_else(|| glib::glib_bool_error!("Failed to push and pull buffer"))
|
.ok_or_else(|| glib::bool_error!("Failed to push and pull buffer"))
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -374,7 +374,7 @@ impl Harness {
|
||||||
|
|
||||||
pub fn set_time(&mut self, time: gst::ClockTime) -> Result<(), glib::BoolError> {
|
pub fn set_time(&mut self, time: gst::ClockTime) -> Result<(), glib::BoolError> {
|
||||||
unsafe {
|
unsafe {
|
||||||
glib::glib_result_from_gboolean!(
|
glib::result_from_gboolean!(
|
||||||
ffi::gst_harness_set_time(self.0.as_ptr(), time.to_glib()),
|
ffi::gst_harness_set_time(self.0.as_ptr(), time.to_glib()),
|
||||||
"Failed to set time",
|
"Failed to set time",
|
||||||
)
|
)
|
||||||
|
@ -461,7 +461,7 @@ impl Harness {
|
||||||
pub fn take_all_data_as_buffer(&mut self) -> Result<gst::Buffer, glib::BoolError> {
|
pub fn take_all_data_as_buffer(&mut self) -> Result<gst::Buffer, glib::BoolError> {
|
||||||
unsafe {
|
unsafe {
|
||||||
Option::<_>::from_glib_full(ffi::gst_harness_take_all_data_as_buffer(self.0.as_ptr()))
|
Option::<_>::from_glib_full(ffi::gst_harness_take_all_data_as_buffer(self.0.as_ptr()))
|
||||||
.ok_or_else(|| glib::glib_bool_error!("Failed to take all data as buffer"))
|
.ok_or_else(|| glib::bool_error!("Failed to take all data as buffer"))
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -470,7 +470,7 @@ impl Harness {
|
||||||
pub fn take_all_data_as_bytes(&mut self) -> Result<glib::Bytes, glib::BoolError> {
|
pub fn take_all_data_as_bytes(&mut self) -> Result<glib::Bytes, glib::BoolError> {
|
||||||
unsafe {
|
unsafe {
|
||||||
Option::<_>::from_glib_full(ffi::gst_harness_take_all_data_as_bytes(self.0.as_ptr()))
|
Option::<_>::from_glib_full(ffi::gst_harness_take_all_data_as_bytes(self.0.as_ptr()))
|
||||||
.ok_or_else(|| glib::glib_bool_error!("Failed to take all data as bytes"))
|
.ok_or_else(|| glib::bool_error!("Failed to take all data as bytes"))
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -512,7 +512,7 @@ impl Harness {
|
||||||
timeout: u32,
|
timeout: u32,
|
||||||
) -> Result<(), glib::BoolError> {
|
) -> Result<(), glib::BoolError> {
|
||||||
unsafe {
|
unsafe {
|
||||||
glib::glib_result_from_gboolean!(
|
glib::result_from_gboolean!(
|
||||||
ffi::gst_harness_wait_for_clock_id_waits(self.0.as_ptr(), waits, timeout),
|
ffi::gst_harness_wait_for_clock_id_waits(self.0.as_ptr(), waits, timeout),
|
||||||
"Failed to wait for clock id waits",
|
"Failed to wait for clock id waits",
|
||||||
)
|
)
|
||||||
|
|
|
@ -2,7 +2,7 @@
|
||||||
|
|
||||||
use glib::translate::*;
|
use glib::translate::*;
|
||||||
|
|
||||||
glib::glib_wrapper! {
|
glib::wrapper! {
|
||||||
#[derive(Debug, PartialEq, Eq, PartialOrd, Ord, Hash)]
|
#[derive(Debug, PartialEq, Eq, PartialOrd, Ord, Hash)]
|
||||||
pub struct ControlPoint(Boxed<ffi::GstControlPoint>);
|
pub struct ControlPoint(Boxed<ffi::GstControlPoint>);
|
||||||
|
|
||||||
|
|
|
@ -12,14 +12,14 @@ static GES_INIT: Once = Once::new();
|
||||||
|
|
||||||
pub fn init() -> Result<(), glib::BoolError> {
|
pub fn init() -> Result<(), glib::BoolError> {
|
||||||
if gst::init().is_err() {
|
if gst::init().is_err() {
|
||||||
return Err(glib::glib_bool_error!("Could not initialize GStreamer."));
|
return Err(glib::bool_error!("Could not initialize GStreamer."));
|
||||||
}
|
}
|
||||||
|
|
||||||
unsafe {
|
unsafe {
|
||||||
if from_glib(ffi::ges_init()) {
|
if from_glib(ffi::ges_init()) {
|
||||||
Ok(())
|
Ok(())
|
||||||
} else {
|
} else {
|
||||||
Err(glib::glib_bool_error!("Could not initialize GES."))
|
Err(glib::bool_error!("Could not initialize GES."))
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -50,7 +50,7 @@ impl<O: IsA<TimelineElement>> TimelineElementExtManual for O {
|
||||||
ptr::null_mut(),
|
ptr::null_mut(),
|
||||||
));
|
));
|
||||||
if !found {
|
if !found {
|
||||||
return Err(glib::glib_bool_error!("Child property not found"));
|
return Err(glib::bool_error!("Child property not found"));
|
||||||
}
|
}
|
||||||
|
|
||||||
let value = value.to_value();
|
let value = value.to_value();
|
||||||
|
|
|
@ -19,7 +19,7 @@ impl GLDisplayEGL {
|
||||||
from_glib_full::<_, Option<GLDisplayEGL>>(ffi::gst_gl_display_egl_new_with_egl_display(
|
from_glib_full::<_, Option<GLDisplayEGL>>(ffi::gst_gl_display_egl_new_with_egl_display(
|
||||||
display as gpointer,
|
display as gpointer,
|
||||||
))
|
))
|
||||||
.ok_or_else(|| glib::glib_bool_error!("Failed to create new EGL GL display"))
|
.ok_or_else(|| glib::bool_error!("Failed to create new EGL GL display"))
|
||||||
}
|
}
|
||||||
|
|
||||||
pub unsafe fn get_from_native(display_type: GLDisplayType, display: uintptr_t) -> gpointer {
|
pub unsafe fn get_from_native(display_type: GLDisplayType, display: uintptr_t) -> gpointer {
|
||||||
|
|
|
@ -88,14 +88,14 @@ impl<'a> VideoFrameGLExt for gst_video::VideoFrameRef<&'a gst::BufferRef> {
|
||||||
|
|
||||||
let n_mem = match buffer_n_gl_memory(buffer) {
|
let n_mem = match buffer_n_gl_memory(buffer) {
|
||||||
Some(n) => n,
|
Some(n) => n,
|
||||||
None => return Err(glib::glib_bool_error!("Memory is not a GstGLMemory")),
|
None => return Err(glib::bool_error!("Memory is not a GstGLMemory")),
|
||||||
};
|
};
|
||||||
|
|
||||||
// FIXME: planes are not memories, in multiview use case,
|
// FIXME: planes are not memories, in multiview use case,
|
||||||
// number of memories = planes * views, but the raw memory is
|
// number of memories = planes * views, but the raw memory is
|
||||||
// not exposed in videoframe
|
// not exposed in videoframe
|
||||||
if n_mem != info.n_planes() {
|
if n_mem != info.n_planes() {
|
||||||
return Err(glib::glib_bool_error!(
|
return Err(glib::bool_error!(
|
||||||
"Number of planes and memories is not matching"
|
"Number of planes and memories is not matching"
|
||||||
));
|
));
|
||||||
}
|
}
|
||||||
|
@ -112,7 +112,7 @@ impl<'a> VideoFrameGLExt for gst_video::VideoFrameRef<&'a gst::BufferRef> {
|
||||||
));
|
));
|
||||||
|
|
||||||
if !res {
|
if !res {
|
||||||
Err(glib::glib_bool_error!(
|
Err(glib::bool_error!(
|
||||||
"Failed to fill in the values of GstVideoFrame"
|
"Failed to fill in the values of GstVideoFrame"
|
||||||
))
|
))
|
||||||
} else {
|
} else {
|
||||||
|
|
|
@ -18,6 +18,6 @@ impl GLDisplayWayland {
|
||||||
from_glib_full::<_, Option<GLDisplayWayland>>(ffi::gst_gl_display_wayland_new_with_display(
|
from_glib_full::<_, Option<GLDisplayWayland>>(ffi::gst_gl_display_wayland_new_with_display(
|
||||||
display as gpointer,
|
display as gpointer,
|
||||||
))
|
))
|
||||||
.ok_or_else(|| glib::glib_bool_error!("Failed to create new Wayland GL display"))
|
.ok_or_else(|| glib::bool_error!("Failed to create new Wayland GL display"))
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -16,6 +16,6 @@ impl GLDisplayX11 {
|
||||||
from_glib_full::<_, Option<GLDisplayX11>>(ffi::gst_gl_display_x11_new_with_display(
|
from_glib_full::<_, Option<GLDisplayX11>>(ffi::gst_gl_display_x11_new_with_display(
|
||||||
display as gpointer,
|
display as gpointer,
|
||||||
))
|
))
|
||||||
.ok_or_else(|| glib::glib_bool_error!("Failed to create new X11 GL display"))
|
.ok_or_else(|| glib::bool_error!("Failed to create new X11 GL display"))
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -227,7 +227,7 @@ impl EncodingContainerProfile {
|
||||||
profile: &P,
|
profile: &P,
|
||||||
) -> Result<(), glib::error::BoolError> {
|
) -> Result<(), glib::error::BoolError> {
|
||||||
unsafe {
|
unsafe {
|
||||||
glib::glib_result_from_gboolean!(
|
glib::result_from_gboolean!(
|
||||||
ffi::gst_encoding_container_profile_add_profile(
|
ffi::gst_encoding_container_profile_add_profile(
|
||||||
self.to_glib_none().0,
|
self.to_glib_none().0,
|
||||||
profile.as_ref().to_glib_full(),
|
profile.as_ref().to_glib_full(),
|
||||||
|
|
|
@ -18,7 +18,7 @@ pub fn pb_utils_add_codec_description_to_tag_list_for_tag<'a, T: CodecTag<'a>>(
|
||||||
assert_initialized_main_thread!();
|
assert_initialized_main_thread!();
|
||||||
let codec_tag = T::tag_name();
|
let codec_tag = T::tag_name();
|
||||||
unsafe {
|
unsafe {
|
||||||
glib::glib_result_from_gboolean!(
|
glib::result_from_gboolean!(
|
||||||
ffi::gst_pb_utils_add_codec_description_to_tag_list(
|
ffi::gst_pb_utils_add_codec_description_to_tag_list(
|
||||||
taglist.as_mut_ptr(),
|
taglist.as_mut_ptr(),
|
||||||
codec_tag.to_glib_none().0,
|
codec_tag.to_glib_none().0,
|
||||||
|
@ -35,7 +35,7 @@ pub fn pb_utils_add_codec_description_to_tag_list(
|
||||||
) -> Result<(), glib::BoolError> {
|
) -> Result<(), glib::BoolError> {
|
||||||
assert_initialized_main_thread!();
|
assert_initialized_main_thread!();
|
||||||
unsafe {
|
unsafe {
|
||||||
glib::glib_result_from_gboolean!(
|
glib::result_from_gboolean!(
|
||||||
ffi::gst_pb_utils_add_codec_description_to_tag_list(
|
ffi::gst_pb_utils_add_codec_description_to_tag_list(
|
||||||
taglist.as_mut_ptr(),
|
taglist.as_mut_ptr(),
|
||||||
ptr::null_mut(),
|
ptr::null_mut(),
|
||||||
|
@ -53,7 +53,7 @@ pub fn pb_utils_get_encoder_description(
|
||||||
unsafe {
|
unsafe {
|
||||||
match from_glib_full(ffi::gst_pb_utils_get_encoder_description(caps.as_ptr())) {
|
match from_glib_full(ffi::gst_pb_utils_get_encoder_description(caps.as_ptr())) {
|
||||||
Some(s) => Ok(s),
|
Some(s) => Ok(s),
|
||||||
None => Err(glib::glib_bool_error!("Failed to get encoder description")),
|
None => Err(glib::bool_error!("Failed to get encoder description")),
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -65,7 +65,7 @@ pub fn pb_utils_get_decoder_description(
|
||||||
unsafe {
|
unsafe {
|
||||||
match from_glib_full(ffi::gst_pb_utils_get_decoder_description(caps.as_ptr())) {
|
match from_glib_full(ffi::gst_pb_utils_get_decoder_description(caps.as_ptr())) {
|
||||||
Some(s) => Ok(s),
|
Some(s) => Ok(s),
|
||||||
None => Err(glib::glib_bool_error!("Failed to get decoder description")),
|
None => Err(glib::bool_error!("Failed to get decoder description")),
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -77,7 +77,7 @@ pub fn pb_utils_get_codec_description(
|
||||||
unsafe {
|
unsafe {
|
||||||
match from_glib_full(ffi::gst_pb_utils_get_codec_description(caps.as_ptr())) {
|
match from_glib_full(ffi::gst_pb_utils_get_codec_description(caps.as_ptr())) {
|
||||||
Some(s) => Ok(s),
|
Some(s) => Ok(s),
|
||||||
None => Err(glib::glib_bool_error!("Failed to get codec description")),
|
None => Err(glib::bool_error!("Failed to get codec description")),
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -35,7 +35,7 @@ impl Player {
|
||||||
|
|
||||||
pub fn set_config(&self, config: crate::PlayerConfig) -> Result<(), glib::error::BoolError> {
|
pub fn set_config(&self, config: crate::PlayerConfig) -> Result<(), glib::error::BoolError> {
|
||||||
unsafe {
|
unsafe {
|
||||||
glib::glib_result_from_gboolean!(
|
glib::result_from_gboolean!(
|
||||||
ffi::gst_player_set_config(self.to_glib_none().0, config.into_ptr()),
|
ffi::gst_player_set_config(self.to_glib_none().0, config.into_ptr()),
|
||||||
"Failed to set config",
|
"Failed to set config",
|
||||||
)
|
)
|
||||||
|
|
|
@ -49,7 +49,7 @@ impl<'a> RTPBuffer<'a, Readable> {
|
||||||
phantom: PhantomData,
|
phantom: PhantomData,
|
||||||
})
|
})
|
||||||
} else {
|
} else {
|
||||||
Err(glib::glib_bool_error!("Failed to map RTP buffer readable"))
|
Err(glib::bool_error!("Failed to map RTP buffer readable"))
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -75,7 +75,7 @@ impl<'a> RTPBuffer<'a, Writable> {
|
||||||
phantom: PhantomData,
|
phantom: PhantomData,
|
||||||
})
|
})
|
||||||
} else {
|
} else {
|
||||||
Err(glib::glib_bool_error!("Failed to map RTP buffer writable"))
|
Err(glib::bool_error!("Failed to map RTP buffer writable"))
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -139,9 +139,7 @@ impl<'a> RTPBuffer<'a, Writable> {
|
||||||
if result {
|
if result {
|
||||||
Ok(())
|
Ok(())
|
||||||
} else {
|
} else {
|
||||||
Err(glib::glib_bool_error!(
|
Err(glib::bool_error!("Failed to add onebyte header extension"))
|
||||||
"Failed to add onebyte header extension"
|
|
||||||
))
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -169,9 +167,7 @@ impl<'a> RTPBuffer<'a, Writable> {
|
||||||
if result {
|
if result {
|
||||||
Ok(())
|
Ok(())
|
||||||
} else {
|
} else {
|
||||||
Err(glib::glib_bool_error!(
|
Err(glib::bool_error!("Failed to add twobytes header extension"))
|
||||||
"Failed to add twobytes header extension"
|
|
||||||
))
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -241,7 +237,7 @@ impl<'a, T> RTPBuffer<'a, T> {
|
||||||
let pointer =
|
let pointer =
|
||||||
ffi::gst_rtp_buffer_get_payload(glib::translate::mut_override(&self.rtp_buffer));
|
ffi::gst_rtp_buffer_get_payload(glib::translate::mut_override(&self.rtp_buffer));
|
||||||
if pointer.is_null() {
|
if pointer.is_null() {
|
||||||
Err(glib::glib_bool_error!("Failed to get payload data"))
|
Err(glib::bool_error!("Failed to get payload data"))
|
||||||
} else {
|
} else {
|
||||||
Ok(slice::from_raw_parts(pointer as *const u8, size as usize))
|
Ok(slice::from_raw_parts(pointer as *const u8, size as usize))
|
||||||
}
|
}
|
||||||
|
@ -346,7 +342,7 @@ impl RTPBufferExt for gst::Buffer {
|
||||||
pad_len,
|
pad_len,
|
||||||
csrc_count,
|
csrc_count,
|
||||||
))
|
))
|
||||||
.ok_or_else(|| glib::glib_bool_error!("Failed to allocate new RTP buffer"))
|
.ok_or_else(|| glib::bool_error!("Failed to allocate new RTP buffer"))
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -14,7 +14,7 @@ use crate::sdp_bandwidth::SDPBandwidth;
|
||||||
use crate::sdp_connection::SDPConnection;
|
use crate::sdp_connection::SDPConnection;
|
||||||
use crate::sdp_key::SDPKey;
|
use crate::sdp_key::SDPKey;
|
||||||
|
|
||||||
glib::glib_wrapper! {
|
glib::wrapper! {
|
||||||
#[derive(PartialEq, Eq, PartialOrd, Ord, Hash)]
|
#[derive(PartialEq, Eq, PartialOrd, Ord, Hash)]
|
||||||
pub struct SDPMedia(Boxed<ffi::GstSDPMedia>);
|
pub struct SDPMedia(Boxed<ffi::GstSDPMedia>);
|
||||||
|
|
||||||
|
@ -160,7 +160,7 @@ impl SDPMediaRef {
|
||||||
unsafe {
|
unsafe {
|
||||||
match from_glib_full(ffi::gst_sdp_media_as_text(&self.0)) {
|
match from_glib_full(ffi::gst_sdp_media_as_text(&self.0)) {
|
||||||
Some(s) => Ok(s),
|
Some(s) => Ok(s),
|
||||||
None => Err(glib::glib_bool_error!(
|
None => Err(glib::bool_error!(
|
||||||
"Failed to convert the contents of media to a text string"
|
"Failed to convert the contents of media to a text string"
|
||||||
)),
|
)),
|
||||||
}
|
}
|
||||||
|
|
|
@ -19,7 +19,7 @@ use crate::sdp_origin::SDPOrigin;
|
||||||
use crate::sdp_time::SDPTime;
|
use crate::sdp_time::SDPTime;
|
||||||
use crate::sdp_zone::SDPZone;
|
use crate::sdp_zone::SDPZone;
|
||||||
|
|
||||||
glib::glib_wrapper! {
|
glib::wrapper! {
|
||||||
#[derive(PartialEq, Eq, PartialOrd, Ord, Hash)]
|
#[derive(PartialEq, Eq, PartialOrd, Ord, Hash)]
|
||||||
pub struct SDPMessage(Boxed<ffi::GstSDPMessage>);
|
pub struct SDPMessage(Boxed<ffi::GstSDPMessage>);
|
||||||
|
|
||||||
|
@ -210,7 +210,7 @@ impl SDPMessageRef {
|
||||||
unsafe {
|
unsafe {
|
||||||
match from_glib_full(ffi::gst_sdp_message_as_text(&self.0)) {
|
match from_glib_full(ffi::gst_sdp_message_as_text(&self.0)) {
|
||||||
Some(s) => Ok(s),
|
Some(s) => Ok(s),
|
||||||
None => Err(glib::glib_bool_error!(
|
None => Err(glib::bool_error!(
|
||||||
"Failed to convert the contents of message to a text string"
|
"Failed to convert the contents of message to a text string"
|
||||||
)),
|
)),
|
||||||
}
|
}
|
||||||
|
@ -830,9 +830,7 @@ impl SDPMessageRef {
|
||||||
&self.0,
|
&self.0,
|
||||||
)) {
|
)) {
|
||||||
Some(s) => Ok(s),
|
Some(s) => Ok(s),
|
||||||
None => Err(glib::glib_bool_error!(
|
None => Err(glib::bool_error!("Failed to create an URI from message")),
|
||||||
"Failed to create an URI from message"
|
|
||||||
)),
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -10,7 +10,7 @@ impl crate::VideoColorMatrix {
|
||||||
unsafe {
|
unsafe {
|
||||||
let mut kr = mem::MaybeUninit::uninit();
|
let mut kr = mem::MaybeUninit::uninit();
|
||||||
let mut kb = mem::MaybeUninit::uninit();
|
let mut kb = mem::MaybeUninit::uninit();
|
||||||
glib::glib_result_from_gboolean!(
|
glib::result_from_gboolean!(
|
||||||
ffi::gst_video_color_matrix_get_Kr_Kb(
|
ffi::gst_video_color_matrix_get_Kr_Kb(
|
||||||
self.to_glib(),
|
self.to_glib(),
|
||||||
kr.as_mut_ptr(),
|
kr.as_mut_ptr(),
|
||||||
|
|
|
@ -28,11 +28,11 @@ impl VideoConverter {
|
||||||
) -> Result<Self, glib::BoolError> {
|
) -> Result<Self, glib::BoolError> {
|
||||||
assert_initialized_main_thread!();
|
assert_initialized_main_thread!();
|
||||||
if in_info.fps() != out_info.fps() {
|
if in_info.fps() != out_info.fps() {
|
||||||
return Err(glib::glib_bool_error!("Can't do framerate conversion"));
|
return Err(glib::bool_error!("Can't do framerate conversion"));
|
||||||
}
|
}
|
||||||
|
|
||||||
if in_info.interlace_mode() != out_info.interlace_mode() {
|
if in_info.interlace_mode() != out_info.interlace_mode() {
|
||||||
return Err(glib::glib_bool_error!("Can't do interlacing conversion"));
|
return Err(glib::bool_error!("Can't do interlacing conversion"));
|
||||||
}
|
}
|
||||||
|
|
||||||
unsafe {
|
unsafe {
|
||||||
|
@ -42,7 +42,7 @@ impl VideoConverter {
|
||||||
config.map(|s| s.0.into_ptr()).unwrap_or(ptr::null_mut()),
|
config.map(|s| s.0.into_ptr()).unwrap_or(ptr::null_mut()),
|
||||||
);
|
);
|
||||||
if ptr.is_null() {
|
if ptr.is_null() {
|
||||||
Err(glib::glib_bool_error!("Failed to create video converter"))
|
Err(glib::bool_error!("Failed to create video converter"))
|
||||||
} else {
|
} else {
|
||||||
Ok(VideoConverter(ptr::NonNull::new_unchecked(ptr)))
|
Ok(VideoConverter(ptr::NonNull::new_unchecked(ptr)))
|
||||||
}
|
}
|
||||||
|
@ -130,9 +130,7 @@ impl convert::TryFrom<gst::Structure> for VideoConverterConfig {
|
||||||
if v.get_name() == "GstVideoConverter" {
|
if v.get_name() == "GstVideoConverter" {
|
||||||
Ok(VideoConverterConfig(v))
|
Ok(VideoConverterConfig(v))
|
||||||
} else {
|
} else {
|
||||||
Err(glib::glib_bool_error!(
|
Err(glib::bool_error!("Structure is no VideoConverterConfig"))
|
||||||
"Structure is no VideoConverterConfig"
|
|
||||||
))
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -169,7 +169,7 @@ impl DownstreamForceKeyUnitEvent {
|
||||||
count: count.assume_init(),
|
count: count.assume_init(),
|
||||||
})
|
})
|
||||||
} else {
|
} else {
|
||||||
Err(glib::glib_bool_error!("Failed to parse GstEvent"))
|
Err(glib::bool_error!("Failed to parse GstEvent"))
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -258,7 +258,7 @@ impl UpstreamForceKeyUnitEvent {
|
||||||
count: count.assume_init(),
|
count: count.assume_init(),
|
||||||
})
|
})
|
||||||
} else {
|
} else {
|
||||||
Err(glib::glib_bool_error!("Failed to parse GstEvent"))
|
Err(glib::bool_error!("Failed to parse GstEvent"))
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -334,7 +334,7 @@ impl StillFrameEvent {
|
||||||
in_still: from_glib(in_still.assume_init()),
|
in_still: from_glib(in_still.assume_init()),
|
||||||
})
|
})
|
||||||
} else {
|
} else {
|
||||||
Err(glib::glib_bool_error!("Invalid still-frame event"))
|
Err(glib::bool_error!("Invalid still-frame event"))
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -334,7 +334,7 @@ impl str::FromStr for crate::VideoFormat {
|
||||||
|
|
||||||
let fmt = Self::from_string(s);
|
let fmt = Self::from_string(s);
|
||||||
if fmt == Self::Unknown {
|
if fmt == Self::Unknown {
|
||||||
Err(glib::glib_bool_error!(
|
Err(glib::bool_error!(
|
||||||
"Failed to parse video format from string"
|
"Failed to parse video format from string"
|
||||||
))
|
))
|
||||||
} else {
|
} else {
|
||||||
|
|
|
@ -56,7 +56,7 @@ impl<T> VideoFrame<T> {
|
||||||
if res {
|
if res {
|
||||||
Ok(())
|
Ok(())
|
||||||
} else {
|
} else {
|
||||||
Err(glib::glib_bool_error!("Failed to copy video frame"))
|
Err(glib::bool_error!("Failed to copy video frame"))
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -77,7 +77,7 @@ impl<T> VideoFrame<T> {
|
||||||
if res {
|
if res {
|
||||||
Ok(())
|
Ok(())
|
||||||
} else {
|
} else {
|
||||||
Err(glib::glib_bool_error!("Failed to copy video frame plane"))
|
Err(glib::bool_error!("Failed to copy video frame plane"))
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -140,7 +140,7 @@ impl<T> VideoFrame<T> {
|
||||||
|
|
||||||
pub fn plane_data(&self, plane: u32) -> Result<&[u8], glib::BoolError> {
|
pub fn plane_data(&self, plane: u32) -> Result<&[u8], glib::BoolError> {
|
||||||
if plane >= self.n_planes() {
|
if plane >= self.n_planes() {
|
||||||
return Err(glib::glib_bool_error!(
|
return Err(glib::bool_error!(
|
||||||
"Plane index higher than number of planes"
|
"Plane index higher than number of planes"
|
||||||
));
|
));
|
||||||
}
|
}
|
||||||
|
@ -354,7 +354,7 @@ impl VideoFrame<Writable> {
|
||||||
|
|
||||||
pub fn plane_data_mut(&mut self, plane: u32) -> Result<&mut [u8], glib::BoolError> {
|
pub fn plane_data_mut(&mut self, plane: u32) -> Result<&mut [u8], glib::BoolError> {
|
||||||
if plane >= self.n_planes() {
|
if plane >= self.n_planes() {
|
||||||
return Err(glib::glib_bool_error!(
|
return Err(glib::bool_error!(
|
||||||
"Plane index higher than number of planes"
|
"Plane index higher than number of planes"
|
||||||
));
|
));
|
||||||
}
|
}
|
||||||
|
@ -430,7 +430,7 @@ impl<T> VideoFrameRef<T> {
|
||||||
if res {
|
if res {
|
||||||
Ok(())
|
Ok(())
|
||||||
} else {
|
} else {
|
||||||
Err(glib::glib_bool_error!("Failed to copy video frame"))
|
Err(glib::bool_error!("Failed to copy video frame"))
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -451,7 +451,7 @@ impl<T> VideoFrameRef<T> {
|
||||||
if res {
|
if res {
|
||||||
Ok(())
|
Ok(())
|
||||||
} else {
|
} else {
|
||||||
Err(glib::glib_bool_error!("Failed to copy video frame plane"))
|
Err(glib::bool_error!("Failed to copy video frame plane"))
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -510,7 +510,7 @@ impl<T> VideoFrameRef<T> {
|
||||||
|
|
||||||
pub fn plane_data(&self, plane: u32) -> Result<&[u8], glib::BoolError> {
|
pub fn plane_data(&self, plane: u32) -> Result<&[u8], glib::BoolError> {
|
||||||
if plane >= self.n_planes() {
|
if plane >= self.n_planes() {
|
||||||
return Err(glib::glib_bool_error!(
|
return Err(glib::bool_error!(
|
||||||
"Plane index higher than number of planes"
|
"Plane index higher than number of planes"
|
||||||
));
|
));
|
||||||
}
|
}
|
||||||
|
@ -589,7 +589,7 @@ impl<'a> VideoFrameRef<&'a gst::BufferRef> {
|
||||||
));
|
));
|
||||||
|
|
||||||
if !res {
|
if !res {
|
||||||
Err(glib::glib_bool_error!("Failed to map VideoFrame"))
|
Err(glib::bool_error!("Failed to map VideoFrame"))
|
||||||
} else {
|
} else {
|
||||||
let frame = frame.assume_init();
|
let frame = frame.assume_init();
|
||||||
let info = crate::VideoInfo(ptr::read(&frame.info));
|
let info = crate::VideoInfo(ptr::read(&frame.info));
|
||||||
|
@ -623,7 +623,7 @@ impl<'a> VideoFrameRef<&'a gst::BufferRef> {
|
||||||
));
|
));
|
||||||
|
|
||||||
if !res {
|
if !res {
|
||||||
Err(glib::glib_bool_error!("Failed to map VideoFrame"))
|
Err(glib::bool_error!("Failed to map VideoFrame"))
|
||||||
} else {
|
} else {
|
||||||
let frame = frame.assume_init();
|
let frame = frame.assume_init();
|
||||||
let info = crate::VideoInfo(ptr::read(&frame.info));
|
let info = crate::VideoInfo(ptr::read(&frame.info));
|
||||||
|
@ -688,7 +688,7 @@ impl<'a> VideoFrameRef<&'a mut gst::BufferRef> {
|
||||||
));
|
));
|
||||||
|
|
||||||
if !res {
|
if !res {
|
||||||
Err(glib::glib_bool_error!("Failed to map VideoFrame"))
|
Err(glib::bool_error!("Failed to map VideoFrame"))
|
||||||
} else {
|
} else {
|
||||||
let frame = frame.assume_init();
|
let frame = frame.assume_init();
|
||||||
let info = crate::VideoInfo(ptr::read(&frame.info));
|
let info = crate::VideoInfo(ptr::read(&frame.info));
|
||||||
|
@ -724,7 +724,7 @@ impl<'a> VideoFrameRef<&'a mut gst::BufferRef> {
|
||||||
));
|
));
|
||||||
|
|
||||||
if !res {
|
if !res {
|
||||||
Err(glib::glib_bool_error!("Failed to map VideoFrame"))
|
Err(glib::bool_error!("Failed to map VideoFrame"))
|
||||||
} else {
|
} else {
|
||||||
let frame = frame.assume_init();
|
let frame = frame.assume_init();
|
||||||
let info = crate::VideoInfo(ptr::read(&frame.info));
|
let info = crate::VideoInfo(ptr::read(&frame.info));
|
||||||
|
@ -744,7 +744,7 @@ impl<'a> VideoFrameRef<&'a mut gst::BufferRef> {
|
||||||
|
|
||||||
pub fn plane_data_mut(&mut self, plane: u32) -> Result<&mut [u8], glib::BoolError> {
|
pub fn plane_data_mut(&mut self, plane: u32) -> Result<&mut [u8], glib::BoolError> {
|
||||||
if plane >= self.n_planes() {
|
if plane >= self.n_planes() {
|
||||||
return Err(glib::glib_bool_error!(
|
return Err(glib::bool_error!(
|
||||||
"Plane index higher than number of planes"
|
"Plane index higher than number of planes"
|
||||||
));
|
));
|
||||||
}
|
}
|
||||||
|
|
|
@ -144,7 +144,7 @@ impl str::FromStr for crate::VideoColorimetry {
|
||||||
if valid {
|
if valid {
|
||||||
Ok(Self(colorimetry.assume_init()))
|
Ok(Self(colorimetry.assume_init()))
|
||||||
} else {
|
} else {
|
||||||
Err(glib::glib_bool_error!("Invalid colorimetry info"))
|
Err(glib::bool_error!("Invalid colorimetry info"))
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -202,7 +202,7 @@ impl str::FromStr for crate::VideoChromaSite {
|
||||||
};
|
};
|
||||||
|
|
||||||
if chroma_site.is_empty() {
|
if chroma_site.is_empty() {
|
||||||
Err(glib::glib_bool_error!("Invalid chroma site"))
|
Err(glib::bool_error!("Invalid chroma site"))
|
||||||
} else {
|
} else {
|
||||||
Ok(chroma_site)
|
Ok(chroma_site)
|
||||||
}
|
}
|
||||||
|
@ -233,7 +233,7 @@ impl std::convert::TryFrom<crate::VideoMultiviewMode> for crate::VideoMultiviewF
|
||||||
let v2 = unsafe { from_glib(v.to_glib()) };
|
let v2 = unsafe { from_glib(v.to_glib()) };
|
||||||
|
|
||||||
if let crate::VideoMultiviewFramePacking::__Unknown(_) = v2 {
|
if let crate::VideoMultiviewFramePacking::__Unknown(_) = v2 {
|
||||||
Err(glib::glib_bool_error!("Invalid frame packing mode"))
|
Err(glib::bool_error!("Invalid frame packing mode"))
|
||||||
} else {
|
} else {
|
||||||
Ok(v2)
|
Ok(v2)
|
||||||
}
|
}
|
||||||
|
@ -370,13 +370,13 @@ impl<'a> VideoInfoBuilder<'a> {
|
||||||
}
|
}
|
||||||
|
|
||||||
if !res {
|
if !res {
|
||||||
return Err(glib::glib_bool_error!("Failed to build VideoInfo"));
|
return Err(glib::bool_error!("Failed to build VideoInfo"));
|
||||||
}
|
}
|
||||||
|
|
||||||
let mut info = info.assume_init();
|
let mut info = info.assume_init();
|
||||||
|
|
||||||
if info.finfo.is_null() || info.width <= 0 || info.height <= 0 {
|
if info.finfo.is_null() || info.width <= 0 || info.height <= 0 {
|
||||||
return Err(glib::glib_bool_error!("Failed to build VideoInfo"));
|
return Err(glib::bool_error!("Failed to build VideoInfo"));
|
||||||
}
|
}
|
||||||
|
|
||||||
if let Some(flags) = self.flags {
|
if let Some(flags) = self.flags {
|
||||||
|
@ -411,7 +411,7 @@ impl<'a> VideoInfoBuilder<'a> {
|
||||||
|
|
||||||
if let Some(offset) = self.offset {
|
if let Some(offset) = self.offset {
|
||||||
if offset.len() != ((*info.finfo).n_planes as usize) {
|
if offset.len() != ((*info.finfo).n_planes as usize) {
|
||||||
return Err(glib::glib_bool_error!("Failed to build VideoInfo"));
|
return Err(glib::bool_error!("Failed to build VideoInfo"));
|
||||||
}
|
}
|
||||||
|
|
||||||
let n_planes = (*info.finfo).n_planes as usize;
|
let n_planes = (*info.finfo).n_planes as usize;
|
||||||
|
@ -420,7 +420,7 @@ impl<'a> VideoInfoBuilder<'a> {
|
||||||
|
|
||||||
if let Some(stride) = self.stride {
|
if let Some(stride) = self.stride {
|
||||||
if stride.len() != ((*info.finfo).n_planes as usize) {
|
if stride.len() != ((*info.finfo).n_planes as usize) {
|
||||||
return Err(glib::glib_bool_error!("Failed to build VideoInfo"));
|
return Err(glib::bool_error!("Failed to build VideoInfo"));
|
||||||
}
|
}
|
||||||
|
|
||||||
let n_planes = (*info.finfo).n_planes as usize;
|
let n_planes = (*info.finfo).n_planes as usize;
|
||||||
|
@ -606,9 +606,7 @@ impl VideoInfo {
|
||||||
)) {
|
)) {
|
||||||
Ok(VideoInfo(info.assume_init()))
|
Ok(VideoInfo(info.assume_init()))
|
||||||
} else {
|
} else {
|
||||||
Err(glib::glib_bool_error!(
|
Err(glib::bool_error!("Failed to create VideoInfo from caps"))
|
||||||
"Failed to create VideoInfo from caps"
|
|
||||||
))
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -618,9 +616,7 @@ impl VideoInfo {
|
||||||
let result = from_glib_full(ffi::gst_video_info_to_caps(&self.0 as *const _ as *mut _));
|
let result = from_glib_full(ffi::gst_video_info_to_caps(&self.0 as *const _ as *mut _));
|
||||||
match result {
|
match result {
|
||||||
Some(c) => Ok(c),
|
Some(c) => Ok(c),
|
||||||
None => Err(glib::glib_bool_error!(
|
None => Err(glib::bool_error!("Failed to create caps from VideoInfo")),
|
||||||
"Failed to create caps from VideoInfo"
|
|
||||||
)),
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -800,7 +796,7 @@ impl VideoInfo {
|
||||||
cfg_if::cfg_if! {
|
cfg_if::cfg_if! {
|
||||||
if #[cfg(feature = "v1_12")] {
|
if #[cfg(feature = "v1_12")] {
|
||||||
unsafe {
|
unsafe {
|
||||||
glib::glib_result_from_gboolean!(ffi::gst_video_info_align(
|
glib::result_from_gboolean!(ffi::gst_video_info_align(
|
||||||
&mut self.0,
|
&mut self.0,
|
||||||
&mut align.0,
|
&mut align.0,
|
||||||
), "Failed to align VideoInfo")
|
), "Failed to align VideoInfo")
|
||||||
|
@ -814,7 +810,7 @@ impl VideoInfo {
|
||||||
|
|
||||||
Ok(())
|
Ok(())
|
||||||
} else {
|
} else {
|
||||||
glib::glib_result_from_gboolean!(ffi::gst_video_info_align(
|
glib::result_from_gboolean!(ffi::gst_video_info_align(
|
||||||
&mut self.0,
|
&mut self.0,
|
||||||
&mut align.0,
|
&mut align.0,
|
||||||
), "Failed to align VideoInfo")
|
), "Failed to align VideoInfo")
|
||||||
|
@ -833,7 +829,7 @@ impl VideoInfo {
|
||||||
let mut plane_size = [0; crate::VIDEO_MAX_PLANES];
|
let mut plane_size = [0; crate::VIDEO_MAX_PLANES];
|
||||||
|
|
||||||
unsafe {
|
unsafe {
|
||||||
glib::glib_result_from_gboolean!(
|
glib::result_from_gboolean!(
|
||||||
ffi::gst_video_info_align_full(&mut self.0, &mut align.0, plane_size.as_mut_ptr()),
|
ffi::gst_video_info_align_full(&mut self.0, &mut align.0, plane_size.as_mut_ptr()),
|
||||||
"Failed to align VideoInfo"
|
"Failed to align VideoInfo"
|
||||||
)?;
|
)?;
|
||||||
|
@ -971,7 +967,7 @@ impl str::FromStr for crate::VideoFieldOrder {
|
||||||
|
|
||||||
let fmt = Self::from_string(s);
|
let fmt = Self::from_string(s);
|
||||||
if fmt == Self::Unknown {
|
if fmt == Self::Unknown {
|
||||||
Err(glib::glib_bool_error!(
|
Err(glib::bool_error!(
|
||||||
"Failed to parse video field order from string"
|
"Failed to parse video field order from string"
|
||||||
))
|
))
|
||||||
} else {
|
} else {
|
||||||
|
|
|
@ -23,20 +23,17 @@ impl VideoMeta {
|
||||||
skip_assert_initialized!();
|
skip_assert_initialized!();
|
||||||
|
|
||||||
if format == crate::VideoFormat::Unknown || format == crate::VideoFormat::Encoded {
|
if format == crate::VideoFormat::Unknown || format == crate::VideoFormat::Encoded {
|
||||||
return Err(glib::glib_bool_error!(
|
return Err(glib::bool_error!("Unsupported video format {}", format));
|
||||||
"Unsupported video format {}",
|
|
||||||
format
|
|
||||||
));
|
|
||||||
}
|
}
|
||||||
|
|
||||||
let info = crate::VideoInfo::builder(format, width, height).build()?;
|
let info = crate::VideoInfo::builder(format, width, height).build()?;
|
||||||
|
|
||||||
if !info.is_valid() {
|
if !info.is_valid() {
|
||||||
return Err(glib::glib_bool_error!("Invalid video info"));
|
return Err(glib::bool_error!("Invalid video info"));
|
||||||
}
|
}
|
||||||
|
|
||||||
if buffer.get_size() < info.size() {
|
if buffer.get_size() < info.size() {
|
||||||
return Err(glib::glib_bool_error!(
|
return Err(glib::bool_error!(
|
||||||
"Buffer smaller than required frame size ({} < {})",
|
"Buffer smaller than required frame size ({} < {})",
|
||||||
buffer.get_size(),
|
buffer.get_size(),
|
||||||
info.size()
|
info.size()
|
||||||
|
@ -53,7 +50,7 @@ impl VideoMeta {
|
||||||
);
|
);
|
||||||
|
|
||||||
if meta.is_null() {
|
if meta.is_null() {
|
||||||
return Err(glib::glib_bool_error!("Failed to add video meta"));
|
return Err(glib::bool_error!("Failed to add video meta"));
|
||||||
}
|
}
|
||||||
|
|
||||||
Ok(Self::from_mut_ptr(buffer, meta))
|
Ok(Self::from_mut_ptr(buffer, meta))
|
||||||
|
@ -72,10 +69,7 @@ impl VideoMeta {
|
||||||
skip_assert_initialized!();
|
skip_assert_initialized!();
|
||||||
|
|
||||||
if format == crate::VideoFormat::Unknown || format == crate::VideoFormat::Encoded {
|
if format == crate::VideoFormat::Unknown || format == crate::VideoFormat::Encoded {
|
||||||
return Err(glib::glib_bool_error!(
|
return Err(glib::bool_error!("Unsupported video format {}", format));
|
||||||
"Unsupported video format {}",
|
|
||||||
format
|
|
||||||
));
|
|
||||||
}
|
}
|
||||||
|
|
||||||
let n_planes = offset.len() as u32;
|
let n_planes = offset.len() as u32;
|
||||||
|
@ -85,11 +79,11 @@ impl VideoMeta {
|
||||||
.build()?;
|
.build()?;
|
||||||
|
|
||||||
if !info.is_valid() {
|
if !info.is_valid() {
|
||||||
return Err(glib::glib_bool_error!("Invalid video info"));
|
return Err(glib::bool_error!("Invalid video info"));
|
||||||
}
|
}
|
||||||
|
|
||||||
if buffer.get_size() < info.size() {
|
if buffer.get_size() < info.size() {
|
||||||
return Err(glib::glib_bool_error!(
|
return Err(glib::bool_error!(
|
||||||
"Buffer smaller than required frame size ({} < {})",
|
"Buffer smaller than required frame size ({} < {})",
|
||||||
buffer.get_size(),
|
buffer.get_size(),
|
||||||
info.size()
|
info.size()
|
||||||
|
@ -109,7 +103,7 @@ impl VideoMeta {
|
||||||
);
|
);
|
||||||
|
|
||||||
if meta.is_null() {
|
if meta.is_null() {
|
||||||
return Err(glib::glib_bool_error!("Failed to add video meta"));
|
return Err(glib::bool_error!("Failed to add video meta"));
|
||||||
}
|
}
|
||||||
|
|
||||||
Ok(Self::from_mut_ptr(buffer, meta))
|
Ok(Self::from_mut_ptr(buffer, meta))
|
||||||
|
@ -166,7 +160,7 @@ impl VideoMeta {
|
||||||
let mut plane_size = [0; crate::VIDEO_MAX_PLANES];
|
let mut plane_size = [0; crate::VIDEO_MAX_PLANES];
|
||||||
|
|
||||||
unsafe {
|
unsafe {
|
||||||
glib::glib_result_from_gboolean!(
|
glib::result_from_gboolean!(
|
||||||
ffi::gst_video_meta_get_plane_size(
|
ffi::gst_video_meta_get_plane_size(
|
||||||
&self.0 as *const _ as usize as *mut _,
|
&self.0 as *const _ as usize as *mut _,
|
||||||
&mut plane_size,
|
&mut plane_size,
|
||||||
|
@ -184,7 +178,7 @@ impl VideoMeta {
|
||||||
let mut plane_height = [0; crate::VIDEO_MAX_PLANES];
|
let mut plane_height = [0; crate::VIDEO_MAX_PLANES];
|
||||||
|
|
||||||
unsafe {
|
unsafe {
|
||||||
glib::glib_result_from_gboolean!(
|
glib::result_from_gboolean!(
|
||||||
ffi::gst_video_meta_get_plane_height(
|
ffi::gst_video_meta_get_plane_height(
|
||||||
&self.0 as *const _ as usize as *mut _,
|
&self.0 as *const _ as usize as *mut _,
|
||||||
&mut plane_height,
|
&mut plane_height,
|
||||||
|
@ -203,7 +197,7 @@ impl VideoMeta {
|
||||||
alignment: &crate::VideoAlignment,
|
alignment: &crate::VideoAlignment,
|
||||||
) -> Result<(), glib::BoolError> {
|
) -> Result<(), glib::BoolError> {
|
||||||
unsafe {
|
unsafe {
|
||||||
glib::glib_result_from_gboolean!(
|
glib::result_from_gboolean!(
|
||||||
ffi::gst_video_meta_set_alignment(&mut self.0, alignment.0),
|
ffi::gst_video_meta_set_alignment(&mut self.0, alignment.0),
|
||||||
"Failed to set alignment on VideoMeta"
|
"Failed to set alignment on VideoMeta"
|
||||||
)
|
)
|
||||||
|
|
|
@ -199,7 +199,7 @@ impl VideoOverlayComposition {
|
||||||
|
|
||||||
let first = match iter.next() {
|
let first = match iter.next() {
|
||||||
None => {
|
None => {
|
||||||
return Err(glib::glib_bool_error!(
|
return Err(glib::bool_error!(
|
||||||
"Failed to create VideoOverlayComposition"
|
"Failed to create VideoOverlayComposition"
|
||||||
))
|
))
|
||||||
}
|
}
|
||||||
|
@ -228,7 +228,7 @@ impl VideoOverlayCompositionRef {
|
||||||
|
|
||||||
pub fn get_rectangle(&self, idx: u32) -> Result<VideoOverlayRectangle, glib::error::BoolError> {
|
pub fn get_rectangle(&self, idx: u32) -> Result<VideoOverlayRectangle, glib::error::BoolError> {
|
||||||
if idx >= self.n_rectangles() {
|
if idx >= self.n_rectangles() {
|
||||||
return Err(glib::glib_bool_error!("Invalid index"));
|
return Err(glib::bool_error!("Invalid index"));
|
||||||
}
|
}
|
||||||
|
|
||||||
unsafe {
|
unsafe {
|
||||||
|
@ -237,7 +237,7 @@ impl VideoOverlayCompositionRef {
|
||||||
idx,
|
idx,
|
||||||
)) {
|
)) {
|
||||||
Some(r) => Ok(r),
|
Some(r) => Ok(r),
|
||||||
None => Err(glib::glib_bool_error!("Failed to get rectangle")),
|
None => Err(glib::bool_error!("Failed to get rectangle")),
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -251,7 +251,7 @@ impl VideoOverlayCompositionRef {
|
||||||
frame: &mut crate::VideoFrameRef<&mut gst::BufferRef>,
|
frame: &mut crate::VideoFrameRef<&mut gst::BufferRef>,
|
||||||
) -> Result<(), glib::BoolError> {
|
) -> Result<(), glib::BoolError> {
|
||||||
unsafe {
|
unsafe {
|
||||||
glib::glib_result_from_gboolean!(
|
glib::result_from_gboolean!(
|
||||||
ffi::gst_video_overlay_composition_blend(self.as_mut_ptr(), frame.as_mut_ptr()),
|
ffi::gst_video_overlay_composition_blend(self.as_mut_ptr(), frame.as_mut_ptr()),
|
||||||
"Failed to blend overlay composition",
|
"Failed to blend overlay composition",
|
||||||
)
|
)
|
||||||
|
|
|
@ -84,7 +84,7 @@ impl VideoTimeCode {
|
||||||
);
|
);
|
||||||
|
|
||||||
if res == glib::ffi::GFALSE {
|
if res == glib::ffi::GFALSE {
|
||||||
Err(glib::glib_bool_error!("Failed to init video time code"))
|
Err(glib::bool_error!("Failed to init video time code"))
|
||||||
} else {
|
} else {
|
||||||
Ok(VideoTimeCode(v.assume_init()))
|
Ok(VideoTimeCode(v.assume_init()))
|
||||||
}
|
}
|
||||||
|
@ -166,9 +166,7 @@ impl ValidVideoTimeCode {
|
||||||
);
|
);
|
||||||
match tc.try_into() {
|
match tc.try_into() {
|
||||||
Ok(v) => Ok(v),
|
Ok(v) => Ok(v),
|
||||||
Err(_) => Err(glib::glib_bool_error!(
|
Err(_) => Err(glib::bool_error!("Failed to create new ValidVideoTimeCode")),
|
||||||
"Failed to create new ValidVideoTimeCode"
|
|
||||||
)),
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -203,7 +201,7 @@ impl ValidVideoTimeCode {
|
||||||
tc_inter.to_glib_none().0,
|
tc_inter.to_glib_none().0,
|
||||||
)) {
|
)) {
|
||||||
Some(i) => Ok(i),
|
Some(i) => Ok(i),
|
||||||
None => Err(glib::glib_bool_error!("Failed to add interval")),
|
None => Err(glib::bool_error!("Failed to add interval")),
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -230,7 +228,7 @@ impl ValidVideoTimeCode {
|
||||||
unsafe {
|
unsafe {
|
||||||
match from_glib_full(ffi::gst_video_time_code_to_date_time(self.to_glib_none().0)) {
|
match from_glib_full(ffi::gst_video_time_code_to_date_time(self.to_glib_none().0)) {
|
||||||
Some(d) => Ok(d),
|
Some(d) => Ok(d),
|
||||||
None => Err(glib::glib_bool_error!(
|
None => Err(glib::bool_error!(
|
||||||
"Failed to convert VideoTimeCode to date time"
|
"Failed to convert VideoTimeCode to date time"
|
||||||
)),
|
)),
|
||||||
}
|
}
|
||||||
|
@ -475,7 +473,7 @@ impl str::FromStr for VideoTimeCode {
|
||||||
Option::<Self>::from_glib_full(ffi::gst_video_time_code_new_from_string(
|
Option::<Self>::from_glib_full(ffi::gst_video_time_code_new_from_string(
|
||||||
s.to_glib_none().0,
|
s.to_glib_none().0,
|
||||||
))
|
))
|
||||||
.ok_or_else(|| glib::glib_bool_error!("Failed to create VideoTimeCode from string"))
|
.ok_or_else(|| glib::bool_error!("Failed to create VideoTimeCode from string"))
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -120,9 +120,7 @@ impl str::FromStr for VideoTimeCodeInterval {
|
||||||
Option::<Self>::from_glib_full(ffi::gst_video_time_code_interval_new_from_string(
|
Option::<Self>::from_glib_full(ffi::gst_video_time_code_interval_new_from_string(
|
||||||
s.to_glib_none().0,
|
s.to_glib_none().0,
|
||||||
))
|
))
|
||||||
.ok_or_else(|| {
|
.ok_or_else(|| glib::bool_error!("Failed to create VideoTimeCodeInterval from string"))
|
||||||
glib::glib_bool_error!("Failed to create VideoTimeCodeInterval from string")
|
|
||||||
})
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -33,7 +33,7 @@ impl<O: IsA<Allocator>> AllocatorExtManual for O {
|
||||||
},
|
},
|
||||||
);
|
);
|
||||||
if ret.is_null() {
|
if ret.is_null() {
|
||||||
Err(glib::glib_bool_error!("Failed to allocate memory"))
|
Err(glib::bool_error!("Failed to allocate memory"))
|
||||||
} else {
|
} else {
|
||||||
Ok(from_glib_full(ret))
|
Ok(from_glib_full(ret))
|
||||||
}
|
}
|
||||||
|
|
|
@ -59,7 +59,7 @@ impl<O: IsA<Bin>> GstBinExtManual for O {
|
||||||
fn add_many<E: IsA<Element>>(&self, elements: &[&E]) -> Result<(), glib::BoolError> {
|
fn add_many<E: IsA<Element>>(&self, elements: &[&E]) -> Result<(), glib::BoolError> {
|
||||||
for e in elements {
|
for e in elements {
|
||||||
unsafe {
|
unsafe {
|
||||||
glib::glib_result_from_gboolean!(
|
glib::result_from_gboolean!(
|
||||||
ffi::gst_bin_add(self.as_ref().to_glib_none().0, e.as_ref().to_glib_none().0),
|
ffi::gst_bin_add(self.as_ref().to_glib_none().0, e.as_ref().to_glib_none().0),
|
||||||
"Failed to add elements"
|
"Failed to add elements"
|
||||||
)?;
|
)?;
|
||||||
|
@ -72,7 +72,7 @@ impl<O: IsA<Bin>> GstBinExtManual for O {
|
||||||
fn remove_many<E: IsA<Element>>(&self, elements: &[&E]) -> Result<(), glib::BoolError> {
|
fn remove_many<E: IsA<Element>>(&self, elements: &[&E]) -> Result<(), glib::BoolError> {
|
||||||
for e in elements {
|
for e in elements {
|
||||||
unsafe {
|
unsafe {
|
||||||
glib::glib_result_from_gboolean!(
|
glib::result_from_gboolean!(
|
||||||
ffi::gst_bin_remove(
|
ffi::gst_bin_remove(
|
||||||
self.as_ref().to_glib_none().0,
|
self.as_ref().to_glib_none().0,
|
||||||
e.as_ref().to_glib_none().0,
|
e.as_ref().to_glib_none().0,
|
||||||
|
|
|
@ -54,7 +54,7 @@ impl Buffer {
|
||||||
size,
|
size,
|
||||||
ptr::null_mut(),
|
ptr::null_mut(),
|
||||||
))
|
))
|
||||||
.ok_or_else(|| glib::glib_bool_error!("Failed to allocate buffer"))
|
.ok_or_else(|| glib::bool_error!("Failed to allocate buffer"))
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -183,7 +183,7 @@ impl BufferRef {
|
||||||
phantom: PhantomData,
|
phantom: PhantomData,
|
||||||
})
|
})
|
||||||
} else {
|
} else {
|
||||||
Err(glib::glib_bool_error!("Failed to map buffer readable"))
|
Err(glib::bool_error!("Failed to map buffer readable"))
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -203,7 +203,7 @@ impl BufferRef {
|
||||||
phantom: PhantomData,
|
phantom: PhantomData,
|
||||||
})
|
})
|
||||||
} else {
|
} else {
|
||||||
Err(glib::glib_bool_error!("Failed to map buffer writable"))
|
Err(glib::bool_error!("Failed to map buffer writable"))
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -222,7 +222,7 @@ impl BufferRef {
|
||||||
offset,
|
offset,
|
||||||
size_real,
|
size_real,
|
||||||
))
|
))
|
||||||
.ok_or_else(|| glib::glib_bool_error!("Failed to copy region of buffer"))
|
.ok_or_else(|| glib::bool_error!("Failed to copy region of buffer"))
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -235,7 +235,7 @@ impl BufferRef {
|
||||||
) -> Result<(), glib::BoolError> {
|
) -> Result<(), glib::BoolError> {
|
||||||
let size_real = size.unwrap_or(usize::MAX);
|
let size_real = size.unwrap_or(usize::MAX);
|
||||||
unsafe {
|
unsafe {
|
||||||
glib::glib_result_from_gboolean!(
|
glib::result_from_gboolean!(
|
||||||
ffi::gst_buffer_copy_into(
|
ffi::gst_buffer_copy_into(
|
||||||
dest.as_mut_ptr(),
|
dest.as_mut_ptr(),
|
||||||
self.as_mut_ptr(),
|
self.as_mut_ptr(),
|
||||||
|
@ -292,7 +292,7 @@ impl BufferRef {
|
||||||
pub fn copy_deep(&self) -> Result<Buffer, glib::BoolError> {
|
pub fn copy_deep(&self) -> Result<Buffer, glib::BoolError> {
|
||||||
unsafe {
|
unsafe {
|
||||||
Option::<_>::from_glib_full(ffi::gst_buffer_copy_deep(self.as_ptr()))
|
Option::<_>::from_glib_full(ffi::gst_buffer_copy_deep(self.as_ptr()))
|
||||||
.ok_or_else(|| glib::glib_bool_error!("Failed to deep copy buffer"))
|
.ok_or_else(|| glib::bool_error!("Failed to deep copy buffer"))
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -593,7 +593,7 @@ impl BufferRef {
|
||||||
unsafe {
|
unsafe {
|
||||||
let mem = ffi::gst_buffer_peek_memory(self.as_mut_ptr(), idx);
|
let mem = ffi::gst_buffer_peek_memory(self.as_mut_ptr(), idx);
|
||||||
if ffi::gst_mini_object_is_writable(mem as *mut _) == glib::ffi::GFALSE {
|
if ffi::gst_mini_object_is_writable(mem as *mut _) == glib::ffi::GFALSE {
|
||||||
Err(glib::glib_bool_error!("Memory not writable"))
|
Err(glib::bool_error!("Memory not writable"))
|
||||||
} else {
|
} else {
|
||||||
Ok(MemoryRef::from_mut_ptr(ffi::gst_buffer_peek_memory(
|
Ok(MemoryRef::from_mut_ptr(ffi::gst_buffer_peek_memory(
|
||||||
self.as_mut_ptr(),
|
self.as_mut_ptr(),
|
||||||
|
@ -660,7 +660,7 @@ impl BufferRef {
|
||||||
|
|
||||||
pub fn iter_memories_mut(&mut self) -> Result<IterMut, glib::BoolError> {
|
pub fn iter_memories_mut(&mut self) -> Result<IterMut, glib::BoolError> {
|
||||||
if !self.is_all_memory_writable() {
|
if !self.is_all_memory_writable() {
|
||||||
Err(glib::glib_bool_error!("Not all memory are writable"))
|
Err(glib::bool_error!("Not all memory are writable"))
|
||||||
} else {
|
} else {
|
||||||
Ok(IterMut::new(self))
|
Ok(IterMut::new(self))
|
||||||
}
|
}
|
||||||
|
|
|
@ -296,7 +296,7 @@ impl BufferCursor<Writable> {
|
||||||
pub(crate) fn new_writable(buffer: Buffer) -> Result<BufferCursor<Writable>, glib::BoolError> {
|
pub(crate) fn new_writable(buffer: Buffer) -> Result<BufferCursor<Writable>, glib::BoolError> {
|
||||||
skip_assert_initialized!();
|
skip_assert_initialized!();
|
||||||
if !buffer.is_writable() || !buffer.is_all_memory_writable() {
|
if !buffer.is_writable() || !buffer.is_all_memory_writable() {
|
||||||
return Err(glib::glib_bool_error!("Not all memories are writable"));
|
return Err(glib::bool_error!("Not all memories are writable"));
|
||||||
}
|
}
|
||||||
|
|
||||||
let size = buffer.get_size() as u64;
|
let size = buffer.get_size() as u64;
|
||||||
|
@ -400,7 +400,7 @@ impl<'a> BufferRefCursor<&'a mut BufferRef> {
|
||||||
) -> Result<BufferRefCursor<&'a mut BufferRef>, glib::BoolError> {
|
) -> Result<BufferRefCursor<&'a mut BufferRef>, glib::BoolError> {
|
||||||
skip_assert_initialized!();
|
skip_assert_initialized!();
|
||||||
if !buffer.is_all_memory_writable() {
|
if !buffer.is_all_memory_writable() {
|
||||||
return Err(glib::glib_bool_error!("Not all memories are writable"));
|
return Err(glib::bool_error!("Not all memories are writable"));
|
||||||
}
|
}
|
||||||
|
|
||||||
let size = buffer.get_size() as u64;
|
let size = buffer.get_size() as u64;
|
||||||
|
|
|
@ -129,7 +129,7 @@ impl BufferPoolConfig {
|
||||||
max_buffers: u32,
|
max_buffers: u32,
|
||||||
) -> Result<(), glib::BoolError> {
|
) -> Result<(), glib::BoolError> {
|
||||||
unsafe {
|
unsafe {
|
||||||
glib::glib_result_from_gboolean!(
|
glib::result_from_gboolean!(
|
||||||
ffi::gst_buffer_pool_config_validate_params(
|
ffi::gst_buffer_pool_config_validate_params(
|
||||||
self.0.to_glib_none().0,
|
self.0.to_glib_none().0,
|
||||||
caps.to_glib_none().0,
|
caps.to_glib_none().0,
|
||||||
|
@ -301,7 +301,7 @@ impl<O: IsA<BufferPool>> BufferPoolExtManual for O {
|
||||||
|
|
||||||
fn set_config(&self, config: BufferPoolConfig) -> Result<(), glib::error::BoolError> {
|
fn set_config(&self, config: BufferPoolConfig) -> Result<(), glib::error::BoolError> {
|
||||||
unsafe {
|
unsafe {
|
||||||
glib::glib_result_from_gboolean!(
|
glib::result_from_gboolean!(
|
||||||
ffi::gst_buffer_pool_set_config(
|
ffi::gst_buffer_pool_set_config(
|
||||||
self.as_ref().to_glib_none().0,
|
self.as_ref().to_glib_none().0,
|
||||||
config.0.into_ptr()
|
config.0.into_ptr()
|
||||||
|
|
|
@ -117,7 +117,7 @@ impl Bus {
|
||||||
);
|
);
|
||||||
|
|
||||||
if res == 0 {
|
if res == 0 {
|
||||||
Err(glib::glib_bool_error!("Bus already has a watch"))
|
Err(glib::bool_error!("Bus already has a watch"))
|
||||||
} else {
|
} else {
|
||||||
Ok(from_glib(res))
|
Ok(from_glib(res))
|
||||||
}
|
}
|
||||||
|
@ -140,7 +140,7 @@ impl Bus {
|
||||||
);
|
);
|
||||||
|
|
||||||
if res == 0 {
|
if res == 0 {
|
||||||
Err(glib::glib_bool_error!("Bus already has a watch"))
|
Err(glib::bool_error!("Bus already has a watch"))
|
||||||
} else {
|
} else {
|
||||||
Ok(from_glib(res))
|
Ok(from_glib(res))
|
||||||
}
|
}
|
||||||
|
|
|
@ -159,7 +159,7 @@ impl str::FromStr for Caps {
|
||||||
assert_initialized_main_thread!();
|
assert_initialized_main_thread!();
|
||||||
unsafe {
|
unsafe {
|
||||||
Option::<_>::from_glib_full(ffi::gst_caps_from_string(s.to_glib_none().0))
|
Option::<_>::from_glib_full(ffi::gst_caps_from_string(s.to_glib_none().0))
|
||||||
.ok_or_else(|| glib::glib_bool_error!("Failed to parse caps from string"))
|
.ok_or_else(|| glib::bool_error!("Failed to parse caps from string"))
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -122,7 +122,7 @@ impl str::FromStr for CapsFeatures {
|
||||||
unsafe {
|
unsafe {
|
||||||
let ptr = ffi::gst_caps_features_from_string(s.to_glib_none().0);
|
let ptr = ffi::gst_caps_features_from_string(s.to_glib_none().0);
|
||||||
if ptr.is_null() {
|
if ptr.is_null() {
|
||||||
return Err(glib::glib_bool_error!(
|
return Err(glib::bool_error!(
|
||||||
"Failed to parse caps features from string"
|
"Failed to parse caps features from string"
|
||||||
));
|
));
|
||||||
}
|
}
|
||||||
|
|
|
@ -50,7 +50,7 @@ impl<O: IsA<ChildProxy>> ChildProxyExtManual for O {
|
||||||
ptr::null_mut(),
|
ptr::null_mut(),
|
||||||
));
|
));
|
||||||
if !found {
|
if !found {
|
||||||
return Err(glib::glib_bool_error!("Child property not found"));
|
return Err(glib::bool_error!("Child property not found"));
|
||||||
}
|
}
|
||||||
|
|
||||||
let value = value.to_value();
|
let value = value.to_value();
|
||||||
|
|
|
@ -25,7 +25,7 @@ use std::pin::Pin;
|
||||||
use std::sync::atomic;
|
use std::sync::atomic;
|
||||||
use std::sync::atomic::AtomicI32;
|
use std::sync::atomic::AtomicI32;
|
||||||
|
|
||||||
glib::glib_wrapper! {
|
glib::wrapper! {
|
||||||
#[derive(Debug, PartialOrd, Ord, PartialEq, Eq, Hash)]
|
#[derive(Debug, PartialOrd, Ord, PartialEq, Eq, Hash)]
|
||||||
pub struct ClockId(Shared<c_void>);
|
pub struct ClockId(Shared<c_void>);
|
||||||
|
|
||||||
|
@ -117,7 +117,7 @@ impl convert::TryFrom<ClockId> for SingleShotClockId {
|
||||||
skip_assert_initialized!();
|
skip_assert_initialized!();
|
||||||
match id.get_type() {
|
match id.get_type() {
|
||||||
ClockEntryType::Single => Ok(SingleShotClockId(id)),
|
ClockEntryType::Single => Ok(SingleShotClockId(id)),
|
||||||
_ => Err(glib::glib_bool_error!("Not a single-shot clock id")),
|
_ => Err(glib::bool_error!("Not a single-shot clock id")),
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -225,7 +225,7 @@ impl convert::TryFrom<ClockId> for PeriodicClockId {
|
||||||
skip_assert_initialized!();
|
skip_assert_initialized!();
|
||||||
match id.get_type() {
|
match id.get_type() {
|
||||||
ClockEntryType::Periodic => Ok(PeriodicClockId(id)),
|
ClockEntryType::Periodic => Ok(PeriodicClockId(id)),
|
||||||
_ => Err(glib::glib_bool_error!("Not a periodic clock id")),
|
_ => Err(glib::bool_error!("Not a periodic clock id")),
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -431,7 +431,7 @@ impl<O: IsA<Clock>> ClockExtManual for O {
|
||||||
if res {
|
if res {
|
||||||
Ok(())
|
Ok(())
|
||||||
} else {
|
} else {
|
||||||
Err(glib::glib_bool_error!("Failed to reinit periodic clock id"))
|
Err(glib::bool_error!("Failed to reinit periodic clock id"))
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -461,9 +461,7 @@ impl<O: IsA<Clock>> ClockExtManual for O {
|
||||||
if res {
|
if res {
|
||||||
Ok(())
|
Ok(())
|
||||||
} else {
|
} else {
|
||||||
Err(glib::glib_bool_error!(
|
Err(glib::bool_error!("Failed to reinit single shot clock id"))
|
||||||
"Failed to reinit single shot clock id"
|
|
||||||
))
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -246,7 +246,7 @@ impl convert::TryFrom<ClockTime> for Duration {
|
||||||
|
|
||||||
t.nanoseconds()
|
t.nanoseconds()
|
||||||
.map(Duration::from_nanos)
|
.map(Duration::from_nanos)
|
||||||
.ok_or_else(|| glib::glib_bool_error!("Can't convert ClockTime::NONE to Duration"))
|
.ok_or_else(|| glib::bool_error!("Can't convert ClockTime::NONE to Duration"))
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -23,7 +23,7 @@ impl<O: IsA<ControlBinding>> ControlBindingExtManual for O {
|
||||||
) -> Result<(), glib::error::BoolError> {
|
) -> Result<(), glib::error::BoolError> {
|
||||||
let n_values = values.len() as u32;
|
let n_values = values.len() as u32;
|
||||||
unsafe {
|
unsafe {
|
||||||
glib::glib_result_from_gboolean!(
|
glib::result_from_gboolean!(
|
||||||
ffi::gst_control_binding_get_g_value_array(
|
ffi::gst_control_binding_get_g_value_array(
|
||||||
self.as_ref().to_glib_none().0,
|
self.as_ref().to_glib_none().0,
|
||||||
timestamp.to_glib(),
|
timestamp.to_glib(),
|
||||||
|
|
|
@ -23,7 +23,7 @@ impl<O: IsA<ControlSource>> ControlSourceExtManual for O {
|
||||||
) -> Result<(), glib::error::BoolError> {
|
) -> Result<(), glib::error::BoolError> {
|
||||||
let n_values = values.len() as u32;
|
let n_values = values.len() as u32;
|
||||||
unsafe {
|
unsafe {
|
||||||
glib::glib_result_from_gboolean!(
|
glib::result_from_gboolean!(
|
||||||
ffi::gst_control_source_get_value_array(
|
ffi::gst_control_source_get_value_array(
|
||||||
self.as_ref().to_glib_none().0,
|
self.as_ref().to_glib_none().0,
|
||||||
timestamp.to_glib(),
|
timestamp.to_glib(),
|
||||||
|
|
|
@ -21,14 +21,14 @@ fn validate(
|
||||||
|
|
||||||
// Check for valid ranges
|
// Check for valid ranges
|
||||||
if year <= 0 || year > 9999 {
|
if year <= 0 || year > 9999 {
|
||||||
return Err(glib::glib_bool_error!(
|
return Err(glib::bool_error!(
|
||||||
"Can't create DateTime: Year out of range"
|
"Can't create DateTime: Year out of range"
|
||||||
));
|
));
|
||||||
}
|
}
|
||||||
|
|
||||||
if let Some(month) = month {
|
if let Some(month) = month {
|
||||||
if month <= 0 || month > 12 {
|
if month <= 0 || month > 12 {
|
||||||
return Err(glib::glib_bool_error!(
|
return Err(glib::bool_error!(
|
||||||
"Can't create DateTime: Month out of range"
|
"Can't create DateTime: Month out of range"
|
||||||
));
|
));
|
||||||
}
|
}
|
||||||
|
@ -36,15 +36,13 @@ fn validate(
|
||||||
|
|
||||||
if let Some(day) = day {
|
if let Some(day) = day {
|
||||||
if day <= 0 || day > 31 {
|
if day <= 0 || day > 31 {
|
||||||
return Err(glib::glib_bool_error!(
|
return Err(glib::bool_error!("Can't create DateTime: Day out of range"));
|
||||||
"Can't create DateTime: Day out of range"
|
|
||||||
));
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if let Some(hour) = hour {
|
if let Some(hour) = hour {
|
||||||
if hour < 0 || hour >= 24 {
|
if hour < 0 || hour >= 24 {
|
||||||
return Err(glib::glib_bool_error!(
|
return Err(glib::bool_error!(
|
||||||
"Can't create DateTime: Hour out of range"
|
"Can't create DateTime: Hour out of range"
|
||||||
));
|
));
|
||||||
}
|
}
|
||||||
|
@ -52,7 +50,7 @@ fn validate(
|
||||||
|
|
||||||
if let Some(minute) = minute {
|
if let Some(minute) = minute {
|
||||||
if minute < 0 || minute >= 60 {
|
if minute < 0 || minute >= 60 {
|
||||||
return Err(glib::glib_bool_error!(
|
return Err(glib::bool_error!(
|
||||||
"Can't create DateTime: Minute out of range"
|
"Can't create DateTime: Minute out of range"
|
||||||
));
|
));
|
||||||
}
|
}
|
||||||
|
@ -60,7 +58,7 @@ fn validate(
|
||||||
|
|
||||||
if let Some(seconds) = seconds {
|
if let Some(seconds) = seconds {
|
||||||
if seconds < 0.0 || seconds >= 60.0 {
|
if seconds < 0.0 || seconds >= 60.0 {
|
||||||
return Err(glib::glib_bool_error!(
|
return Err(glib::bool_error!(
|
||||||
"Can't create DateTime: Seconds out of range"
|
"Can't create DateTime: Seconds out of range"
|
||||||
));
|
));
|
||||||
}
|
}
|
||||||
|
@ -68,7 +66,7 @@ fn validate(
|
||||||
|
|
||||||
if let Some(tzoffset) = tzoffset {
|
if let Some(tzoffset) = tzoffset {
|
||||||
if tzoffset < -12.0 || tzoffset > 12.0 {
|
if tzoffset < -12.0 || tzoffset > 12.0 {
|
||||||
return Err(glib::glib_bool_error!(
|
return Err(glib::bool_error!(
|
||||||
"Can't create DateTime: Timezone offset out of range"
|
"Can't create DateTime: Timezone offset out of range"
|
||||||
));
|
));
|
||||||
}
|
}
|
||||||
|
@ -76,34 +74,34 @@ fn validate(
|
||||||
|
|
||||||
// If day is provided, month also has to be provided
|
// If day is provided, month also has to be provided
|
||||||
if day.is_some() && month.is_none() {
|
if day.is_some() && month.is_none() {
|
||||||
return Err(glib::glib_bool_error!(
|
return Err(glib::bool_error!(
|
||||||
"Can't create DateTime: Need to provide month if providing day"
|
"Can't create DateTime: Need to provide month if providing day"
|
||||||
));
|
));
|
||||||
}
|
}
|
||||||
|
|
||||||
// If hour is provided, day also has to be provided
|
// If hour is provided, day also has to be provided
|
||||||
if hour.is_some() && day.is_none() {
|
if hour.is_some() && day.is_none() {
|
||||||
return Err(glib::glib_bool_error!(
|
return Err(glib::bool_error!(
|
||||||
"Can't create DateTime: Need to provide day if providing hour"
|
"Can't create DateTime: Need to provide day if providing hour"
|
||||||
));
|
));
|
||||||
}
|
}
|
||||||
|
|
||||||
// If minutes are provided, hours also need to be provided and the other way around
|
// If minutes are provided, hours also need to be provided and the other way around
|
||||||
if hour.is_none() && minute.is_some() {
|
if hour.is_none() && minute.is_some() {
|
||||||
return Err(glib::glib_bool_error!(
|
return Err(glib::bool_error!(
|
||||||
"Can't create DateTime: Need to provide both hour and minute or neither"
|
"Can't create DateTime: Need to provide both hour and minute or neither"
|
||||||
));
|
));
|
||||||
}
|
}
|
||||||
|
|
||||||
if minute.is_some() && hour.is_none() {
|
if minute.is_some() && hour.is_none() {
|
||||||
return Err(glib::glib_bool_error!(
|
return Err(glib::bool_error!(
|
||||||
"Can't create DateTime: Need to provide both hour and minute or neither"
|
"Can't create DateTime: Need to provide both hour and minute or neither"
|
||||||
));
|
));
|
||||||
}
|
}
|
||||||
|
|
||||||
// If seconds or tzoffset are provided then also hours and minutes must be provided
|
// If seconds or tzoffset are provided then also hours and minutes must be provided
|
||||||
if (seconds.is_some() || tzoffset.is_some()) && (hour.is_none() || minute.is_none()) {
|
if (seconds.is_some() || tzoffset.is_some()) && (hour.is_none() || minute.is_none()) {
|
||||||
return Err(glib::glib_bool_error!("Can't create DateTime: Need to provide hour and minute if providing seconds or timezone offset"));
|
return Err(glib::bool_error!("Can't create DateTime: Need to provide hour and minute if providing seconds or timezone offset"));
|
||||||
}
|
}
|
||||||
|
|
||||||
Ok(())
|
Ok(())
|
||||||
|
@ -149,7 +147,7 @@ impl DateTime {
|
||||||
minute.unwrap_or(-1),
|
minute.unwrap_or(-1),
|
||||||
seconds.unwrap_or(-1.0),
|
seconds.unwrap_or(-1.0),
|
||||||
))
|
))
|
||||||
.ok_or_else(|| glib::glib_bool_error!("Can't create DateTime"))
|
.ok_or_else(|| glib::bool_error!("Can't create DateTime"))
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -188,7 +186,7 @@ impl DateTime {
|
||||||
minute.unwrap_or(-1),
|
minute.unwrap_or(-1),
|
||||||
seconds.unwrap_or(-1.0),
|
seconds.unwrap_or(-1.0),
|
||||||
))
|
))
|
||||||
.ok_or_else(|| glib::glib_bool_error!("Can't create DateTime"))
|
.ok_or_else(|| glib::bool_error!("Can't create DateTime"))
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -199,7 +197,7 @@ impl DateTime {
|
||||||
|
|
||||||
unsafe {
|
unsafe {
|
||||||
Option::<_>::from_glib_full(ffi::gst_date_time_new_y(year))
|
Option::<_>::from_glib_full(ffi::gst_date_time_new_y(year))
|
||||||
.ok_or_else(|| glib::glib_bool_error!("Can't create DateTime"))
|
.ok_or_else(|| glib::bool_error!("Can't create DateTime"))
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -210,7 +208,7 @@ impl DateTime {
|
||||||
|
|
||||||
unsafe {
|
unsafe {
|
||||||
Option::<_>::from_glib_full(ffi::gst_date_time_new_ym(year, month))
|
Option::<_>::from_glib_full(ffi::gst_date_time_new_ym(year, month))
|
||||||
.ok_or_else(|| glib::glib_bool_error!("Can't create DateTime"))
|
.ok_or_else(|| glib::bool_error!("Can't create DateTime"))
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -221,7 +219,7 @@ impl DateTime {
|
||||||
|
|
||||||
unsafe {
|
unsafe {
|
||||||
Option::<_>::from_glib_full(ffi::gst_date_time_new_ymd(year, month, day))
|
Option::<_>::from_glib_full(ffi::gst_date_time_new_ymd(year, month, day))
|
||||||
.ok_or_else(|| glib::glib_bool_error!("Can't create DateTime"))
|
.ok_or_else(|| glib::bool_error!("Can't create DateTime"))
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -300,7 +298,7 @@ impl DateTime {
|
||||||
self.to_g_date_time()
|
self.to_g_date_time()
|
||||||
.and_then(|d| {
|
.and_then(|d| {
|
||||||
d.to_utc()
|
d.to_utc()
|
||||||
.ok_or_else(|| glib::glib_bool_error!("Can't convert datetime to UTC"))
|
.ok_or_else(|| glib::bool_error!("Can't convert datetime to UTC"))
|
||||||
})
|
})
|
||||||
.map(|d| d.into())
|
.map(|d| d.into())
|
||||||
} else {
|
} else {
|
||||||
|
@ -320,7 +318,7 @@ impl DateTime {
|
||||||
.and_then(|d| d.to_g_date_time())
|
.and_then(|d| d.to_g_date_time())
|
||||||
.and_then(|d| {
|
.and_then(|d| {
|
||||||
d.to_utc()
|
d.to_utc()
|
||||||
.ok_or_else(|| glib::glib_bool_error!("Can't convert datetime to UTC"))
|
.ok_or_else(|| glib::bool_error!("Can't convert datetime to UTC"))
|
||||||
})
|
})
|
||||||
.and_then(|d| {
|
.and_then(|d| {
|
||||||
DateTime::new(
|
DateTime::new(
|
||||||
|
|
|
@ -114,18 +114,18 @@ impl TryFrom<DateTimeVariants> for Date {
|
||||||
DateTimeVariants::YMD(y, m, d) => {
|
DateTimeVariants::YMD(y, m, d) => {
|
||||||
let month = unsafe { glib::DateMonth::from_glib(m) };
|
let month = unsafe { glib::DateMonth::from_glib(m) };
|
||||||
if let glib::DateMonth::__Unknown(_) = month {
|
if let glib::DateMonth::__Unknown(_) = month {
|
||||||
return Err(glib::glib_bool_error!("Out of range `month` for `Date`"));
|
return Err(glib::bool_error!("Out of range `month` for `Date`"));
|
||||||
}
|
}
|
||||||
|
|
||||||
Ok(Date(glib::Date::new_dmy(
|
Ok(Date(glib::Date::new_dmy(
|
||||||
d.try_into()
|
d.try_into()
|
||||||
.map_err(|_| glib::glib_bool_error!("Out of range `day` for `Date`"))?,
|
.map_err(|_| glib::bool_error!("Out of range `day` for `Date`"))?,
|
||||||
month,
|
month,
|
||||||
y.try_into()
|
y.try_into()
|
||||||
.map_err(|_| glib::glib_bool_error!("Out of range `year` for `Date`"))?,
|
.map_err(|_| glib::bool_error!("Out of range `year` for `Date`"))?,
|
||||||
)))
|
)))
|
||||||
}
|
}
|
||||||
_ => Err(glib::glib_bool_error!(
|
_ => Err(glib::bool_error!(
|
||||||
"Incompatible variant for `Date` (expecting \"YMD\")"
|
"Incompatible variant for `Date` (expecting \"YMD\")"
|
||||||
)),
|
)),
|
||||||
}
|
}
|
||||||
|
|
|
@ -83,7 +83,7 @@ impl<O: IsA<DeviceMonitor>> DeviceMonitorExtManual for O {
|
||||||
filter_id: DeviceMonitorFilterId,
|
filter_id: DeviceMonitorFilterId,
|
||||||
) -> Result<(), glib::error::BoolError> {
|
) -> Result<(), glib::error::BoolError> {
|
||||||
unsafe {
|
unsafe {
|
||||||
glib::glib_result_from_gboolean!(
|
glib::result_from_gboolean!(
|
||||||
ffi::gst_device_monitor_remove_filter(
|
ffi::gst_device_monitor_remove_filter(
|
||||||
self.as_ref().to_glib_none().0,
|
self.as_ref().to_glib_none().0,
|
||||||
filter_id.to_glib()
|
filter_id.to_glib()
|
||||||
|
|
|
@ -19,7 +19,7 @@ impl DeviceProvider {
|
||||||
) -> Result<(), glib::error::BoolError> {
|
) -> Result<(), glib::error::BoolError> {
|
||||||
assert_initialized_main_thread!();
|
assert_initialized_main_thread!();
|
||||||
unsafe {
|
unsafe {
|
||||||
glib::glib_result_from_gboolean!(
|
glib::result_from_gboolean!(
|
||||||
ffi::gst_device_provider_register(
|
ffi::gst_device_provider_register(
|
||||||
plugin.to_glib_none().0,
|
plugin.to_glib_none().0,
|
||||||
name.to_glib_none().0,
|
name.to_glib_none().0,
|
||||||
|
|
|
@ -50,7 +50,7 @@ impl Element {
|
||||||
skip_assert_initialized!();
|
skip_assert_initialized!();
|
||||||
for e in elements.windows(2) {
|
for e in elements.windows(2) {
|
||||||
unsafe {
|
unsafe {
|
||||||
glib::glib_result_from_gboolean!(
|
glib::result_from_gboolean!(
|
||||||
ffi::gst_element_link(
|
ffi::gst_element_link(
|
||||||
e[0].as_ref().to_glib_none().0,
|
e[0].as_ref().to_glib_none().0,
|
||||||
e[1].as_ref().to_glib_none().0,
|
e[1].as_ref().to_glib_none().0,
|
||||||
|
@ -83,7 +83,7 @@ impl Element {
|
||||||
) -> Result<(), glib::error::BoolError> {
|
) -> Result<(), glib::error::BoolError> {
|
||||||
assert_initialized_main_thread!();
|
assert_initialized_main_thread!();
|
||||||
unsafe {
|
unsafe {
|
||||||
glib::glib_result_from_gboolean!(
|
glib::result_from_gboolean!(
|
||||||
ffi::gst_element_register(
|
ffi::gst_element_register(
|
||||||
plugin.to_glib_none().0,
|
plugin.to_glib_none().0,
|
||||||
name.to_glib_none().0,
|
name.to_glib_none().0,
|
||||||
|
@ -454,7 +454,7 @@ impl<O: IsA<Element>> ElementExtManual for O {
|
||||||
|
|
||||||
fn post_message(&self, message: crate::Message) -> Result<(), glib::error::BoolError> {
|
fn post_message(&self, message: crate::Message) -> Result<(), glib::error::BoolError> {
|
||||||
unsafe {
|
unsafe {
|
||||||
glib::glib_result_from_gboolean!(
|
glib::result_from_gboolean!(
|
||||||
ffi::gst_element_post_message(self.as_ref().to_glib_none().0, message.into_ptr()),
|
ffi::gst_element_post_message(self.as_ref().to_glib_none().0, message.into_ptr()),
|
||||||
"Failed to post message"
|
"Failed to post message"
|
||||||
)
|
)
|
||||||
|
@ -731,7 +731,7 @@ impl<O: IsA<Element>> ElementExtManual for O {
|
||||||
assert_eq!(stop.get_format(), start.get_format());
|
assert_eq!(stop.get_format(), start.get_format());
|
||||||
|
|
||||||
unsafe {
|
unsafe {
|
||||||
glib::glib_result_from_gboolean!(
|
glib::result_from_gboolean!(
|
||||||
ffi::gst_element_seek(
|
ffi::gst_element_seek(
|
||||||
self.as_ref().to_glib_none().0,
|
self.as_ref().to_glib_none().0,
|
||||||
rate,
|
rate,
|
||||||
|
@ -754,7 +754,7 @@ impl<O: IsA<Element>> ElementExtManual for O {
|
||||||
) -> Result<(), glib::error::BoolError> {
|
) -> Result<(), glib::error::BoolError> {
|
||||||
let seek_pos = seek_pos.into();
|
let seek_pos = seek_pos.into();
|
||||||
unsafe {
|
unsafe {
|
||||||
glib::glib_result_from_gboolean!(
|
glib::result_from_gboolean!(
|
||||||
ffi::gst_element_seek_simple(
|
ffi::gst_element_seek_simple(
|
||||||
self.as_ref().to_glib_none().0,
|
self.as_ref().to_glib_none().0,
|
||||||
seek_pos.get_format().to_glib(),
|
seek_pos.get_format().to_glib(),
|
||||||
|
|
|
@ -83,12 +83,12 @@ impl ErrorMessage {
|
||||||
macro_rules! gst_loggable_error(
|
macro_rules! gst_loggable_error(
|
||||||
// Plain strings
|
// Plain strings
|
||||||
($cat:expr, $msg:expr) => {
|
($cat:expr, $msg:expr) => {
|
||||||
$crate::LoggableError::new($cat.clone(), $crate::glib::glib_bool_error!($msg))
|
$crate::LoggableError::new($cat.clone(), $crate::glib::bool_error!($msg))
|
||||||
};
|
};
|
||||||
|
|
||||||
// Format strings
|
// Format strings
|
||||||
($cat:expr, $($msg:tt)*) => { {
|
($cat:expr, $($msg:tt)*) => { {
|
||||||
$crate::LoggableError::new($cat.clone(), $crate::glib::glib_bool_error!($($msg)*))
|
$crate::LoggableError::new($cat.clone(), $crate::glib::bool_error!($($msg)*))
|
||||||
}};
|
}};
|
||||||
);
|
);
|
||||||
|
|
||||||
|
@ -96,13 +96,13 @@ macro_rules! gst_loggable_error(
|
||||||
macro_rules! gst_result_from_gboolean(
|
macro_rules! gst_result_from_gboolean(
|
||||||
// Plain strings
|
// Plain strings
|
||||||
($ffi_bool:expr, $cat:expr, $msg:expr) => {
|
($ffi_bool:expr, $cat:expr, $msg:expr) => {
|
||||||
$crate::glib::glib_result_from_gboolean!($ffi_bool, $msg)
|
$crate::glib::result_from_gboolean!($ffi_bool, $msg)
|
||||||
.map_err(|bool_err| $crate::LoggableError::new($cat.clone(), bool_err))
|
.map_err(|bool_err| $crate::LoggableError::new($cat.clone(), bool_err))
|
||||||
};
|
};
|
||||||
|
|
||||||
// Format strings
|
// Format strings
|
||||||
($ffi_bool:expr, $cat:expr, $($msg:tt)*) => { {
|
($ffi_bool:expr, $cat:expr, $($msg:tt)*) => { {
|
||||||
$crate::glib::glib_result_from_gboolean!($ffi_bool, $($msg)*)
|
$crate::glib::result_from_gboolean!($ffi_bool, $($msg)*)
|
||||||
.map_err(|bool_err| $crate::LoggableError::new($cat.clone(), bool_err))
|
.map_err(|bool_err| $crate::LoggableError::new($cat.clone(), bool_err))
|
||||||
}};
|
}};
|
||||||
);
|
);
|
||||||
|
|
|
@ -25,7 +25,7 @@ impl GhostPad {
|
||||||
) -> Result<(), glib::BoolError> {
|
) -> Result<(), glib::BoolError> {
|
||||||
skip_assert_initialized!();
|
skip_assert_initialized!();
|
||||||
unsafe {
|
unsafe {
|
||||||
glib::glib_result_from_gboolean!(
|
glib::result_from_gboolean!(
|
||||||
ffi::gst_ghost_pad_activate_mode_default(
|
ffi::gst_ghost_pad_activate_mode_default(
|
||||||
pad.to_glib_none().0 as *mut ffi::GstPad,
|
pad.to_glib_none().0 as *mut ffi::GstPad,
|
||||||
parent.map(|p| p.as_ref()).to_glib_none().0,
|
parent.map(|p| p.as_ref()).to_glib_none().0,
|
||||||
|
@ -45,7 +45,7 @@ impl GhostPad {
|
||||||
) -> Result<(), glib::BoolError> {
|
) -> Result<(), glib::BoolError> {
|
||||||
skip_assert_initialized!();
|
skip_assert_initialized!();
|
||||||
unsafe {
|
unsafe {
|
||||||
glib::glib_result_from_gboolean!(
|
glib::result_from_gboolean!(
|
||||||
ffi::gst_ghost_pad_internal_activate_mode_default(
|
ffi::gst_ghost_pad_internal_activate_mode_default(
|
||||||
pad.to_glib_none().0 as *mut ffi::GstPad,
|
pad.to_glib_none().0 as *mut ffi::GstPad,
|
||||||
parent.map(|p| p.as_ref()).to_glib_none().0,
|
parent.map(|p| p.as_ref()).to_glib_none().0,
|
||||||
|
@ -112,7 +112,7 @@ impl GhostPad {
|
||||||
skip_assert_initialized!();
|
skip_assert_initialized!();
|
||||||
|
|
||||||
if target.get_direction() != templ.get_property_direction() {
|
if target.get_direction() != templ.get_property_direction() {
|
||||||
return Err(glib::glib_bool_error!(
|
return Err(glib::bool_error!(
|
||||||
"Template and target have different directions"
|
"Template and target have different directions"
|
||||||
));
|
));
|
||||||
}
|
}
|
||||||
|
|
|
@ -255,7 +255,7 @@ impl MemoryRef {
|
||||||
phantom: PhantomData,
|
phantom: PhantomData,
|
||||||
})
|
})
|
||||||
} else {
|
} else {
|
||||||
Err(glib::glib_bool_error!("Failed to map memory readable"))
|
Err(glib::bool_error!("Failed to map memory readable"))
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -275,7 +275,7 @@ impl MemoryRef {
|
||||||
phantom: PhantomData,
|
phantom: PhantomData,
|
||||||
})
|
})
|
||||||
} else {
|
} else {
|
||||||
Err(glib::glib_bool_error!("Failed to map memory writable"))
|
Err(glib::bool_error!("Failed to map memory writable"))
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -110,7 +110,7 @@ impl<O: IsA<crate::Object>> GstObjectExtManual for O {
|
||||||
) -> Result<(), glib::error::BoolError> {
|
) -> Result<(), glib::error::BoolError> {
|
||||||
let n_values = values.len() as u32;
|
let n_values = values.len() as u32;
|
||||||
unsafe {
|
unsafe {
|
||||||
glib::glib_result_from_gboolean!(
|
glib::result_from_gboolean!(
|
||||||
ffi::gst_object_get_g_value_array(
|
ffi::gst_object_get_g_value_array(
|
||||||
self.as_ref().to_glib_none().0,
|
self.as_ref().to_glib_none().0,
|
||||||
property_name.to_glib_none().0,
|
property_name.to_glib_none().0,
|
||||||
|
|
|
@ -745,7 +745,7 @@ impl<O: IsA<Pad>> PadExtManual for O {
|
||||||
|
|
||||||
fn start_task<F: FnMut() + Send + 'static>(&self, func: F) -> Result<(), glib::BoolError> {
|
fn start_task<F: FnMut() + Send + 'static>(&self, func: F) -> Result<(), glib::BoolError> {
|
||||||
unsafe {
|
unsafe {
|
||||||
glib::glib_result_from_gboolean!(
|
glib::result_from_gboolean!(
|
||||||
ffi::gst_pad_start_task(
|
ffi::gst_pad_start_task(
|
||||||
self.as_ref().to_glib_none().0,
|
self.as_ref().to_glib_none().0,
|
||||||
Some(trampoline_pad_task::<F>),
|
Some(trampoline_pad_task::<F>),
|
||||||
|
|
|
@ -23,7 +23,7 @@ impl PadTemplate {
|
||||||
pad_type.to_glib(),
|
pad_type.to_glib(),
|
||||||
),
|
),
|
||||||
)
|
)
|
||||||
.ok_or_else(|| glib::glib_bool_error!("Failed to create PadTemplate"))
|
.ok_or_else(|| glib::bool_error!("Failed to create PadTemplate"))
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -2,7 +2,7 @@
|
||||||
|
|
||||||
use glib::translate::*;
|
use glib::translate::*;
|
||||||
|
|
||||||
glib::glib_wrapper! {
|
glib::wrapper! {
|
||||||
#[derive(Debug, PartialEq, Eq, PartialOrd, Ord, Hash)]
|
#[derive(Debug, PartialEq, Eq, PartialOrd, Ord, Hash)]
|
||||||
pub struct ParseContext(Boxed<ffi::GstParseContext>);
|
pub struct ParseContext(Boxed<ffi::GstParseContext>);
|
||||||
|
|
||||||
|
|
|
@ -10,7 +10,7 @@ use std::pin::Pin;
|
||||||
use std::ptr;
|
use std::ptr;
|
||||||
use std::task::{Context, Poll};
|
use std::task::{Context, Poll};
|
||||||
|
|
||||||
glib::glib_wrapper! {
|
glib::wrapper! {
|
||||||
#[derive(Debug, PartialEq, Eq, PartialOrd, Ord, Hash)]
|
#[derive(Debug, PartialEq, Eq, PartialOrd, Ord, Hash)]
|
||||||
pub struct Promise(Shared<ffi::GstPromise>);
|
pub struct Promise(Shared<ffi::GstPromise>);
|
||||||
|
|
||||||
|
|
|
@ -163,7 +163,7 @@ impl<T: FormattedValue> FormattedSegment<T> {
|
||||||
|
|
||||||
pub fn offset_running_time(&mut self, offset: i64) -> Result<(), glib::BoolError> {
|
pub fn offset_running_time(&mut self, offset: i64) -> Result<(), glib::BoolError> {
|
||||||
unsafe {
|
unsafe {
|
||||||
glib::glib_result_from_gboolean!(
|
glib::result_from_gboolean!(
|
||||||
ffi::gst_segment_offset_running_time(
|
ffi::gst_segment_offset_running_time(
|
||||||
&mut self.0,
|
&mut self.0,
|
||||||
self.get_format().to_glib(),
|
self.get_format().to_glib(),
|
||||||
|
@ -264,7 +264,7 @@ impl<T: FormattedValue> FormattedSegment<T> {
|
||||||
}
|
}
|
||||||
|
|
||||||
unsafe {
|
unsafe {
|
||||||
glib::glib_result_from_gboolean!(
|
glib::result_from_gboolean!(
|
||||||
ffi::gst_segment_set_running_time(
|
ffi::gst_segment_set_running_time(
|
||||||
&mut self.0,
|
&mut self.0,
|
||||||
self.get_format().to_glib(),
|
self.get_format().to_glib(),
|
||||||
|
|
|
@ -180,9 +180,7 @@ impl str::FromStr for Structure {
|
||||||
unsafe {
|
unsafe {
|
||||||
let structure = ffi::gst_structure_from_string(s.to_glib_none().0, ptr::null_mut());
|
let structure = ffi::gst_structure_from_string(s.to_glib_none().0, ptr::null_mut());
|
||||||
if structure.is_null() {
|
if structure.is_null() {
|
||||||
Err(glib::glib_bool_error!(
|
Err(glib::bool_error!("Failed to parse structure from string"))
|
||||||
"Failed to parse structure from string"
|
|
||||||
))
|
|
||||||
} else {
|
} else {
|
||||||
Ok(Self(ptr::NonNull::new_unchecked(
|
Ok(Self(ptr::NonNull::new_unchecked(
|
||||||
structure as *mut StructureRef,
|
structure as *mut StructureRef,
|
||||||
|
|
|
@ -626,7 +626,7 @@ mod tests {
|
||||||
type Instance = crate::subclass::ElementInstanceStruct<Self>;
|
type Instance = crate::subclass::ElementInstanceStruct<Self>;
|
||||||
type Class = subclass::simple::ClassStruct<Self>;
|
type Class = subclass::simple::ClassStruct<Self>;
|
||||||
|
|
||||||
glib::glib_object_subclass!();
|
glib::object_subclass!();
|
||||||
|
|
||||||
fn with_class(klass: &Self::Class) -> Self {
|
fn with_class(klass: &Self::Class) -> Self {
|
||||||
let templ = klass.get_pad_template("sink").unwrap();
|
let templ = klass.get_pad_template("sink").unwrap();
|
||||||
|
@ -735,7 +735,7 @@ mod tests {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
glib::glib_wrapper! {
|
glib::wrapper! {
|
||||||
pub struct TestElement(ObjectSubclass<imp::TestElement>) @extends Element, crate::Object;
|
pub struct TestElement(ObjectSubclass<imp::TestElement>) @extends Element, crate::Object;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -107,7 +107,7 @@ mod tests {
|
||||||
type Instance = subclass::simple::InstanceStruct<Self>;
|
type Instance = subclass::simple::InstanceStruct<Self>;
|
||||||
type Class = subclass::simple::ClassStruct<Self>;
|
type Class = subclass::simple::ClassStruct<Self>;
|
||||||
|
|
||||||
glib::glib_object_subclass!();
|
glib::object_subclass!();
|
||||||
|
|
||||||
fn new() -> Self {
|
fn new() -> Self {
|
||||||
Self {
|
Self {
|
||||||
|
@ -132,7 +132,7 @@ mod tests {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
glib::glib_wrapper! {
|
glib::wrapper! {
|
||||||
pub struct TestPad(ObjectSubclass<imp::TestPad>) @extends Pad, crate::Object;
|
pub struct TestPad(ObjectSubclass<imp::TestPad>) @extends Pad, crate::Object;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -41,7 +41,7 @@ macro_rules! gst_plugin_define(
|
||||||
|
|
||||||
pub fn plugin_register_static() -> Result<(), $crate::glib::BoolError> {
|
pub fn plugin_register_static() -> Result<(), $crate::glib::BoolError> {
|
||||||
unsafe {
|
unsafe {
|
||||||
$crate::glib::glib_result_from_gboolean!(
|
$crate::glib::result_from_gboolean!(
|
||||||
$crate::ffi::gst_plugin_register_static(
|
$crate::ffi::gst_plugin_register_static(
|
||||||
$crate::subclass::MAJOR_VERSION,
|
$crate::subclass::MAJOR_VERSION,
|
||||||
$crate::subclass::MINOR_VERSION,
|
$crate::subclass::MINOR_VERSION,
|
||||||
|
|
|
@ -44,7 +44,7 @@ macro_rules! gst_plugin_define(
|
||||||
|
|
||||||
pub fn plugin_register_static() -> Result<(), $crate::glib::BoolError> {
|
pub fn plugin_register_static() -> Result<(), $crate::glib::BoolError> {
|
||||||
unsafe {
|
unsafe {
|
||||||
$crate::glib::glib_result_from_gboolean!(
|
$crate::glib::result_from_gboolean!(
|
||||||
$crate::ffi::gst_plugin_register_static(
|
$crate::ffi::gst_plugin_register_static(
|
||||||
$crate::subclass::MAJOR_VERSION,
|
$crate::subclass::MAJOR_VERSION,
|
||||||
$crate::subclass::MINOR_VERSION,
|
$crate::subclass::MINOR_VERSION,
|
||||||
|
|
|
@ -50,7 +50,7 @@ impl TypeFind {
|
||||||
Some(type_find_closure_drop::<F>),
|
Some(type_find_closure_drop::<F>),
|
||||||
);
|
);
|
||||||
|
|
||||||
glib::glib_result_from_gboolean!(res, "Failed to register typefind factory")
|
glib::result_from_gboolean!(res, "Failed to register typefind factory")
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -882,7 +882,7 @@ impl GstValueExt for glib::Value {
|
||||||
fn serialize(&self) -> Result<glib::GString, glib::BoolError> {
|
fn serialize(&self) -> Result<glib::GString, glib::BoolError> {
|
||||||
unsafe {
|
unsafe {
|
||||||
Option::<_>::from_glib_full(ffi::gst_value_serialize(self.to_glib_none().0))
|
Option::<_>::from_glib_full(ffi::gst_value_serialize(self.to_glib_none().0))
|
||||||
.ok_or_else(|| glib::glib_bool_error!("Failed to serialize value"))
|
.ok_or_else(|| glib::bool_error!("Failed to serialize value"))
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -900,7 +900,7 @@ impl GstValueExt for glib::Value {
|
||||||
if ret {
|
if ret {
|
||||||
Ok(value)
|
Ok(value)
|
||||||
} else {
|
} else {
|
||||||
Err(glib::glib_bool_error!("Failed to deserialize value"))
|
Err(glib::bool_error!("Failed to deserialize value"))
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue