2020-12-15 10:53:31 +00:00
|
|
|
// Take a look at the license at the top of the repository in the LICENSE file.
|
2018-10-28 12:39:27 +00:00
|
|
|
|
|
|
|
use glib::translate::*;
|
|
|
|
use std::ptr;
|
|
|
|
|
|
|
|
pub unsafe trait CodecTag<'a>: gst::Tag<'a, TagType = &'a str> {}
|
|
|
|
|
|
|
|
unsafe impl<'a> CodecTag<'a> for gst::tags::ContainerFormat {}
|
|
|
|
unsafe impl<'a> CodecTag<'a> for gst::tags::AudioCodec {}
|
|
|
|
unsafe impl<'a> CodecTag<'a> for gst::tags::VideoCodec {}
|
|
|
|
unsafe impl<'a> CodecTag<'a> for gst::tags::SubtitleCodec {}
|
|
|
|
unsafe impl<'a> CodecTag<'a> for gst::tags::Codec {}
|
|
|
|
|
|
|
|
pub fn pb_utils_add_codec_description_to_tag_list_for_tag<'a, T: CodecTag<'a>>(
|
|
|
|
taglist: &mut gst::TagListRef,
|
|
|
|
caps: &gst::CapsRef,
|
|
|
|
) -> Result<(), glib::BoolError> {
|
|
|
|
assert_initialized_main_thread!();
|
|
|
|
let codec_tag = T::tag_name();
|
|
|
|
unsafe {
|
2020-12-17 22:38:06 +00:00
|
|
|
glib::result_from_gboolean!(
|
2020-11-22 10:10:54 +00:00
|
|
|
ffi::gst_pb_utils_add_codec_description_to_tag_list(
|
2018-10-28 12:39:27 +00:00
|
|
|
taglist.as_mut_ptr(),
|
|
|
|
codec_tag.to_glib_none().0,
|
|
|
|
caps.as_ptr(),
|
|
|
|
),
|
|
|
|
"Failed to find codec description",
|
|
|
|
)
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2021-05-19 20:35:47 +00:00
|
|
|
#[doc(alias = "gst_pb_utils_add_codec_description_to_tag_list")]
|
2018-10-28 12:39:27 +00:00
|
|
|
pub fn pb_utils_add_codec_description_to_tag_list(
|
|
|
|
taglist: &mut gst::TagListRef,
|
|
|
|
caps: &gst::CapsRef,
|
|
|
|
) -> Result<(), glib::BoolError> {
|
|
|
|
assert_initialized_main_thread!();
|
|
|
|
unsafe {
|
2020-12-17 22:38:06 +00:00
|
|
|
glib::result_from_gboolean!(
|
2020-11-22 10:10:54 +00:00
|
|
|
ffi::gst_pb_utils_add_codec_description_to_tag_list(
|
2018-10-28 12:39:27 +00:00
|
|
|
taglist.as_mut_ptr(),
|
|
|
|
ptr::null_mut(),
|
|
|
|
caps.as_ptr(),
|
|
|
|
),
|
|
|
|
"Failed to find codec description",
|
|
|
|
)
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2021-05-19 20:35:47 +00:00
|
|
|
#[doc(alias = "gst_pb_utils_get_encoder_description")]
|
2019-12-17 08:20:47 +00:00
|
|
|
pub fn pb_utils_get_encoder_description(
|
|
|
|
caps: &gst::CapsRef,
|
|
|
|
) -> Result<glib::GString, glib::error::BoolError> {
|
2018-10-28 12:39:27 +00:00
|
|
|
assert_initialized_main_thread!();
|
2019-03-19 07:58:20 +00:00
|
|
|
unsafe {
|
2020-11-22 10:10:54 +00:00
|
|
|
match from_glib_full(ffi::gst_pb_utils_get_encoder_description(caps.as_ptr())) {
|
2019-12-17 08:20:47 +00:00
|
|
|
Some(s) => Ok(s),
|
2020-12-17 22:38:06 +00:00
|
|
|
None => Err(glib::bool_error!("Failed to get encoder description")),
|
2019-12-17 08:20:47 +00:00
|
|
|
}
|
2019-03-19 07:58:20 +00:00
|
|
|
}
|
2018-10-28 12:39:27 +00:00
|
|
|
}
|
|
|
|
|
2021-05-19 20:35:47 +00:00
|
|
|
#[doc(alias = "gst_pb_utils_get_decoder_description")]
|
2019-12-17 08:20:47 +00:00
|
|
|
pub fn pb_utils_get_decoder_description(
|
|
|
|
caps: &gst::CapsRef,
|
|
|
|
) -> Result<glib::GString, glib::error::BoolError> {
|
2018-10-28 12:39:27 +00:00
|
|
|
assert_initialized_main_thread!();
|
2019-03-19 07:58:20 +00:00
|
|
|
unsafe {
|
2020-11-22 10:10:54 +00:00
|
|
|
match from_glib_full(ffi::gst_pb_utils_get_decoder_description(caps.as_ptr())) {
|
2019-12-17 08:20:47 +00:00
|
|
|
Some(s) => Ok(s),
|
2020-12-17 22:38:06 +00:00
|
|
|
None => Err(glib::bool_error!("Failed to get decoder description")),
|
2019-12-17 08:20:47 +00:00
|
|
|
}
|
2019-03-19 07:58:20 +00:00
|
|
|
}
|
2018-10-28 12:39:27 +00:00
|
|
|
}
|
|
|
|
|
2021-05-19 20:35:47 +00:00
|
|
|
#[doc(alias = "gst_pb_utils_get_codec_description")]
|
2019-12-17 08:20:47 +00:00
|
|
|
pub fn pb_utils_get_codec_description(
|
|
|
|
caps: &gst::CapsRef,
|
|
|
|
) -> Result<glib::GString, glib::error::BoolError> {
|
2018-10-28 12:39:27 +00:00
|
|
|
assert_initialized_main_thread!();
|
2019-03-19 07:58:20 +00:00
|
|
|
unsafe {
|
2020-11-22 10:10:54 +00:00
|
|
|
match from_glib_full(ffi::gst_pb_utils_get_codec_description(caps.as_ptr())) {
|
2019-12-17 08:20:47 +00:00
|
|
|
Some(s) => Ok(s),
|
2020-12-17 22:38:06 +00:00
|
|
|
None => Err(glib::bool_error!("Failed to get codec description")),
|
2019-12-17 08:20:47 +00:00
|
|
|
}
|
2019-03-19 07:58:20 +00:00
|
|
|
}
|
2018-10-28 12:39:27 +00:00
|
|
|
}
|