mirror of
https://gitlab.freedesktop.org/gstreamer/gstreamer-rs.git
synced 2024-10-31 22:59:14 +00:00
Fix nullability handling in some functions in manual code
This commit is contained in:
parent
935609ad6c
commit
f9690817ad
19 changed files with 135 additions and 135 deletions
|
@ -200,7 +200,7 @@ mod cairo_compositor {
|
||||||
caps
|
caps
|
||||||
};
|
};
|
||||||
|
|
||||||
q.set_result(&caps);
|
q.set_result(Some(&caps));
|
||||||
|
|
||||||
true
|
true
|
||||||
}
|
}
|
||||||
|
|
|
@ -41,9 +41,7 @@ fn print_tags(info: &DiscovererInfo) {
|
||||||
|
|
||||||
fn print_stream_info(stream: &DiscovererStreamInfo) {
|
fn print_stream_info(stream: &DiscovererStreamInfo) {
|
||||||
println!("Stream: ");
|
println!("Stream: ");
|
||||||
if let Some(id) = stream.stream_id() {
|
println!(" Stream id: {}", stream.stream_id());
|
||||||
println!(" Stream id: {}", id);
|
|
||||||
}
|
|
||||||
let caps_str = match stream.caps() {
|
let caps_str = match stream.caps() {
|
||||||
Some(caps) => caps.to_string(),
|
Some(caps) => caps.to_string(),
|
||||||
None => String::from("--"),
|
None => String::from("--"),
|
||||||
|
@ -52,10 +50,7 @@ fn print_stream_info(stream: &DiscovererStreamInfo) {
|
||||||
}
|
}
|
||||||
|
|
||||||
fn print_discoverer_info(info: &DiscovererInfo) -> Result<(), Error> {
|
fn print_discoverer_info(info: &DiscovererInfo) -> Result<(), Error> {
|
||||||
let uri = info
|
println!("URI: {}", info.uri());
|
||||||
.uri()
|
|
||||||
.ok_or(DiscovererError("URI should not be null"))?;
|
|
||||||
println!("URI: {}", uri);
|
|
||||||
println!("Duration: {}", info.duration().display());
|
println!("Duration: {}", info.duration().display());
|
||||||
print_tags(info);
|
print_tags(info);
|
||||||
print_stream_info(
|
print_stream_info(
|
||||||
|
|
|
@ -107,11 +107,9 @@ fn create_receiver_pipeline(
|
||||||
// ownership of the passed file descriptor. The file descriptor
|
// ownership of the passed file descriptor. The file descriptor
|
||||||
// will be closed when the memory is released.
|
// will be closed when the memory is released.
|
||||||
let memory = unsafe {
|
let memory = unsafe {
|
||||||
fd_allocator.alloc(
|
fd_allocator
|
||||||
*fd,
|
.alloc(*fd, video_info.size(), gst_allocators::FdMemoryFlags::NONE)
|
||||||
video_info.size(),
|
.unwrap()
|
||||||
gst_allocators::FdMemoryFlags::NONE,
|
|
||||||
)
|
|
||||||
};
|
};
|
||||||
let mut buffer = gst::Buffer::new();
|
let mut buffer = gst::Buffer::new();
|
||||||
let buffer_mut = buffer.make_mut();
|
let buffer_mut = buffer.make_mut();
|
||||||
|
|
|
@ -428,7 +428,7 @@ impl App {
|
||||||
msg.src().map(|s| s.downcast::<gst::Element>().unwrap())
|
msg.src().map(|s| s.downcast::<gst::Element>().unwrap())
|
||||||
{
|
{
|
||||||
let context = gst::Context::new(context_type, true);
|
let context = gst::Context::new(context_type, true);
|
||||||
context.set_gl_display(&gl_display);
|
context.set_gl_display(Some(&gl_display));
|
||||||
el.set_context(&context);
|
el.set_context(&context);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -45,13 +45,18 @@ impl DmaBufMemoryRef {
|
||||||
|
|
||||||
impl DmaBufAllocator {
|
impl DmaBufAllocator {
|
||||||
#[doc(alias = "gst_dmabuf_allocator_alloc")]
|
#[doc(alias = "gst_dmabuf_allocator_alloc")]
|
||||||
pub unsafe fn alloc<A: IntoRawFd>(&self, fd: A, size: usize) -> gst::Memory {
|
pub unsafe fn alloc<A: IntoRawFd>(
|
||||||
|
&self,
|
||||||
|
fd: A,
|
||||||
|
size: usize,
|
||||||
|
) -> Result<gst::Memory, glib::BoolError> {
|
||||||
assert_initialized_main_thread!();
|
assert_initialized_main_thread!();
|
||||||
from_glib_full(ffi::gst_dmabuf_allocator_alloc(
|
Option::<_>::from_glib_full(ffi::gst_dmabuf_allocator_alloc(
|
||||||
self.unsafe_cast_ref::<gst::Allocator>().to_glib_none().0,
|
self.unsafe_cast_ref::<gst::Allocator>().to_glib_none().0,
|
||||||
fd.into_raw_fd(),
|
fd.into_raw_fd(),
|
||||||
size,
|
size,
|
||||||
))
|
))
|
||||||
|
.ok_or_else(|| glib::bool_error!("Failed to allocate memory"))
|
||||||
}
|
}
|
||||||
|
|
||||||
#[cfg(any(feature = "v1_16", feature = "dox"))]
|
#[cfg(any(feature = "v1_16", feature = "dox"))]
|
||||||
|
@ -62,13 +67,14 @@ impl DmaBufAllocator {
|
||||||
fd: RawFd,
|
fd: RawFd,
|
||||||
size: usize,
|
size: usize,
|
||||||
flags: FdMemoryFlags,
|
flags: FdMemoryFlags,
|
||||||
) -> gst::Memory {
|
) -> Result<gst::Memory, glib::BoolError> {
|
||||||
assert_initialized_main_thread!();
|
assert_initialized_main_thread!();
|
||||||
from_glib_full(ffi::gst_dmabuf_allocator_alloc_with_flags(
|
Option::<_>::from_glib_full(ffi::gst_dmabuf_allocator_alloc_with_flags(
|
||||||
self.unsafe_cast_ref::<gst::Allocator>().to_glib_none().0,
|
self.unsafe_cast_ref::<gst::Allocator>().to_glib_none().0,
|
||||||
fd,
|
fd,
|
||||||
size,
|
size,
|
||||||
flags.into_glib(),
|
flags.into_glib(),
|
||||||
))
|
))
|
||||||
|
.ok_or_else(|| glib::bool_error!("Failed to allocate memory"))
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -47,13 +47,19 @@ impl FdMemoryRef {
|
||||||
|
|
||||||
impl FdAllocator {
|
impl FdAllocator {
|
||||||
#[doc(alias = "gst_fd_allocator_alloc")]
|
#[doc(alias = "gst_fd_allocator_alloc")]
|
||||||
pub unsafe fn alloc(&self, fd: RawFd, size: usize, flags: FdMemoryFlags) -> gst::Memory {
|
pub unsafe fn alloc(
|
||||||
|
&self,
|
||||||
|
fd: RawFd,
|
||||||
|
size: usize,
|
||||||
|
flags: FdMemoryFlags,
|
||||||
|
) -> Result<gst::Memory, glib::BoolError> {
|
||||||
assert_initialized_main_thread!();
|
assert_initialized_main_thread!();
|
||||||
from_glib_full(ffi::gst_fd_allocator_alloc(
|
Option::<_>::from_glib_full(ffi::gst_fd_allocator_alloc(
|
||||||
self.unsafe_cast_ref::<gst::Allocator>().to_glib_none().0,
|
self.unsafe_cast_ref::<gst::Allocator>().to_glib_none().0,
|
||||||
fd,
|
fd,
|
||||||
size,
|
size,
|
||||||
flags.into_glib(),
|
flags.into_glib(),
|
||||||
))
|
))
|
||||||
|
.ok_or_else(|| glib::bool_error!("Failed to allocate memory"))
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -11,7 +11,7 @@ pub trait ContextGLExt {
|
||||||
#[doc(alias = "gst_context_get_gl_display")]
|
#[doc(alias = "gst_context_get_gl_display")]
|
||||||
fn gl_display(&self) -> Option<GLDisplay>;
|
fn gl_display(&self) -> Option<GLDisplay>;
|
||||||
#[doc(alias = "gst_context_set_gl_display")]
|
#[doc(alias = "gst_context_set_gl_display")]
|
||||||
fn set_gl_display<T: IsA<GLDisplay>>(&self, display: &T);
|
fn set_gl_display<T: IsA<GLDisplay>>(&self, display: Option<&T>);
|
||||||
}
|
}
|
||||||
|
|
||||||
impl ContextGLExt for ContextRef {
|
impl ContextGLExt for ContextRef {
|
||||||
|
@ -29,9 +29,12 @@ impl ContextGLExt for ContextRef {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
fn set_gl_display<T: IsA<GLDisplay>>(&self, display: &T) {
|
fn set_gl_display<T: IsA<GLDisplay>>(&self, display: Option<&T>) {
|
||||||
unsafe {
|
unsafe {
|
||||||
ffi::gst_context_set_gl_display(self.as_mut_ptr(), display.as_ref().to_glib_none().0);
|
ffi::gst_context_set_gl_display(
|
||||||
|
self.as_mut_ptr(),
|
||||||
|
display.map(|d| d.as_ref()).to_glib_none().0,
|
||||||
|
);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -7,7 +7,6 @@ use crate::GLBaseMemoryAllocator;
|
||||||
|
|
||||||
use ffi::GstGLBaseMemory;
|
use ffi::GstGLBaseMemory;
|
||||||
use gst::MemoryRef;
|
use gst::MemoryRef;
|
||||||
use gst::{result_from_gboolean, LoggableError, CAT_RUST};
|
|
||||||
|
|
||||||
gst::memory_object_wrapper!(
|
gst::memory_object_wrapper!(
|
||||||
GLBaseMemory,
|
GLBaseMemory,
|
||||||
|
@ -51,16 +50,15 @@ impl GLBaseMemoryRef {
|
||||||
dest: &mut GLBaseMemory,
|
dest: &mut GLBaseMemory,
|
||||||
offset: isize,
|
offset: isize,
|
||||||
size: isize,
|
size: isize,
|
||||||
) -> Result<(), LoggableError> {
|
) -> Result<(), glib::BoolError> {
|
||||||
Self::init_once();
|
Self::init_once();
|
||||||
result_from_gboolean!(
|
glib::result_from_gboolean!(
|
||||||
ffi::gst_gl_base_memory_memcpy(
|
ffi::gst_gl_base_memory_memcpy(
|
||||||
mut_override(&self.0),
|
mut_override(&self.0),
|
||||||
dest.to_glib_none_mut().0,
|
dest.to_glib_none_mut().0,
|
||||||
offset,
|
offset,
|
||||||
size,
|
size,
|
||||||
),
|
),
|
||||||
CAT_RUST,
|
|
||||||
"Failed to copy memory"
|
"Failed to copy memory"
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
@ -69,14 +67,15 @@ impl GLBaseMemoryRef {
|
||||||
pub fn alloc<P: IsA<GLBaseMemoryAllocator>>(
|
pub fn alloc<P: IsA<GLBaseMemoryAllocator>>(
|
||||||
allocator: &P,
|
allocator: &P,
|
||||||
params: &GLAllocationParams,
|
params: &GLAllocationParams,
|
||||||
) -> Option<GLBaseMemory> {
|
) -> Result<GLBaseMemory, glib::BoolError> {
|
||||||
skip_assert_initialized!();
|
skip_assert_initialized!();
|
||||||
Self::init_once();
|
Self::init_once();
|
||||||
unsafe {
|
unsafe {
|
||||||
from_glib_full(ffi::gst_gl_base_memory_alloc(
|
Option::<_>::from_glib_full(ffi::gst_gl_base_memory_alloc(
|
||||||
allocator.as_ref().to_glib_none().0,
|
allocator.as_ref().to_glib_none().0,
|
||||||
mut_override(params.to_glib_none().0),
|
mut_override(params.to_glib_none().0),
|
||||||
))
|
))
|
||||||
|
.ok_or_else(|| glib::bool_error!("Failed to allocate memory"))
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -48,42 +48,21 @@ pub fn pb_utils_add_codec_description_to_tag_list(
|
||||||
}
|
}
|
||||||
|
|
||||||
#[doc(alias = "gst_pb_utils_get_encoder_description")]
|
#[doc(alias = "gst_pb_utils_get_encoder_description")]
|
||||||
pub fn pb_utils_get_encoder_description(
|
pub fn pb_utils_get_encoder_description(caps: &gst::CapsRef) -> glib::GString {
|
||||||
caps: &gst::CapsRef,
|
|
||||||
) -> Result<glib::GString, glib::error::BoolError> {
|
|
||||||
assert_initialized_main_thread!();
|
assert_initialized_main_thread!();
|
||||||
unsafe {
|
unsafe { 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),
|
|
||||||
None => Err(glib::bool_error!("Failed to get encoder description")),
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
#[doc(alias = "gst_pb_utils_get_decoder_description")]
|
#[doc(alias = "gst_pb_utils_get_decoder_description")]
|
||||||
pub fn pb_utils_get_decoder_description(
|
pub fn pb_utils_get_decoder_description(caps: &gst::CapsRef) -> glib::GString {
|
||||||
caps: &gst::CapsRef,
|
|
||||||
) -> Result<glib::GString, glib::error::BoolError> {
|
|
||||||
assert_initialized_main_thread!();
|
assert_initialized_main_thread!();
|
||||||
unsafe {
|
unsafe { 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),
|
|
||||||
None => Err(glib::bool_error!("Failed to get decoder description")),
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
#[doc(alias = "gst_pb_utils_get_codec_description")]
|
#[doc(alias = "gst_pb_utils_get_codec_description")]
|
||||||
pub fn pb_utils_get_codec_description(
|
pub fn pb_utils_get_codec_description(caps: &gst::CapsRef) -> glib::GString {
|
||||||
caps: &gst::CapsRef,
|
|
||||||
) -> Result<glib::GString, glib::error::BoolError> {
|
|
||||||
assert_initialized_main_thread!();
|
assert_initialized_main_thread!();
|
||||||
unsafe {
|
unsafe { 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),
|
|
||||||
None => Err(glib::bool_error!("Failed to get codec description")),
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
#[doc(alias = "gst_codec_utils_aac_caps_set_level_and_profile")]
|
#[doc(alias = "gst_codec_utils_aac_caps_set_level_and_profile")]
|
||||||
|
|
|
@ -425,26 +425,6 @@ impl<'a, T> RTPBuffer<'a, T> {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
impl RTPBuffer<'_, ()> {
|
|
||||||
#[doc(alias = "gst_rtp_buffer_calc_header_len")]
|
|
||||||
pub fn calc_header_len(csrc_count: u8) -> u32 {
|
|
||||||
skip_assert_initialized!();
|
|
||||||
unsafe { ffi::gst_rtp_buffer_calc_header_len(csrc_count) }
|
|
||||||
}
|
|
||||||
|
|
||||||
#[doc(alias = "gst_rtp_buffer_calc_packet_len")]
|
|
||||||
pub fn calc_packet_len(payload_len: u32, pad_len: u8, csrc_count: u8) -> u32 {
|
|
||||||
skip_assert_initialized!();
|
|
||||||
unsafe { ffi::gst_rtp_buffer_calc_packet_len(payload_len, pad_len, csrc_count) }
|
|
||||||
}
|
|
||||||
|
|
||||||
#[doc(alias = "gst_rtp_buffer_calc_payload_len")]
|
|
||||||
pub fn calc_payload_len(packet_len: u32, pad_len: u8, csrc_count: u8) -> u32 {
|
|
||||||
skip_assert_initialized!();
|
|
||||||
unsafe { ffi::gst_rtp_buffer_calc_payload_len(packet_len, pad_len, csrc_count) }
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
impl<'a, T> Drop for RTPBuffer<'a, T> {
|
impl<'a, T> Drop for RTPBuffer<'a, T> {
|
||||||
fn drop(&mut self) {
|
fn drop(&mut self) {
|
||||||
unsafe {
|
unsafe {
|
||||||
|
@ -485,6 +465,30 @@ pub fn compare_seqnum(seqnum1: u16, seqnum2: u16) -> i32 {
|
||||||
unsafe { ffi::gst_rtp_buffer_compare_seqnum(seqnum1, seqnum2) }
|
unsafe { ffi::gst_rtp_buffer_compare_seqnum(seqnum1, seqnum2) }
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#[doc(alias = "gst_rtp_buffer_calc_header_len")]
|
||||||
|
pub fn calc_header_len(csrc_count: u8) -> u32 {
|
||||||
|
skip_assert_initialized!();
|
||||||
|
unsafe { ffi::gst_rtp_buffer_calc_header_len(csrc_count) }
|
||||||
|
}
|
||||||
|
|
||||||
|
#[doc(alias = "gst_rtp_buffer_calc_packet_len")]
|
||||||
|
pub fn calc_packet_len(payload_len: u32, pad_len: u8, csrc_count: u8) -> u32 {
|
||||||
|
skip_assert_initialized!();
|
||||||
|
unsafe { ffi::gst_rtp_buffer_calc_packet_len(payload_len, pad_len, csrc_count) }
|
||||||
|
}
|
||||||
|
|
||||||
|
#[doc(alias = "gst_rtp_buffer_calc_payload_len")]
|
||||||
|
pub fn calc_payload_len(packet_len: u32, pad_len: u8, csrc_count: u8) -> u32 {
|
||||||
|
skip_assert_initialized!();
|
||||||
|
unsafe { ffi::gst_rtp_buffer_calc_payload_len(packet_len, pad_len, csrc_count) }
|
||||||
|
}
|
||||||
|
|
||||||
|
#[doc(alias = "gst_rtp_buffer_ext_timestamp")]
|
||||||
|
pub fn ext_timestamp(exttimestamp: &mut u64, timestamp: u32) -> u64 {
|
||||||
|
skip_assert_initialized!();
|
||||||
|
unsafe { ffi::gst_rtp_buffer_ext_timestamp(exttimestamp, timestamp) }
|
||||||
|
}
|
||||||
|
|
||||||
#[cfg(test)]
|
#[cfg(test)]
|
||||||
mod tests {
|
mod tests {
|
||||||
use super::*;
|
use super::*;
|
||||||
|
@ -692,11 +696,11 @@ mod tests {
|
||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
fn test_calc_functions() {
|
fn test_calc_functions() {
|
||||||
let res = RTPBuffer::calc_header_len(0);
|
let res = super::calc_header_len(0);
|
||||||
assert_eq!(res, 12);
|
assert_eq!(res, 12);
|
||||||
let res = RTPBuffer::calc_packet_len(100, 10, 2);
|
let res = super::calc_packet_len(100, 10, 2);
|
||||||
assert_eq!(res, 130);
|
assert_eq!(res, 130);
|
||||||
let res = RTPBuffer::calc_payload_len(100, 5, 4);
|
let res = super::calc_payload_len(100, 5, 4);
|
||||||
assert_eq!(res, 67);
|
assert_eq!(res, 67);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -22,7 +22,7 @@ impl RTSPToken {
|
||||||
|
|
||||||
{
|
{
|
||||||
let token = token.get_mut().unwrap();
|
let token = token.get_mut().unwrap();
|
||||||
let structure = token.structure_mut().unwrap();
|
let structure = token.structure_mut();
|
||||||
|
|
||||||
for &(f, v) in values {
|
for &(f, v) in values {
|
||||||
structure.set_value(f, v.to_send_value());
|
structure.set_value(f, v.to_send_value());
|
||||||
|
@ -62,14 +62,10 @@ impl RTSPTokenRef {
|
||||||
}
|
}
|
||||||
|
|
||||||
#[doc(alias = "get_mut_structure")]
|
#[doc(alias = "get_mut_structure")]
|
||||||
pub fn structure_mut(&mut self) -> Option<&mut gst::StructureRef> {
|
pub fn structure_mut(&mut self) -> &mut gst::StructureRef {
|
||||||
unsafe {
|
unsafe {
|
||||||
let structure = ffi::gst_rtsp_token_writable_structure(self.as_mut_ptr());
|
let structure = ffi::gst_rtsp_token_writable_structure(self.as_mut_ptr());
|
||||||
if structure.is_null() {
|
gst::StructureRef::from_glib_borrow_mut(structure)
|
||||||
None
|
|
||||||
} else {
|
|
||||||
Some(gst::StructureRef::from_glib_borrow_mut(structure))
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -39,6 +39,7 @@ macro_rules! skip_assert_initialized {
|
||||||
#[allow(clippy::too_many_arguments)]
|
#[allow(clippy::too_many_arguments)]
|
||||||
#[allow(clippy::match_same_arms)]
|
#[allow(clippy::match_same_arms)]
|
||||||
#[allow(non_snake_case)]
|
#[allow(non_snake_case)]
|
||||||
|
#[allow(clippy::needless_borrow)]
|
||||||
#[allow(clippy::use_self)]
|
#[allow(clippy::use_self)]
|
||||||
#[allow(unused_imports)]
|
#[allow(unused_imports)]
|
||||||
mod auto;
|
mod auto;
|
||||||
|
|
|
@ -46,9 +46,8 @@ impl PluginApiExt for glib::Type {
|
||||||
self.into_glib(),
|
self.into_glib(),
|
||||||
flags.as_mut_ptr(),
|
flags.as_mut_ptr(),
|
||||||
));
|
));
|
||||||
let flags = flags.assume_init();
|
|
||||||
if ret {
|
if ret {
|
||||||
Some(from_glib(flags))
|
Some(from_glib(flags.assume_init()))
|
||||||
} else {
|
} else {
|
||||||
None
|
None
|
||||||
}
|
}
|
||||||
|
|
|
@ -1532,14 +1532,17 @@ declare_concrete_message!(PropertyNotify, T);
|
||||||
impl PropertyNotify {
|
impl PropertyNotify {
|
||||||
#[doc(alias = "gst_message_new_property_notify")]
|
#[doc(alias = "gst_message_new_property_notify")]
|
||||||
#[allow(clippy::new_ret_no_self)]
|
#[allow(clippy::new_ret_no_self)]
|
||||||
pub fn new(property_name: &str) -> Message {
|
pub fn new(object: &impl IsA<crate::Object>, property_name: &str) -> Message {
|
||||||
skip_assert_initialized!();
|
skip_assert_initialized!();
|
||||||
Self::builder(property_name).build()
|
Self::builder(object, property_name).build()
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn builder(property_name: &str) -> PropertyNotifyBuilder {
|
pub fn builder<'a>(
|
||||||
|
object: &'a impl IsA<crate::Object>,
|
||||||
|
property_name: &'a str,
|
||||||
|
) -> PropertyNotifyBuilder<'a> {
|
||||||
assert_initialized_main_thread!();
|
assert_initialized_main_thread!();
|
||||||
PropertyNotifyBuilder::new(property_name)
|
PropertyNotifyBuilder::new(property_name).src(object)
|
||||||
}
|
}
|
||||||
|
|
||||||
#[doc(alias = "gst_message_parse_property_notify")]
|
#[doc(alias = "gst_message_parse_property_notify")]
|
||||||
|
|
|
@ -939,7 +939,7 @@ impl Default for Uri<Query> {
|
||||||
impl Uri {
|
impl Uri {
|
||||||
#[doc(alias = "get_uri")]
|
#[doc(alias = "get_uri")]
|
||||||
#[doc(alias = "gst_query_parse_uri")]
|
#[doc(alias = "gst_query_parse_uri")]
|
||||||
pub fn uri(&self) -> Option<String> {
|
pub fn uri(&self) -> Option<glib::GString> {
|
||||||
unsafe {
|
unsafe {
|
||||||
let mut uri = ptr::null_mut();
|
let mut uri = ptr::null_mut();
|
||||||
ffi::gst_query_parse_uri(self.as_mut_ptr(), &mut uri);
|
ffi::gst_query_parse_uri(self.as_mut_ptr(), &mut uri);
|
||||||
|
@ -950,7 +950,7 @@ impl Uri {
|
||||||
#[doc(alias = "get_redirection")]
|
#[doc(alias = "get_redirection")]
|
||||||
#[doc(alias = "gst_query_parse_uri_redirection")]
|
#[doc(alias = "gst_query_parse_uri_redirection")]
|
||||||
#[doc(alias = "gst_query_parse_uri_redirection_permanent")]
|
#[doc(alias = "gst_query_parse_uri_redirection_permanent")]
|
||||||
pub fn redirection(&self) -> (Option<String>, bool) {
|
pub fn redirection(&self) -> (Option<glib::GString>, bool) {
|
||||||
unsafe {
|
unsafe {
|
||||||
let mut uri = ptr::null_mut();
|
let mut uri = ptr::null_mut();
|
||||||
ffi::gst_query_parse_uri_redirection(self.as_mut_ptr(), &mut uri);
|
ffi::gst_query_parse_uri_redirection(self.as_mut_ptr(), &mut uri);
|
||||||
|
@ -965,7 +965,7 @@ impl Uri {
|
||||||
}
|
}
|
||||||
|
|
||||||
#[doc(alias = "gst_query_set_uri")]
|
#[doc(alias = "gst_query_set_uri")]
|
||||||
pub fn set_uri(&mut self, uri: &str) {
|
pub fn set_uri(&mut self, uri: Option<&str>) {
|
||||||
unsafe {
|
unsafe {
|
||||||
ffi::gst_query_set_uri(self.as_mut_ptr(), uri.to_glib_none().0);
|
ffi::gst_query_set_uri(self.as_mut_ptr(), uri.to_glib_none().0);
|
||||||
}
|
}
|
||||||
|
@ -973,7 +973,7 @@ impl Uri {
|
||||||
|
|
||||||
#[doc(alias = "gst_query_set_uri_redirection")]
|
#[doc(alias = "gst_query_set_uri_redirection")]
|
||||||
#[doc(alias = "gst_query_set_uri_redirection_permanent")]
|
#[doc(alias = "gst_query_set_uri_redirection_permanent")]
|
||||||
pub fn set_redirection(&mut self, uri: &str, permanent: bool) {
|
pub fn set_redirection(&mut self, uri: Option<&str>, permanent: bool) {
|
||||||
unsafe {
|
unsafe {
|
||||||
ffi::gst_query_set_uri_redirection(self.as_mut_ptr(), uri.to_glib_none().0);
|
ffi::gst_query_set_uri_redirection(self.as_mut_ptr(), uri.to_glib_none().0);
|
||||||
ffi::gst_query_set_uri_redirection_permanent(
|
ffi::gst_query_set_uri_redirection_permanent(
|
||||||
|
@ -1453,9 +1453,13 @@ impl Caps {
|
||||||
}
|
}
|
||||||
|
|
||||||
#[doc(alias = "gst_query_set_caps_result")]
|
#[doc(alias = "gst_query_set_caps_result")]
|
||||||
pub fn set_result(&mut self, caps: &crate::Caps) {
|
pub fn set_result(&mut self, caps: Option<&crate::Caps>) {
|
||||||
unsafe {
|
unsafe {
|
||||||
ffi::gst_query_set_caps_result(self.as_mut_ptr(), caps.as_mut_ptr());
|
ffi::gst_query_set_caps_result(
|
||||||
|
self.as_mut_ptr(),
|
||||||
|
caps.map(|caps| caps.as_mut_ptr())
|
||||||
|
.unwrap_or(ptr::null_mut()),
|
||||||
|
);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -1523,9 +1527,14 @@ impl Context {
|
||||||
}
|
}
|
||||||
|
|
||||||
#[doc(alias = "gst_query_set_context")]
|
#[doc(alias = "gst_query_set_context")]
|
||||||
pub fn set_context(&mut self, context: &crate::Context) {
|
pub fn set_context(&mut self, context: Option<&crate::Context>) {
|
||||||
unsafe {
|
unsafe {
|
||||||
ffi::gst_query_set_context(self.as_mut_ptr(), context.as_mut_ptr());
|
ffi::gst_query_set_context(
|
||||||
|
self.as_mut_ptr(),
|
||||||
|
context
|
||||||
|
.map(|context| context.as_mut_ptr())
|
||||||
|
.unwrap_or(ptr::null_mut()),
|
||||||
|
);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -1027,16 +1027,11 @@ pub fn tag_get_type(name: &str) -> glib::Type {
|
||||||
}
|
}
|
||||||
|
|
||||||
#[doc(alias = "gst_tag_get_nick")]
|
#[doc(alias = "gst_tag_get_nick")]
|
||||||
pub fn tag_get_nick<'b>(name: &str) -> Option<&'b str> {
|
pub fn tag_get_nick(name: &str) -> &str {
|
||||||
skip_assert_initialized!();
|
skip_assert_initialized!();
|
||||||
unsafe {
|
unsafe {
|
||||||
let ptr = ffi::gst_tag_get_nick(name.to_glib_none().0);
|
let ptr = ffi::gst_tag_get_nick(name.to_glib_none().0);
|
||||||
|
CStr::from_ptr(ptr).to_str().unwrap()
|
||||||
if ptr.is_null() {
|
|
||||||
None
|
|
||||||
} else {
|
|
||||||
Some(CStr::from_ptr(ptr).to_str().unwrap())
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1324,10 +1319,7 @@ mod tests {
|
||||||
tag_get_type(MyCustomTag::tag_name()),
|
tag_get_type(MyCustomTag::tag_name()),
|
||||||
<MyCustomTag as Tag>::TagType::static_type()
|
<MyCustomTag as Tag>::TagType::static_type()
|
||||||
);
|
);
|
||||||
assert_eq!(
|
assert_eq!(tag_get_nick(MyCustomTag::tag_name()), MyCustomTag::NICK);
|
||||||
tag_get_nick(MyCustomTag::tag_name()),
|
|
||||||
Some(MyCustomTag::NICK)
|
|
||||||
);
|
|
||||||
assert_eq!(
|
assert_eq!(
|
||||||
tag_get_description(MyCustomTag::tag_name()),
|
tag_get_description(MyCustomTag::tag_name()),
|
||||||
Some(MyCustomTag::DESCRIPTION)
|
Some(MyCustomTag::DESCRIPTION)
|
||||||
|
|
|
@ -3,6 +3,7 @@
|
||||||
use std::ffi::CStr;
|
use std::ffi::CStr;
|
||||||
use std::fmt;
|
use std::fmt;
|
||||||
use std::mem;
|
use std::mem;
|
||||||
|
use std::ptr;
|
||||||
|
|
||||||
use glib::translate::{
|
use glib::translate::{
|
||||||
from_glib, from_glib_full, from_glib_none, FromGlibPtrContainer, IntoGlib, IntoGlibPtr,
|
from_glib, from_glib_full, from_glib_none, FromGlibPtrContainer, IntoGlib, IntoGlibPtr,
|
||||||
|
@ -57,16 +58,25 @@ impl TocRef {
|
||||||
}
|
}
|
||||||
|
|
||||||
#[doc(alias = "gst_toc_set_tags")]
|
#[doc(alias = "gst_toc_set_tags")]
|
||||||
pub fn set_tags(&mut self, tag_list: TagList) {
|
pub fn set_tags(&mut self, tag_list: Option<TagList>) {
|
||||||
unsafe {
|
unsafe {
|
||||||
ffi::gst_toc_set_tags(self.as_mut_ptr(), tag_list.into_glib_ptr());
|
ffi::gst_toc_set_tags(
|
||||||
|
self.as_mut_ptr(),
|
||||||
|
tag_list
|
||||||
|
.map(|t| t.into_glib_ptr())
|
||||||
|
.unwrap_or(ptr::null_mut()),
|
||||||
|
);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
#[doc(alias = "gst_toc_merge_tags")]
|
#[doc(alias = "gst_toc_merge_tags")]
|
||||||
pub fn merge_tags(&mut self, tag_list: &TagList, mode: TagMergeMode) {
|
pub fn merge_tags(&mut self, tag_list: Option<&TagList>, mode: TagMergeMode) {
|
||||||
unsafe {
|
unsafe {
|
||||||
ffi::gst_toc_merge_tags(self.as_mut_ptr(), tag_list.as_mut_ptr(), mode.into_glib());
|
ffi::gst_toc_merge_tags(
|
||||||
|
self.as_mut_ptr(),
|
||||||
|
tag_list.map(|l| l.as_mut_ptr()).unwrap_or(ptr::null_mut()),
|
||||||
|
mode.into_glib(),
|
||||||
|
);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -182,18 +192,23 @@ impl TocEntryRef {
|
||||||
}
|
}
|
||||||
|
|
||||||
#[doc(alias = "gst_toc_entry_set_tags")]
|
#[doc(alias = "gst_toc_entry_set_tags")]
|
||||||
pub fn set_tags(&mut self, tag_list: TagList) {
|
pub fn set_tags(&mut self, tag_list: Option<TagList>) {
|
||||||
unsafe {
|
unsafe {
|
||||||
ffi::gst_toc_entry_set_tags(self.as_mut_ptr(), tag_list.into_glib_ptr());
|
ffi::gst_toc_entry_set_tags(
|
||||||
|
self.as_mut_ptr(),
|
||||||
|
tag_list
|
||||||
|
.map(|t| t.into_glib_ptr())
|
||||||
|
.unwrap_or(ptr::null_mut()),
|
||||||
|
);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
#[doc(alias = "gst_toc_entry_merge_tags")]
|
#[doc(alias = "gst_toc_entry_merge_tags")]
|
||||||
pub fn merge_tags(&mut self, tag_list: &TagList, mode: TagMergeMode) {
|
pub fn merge_tags(&mut self, tag_list: Option<&TagList>, mode: TagMergeMode) {
|
||||||
unsafe {
|
unsafe {
|
||||||
ffi::gst_toc_entry_merge_tags(
|
ffi::gst_toc_entry_merge_tags(
|
||||||
self.as_mut_ptr(),
|
self.as_mut_ptr(),
|
||||||
tag_list.as_mut_ptr(),
|
tag_list.map(|l| l.as_mut_ptr()).unwrap_or(ptr::null_mut()),
|
||||||
mode.into_glib(),
|
mode.into_glib(),
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
|
@ -57,9 +57,7 @@ impl From<TocDe> for Toc {
|
||||||
let mut toc = Toc::new(toc_de.scope);
|
let mut toc = Toc::new(toc_de.scope);
|
||||||
{
|
{
|
||||||
let toc = toc.get_mut().unwrap();
|
let toc = toc.get_mut().unwrap();
|
||||||
if let Some(tags) = toc_de.tags.take() {
|
toc.set_tags(toc_de.tags.take());
|
||||||
toc.set_tags(tags);
|
|
||||||
}
|
|
||||||
let entry_iter = toc_de.entries.drain(..);
|
let entry_iter = toc_de.entries.drain(..);
|
||||||
for entry in entry_iter {
|
for entry in entry_iter {
|
||||||
toc.append_entry(entry);
|
toc.append_entry(entry);
|
||||||
|
@ -96,9 +94,7 @@ impl From<TocEntryDe> for TocEntry {
|
||||||
if let Some(start_stop) = toc_entry_de.start_stop.take() {
|
if let Some(start_stop) = toc_entry_de.start_stop.take() {
|
||||||
toc_entry.set_start_stop_times(start_stop.0, start_stop.1);
|
toc_entry.set_start_stop_times(start_stop.0, start_stop.1);
|
||||||
}
|
}
|
||||||
if let Some(tags) = toc_entry_de.tags.take() {
|
toc_entry.set_tags(toc_entry_de.tags.take());
|
||||||
toc_entry.set_tags(tags);
|
|
||||||
}
|
|
||||||
if let Some(loop_) = toc_entry_de.loop_.take() {
|
if let Some(loop_) = toc_entry_de.loop_.take() {
|
||||||
toc_entry.set_loop(loop_.0, loop_.1);
|
toc_entry.set_loop(loop_.0, loop_.1);
|
||||||
}
|
}
|
||||||
|
@ -139,7 +135,7 @@ mod tests {
|
||||||
tags.get_mut()
|
tags.get_mut()
|
||||||
.unwrap()
|
.unwrap()
|
||||||
.add::<Title>(&"toc", TagMergeMode::Append);
|
.add::<Title>(&"toc", TagMergeMode::Append);
|
||||||
toc.set_tags(tags);
|
toc.set_tags(Some(tags));
|
||||||
|
|
||||||
let mut toc_edition = TocEntry::new(TocEntryType::Edition, "edition");
|
let mut toc_edition = TocEntry::new(TocEntryType::Edition, "edition");
|
||||||
{
|
{
|
||||||
|
@ -158,7 +154,7 @@ mod tests {
|
||||||
tags.get_mut()
|
tags.get_mut()
|
||||||
.unwrap()
|
.unwrap()
|
||||||
.add::<Title>(&"chapter 1.1", TagMergeMode::Append);
|
.add::<Title>(&"chapter 1.1", TagMergeMode::Append);
|
||||||
toc_chap_1_1.set_tags(tags);
|
toc_chap_1_1.set_tags(Some(tags));
|
||||||
}
|
}
|
||||||
toc_chap_1.append_sub_entry(toc_chap_1_1);
|
toc_chap_1.append_sub_entry(toc_chap_1_1);
|
||||||
|
|
||||||
|
@ -170,7 +166,7 @@ mod tests {
|
||||||
tags.get_mut()
|
tags.get_mut()
|
||||||
.unwrap()
|
.unwrap()
|
||||||
.add::<Title>(&"chapter 1.2", TagMergeMode::Append);
|
.add::<Title>(&"chapter 1.2", TagMergeMode::Append);
|
||||||
toc_chap_1_2.set_tags(tags);
|
toc_chap_1_2.set_tags(Some(tags));
|
||||||
}
|
}
|
||||||
toc_chap_1.append_sub_entry(toc_chap_1_2);
|
toc_chap_1.append_sub_entry(toc_chap_1_2);
|
||||||
}
|
}
|
||||||
|
@ -184,7 +180,7 @@ mod tests {
|
||||||
tags.get_mut()
|
tags.get_mut()
|
||||||
.unwrap()
|
.unwrap()
|
||||||
.add::<Title>(&"chapter 2", TagMergeMode::Append);
|
.add::<Title>(&"chapter 2", TagMergeMode::Append);
|
||||||
toc_chap_2.set_tags(tags);
|
toc_chap_2.set_tags(Some(tags));
|
||||||
}
|
}
|
||||||
toc_edition.append_sub_entry(toc_chap_2);
|
toc_edition.append_sub_entry(toc_chap_2);
|
||||||
}
|
}
|
||||||
|
@ -419,7 +415,7 @@ mod tests {
|
||||||
tags.get_mut()
|
tags.get_mut()
|
||||||
.unwrap()
|
.unwrap()
|
||||||
.add::<Title>(&"toc", TagMergeMode::Append);
|
.add::<Title>(&"toc", TagMergeMode::Append);
|
||||||
toc.set_tags(tags);
|
toc.set_tags(Some(tags));
|
||||||
|
|
||||||
let mut toc_edition = TocEntry::new(TocEntryType::Edition, "edition");
|
let mut toc_edition = TocEntry::new(TocEntryType::Edition, "edition");
|
||||||
{
|
{
|
||||||
|
@ -438,7 +434,7 @@ mod tests {
|
||||||
tags.get_mut()
|
tags.get_mut()
|
||||||
.unwrap()
|
.unwrap()
|
||||||
.add::<Title>(&"chapter 1.1", TagMergeMode::Append);
|
.add::<Title>(&"chapter 1.1", TagMergeMode::Append);
|
||||||
toc_chap_1_1.set_tags(tags);
|
toc_chap_1_1.set_tags(Some(tags));
|
||||||
}
|
}
|
||||||
toc_chap_1.append_sub_entry(toc_chap_1_1);
|
toc_chap_1.append_sub_entry(toc_chap_1_1);
|
||||||
|
|
||||||
|
@ -450,7 +446,7 @@ mod tests {
|
||||||
tags.get_mut()
|
tags.get_mut()
|
||||||
.unwrap()
|
.unwrap()
|
||||||
.add::<Title>(&"chapter 1.2", TagMergeMode::Append);
|
.add::<Title>(&"chapter 1.2", TagMergeMode::Append);
|
||||||
toc_chap_1_2.set_tags(tags);
|
toc_chap_1_2.set_tags(Some(tags));
|
||||||
}
|
}
|
||||||
toc_chap_1.append_sub_entry(toc_chap_1_2);
|
toc_chap_1.append_sub_entry(toc_chap_1_2);
|
||||||
}
|
}
|
||||||
|
@ -464,7 +460,7 @@ mod tests {
|
||||||
tags.get_mut()
|
tags.get_mut()
|
||||||
.unwrap()
|
.unwrap()
|
||||||
.add::<Title>(&"chapter 2", TagMergeMode::Append);
|
.add::<Title>(&"chapter 2", TagMergeMode::Append);
|
||||||
toc_chap_2.set_tags(tags);
|
toc_chap_2.set_tags(Some(tags));
|
||||||
}
|
}
|
||||||
toc_edition.append_sub_entry(toc_chap_2);
|
toc_edition.append_sub_entry(toc_chap_2);
|
||||||
}
|
}
|
||||||
|
|
|
@ -24,7 +24,6 @@ fn print_stream_info(info: &DiscovererStreamInfo, depth: usize) {
|
||||||
let caps_str = if let Some(caps) = info.caps() {
|
let caps_str = if let Some(caps) = info.caps() {
|
||||||
if caps.is_fixed() {
|
if caps.is_fixed() {
|
||||||
gst_pbutils::pb_utils_get_codec_description(&caps)
|
gst_pbutils::pb_utils_get_codec_description(&caps)
|
||||||
.unwrap_or_else(|_| glib::GString::from("unknown codec"))
|
|
||||||
} else {
|
} else {
|
||||||
glib::GString::from(caps.to_string())
|
glib::GString::from(caps.to_string())
|
||||||
}
|
}
|
||||||
|
@ -82,7 +81,7 @@ fn on_discovered(
|
||||||
discoverer_info: &DiscovererInfo,
|
discoverer_info: &DiscovererInfo,
|
||||||
error: Option<&glib::Error>,
|
error: Option<&glib::Error>,
|
||||||
) {
|
) {
|
||||||
let uri = discoverer_info.uri().unwrap();
|
let uri = discoverer_info.uri();
|
||||||
match discoverer_info.result() {
|
match discoverer_info.result() {
|
||||||
DiscovererResult::Ok => println!("Discovered {}", uri),
|
DiscovererResult::Ok => println!("Discovered {}", uri),
|
||||||
DiscovererResult::UriInvalid => println!("Invalid uri {}", uri),
|
DiscovererResult::UriInvalid => println!("Invalid uri {}", uri),
|
||||||
|
|
Loading…
Reference in a new issue