Fix nullability handling in some functions in manual code

This commit is contained in:
Sebastian Dröge 2022-10-18 14:16:04 +03:00
parent 935609ad6c
commit f9690817ad
19 changed files with 135 additions and 135 deletions

View file

@ -200,7 +200,7 @@ mod cairo_compositor {
caps
};
q.set_result(&caps);
q.set_result(Some(&caps));
true
}

View file

@ -41,9 +41,7 @@ fn print_tags(info: &DiscovererInfo) {
fn print_stream_info(stream: &DiscovererStreamInfo) {
println!("Stream: ");
if let Some(id) = stream.stream_id() {
println!(" Stream id: {}", id);
}
println!(" Stream id: {}", stream.stream_id());
let caps_str = match stream.caps() {
Some(caps) => caps.to_string(),
None => String::from("--"),
@ -52,10 +50,7 @@ fn print_stream_info(stream: &DiscovererStreamInfo) {
}
fn print_discoverer_info(info: &DiscovererInfo) -> Result<(), Error> {
let uri = info
.uri()
.ok_or(DiscovererError("URI should not be null"))?;
println!("URI: {}", uri);
println!("URI: {}", info.uri());
println!("Duration: {}", info.duration().display());
print_tags(info);
print_stream_info(

View file

@ -107,11 +107,9 @@ fn create_receiver_pipeline(
// ownership of the passed file descriptor. The file descriptor
// will be closed when the memory is released.
let memory = unsafe {
fd_allocator.alloc(
*fd,
video_info.size(),
gst_allocators::FdMemoryFlags::NONE,
)
fd_allocator
.alloc(*fd, video_info.size(), gst_allocators::FdMemoryFlags::NONE)
.unwrap()
};
let mut buffer = gst::Buffer::new();
let buffer_mut = buffer.make_mut();

View file

@ -428,7 +428,7 @@ impl App {
msg.src().map(|s| s.downcast::<gst::Element>().unwrap())
{
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);
}
}

View file

@ -45,13 +45,18 @@ impl DmaBufMemoryRef {
impl DmaBufAllocator {
#[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!();
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,
fd.into_raw_fd(),
size,
))
.ok_or_else(|| glib::bool_error!("Failed to allocate memory"))
}
#[cfg(any(feature = "v1_16", feature = "dox"))]
@ -62,13 +67,14 @@ impl DmaBufAllocator {
fd: RawFd,
size: usize,
flags: FdMemoryFlags,
) -> gst::Memory {
) -> Result<gst::Memory, glib::BoolError> {
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,
fd,
size,
flags.into_glib(),
))
.ok_or_else(|| glib::bool_error!("Failed to allocate memory"))
}
}

View file

@ -47,13 +47,19 @@ impl FdMemoryRef {
impl FdAllocator {
#[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!();
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,
fd,
size,
flags.into_glib(),
))
.ok_or_else(|| glib::bool_error!("Failed to allocate memory"))
}
}

View file

@ -11,7 +11,7 @@ pub trait ContextGLExt {
#[doc(alias = "gst_context_get_gl_display")]
fn gl_display(&self) -> Option<GLDisplay>;
#[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 {
@ -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 {
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,
);
}
}
}

View file

@ -7,7 +7,6 @@ use crate::GLBaseMemoryAllocator;
use ffi::GstGLBaseMemory;
use gst::MemoryRef;
use gst::{result_from_gboolean, LoggableError, CAT_RUST};
gst::memory_object_wrapper!(
GLBaseMemory,
@ -51,16 +50,15 @@ impl GLBaseMemoryRef {
dest: &mut GLBaseMemory,
offset: isize,
size: isize,
) -> Result<(), LoggableError> {
) -> Result<(), glib::BoolError> {
Self::init_once();
result_from_gboolean!(
glib::result_from_gboolean!(
ffi::gst_gl_base_memory_memcpy(
mut_override(&self.0),
dest.to_glib_none_mut().0,
offset,
size,
),
CAT_RUST,
"Failed to copy memory"
)
}
@ -69,14 +67,15 @@ impl GLBaseMemoryRef {
pub fn alloc<P: IsA<GLBaseMemoryAllocator>>(
allocator: &P,
params: &GLAllocationParams,
) -> Option<GLBaseMemory> {
) -> Result<GLBaseMemory, glib::BoolError> {
skip_assert_initialized!();
Self::init_once();
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,
mut_override(params.to_glib_none().0),
))
.ok_or_else(|| glib::bool_error!("Failed to allocate memory"))
}
}

View file

