1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385
// This file was generated by gir (https://github.com/gtk-rs/gir)
// from gir-files (https://github.com/gtk-rs/gir-files)
// from gst-gir-files (https://gitlab.freedesktop.org/gstreamer/gir-files-rs.git)
// DO NOT EDIT
use crate::{ffi, DiscovererInfo};
#[cfg(feature = "v1_20")]
#[cfg_attr(docsrs, doc(cfg(feature = "v1_20")))]
use glib::signal::{connect_raw, SignalHandlerId};
use glib::{prelude::*, translate::*};
#[cfg(feature = "v1_20")]
#[cfg_attr(docsrs, doc(cfg(feature = "v1_20")))]
use std::boxed::Box as Box_;
glib::wrapper! {
/// The opaque base class object for all encoding profiles. This contains generic
/// information like name, description, format and preset.
///
/// ## Properties
///
///
/// #### `element-properties`
/// A [`gst::Structure`][crate::gst::Structure] defining the properties to be set to the element
/// the profile represents.
///
/// For example for `av1enc`:
///
/// ```text
/// element-properties,row-mt=true, end-usage=vbr
/// ```
///
/// Readable | Writeable
///
///
/// #### `restriction-caps`
/// Readable | Writeable
///
/// # Implements
///
/// [`EncodingProfileExt`][trait@crate::prelude::EncodingProfileExt], [`trait@glib::ObjectExt`]
#[doc(alias = "GstEncodingProfile")]
pub struct EncodingProfile(Object<ffi::GstEncodingProfile, ffi::GstEncodingProfileClass>);
match fn {
type_ => || ffi::gst_encoding_profile_get_type(),
}
}
impl EncodingProfile {
pub const NONE: Option<&'static EncodingProfile> = None;
/// Find the [`EncodingProfile`][crate::EncodingProfile] with the specified name and category.
/// ## `targetname`
/// The name of the target
/// ## `profilename`
/// The name of the profile, if [`None`]
/// provided, it will default to the encoding profile called `default`.
/// ## `category`
/// The target category. Can be [`None`]
///
/// # Returns
///
/// The matching [`EncodingProfile`][crate::EncodingProfile] or [`None`].
#[doc(alias = "gst_encoding_profile_find")]
pub fn find(
targetname: &str,
profilename: Option<&str>,
category: Option<&str>,
) -> Option<EncodingProfile> {
assert_initialized_main_thread!();
unsafe {
from_glib_full(ffi::gst_encoding_profile_find(
targetname.to_glib_none().0,
profilename.to_glib_none().0,
category.to_glib_none().0,
))
}
}
/// Creates a [`EncodingProfile`][crate::EncodingProfile] matching the formats from the given
/// [`DiscovererInfo`][crate::DiscovererInfo]. Streams other than audio or video (eg,
/// subtitles), are currently ignored.
/// ## `info`
/// The [`DiscovererInfo`][crate::DiscovererInfo] to read from
///
/// # Returns
///
/// The new [`EncodingProfile`][crate::EncodingProfile] or [`None`].
#[doc(alias = "gst_encoding_profile_from_discoverer")]
pub fn from_discoverer(info: &DiscovererInfo) -> Result<EncodingProfile, glib::BoolError> {
skip_assert_initialized!();
unsafe {
Option::<_>::from_glib_full(ffi::gst_encoding_profile_from_discoverer(
info.to_glib_none().0,
))
.ok_or_else(|| {
glib::bool_error!("Failed to create EncodingProfile from DiscovererInfo")
})
}
}
/// Converts a string in the "encoding profile serialization format" into a
/// GstEncodingProfile. Refer to the encoding-profile documentation for details
/// on the format.
/// ## `string`
/// The string to convert into a GstEncodingProfile.
///
/// # Returns
///
/// A newly created GstEncodingProfile or NULL if the
/// input string is not a valid encoding profile serialization format.
#[cfg(feature = "v1_26")]
#[cfg_attr(docsrs, doc(cfg(feature = "v1_26")))]
#[doc(alias = "gst_encoding_profile_from_string")]
pub fn from_string(string: &str) -> Result<EncodingProfile, glib::BoolError> {
assert_initialized_main_thread!();
unsafe {
Option::<_>::from_glib_full(ffi::gst_encoding_profile_from_string(
string.to_glib_none().0,
))
.ok_or_else(|| glib::bool_error!("Failed to create EncodingProfile from string"))
}
}
}
#[cfg(feature = "v1_26")]
#[cfg_attr(docsrs, doc(cfg(feature = "v1_26")))]
impl std::fmt::Display for EncodingProfile {
#[inline]
fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result {
f.write_str(&EncodingProfileExt::to_str(self))
}
}
unsafe impl Send for EncodingProfile {}
unsafe impl Sync for EncodingProfile {}
mod sealed {
pub trait Sealed {}
impl<T: super::IsA<super::EncodingProfile>> Sealed for T {}
}
/// Trait containing all [`struct@EncodingProfile`] methods.
///
/// # Implementors
///
/// [`EncodingAudioProfile`][struct@crate::EncodingAudioProfile], [`EncodingContainerProfile`][struct@crate::EncodingContainerProfile], [`EncodingProfile`][struct@crate::EncodingProfile], [`EncodingVideoProfile`][struct@crate::EncodingVideoProfile]
pub trait EncodingProfileExt: IsA<EncodingProfile> + sealed::Sealed + 'static {
#[doc(alias = "gst_encoding_profile_copy")]
#[must_use]
fn copy(&self) -> EncodingProfile {
unsafe {
from_glib_full(ffi::gst_encoding_profile_copy(
self.as_ref().to_glib_none().0,
))
}
}
/// Get whether the format that has been negotiated in at some point can be renegotiated
/// later during the encoding.
#[doc(alias = "gst_encoding_profile_get_allow_dynamic_output")]
#[doc(alias = "get_allow_dynamic_output")]
fn allows_dynamic_output(&self) -> bool {
unsafe {
from_glib(ffi::gst_encoding_profile_get_allow_dynamic_output(
self.as_ref().to_glib_none().0,
))
}
}
///
/// # Returns
///
/// the description of the profile, can be [`None`].
#[doc(alias = "gst_encoding_profile_get_description")]
#[doc(alias = "get_description")]
fn description(&self) -> Option<glib::GString> {
unsafe {
from_glib_none(ffi::gst_encoding_profile_get_description(
self.as_ref().to_glib_none().0,
))
}
}
///
/// # Returns
///
/// a suitable file extension for `self`, or NULL.
#[doc(alias = "gst_encoding_profile_get_file_extension")]
#[doc(alias = "get_file_extension")]
fn file_extension(&self) -> Option<glib::GString> {
unsafe {
from_glib_none(ffi::gst_encoding_profile_get_file_extension(
self.as_ref().to_glib_none().0,
))
}
}
///
/// # Returns
///
/// (nullable): the [`gst::Caps`][crate::gst::Caps] corresponding to the media format used
/// in the profile. Unref after usage.
#[doc(alias = "gst_encoding_profile_get_format")]
#[doc(alias = "get_format")]
fn format(&self) -> gst::Caps {
unsafe {
from_glib_full(ffi::gst_encoding_profile_get_format(
self.as_ref().to_glib_none().0,
))
}
}
/// Computes the full output caps that this `self` will be able to consume.
///
/// # Returns
///
/// The full caps the given `self` can consume. Call
/// `gst_caps_unref()` when you are done with the caps.
#[doc(alias = "gst_encoding_profile_get_input_caps")]
#[doc(alias = "get_input_caps")]
fn input_caps(&self) -> gst::Caps {
unsafe {
from_glib_full(ffi::gst_encoding_profile_get_input_caps(
self.as_ref().to_glib_none().0,
))
}
}
///
/// # Returns
///
/// the name of the profile, can be [`None`].
#[doc(alias = "gst_encoding_profile_get_name")]
#[doc(alias = "get_name")]
fn name(&self) -> Option<glib::GString> {
unsafe {
from_glib_none(ffi::gst_encoding_profile_get_name(
self.as_ref().to_glib_none().0,
))
}
}
///
/// # Returns
///
/// The number of times the profile is used in its parent
/// container profile. If 0, it is not a mandatory stream.
#[doc(alias = "gst_encoding_profile_get_presence")]
#[doc(alias = "get_presence")]
fn presence(&self) -> u32 {
unsafe { ffi::gst_encoding_profile_get_presence(self.as_ref().to_glib_none().0) }
}
///
/// # Returns
///
/// the name of the [`gst::Preset`][crate::gst::Preset] to be used in the profile.
/// This is the name that has been set when saving the preset.
#[doc(alias = "gst_encoding_profile_get_preset")]
#[doc(alias = "get_preset")]
fn preset(&self) -> Option<glib::GString> {
unsafe {
from_glib_none(ffi::gst_encoding_profile_get_preset(
self.as_ref().to_glib_none().0,
))
}
}
///
/// # Returns
///
/// the name of the [`gst::Preset`][crate::gst::Preset] factory to be used in the profile.
#[doc(alias = "gst_encoding_profile_get_preset_name")]
#[doc(alias = "get_preset_name")]
fn preset_name(&self) -> Option<glib::GString> {
unsafe {
from_glib_none(ffi::gst_encoding_profile_get_preset_name(
self.as_ref().to_glib_none().0,
))
}
}
///
/// # Returns
///
/// [`true`] if the stream represented by `self` should use a single
/// segment before the encoder, [`false`] otherwise. This means that buffers will be retimestamped
/// and segments will be eat so as to appear as one segment.
#[cfg(feature = "v1_18")]
#[cfg_attr(docsrs, doc(cfg(feature = "v1_18")))]
#[doc(alias = "gst_encoding_profile_get_single_segment")]
#[doc(alias = "get_single_segment")]
fn is_single_segment(&self) -> bool {
unsafe {
from_glib(ffi::gst_encoding_profile_get_single_segment(
self.as_ref().to_glib_none().0,
))
}
}
///
/// # Returns
///
/// the human-readable name of the type of `self`.
#[doc(alias = "gst_encoding_profile_get_type_nick")]
#[doc(alias = "get_type_nick")]
fn type_nick(&self) -> glib::GString {
unsafe {
from_glib_none(ffi::gst_encoding_profile_get_type_nick(
self.as_ref().to_glib_none().0,
))
}
}
#[doc(alias = "gst_encoding_profile_is_enabled")]
fn is_enabled(&self) -> bool {
unsafe {
from_glib(ffi::gst_encoding_profile_is_enabled(
self.as_ref().to_glib_none().0,
))
}
}
#[doc(alias = "gst_encoding_profile_is_equal")]
fn is_equal(&self, b: &impl IsA<EncodingProfile>) -> bool {
unsafe {
from_glib(ffi::gst_encoding_profile_is_equal(
self.as_ref().to_glib_none().0,
b.as_ref().to_glib_none().0,
))
}
}
/// Converts a GstEncodingProfile to a string in the "Encoding Profile
/// serialization format".
///
/// # Returns
///
/// A string representation of the GstEncodingProfile.
#[cfg(feature = "v1_26")]
#[cfg_attr(docsrs, doc(cfg(feature = "v1_26")))]
#[doc(alias = "gst_encoding_profile_to_string")]
#[doc(alias = "to_string")]
fn to_str(&self) -> glib::GString {
unsafe {
from_glib_full(ffi::gst_encoding_profile_to_string(
self.as_ref().to_glib_none().0,
))
}
}
#[cfg(feature = "v1_20")]
#[cfg_attr(docsrs, doc(cfg(feature = "v1_20")))]
#[doc(alias = "element-properties")]
fn connect_element_properties_notify<F: Fn(&Self) + Send + Sync + 'static>(
&self,
f: F,
) -> SignalHandlerId {
unsafe extern "C" fn notify_element_properties_trampoline<
P: IsA<EncodingProfile>,
F: Fn(&P) + Send + Sync + 'static,
>(
this: *mut ffi::GstEncodingProfile,
_param_spec: glib::ffi::gpointer,
f: glib::ffi::gpointer,
) {
let f: &F = &*(f as *const F);
f(EncodingProfile::from_glib_borrow(this).unsafe_cast_ref())
}
unsafe {
let f: Box_<F> = Box_::new(f);
connect_raw(
self.as_ptr() as *mut _,
b"notify::element-properties\0".as_ptr() as *const _,
Some(std::mem::transmute::<*const (), unsafe extern "C" fn()>(
notify_element_properties_trampoline::<Self, F> as *const (),
)),
Box_::into_raw(f),
)
}
}
}
impl<O: IsA<EncodingProfile>> EncodingProfileExt for O {}