@ -48,42 +48,21 @@ pub fn pb_utils_add_codec_description_to_tag_list(
}
#[doc(alias = "gst_pb_utils_get_encoder_description")]
pub fn pb_utils_get_encoder_description(
caps: &gst::CapsRef,
) -> Result<glib::GString, glib::error::BoolError> {
pub fn pb_utils_get_encoder_description(caps: &gst::CapsRef) -> glib::GString {
assert_initialized_main_thread!();
unsafe {
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")),
}
}
unsafe { from_glib_full(ffi::gst_pb_utils_get_encoder_description(caps.as_ptr())) }
}
#[doc(alias = "gst_pb_utils_get_decoder_description")]
pub fn pb_utils_get_decoder_description(
caps: &gst::CapsRef,
) -> Result<glib::GString, glib::error::BoolError> {
pub fn pb_utils_get_decoder_description(caps: &gst::CapsRef) -> glib::GString {
assert_initialized_main_thread!();
unsafe {
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")),
}
}
unsafe { from_glib_full(ffi::gst_pb_utils_get_decoder_description(caps.as_ptr())) }
}
#[doc(alias = "gst_pb_utils_get_codec_description")]
pub fn pb_utils_get_codec_description(
caps: &gst::CapsRef,
) -> Result<glib::GString, glib::error::BoolError> {
pub fn pb_utils_get_codec_description(caps: &gst::CapsRef) -> glib::GString {
assert_initialized_main_thread!();
unsafe {
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")),
}
}
unsafe { from_glib_full(ffi::gst_pb_utils_get_codec_description(caps.as_ptr())) }
}
#[doc(alias = "gst_codec_utils_aac_caps_set_level_and_profile")]

View file

@ -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> {
fn drop(&mut self) {
unsafe {
@ -485,6 +465,30 @@ pub fn compare_seqnum(seqnum1: u16, seqnum2: u16) -> i32 {
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)]
mod tests {
use super::*;
@ -692,11 +696,11 @@ mod tests {
#[test]
fn test_calc_functions() {
let res = RTPBuffer::calc_header_len(0);
let res = super::calc_header_len(0);
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);
let res = RTPBuffer::calc_payload_len(100, 5, 4);
let res = super::calc_payload_len(100, 5, 4);
assert_eq!(res, 67);
}
}

View file

@ -22,7 +22,7 @@ impl RTSPToken {
{
let token = token.get_mut().unwrap();
let structure = token.structure_mut().unwrap();
let structure = token.structure_mut();
for &(f, v) in values {
structure.set_value(f, v.to_send_value());
@ -62,14 +62,10 @@ impl RTSPTokenRef {
}
#[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 {
let structure = ffi::gst_rtsp_token_writable_structure(self.as_mut_ptr());
if structure.is_null() {
None
} else {
Some(gst::StructureRef::from_glib_borrow_mut(structure))
}
gst::StructureRef::from_glib_borrow_mut(structure)
}
}
}

View file

@ -39,6 +39,7 @@ macro_rules! skip_assert_initialized {
#[allow(clippy::too_many_arguments)]
#[allow(clippy::match_same_arms)]
#[allow(non_snake_case)]
#[allow(clippy::needless_borrow)]
#[allow(clippy::use_self)]
#[allow(unused_imports)]
mod auto;

View file

@ -46,9 +46,8 @@ impl PluginApiExt for glib::Type {
self.into_glib(),
flags.as_mut_ptr(),
));
let flags = flags.assume_init();
if ret {
Some(from_glib(flags))
Some(from_glib(flags.assume_init()))
} else {
None
}

View file

@ -1532,14 +1532,17 @@ declare_concrete_message!(PropertyNotify, T);
impl PropertyNotify {
#[doc(alias = "gst_message_new_property_notify")]
#[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!();
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!();
PropertyNotifyBuilder::new(property_name)
PropertyNotifyBuilder::new(property_name).src(object)
}
#[doc(alias = "gst_message_parse_property_notify")]

View file

@ -939,7 +939,7 @@ impl Default for Uri<Query> {
impl Uri {
#[doc(alias = "get_uri")]
#[doc(alias = "gst_query_parse_uri")]
pub fn uri(&self) -> Option<String> {
pub fn uri(&self) -> Option<glib::GString> {
unsafe {
let mut uri = ptr::null_mut();
ffi::gst_query_parse_uri(self.as_mut_ptr(), &mut uri);
@ -950,7 +950,7 @@ impl Uri {
#[doc(alias = "get_redirection")]
#[doc(alias = "gst_query_parse_uri_redirection")]
#[doc(alias = "gst_query_parse_uri_redirection_permanent")]
pub fn redirection(&self) -> (Option<String>, bool) {
pub fn redirection(&self) -> (Option<glib::GString>, bool) {
unsafe {
let mut uri = ptr::null_mut();
ffi::gst_query_parse_uri_redirection(self.as_mut_ptr(), &mut uri);
@ -965,7 +965,7 @@ impl 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 {
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_permanent")]
pub fn set_redirection(&mut self, uri: &str, permanent: bool) {
pub fn set_redirection(&mut self, uri: Option<&str>, permanent: bool) {
unsafe {
ffi::gst_query_set_uri_redirection(self.as_mut_ptr(), uri.to_glib_none().0);
ffi::gst_query_set_uri_redirection_permanent(
@ -1453,9 +1453,13 @@ impl Caps {
}
#[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 {
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")]
pub fn set_context(&mut self, context: &crate::Context) {
pub fn set_context(&mut self, context: Option<&crate::Context>) {
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()),
);
}
}
}

View file

@ -1027,16 +1027,11 @@ pub fn tag_get_type(name: &str) -> glib::Type {
}
#[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!();
unsafe {
let ptr = ffi::gst_tag_get_nick(name.to_glib_none().0);
if ptr.is_null() {
None
} else {
Some(CStr::from_ptr(ptr).to_str().unwrap())
}
CStr::from_ptr(ptr).to_str().unwrap()
}
}
@ -1324,10 +1319,7 @@ mod tests {
tag_get_type(MyCustomTag::tag_name()),
<MyCustomTag as Tag>::TagType::static_type()
);
assert_eq!(
tag_get_nick(MyCustomTag::tag_name()),
Some(MyCustomTag::NICK)
);
assert_eq!(tag_get_nick(MyCustomTag::tag_name()), MyCustomTag::NICK);
assert_eq!(
tag_get_description(MyCustomTag::tag_name()),
Some(MyCustomTag::DESCRIPTION)

View file

@ -3,6 +3,7 @@
use std::ffi::CStr;
use std::fmt;
use std::mem;
use std::ptr;
use glib::translate::{
from_glib, from_glib_full, from_glib_none, FromGlibPtrContainer, IntoGlib, IntoGlibPtr,
@ -57,16 +58,25 @@ impl TocRef {
}
#[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 {
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")]
pub fn merge_tags(&mut self, tag_list: &TagList, mode: TagMergeMode) {
pub fn merge_tags(&mut self, tag_list: Option<&TagList>, mode: TagMergeMode) {
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")]
pub fn set_tags(&mut self, tag_list: TagList) {
pub fn set_tags(&mut self, tag_list: Option<TagList>) {
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")]
pub fn merge_tags(&mut self, tag_list: &TagList, mode: TagMergeMode) {
pub fn merge_tags(&mut self, tag_list: Option<&TagList>, mode: TagMergeMode) {
unsafe {
ffi::gst_toc_entry_merge_tags(
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(),
);
}

View file

@ -57,9 +57,7 @@ impl From<TocDe> for Toc {
let mut toc = Toc::new(toc_de.scope);
{
let toc = toc.get_mut().unwrap();
if let Some(tags) = toc_de.tags.take() {
toc.set_tags(tags);
}
toc.set_tags(toc_de.tags.take());
let entry_iter = toc_de.entries.drain(..);
for entry in entry_iter {
toc.append_entry(entry);
@ -96,9 +94,7 @@ impl From<TocEntryDe> for TocEntry {
if let Some(start_stop) = toc_entry_de.start_stop.take() {
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(tags);
}
toc_entry.set_tags(toc_entry_de.tags.take());
if let Some(loop_) = toc_entry_de.loop_.take() {
toc_entry.set_loop(loop_.0, loop_.1);
}
@ -139,7 +135,7 @@ mod tests {
tags.get_mut()
.unwrap()
.add::<Title>(&"toc", TagMergeMode::Append);
toc.set_tags(tags);
toc.set_tags(Some(tags));
let mut toc_edition = TocEntry::new(TocEntryType::Edition, "edition");
{
@ -158,7 +154,7 @@ mod tests {
tags.get_mut()
.unwrap()
.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);
@ -170,7 +166,7 @@ mod tests {
tags.get_mut()
.unwrap()
.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);
}
@ -184,7 +180,7 @@ mod tests {
tags.get_mut()
.unwrap()
.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);
}
@ -419,7 +415,7 @@ mod tests {
tags.get_mut()
.unwrap()
.add::<Title>(&"toc", TagMergeMode::Append);
toc.set_tags(tags);
toc.set_tags(Some(tags));
let mut toc_edition = TocEntry::new(TocEntryType::Edition, "edition");
{
@ -438,7 +434,7 @@ mod tests {
tags.get_mut()
.unwrap()
.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);
@ -450,7 +446,7 @@ mod tests {
tags.get_mut()
.unwrap()
.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);
}
@ -464,7 +460,7 @@ mod tests {
tags.get_mut()
.unwrap()
.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);
}

View file

@ -24,7 +24,6 @@ fn print_stream_info(info: &DiscovererStreamInfo, depth: usize) {
let caps_str = if let Some(caps) = info.caps() {
if caps.is_fixed() {
gst_pbutils::pb_utils_get_codec_description(&caps)
.unwrap_or_else(|_| glib::GString::from("unknown codec"))
} else {
glib::GString::from(caps.to_string())
}
@ -82,7 +81,7 @@ fn on_discovered(
discoverer_info: &DiscovererInfo,
error: Option<&glib::Error>,
) {
let uri = discoverer_info.uri().unwrap();
let uri = discoverer_info.uri();
match discoverer_info.result() {
DiscovererResult::Ok => println!("Discovered {}", uri),
DiscovererResult::UriInvalid => println!("Invalid uri {}", uri),