mirror of
https://gitlab.freedesktop.org/gstreamer/gstreamer-rs.git
synced 2024-12-22 16:16:37 +00:00
Inline various trivial functions
Part-of: <https://gitlab.freedesktop.org/gstreamer/gstreamer-rs/-/merge_requests/1177>
This commit is contained in:
parent
0fccb73eb6
commit
f235dc987d
70 changed files with 1370 additions and 7 deletions
|
@ -30,67 +30,83 @@ impl<T> fmt::Debug for AudioBuffer<T> {
|
|||
}
|
||||
|
||||
impl<T> AudioBuffer<T> {
|
||||
#[inline]
|
||||
pub fn info(&self) -> &crate::AudioInfo {
|
||||
&self.info
|
||||
}
|
||||
|
||||
#[inline]
|
||||
pub fn into_buffer(self) -> gst::Buffer {
|
||||
unsafe { ptr::read(&mem::ManuallyDrop::new(self).buffer) }
|
||||
}
|
||||
|
||||
#[inline]
|
||||
pub fn format(&self) -> crate::AudioFormat {
|
||||
self.info().format()
|
||||
}
|
||||
|
||||
#[inline]
|
||||
pub fn format_info(&self) -> crate::AudioFormatInfo {
|
||||
self.info().format_info()
|
||||
}
|
||||
|
||||
#[inline]
|
||||
pub fn channels(&self) -> u32 {
|
||||
self.info().channels()
|
||||
}
|
||||
|
||||
#[inline]
|
||||
pub fn rate(&self) -> u32 {
|
||||
self.info().rate()
|
||||
}
|
||||
|
||||
#[inline]
|
||||
pub fn layout(&self) -> crate::AudioLayout {
|
||||
self.info().layout()
|
||||
}
|
||||
|
||||
#[inline]
|
||||
pub fn width(&self) -> u32 {
|
||||
self.info().width()
|
||||
}
|
||||
|
||||
#[inline]
|
||||
pub fn depth(&self) -> u32 {
|
||||
self.info().depth()
|
||||
}
|
||||
|
||||
#[inline]
|
||||
pub fn sample_stride(&self) -> u32 {
|
||||
self.info().width() / 8
|
||||
}
|
||||
|
||||
#[inline]
|
||||
pub fn bps(&self) -> u32 {
|
||||
self.info().bps()
|
||||
}
|
||||
|
||||
#[inline]
|
||||
pub fn bpf(&self) -> u32 {
|
||||
self.info().bpf()
|
||||
}
|
||||
|
||||
#[inline]
|
||||
pub fn n_samples(&self) -> usize {
|
||||
self.audio_buffer.n_samples
|
||||
}
|
||||
|
||||
#[inline]
|
||||
pub fn n_planes(&self) -> u32 {
|
||||
self.audio_buffer.n_planes as u32
|
||||
}
|
||||
|
||||
#[inline]
|
||||
pub fn plane_size(&self) -> usize {
|
||||
(self.n_samples() * self.sample_stride() as usize * self.channels() as usize)
|
||||
/ self.n_planes() as usize
|
||||
}
|
||||
|
||||
#[inline]
|
||||
pub fn buffer(&self) -> &gst::BufferRef {
|
||||
unsafe { gst::BufferRef::from_ptr(self.audio_buffer.buffer) }
|
||||
}
|
||||
|
@ -110,6 +126,7 @@ impl<T> AudioBuffer<T> {
|
|||
}
|
||||
}
|
||||
|
||||
#[inline]
|
||||
pub fn as_audio_buffer_ref(&self) -> AudioBufferRef<&gst::BufferRef> {
|
||||
let info = self.info.clone();
|
||||
AudioBufferRef {
|
||||
|
@ -120,12 +137,14 @@ impl<T> AudioBuffer<T> {
|
|||
}
|
||||
}
|
||||
|
||||
#[inline]
|
||||
pub fn as_ptr(&self) -> *const ffi::GstAudioBuffer {
|
||||
&*self.audio_buffer
|
||||
}
|
||||
}
|
||||
|
||||
impl<T> Drop for AudioBuffer<T> {
|
||||
#[inline]
|
||||
fn drop(&mut self) {
|
||||
unsafe {
|
||||
ffi::gst_audio_buffer_unmap(&mut *self.audio_buffer);
|
||||
|
@ -134,6 +153,7 @@ impl<T> Drop for AudioBuffer<T> {
|
|||
}
|
||||
|
||||
impl AudioBuffer<Readable> {
|
||||
#[inline]
|
||||
pub fn from_buffer_readable(
|
||||
buffer: gst::Buffer,
|
||||
info: &crate::AudioInfo,
|
||||
|
@ -169,6 +189,7 @@ impl AudioBuffer<Readable> {
|
|||
}
|
||||
|
||||
impl AudioBuffer<Writable> {
|
||||
#[inline]
|
||||
pub fn from_buffer_writable(
|
||||
buffer: gst::Buffer,
|
||||
info: &crate::AudioInfo,
|
||||
|
@ -202,6 +223,7 @@ impl AudioBuffer<Writable> {
|
|||
}
|
||||
}
|
||||
|
||||
#[inline]
|
||||
pub fn buffer_mut(&mut self) -> &mut gst::BufferRef {
|
||||
unsafe { gst::BufferRef::from_mut_ptr(self.audio_buffer.buffer) }
|
||||
}
|
||||
|
@ -221,6 +243,7 @@ impl AudioBuffer<Writable> {
|
|||
}
|
||||
}
|
||||
|
||||
#[inline]
|
||||
pub fn as_mut_audio_buffer_ref(&mut self) -> AudioBufferRef<&mut gst::BufferRef> {
|
||||
let info = self.info.clone();
|
||||
AudioBufferRef {
|
||||
|
@ -231,6 +254,7 @@ impl AudioBuffer<Writable> {
|
|||
}
|
||||
}
|
||||
|
||||
#[inline]
|
||||
pub fn as_mut_ptr(&mut self) -> *mut ffi::GstAudioBuffer {
|
||||
&mut *self.audio_buffer
|
||||
}
|
||||
|
@ -245,6 +269,7 @@ enum AudioBufferPtr {
|
|||
impl ops::Deref for AudioBufferPtr {
|
||||
type Target = ffi::GstAudioBuffer;
|
||||
|
||||
#[inline]
|
||||
fn deref(&self) -> &Self::Target {
|
||||
match self {
|
||||
Self::Owned(ref b) => b,
|
||||
|
@ -254,6 +279,7 @@ impl ops::Deref for AudioBufferPtr {
|
|||
}
|
||||
|
||||
impl ops::DerefMut for AudioBufferPtr {
|
||||
#[inline]
|
||||
fn deref_mut(&mut self) -> &mut Self::Target {
|
||||
match self {
|
||||
Self::Owned(ref mut b) => &mut *b,
|
||||
|
@ -272,58 +298,72 @@ pub struct AudioBufferRef<T> {
|
|||
}
|
||||
|
||||
impl<T> AudioBufferRef<T> {
|
||||
#[inline]
|
||||
pub fn info(&self) -> &crate::AudioInfo {
|
||||
&self.info
|
||||
}
|
||||
|
||||
#[inline]
|
||||
pub fn format(&self) -> crate::AudioFormat {
|
||||
self.info().format()
|
||||
}
|
||||
|
||||
#[inline]
|
||||
pub fn format_info(&self) -> crate::AudioFormatInfo {
|
||||
self.info().format_info()
|
||||
}
|
||||
|
||||
#[inline]
|
||||
pub fn channels(&self) -> u32 {
|
||||
self.info().channels()
|
||||
}
|
||||
|
||||
#[inline]
|
||||
pub fn rate(&self) -> u32 {
|
||||
self.info().rate()
|
||||
}
|
||||
|
||||
#[inline]
|
||||
pub fn layout(&self) -> crate::AudioLayout {
|
||||
self.info().layout()
|
||||
}
|
||||
|
||||
#[inline]
|
||||
pub fn width(&self) -> u32 {
|
||||
self.info().width()
|
||||
}
|
||||
|
||||
#[inline]
|
||||
pub fn depth(&self) -> u32 {
|
||||
self.info().depth()
|
||||
}
|
||||
|
||||
#[inline]
|
||||
pub fn sample_stride(&self) -> u32 {
|
||||
self.info().width() / 8
|
||||
}
|
||||
|
||||
#[inline]
|
||||
pub fn bps(&self) -> u32 {
|
||||
self.info().bps()
|
||||
}
|
||||
|
||||
#[inline]
|
||||
pub fn bpf(&self) -> u32 {
|
||||
self.info().bpf()
|
||||
}
|
||||
|
||||
#[inline]
|
||||
pub fn n_samples(&self) -> usize {
|
||||
self.audio_buffer.n_samples
|
||||
}
|
||||
|
||||
#[inline]
|
||||
pub fn n_planes(&self) -> u32 {
|
||||
self.audio_buffer.n_planes as u32
|
||||
}
|
||||
|
||||
#[inline]
|
||||
pub fn plane_size(&self) -> usize {
|
||||
(self.n_samples() * self.sample_stride() as usize * self.channels() as usize)
|
||||
/ self.n_planes() as usize
|
||||
|
@ -348,12 +388,14 @@ impl<T> AudioBufferRef<T> {
|
|||
}
|
||||
}
|
||||
|
||||
#[inline]
|
||||
pub fn as_ptr(&self) -> *const ffi::GstAudioBuffer {
|
||||
&*self.audio_buffer
|
||||
}
|
||||
}
|
||||
|
||||
impl<'a> AudioBufferRef<&'a gst::BufferRef> {
|
||||
#[inline]
|
||||
pub unsafe fn from_glib_borrow(audio_buffer: *const ffi::GstAudioBuffer) -> Borrowed<Self> {
|
||||
assert!(!audio_buffer.is_null());
|
||||
|
||||
|
@ -370,6 +412,7 @@ impl<'a> AudioBufferRef<&'a gst::BufferRef> {
|
|||
})
|
||||
}
|
||||
|
||||
#[inline]
|
||||
pub fn from_buffer_ref_readable<'b>(
|
||||
buffer: &'a gst::BufferRef,
|
||||
info: &'b crate::AudioInfo,
|
||||
|
@ -403,12 +446,14 @@ impl<'a> AudioBufferRef<&'a gst::BufferRef> {
|
|||
}
|
||||
}
|
||||
|
||||
#[inline]
|
||||
pub fn buffer(&self) -> &gst::BufferRef {
|
||||
unsafe { gst::BufferRef::from_ptr(self.audio_buffer.buffer) }
|
||||
}
|
||||
}
|
||||
|
||||
impl<'a> AudioBufferRef<&'a mut gst::BufferRef> {
|
||||
#[inline]
|
||||
pub unsafe fn from_glib_borrow_mut(audio_buffer: *mut ffi::GstAudioBuffer) -> Borrowed<Self> {
|
||||
assert!(!audio_buffer.is_null());
|
||||
|
||||
|
@ -423,6 +468,7 @@ impl<'a> AudioBufferRef<&'a mut gst::BufferRef> {
|
|||
})
|
||||
}
|
||||
|
||||
#[inline]
|
||||
pub fn from_buffer_ref_writable<'b>(
|
||||
buffer: &'a mut gst::BufferRef,
|
||||
info: &'b crate::AudioInfo,
|
||||
|
@ -456,10 +502,12 @@ impl<'a> AudioBufferRef<&'a mut gst::BufferRef> {
|
|||
}
|
||||
}
|
||||
|
||||
#[inline]
|
||||
pub fn buffer_mut(&mut self) -> &mut gst::BufferRef {
|
||||
unsafe { gst::BufferRef::from_mut_ptr(self.audio_buffer.buffer) }
|
||||
}
|
||||
|
||||
#[inline]
|
||||
pub fn plane_data_mut(&mut self, plane: u32) -> Result<&mut [u8], glib::BoolError> {
|
||||
if plane >= self.n_planes() {
|
||||
return Err(glib::bool_error!(
|
||||
|
@ -479,6 +527,7 @@ impl<'a> AudioBufferRef<&'a mut gst::BufferRef> {
|
|||
}
|
||||
}
|
||||
|
||||
#[inline]
|
||||
pub fn as_mut_ptr(&mut self) -> *mut ffi::GstAudioBuffer {
|
||||
&mut *self.audio_buffer
|
||||
}
|
||||
|
@ -487,6 +536,7 @@ impl<'a> AudioBufferRef<&'a mut gst::BufferRef> {
|
|||
impl<'a> ops::Deref for AudioBufferRef<&'a mut gst::BufferRef> {
|
||||
type Target = AudioBufferRef<&'a gst::BufferRef>;
|
||||
|
||||
#[inline]
|
||||
fn deref(&self) -> &Self::Target {
|
||||
unsafe { &*(self as *const Self as *const Self::Target) }
|
||||
}
|
||||
|
@ -496,6 +546,7 @@ unsafe impl<T> Send for AudioBufferRef<T> {}
|
|||
unsafe impl<T> Sync for AudioBufferRef<T> {}
|
||||
|
||||
impl<T> Drop for AudioBufferRef<T> {
|
||||
#[inline]
|
||||
fn drop(&mut self) {
|
||||
unsafe {
|
||||
if self.unmap {
|
||||
|
|
|
@ -10,30 +10,35 @@ pub struct AudioConverterConfig(gst::Structure);
|
|||
impl ops::Deref for AudioConverterConfig {
|
||||
type Target = gst::StructureRef;
|
||||
|
||||
#[inline]
|
||||
fn deref(&self) -> &gst::StructureRef {
|
||||
self.0.deref()
|
||||
}
|
||||
}
|
||||
|
||||
impl ops::DerefMut for AudioConverterConfig {
|
||||
#[inline]
|
||||
fn deref_mut(&mut self) -> &mut gst::StructureRef {
|
||||
self.0.deref_mut()
|
||||
}
|
||||
}
|
||||
|
||||
impl AsRef<gst::StructureRef> for AudioConverterConfig {
|
||||
#[inline]
|
||||
fn as_ref(&self) -> &gst::StructureRef {
|
||||
self.0.as_ref()
|
||||
}
|
||||
}
|
||||
|
||||
impl AsMut<gst::StructureRef> for AudioConverterConfig {
|
||||
#[inline]
|
||||
fn as_mut(&mut self) -> &mut gst::StructureRef {
|
||||
self.0.as_mut()
|
||||
}
|
||||
}
|
||||
|
||||
impl Default for AudioConverterConfig {
|
||||
#[inline]
|
||||
fn default() -> Self {
|
||||
Self::new()
|
||||
}
|
||||
|
|
|
@ -16,6 +16,7 @@ pub enum AudioEndianness {
|
|||
|
||||
impl FromGlib<i32> for AudioEndianness {
|
||||
#[allow(unused_unsafe)]
|
||||
#[inline]
|
||||
unsafe fn from_glib(value: i32) -> Self {
|
||||
assert_initialized_main_thread!();
|
||||
|
||||
|
@ -30,6 +31,7 @@ impl FromGlib<i32> for AudioEndianness {
|
|||
impl IntoGlib for AudioEndianness {
|
||||
type GlibType = i32;
|
||||
|
||||
#[inline]
|
||||
fn into_glib(self) -> i32 {
|
||||
match self {
|
||||
Self::LittleEndian => 1234,
|
||||
|
@ -44,6 +46,7 @@ impl IntoGlib for AudioEndianness {
|
|||
pub struct AudioFormatInfo(&'static ffi::GstAudioFormatInfo);
|
||||
|
||||
impl AudioFormatInfo {
|
||||
#[inline]
|
||||
pub fn from_format(format: crate::AudioFormat) -> Self {
|
||||
assert_initialized_main_thread!();
|
||||
|
||||
|
@ -55,38 +58,47 @@ impl AudioFormatInfo {
|
|||
}
|
||||
}
|
||||
|
||||
#[inline]
|
||||
pub fn format(&self) -> crate::AudioFormat {
|
||||
unsafe { from_glib(self.0.format) }
|
||||
}
|
||||
|
||||
#[inline]
|
||||
pub fn name<'a>(&self) -> &'a str {
|
||||
unsafe { CStr::from_ptr(self.0.name).to_str().unwrap() }
|
||||
}
|
||||
|
||||
#[inline]
|
||||
pub fn description<'a>(&self) -> &'a str {
|
||||
unsafe { CStr::from_ptr(self.0.description).to_str().unwrap() }
|
||||
}
|
||||
|
||||
#[inline]
|
||||
pub fn flags(&self) -> crate::AudioFormatFlags {
|
||||
unsafe { from_glib(self.0.flags) }
|
||||
}
|
||||
|
||||
#[inline]
|
||||
pub fn endianness(&self) -> AudioEndianness {
|
||||
unsafe { from_glib(self.0.endianness) }
|
||||
}
|
||||
|
||||
#[inline]
|
||||
pub fn width(&self) -> u32 {
|
||||
self.0.width as u32
|
||||
}
|
||||
|
||||
#[inline]
|
||||
pub fn depth(&self) -> u32 {
|
||||
self.0.depth as u32
|
||||
}
|
||||
|
||||
#[inline]
|
||||
pub fn unpack_format(&self) -> crate::AudioFormat {
|
||||
unsafe { from_glib(self.0.unpack_format) }
|
||||
}
|
||||
|
||||
#[inline]
|
||||
pub fn silence<'a>(&self) -> &'a [u8] {
|
||||
&self.0.silence
|
||||
}
|
||||
|
@ -183,22 +195,27 @@ impl AudioFormatInfo {
|
|||
}
|
||||
}
|
||||
|
||||
#[inline]
|
||||
pub fn is_float(&self) -> bool {
|
||||
self.flags().contains(crate::AudioFormatFlags::FLOAT)
|
||||
}
|
||||
|
||||
#[inline]
|
||||
pub fn is_integer(&self) -> bool {
|
||||
self.flags().contains(crate::AudioFormatFlags::INTEGER)
|
||||
}
|
||||
|
||||
#[inline]
|
||||
pub fn is_signed(&self) -> bool {
|
||||
self.flags().contains(crate::AudioFormatFlags::SIGNED)
|
||||
}
|
||||
|
||||
#[inline]
|
||||
pub fn is_little_endian(&self) -> bool {
|
||||
self.endianness() == AudioEndianness::LittleEndian
|
||||
}
|
||||
|
||||
#[inline]
|
||||
pub fn is_big_endian(&self) -> bool {
|
||||
self.endianness() == AudioEndianness::BigEndian
|
||||
}
|
||||
|
@ -208,6 +225,7 @@ unsafe impl Sync for AudioFormatInfo {}
|
|||
unsafe impl Send for AudioFormatInfo {}
|
||||
|
||||
impl PartialEq for AudioFormatInfo {
|
||||
#[inline]
|
||||
fn eq(&self, other: &Self) -> bool {
|
||||
self.format() == other.format()
|
||||
}
|
||||
|
@ -216,6 +234,7 @@ impl PartialEq for AudioFormatInfo {
|
|||
impl Eq for AudioFormatInfo {}
|
||||
|
||||
impl PartialOrd for AudioFormatInfo {
|
||||
#[inline]
|
||||
fn partial_cmp(&self, other: &Self) -> Option<Ordering> {
|
||||
Some(self.cmp(other))
|
||||
}
|
||||
|
@ -305,6 +324,7 @@ impl str::FromStr for crate::AudioFormatInfo {
|
|||
}
|
||||
|
||||
impl From<crate::AudioFormat> for AudioFormatInfo {
|
||||
#[inline]
|
||||
fn from(f: crate::AudioFormat) -> Self {
|
||||
skip_assert_initialized!();
|
||||
Self::from_format(f)
|
||||
|
@ -312,6 +332,7 @@ impl From<crate::AudioFormat> for AudioFormatInfo {
|
|||
}
|
||||
|
||||
impl glib::types::StaticType for AudioFormatInfo {
|
||||
#[inline]
|
||||
fn static_type() -> glib::types::Type {
|
||||
unsafe { glib::translate::from_glib(ffi::gst_audio_format_info_get_type()) }
|
||||
}
|
||||
|
@ -385,6 +406,7 @@ unsafe impl glib::translate::TransparentPtrType for AudioFormatInfo {}
|
|||
impl<'a> glib::translate::ToGlibPtr<'a, *const ffi::GstAudioFormatInfo> for AudioFormatInfo {
|
||||
type Storage = PhantomData<&'a Self>;
|
||||
|
||||
#[inline]
|
||||
fn to_glib_none(&'a self) -> glib::translate::Stash<'a, *const ffi::GstAudioFormatInfo, Self> {
|
||||
glib::translate::Stash(self.0, PhantomData)
|
||||
}
|
||||
|
|
|
@ -139,6 +139,7 @@ impl AudioInfo {
|
|||
}
|
||||
}
|
||||
|
||||
#[inline]
|
||||
pub fn is_valid(&self) -> bool {
|
||||
!self.0.finfo.is_null() && self.0.channels > 0 && self.0.rate > 0 && self.0.bpf > 0
|
||||
}
|
||||
|
@ -220,6 +221,7 @@ impl AudioInfo {
|
|||
}
|
||||
}
|
||||
|
||||
#[inline]
|
||||
pub fn format(&self) -> crate::AudioFormat {
|
||||
if self.0.finfo.is_null() {
|
||||
return crate::AudioFormat::Unknown;
|
||||
|
@ -228,66 +230,82 @@ impl AudioInfo {
|
|||
unsafe { from_glib((*self.0.finfo).format) }
|
||||
}
|
||||
|
||||
#[inline]
|
||||
pub fn format_info(&self) -> crate::AudioFormatInfo {
|
||||
crate::AudioFormatInfo::from_format(self.format())
|
||||
}
|
||||
|
||||
#[inline]
|
||||
pub fn layout(&self) -> crate::AudioLayout {
|
||||
unsafe { from_glib(self.0.layout) }
|
||||
}
|
||||
|
||||
#[inline]
|
||||
pub fn flags(&self) -> crate::AudioFlags {
|
||||
unsafe { from_glib(self.0.flags) }
|
||||
}
|
||||
|
||||
#[inline]
|
||||
pub fn rate(&self) -> u32 {
|
||||
self.0.rate as u32
|
||||
}
|
||||
|
||||
#[inline]
|
||||
pub fn channels(&self) -> u32 {
|
||||
self.0.channels as u32
|
||||
}
|
||||
|
||||
#[inline]
|
||||
pub fn bpf(&self) -> u32 {
|
||||
self.0.bpf as u32
|
||||
}
|
||||
|
||||
#[inline]
|
||||
pub fn bps(&self) -> u32 {
|
||||
self.format_info().depth() >> 3
|
||||
}
|
||||
|
||||
#[inline]
|
||||
pub fn depth(&self) -> u32 {
|
||||
self.format_info().depth()
|
||||
}
|
||||
|
||||
#[inline]
|
||||
pub fn width(&self) -> u32 {
|
||||
self.format_info().width()
|
||||
}
|
||||
|
||||
#[inline]
|
||||
pub fn endianness(&self) -> crate::AudioEndianness {
|
||||
self.format_info().endianness()
|
||||
}
|
||||
|
||||
#[inline]
|
||||
pub fn is_big_endian(&self) -> bool {
|
||||
self.format_info().is_big_endian()
|
||||
}
|
||||
|
||||
#[inline]
|
||||
pub fn is_little_endian(&self) -> bool {
|
||||
self.format_info().is_little_endian()
|
||||
}
|
||||
|
||||
#[inline]
|
||||
pub fn is_float(&self) -> bool {
|
||||
self.format_info().is_float()
|
||||
}
|
||||
|
||||
#[inline]
|
||||
pub fn is_integer(&self) -> bool {
|
||||
self.format_info().is_integer()
|
||||
}
|
||||
|
||||
#[inline]
|
||||
pub fn is_signed(&self) -> bool {
|
||||
self.format_info().is_signed()
|
||||
}
|
||||
|
||||
#[inline]
|
||||
pub fn positions(&self) -> Option<&[crate::AudioChannelPosition]> {
|
||||
if self.0.channels > 64 || self.is_unpositioned() {
|
||||
return None;
|
||||
|
@ -296,12 +314,14 @@ impl AudioInfo {
|
|||
Some(&self.1[0..(self.0.channels as usize)])
|
||||
}
|
||||
|
||||
#[inline]
|
||||
pub fn is_unpositioned(&self) -> bool {
|
||||
self.flags().contains(crate::AudioFlags::UNPOSITIONED)
|
||||
}
|
||||
}
|
||||
|
||||
impl Clone for AudioInfo {
|
||||
#[inline]
|
||||
fn clone(&self) -> Self {
|
||||
unsafe { Self(ptr::read(&self.0), self.1) }
|
||||
}
|
||||
|
@ -309,6 +329,7 @@ impl Clone for AudioInfo {
|
|||
|
||||
impl PartialEq for AudioInfo {
|
||||
#[doc(alias = "gst_audio_info_is_equal")]
|
||||
#[inline]
|
||||
fn eq(&self, other: &Self) -> bool {
|
||||
unsafe { from_glib(ffi::gst_audio_info_is_equal(&self.0, &other.0)) }
|
||||
}
|
||||
|
@ -320,6 +341,7 @@ unsafe impl Send for AudioInfo {}
|
|||
unsafe impl Sync for AudioInfo {}
|
||||
|
||||
impl glib::types::StaticType for AudioInfo {
|
||||
#[inline]
|
||||
fn static_type() -> glib::types::Type {
|
||||
unsafe { glib::translate::from_glib(ffi::gst_audio_info_get_type()) }
|
||||
}
|
||||
|
@ -384,6 +406,7 @@ impl glib::value::ToValueOptional for AudioInfo {
|
|||
|
||||
#[doc(hidden)]
|
||||
impl glib::translate::Uninitialized for AudioInfo {
|
||||
#[inline]
|
||||
unsafe fn uninitialized() -> Self {
|
||||
mem::zeroed()
|
||||
}
|
||||
|
@ -398,6 +421,7 @@ impl glib::translate::GlibPtrDefault for AudioInfo {
|
|||
impl<'a> glib::translate::ToGlibPtr<'a, *const ffi::GstAudioInfo> for AudioInfo {
|
||||
type Storage = PhantomData<&'a Self>;
|
||||
|
||||
#[inline]
|
||||
fn to_glib_none(&'a self) -> glib::translate::Stash<'a, *const ffi::GstAudioInfo, Self> {
|
||||
glib::translate::Stash(&self.0, PhantomData)
|
||||
}
|
||||
|
|
|
@ -43,11 +43,13 @@ impl AudioClippingMeta {
|
|||
}
|
||||
|
||||
#[doc(alias = "get_start")]
|
||||
#[inline]
|
||||
pub fn start(&self) -> gst::GenericFormattedValue {
|
||||
unsafe { gst::GenericFormattedValue::new(from_glib(self.0.format), self.0.start as i64) }
|
||||
}
|
||||
|
||||
#[doc(alias = "get_end")]
|
||||
#[inline]
|
||||
pub fn end(&self) -> gst::GenericFormattedValue {
|
||||
unsafe { gst::GenericFormattedValue::new(from_glib(self.0.format), self.0.end as i64) }
|
||||
}
|
||||
|
@ -57,6 +59,7 @@ unsafe impl MetaAPI for AudioClippingMeta {
|
|||
type GstType = ffi::GstAudioClippingMeta;
|
||||
|
||||
#[doc(alias = "gst_audio_clipping_meta_api_get_type")]
|
||||
#[inline]
|
||||
fn meta_api() -> glib::Type {
|
||||
unsafe { from_glib(ffi::gst_audio_clipping_meta_api_get_type()) }
|
||||
}
|
||||
|
@ -175,16 +178,19 @@ impl AudioMeta {
|
|||
}
|
||||
|
||||
#[doc(alias = "get_info")]
|
||||
#[inline]
|
||||
pub fn info(&self) -> crate::AudioInfo {
|
||||
unsafe { from_glib_none(&self.0.info as *const _ as *mut ffi::GstAudioInfo) }
|
||||
}
|
||||
|
||||
#[doc(alias = "get_samples")]
|
||||
#[inline]
|
||||
pub fn samples(&self) -> usize {
|
||||
self.0.samples
|
||||
}
|
||||
|
||||
#[doc(alias = "get_offsets")]
|
||||
#[inline]
|
||||
pub fn offsets(&self) -> &[usize] {
|
||||
if self.0.offsets.is_null() || self.0.info.channels < 1 {
|
||||
return &[];
|
||||
|
@ -200,6 +206,7 @@ unsafe impl MetaAPI for AudioMeta {
|
|||
type GstType = ffi::GstAudioMeta;
|
||||
|
||||
#[doc(alias = "gst_audio_meta_api_get_type")]
|
||||
#[inline]
|
||||
fn meta_api() -> glib::Type {
|
||||
unsafe { from_glib(ffi::gst_audio_meta_api_get_type()) }
|
||||
}
|
||||
|
@ -252,11 +259,13 @@ impl AudioLevelMeta {
|
|||
}
|
||||
|
||||
#[doc(alias = "get_level")]
|
||||
#[inline]
|
||||
pub fn level(&self) -> u8 {
|
||||
self.0.level
|
||||
}
|
||||
|
||||
#[doc(alias = "get_voice_activity")]
|
||||
#[inline]
|
||||
pub fn voice_activity(&self) -> bool {
|
||||
unsafe { from_glib(self.0.voice_activity) }
|
||||
}
|
||||
|
@ -268,6 +277,7 @@ unsafe impl MetaAPI for AudioLevelMeta {
|
|||
type GstType = ffi::GstAudioLevelMeta;
|
||||
|
||||
#[doc(alias = "gst_audio_level_meta_api_get_type")]
|
||||
#[inline]
|
||||
fn meta_api() -> glib::Type {
|
||||
unsafe { from_glib(ffi::gst_audio_level_meta_api_get_type()) }
|
||||
}
|
||||
|
|
|
@ -12,71 +12,86 @@ pub struct AudioRingBufferSpec(pub(crate) GstAudioRingBufferSpec);
|
|||
|
||||
impl AudioRingBufferSpec {
|
||||
#[doc(alias = "get_type")]
|
||||
#[inline]
|
||||
pub fn type_(&self) -> AudioRingBufferFormatType {
|
||||
unsafe { AudioRingBufferFormatType::from_glib(self.0.type_) }
|
||||
}
|
||||
|
||||
#[inline]
|
||||
pub fn set_type(&mut self, value: AudioRingBufferFormatType) {
|
||||
self.0.type_ = value.into_glib();
|
||||
}
|
||||
|
||||
#[doc(alias = "get_caps")]
|
||||
#[inline]
|
||||
pub fn caps(&self) -> Caps {
|
||||
unsafe { Caps::from_glib_none(self.0.caps) }
|
||||
}
|
||||
|
||||
#[doc(alias = "get_audio_info")]
|
||||
#[inline]
|
||||
pub fn audio_info(&self) -> AudioInfo {
|
||||
unsafe { AudioInfo::from_glib_none(mut_override(&self.0.info)) }
|
||||
}
|
||||
|
||||
#[doc(alias = "get_latency_time")]
|
||||
#[inline]
|
||||
pub fn latency_time(&self) -> u64 {
|
||||
self.0.latency_time
|
||||
}
|
||||
|
||||
#[inline]
|
||||
pub fn set_latency_time(&mut self, value: u64) {
|
||||
self.0.latency_time = value;
|
||||
}
|
||||
|
||||
#[doc(alias = "get_buffer_time")]
|
||||
#[inline]
|
||||
pub fn buffer_time(&self) -> u64 {
|
||||
self.0.buffer_time
|
||||
}
|
||||
|
||||
#[inline]
|
||||
pub fn set_buffer_time(&mut self, value: u64) {
|
||||
self.0.buffer_time = value;
|
||||
}
|
||||
|
||||
#[doc(alias = "get_segsize")]
|
||||
#[inline]
|
||||
pub fn segsize(&self) -> i32 {
|
||||
self.0.segsize
|
||||
}
|
||||
|
||||
#[inline]
|
||||
pub fn set_segsize(&mut self, value: i32) {
|
||||
self.0.segsize = value;
|
||||
}
|
||||
|
||||
#[doc(alias = "get_segtotal")]
|
||||
#[inline]
|
||||
pub fn segtotal(&self) -> i32 {
|
||||
self.0.segtotal
|
||||
}
|
||||
|
||||
#[inline]
|
||||
pub fn set_segtotal(&mut self, value: i32) {
|
||||
self.0.segtotal = value;
|
||||
}
|
||||
|
||||
#[doc(alias = "get_seglatency")]
|
||||
#[inline]
|
||||
pub fn seglatency(&self) -> i32 {
|
||||
self.0.seglatency
|
||||
}
|
||||
|
||||
#[inline]
|
||||
pub fn set_seglatency(&mut self, value: i32) {
|
||||
self.0.seglatency = value;
|
||||
}
|
||||
}
|
||||
|
||||
impl Clone for AudioRingBufferSpec {
|
||||
#[inline]
|
||||
fn clone(&self) -> Self {
|
||||
unsafe {
|
||||
let spec = self.0;
|
||||
|
@ -88,6 +103,7 @@ impl Clone for AudioRingBufferSpec {
|
|||
}
|
||||
|
||||
impl Drop for AudioRingBufferSpec {
|
||||
#[inline]
|
||||
fn drop(&mut self) {
|
||||
unsafe {
|
||||
gst::ffi::gst_mini_object_unref(self.0.caps as *mut gst::ffi::GstMiniObject);
|
||||
|
|
|
@ -10,6 +10,7 @@ impl<'a> MutexGuard<'a> {
|
|||
#[allow(clippy::trivially_copy_pass_by_ref)]
|
||||
#[allow(dead_code)]
|
||||
#[doc(alias = "g_mutex_lock")]
|
||||
#[inline]
|
||||
pub fn lock(mutex: &'a glib::ffi::GMutex) -> Self {
|
||||
skip_assert_initialized!();
|
||||
unsafe {
|
||||
|
@ -20,6 +21,7 @@ impl<'a> MutexGuard<'a> {
|
|||
}
|
||||
|
||||
impl<'a> Drop for MutexGuard<'a> {
|
||||
#[inline]
|
||||
fn drop(&mut self) {
|
||||
unsafe {
|
||||
glib::ffi::g_mutex_unlock(mut_override(self.0));
|
||||
|
|
|
@ -423,6 +423,7 @@ impl UniqueAdapter {
|
|||
pub struct UniqueAdapterMap<'a>(&'a UniqueAdapter, &'a [u8]);
|
||||
|
||||
impl<'a> Drop for UniqueAdapterMap<'a> {
|
||||
#[inline]
|
||||
fn drop(&mut self) {
|
||||
unsafe {
|
||||
ffi::gst_adapter_unmap((self.0).0.to_glib_none().0);
|
||||
|
@ -433,24 +434,28 @@ impl<'a> Drop for UniqueAdapterMap<'a> {
|
|||
impl<'a> ops::Deref for UniqueAdapterMap<'a> {
|
||||
type Target = [u8];
|
||||
|
||||
#[inline]
|
||||
fn deref(&self) -> &[u8] {
|
||||
self.1
|
||||
}
|
||||
}
|
||||
|
||||
impl<'a> AsRef<[u8]> for UniqueAdapterMap<'a> {
|
||||
#[inline]
|
||||
fn as_ref(&self) -> &[u8] {
|
||||
self.1
|
||||
}
|
||||
}
|
||||
|
||||
impl Default for UniqueAdapter {
|
||||
#[inline]
|
||||
fn default() -> Self {
|
||||
Self::new()
|
||||
}
|
||||
}
|
||||
|
||||
impl io::Read for UniqueAdapter {
|
||||
#[inline]
|
||||
fn read(&mut self, buf: &mut [u8]) -> Result<usize, io::Error> {
|
||||
self.0.read(buf)
|
||||
}
|
||||
|
|
|
@ -25,6 +25,7 @@ pub enum Overhead {
|
|||
impl IntoGlib for Overhead {
|
||||
type GlibType = i32;
|
||||
|
||||
#[inline]
|
||||
fn into_glib(self) -> i32 {
|
||||
match self {
|
||||
Self::None => 0,
|
||||
|
@ -51,6 +52,7 @@ impl FromGlib<i32> for Overhead {
|
|||
impl<'a> ::glib::translate::ToGlibPtr<'a, *mut ffi::GstBaseParseFrame> for BaseParseFrame<'a> {
|
||||
type Storage = PhantomData<&'a Self>;
|
||||
|
||||
#[inline]
|
||||
fn to_glib_none(&'a self) -> ::glib::translate::Stash<*mut ffi::GstBaseParseFrame, Self> {
|
||||
Stash(self.0.as_ptr(), PhantomData)
|
||||
}
|
||||
|
@ -75,6 +77,7 @@ impl<'a> fmt::Debug for BaseParseFrame<'a> {
|
|||
}
|
||||
|
||||
impl<'a> BaseParseFrame<'a> {
|
||||
#[inline]
|
||||
pub(crate) unsafe fn new(frame: *mut ffi::GstBaseParseFrame, _parse: &'a BaseParse) -> Self {
|
||||
skip_assert_initialized!();
|
||||
assert!(!frame.is_null());
|
||||
|
@ -82,6 +85,7 @@ impl<'a> BaseParseFrame<'a> {
|
|||
}
|
||||
|
||||
#[doc(alias = "get_buffer")]
|
||||
#[inline]
|
||||
pub fn buffer(&self) -> Option<&gst::BufferRef> {
|
||||
unsafe {
|
||||
let ptr = (*self.to_glib_none().0).buffer;
|
||||
|
@ -111,6 +115,7 @@ impl<'a> BaseParseFrame<'a> {
|
|||
}
|
||||
|
||||
#[doc(alias = "get_output_buffer")]
|
||||
#[inline]
|
||||
pub fn output_buffer(&self) -> Option<&gst::BufferRef> {
|
||||
unsafe {
|
||||
let ptr = (*self.to_glib_none().0).out_buffer;
|
||||
|
@ -158,29 +163,35 @@ impl<'a> BaseParseFrame<'a> {
|
|||
}
|
||||
|
||||
#[doc(alias = "get_flags")]
|
||||
#[inline]
|
||||
pub fn flags(&self) -> BaseParseFrameFlags {
|
||||
let flags = unsafe { (*self.to_glib_none().0).flags };
|
||||
BaseParseFrameFlags::from_bits_truncate(flags)
|
||||
}
|
||||
|
||||
#[inline]
|
||||
pub fn set_flags(&mut self, flags: BaseParseFrameFlags) {
|
||||
unsafe { (*self.to_glib_none().0).flags |= flags.bits() }
|
||||
}
|
||||
|
||||
#[inline]
|
||||
pub fn unset_flags(&mut self, flags: BaseParseFrameFlags) {
|
||||
unsafe { (*self.to_glib_none().0).flags &= !flags.bits() }
|
||||
}
|
||||
|
||||
#[doc(alias = "get_offset")]
|
||||
#[inline]
|
||||
pub fn offset(&self) -> u64 {
|
||||
unsafe { (*self.to_glib_none().0).offset }
|
||||
}
|
||||
|
||||
#[doc(alias = "get_overhead")]
|
||||
#[inline]
|
||||
pub fn overhead(&self) -> Overhead {
|
||||
unsafe { from_glib((*self.to_glib_none().0).overhead) }
|
||||
}
|
||||
|
||||
#[inline]
|
||||
pub fn set_overhead(&mut self, overhead: Overhead) {
|
||||
unsafe {
|
||||
(*self.to_glib_none().0).overhead = overhead.into_glib();
|
||||
|
|
|
@ -9,6 +9,7 @@ pub struct MutexGuard<'a>(&'a glib::ffi::GMutex);
|
|||
impl<'a> MutexGuard<'a> {
|
||||
#[allow(clippy::trivially_copy_pass_by_ref)]
|
||||
#[doc(alias = "g_mutex_lock")]
|
||||
#[inline]
|
||||
pub fn lock(mutex: &'a glib::ffi::GMutex) -> Self {
|
||||
skip_assert_initialized!();
|
||||
unsafe {
|
||||
|
@ -19,6 +20,7 @@ impl<'a> MutexGuard<'a> {
|
|||
}
|
||||
|
||||
impl<'a> Drop for MutexGuard<'a> {
|
||||
#[inline]
|
||||
fn drop(&mut self) {
|
||||
unsafe {
|
||||
glib::ffi::g_mutex_unlock(mut_override(self.0));
|
||||
|
|
|
@ -13,6 +13,7 @@ use crate::TestClock;
|
|||
pub struct Harness(ptr::NonNull<ffi::GstHarness>);
|
||||
|
||||
impl Drop for Harness {
|
||||
#[inline]
|
||||
fn drop(&mut self) {
|
||||
unsafe {
|
||||
ffi::gst_harness_teardown(self.0.as_ptr());
|
||||
|
@ -592,6 +593,7 @@ impl Harness {
|
|||
}
|
||||
}
|
||||
|
||||
#[inline]
|
||||
unsafe fn from_glib_full(ptr: *mut ffi::GstHarness) -> Harness {
|
||||
assert!(!ptr.is_null());
|
||||
|
||||
|
@ -814,6 +816,7 @@ pub struct Ref<'a>(&'a Harness);
|
|||
impl<'a> ops::Deref for Ref<'a> {
|
||||
type Target = Harness;
|
||||
|
||||
#[inline]
|
||||
fn deref(&self) -> &Harness {
|
||||
self.0
|
||||
}
|
||||
|
@ -825,12 +828,14 @@ pub struct RefMut<'a>(&'a mut Harness);
|
|||
impl<'a> ops::Deref for RefMut<'a> {
|
||||
type Target = Harness;
|
||||
|
||||
#[inline]
|
||||
fn deref(&self) -> &Harness {
|
||||
self.0
|
||||
}
|
||||
}
|
||||
|
||||
impl<'a> ops::DerefMut for RefMut<'a> {
|
||||
#[inline]
|
||||
fn deref_mut(&mut self) -> &mut Harness {
|
||||
self.0
|
||||
}
|
||||
|
|
|
@ -31,12 +31,13 @@ impl GLSyncMeta {
|
|||
}
|
||||
|
||||
#[doc(alias = "get_context")]
|
||||
pub fn context(&self) -> GLContext {
|
||||
unsafe { from_glib_none(self.0.context) }
|
||||
#[inline]
|
||||
pub fn context(&self) -> &GLContext {
|
||||
unsafe { &*(&self.0.context as *const *mut ffi::GstGLContext as *const GLContext) }
|
||||
}
|
||||
|
||||
#[doc(alias = "gst_gl_sync_meta_set_sync_point")]
|
||||
pub fn set_sync_point<C: IsA<GLContext>>(&self, context: &C) {
|
||||
pub fn set_sync_point(&self, context: &impl IsA<GLContext>) {
|
||||
unsafe {
|
||||
ffi::gst_gl_sync_meta_set_sync_point(
|
||||
&self.0 as *const _ as *mut _,
|
||||
|
@ -46,7 +47,7 @@ impl GLSyncMeta {
|
|||
}
|
||||
|
||||
#[doc(alias = "gst_gl_sync_meta_wait")]
|
||||
pub fn wait<C: IsA<GLContext>>(&self, context: &C) {
|
||||
pub fn wait(&self, context: &impl IsA<GLContext>) {
|
||||
unsafe {
|
||||
ffi::gst_gl_sync_meta_wait(
|
||||
&self.0 as *const _ as *mut _,
|
||||
|
@ -56,7 +57,7 @@ impl GLSyncMeta {
|
|||
}
|
||||
|
||||
#[doc(alias = "gst_gl_sync_meta_wait_cpu")]
|
||||
pub fn wait_cpu<C: IsA<GLContext>>(&self, context: &C) {
|
||||
pub fn wait_cpu(&self, context: &impl IsA<GLContext>) {
|
||||
unsafe {
|
||||
ffi::gst_gl_sync_meta_wait_cpu(
|
||||
&self.0 as *const _ as *mut _,
|
||||
|
@ -70,6 +71,7 @@ unsafe impl MetaAPI for GLSyncMeta {
|
|||
type GstType = ffi::GstGLSyncMeta;
|
||||
|
||||
#[doc(alias = "gst_gl_sync_meta_api_get_type")]
|
||||
#[inline]
|
||||
fn meta_api() -> glib::Type {
|
||||
unsafe { from_glib(ffi::gst_gl_sync_meta_api_get_type()) }
|
||||
}
|
||||
|
|
|
@ -29,10 +29,12 @@ impl NetAddressMeta {
|
|||
}
|
||||
|
||||
#[doc(alias = "get_addr")]
|
||||
#[inline]
|
||||
pub fn addr(&self) -> gio::SocketAddress {
|
||||
unsafe { from_glib_none(self.0.addr) }
|
||||
}
|
||||
|
||||
#[inline]
|
||||
pub fn set_addr(&mut self, addr: impl IsA<gio::SocketAddress>) {
|
||||
#![allow(clippy::cast_ptr_alignment)]
|
||||
unsafe {
|
||||
|
@ -46,6 +48,7 @@ unsafe impl MetaAPI for NetAddressMeta {
|
|||
type GstType = ffi::GstNetAddressMeta;
|
||||
|
||||
#[doc(alias = "gst_net_address_meta_api_get_type")]
|
||||
#[inline]
|
||||
fn meta_api() -> glib::Type {
|
||||
unsafe { from_glib(ffi::gst_net_address_meta_api_get_type()) }
|
||||
}
|
||||
|
|
|
@ -41,12 +41,14 @@ impl Default for ElementProperties {
|
|||
impl Deref for ElementProperties {
|
||||
type Target = gst::StructureRef;
|
||||
|
||||
#[inline]
|
||||
fn deref(&self) -> &Self::Target {
|
||||
self.0.as_ref()
|
||||
}
|
||||
}
|
||||
|
||||
impl From<ElementProperties> for gst::Structure {
|
||||
#[inline]
|
||||
fn from(e: ElementProperties) -> Self {
|
||||
skip_assert_initialized!();
|
||||
|
||||
|
@ -122,6 +124,7 @@ impl ElementProperties {
|
|||
)
|
||||
}
|
||||
|
||||
#[inline]
|
||||
pub fn into_inner(self) -> gst::Structure {
|
||||
self.0
|
||||
}
|
||||
|
@ -197,18 +200,21 @@ pub struct ElementPropertiesMapItem(gst::Structure);
|
|||
impl Deref for ElementPropertiesMapItem {
|
||||
type Target = gst::StructureRef;
|
||||
|
||||
#[inline]
|
||||
fn deref(&self) -> &Self::Target {
|
||||
self.0.as_ref()
|
||||
}
|
||||
}
|
||||
|
||||
impl DerefMut for ElementPropertiesMapItem {
|
||||
#[inline]
|
||||
fn deref_mut(&mut self) -> &mut Self::Target {
|
||||
self.0.deref_mut()
|
||||
}
|
||||
}
|
||||
|
||||
impl From<ElementPropertiesMapItem> for gst::Structure {
|
||||
#[inline]
|
||||
fn from(e: ElementPropertiesMapItem) -> Self {
|
||||
skip_assert_initialized!();
|
||||
|
||||
|
@ -225,6 +231,7 @@ impl ElementPropertiesMapItem {
|
|||
}
|
||||
}
|
||||
|
||||
#[inline]
|
||||
pub fn into_inner(self) -> gst::Structure {
|
||||
self.0
|
||||
}
|
||||
|
|
|
@ -10,24 +10,28 @@ pub struct PlayConfig(gst::Structure);
|
|||
impl ops::Deref for PlayConfig {
|
||||
type Target = gst::StructureRef;
|
||||
|
||||
#[inline]
|
||||
fn deref(&self) -> &gst::StructureRef {
|
||||
self.0.deref()
|
||||
}
|
||||
}
|
||||
|
||||
impl ops::DerefMut for PlayConfig {
|
||||
#[inline]
|
||||
fn deref_mut(&mut self) -> &mut gst::StructureRef {
|
||||
self.0.deref_mut()
|
||||
}
|
||||
}
|
||||
|
||||
impl AsRef<gst::StructureRef> for PlayConfig {
|
||||
#[inline]
|
||||
fn as_ref(&self) -> &gst::StructureRef {
|
||||
self.0.as_ref()
|
||||
}
|
||||
}
|
||||
|
||||
impl AsMut<gst::StructureRef> for PlayConfig {
|
||||
#[inline]
|
||||
fn as_mut(&mut self) -> &mut gst::StructureRef {
|
||||
self.0.as_mut()
|
||||
}
|
||||
|
@ -89,6 +93,7 @@ impl PlayConfig {
|
|||
}
|
||||
|
||||
impl IntoGlibPtr<*mut gst::ffi::GstStructure> for PlayConfig {
|
||||
#[inline]
|
||||
unsafe fn into_glib_ptr(self) -> *mut gst::ffi::GstStructure {
|
||||
let mut s = mem::ManuallyDrop::new(self);
|
||||
s.0.to_glib_none_mut().0
|
||||
|
@ -96,6 +101,7 @@ impl IntoGlibPtr<*mut gst::ffi::GstStructure> for PlayConfig {
|
|||
}
|
||||
|
||||
impl FromGlibPtrFull<*mut gst::ffi::GstStructure> for PlayConfig {
|
||||
#[inline]
|
||||
unsafe fn from_glib_full(ptr: *mut gst::ffi::GstStructure) -> Self {
|
||||
PlayConfig(from_glib_full(ptr))
|
||||
}
|
||||
|
|
|
@ -10,24 +10,28 @@ pub struct PlayerConfig(gst::Structure);
|
|||
impl ops::Deref for PlayerConfig {
|
||||
type Target = gst::StructureRef;
|
||||
|
||||
#[inline]
|
||||
fn deref(&self) -> &gst::StructureRef {
|
||||
self.0.deref()
|
||||
}
|
||||
}
|
||||
|
||||
impl ops::DerefMut for PlayerConfig {
|
||||
#[inline]
|
||||
fn deref_mut(&mut self) -> &mut gst::StructureRef {
|
||||
self.0.deref_mut()
|
||||
}
|
||||
}
|
||||
|
||||
impl AsRef<gst::StructureRef> for PlayerConfig {
|
||||
#[inline]
|
||||
fn as_ref(&self) -> &gst::StructureRef {
|
||||
self.0.as_ref()
|
||||
}
|
||||
}
|
||||
|
||||
impl AsMut<gst::StructureRef> for PlayerConfig {
|
||||
#[inline]
|
||||
fn as_mut(&mut self) -> &mut gst::StructureRef {
|
||||
self.0.as_mut()
|
||||
}
|
||||
|
@ -93,6 +97,7 @@ impl PlayerConfig {
|
|||
}
|
||||
|
||||
impl IntoGlibPtr<*mut gst::ffi::GstStructure> for PlayerConfig {
|
||||
#[inline]
|
||||
unsafe fn into_glib_ptr(self) -> *mut gst::ffi::GstStructure {
|
||||
let mut s = mem::ManuallyDrop::new(self);
|
||||
s.0.to_glib_none_mut().0
|
||||
|
@ -100,6 +105,7 @@ impl IntoGlibPtr<*mut gst::ffi::GstStructure> for PlayerConfig {
|
|||
}
|
||||
|
||||
impl FromGlibPtrFull<*mut gst::ffi::GstStructure> for PlayerConfig {
|
||||
#[inline]
|
||||
unsafe fn from_glib_full(ptr: *mut gst::ffi::GstStructure) -> Self {
|
||||
PlayerConfig(from_glib_full(ptr))
|
||||
}
|
||||
|
|
|
@ -24,6 +24,7 @@ impl<'a, T> fmt::Debug for RTPBuffer<'a, T> {
|
|||
}
|
||||
|
||||
impl<'a> RTPBuffer<'a, Readable> {
|
||||
#[inline]
|
||||
pub fn from_buffer_readable(
|
||||
buffer: &'a gst::BufferRef,
|
||||
) -> Result<RTPBuffer<Readable>, glib::BoolError> {
|
||||
|
@ -47,6 +48,7 @@ impl<'a> RTPBuffer<'a, Readable> {
|
|||
}
|
||||
}
|
||||
|
||||
#[inline]
|
||||
pub unsafe fn from_glib_borrow<'b>(
|
||||
rtp_buffer: *mut ffi::GstRTPBuffer,
|
||||
) -> glib::translate::Borrowed<RTPBuffer<'b, Readable>> {
|
||||
|
@ -58,6 +60,7 @@ impl<'a> RTPBuffer<'a, Readable> {
|
|||
}
|
||||
|
||||
impl<'a> RTPBuffer<'a, Writable> {
|
||||
#[inline]
|
||||
pub fn from_buffer_writable(
|
||||
buffer: &'a mut gst::BufferRef,
|
||||
) -> Result<RTPBuffer<Writable>, glib::BoolError> {
|
||||
|
@ -311,6 +314,7 @@ impl<'a, T> RTPBuffer<'a, T> {
|
|||
}
|
||||
}
|
||||
|
||||
#[inline]
|
||||
pub fn buffer(&self) -> &gst::BufferRef {
|
||||
unsafe {
|
||||
let ptr = self.rtp_buffer.buffer;
|
||||
|
@ -412,16 +416,19 @@ impl<'a, T> RTPBuffer<'a, T> {
|
|||
}
|
||||
}
|
||||
|
||||
#[inline]
|
||||
pub fn as_ptr(&self) -> *const ffi::GstRTPBuffer {
|
||||
&self.rtp_buffer as *const ffi::GstRTPBuffer
|
||||
}
|
||||
|
||||
#[inline]
|
||||
pub fn as_mut_ptr(&self) -> *mut ffi::GstRTPBuffer {
|
||||
&self.rtp_buffer as *const ffi::GstRTPBuffer as *mut ffi::GstRTPBuffer
|
||||
}
|
||||
}
|
||||
|
||||
impl<'a, T> Drop for RTPBuffer<'a, T> {
|
||||
#[inline]
|
||||
fn drop(&mut self) {
|
||||
unsafe {
|
||||
ffi::gst_rtp_buffer_unmap(&mut self.rtp_buffer);
|
||||
|
|
|
@ -9,6 +9,7 @@ use glib::translate::*;
|
|||
pub struct RTSPContext(ptr::NonNull<ffi::GstRTSPContext>);
|
||||
|
||||
impl RTSPContext {
|
||||
#[inline]
|
||||
pub fn with_current_context<F: FnOnce(&RTSPContext) -> T, T>(func: F) -> Option<T> {
|
||||
unsafe {
|
||||
let ptr = ffi::gst_rtsp_context_get_current();
|
||||
|
@ -37,6 +38,7 @@ impl FromGlibPtrBorrow<*mut ffi::GstRTSPContext> for RTSPContext {
|
|||
impl<'a> ToGlibPtr<'a, *mut ffi::GstRTSPContext> for RTSPContext {
|
||||
type Storage = PhantomData<&'a RTSPContext>;
|
||||
|
||||
#[inline]
|
||||
fn to_glib_none(&'a self) -> Stash<'a, *mut ffi::GstRTSPContext, Self> {
|
||||
Stash(self.0.as_ptr(), PhantomData)
|
||||
}
|
||||
|
|
|
@ -469,6 +469,7 @@ impl std::hash::Hash for StreamConsumer {
|
|||
}
|
||||
|
||||
impl std::borrow::Borrow<gst_app::AppSrc> for StreamConsumer {
|
||||
#[inline]
|
||||
fn borrow(&self) -> &gst_app::AppSrc {
|
||||
&self.appsrc
|
||||
}
|
||||
|
|
|
@ -17,6 +17,7 @@ impl<'a> MutexGuard<'a> {
|
|||
#[allow(clippy::trivially_copy_pass_by_ref)]
|
||||
#[allow(dead_code)]
|
||||
#[doc(alias = "g_mutex_lock")]
|
||||
#[inline]
|
||||
pub fn lock(mutex: &'a glib::ffi::GMutex) -> Self {
|
||||
skip_assert_initialized!();
|
||||
unsafe {
|
||||
|
@ -27,6 +28,7 @@ impl<'a> MutexGuard<'a> {
|
|||
}
|
||||
|
||||
impl<'a> Drop for MutexGuard<'a> {
|
||||
#[inline]
|
||||
fn drop(&mut self) {
|
||||
unsafe {
|
||||
glib::ffi::g_mutex_unlock(mut_override(self.0));
|
||||
|
|
|
@ -34,22 +34,27 @@ pub struct VideoAlignment(pub(crate) ffi::GstVideoAlignment);
|
|||
|
||||
impl VideoAlignment {
|
||||
#[doc(alias = "get_padding_top")]
|
||||
#[inline]
|
||||
pub fn padding_top(&self) -> u32 {
|
||||
self.0.padding_top
|
||||
}
|
||||
#[doc(alias = "get_padding_bottom")]
|
||||
#[inline]
|
||||
pub fn padding_bottom(&self) -> u32 {
|
||||
self.0.padding_bottom
|
||||
}
|
||||
#[doc(alias = "get_padding_left")]
|
||||
#[inline]
|
||||
pub fn padding_left(&self) -> u32 {
|
||||
self.0.padding_left
|
||||
}
|
||||
#[doc(alias = "get_padding_right")]
|
||||
#[inline]
|
||||
pub fn padding_right(&self) -> u32 {
|
||||
self.0.padding_right
|
||||
}
|
||||
#[doc(alias = "get_stride_align")]
|
||||
#[inline]
|
||||
pub fn stride_align(&self) -> &[u32; ffi::GST_VIDEO_MAX_PLANES as usize] {
|
||||
&self.0.stride_align
|
||||
}
|
||||
|
@ -76,6 +81,7 @@ impl VideoAlignment {
|
|||
}
|
||||
|
||||
impl PartialEq for VideoAlignment {
|
||||
#[inline]
|
||||
fn eq(&self, other: &Self) -> bool {
|
||||
self.padding_top() == other.padding_top()
|
||||
&& self.padding_bottom() == other.padding_bottom()
|
||||
|
@ -91,6 +97,7 @@ impl Eq for VideoAlignment {}
|
|||
impl<'a> ToGlibPtr<'a, *const ffi::GstVideoAlignment> for VideoAlignment {
|
||||
type Storage = PhantomData<&'a Self>;
|
||||
|
||||
#[inline]
|
||||
fn to_glib_none(&'a self) -> Stash<*const ffi::GstVideoAlignment, Self> {
|
||||
Stash(&self.0, PhantomData)
|
||||
}
|
||||
|
|
|
@ -17,10 +17,12 @@ pub struct VideoCodecFrame<'a> {
|
|||
impl<'a> ::glib::translate::ToGlibPtr<'a, *mut ffi::GstVideoCodecFrame> for VideoCodecFrame<'a> {
|
||||
type Storage = PhantomData<&'a Self>;
|
||||
|
||||
#[inline]
|
||||
fn to_glib_none(&'a self) -> ::glib::translate::Stash<'a, *mut ffi::GstVideoCodecFrame, Self> {
|
||||
Stash(self.frame, PhantomData)
|
||||
}
|
||||
|
||||
#[inline]
|
||||
fn to_glib_full(&self) -> *mut ffi::GstVideoCodecFrame {
|
||||
unsafe { ffi::gst_video_codec_frame_ref(self.frame) }
|
||||
}
|
||||
|
@ -62,39 +64,47 @@ impl<'a> VideoCodecFrame<'a> {
|
|||
}
|
||||
|
||||
#[doc(alias = "get_flags")]
|
||||
#[inline]
|
||||
pub fn flags(&self) -> VideoCodecFrameFlags {
|
||||
let flags = unsafe { (*self.to_glib_none().0).flags };
|
||||
VideoCodecFrameFlags::from_bits_truncate(flags)
|
||||
}
|
||||
|
||||
#[inline]
|
||||
pub fn set_flags(&mut self, flags: VideoCodecFrameFlags) {
|
||||
unsafe { (*self.to_glib_none().0).flags |= flags.bits() }
|
||||
}
|
||||
|
||||
#[inline]
|
||||
pub fn unset_flags(&mut self, flags: VideoCodecFrameFlags) {
|
||||
unsafe { (*self.to_glib_none().0).flags &= !flags.bits() }
|
||||
}
|
||||
|
||||
#[doc(alias = "get_system_frame_number")]
|
||||
#[inline]
|
||||
pub fn system_frame_number(&self) -> u32 {
|
||||
unsafe { (*self.to_glib_none().0).system_frame_number }
|
||||
}
|
||||
|
||||
#[doc(alias = "get_decode_frame_number")]
|
||||
#[inline]
|
||||
pub fn decode_frame_number(&self) -> u32 {
|
||||
unsafe { (*self.to_glib_none().0).decode_frame_number }
|
||||
}
|
||||
|
||||
#[doc(alias = "get_presentation_frame_number")]
|
||||
#[inline]
|
||||
pub fn presentation_frame_number(&self) -> u32 {
|
||||
unsafe { (*self.to_glib_none().0).presentation_frame_number }
|
||||
}
|
||||
|
||||
#[doc(alias = "get_dts")]
|
||||
#[inline]
|
||||
pub fn dts(&self) -> Option<gst::ClockTime> {
|
||||
unsafe { from_glib((*self.to_glib_none().0).dts) }
|
||||
}
|
||||
|
||||
#[inline]
|
||||
pub fn set_dts(&mut self, dts: impl Into<Option<gst::ClockTime>>) {
|
||||
unsafe {
|
||||
(*self.to_glib_none().0).dts = dts.into().into_glib();
|
||||
|
@ -102,10 +112,12 @@ impl<'a> VideoCodecFrame<'a> {
|
|||
}
|
||||
|
||||
#[doc(alias = "get_pts")]
|
||||
#[inline]
|
||||
pub fn pts(&self) -> Option<gst::ClockTime> {
|
||||
unsafe { from_glib((*self.to_glib_none().0).pts) }
|
||||
}
|
||||
|
||||
#[inline]
|
||||
pub fn set_pts(&mut self, pts: impl Into<Option<gst::ClockTime>>) {
|
||||
unsafe {
|
||||
(*self.to_glib_none().0).pts = pts.into().into_glib();
|
||||
|
@ -113,10 +125,12 @@ impl<'a> VideoCodecFrame<'a> {
|
|||
}
|
||||
|
||||
#[doc(alias = "get_duration")]
|
||||
#[inline]
|
||||
pub fn duration(&self) -> Option<gst::ClockTime> {
|
||||
unsafe { from_glib((*self.to_glib_none().0).duration) }
|
||||
}
|
||||
|
||||
#[inline]
|
||||
pub fn set_duration(&mut self, duration: impl Into<Option<gst::ClockTime>>) {
|
||||
unsafe {
|
||||
(*self.to_glib_none().0).duration = duration.into().into_glib();
|
||||
|
@ -124,11 +138,13 @@ impl<'a> VideoCodecFrame<'a> {
|
|||
}
|
||||
|
||||
#[doc(alias = "get_distance_from_sync")]
|
||||
#[inline]
|
||||
pub fn distance_from_sync(&self) -> i32 {
|
||||
unsafe { (*self.to_glib_none().0).distance_from_sync }
|
||||
}
|
||||
|
||||
#[doc(alias = "get_input_buffer")]
|
||||
#[inline]
|
||||
pub fn input_buffer(&self) -> Option<&gst::BufferRef> {
|
||||
unsafe {
|
||||
let ptr = (*self.to_glib_none().0).input_buffer;
|
||||
|
@ -141,6 +157,7 @@ impl<'a> VideoCodecFrame<'a> {
|
|||
}
|
||||
|
||||
#[doc(alias = "get_input_buffer")]
|
||||
#[inline]
|
||||
pub fn input_buffer_owned(&self) -> Option<gst::Buffer> {
|
||||
unsafe {
|
||||
let ptr = (*self.to_glib_none().0).input_buffer;
|
||||
|
@ -153,6 +170,7 @@ impl<'a> VideoCodecFrame<'a> {
|
|||
}
|
||||
|
||||
#[doc(alias = "get_output_buffer")]
|
||||
#[inline]
|
||||
pub fn output_buffer(&self) -> Option<&gst::BufferRef> {
|
||||
unsafe {
|
||||
let ptr = (*self.to_glib_none().0).output_buffer;
|
||||
|
@ -200,6 +218,7 @@ impl<'a> VideoCodecFrame<'a> {
|
|||
}
|
||||
|
||||
#[doc(alias = "get_deadline")]
|
||||
#[inline]
|
||||
pub fn deadline(&self) -> Option<gst::ClockTime> {
|
||||
unsafe { from_glib((*self.to_glib_none().0).deadline) }
|
||||
}
|
||||
|
@ -207,6 +226,7 @@ impl<'a> VideoCodecFrame<'a> {
|
|||
#[cfg(any(feature = "v1_20", feature = "dox"))]
|
||||
#[cfg_attr(feature = "dox", doc(cfg(feature = "v1_20")))]
|
||||
#[doc(alias = "gst_video_decoder_get_processed_subframe_index")]
|
||||
#[inline]
|
||||
pub fn subframes_processed(&self) -> u32 {
|
||||
unsafe { (*self.to_glib_none().0).abidata.ABI.subframes_processed }
|
||||
}
|
||||
|
@ -214,12 +234,14 @@ impl<'a> VideoCodecFrame<'a> {
|
|||
#[cfg(any(feature = "v1_20", feature = "dox"))]
|
||||
#[cfg_attr(feature = "dox", doc(cfg(feature = "v1_20")))]
|
||||
#[doc(alias = "gst_video_decoder_get_input_subframe_index")]
|
||||
#[inline]
|
||||
pub fn num_subframes(&self) -> u32 {
|
||||
unsafe { (*self.to_glib_none().0).abidata.ABI.num_subframes }
|
||||
}
|
||||
}
|
||||
|
||||
impl<'a> IntoGlibPtr<*mut ffi::GstVideoCodecFrame> for VideoCodecFrame<'a> {
|
||||
#[inline]
|
||||
unsafe fn into_glib_ptr(self) -> *mut ffi::GstVideoCodecFrame {
|
||||
let stream_lock = self.element.stream_lock();
|
||||
glib::ffi::g_rec_mutex_unlock(stream_lock);
|
||||
|
@ -230,6 +252,7 @@ impl<'a> IntoGlibPtr<*mut ffi::GstVideoCodecFrame> for VideoCodecFrame<'a> {
|
|||
}
|
||||
|
||||
impl<'a> Drop for VideoCodecFrame<'a> {
|
||||
#[inline]
|
||||
fn drop(&mut self) {
|
||||
unsafe {
|
||||
let stream_lock = self.element.stream_lock();
|
||||
|
|
|
@ -21,20 +21,24 @@ pub struct InNegotiation<'a> {
|
|||
pub struct Readable {}
|
||||
|
||||
impl<'a> VideoCodecStateContext<'a> for InNegotiation<'a> {
|
||||
#[inline]
|
||||
fn element(&self) -> Option<&'a dyn HasStreamLock> {
|
||||
Some(self.element)
|
||||
}
|
||||
|
||||
#[inline]
|
||||
fn element_as_ptr(&self) -> *const gst::ffi::GstElement {
|
||||
self.element.element_as_ptr()
|
||||
}
|
||||
}
|
||||
|
||||
impl<'a> VideoCodecStateContext<'a> for Readable {
|
||||
#[inline]
|
||||
fn element(&self) -> Option<&'a dyn HasStreamLock> {
|
||||
None
|
||||
}
|
||||
|
||||
#[inline]
|
||||
fn element_as_ptr(&self) -> *const gst::ffi::GstElement {
|
||||
ptr::null()
|
||||
}
|
||||
|
@ -59,6 +63,7 @@ impl<'a, T: VideoCodecStateContext<'a>> fmt::Debug for VideoCodecState<'a, T> {
|
|||
|
||||
impl<'a> VideoCodecState<'a, Readable> {
|
||||
// Take ownership of @state
|
||||
#[inline]
|
||||
pub(crate) unsafe fn new(state: *mut ffi::GstVideoCodecState) -> Self {
|
||||
skip_assert_initialized!();
|
||||
Self {
|
||||
|
@ -71,6 +76,7 @@ impl<'a> VideoCodecState<'a, Readable> {
|
|||
|
||||
impl<'a> VideoCodecState<'a, InNegotiation<'a>> {
|
||||
// Take ownership of @state
|
||||
#[inline]
|
||||
pub(crate) unsafe fn new<T: HasStreamLock>(
|
||||
state: *mut ffi::GstVideoCodecState,
|
||||
element: &'a T,
|
||||
|
@ -88,6 +94,7 @@ impl<'a> VideoCodecState<'a, InNegotiation<'a>> {
|
|||
|
||||
impl<'a, T: VideoCodecStateContext<'a>> VideoCodecState<'a, T> {
|
||||
#[doc(alias = "get_info")]
|
||||
#[inline]
|
||||
pub fn info(&self) -> VideoInfo {
|
||||
unsafe {
|
||||
let ptr = &((*self.as_mut_ptr()).info) as *const _ as usize as *mut _;
|
||||
|
@ -96,6 +103,7 @@ impl<'a, T: VideoCodecStateContext<'a>> VideoCodecState<'a, T> {
|
|||
}
|
||||
|
||||
#[doc(alias = "get_caps")]
|
||||
#[inline]
|
||||
pub fn caps(&self) -> Option<&gst::CapsRef> {
|
||||
unsafe {
|
||||
let ptr = (*self.as_mut_ptr()).caps;
|
||||
|
@ -108,7 +116,14 @@ impl<'a, T: VideoCodecStateContext<'a>> VideoCodecState<'a, T> {
|
|||
}
|
||||
}
|
||||
|
||||
#[doc(alias = "get_caps")]
|
||||
#[inline]
|
||||
pub fn caps_owned(&self) -> Option<gst::Caps> {
|
||||
unsafe { from_glib_none((*self.as_mut_ptr()).caps) }
|
||||
}
|
||||
|
||||
#[doc(alias = "get_codec_data")]
|
||||
#[inline]
|
||||
pub fn codec_data(&self) -> Option<&gst::BufferRef> {
|
||||
unsafe {
|
||||
let ptr = (*self.as_mut_ptr()).codec_data;
|
||||
|
@ -121,7 +136,14 @@ impl<'a, T: VideoCodecStateContext<'a>> VideoCodecState<'a, T> {
|
|||
}
|
||||
}
|
||||
|
||||
#[doc(alias = "get_codec_data")]
|
||||
#[inline]
|
||||
pub fn codec_data_owned(&self) -> Option<gst::Buffer> {
|
||||
unsafe { from_glib_none((*self.as_mut_ptr()).codec_data) }
|
||||
}
|
||||
|
||||
#[doc(alias = "get_allocation_caps")]
|
||||
#[inline]
|
||||
pub fn allocation_caps(&self) -> Option<&gst::CapsRef> {
|
||||
unsafe {
|
||||
let ptr = (*self.as_mut_ptr()).allocation_caps;
|
||||
|
@ -133,13 +155,22 @@ impl<'a, T: VideoCodecStateContext<'a>> VideoCodecState<'a, T> {
|
|||
}
|
||||
}
|
||||
}
|
||||
|
||||
#[doc(alias = "get_allocation_caps")]
|
||||
#[inline]
|
||||
pub fn allocation_caps_owned(&self) -> Option<gst::Caps> {
|
||||
unsafe { from_glib_none((*self.as_mut_ptr()).allocation_caps) }
|
||||
}
|
||||
|
||||
#[doc(hidden)]
|
||||
#[inline]
|
||||
pub fn as_mut_ptr(&self) -> *mut ffi::GstVideoCodecState {
|
||||
self.state
|
||||
}
|
||||
}
|
||||
|
||||
impl<'a, T: VideoCodecStateContext<'a>> Drop for VideoCodecState<'a, T> {
|
||||
#[inline]
|
||||
fn drop(&mut self) {
|
||||
unsafe {
|
||||
if let Some(element) = self.context.element() {
|
||||
|
@ -152,12 +183,14 @@ impl<'a, T: VideoCodecStateContext<'a>> Drop for VideoCodecState<'a, T> {
|
|||
}
|
||||
|
||||
impl<'a> VideoCodecState<'a, InNegotiation<'a>> {
|
||||
#[inline]
|
||||
pub fn set_info(&mut self, info: VideoInfo) {
|
||||
unsafe {
|
||||
ptr::write(&mut (*self.as_mut_ptr()).info, *(info.to_glib_none().0));
|
||||
}
|
||||
}
|
||||
|
||||
#[inline]
|
||||
pub fn set_caps(&mut self, caps: &gst::Caps) {
|
||||
unsafe {
|
||||
let prev = (*self.as_mut_ptr()).caps;
|
||||
|
@ -173,6 +206,7 @@ impl<'a> VideoCodecState<'a, InNegotiation<'a>> {
|
|||
}
|
||||
}
|
||||
|
||||
#[inline]
|
||||
pub fn set_codec_data(&mut self, codec_data: &gst::Buffer) {
|
||||
unsafe {
|
||||
let prev = (*self.as_mut_ptr()).codec_data;
|
||||
|
@ -188,6 +222,7 @@ impl<'a> VideoCodecState<'a, InNegotiation<'a>> {
|
|||
}
|
||||
}
|
||||
|
||||
#[inline]
|
||||
pub fn set_allocation_caps(&mut self, allocation_caps: &gst::Caps) {
|
||||
unsafe {
|
||||
let prev = (*self.as_mut_ptr()).allocation_caps;
|
||||
|
@ -205,6 +240,7 @@ impl<'a> VideoCodecState<'a, InNegotiation<'a>> {
|
|||
}
|
||||
|
||||
impl<'a> Clone for VideoCodecState<'a, Readable> {
|
||||
#[inline]
|
||||
fn clone(&self) -> Self {
|
||||
unsafe {
|
||||
let state = ffi::gst_video_codec_state_ref(self.state);
|
||||
|
|
|
@ -9,6 +9,7 @@ use glib::translate::*;
|
|||
pub struct VideoConverter(ptr::NonNull<ffi::GstVideoConverter>);
|
||||
|
||||
impl Drop for VideoConverter {
|
||||
#[inline]
|
||||
fn drop(&mut self) {
|
||||
unsafe {
|
||||
ffi::gst_video_converter_free(self.0.as_ptr());
|
||||
|
@ -115,24 +116,28 @@ pub struct VideoConverterConfig(gst::Structure);
|
|||
impl ops::Deref for VideoConverterConfig {
|
||||
type Target = gst::StructureRef;
|
||||
|
||||
#[inline]
|
||||
fn deref(&self) -> &gst::StructureRef {
|
||||
self.0.deref()
|
||||
}
|
||||
}
|
||||
|
||||
impl ops::DerefMut for VideoConverterConfig {
|
||||
#[inline]
|
||||
fn deref_mut(&mut self) -> &mut gst::StructureRef {
|
||||
self.0.deref_mut()
|
||||
}
|
||||
}
|
||||
|
||||
impl AsRef<gst::StructureRef> for VideoConverterConfig {
|
||||
#[inline]
|
||||
fn as_ref(&self) -> &gst::StructureRef {
|
||||
self.0.as_ref()
|
||||
}
|
||||
}
|
||||
|
||||
impl AsMut<gst::StructureRef> for VideoConverterConfig {
|
||||
#[inline]
|
||||
fn as_mut(&mut self) -> &mut gst::StructureRef {
|
||||
self.0.as_mut()
|
||||
}
|
||||
|
|
|
@ -217,6 +217,7 @@ pub enum VideoEndianness {
|
|||
}
|
||||
|
||||
impl FromGlib<i32> for VideoEndianness {
|
||||
#[inline]
|
||||
unsafe fn from_glib(value: i32) -> Self {
|
||||
skip_assert_initialized!();
|
||||
|
||||
|
@ -231,6 +232,7 @@ impl FromGlib<i32> for VideoEndianness {
|
|||
impl IntoGlib for VideoEndianness {
|
||||
type GlibType = i32;
|
||||
|
||||
#[inline]
|
||||
fn into_glib(self) -> i32 {
|
||||
match self {
|
||||
Self::LittleEndian => 1234,
|
||||
|
|
|
@ -9,12 +9,14 @@ use glib::translate::{from_glib, IntoGlib, ToGlibPtr};
|
|||
pub struct VideoFormatInfo(&'static ffi::GstVideoFormatInfo);
|
||||
|
||||
impl VideoFormatInfo {
|
||||
#[inline]
|
||||
pub unsafe fn from_ptr(format_info: *const ffi::GstVideoFormatInfo) -> Self {
|
||||
assert_initialized_main_thread!();
|
||||
assert!(!format_info.is_null());
|
||||
Self(&*format_info)
|
||||
}
|
||||
|
||||
#[inline]
|
||||
pub fn from_format(format: crate::VideoFormat) -> Self {
|
||||
assert_initialized_main_thread!();
|
||||
|
||||
|
@ -26,126 +28,156 @@ impl VideoFormatInfo {
|
|||
}
|
||||
}
|
||||
|
||||
#[inline]
|
||||
pub fn format(&self) -> crate::VideoFormat {
|
||||
unsafe { from_glib(self.0.format) }
|
||||
}
|
||||
|
||||
#[inline]
|
||||
pub fn name<'a>(&self) -> &'a str {
|
||||
unsafe { CStr::from_ptr(self.0.name).to_str().unwrap() }
|
||||
}
|
||||
|
||||
#[inline]
|
||||
pub fn description<'a>(&self) -> &'a str {
|
||||
unsafe { CStr::from_ptr(self.0.description).to_str().unwrap() }
|
||||
}
|
||||
|
||||
#[inline]
|
||||
pub fn flags(&self) -> crate::VideoFormatFlags {
|
||||
unsafe { from_glib(self.0.flags) }
|
||||
}
|
||||
|
||||
#[inline]
|
||||
pub fn bits(&self) -> u32 {
|
||||
self.0.bits
|
||||
}
|
||||
|
||||
#[inline]
|
||||
pub fn n_components(&self) -> u32 {
|
||||
self.0.n_components
|
||||
}
|
||||
|
||||
#[inline]
|
||||
pub fn shift(&self) -> &[u32] {
|
||||
&self.0.shift[0..(self.0.n_components as usize)]
|
||||
}
|
||||
|
||||
#[inline]
|
||||
pub fn depth(&self) -> &[u32] {
|
||||
&self.0.depth[0..(self.0.n_components as usize)]
|
||||
}
|
||||
|
||||
#[inline]
|
||||
pub fn pixel_stride(&self) -> &[i32] {
|
||||
&self.0.pixel_stride[0..(self.0.n_components as usize)]
|
||||
}
|
||||
|
||||
#[inline]
|
||||
pub fn n_planes(&self) -> u32 {
|
||||
self.0.n_planes
|
||||
}
|
||||
|
||||
#[inline]
|
||||
pub fn plane(&self) -> &[u32] {
|
||||
&self.0.plane[0..(self.0.n_components as usize)]
|
||||
}
|
||||
|
||||
#[inline]
|
||||
pub fn poffset(&self) -> &[u32] {
|
||||
&self.0.poffset[0..(self.0.n_components as usize)]
|
||||
}
|
||||
|
||||
#[inline]
|
||||
pub fn w_sub(&self) -> &[u32] {
|
||||
&self.0.w_sub[0..(self.0.n_components as usize)]
|
||||
}
|
||||
|
||||
#[inline]
|
||||
pub fn h_sub(&self) -> &[u32] {
|
||||
&self.0.h_sub[0..(self.0.n_components as usize)]
|
||||
}
|
||||
|
||||
#[inline]
|
||||
pub fn tile_mode(&self) -> crate::VideoTileMode {
|
||||
unsafe { from_glib(self.0.tile_mode) }
|
||||
}
|
||||
|
||||
#[cfg_attr(feature = "v1_22", deprecated = "Since 1.22")]
|
||||
#[inline]
|
||||
pub fn tile_ws(&self) -> u32 {
|
||||
self.0.tile_ws
|
||||
}
|
||||
|
||||
#[cfg_attr(feature = "v1_22", deprecated = "Since 1.22")]
|
||||
#[inline]
|
||||
pub fn tile_hs(&self) -> u32 {
|
||||
self.0.tile_hs
|
||||
}
|
||||
|
||||
#[inline]
|
||||
pub fn unpack_format(&self) -> crate::VideoFormat {
|
||||
unsafe { from_glib(self.0.unpack_format) }
|
||||
}
|
||||
|
||||
#[inline]
|
||||
pub fn pack_lines(&self) -> i32 {
|
||||
self.0.pack_lines
|
||||
}
|
||||
|
||||
#[inline]
|
||||
pub fn has_alpha(&self) -> bool {
|
||||
self.0.flags & ffi::GST_VIDEO_FORMAT_FLAG_ALPHA != 0
|
||||
}
|
||||
|
||||
#[inline]
|
||||
pub fn has_palette(&self) -> bool {
|
||||
self.0.flags & ffi::GST_VIDEO_FORMAT_FLAG_PALETTE != 0
|
||||
}
|
||||
|
||||
#[cfg(any(feature = "v1_22", feature = "dox"))]
|
||||
#[cfg_attr(feature = "dox", doc(cfg(feature = "v1_22")))]
|
||||
#[inline]
|
||||
pub fn has_subtiles(&self) -> bool {
|
||||
self.0.flags & ffi::GST_VIDEO_FORMAT_FLAG_SUBTILES != 0
|
||||
}
|
||||
|
||||
#[inline]
|
||||
pub fn is_complex(&self) -> bool {
|
||||
self.0.flags & ffi::GST_VIDEO_FORMAT_FLAG_COMPLEX != 0
|
||||
}
|
||||
|
||||
#[inline]
|
||||
pub fn is_gray(&self) -> bool {
|
||||
self.0.flags & ffi::GST_VIDEO_FORMAT_FLAG_GRAY != 0
|
||||
}
|
||||
|
||||
#[inline]
|
||||
pub fn is_le(&self) -> bool {
|
||||
self.0.flags & ffi::GST_VIDEO_FORMAT_FLAG_LE != 0
|
||||
}
|
||||
|
||||
#[inline]
|
||||
pub fn is_rgb(&self) -> bool {
|
||||
self.0.flags & ffi::GST_VIDEO_FORMAT_FLAG_RGB != 0
|
||||
}
|
||||
|
||||
#[inline]
|
||||
pub fn is_tiled(&self) -> bool {
|
||||
self.0.flags & ffi::GST_VIDEO_FORMAT_FLAG_TILED != 0
|
||||
}
|
||||
|
||||
#[inline]
|
||||
pub fn is_yuv(&self) -> bool {
|
||||
self.0.flags & ffi::GST_VIDEO_FORMAT_FLAG_YUV != 0
|
||||
}
|
||||
|
||||
#[inline]
|
||||
pub fn scale_width(&self, component: u8, width: u32) -> u32 {
|
||||
(-((-(i64::from(width))) >> self.w_sub()[component as usize])) as u32
|
||||
}
|
||||
|
||||
#[inline]
|
||||
pub fn scale_height(&self, component: u8, height: u32) -> u32 {
|
||||
(-((-(i64::from(height))) >> self.h_sub()[component as usize])) as u32
|
||||
}
|
||||
|
@ -345,6 +377,7 @@ unsafe impl Sync for VideoFormatInfo {}
|
|||
unsafe impl Send for VideoFormatInfo {}
|
||||
|
||||
impl PartialEq for VideoFormatInfo {
|
||||
#[inline]
|
||||
fn eq(&self, other: &Self) -> bool {
|
||||
self.format() == other.format()
|
||||
}
|
||||
|
@ -353,6 +386,7 @@ impl PartialEq for VideoFormatInfo {
|
|||
impl Eq for VideoFormatInfo {}
|
||||
|
||||
impl PartialOrd for VideoFormatInfo {
|
||||
#[inline]
|
||||
fn partial_cmp(&self, other: &Self) -> Option<Ordering> {
|
||||
Some(self.cmp(other))
|
||||
}
|
||||
|
@ -497,6 +531,7 @@ impl str::FromStr for crate::VideoFormatInfo {
|
|||
}
|
||||
|
||||
impl From<crate::VideoFormat> for VideoFormatInfo {
|
||||
#[inline]
|
||||
fn from(f: crate::VideoFormat) -> Self {
|
||||
skip_assert_initialized!();
|
||||
Self::from_format(f)
|
||||
|
@ -515,6 +550,7 @@ unsafe impl glib::translate::TransparentPtrType for VideoFormatInfo {}
|
|||
impl<'a> glib::translate::ToGlibPtr<'a, *const ffi::GstVideoFormatInfo> for VideoFormatInfo {
|
||||
type Storage = PhantomData<&'a Self>;
|
||||
|
||||
#[inline]
|
||||
fn to_glib_none(&'a self) -> glib::translate::Stash<'a, *const ffi::GstVideoFormatInfo, Self> {
|
||||
glib::translate::Stash(self.0, PhantomData)
|
||||
}
|
||||
|
@ -562,18 +598,22 @@ impl fmt::Debug for VideoTileInfo {
|
|||
#[cfg(any(feature = "v1_22", feature = "dox"))]
|
||||
#[cfg_attr(feature = "dox", doc(cfg(feature = "v1_22")))]
|
||||
impl VideoTileInfo {
|
||||
#[inline]
|
||||
pub fn width(&self) -> u32 {
|
||||
self.0.width
|
||||
}
|
||||
|
||||
#[inline]
|
||||
pub fn height(&self) -> u32 {
|
||||
self.0.height
|
||||
}
|
||||
|
||||
#[inline]
|
||||
pub fn stride(&self) -> u32 {
|
||||
self.0.stride
|
||||
}
|
||||
|
||||
#[inline]
|
||||
pub fn size(&self) -> u32 {
|
||||
self.0.size
|
||||
}
|
||||
|
|
|
@ -29,18 +29,22 @@ impl<T> fmt::Debug for VideoFrame<T> {
|
|||
}
|
||||
|
||||
impl<T> VideoFrame<T> {
|
||||
#[inline]
|
||||
pub fn info(&self) -> &crate::VideoInfo {
|
||||
&self.info
|
||||
}
|
||||
|
||||
#[inline]
|
||||
pub fn flags(&self) -> crate::VideoFrameFlags {
|
||||
unsafe { from_glib(self.frame.flags) }
|
||||
}
|
||||
|
||||
#[inline]
|
||||
pub fn id(&self) -> i32 {
|
||||
self.frame.id
|
||||
}
|
||||
|
||||
#[inline]
|
||||
pub fn into_buffer(self) -> gst::Buffer {
|
||||
let s = mem::ManuallyDrop::new(self);
|
||||
unsafe { ptr::read(&s.buffer) }
|
||||
|
@ -80,105 +84,130 @@ impl<T> VideoFrame<T> {
|
|||
}
|
||||
}
|
||||
|
||||
#[inline]
|
||||
pub fn format(&self) -> crate::VideoFormat {
|
||||
self.info().format()
|
||||
}
|
||||
|
||||
#[inline]
|
||||
pub fn format_info(&self) -> crate::VideoFormatInfo {
|
||||
self.info().format_info()
|
||||
}
|
||||
|
||||
#[inline]
|
||||
pub fn width(&self) -> u32 {
|
||||
self.info().width()
|
||||
}
|
||||
|
||||
#[inline]
|
||||
pub fn height(&self) -> u32 {
|
||||
self.info().height()
|
||||
}
|
||||
|
||||
#[inline]
|
||||
pub fn size(&self) -> usize {
|
||||
self.info().size()
|
||||
}
|
||||
|
||||
#[inline]
|
||||
pub fn is_interlaced(&self) -> bool {
|
||||
self.flags().contains(crate::VideoFrameFlags::INTERLACED)
|
||||
}
|
||||
|
||||
#[inline]
|
||||
pub fn is_tff(&self) -> bool {
|
||||
self.flags().contains(crate::VideoFrameFlags::TFF)
|
||||
}
|
||||
|
||||
#[inline]
|
||||
pub fn is_rff(&self) -> bool {
|
||||
self.flags().contains(crate::VideoFrameFlags::RFF)
|
||||
}
|
||||
|
||||
#[inline]
|
||||
pub fn is_onefield(&self) -> bool {
|
||||
self.flags().contains(crate::VideoFrameFlags::ONEFIELD)
|
||||
}
|
||||
|
||||
#[inline]
|
||||
pub fn is_bottom_field(&self) -> bool {
|
||||
self.flags().contains(crate::VideoFrameFlags::ONEFIELD)
|
||||
&& !self.flags().contains(crate::VideoFrameFlags::TFF)
|
||||
}
|
||||
|
||||
#[inline]
|
||||
pub fn is_top_field(&self) -> bool {
|
||||
self.flags().contains(crate::VideoFrameFlags::ONEFIELD)
|
||||
&& self.flags().contains(crate::VideoFrameFlags::TFF)
|
||||
}
|
||||
|
||||
#[inline]
|
||||
pub fn n_planes(&self) -> u32 {
|
||||
self.info().n_planes()
|
||||
}
|
||||
|
||||
#[inline]
|
||||
pub fn n_components(&self) -> u32 {
|
||||
self.info().n_components()
|
||||
}
|
||||
|
||||
#[inline]
|
||||
pub fn plane_stride(&self) -> &[i32] {
|
||||
self.info().stride()
|
||||
}
|
||||
|
||||
#[inline]
|
||||
pub fn plane_offset(&self) -> &[usize] {
|
||||
self.info().offset()
|
||||
}
|
||||
|
||||
#[inline]
|
||||
pub fn comp_data(&self, component: u32) -> Result<&[u8], glib::BoolError> {
|
||||
let poffset = self.info().comp_poffset(component as u8) as usize;
|
||||
Ok(&self.plane_data(self.format_info().plane()[component as usize])?[poffset..])
|
||||
}
|
||||
|
||||
#[inline]
|
||||
pub fn comp_depth(&self, component: u32) -> u32 {
|
||||
self.info().comp_depth(component as u8)
|
||||
}
|
||||
|
||||
#[inline]
|
||||
pub fn comp_height(&self, component: u32) -> u32 {
|
||||
self.info().comp_height(component as u8)
|
||||
}
|
||||
|
||||
#[inline]
|
||||
pub fn comp_width(&self, component: u32) -> u32 {
|
||||
self.info().comp_width(component as u8)
|
||||
}
|
||||
|
||||
#[inline]
|
||||
pub fn comp_offset(&self, component: u32) -> usize {
|
||||
self.info().comp_offset(component as u8)
|
||||
}
|
||||
|
||||
#[inline]
|
||||
pub fn comp_poffset(&self, component: u32) -> u32 {
|
||||
self.info().comp_poffset(component as u8)
|
||||
}
|
||||
|
||||
#[inline]
|
||||
pub fn comp_pstride(&self, component: u32) -> i32 {
|
||||
self.info().comp_pstride(component as u8)
|
||||
}
|
||||
|
||||
#[inline]
|
||||
pub fn comp_stride(&self, component: u32) -> i32 {
|
||||
self.info().comp_stride(component as u8)
|
||||
}
|
||||
|
||||
#[inline]
|
||||
pub fn comp_plane(&self, component: u32) -> u32 {
|
||||
self.info().comp_plane(component as u8)
|
||||
}
|
||||
|
||||
#[inline]
|
||||
pub fn buffer(&self) -> &gst::BufferRef {
|
||||
unsafe { gst::BufferRef::from_ptr(self.frame.buffer) }
|
||||
}
|
||||
|
@ -219,6 +248,7 @@ impl<T> VideoFrame<T> {
|
|||
}
|
||||
}
|
||||
|
||||
#[inline]
|
||||
pub unsafe fn from_glib_full(frame: ffi::GstVideoFrame) -> Self {
|
||||
let info = crate::VideoInfo(ptr::read(&frame.info));
|
||||
let buffer = gst::Buffer::from_glib_none(frame.buffer);
|
||||
|
@ -230,6 +260,7 @@ impl<T> VideoFrame<T> {
|
|||
}
|
||||
}
|
||||
|
||||
#[inline]
|
||||
pub fn as_video_frame_ref(&self) -> VideoFrameRef<&gst::BufferRef> {
|
||||
let frame = unsafe { ptr::read(&self.frame) };
|
||||
let info = self.info.clone();
|
||||
|
@ -241,16 +272,19 @@ impl<T> VideoFrame<T> {
|
|||
}
|
||||
}
|
||||
|
||||
#[inline]
|
||||
pub fn as_ptr(&self) -> *const ffi::GstVideoFrame {
|
||||
&self.frame
|
||||
}
|
||||
|
||||
#[inline]
|
||||
pub fn into_raw(self) -> ffi::GstVideoFrame {
|
||||
mem::ManuallyDrop::new(self).frame
|
||||
}
|
||||
}
|
||||
|
||||
impl<T> Drop for VideoFrame<T> {
|
||||
#[inline]
|
||||
fn drop(&mut self) {
|
||||
unsafe {
|
||||
ffi::gst_video_frame_unmap(&mut self.frame);
|
||||
|
@ -259,6 +293,7 @@ impl<T> Drop for VideoFrame<T> {
|
|||
}
|
||||
|
||||
impl VideoFrame<Readable> {
|
||||
#[inline]
|
||||
pub fn from_buffer_readable(
|
||||
buffer: gst::Buffer,
|
||||
info: &crate::VideoInfo,
|
||||
|
@ -291,6 +326,7 @@ impl VideoFrame<Readable> {
|
|||
}
|
||||
}
|
||||
|
||||
#[inline]
|
||||
pub fn from_buffer_id_readable(
|
||||
buffer: gst::Buffer,
|
||||
id: i32,
|
||||
|
@ -325,12 +361,14 @@ impl VideoFrame<Readable> {
|
|||
}
|
||||
}
|
||||
|
||||
#[inline]
|
||||
pub fn buffer_owned(&self) -> gst::Buffer {
|
||||
unsafe { from_glib_none(self.frame.buffer) }
|
||||
}
|
||||
}
|
||||
|
||||
impl VideoFrame<Writable> {
|
||||
#[inline]
|
||||
pub fn from_buffer_writable(
|
||||
buffer: gst::Buffer,
|
||||
info: &crate::VideoInfo,
|
||||
|
@ -365,6 +403,7 @@ impl VideoFrame<Writable> {
|
|||
}
|
||||
}
|
||||
|
||||
#[inline]
|
||||
pub fn from_buffer_id_writable(
|
||||
buffer: gst::Buffer,
|
||||
id: i32,
|
||||
|
@ -401,6 +440,7 @@ impl VideoFrame<Writable> {
|
|||
}
|
||||
}
|
||||
|
||||
#[inline]
|
||||
pub fn buffer_mut(&mut self) -> &mut gst::BufferRef {
|
||||
unsafe { gst::BufferRef::from_mut_ptr(self.frame.buffer) }
|
||||
}
|
||||
|
@ -446,6 +486,7 @@ impl VideoFrame<Writable> {
|
|||
}
|
||||
}
|
||||
|
||||
#[inline]
|
||||
pub fn as_mut_video_frame_ref(&mut self) -> VideoFrameRef<&mut gst::BufferRef> {
|
||||
let frame = unsafe { ptr::read(&self.frame) };
|
||||
let info = self.info.clone();
|
||||
|
@ -457,6 +498,7 @@ impl VideoFrame<Writable> {
|
|||
}
|
||||
}
|
||||
|
||||
#[inline]
|
||||
pub fn as_mut_ptr(&mut self) -> *mut ffi::GstVideoFrame {
|
||||
&mut self.frame
|
||||
}
|
||||
|
@ -471,14 +513,17 @@ pub struct VideoFrameRef<T> {
|
|||
}
|
||||
|
||||
impl<T> VideoFrameRef<T> {
|
||||
#[inline]
|
||||
pub fn info(&self) -> &crate::VideoInfo {
|
||||
&self.info
|
||||
}
|
||||
|
||||
#[inline]
|
||||
pub fn flags(&self) -> crate::VideoFrameFlags {
|
||||
unsafe { from_glib(self.frame.flags) }
|
||||
}
|
||||
|
||||
#[inline]
|
||||
pub fn id(&self) -> i32 {
|
||||
self.frame.id
|
||||
}
|
||||
|
@ -520,64 +565,79 @@ impl<T> VideoFrameRef<T> {
|
|||
}
|
||||
}
|
||||
|
||||
#[inline]
|
||||
pub fn format(&self) -> crate::VideoFormat {
|
||||
self.info().format()
|
||||
}
|
||||
|
||||
#[inline]
|
||||
pub fn format_info(&self) -> crate::VideoFormatInfo {
|
||||
self.info().format_info()
|
||||
}
|
||||
|
||||
#[inline]
|
||||
pub fn width(&self) -> u32 {
|
||||
self.info().width()
|
||||
}
|
||||
|
||||
#[inline]
|
||||
pub fn height(&self) -> u32 {
|
||||
self.info().height()
|
||||
}
|
||||
|
||||
#[inline]
|
||||
pub fn size(&self) -> usize {
|
||||
self.info().size()
|
||||
}
|
||||
|
||||
#[inline]
|
||||
pub fn is_interlaced(&self) -> bool {
|
||||
self.flags().contains(crate::VideoFrameFlags::INTERLACED)
|
||||
}
|
||||
|
||||
#[inline]
|
||||
pub fn is_tff(&self) -> bool {
|
||||
self.flags().contains(crate::VideoFrameFlags::TFF)
|
||||
}
|
||||
|
||||
#[inline]
|
||||
pub fn is_rff(&self) -> bool {
|
||||
self.flags().contains(crate::VideoFrameFlags::RFF)
|
||||
}
|
||||
|
||||
#[inline]
|
||||
pub fn is_onefield(&self) -> bool {
|
||||
self.flags().contains(crate::VideoFrameFlags::ONEFIELD)
|
||||
}
|
||||
|
||||
#[inline]
|
||||
pub fn is_bottom_field(&self) -> bool {
|
||||
self.flags().contains(crate::VideoFrameFlags::ONEFIELD)
|
||||
&& !self.flags().contains(crate::VideoFrameFlags::TFF)
|
||||
}
|
||||
|
||||
#[inline]
|
||||
pub fn is_top_field(&self) -> bool {
|
||||
self.flags().contains(crate::VideoFrameFlags::ONEFIELD)
|
||||
&& self.flags().contains(crate::VideoFrameFlags::TFF)
|
||||
}
|
||||
|
||||
#[inline]
|
||||
pub fn n_planes(&self) -> u32 {
|
||||
self.info().n_planes()
|
||||
}
|
||||
|
||||
#[inline]
|
||||
pub fn n_components(&self) -> u32 {
|
||||
self.info().n_components()
|
||||
}
|
||||
|
||||
#[inline]
|
||||
pub fn plane_stride(&self) -> &[i32] {
|
||||
self.info().stride()
|
||||
}
|
||||
|
||||
#[inline]
|
||||
pub fn plane_offset(&self) -> &[usize] {
|
||||
self.info().offset()
|
||||
}
|
||||
|
@ -587,34 +647,42 @@ impl<T> VideoFrameRef<T> {
|
|||
Ok(&self.plane_data(self.format_info().plane()[component as usize])?[poffset..])
|
||||
}
|
||||
|
||||
#[inline]
|
||||
pub fn comp_depth(&self, component: u32) -> u32 {
|
||||
self.info().comp_depth(component as u8)
|
||||
}
|
||||
|
||||
#[inline]
|
||||
pub fn comp_height(&self, component: u32) -> u32 {
|
||||
self.info().comp_height(component as u8)
|
||||
}
|
||||
|
||||
#[inline]
|
||||
pub fn comp_width(&self, component: u32) -> u32 {
|
||||
self.info().comp_width(component as u8)
|
||||
}
|
||||
|
||||
#[inline]
|
||||
pub fn comp_offset(&self, component: u32) -> usize {
|
||||
self.info().comp_offset(component as u8)
|
||||
}
|
||||
|
||||
#[inline]
|
||||
pub fn comp_poffset(&self, component: u32) -> u32 {
|
||||
self.info().comp_poffset(component as u8)
|
||||
}
|
||||
|
||||
#[inline]
|
||||
pub fn comp_pstride(&self, component: u32) -> i32 {
|
||||
self.info().comp_pstride(component as u8)
|
||||
}
|
||||
|
||||
#[inline]
|
||||
pub fn comp_stride(&self, component: u32) -> i32 {
|
||||
self.info().comp_stride(component as u8)
|
||||
}
|
||||
|
||||
#[inline]
|
||||
pub fn comp_plane(&self, component: u32) -> u32 {
|
||||
self.info().comp_plane(component as u8)
|
||||
}
|
||||
|
@ -655,12 +723,14 @@ impl<T> VideoFrameRef<T> {
|
|||
}
|
||||
}
|
||||
|
||||
#[inline]
|
||||
pub fn as_ptr(&self) -> *const ffi::GstVideoFrame {
|
||||
&self.frame
|
||||
}
|
||||
}
|
||||
|
||||
impl<'a> VideoFrameRef<&'a gst::BufferRef> {
|
||||
#[inline]
|
||||
pub unsafe fn from_glib_borrow(frame: *const ffi::GstVideoFrame) -> Borrowed<Self> {
|
||||
assert!(!frame.is_null());
|
||||
|
||||
|
@ -674,6 +744,7 @@ impl<'a> VideoFrameRef<&'a gst::BufferRef> {
|
|||
})
|
||||
}
|
||||
|
||||
#[inline]
|
||||
pub unsafe fn from_glib_full(frame: ffi::GstVideoFrame) -> Self {
|
||||
let info = crate::VideoInfo(ptr::read(&frame.info));
|
||||
Self {
|
||||
|
@ -684,6 +755,7 @@ impl<'a> VideoFrameRef<&'a gst::BufferRef> {
|
|||
}
|
||||
}
|
||||
|
||||
#[inline]
|
||||
pub fn from_buffer_ref_readable<'b>(
|
||||
buffer: &'a gst::BufferRef,
|
||||
info: &'b crate::VideoInfo,
|
||||
|
@ -716,6 +788,7 @@ impl<'a> VideoFrameRef<&'a gst::BufferRef> {
|
|||
}
|
||||
}
|
||||
|
||||
#[inline]
|
||||
pub fn from_buffer_ref_id_readable<'b>(
|
||||
buffer: &'a gst::BufferRef,
|
||||
id: i32,
|
||||
|
@ -750,12 +823,14 @@ impl<'a> VideoFrameRef<&'a gst::BufferRef> {
|
|||
}
|
||||
}
|
||||
|
||||
#[inline]
|
||||
pub fn buffer(&self) -> &gst::BufferRef {
|
||||
unsafe { gst::BufferRef::from_ptr(self.frame.buffer) }
|
||||
}
|
||||
}
|
||||
|
||||
impl<'a> VideoFrameRef<&'a mut gst::BufferRef> {
|
||||
#[inline]
|
||||
pub unsafe fn from_glib_borrow_mut(frame: *mut ffi::GstVideoFrame) -> Self {
|
||||
assert!(!frame.is_null());
|
||||
|
||||
|
@ -769,6 +844,7 @@ impl<'a> VideoFrameRef<&'a mut gst::BufferRef> {
|
|||
}
|
||||
}
|
||||
|
||||
#[inline]
|
||||
pub unsafe fn from_glib_full_mut(frame: ffi::GstVideoFrame) -> Self {
|
||||
let info = crate::VideoInfo(ptr::read(&frame.info));
|
||||
Self {
|
||||
|
@ -779,6 +855,7 @@ impl<'a> VideoFrameRef<&'a mut gst::BufferRef> {
|
|||
}
|
||||
}
|
||||
|
||||
#[inline]
|
||||
pub fn from_buffer_ref_writable<'b>(
|
||||
buffer: &'a mut gst::BufferRef,
|
||||
info: &'b crate::VideoInfo,
|
||||
|
@ -813,6 +890,7 @@ impl<'a> VideoFrameRef<&'a mut gst::BufferRef> {
|
|||
}
|
||||
}
|
||||
|
||||
#[inline]
|
||||
pub fn from_buffer_ref_id_writable<'b>(
|
||||
buffer: &'a mut gst::BufferRef,
|
||||
id: i32,
|
||||
|
@ -849,6 +927,7 @@ impl<'a> VideoFrameRef<&'a mut gst::BufferRef> {
|
|||
}
|
||||
}
|
||||
|
||||
#[inline]
|
||||
pub fn buffer_mut(&mut self) -> &mut gst::BufferRef {
|
||||
unsafe { gst::BufferRef::from_mut_ptr(self.frame.buffer) }
|
||||
}
|
||||
|
@ -894,6 +973,7 @@ impl<'a> VideoFrameRef<&'a mut gst::BufferRef> {
|
|||
}
|
||||
}
|
||||
|
||||
#[inline]
|
||||
pub fn as_mut_ptr(&mut self) -> *mut ffi::GstVideoFrame {
|
||||
&mut self.frame
|
||||
}
|
||||
|
@ -902,6 +982,7 @@ impl<'a> VideoFrameRef<&'a mut gst::BufferRef> {
|
|||
impl<'a> ops::Deref for VideoFrameRef<&'a mut gst::BufferRef> {
|
||||
type Target = VideoFrameRef<&'a gst::BufferRef>;
|
||||
|
||||
#[inline]
|
||||
fn deref(&self) -> &Self::Target {
|
||||
unsafe { &*(self as *const Self as *const Self::Target) }
|
||||
}
|
||||
|
@ -911,6 +992,7 @@ unsafe impl<T> Send for VideoFrameRef<T> {}
|
|||
unsafe impl<T> Sync for VideoFrameRef<T> {}
|
||||
|
||||
impl<T> Drop for VideoFrameRef<T> {
|
||||
#[inline]
|
||||
fn drop(&mut self) {
|
||||
unsafe {
|
||||
if self.unmap {
|
||||
|
@ -928,6 +1010,7 @@ pub trait VideoBufferExt {
|
|||
}
|
||||
|
||||
impl VideoBufferExt for gst::BufferRef {
|
||||
#[inline]
|
||||
fn video_flags(&self) -> crate::VideoBufferFlags {
|
||||
unsafe {
|
||||
let ptr = self.as_mut_ptr();
|
||||
|
@ -935,6 +1018,7 @@ impl VideoBufferExt for gst::BufferRef {
|
|||
}
|
||||
}
|
||||
|
||||
#[inline]
|
||||
fn set_video_flags(&mut self, flags: crate::VideoBufferFlags) {
|
||||
unsafe {
|
||||
let ptr = self.as_mut_ptr();
|
||||
|
@ -942,6 +1026,7 @@ impl VideoBufferExt for gst::BufferRef {
|
|||
}
|
||||
}
|
||||
|
||||
#[inline]
|
||||
fn unset_video_flags(&mut self, flags: crate::VideoBufferFlags) {
|
||||
unsafe {
|
||||
let ptr = self.as_mut_ptr();
|
||||
|
|
|
@ -26,6 +26,7 @@ pub enum VideoColorRange {
|
|||
impl IntoGlib for VideoColorRange {
|
||||
type GlibType = ffi::GstVideoColorRange;
|
||||
|
||||
#[inline]
|
||||
fn into_glib(self) -> ffi::GstVideoColorRange {
|
||||
match self {
|
||||
Self::Unknown => ffi::GST_VIDEO_COLOR_RANGE_UNKNOWN,
|
||||
|
@ -38,6 +39,7 @@ impl IntoGlib for VideoColorRange {
|
|||
|
||||
#[doc(hidden)]
|
||||
impl FromGlib<ffi::GstVideoColorRange> for VideoColorRange {
|
||||
#[inline]
|
||||
unsafe fn from_glib(value: ffi::GstVideoColorRange) -> Self {
|
||||
skip_assert_initialized!();
|
||||
match value {
|
||||
|
@ -50,6 +52,7 @@ impl FromGlib<ffi::GstVideoColorRange> for VideoColorRange {
|
|||
}
|
||||
|
||||
impl StaticType for VideoColorRange {
|
||||
#[inline]
|
||||
fn static_type() -> glib::Type {
|
||||
unsafe { from_glib(ffi::gst_video_color_range_get_type()) }
|
||||
}
|
||||
|
@ -110,18 +113,22 @@ impl VideoColorimetry {
|
|||
Self(colorimetry)
|
||||
}
|
||||
|
||||
#[inline]
|
||||
pub fn range(&self) -> crate::VideoColorRange {
|
||||
unsafe { from_glib(self.0.range) }
|
||||
}
|
||||
|
||||
#[inline]
|
||||
pub fn matrix(&self) -> crate::VideoColorMatrix {
|
||||
unsafe { from_glib(self.0.matrix) }
|
||||
}
|
||||
|
||||
#[inline]
|
||||
pub fn transfer(&self) -> crate::VideoTransferFunction {
|
||||
unsafe { from_glib(self.0.transfer) }
|
||||
}
|
||||
|
||||
#[inline]
|
||||
pub fn primaries(&self) -> crate::VideoColorPrimaries {
|
||||
unsafe { from_glib(self.0.primaries) }
|
||||
}
|
||||
|
@ -235,6 +242,7 @@ impl str::FromStr for crate::VideoChromaSite {
|
|||
}
|
||||
|
||||
impl From<crate::VideoMultiviewFramePacking> for crate::VideoMultiviewMode {
|
||||
#[inline]
|
||||
fn from(v: crate::VideoMultiviewFramePacking) -> Self {
|
||||
skip_assert_initialized!();
|
||||
unsafe { from_glib(v.into_glib()) }
|
||||
|
@ -549,6 +557,7 @@ impl VideoInfo {
|
|||
}
|
||||
}
|
||||
|
||||
#[inline]
|
||||
pub fn is_valid(&self) -> bool {
|
||||
!self.0.finfo.is_null() && self.0.width > 0 && self.0.height > 0 && self.0.size > 0
|
||||
}
|
||||
|
@ -581,6 +590,7 @@ impl VideoInfo {
|
|||
}
|
||||
}
|
||||
|
||||
#[inline]
|
||||
pub fn format(&self) -> crate::VideoFormat {
|
||||
if self.0.finfo.is_null() {
|
||||
return crate::VideoFormat::Unknown;
|
||||
|
@ -589,24 +599,29 @@ impl VideoInfo {
|
|||
self.format_info().format()
|
||||
}
|
||||
|
||||
#[inline]
|
||||
pub fn format_info(&self) -> crate::VideoFormatInfo {
|
||||
unsafe { crate::VideoFormatInfo::from_ptr(self.0.finfo) }
|
||||
}
|
||||
|
||||
#[inline]
|
||||
pub fn name<'a>(&self) -> &'a str {
|
||||
self.format_info().name()
|
||||
}
|
||||
|
||||
#[inline]
|
||||
pub fn width(&self) -> u32 {
|
||||
self.0.width as u32
|
||||
}
|
||||
|
||||
#[inline]
|
||||
pub fn height(&self) -> u32 {
|
||||
self.0.height as u32
|
||||
}
|
||||
|
||||
#[cfg(any(feature = "v1_16", feature = "dox"))]
|
||||
#[cfg_attr(feature = "dox", doc(cfg(feature = "v1_16")))]
|
||||
#[inline]
|
||||
pub fn field_height(&self) -> u32 {
|
||||
if self.0.interlace_mode == ffi::GST_VIDEO_INTERLACE_MODE_ALTERNATE {
|
||||
(self.0.height as u32 + 1) / 2
|
||||
|
@ -615,73 +630,90 @@ impl VideoInfo {
|
|||
}
|
||||
}
|
||||
|
||||
#[inline]
|
||||
pub fn interlace_mode(&self) -> crate::VideoInterlaceMode {
|
||||
unsafe { from_glib(self.0.interlace_mode) }
|
||||
}
|
||||
|
||||
#[inline]
|
||||
pub fn flags(&self) -> crate::VideoFlags {
|
||||
unsafe { from_glib(self.0.flags) }
|
||||
}
|
||||
|
||||
#[inline]
|
||||
pub fn size(&self) -> usize {
|
||||
self.0.size
|
||||
}
|
||||
|
||||
#[inline]
|
||||
pub fn views(&self) -> u32 {
|
||||
self.0.views as u32
|
||||
}
|
||||
|
||||
#[inline]
|
||||
pub fn chroma_site(&self) -> crate::VideoChromaSite {
|
||||
unsafe { from_glib(self.0.chroma_site) }
|
||||
}
|
||||
|
||||
#[inline]
|
||||
pub fn colorimetry(&self) -> VideoColorimetry {
|
||||
unsafe { VideoColorimetry(ptr::read(&self.0.colorimetry)) }
|
||||
}
|
||||
|
||||
#[inline]
|
||||
pub fn comp_depth(&self, component: u8) -> u32 {
|
||||
self.format_info().depth()[component as usize]
|
||||
}
|
||||
|
||||
#[inline]
|
||||
pub fn comp_height(&self, component: u8) -> u32 {
|
||||
self.format_info().scale_height(component, self.height())
|
||||
}
|
||||
|
||||
#[inline]
|
||||
pub fn comp_width(&self, component: u8) -> u32 {
|
||||
self.format_info().scale_width(component, self.width())
|
||||
}
|
||||
|
||||
#[inline]
|
||||
pub fn comp_offset(&self, component: u8) -> usize {
|
||||
self.offset()[self.format_info().plane()[component as usize] as usize]
|
||||
+ self.format_info().poffset()[component as usize] as usize
|
||||
}
|
||||
|
||||
#[inline]
|
||||
pub fn comp_plane(&self, component: u8) -> u32 {
|
||||
self.format_info().plane()[component as usize]
|
||||
}
|
||||
|
||||
#[inline]
|
||||
pub fn comp_poffset(&self, component: u8) -> u32 {
|
||||
self.format_info().poffset()[component as usize]
|
||||
}
|
||||
|
||||
#[inline]
|
||||
pub fn comp_pstride(&self, component: u8) -> i32 {
|
||||
self.format_info().pixel_stride()[component as usize]
|
||||
}
|
||||
|
||||
#[inline]
|
||||
pub fn comp_stride(&self, component: u8) -> i32 {
|
||||
self.stride()[self.format_info().plane()[component as usize] as usize]
|
||||
}
|
||||
|
||||
#[inline]
|
||||
pub fn par(&self) -> gst::Fraction {
|
||||
gst::Fraction::new(self.0.par_n, self.0.par_d)
|
||||
}
|
||||
|
||||
#[inline]
|
||||
pub fn fps(&self) -> gst::Fraction {
|
||||
gst::Fraction::new(self.0.fps_n, self.0.fps_d)
|
||||
}
|
||||
|
||||
#[cfg(any(feature = "v1_16", feature = "dox"))]
|
||||
#[cfg_attr(feature = "dox", doc(cfg(feature = "v1_16")))]
|
||||
#[inline]
|
||||
pub fn field_rate(&self) -> gst::Fraction {
|
||||
if self.interlace_mode() == crate::VideoInterlaceMode::Alternate {
|
||||
2 * self.fps()
|
||||
|
@ -690,14 +722,17 @@ impl VideoInfo {
|
|||
}
|
||||
}
|
||||
|
||||
#[inline]
|
||||
pub fn offset(&self) -> &[usize] {
|
||||
&self.0.offset[0..(self.format_info().n_planes() as usize)]
|
||||
}
|
||||
|
||||
#[inline]
|
||||
pub fn stride(&self) -> &[i32] {
|
||||
&self.0.stride[0..(self.format_info().n_planes() as usize)]
|
||||
}
|
||||
|
||||
#[inline]
|
||||
pub fn multiview_mode(&self) -> crate::VideoMultiviewMode {
|
||||
unsafe {
|
||||
let ptr = &self.0.ABI._gst_reserved as *const _ as *const i32;
|
||||
|
@ -705,6 +740,7 @@ impl VideoInfo {
|
|||
}
|
||||
}
|
||||
|
||||
#[inline]
|
||||
pub fn multiview_flags(&self) -> crate::VideoMultiviewFlags {
|
||||
unsafe {
|
||||
let ptr = &self.0.ABI._gst_reserved as *const _ as *const u32;
|
||||
|
@ -712,6 +748,7 @@ impl VideoInfo {
|
|||
}
|
||||
}
|
||||
|
||||
#[inline]
|
||||
pub fn field_order(&self) -> crate::VideoFieldOrder {
|
||||
unsafe {
|
||||
let ptr = &self.0.ABI._gst_reserved as *const _ as *const i32;
|
||||
|
@ -719,30 +756,37 @@ impl VideoInfo {
|
|||
}
|
||||
}
|
||||
|
||||
#[inline]
|
||||
pub fn has_alpha(&self) -> bool {
|
||||
self.format_info().has_alpha()
|
||||
}
|
||||
|
||||
#[inline]
|
||||
pub fn is_gray(&self) -> bool {
|
||||
self.format_info().is_gray()
|
||||
}
|
||||
|
||||
#[inline]
|
||||
pub fn is_rgb(&self) -> bool {
|
||||
self.format_info().is_rgb()
|
||||
}
|
||||
|
||||
#[inline]
|
||||
pub fn is_yuv(&self) -> bool {
|
||||
self.format_info().is_yuv()
|
||||
}
|
||||
|
||||
#[inline]
|
||||
pub fn is_interlaced(&self) -> bool {
|
||||
self.interlace_mode() != crate::VideoInterlaceMode::Progressive
|
||||
}
|
||||
|
||||
#[inline]
|
||||
pub fn n_planes(&self) -> u32 {
|
||||
self.format_info().n_planes()
|
||||
}
|
||||
|
||||
#[inline]
|
||||
pub fn n_components(&self) -> u32 {
|
||||
self.format_info().n_components()
|
||||
}
|
||||
|
@ -824,6 +868,7 @@ impl VideoInfo {
|
|||
}
|
||||
|
||||
#[doc(alias = "gst_video_color_range_offsets")]
|
||||
#[inline]
|
||||
pub fn range_offsets(&self, range: crate::VideoColorRange) -> ([i32; 4], [i32; 4]) {
|
||||
self.format_info().range_offsets(range)
|
||||
}
|
||||
|
@ -842,6 +887,7 @@ unsafe impl Send for VideoInfo {}
|
|||
unsafe impl Sync for VideoInfo {}
|
||||
|
||||
impl glib::types::StaticType for VideoInfo {
|
||||
#[inline]
|
||||
fn static_type() -> glib::types::Type {
|
||||
unsafe { glib::translate::from_glib(ffi::gst_video_info_get_type()) }
|
||||
}
|
||||
|
@ -906,6 +952,7 @@ impl From<VideoInfo> for glib::Value {
|
|||
|
||||
#[doc(hidden)]
|
||||
impl glib::translate::Uninitialized for VideoInfo {
|
||||
#[inline]
|
||||
unsafe fn uninitialized() -> Self {
|
||||
mem::zeroed()
|
||||
}
|
||||
|
@ -920,6 +967,7 @@ impl glib::translate::GlibPtrDefault for VideoInfo {
|
|||
impl<'a> glib::translate::ToGlibPtr<'a, *const ffi::GstVideoInfo> for VideoInfo {
|
||||
type Storage = PhantomData<&'a Self>;
|
||||
|
||||
#[inline]
|
||||
fn to_glib_none(&'a self) -> glib::translate::Stash<'a, *const ffi::GstVideoInfo, Self> {
|
||||
glib::translate::Stash(&self.0, PhantomData)
|
||||
}
|
||||
|
|
|
@ -112,41 +112,49 @@ impl VideoMeta {
|
|||
}
|
||||
|
||||
#[doc(alias = "get_flags")]
|
||||
#[inline]
|
||||
pub fn video_frame_flags(&self) -> crate::VideoFrameFlags {
|
||||
unsafe { from_glib(self.0.flags) }
|
||||
}
|
||||
|
||||
#[doc(alias = "get_format")]
|
||||
#[inline]
|
||||
pub fn format(&self) -> crate::VideoFormat {
|
||||
unsafe { from_glib(self.0.format) }
|
||||
}
|
||||
|
||||
#[doc(alias = "get_id")]
|
||||
#[inline]
|
||||
pub fn id(&self) -> i32 {
|
||||
self.0.id
|
||||
}
|
||||
|
||||
#[doc(alias = "get_width")]
|
||||
#[inline]
|
||||
pub fn width(&self) -> u32 {
|
||||
self.0.width
|
||||
}
|
||||
|
||||
#[doc(alias = "get_height")]
|
||||
#[inline]
|
||||
pub fn height(&self) -> u32 {
|
||||
self.0.height
|
||||
}
|
||||
|
||||
#[doc(alias = "get_n_planes")]
|
||||
#[inline]
|
||||
pub fn n_planes(&self) -> u32 {
|
||||
self.0.n_planes
|
||||
}
|
||||
|
||||
#[doc(alias = "get_offset")]
|
||||
#[inline]
|
||||
pub fn offset(&self) -> &[usize] {
|
||||
&self.0.offset[0..(self.0.n_planes as usize)]
|
||||
}
|
||||
|
||||
#[doc(alias = "get_stride")]
|
||||
#[inline]
|
||||
pub fn stride(&self) -> &[i32] {
|
||||
&self.0.stride[0..(self.0.n_planes as usize)]
|
||||
}
|
||||
|
@ -154,6 +162,7 @@ impl VideoMeta {
|
|||
#[cfg(any(feature = "v1_18", feature = "dox"))]
|
||||
#[cfg_attr(feature = "dox", doc(cfg(feature = "v1_18")))]
|
||||
#[doc(alias = "get_alignment")]
|
||||
#[inline]
|
||||
pub fn alignment(&self) -> crate::VideoAlignment {
|
||||
crate::VideoAlignment::new(
|
||||
self.0.alignment.padding_top,
|
||||
|
@ -224,6 +233,7 @@ unsafe impl MetaAPI for VideoMeta {
|
|||
type GstType = ffi::GstVideoMeta;
|
||||
|
||||
#[doc(alias = "gst_video_meta_api_get_type")]
|
||||
#[inline]
|
||||
fn meta_api() -> glib::Type {
|
||||
unsafe { from_glib(ffi::gst_video_meta_api_get_type()) }
|
||||
}
|
||||
|
@ -278,10 +288,12 @@ impl VideoCropMeta {
|
|||
}
|
||||
|
||||
#[doc(alias = "get_rect")]
|
||||
#[inline]
|
||||
pub fn rect(&self) -> (u32, u32, u32, u32) {
|
||||
(self.0.x, self.0.y, self.0.width, self.0.height)
|
||||
}
|
||||
|
||||
#[inline]
|
||||
pub fn set_rect(&mut self, rect: (u32, u32, u32, u32)) {
|
||||
self.0.x = rect.0;
|
||||
self.0.y = rect.1;
|
||||
|
@ -294,6 +306,7 @@ unsafe impl MetaAPI for VideoCropMeta {
|
|||
type GstType = ffi::GstVideoCropMeta;
|
||||
|
||||
#[doc(alias = "gst_video_crop_meta_api_get_type")]
|
||||
#[inline]
|
||||
fn meta_api() -> glib::Type {
|
||||
unsafe { from_glib(ffi::gst_video_crop_meta_api_get_type()) }
|
||||
}
|
||||
|
@ -337,21 +350,25 @@ impl VideoRegionOfInterestMeta {
|
|||
}
|
||||
|
||||
#[doc(alias = "get_rect")]
|
||||
#[inline]
|
||||
pub fn rect(&self) -> (u32, u32, u32, u32) {
|
||||
(self.0.x, self.0.y, self.0.w, self.0.h)
|
||||
}
|
||||
|
||||
#[doc(alias = "get_id")]
|
||||
#[inline]
|
||||
pub fn id(&self) -> i32 {
|
||||
self.0.id
|
||||
}
|
||||
|
||||
#[doc(alias = "get_parent_id")]
|
||||
#[inline]
|
||||
pub fn parent_id(&self) -> i32 {
|
||||
self.0.parent_id
|
||||
}
|
||||
|
||||
#[doc(alias = "get_roi_type")]
|
||||
#[inline]
|
||||
pub fn roi_type<'a>(&self) -> &'a str {
|
||||
unsafe { glib::Quark::from_glib(self.0.roi_type).as_str() }
|
||||
}
|
||||
|
@ -365,10 +382,12 @@ impl VideoRegionOfInterestMeta {
|
|||
}
|
||||
|
||||
#[doc(alias = "get_param")]
|
||||
#[inline]
|
||||
pub fn param<'b>(&self, name: &'b str) -> Option<&gst::StructureRef> {
|
||||
self.params().find(|s| s.name() == name)
|
||||
}
|
||||
|
||||
#[inline]
|
||||
pub fn set_rect(&mut self, rect: (u32, u32, u32, u32)) {
|
||||
self.0.x = rect.0;
|
||||
self.0.y = rect.1;
|
||||
|
@ -376,10 +395,12 @@ impl VideoRegionOfInterestMeta {
|
|||
self.0.h = rect.3;
|
||||
}
|
||||
|
||||
#[inline]
|
||||
pub fn set_id(&mut self, id: i32) {
|
||||
self.0.id = id
|
||||
}
|
||||
|
||||
#[inline]
|
||||
pub fn set_parent_id(&mut self, id: i32) {
|
||||
self.0.parent_id = id
|
||||
}
|
||||
|
@ -421,6 +442,7 @@ unsafe impl MetaAPI for VideoRegionOfInterestMeta {
|
|||
type GstType = ffi::GstVideoRegionOfInterestMeta;
|
||||
|
||||
#[doc(alias = "gst_video_region_of_interest_meta_api_get_type")]
|
||||
#[inline]
|
||||
fn meta_api() -> glib::Type {
|
||||
unsafe { from_glib(ffi::gst_video_region_of_interest_meta_api_get_type()) }
|
||||
}
|
||||
|
@ -471,10 +493,12 @@ impl VideoAffineTransformationMeta {
|
|||
}
|
||||
|
||||
#[doc(alias = "get_matrix")]
|
||||
#[inline]
|
||||
pub fn matrix(&self) -> &[[f32; 4]; 4] {
|
||||
unsafe { &*(&self.0.matrix as *const [f32; 16] as *const [[f32; 4]; 4]) }
|
||||
}
|
||||
|
||||
#[inline]
|
||||
pub fn set_matrix(&mut self, matrix: &[[f32; 4]; 4]) {
|
||||
for (i, o) in Iterator::zip(matrix.iter().flatten(), self.0.matrix.iter_mut()) {
|
||||
*o = *i;
|
||||
|
@ -496,6 +520,7 @@ unsafe impl MetaAPI for VideoAffineTransformationMeta {
|
|||
type GstType = ffi::GstVideoAffineTransformationMeta;
|
||||
|
||||
#[doc(alias = "gst_video_affine_transformation_meta_api_get_type")]
|
||||
#[inline]
|
||||
fn meta_api() -> glib::Type {
|
||||
unsafe { from_glib(ffi::gst_video_affine_transformation_meta_api_get_type()) }
|
||||
}
|
||||
|
@ -534,15 +559,18 @@ impl VideoOverlayCompositionMeta {
|
|||
}
|
||||
|
||||
#[doc(alias = "get_overlay")]
|
||||
#[inline]
|
||||
pub fn overlay(&self) -> &crate::VideoOverlayCompositionRef {
|
||||
unsafe { crate::VideoOverlayCompositionRef::from_ptr(self.0.overlay) }
|
||||
}
|
||||
|
||||
#[doc(alias = "get_overlay_owned")]
|
||||
#[inline]
|
||||
pub fn overlay_owned(&self) -> crate::VideoOverlayComposition {
|
||||
unsafe { from_glib_none(self.overlay().as_ptr()) }
|
||||
}
|
||||
|
||||
#[inline]
|
||||
pub fn set_overlay(&mut self, overlay: &crate::VideoOverlayComposition) {
|
||||
#![allow(clippy::cast_ptr_alignment)]
|
||||
unsafe {
|
||||
|
@ -557,6 +585,7 @@ unsafe impl MetaAPI for VideoOverlayCompositionMeta {
|
|||
type GstType = ffi::GstVideoOverlayCompositionMeta;
|
||||
|
||||
#[doc(alias = "gst_video_overlay_composition_meta_api_get_type")]
|
||||
#[inline]
|
||||
fn meta_api() -> glib::Type {
|
||||
unsafe { from_glib(ffi::gst_video_overlay_composition_meta_api_get_type()) }
|
||||
}
|
||||
|
@ -607,11 +636,13 @@ impl VideoCaptionMeta {
|
|||
}
|
||||
|
||||
#[doc(alias = "get_caption_type")]
|
||||
#[inline]
|
||||
pub fn caption_type(&self) -> crate::VideoCaptionType {
|
||||
unsafe { from_glib(self.0.caption_type) }
|
||||
}
|
||||
|
||||
#[doc(alias = "get_data")]
|
||||
#[inline]
|
||||
pub fn data(&self) -> &[u8] {
|
||||
if self.0.size == 0 {
|
||||
return &[];
|
||||
|
@ -630,6 +661,7 @@ unsafe impl MetaAPI for VideoCaptionMeta {
|
|||
type GstType = ffi::GstVideoCaptionMeta;
|
||||
|
||||
#[doc(alias = "gst_video_caption_meta_api_get_type")]
|
||||
#[inline]
|
||||
fn meta_api() -> glib::Type {
|
||||
unsafe { from_glib(ffi::gst_video_caption_meta_api_get_type()) }
|
||||
}
|
||||
|
@ -684,16 +716,19 @@ impl VideoAFDMeta {
|
|||
}
|
||||
|
||||
#[doc(alias = "get_field")]
|
||||
#[inline]
|
||||
pub fn field(&self) -> u8 {
|
||||
self.0.field
|
||||
}
|
||||
|
||||
#[doc(alias = "get_spec")]
|
||||
#[inline]
|
||||
pub fn spec(&self) -> crate::VideoAFDSpec {
|
||||
unsafe { from_glib(self.0.spec) }
|
||||
}
|
||||
|
||||
#[doc(alias = "get_afd")]
|
||||
#[inline]
|
||||
pub fn afd(&self) -> crate::VideoAFDValue {
|
||||
unsafe { from_glib(self.0.afd) }
|
||||
}
|
||||
|
@ -705,6 +740,7 @@ unsafe impl MetaAPI for VideoAFDMeta {
|
|||
type GstType = ffi::GstVideoAFDMeta;
|
||||
|
||||
#[doc(alias = "gst_video_afd_meta_api_get_type")]
|
||||
#[inline]
|
||||
fn meta_api() -> glib::Type {
|
||||
unsafe { from_glib(ffi::gst_video_afd_meta_api_get_type()) }
|
||||
}
|
||||
|
@ -762,20 +798,24 @@ impl VideoBarMeta {
|
|||
}
|
||||
|
||||
#[doc(alias = "get_field")]
|
||||
#[inline]
|
||||
pub fn field(&self) -> u8 {
|
||||
self.0.field
|
||||
}
|
||||
|
||||
#[inline]
|
||||
pub fn is_letterbox(&self) -> bool {
|
||||
unsafe { from_glib(self.0.is_letterbox) }
|
||||
}
|
||||
|
||||
#[doc(alias = "get_bar_data1")]
|
||||
#[inline]
|
||||
pub fn bar_data1(&self) -> u32 {
|
||||
self.0.bar_data1
|
||||
}
|
||||
|
||||
#[doc(alias = "get_bar_data2")]
|
||||
#[inline]
|
||||
pub fn bar_data2(&self) -> u32 {
|
||||
self.0.bar_data2
|
||||
}
|
||||
|
@ -787,6 +827,7 @@ unsafe impl MetaAPI for VideoBarMeta {
|
|||
type GstType = ffi::GstVideoBarMeta;
|
||||
|
||||
#[doc(alias = "gst_video_bar_meta_api_get_type")]
|
||||
#[inline]
|
||||
fn meta_api() -> glib::Type {
|
||||
unsafe { from_glib(ffi::gst_video_bar_meta_api_get_type()) }
|
||||
}
|
||||
|
@ -837,10 +878,12 @@ impl VideoCodecAlphaMeta {
|
|||
}
|
||||
}
|
||||
|
||||
#[inline]
|
||||
pub fn alpha_buffer(&self) -> &gst::BufferRef {
|
||||
unsafe { gst::BufferRef::from_ptr(self.0.buffer) }
|
||||
}
|
||||
|
||||
#[inline]
|
||||
pub fn alpha_buffer_owned(&self) -> gst::Buffer {
|
||||
unsafe { from_glib_none(self.0.buffer) }
|
||||
}
|
||||
|
@ -852,6 +895,7 @@ unsafe impl MetaAPI for VideoCodecAlphaMeta {
|
|||
type GstType = ffi::GstVideoCodecAlphaMeta;
|
||||
|
||||
#[doc(alias = "gst_video_codec_alpha_meta_api_get_type")]
|
||||
#[inline]
|
||||
fn meta_api() -> glib::Type {
|
||||
unsafe { from_glib(ffi::gst_video_codec_alpha_meta_api_get_type()) }
|
||||
}
|
||||
|
|
|
@ -14,6 +14,7 @@ pub struct VideoRectangle {
|
|||
}
|
||||
|
||||
impl VideoRectangle {
|
||||
#[inline]
|
||||
pub fn new(x: i32, y: i32, w: i32, h: i32) -> Self {
|
||||
skip_assert_initialized!();
|
||||
Self { x, y, w, h }
|
||||
|
@ -52,6 +53,7 @@ pub fn center_video_rectangle(
|
|||
|
||||
#[doc(hidden)]
|
||||
impl glib::translate::Uninitialized for VideoRectangle {
|
||||
#[inline]
|
||||
unsafe fn uninitialized() -> Self {
|
||||
mem::zeroed()
|
||||
}
|
||||
|
@ -61,6 +63,7 @@ impl glib::translate::Uninitialized for VideoRectangle {
|
|||
impl<'a> glib::translate::ToGlibPtrMut<'a, *mut ffi::GstVideoRectangle> for VideoRectangle {
|
||||
type Storage = PhantomData<&'a mut Self>;
|
||||
|
||||
#[inline]
|
||||
fn to_glib_none_mut(
|
||||
&'a mut self,
|
||||
) -> glib::translate::StashMut<*mut ffi::GstVideoRectangle, Self> {
|
||||
|
|
|
@ -134,33 +134,40 @@ impl VideoTimeCode {
|
|||
unsafe { from_glib(ffi::gst_video_time_code_is_valid(self.to_glib_none().0)) }
|
||||
}
|
||||
|
||||
#[inline]
|
||||
pub fn set_fps(&mut self, fps: gst::Fraction) {
|
||||
self.inner.config.fps_n = fps.numer() as u32;
|
||||
self.inner.config.fps_d = fps.denom() as u32;
|
||||
}
|
||||
|
||||
#[inline]
|
||||
pub fn set_flags(&mut self, flags: VideoTimeCodeFlags) {
|
||||
self.inner.config.flags = flags.into_glib()
|
||||
}
|
||||
|
||||
#[inline]
|
||||
pub fn set_hours(&mut self, hours: u32) {
|
||||
self.inner.hours = hours
|
||||
}
|
||||
|
||||
#[inline]
|
||||
pub fn set_minutes(&mut self, minutes: u32) {
|
||||
assert!(minutes < 60);
|
||||
self.inner.minutes = minutes
|
||||
}
|
||||
|
||||
#[inline]
|
||||
pub fn set_seconds(&mut self, seconds: u32) {
|
||||
assert!(seconds < 60);
|
||||
self.inner.seconds = seconds
|
||||
}
|
||||
|
||||
#[inline]
|
||||
pub fn set_frames(&mut self, frames: u32) {
|
||||
self.inner.frames = frames
|
||||
}
|
||||
|
||||
#[inline]
|
||||
pub fn set_field_count(&mut self, field_count: u32) {
|
||||
assert!(field_count <= 2);
|
||||
self.inner.field_count = field_count
|
||||
|
@ -289,26 +296,32 @@ impl ValidVideoTimeCode {
|
|||
macro_rules! generic_impl {
|
||||
($name:ident) => {
|
||||
impl $name {
|
||||
#[inline]
|
||||
pub fn hours(&self) -> u32 {
|
||||
self.inner.hours
|
||||
}
|
||||
|
||||
#[inline]
|
||||
pub fn minutes(&self) -> u32 {
|
||||
self.inner.minutes
|
||||
}
|
||||
|
||||
#[inline]
|
||||
pub fn seconds(&self) -> u32 {
|
||||
self.inner.seconds
|
||||
}
|
||||
|
||||
#[inline]
|
||||
pub fn frames(&self) -> u32 {
|
||||
self.inner.frames
|
||||
}
|
||||
|
||||
#[inline]
|
||||
pub fn field_count(&self) -> u32 {
|
||||
self.inner.field_count
|
||||
}
|
||||
|
||||
#[inline]
|
||||
pub fn fps(&self) -> gst::Fraction {
|
||||
(
|
||||
self.inner.config.fps_n as i32,
|
||||
|
@ -317,14 +330,17 @@ macro_rules! generic_impl {
|
|||
.into()
|
||||
}
|
||||
|
||||
#[inline]
|
||||
pub fn flags(&self) -> VideoTimeCodeFlags {
|
||||
unsafe { from_glib(self.inner.config.flags) }
|
||||
}
|
||||
|
||||
#[inline]
|
||||
pub fn latest_daily_jam(&self) -> Option<glib::DateTime> {
|
||||
unsafe { from_glib_none(self.inner.config.latest_daily_jam) }
|
||||
}
|
||||
|
||||
#[inline]
|
||||
pub fn set_latest_daily_jam(&mut self, latest_daily_jam: Option<glib::DateTime>) {
|
||||
unsafe {
|
||||
if !self.inner.config.latest_daily_jam.is_null() {
|
||||
|
@ -372,6 +388,7 @@ generic_impl!(VideoTimeCode);
|
|||
generic_impl!(ValidVideoTimeCode);
|
||||
|
||||
impl StaticType for ValidVideoTimeCode {
|
||||
#[inline]
|
||||
fn static_type() -> glib::Type {
|
||||
unsafe { from_glib(ffi::gst_video_time_code_get_type()) }
|
||||
}
|
||||
|
@ -457,6 +474,7 @@ impl Ord for ValidVideoTimeCode {
|
|||
}
|
||||
|
||||
impl From<ValidVideoTimeCode> for VideoTimeCode {
|
||||
#[inline]
|
||||
fn from(v: ValidVideoTimeCode) -> Self {
|
||||
skip_assert_initialized!();
|
||||
// Use ManuallyDrop here to prevent the Drop impl of VideoTimeCode
|
||||
|
@ -492,10 +510,12 @@ impl VideoTimeCodeMeta {
|
|||
}
|
||||
|
||||
#[doc(alias = "get_tc")]
|
||||
#[inline]
|
||||
pub fn tc(&self) -> ValidVideoTimeCode {
|
||||
unsafe { ValidVideoTimeCode::from_glib_none(&self.0.tc as *const _) }
|
||||
}
|
||||
|
||||
#[inline]
|
||||
pub fn set_tc(&mut self, tc: ValidVideoTimeCode) {
|
||||
#![allow(clippy::cast_ptr_alignment)]
|
||||
unsafe {
|
||||
|
@ -513,6 +533,7 @@ unsafe impl MetaAPI for VideoTimeCodeMeta {
|
|||
type GstType = ffi::GstVideoTimeCodeMeta;
|
||||
|
||||
#[doc(alias = "gst_video_time_code_meta_api_get_type")]
|
||||
#[inline]
|
||||
fn meta_api() -> glib::Type {
|
||||
unsafe { from_glib(ffi::gst_video_time_code_meta_api_get_type()) }
|
||||
}
|
||||
|
|
|
@ -16,21 +16,25 @@ unsafe impl Sync for AllocationParams {}
|
|||
|
||||
impl AllocationParams {
|
||||
#[doc(alias = "get_flags")]
|
||||
#[inline]
|
||||
pub fn flags(&self) -> MemoryFlags {
|
||||
unsafe { from_glib(self.0.flags) }
|
||||
}
|
||||
|
||||
#[doc(alias = "get_align")]
|
||||
#[inline]
|
||||
pub fn align(&self) -> usize {
|
||||
self.0.align
|
||||
}
|
||||
|
||||
#[doc(alias = "get_prefix")]
|
||||
#[inline]
|
||||
pub fn prefix(&self) -> usize {
|
||||
self.0.prefix
|
||||
}
|
||||
|
||||
#[doc(alias = "get_padding")]
|
||||
#[inline]
|
||||
pub fn padding(&self) -> usize {
|
||||
self.0.padding
|
||||
}
|
||||
|
@ -50,12 +54,14 @@ impl AllocationParams {
|
|||
params.into()
|
||||
}
|
||||
|
||||
#[inline]
|
||||
pub fn as_ptr(&self) -> *const ffi::GstAllocationParams {
|
||||
&self.0
|
||||
}
|
||||
}
|
||||
|
||||
impl From<ffi::GstAllocationParams> for AllocationParams {
|
||||
#[inline]
|
||||
fn from(params: ffi::GstAllocationParams) -> Self {
|
||||
skip_assert_initialized!();
|
||||
AllocationParams(params)
|
||||
|
@ -66,6 +72,7 @@ impl From<ffi::GstAllocationParams> for AllocationParams {
|
|||
impl<'a> ToGlibPtr<'a, *const ffi::GstAllocationParams> for AllocationParams {
|
||||
type Storage = PhantomData<&'a Self>;
|
||||
|
||||
#[inline]
|
||||
fn to_glib_none(&'a self) -> Stash<'a, *const ffi::GstAllocationParams, Self> {
|
||||
Stash(&self.0, PhantomData)
|
||||
}
|
||||
|
@ -73,6 +80,7 @@ impl<'a> ToGlibPtr<'a, *const ffi::GstAllocationParams> for AllocationParams {
|
|||
|
||||
impl FromGlib<ffi::GstAllocationParams> for AllocationParams {
|
||||
#[allow(unused_unsafe)]
|
||||
#[inline]
|
||||
unsafe fn from_glib(value: ffi::GstAllocationParams) -> Self {
|
||||
assert_initialized_main_thread!();
|
||||
Self::from(value)
|
||||
|
|
|
@ -108,6 +108,7 @@ impl Buffer {
|
|||
}
|
||||
|
||||
#[doc(alias = "gst_buffer_map")]
|
||||
#[inline]
|
||||
pub fn into_mapped_buffer_readable(self) -> Result<MappedBuffer<Readable>, Self> {
|
||||
unsafe {
|
||||
let mut map_info = mem::MaybeUninit::uninit();
|
||||
|
@ -129,6 +130,7 @@ impl Buffer {
|
|||
}
|
||||
|
||||
#[doc(alias = "gst_buffer_map")]
|
||||
#[inline]
|
||||
pub fn into_mapped_buffer_writable(self) -> Result<MappedBuffer<Writable>, Self> {
|
||||
unsafe {
|
||||
let mut map_info = mem::MaybeUninit::uninit();
|
||||
|
@ -149,10 +151,12 @@ impl Buffer {
|
|||
}
|
||||
}
|
||||
|
||||
#[inline]
|
||||
pub fn into_cursor_readable(self) -> BufferCursor<Readable> {
|
||||
BufferCursor::new_readable(self)
|
||||
}
|
||||
|
||||
#[inline]
|
||||
pub fn into_cursor_writable(self) -> Result<BufferCursor<Writable>, glib::BoolError> {
|
||||
BufferCursor::new_writable(self)
|
||||
}
|
||||
|
@ -175,6 +179,7 @@ impl Default for Buffer {
|
|||
|
||||
impl BufferRef {
|
||||
#[doc(alias = "gst_buffer_map")]
|
||||
#[inline]
|
||||
pub fn map_readable(&self) -> Result<BufferMap<Readable>, glib::BoolError> {
|
||||
unsafe {
|
||||
let mut map_info = mem::MaybeUninit::uninit();
|
||||
|
@ -193,6 +198,7 @@ impl BufferRef {
|
|||
}
|
||||
|
||||
#[doc(alias = "gst_buffer_map")]
|
||||
#[inline]
|
||||
pub fn map_writable(&mut self) -> Result<BufferMap<Writable>, glib::BoolError> {
|
||||
unsafe {
|
||||
let mut map_info = mem::MaybeUninit::uninit();
|
||||
|
@ -339,46 +345,55 @@ impl BufferRef {
|
|||
|
||||
#[doc(alias = "get_offset")]
|
||||
#[doc(alias = "GST_BUFFER_OFFSET")]
|
||||
#[inline]
|
||||
pub fn offset(&self) -> u64 {
|
||||
self.0.offset
|
||||
}
|
||||
|
||||
#[inline]
|
||||
pub fn set_offset(&mut self, offset: u64) {
|
||||
self.0.offset = offset;
|
||||
}
|
||||
|
||||
#[doc(alias = "get_offset_end")]
|
||||
#[doc(alias = "GST_BUFFER_OFFSET_END")]
|
||||
#[inline]
|
||||
pub fn offset_end(&self) -> u64 {
|
||||
self.0.offset_end
|
||||
}
|
||||
|
||||
#[inline]
|
||||
pub fn set_offset_end(&mut self, offset_end: u64) {
|
||||
self.0.offset_end = offset_end;
|
||||
}
|
||||
|
||||
#[doc(alias = "get_pts")]
|
||||
#[doc(alias = "GST_BUFFER_PTS")]
|
||||
#[inline]
|
||||
pub fn pts(&self) -> Option<ClockTime> {
|
||||
unsafe { from_glib(self.0.pts) }
|
||||
}
|
||||
|
||||
#[inline]
|
||||
pub fn set_pts(&mut self, pts: impl Into<Option<ClockTime>>) {
|
||||
self.0.pts = pts.into().into_glib();
|
||||
}
|
||||
|
||||
#[doc(alias = "get_dts")]
|
||||
#[doc(alias = "GST_BUFFER_DTS")]
|
||||
#[inline]
|
||||
pub fn dts(&self) -> Option<ClockTime> {
|
||||
unsafe { from_glib(self.0.dts) }
|
||||
}
|
||||
|
||||
#[inline]
|
||||
pub fn set_dts(&mut self, dts: impl Into<Option<ClockTime>>) {
|
||||
self.0.dts = dts.into().into_glib();
|
||||
}
|
||||
|
||||
#[doc(alias = "get_dts_or_pts")]
|
||||
#[doc(alias = "GST_BUFFER_DTS_OR_PTS")]
|
||||
#[inline]
|
||||
pub fn dts_or_pts(&self) -> Option<ClockTime> {
|
||||
let val = self.dts();
|
||||
if val.is_none() {
|
||||
|
@ -390,32 +405,38 @@ impl BufferRef {
|
|||
|
||||
#[doc(alias = "get_duration")]
|
||||
#[doc(alias = "GST_BUFFER_DURATION")]
|
||||
#[inline]
|
||||
pub fn duration(&self) -> Option<ClockTime> {
|
||||
unsafe { from_glib(self.0.duration) }
|
||||
}
|
||||
|
||||
#[inline]
|
||||
pub fn set_duration(&mut self, duration: impl Into<Option<ClockTime>>) {
|
||||
self.0.duration = duration.into().into_glib();
|
||||
}
|
||||
|
||||
#[doc(alias = "get_flags")]
|
||||
#[doc(alias = "GST_BUFFER_FLAGS")]
|
||||
#[inline]
|
||||
pub fn flags(&self) -> BufferFlags {
|
||||
BufferFlags::from_bits_truncate(self.0.mini_object.flags)
|
||||
}
|
||||
|
||||
#[doc(alias = "GST_BUFFER_FLAG_SET")]
|
||||
#[inline]
|
||||
pub fn set_flags(&mut self, flags: BufferFlags) {
|
||||
self.0.mini_object.flags |= flags.bits();
|
||||
}
|
||||
|
||||
#[doc(alias = "GST_BUFFER_FLAG_UNSET")]
|
||||
#[inline]
|
||||
pub fn unset_flags(&mut self, flags: BufferFlags) {
|
||||
self.0.mini_object.flags &= !flags.bits();
|
||||
}
|
||||
|
||||
#[doc(alias = "get_meta")]
|
||||
#[doc(alias = "gst_buffer_get_meta")]
|
||||
#[inline]
|
||||
pub fn meta<T: MetaAPI>(&self) -> Option<MetaRef<T>> {
|
||||
unsafe {
|
||||
let meta = ffi::gst_buffer_get_meta(self.as_mut_ptr(), T::meta_api().into_glib());
|
||||
|
@ -428,6 +449,7 @@ impl BufferRef {
|
|||
}
|
||||
|
||||
#[doc(alias = "get_meta_mut")]
|
||||
#[inline]
|
||||
pub fn meta_mut<T: MetaAPI>(&mut self) -> Option<MetaRefMut<T, crate::meta::Standalone>> {
|
||||
unsafe {
|
||||
let meta = ffi::gst_buffer_get_meta(self.as_mut_ptr(), T::meta_api().into_glib());
|
||||
|
@ -1087,15 +1109,18 @@ impl Eq for BufferRef {}
|
|||
|
||||
impl<'a, T> BufferMap<'a, T> {
|
||||
#[doc(alias = "get_size")]
|
||||
#[inline]
|
||||
pub fn size(&self) -> usize {
|
||||
self.map_info.size
|
||||
}
|
||||
|
||||
#[doc(alias = "get_buffer")]
|
||||
#[inline]
|
||||
pub fn buffer(&self) -> &BufferRef {
|
||||
self.buffer
|
||||
}
|
||||
|
||||
#[inline]
|
||||
pub fn as_slice(&self) -> &[u8] {
|
||||
if self.map_info.size == 0 {
|
||||
return &[];
|
||||
|
@ -1105,6 +1130,7 @@ impl<'a, T> BufferMap<'a, T> {
|
|||
}
|
||||
|
||||
impl<'a> BufferMap<'a, Writable> {
|
||||
#[inline]
|
||||
pub fn as_mut_slice(&mut self) -> &mut [u8] {
|
||||
if self.map_info.size == 0 {
|
||||
return &mut [];
|
||||
|
@ -1114,12 +1140,14 @@ impl<'a> BufferMap<'a, Writable> {
|
|||
}
|
||||
|
||||
impl<'a, T> AsRef<[u8]> for BufferMap<'a, T> {
|
||||
#[inline]
|
||||
fn as_ref(&self) -> &[u8] {
|
||||
self.as_slice()
|
||||
}
|
||||
}
|
||||
|
||||
impl<'a> AsMut<[u8]> for BufferMap<'a, Writable> {
|
||||
#[inline]
|
||||
fn as_mut(&mut self) -> &mut [u8] {
|
||||
self.as_mut_slice()
|
||||
}
|
||||
|
@ -1128,12 +1156,14 @@ impl<'a> AsMut<[u8]> for BufferMap<'a, Writable> {
|
|||
impl<'a, T> ops::Deref for BufferMap<'a, T> {
|
||||
type Target = [u8];
|
||||
|
||||
#[inline]
|
||||
fn deref(&self) -> &[u8] {
|
||||
self.as_slice()
|
||||
}
|
||||
}
|
||||
|
||||
impl<'a> ops::DerefMut for BufferMap<'a, Writable> {
|
||||
#[inline]
|
||||
fn deref_mut(&mut self) -> &mut [u8] {
|
||||
self.as_mut_slice()
|
||||
}
|
||||
|
@ -1154,6 +1184,7 @@ impl<'a, T> PartialEq for BufferMap<'a, T> {
|
|||
impl<'a, T> Eq for BufferMap<'a, T> {}
|
||||
|
||||
impl<'a, T> Drop for BufferMap<'a, T> {
|
||||
#[inline]
|
||||
fn drop(&mut self) {
|
||||
unsafe {
|
||||
ffi::gst_buffer_unmap(self.buffer.as_mut_ptr(), &mut self.map_info);
|
||||
|
@ -1165,6 +1196,7 @@ unsafe impl<'a, T> Send for BufferMap<'a, T> {}
|
|||
unsafe impl<'a, T> Sync for BufferMap<'a, T> {}
|
||||
|
||||
impl<T> MappedBuffer<T> {
|
||||
#[inline]
|
||||
pub fn as_slice(&self) -> &[u8] {
|
||||
if self.map_info.size == 0 {
|
||||
return &[];
|
||||
|
@ -1173,15 +1205,18 @@ impl<T> MappedBuffer<T> {
|
|||
}
|
||||
|
||||
#[doc(alias = "get_size")]
|
||||
#[inline]
|
||||
pub fn size(&self) -> usize {
|
||||
self.map_info.size
|
||||
}
|
||||
|
||||
#[doc(alias = "get_buffer")]
|
||||
#[inline]
|
||||
pub fn buffer(&self) -> &BufferRef {
|
||||
self.buffer.as_ref()
|
||||
}
|
||||
|
||||
#[inline]
|
||||
pub fn into_buffer(self) -> Buffer {
|
||||
let mut s = mem::ManuallyDrop::new(self);
|
||||
let buffer = unsafe { ptr::read(&s.buffer) };
|
||||
|
@ -1194,6 +1229,7 @@ impl<T> MappedBuffer<T> {
|
|||
}
|
||||
|
||||
impl MappedBuffer<Writable> {
|
||||
#[inline]
|
||||
pub fn as_mut_slice(&mut self) -> &mut [u8] {
|
||||
if self.map_info.size == 0 {
|
||||
return &mut [];
|
||||
|
@ -1203,12 +1239,14 @@ impl MappedBuffer<Writable> {
|
|||
}
|
||||
|
||||
impl<T> AsRef<[u8]> for MappedBuffer<T> {
|
||||
#[inline]
|
||||
fn as_ref(&self) -> &[u8] {
|
||||
self.as_slice()
|
||||
}
|
||||
}
|
||||
|
||||
impl AsMut<[u8]> for MappedBuffer<Writable> {
|
||||
#[inline]
|
||||
fn as_mut(&mut self) -> &mut [u8] {
|
||||
self.as_mut_slice()
|
||||
}
|
||||
|
@ -1217,18 +1255,21 @@ impl AsMut<[u8]> for MappedBuffer<Writable> {
|
|||
impl<T> ops::Deref for MappedBuffer<T> {
|
||||
type Target = [u8];
|
||||
|
||||
#[inline]
|
||||
fn deref(&self) -> &[u8] {
|
||||
self.as_slice()
|
||||
}
|
||||
}
|
||||
|
||||
impl ops::DerefMut for MappedBuffer<Writable> {
|
||||
#[inline]
|
||||
fn deref_mut(&mut self) -> &mut [u8] {
|
||||
self.as_mut_slice()
|
||||
}
|
||||
}
|
||||
|
||||
impl<T> Drop for MappedBuffer<T> {
|
||||
#[inline]
|
||||
fn drop(&mut self) {
|
||||
unsafe {
|
||||
ffi::gst_buffer_unmap(self.buffer.as_mut_ptr(), &mut self.map_info);
|
||||
|
|
|
@ -18,24 +18,28 @@ pub struct BufferPoolConfig(Structure);
|
|||
impl Deref for BufferPoolConfig {
|
||||
type Target = BufferPoolConfigRef;
|
||||
|
||||
#[inline]
|
||||
fn deref(&self) -> &BufferPoolConfigRef {
|
||||
unsafe { &*(self.0.as_ptr() as *const StructureRef as *const BufferPoolConfigRef) }
|
||||
}
|
||||
}
|
||||
|
||||
impl DerefMut for BufferPoolConfig {
|
||||
#[inline]
|
||||
fn deref_mut(&mut self) -> &mut BufferPoolConfigRef {
|
||||
unsafe { &mut *(self.0.as_ptr() as *mut StructureRef as *mut BufferPoolConfigRef) }
|
||||
}
|
||||
}
|
||||
|
||||
impl AsRef<BufferPoolConfigRef> for BufferPoolConfig {
|
||||
#[inline]
|
||||
fn as_ref(&self) -> &BufferPoolConfigRef {
|
||||
self.deref()
|
||||
}
|
||||
}
|
||||
|
||||
impl AsMut<BufferPoolConfigRef> for BufferPoolConfig {
|
||||
#[inline]
|
||||
fn as_mut(&mut self) -> &mut BufferPoolConfigRef {
|
||||
self.deref_mut()
|
||||
}
|
||||
|
@ -46,12 +50,14 @@ impl AsMut<BufferPoolConfigRef> for BufferPoolConfig {
|
|||
pub struct BufferPoolConfigRef(StructureRef);
|
||||
|
||||
impl BufferPoolConfigRef {
|
||||
#[inline]
|
||||
pub unsafe fn from_glib_borrow<'a>(ptr: *const ffi::GstStructure) -> &'a BufferPoolConfigRef {
|
||||
assert!(!ptr.is_null());
|
||||
|
||||
&*(ptr as *mut StructureRef as *mut BufferPoolConfigRef)
|
||||
}
|
||||
|
||||
#[inline]
|
||||
pub unsafe fn from_glib_borrow_mut<'a>(
|
||||
ptr: *mut ffi::GstStructure,
|
||||
) -> &'a mut BufferPoolConfigRef {
|
||||
|
@ -60,10 +66,12 @@ impl BufferPoolConfigRef {
|
|||
&mut *(ptr as *mut StructureRef as *mut BufferPoolConfigRef)
|
||||
}
|
||||
|
||||
#[inline]
|
||||
pub fn as_ptr(&self) -> *const ffi::GstStructure {
|
||||
self as *const Self as *const ffi::GstStructure
|
||||
}
|
||||
|
||||
#[inline]
|
||||
pub fn as_mut_ptr(&self) -> *mut ffi::GstStructure {
|
||||
self as *const Self as *mut ffi::GstStructure
|
||||
}
|
||||
|
@ -72,24 +80,28 @@ impl BufferPoolConfigRef {
|
|||
impl ops::Deref for BufferPoolConfigRef {
|
||||
type Target = crate::StructureRef;
|
||||
|
||||
#[inline]
|
||||
fn deref(&self) -> &crate::StructureRef {
|
||||
&self.0
|
||||
}
|
||||
}
|
||||
|
||||
impl ops::DerefMut for BufferPoolConfigRef {
|
||||
#[inline]
|
||||
fn deref_mut(&mut self) -> &mut crate::StructureRef {
|
||||
&mut self.0
|
||||
}
|
||||
}
|
||||
|
||||
impl AsRef<crate::StructureRef> for BufferPoolConfigRef {
|
||||
#[inline]
|
||||
fn as_ref(&self) -> &crate::StructureRef {
|
||||
&self.0
|
||||
}
|
||||
}
|
||||
|
||||
impl AsMut<crate::StructureRef> for BufferPoolConfigRef {
|
||||
#[inline]
|
||||
fn as_mut(&mut self) -> &mut crate::StructureRef {
|
||||
&mut self.0
|
||||
}
|
||||
|
@ -305,6 +317,7 @@ impl Eq for BufferPoolAcquireParams {}
|
|||
impl<'a> ToGlibPtr<'a, *const ffi::GstBufferPoolAcquireParams> for BufferPoolAcquireParams {
|
||||
type Storage = PhantomData<&'a Self>;
|
||||
|
||||
#[inline]
|
||||
fn to_glib_none(
|
||||
&'a self,
|
||||
) -> glib::translate::Stash<'a, *const ffi::GstBufferPoolAcquireParams, Self> {
|
||||
|
@ -316,6 +329,7 @@ impl<'a> ToGlibPtr<'a, *const ffi::GstBufferPoolAcquireParams> for BufferPoolAcq
|
|||
impl<'a> ToGlibPtrMut<'a, *mut ffi::GstBufferPoolAcquireParams> for BufferPoolAcquireParams {
|
||||
type Storage = PhantomData<&'a mut Self>;
|
||||
|
||||
#[inline]
|
||||
fn to_glib_none_mut(
|
||||
&'a mut self,
|
||||
) -> glib::translate::StashMut<'a, *mut ffi::GstBufferPoolAcquireParams, Self> {
|
||||
|
@ -325,6 +339,7 @@ impl<'a> ToGlibPtrMut<'a, *mut ffi::GstBufferPoolAcquireParams> for BufferPoolAc
|
|||
|
||||
#[doc(hidden)]
|
||||
impl FromGlibPtrNone<*mut ffi::GstBufferPoolAcquireParams> for BufferPoolAcquireParams {
|
||||
#[inline]
|
||||
unsafe fn from_glib_none(ptr: *mut ffi::GstBufferPoolAcquireParams) -> Self {
|
||||
Self(*ptr)
|
||||
}
|
||||
|
|
|
@ -62,6 +62,7 @@ impl CapsFeatures {
|
|||
}
|
||||
|
||||
impl IntoGlibPtr<*mut ffi::GstCapsFeatures> for CapsFeatures {
|
||||
#[inline]
|
||||
unsafe fn into_glib_ptr(self) -> *mut ffi::GstCapsFeatures {
|
||||
let s = mem::ManuallyDrop::new(self);
|
||||
s.0.as_ptr()
|
||||
|
@ -71,30 +72,35 @@ impl IntoGlibPtr<*mut ffi::GstCapsFeatures> for CapsFeatures {
|
|||
impl Deref for CapsFeatures {
|
||||
type Target = CapsFeaturesRef;
|
||||
|
||||
#[inline]
|
||||
fn deref(&self) -> &CapsFeaturesRef {
|
||||
unsafe { &*(self.0.as_ref() as *const ffi::GstCapsFeatures as *const CapsFeaturesRef) }
|
||||
}
|
||||
}
|
||||
|
||||
impl DerefMut for CapsFeatures {
|
||||
#[inline]
|
||||
fn deref_mut(&mut self) -> &mut CapsFeaturesRef {
|
||||
unsafe { &mut *(self.0.as_mut() as *mut ffi::GstCapsFeatures as *mut CapsFeaturesRef) }
|
||||
}
|
||||
}
|
||||
|
||||
impl AsRef<CapsFeaturesRef> for CapsFeatures {
|
||||
#[inline]
|
||||
fn as_ref(&self) -> &CapsFeaturesRef {
|
||||
self.deref()
|
||||
}
|
||||
}
|
||||
|
||||
impl AsMut<CapsFeaturesRef> for CapsFeatures {
|
||||
#[inline]
|
||||
fn as_mut(&mut self) -> &mut CapsFeaturesRef {
|
||||
self.deref_mut()
|
||||
}
|
||||
}
|
||||
|
||||
impl Clone for CapsFeatures {
|
||||
#[inline]
|
||||
fn clone(&self) -> Self {
|
||||
unsafe {
|
||||
let ptr = ffi::gst_caps_features_copy(self.0.as_ref());
|
||||
|
@ -105,6 +111,7 @@ impl Clone for CapsFeatures {
|
|||
}
|
||||
|
||||
impl Drop for CapsFeatures {
|
||||
#[inline]
|
||||
fn drop(&mut self) {
|
||||
unsafe { ffi::gst_caps_features_free(self.0.as_mut()) }
|
||||
}
|
||||
|
@ -146,18 +153,21 @@ impl str::FromStr for CapsFeatures {
|
|||
}
|
||||
|
||||
impl Borrow<CapsFeaturesRef> for CapsFeatures {
|
||||
#[inline]
|
||||
fn borrow(&self) -> &CapsFeaturesRef {
|
||||
self.as_ref()
|
||||
}
|
||||
}
|
||||
|
||||
impl BorrowMut<CapsFeaturesRef> for CapsFeatures {
|
||||
#[inline]
|
||||
fn borrow_mut(&mut self) -> &mut CapsFeaturesRef {
|
||||
self.as_mut()
|
||||
}
|
||||
}
|
||||
|
||||
impl glib::types::StaticType for CapsFeatures {
|
||||
#[inline]
|
||||
fn static_type() -> glib::types::Type {
|
||||
unsafe { from_glib(ffi::gst_caps_features_get_type()) }
|
||||
}
|
||||
|
@ -166,10 +176,12 @@ impl glib::types::StaticType for CapsFeatures {
|
|||
impl<'a> ToGlibPtr<'a, *const ffi::GstCapsFeatures> for CapsFeatures {
|
||||
type Storage = PhantomData<&'a Self>;
|
||||
|
||||
#[inline]
|
||||
fn to_glib_none(&'a self) -> Stash<'a, *const ffi::GstCapsFeatures, Self> {
|
||||
unsafe { Stash(self.0.as_ref(), PhantomData) }
|
||||
}
|
||||
|
||||
#[inline]
|
||||
fn to_glib_full(&self) -> *const ffi::GstCapsFeatures {
|
||||
unsafe { ffi::gst_caps_features_copy(self.0.as_ref()) }
|
||||
}
|
||||
|
@ -178,6 +190,7 @@ impl<'a> ToGlibPtr<'a, *const ffi::GstCapsFeatures> for CapsFeatures {
|
|||
impl<'a> ToGlibPtr<'a, *mut ffi::GstCapsFeatures> for CapsFeatures {
|
||||
type Storage = PhantomData<&'a Self>;
|
||||
|
||||
#[inline]
|
||||
fn to_glib_none(&'a self) -> Stash<'a, *mut ffi::GstCapsFeatures, Self> {
|
||||
unsafe {
|
||||
Stash(
|
||||
|
@ -187,6 +200,7 @@ impl<'a> ToGlibPtr<'a, *mut ffi::GstCapsFeatures> for CapsFeatures {
|
|||
}
|
||||
}
|
||||
|
||||
#[inline]
|
||||
fn to_glib_full(&self) -> *mut ffi::GstCapsFeatures {
|
||||
unsafe { ffi::gst_caps_features_copy(self.0.as_ref()) }
|
||||
}
|
||||
|
@ -195,12 +209,14 @@ impl<'a> ToGlibPtr<'a, *mut ffi::GstCapsFeatures> for CapsFeatures {
|
|||
impl<'a> ToGlibPtrMut<'a, *mut ffi::GstCapsFeatures> for CapsFeatures {
|
||||
type Storage = PhantomData<&'a mut Self>;
|
||||
|
||||
#[inline]
|
||||
fn to_glib_none_mut(&'a mut self) -> StashMut<*mut ffi::GstCapsFeatures, Self> {
|
||||
unsafe { StashMut(self.0.as_mut(), PhantomData) }
|
||||
}
|
||||
}
|
||||
|
||||
impl FromGlibPtrNone<*const ffi::GstCapsFeatures> for CapsFeatures {
|
||||
#[inline]
|
||||
unsafe fn from_glib_none(ptr: *const ffi::GstCapsFeatures) -> Self {
|
||||
assert!(!ptr.is_null());
|
||||
let ptr = ffi::gst_caps_features_copy(ptr);
|
||||
|
@ -210,6 +226,7 @@ impl FromGlibPtrNone<*const ffi::GstCapsFeatures> for CapsFeatures {
|
|||
}
|
||||
|
||||
impl FromGlibPtrNone<*mut ffi::GstCapsFeatures> for CapsFeatures {
|
||||
#[inline]
|
||||
unsafe fn from_glib_none(ptr: *mut ffi::GstCapsFeatures) -> Self {
|
||||
assert!(!ptr.is_null());
|
||||
let ptr = ffi::gst_caps_features_copy(ptr);
|
||||
|
@ -219,6 +236,7 @@ impl FromGlibPtrNone<*mut ffi::GstCapsFeatures> for CapsFeatures {
|
|||
}
|
||||
|
||||
impl FromGlibPtrFull<*const ffi::GstCapsFeatures> for CapsFeatures {
|
||||
#[inline]
|
||||
unsafe fn from_glib_full(ptr: *const ffi::GstCapsFeatures) -> Self {
|
||||
assert!(!ptr.is_null());
|
||||
CapsFeatures(ptr::NonNull::new_unchecked(
|
||||
|
@ -228,6 +246,7 @@ impl FromGlibPtrFull<*const ffi::GstCapsFeatures> for CapsFeatures {
|
|||
}
|
||||
|
||||
impl FromGlibPtrFull<*mut ffi::GstCapsFeatures> for CapsFeatures {
|
||||
#[inline]
|
||||
unsafe fn from_glib_full(ptr: *mut ffi::GstCapsFeatures) -> Self {
|
||||
assert!(!ptr.is_null());
|
||||
CapsFeatures(ptr::NonNull::new_unchecked(ptr))
|
||||
|
@ -306,12 +325,14 @@ unsafe impl TransparentPtrType for CapsFeatures {}
|
|||
pub struct CapsFeaturesRef(ffi::GstCapsFeatures);
|
||||
|
||||
impl CapsFeaturesRef {
|
||||
#[inline]
|
||||
pub unsafe fn from_glib_borrow<'a>(ptr: *const ffi::GstCapsFeatures) -> &'a CapsFeaturesRef {
|
||||
assert!(!ptr.is_null());
|
||||
|
||||
&*(ptr as *mut CapsFeaturesRef)
|
||||
}
|
||||
|
||||
#[inline]
|
||||
pub unsafe fn from_glib_borrow_mut<'a>(
|
||||
ptr: *mut ffi::GstCapsFeatures,
|
||||
) -> &'a mut CapsFeaturesRef {
|
||||
|
@ -320,10 +341,12 @@ impl CapsFeaturesRef {
|
|||
&mut *(ptr as *mut CapsFeaturesRef)
|
||||
}
|
||||
|
||||
#[inline]
|
||||
pub fn as_ptr(&self) -> *const ffi::GstCapsFeatures {
|
||||
self as *const Self as *const ffi::GstCapsFeatures
|
||||
}
|
||||
|
||||
#[inline]
|
||||
pub fn as_mut_ptr(&self) -> *mut ffi::GstCapsFeatures {
|
||||
self as *const Self as *mut ffi::GstCapsFeatures
|
||||
}
|
||||
|
@ -429,6 +452,7 @@ impl CapsFeaturesRef {
|
|||
}
|
||||
|
||||
impl glib::types::StaticType for CapsFeaturesRef {
|
||||
#[inline]
|
||||
fn static_type() -> glib::types::Type {
|
||||
unsafe { from_glib(ffi::gst_structure_get_type()) }
|
||||
}
|
||||
|
@ -680,6 +704,7 @@ impl fmt::Display for CapsFeaturesRef {
|
|||
impl ToOwned for CapsFeaturesRef {
|
||||
type Owned = CapsFeatures;
|
||||
|
||||
#[inline]
|
||||
fn to_owned(&self) -> CapsFeatures {
|
||||
unsafe { from_glib_full(ffi::gst_caps_features_copy(self.as_ptr() as *const _) as *mut _) }
|
||||
}
|
||||
|
|
|
@ -109,12 +109,14 @@ pub struct SingleShotClockId(ClockId);
|
|||
impl std::ops::Deref for SingleShotClockId {
|
||||
type Target = ClockId;
|
||||
|
||||
#[inline]
|
||||
fn deref(&self) -> &Self::Target {
|
||||
&self.0
|
||||
}
|
||||
}
|
||||
|
||||
impl From<SingleShotClockId> for ClockId {
|
||||
#[inline]
|
||||
fn from(id: SingleShotClockId) -> ClockId {
|
||||
skip_assert_initialized!();
|
||||
id.0
|
||||
|
@ -124,6 +126,7 @@ impl From<SingleShotClockId> for ClockId {
|
|||
impl TryFrom<ClockId> for SingleShotClockId {
|
||||
type Error = glib::BoolError;
|
||||
|
||||
#[inline]
|
||||
fn try_from(id: ClockId) -> Result<SingleShotClockId, glib::BoolError> {
|
||||
skip_assert_initialized!();
|
||||
match id.type_() {
|
||||
|
@ -135,6 +138,7 @@ impl TryFrom<ClockId> for SingleShotClockId {
|
|||
|
||||
impl SingleShotClockId {
|
||||
#[doc(alias = "gst_clock_id_compare_func")]
|
||||
#[inline]
|
||||
pub fn compare_by_time(&self, other: &Self) -> cmp::Ordering {
|
||||
self.0.compare_by_time(&other.0)
|
||||
}
|
||||
|
@ -220,12 +224,14 @@ pub struct PeriodicClockId(ClockId);
|
|||
impl std::ops::Deref for PeriodicClockId {
|
||||
type Target = ClockId;
|
||||
|
||||
#[inline]
|
||||
fn deref(&self) -> &Self::Target {
|
||||
&self.0
|
||||
}
|
||||
}
|
||||
|
||||
impl From<PeriodicClockId> for ClockId {
|
||||
#[inline]
|
||||
fn from(id: PeriodicClockId) -> ClockId {
|
||||
skip_assert_initialized!();
|
||||
id.0
|
||||
|
@ -235,6 +241,7 @@ impl From<PeriodicClockId> for ClockId {
|
|||
impl TryFrom<ClockId> for PeriodicClockId {
|
||||
type Error = glib::BoolError;
|
||||
|
||||
#[inline]
|
||||
fn try_from(id: ClockId) -> Result<PeriodicClockId, glib::BoolError> {
|
||||
skip_assert_initialized!();
|
||||
match id.type_() {
|
||||
|
@ -247,6 +254,7 @@ impl TryFrom<ClockId> for PeriodicClockId {
|
|||
impl PeriodicClockId {
|
||||
#[doc(alias = "get_interval")]
|
||||
#[doc(alias = "GST_CLOCK_ENTRY_INTERVAL")]
|
||||
#[inline]
|
||||
pub fn interval(&self) -> ClockTime {
|
||||
unsafe {
|
||||
let ptr = self.as_ptr() as *mut ffi::GstClockEntry;
|
||||
|
@ -255,6 +263,7 @@ impl PeriodicClockId {
|
|||
}
|
||||
|
||||
#[doc(alias = "gst_clock_id_compare_func")]
|
||||
#[inline]
|
||||
pub fn compare_by_time(&self, other: &Self) -> cmp::Ordering {
|
||||
self.0.compare_by_time(&other.0)
|
||||
}
|
||||
|
@ -327,18 +336,22 @@ impl PeriodicClockId {
|
|||
pub struct AtomicClockReturn(AtomicI32);
|
||||
|
||||
impl AtomicClockReturn {
|
||||
#[inline]
|
||||
pub fn load(&self) -> ClockReturn {
|
||||
unsafe { from_glib(self.0.load(atomic::Ordering::SeqCst)) }
|
||||
}
|
||||
|
||||
#[inline]
|
||||
pub fn store(&self, val: ClockReturn) {
|
||||
self.0.store(val.into_glib(), atomic::Ordering::SeqCst)
|
||||
}
|
||||
|
||||
#[inline]
|
||||
pub fn swap(&self, val: ClockReturn) -> ClockReturn {
|
||||
unsafe { from_glib(self.0.swap(val.into_glib(), atomic::Ordering::SeqCst)) }
|
||||
}
|
||||
|
||||
#[inline]
|
||||
pub fn compare_exchange(
|
||||
&self,
|
||||
current: ClockReturn,
|
||||
|
|
|
@ -31,6 +31,7 @@ enum DateTimeVariants {
|
|||
pub(crate) struct Date(glib::Date);
|
||||
|
||||
impl From<glib::Date> for Date {
|
||||
#[inline]
|
||||
fn from(glib_date: glib::Date) -> Self {
|
||||
skip_assert_initialized!();
|
||||
Date(glib_date)
|
||||
|
@ -55,12 +56,14 @@ impl ToValueOptional for Date {
|
|||
}
|
||||
|
||||
impl StaticType for Date {
|
||||
#[inline]
|
||||
fn static_type() -> glib::Type {
|
||||
glib::Date::static_type()
|
||||
}
|
||||
}
|
||||
|
||||
impl From<Date> for glib::Value {
|
||||
#[inline]
|
||||
fn from(v: Date) -> glib::Value {
|
||||
skip_assert_initialized!();
|
||||
v.0.into()
|
||||
|
|
|
@ -12,12 +12,14 @@ pub struct DeviceMonitorFilterId(NonZeroU32);
|
|||
impl IntoGlib for DeviceMonitorFilterId {
|
||||
type GlibType = libc::c_uint;
|
||||
|
||||
#[inline]
|
||||
fn into_glib(self) -> libc::c_uint {
|
||||
self.0.get()
|
||||
}
|
||||
}
|
||||
|
||||
impl FromGlib<libc::c_uint> for DeviceMonitorFilterId {
|
||||
#[inline]
|
||||
unsafe fn from_glib(val: libc::c_uint) -> DeviceMonitorFilterId {
|
||||
skip_assert_initialized!();
|
||||
assert_ne!(val, 0);
|
||||
|
|
|
@ -84,12 +84,14 @@ pub struct NotifyWatchId(NonZeroU64);
|
|||
impl IntoGlib for NotifyWatchId {
|
||||
type GlibType = libc::c_ulong;
|
||||
|
||||
#[inline]
|
||||
fn into_glib(self) -> libc::c_ulong {
|
||||
self.0.get() as libc::c_ulong
|
||||
}
|
||||
}
|
||||
|
||||
impl FromGlib<libc::c_ulong> for NotifyWatchId {
|
||||
#[inline]
|
||||
unsafe fn from_glib(val: libc::c_ulong) -> NotifyWatchId {
|
||||
skip_assert_initialized!();
|
||||
assert_ne!(val, 0);
|
||||
|
@ -294,6 +296,7 @@ pub trait ElementExtManual: 'static {
|
|||
}
|
||||
|
||||
impl<O: IsA<Element>> ElementExtManual for O {
|
||||
#[inline]
|
||||
fn element_class(&self) -> &glib::Class<Element> {
|
||||
unsafe {
|
||||
let klass = (*(self.as_ptr() as *mut glib::gobject_ffi::GTypeInstance)).g_class
|
||||
|
|
|
@ -60,6 +60,7 @@ bitflags! {
|
|||
impl IntoGlib for ElementFactoryType {
|
||||
type GlibType = ffi::GstElementFactoryListType;
|
||||
|
||||
#[inline]
|
||||
fn into_glib(self) -> ffi::GstElementFactoryListType {
|
||||
self.bits()
|
||||
}
|
||||
|
@ -67,6 +68,7 @@ impl IntoGlib for ElementFactoryType {
|
|||
|
||||
#[doc(hidden)]
|
||||
impl FromGlib<ffi::GstElementFactoryListType> for ElementFactoryType {
|
||||
#[inline]
|
||||
unsafe fn from_glib(value: ffi::GstElementFactoryListType) -> ElementFactoryType {
|
||||
skip_assert_initialized!();
|
||||
ElementFactoryType::from_bits_truncate(value)
|
||||
|
|
|
@ -14,6 +14,7 @@ use crate::{ClockReturn, FlowReturn, PadLinkReturn, State, StateChange, StateCha
|
|||
macro_rules! impl_return_result_traits {
|
||||
($ffi_type:ident, $ret_type:ident, $ok_type:ident, $err_type:ident) => {
|
||||
impl From<$ok_type> for $ret_type {
|
||||
#[inline]
|
||||
fn from(value: $ok_type) -> Self {
|
||||
skip_assert_initialized!();
|
||||
$ret_type::from_ok(value)
|
||||
|
@ -23,12 +24,14 @@ macro_rules! impl_return_result_traits {
|
|||
impl IntoGlib for $ok_type {
|
||||
type GlibType = <$ret_type as IntoGlib>::GlibType;
|
||||
|
||||
#[inline]
|
||||
fn into_glib(self) -> Self::GlibType {
|
||||
$ret_type::from_ok(self).into_glib()
|
||||
}
|
||||
}
|
||||
|
||||
impl From<$err_type> for $ret_type {
|
||||
#[inline]
|
||||
fn from(value: $err_type) -> Self {
|
||||
skip_assert_initialized!();
|
||||
$ret_type::from_error(value)
|
||||
|
@ -38,12 +41,14 @@ macro_rules! impl_return_result_traits {
|
|||
impl IntoGlib for $err_type {
|
||||
type GlibType = <$ret_type as IntoGlib>::GlibType;
|
||||
|
||||
#[inline]
|
||||
fn into_glib(self) -> Self::GlibType {
|
||||
$ret_type::from_error(self).into_glib()
|
||||
}
|
||||
}
|
||||
|
||||
impl From<Result<$ok_type, $err_type>> for $ret_type {
|
||||
#[inline]
|
||||
fn from(res: Result<$ok_type, $err_type>) -> Self {
|
||||
skip_assert_initialized!();
|
||||
match res {
|
||||
|
@ -55,6 +60,8 @@ macro_rules! impl_return_result_traits {
|
|||
|
||||
impl TryFromGlib<ffi::$ffi_type> for $ok_type {
|
||||
type Error = $err_type;
|
||||
|
||||
#[inline]
|
||||
unsafe fn try_from_glib(val: ffi::$ffi_type) -> Result<$ok_type, $err_type> {
|
||||
skip_assert_initialized!();
|
||||
$ret_type::from_glib(val).into_result()
|
||||
|
@ -64,6 +71,7 @@ macro_rules! impl_return_result_traits {
|
|||
}
|
||||
|
||||
impl StateChangeReturn {
|
||||
#[inline]
|
||||
pub fn into_result(self) -> Result<StateChangeSuccess, StateChangeError> {
|
||||
match self {
|
||||
StateChangeReturn::Success => Ok(StateChangeSuccess::Success),
|
||||
|
@ -74,11 +82,13 @@ impl StateChangeReturn {
|
|||
}
|
||||
}
|
||||
|
||||
#[inline]
|
||||
pub fn from_error(_: StateChangeError) -> Self {
|
||||
skip_assert_initialized!();
|
||||
StateChangeReturn::Failure
|
||||
}
|
||||
|
||||
#[inline]
|
||||
pub fn from_ok(v: StateChangeSuccess) -> Self {
|
||||
skip_assert_initialized!();
|
||||
match v {
|
||||
|
@ -109,6 +119,7 @@ impl_return_result_traits!(
|
|||
);
|
||||
|
||||
impl FlowReturn {
|
||||
#[inline]
|
||||
pub fn into_result(self) -> Result<FlowSuccess, FlowError> {
|
||||
match self {
|
||||
FlowReturn::CustomSuccess2 => Ok(FlowSuccess::CustomSuccess2),
|
||||
|
@ -128,6 +139,7 @@ impl FlowReturn {
|
|||
}
|
||||
}
|
||||
|
||||
#[inline]
|
||||
pub fn from_error(v: FlowError) -> Self {
|
||||
skip_assert_initialized!();
|
||||
match v {
|
||||
|
@ -143,6 +155,7 @@ impl FlowReturn {
|
|||
}
|
||||
}
|
||||
|
||||
#[inline]
|
||||
pub fn from_ok(v: FlowSuccess) -> Self {
|
||||
skip_assert_initialized!();
|
||||
match v {
|
||||
|
@ -188,6 +201,7 @@ pub enum FlowError {
|
|||
impl_return_result_traits!(GstFlowReturn, FlowReturn, FlowSuccess, FlowError);
|
||||
|
||||
impl PadLinkReturn {
|
||||
#[inline]
|
||||
pub fn into_result(self) -> Result<PadLinkSuccess, PadLinkError> {
|
||||
match self {
|
||||
PadLinkReturn::Ok => Ok(PadLinkSuccess),
|
||||
|
@ -201,6 +215,7 @@ impl PadLinkReturn {
|
|||
}
|
||||
}
|
||||
|
||||
#[inline]
|
||||
pub fn from_error(v: PadLinkError) -> Self {
|
||||
skip_assert_initialized!();
|
||||
match v {
|
||||
|
@ -213,6 +228,7 @@ impl PadLinkReturn {
|
|||
}
|
||||
}
|
||||
|
||||
#[inline]
|
||||
pub fn from_ok(_: PadLinkSuccess) -> Self {
|
||||
skip_assert_initialized!();
|
||||
PadLinkReturn::Ok
|
||||
|
@ -247,6 +263,7 @@ impl_return_result_traits!(
|
|||
);
|
||||
|
||||
impl ClockReturn {
|
||||
#[inline]
|
||||
pub fn into_result(self) -> Result<ClockSuccess, ClockError> {
|
||||
match self {
|
||||
ClockReturn::Ok => Ok(ClockSuccess::Ok),
|
||||
|
@ -261,6 +278,7 @@ impl ClockReturn {
|
|||
}
|
||||
}
|
||||
|
||||
#[inline]
|
||||
pub fn from_error(v: ClockError) -> Self {
|
||||
skip_assert_initialized!();
|
||||
match v {
|
||||
|
@ -273,6 +291,7 @@ impl ClockReturn {
|
|||
}
|
||||
}
|
||||
|
||||
#[inline]
|
||||
pub fn from_ok(v: ClockSuccess) -> Self {
|
||||
skip_assert_initialized!();
|
||||
match v {
|
||||
|
@ -308,6 +327,7 @@ pub enum ClockError {
|
|||
impl_return_result_traits!(GstClockReturn, ClockReturn, ClockSuccess, ClockError);
|
||||
|
||||
impl PartialEq for crate::TypeFindProbability {
|
||||
#[inline]
|
||||
fn eq(&self, other: &crate::TypeFindProbability) -> bool {
|
||||
(self.into_glib() as u32).eq(&(other.into_glib() as u32))
|
||||
}
|
||||
|
@ -316,12 +336,14 @@ impl PartialEq for crate::TypeFindProbability {
|
|||
impl Eq for crate::TypeFindProbability {}
|
||||
|
||||
impl PartialOrd for crate::TypeFindProbability {
|
||||
#[inline]
|
||||
fn partial_cmp(&self, other: &Self) -> Option<cmp::Ordering> {
|
||||
(self.into_glib() as u32).partial_cmp(&(other.into_glib() as u32))
|
||||
}
|
||||
}
|
||||
|
||||
impl Ord for crate::TypeFindProbability {
|
||||
#[inline]
|
||||
fn cmp(&self, other: &Self) -> cmp::Ordering {
|
||||
(self.into_glib() as u32).cmp(&(other.into_glib() as u32))
|
||||
}
|
||||
|
@ -330,6 +352,7 @@ impl Ord for crate::TypeFindProbability {
|
|||
impl ops::Add<u32> for crate::TypeFindProbability {
|
||||
type Output = crate::TypeFindProbability;
|
||||
|
||||
#[inline]
|
||||
fn add(self, rhs: u32) -> crate::TypeFindProbability {
|
||||
let res = (self.into_glib() as u32).saturating_add(rhs);
|
||||
unsafe { from_glib(res as i32) }
|
||||
|
@ -337,6 +360,7 @@ impl ops::Add<u32> for crate::TypeFindProbability {
|
|||
}
|
||||
|
||||
impl ops::AddAssign<u32> for crate::TypeFindProbability {
|
||||
#[inline]
|
||||
fn add_assign(&mut self, rhs: u32) {
|
||||
let res = (self.into_glib() as u32).saturating_add(rhs);
|
||||
*self = unsafe { from_glib(res as i32) };
|
||||
|
@ -346,6 +370,7 @@ impl ops::AddAssign<u32> for crate::TypeFindProbability {
|
|||
impl ops::Sub<u32> for crate::TypeFindProbability {
|
||||
type Output = crate::TypeFindProbability;
|
||||
|
||||
#[inline]
|
||||
fn sub(self, rhs: u32) -> crate::TypeFindProbability {
|
||||
let res = (self.into_glib() as u32).saturating_sub(rhs);
|
||||
unsafe { from_glib(res as i32) }
|
||||
|
@ -353,6 +378,7 @@ impl ops::Sub<u32> for crate::TypeFindProbability {
|
|||
}
|
||||
|
||||
impl ops::SubAssign<u32> for crate::TypeFindProbability {
|
||||
#[inline]
|
||||
fn sub_assign(&mut self, rhs: u32) {
|
||||
let res = (self.into_glib() as u32).saturating_sub(rhs);
|
||||
*self = unsafe { from_glib(res as i32) };
|
||||
|
@ -360,6 +386,7 @@ impl ops::SubAssign<u32> for crate::TypeFindProbability {
|
|||
}
|
||||
|
||||
impl PartialEq for crate::Rank {
|
||||
#[inline]
|
||||
fn eq(&self, other: &crate::Rank) -> bool {
|
||||
(self.into_glib() as u32).eq(&(other.into_glib() as u32))
|
||||
}
|
||||
|
@ -368,12 +395,14 @@ impl PartialEq for crate::Rank {
|
|||
impl Eq for crate::Rank {}
|
||||
|
||||
impl PartialOrd for crate::Rank {
|
||||
#[inline]
|
||||
fn partial_cmp(&self, other: &Self) -> Option<cmp::Ordering> {
|
||||
(self.into_glib() as u32).partial_cmp(&(other.into_glib() as u32))
|
||||
}
|
||||
}
|
||||
|
||||
impl Ord for crate::Rank {
|
||||
#[inline]
|
||||
fn cmp(&self, other: &Self) -> cmp::Ordering {
|
||||
(self.into_glib() as u32).cmp(&(other.into_glib() as u32))
|
||||
}
|
||||
|
@ -382,6 +411,7 @@ impl Ord for crate::Rank {
|
|||
impl ops::Add<u32> for crate::Rank {
|
||||
type Output = crate::Rank;
|
||||
|
||||
#[inline]
|
||||
fn add(self, rhs: u32) -> crate::Rank {
|
||||
let res = (self.into_glib() as u32).saturating_add(rhs);
|
||||
unsafe { from_glib(res as i32) }
|
||||
|
@ -389,6 +419,7 @@ impl ops::Add<u32> for crate::Rank {
|
|||
}
|
||||
|
||||
impl ops::AddAssign<u32> for crate::Rank {
|
||||
#[inline]
|
||||
fn add_assign(&mut self, rhs: u32) {
|
||||
let res = (self.into_glib() as u32).saturating_add(rhs);
|
||||
*self = unsafe { from_glib(res as i32) };
|
||||
|
@ -398,6 +429,7 @@ impl ops::AddAssign<u32> for crate::Rank {
|
|||
impl ops::Sub<u32> for crate::Rank {
|
||||
type Output = crate::Rank;
|
||||
|
||||
#[inline]
|
||||
fn sub(self, rhs: u32) -> crate::Rank {
|
||||
let res = (self.into_glib() as u32).saturating_sub(rhs);
|
||||
unsafe { from_glib(res as i32) }
|
||||
|
@ -405,6 +437,7 @@ impl ops::Sub<u32> for crate::Rank {
|
|||
}
|
||||
|
||||
impl ops::SubAssign<u32> for crate::Rank {
|
||||
#[inline]
|
||||
fn sub_assign(&mut self, rhs: u32) {
|
||||
let res = (self.into_glib() as u32).saturating_sub(rhs);
|
||||
*self = unsafe { from_glib(res as i32) };
|
||||
|
@ -606,6 +639,7 @@ impl FromGlib<ffi::GstMessageType> for MessageType {
|
|||
}
|
||||
|
||||
impl StaticType for MessageType {
|
||||
#[inline]
|
||||
fn static_type() -> Type {
|
||||
unsafe { from_glib(ffi::gst_message_type_get_type()) }
|
||||
}
|
||||
|
@ -618,6 +652,7 @@ impl glib::value::ValueType for MessageType {
|
|||
unsafe impl<'a> FromValue<'a> for MessageType {
|
||||
type Checker = glib::value::GenericValueTypeChecker<Self>;
|
||||
|
||||
#[inline]
|
||||
unsafe fn from_value(value: &glib::Value) -> Self {
|
||||
skip_assert_initialized!();
|
||||
from_glib(glib::gobject_ffi::g_value_get_enum(value.to_glib_none().0) as ffi::GstMessageType)
|
||||
|
@ -625,6 +660,7 @@ unsafe impl<'a> FromValue<'a> for MessageType {
|
|||
}
|
||||
|
||||
impl ToValue for MessageType {
|
||||
#[inline]
|
||||
fn to_value(&self) -> Value {
|
||||
let mut value = glib::Value::for_value_type::<Self>();
|
||||
unsafe {
|
||||
|
@ -633,12 +669,14 @@ impl ToValue for MessageType {
|
|||
value
|
||||
}
|
||||
|
||||
#[inline]
|
||||
fn value_type(&self) -> Type {
|
||||
Self::static_type()
|
||||
}
|
||||
}
|
||||
|
||||
impl From<MessageType> for glib::Value {
|
||||
#[inline]
|
||||
fn from(v: MessageType) -> glib::Value {
|
||||
skip_assert_initialized!();
|
||||
ToValue::to_value(&v)
|
||||
|
@ -647,6 +685,7 @@ impl From<MessageType> for glib::Value {
|
|||
|
||||
impl State {
|
||||
#[must_use]
|
||||
#[inline]
|
||||
pub fn next(self, pending: Self) -> Self {
|
||||
let current = self.into_glib();
|
||||
let pending = pending.into_glib();
|
||||
|
@ -658,6 +697,7 @@ impl State {
|
|||
}
|
||||
|
||||
impl StateChange {
|
||||
#[inline]
|
||||
pub fn new(current: State, next: State) -> Self {
|
||||
skip_assert_initialized!();
|
||||
let current = current.into_glib();
|
||||
|
@ -665,6 +705,7 @@ impl StateChange {
|
|||
unsafe { from_glib((current << 3) | next) }
|
||||
}
|
||||
|
||||
#[inline]
|
||||
pub fn current(self) -> State {
|
||||
match self {
|
||||
StateChange::NullToReady => State::Null,
|
||||
|
@ -681,6 +722,7 @@ impl StateChange {
|
|||
}
|
||||
}
|
||||
|
||||
#[inline]
|
||||
pub fn next(self) -> State {
|
||||
match self {
|
||||
StateChange::NullToReady => State::Ready,
|
||||
|
|
|
@ -20,6 +20,7 @@ pub struct Seqnum(pub(crate) NonZeroU32);
|
|||
|
||||
impl Seqnum {
|
||||
#[doc(alias = "gst_util_seqnum_next")]
|
||||
#[inline]
|
||||
pub fn next() -> Self {
|
||||
unsafe {
|
||||
let v = ffi::gst_util_seqnum_next();
|
||||
|
@ -35,18 +36,21 @@ impl Seqnum {
|
|||
impl IntoGlib for Seqnum {
|
||||
type GlibType = u32;
|
||||
|
||||
#[inline]
|
||||
fn into_glib(self) -> u32 {
|
||||
self.0.get()
|
||||
}
|
||||
}
|
||||
|
||||
impl cmp::PartialOrd for Seqnum {
|
||||
#[inline]
|
||||
fn partial_cmp(&self, other: &Seqnum) -> Option<cmp::Ordering> {
|
||||
Some(self.cmp(other))
|
||||
}
|
||||
}
|
||||
|
||||
impl cmp::Ord for Seqnum {
|
||||
#[inline]
|
||||
fn cmp(&self, other: &Seqnum) -> cmp::Ordering {
|
||||
unsafe {
|
||||
let ret = ffi::gst_util_seqnum_compare(self.0.get(), other.0.get());
|
||||
|
@ -60,6 +64,7 @@ pub struct GroupId(pub(crate) NonZeroU32);
|
|||
|
||||
impl GroupId {
|
||||
#[doc(alias = "gst_util_group_id_next")]
|
||||
#[inline]
|
||||
pub fn next() -> Self {
|
||||
unsafe {
|
||||
let v = ffi::gst_util_group_id_next();
|
||||
|
@ -74,26 +79,31 @@ impl GroupId {
|
|||
|
||||
impl EventType {
|
||||
#[doc(alias = "GST_EVENT_IS_UPSTREAM")]
|
||||
#[inline]
|
||||
pub fn is_upstream(self) -> bool {
|
||||
(self.into_glib() as u32) & ffi::GST_EVENT_TYPE_UPSTREAM != 0
|
||||
}
|
||||
|
||||
#[doc(alias = "GST_EVENT_IS_DOWNSTREAM")]
|
||||
#[inline]
|
||||
pub fn is_downstream(self) -> bool {
|
||||
(self.into_glib() as u32) & ffi::GST_EVENT_TYPE_DOWNSTREAM != 0
|
||||
}
|
||||
|
||||
#[doc(alias = "GST_EVENT_IS_SERIALIZED")]
|
||||
#[inline]
|
||||
pub fn is_serialized(self) -> bool {
|
||||
(self.into_glib() as u32) & ffi::GST_EVENT_TYPE_SERIALIZED != 0
|
||||
}
|
||||
|
||||
#[doc(alias = "GST_EVENT_IS_STICKY")]
|
||||
#[inline]
|
||||
pub fn is_sticky(self) -> bool {
|
||||
(self.into_glib() as u32) & ffi::GST_EVENT_TYPE_STICKY != 0
|
||||
}
|
||||
|
||||
#[doc(alias = "GST_EVENT_IS_STICKY_MULTI")]
|
||||
#[inline]
|
||||
pub fn is_sticky_multi(self) -> bool {
|
||||
(self.into_glib() as u32) & ffi::GST_EVENT_TYPE_STICKY_MULTI != 0
|
||||
}
|
||||
|
@ -165,6 +175,7 @@ impl EventRef {
|
|||
|
||||
#[doc(alias = "get_structure")]
|
||||
#[doc(alias = "gst_event_get_structure")]
|
||||
#[inline]
|
||||
pub fn structure(&self) -> Option<&StructureRef> {
|
||||
unsafe {
|
||||
let structure = ffi::gst_event_get_structure(self.as_mut_ptr());
|
||||
|
@ -177,6 +188,7 @@ impl EventRef {
|
|||
}
|
||||
|
||||
#[doc(alias = "gst_event_writable_structure")]
|
||||
#[inline]
|
||||
pub fn structure_mut(&mut self) -> &mut StructureRef {
|
||||
unsafe {
|
||||
StructureRef::from_glib_borrow_mut(ffi::gst_event_writable_structure(self.as_mut_ptr()))
|
||||
|
@ -184,37 +196,44 @@ impl EventRef {
|
|||
}
|
||||
|
||||
#[doc(alias = "GST_EVENT_IS_UPSTREAM")]
|
||||
#[inline]
|
||||
pub fn is_upstream(&self) -> bool {
|
||||
self.type_().is_upstream()
|
||||
}
|
||||
|
||||
#[doc(alias = "GST_EVENT_IS_DOWNSTREAM")]
|
||||
#[inline]
|
||||
pub fn is_downstream(&self) -> bool {
|
||||
self.type_().is_downstream()
|
||||
}
|
||||
|
||||
#[doc(alias = "GST_EVENT_IS_SERIALIZED")]
|
||||
#[inline]
|
||||
pub fn is_serialized(&self) -> bool {
|
||||
self.type_().is_serialized()
|
||||
}
|
||||
|
||||
#[doc(alias = "GST_EVENT_IS_STICKY")]
|
||||
#[inline]
|
||||
pub fn is_sticky(&self) -> bool {
|
||||
self.type_().is_sticky()
|
||||
}
|
||||
|
||||
#[doc(alias = "GST_EVENT_IS_STICKY_MULTI")]
|
||||
#[inline]
|
||||
pub fn is_sticky_multi(&self) -> bool {
|
||||
self.type_().is_sticky_multi()
|
||||
}
|
||||
|
||||
#[doc(alias = "get_type")]
|
||||
#[doc(alias = "GST_EVENT_TYPE")]
|
||||
#[inline]
|
||||
pub fn type_(&self) -> EventType {
|
||||
unsafe { from_glib((*self.as_ptr()).type_) }
|
||||
}
|
||||
|
||||
#[doc(alias = "gst_event_has_name")]
|
||||
#[inline]
|
||||
pub fn has_name(&self, name: &str) -> bool {
|
||||
self.structure().map_or(false, |s| s.has_name(name))
|
||||
}
|
||||
|
@ -334,6 +353,7 @@ macro_rules! declare_concrete_event {
|
|||
impl StickyEventType for $name {
|
||||
const TYPE: EventType = EventType::$name;
|
||||
|
||||
#[inline]
|
||||
unsafe fn from_event(event: Event) -> Self::Owned {
|
||||
$name::<Event>(event)
|
||||
}
|
||||
|
@ -345,10 +365,12 @@ macro_rules! declare_concrete_event {
|
|||
pub struct $name<$param = EventRef>($param);
|
||||
|
||||
impl $name {
|
||||
#[inline]
|
||||
pub fn event(&self) -> &EventRef {
|
||||
unsafe { &*(self as *const Self as *const EventRef) }
|
||||
}
|
||||
|
||||
#[inline]
|
||||
unsafe fn view(event: &EventRef) -> EventView<'_> {
|
||||
let event = &*(event as *const EventRef as *const Self);
|
||||
EventView::$name(event)
|
||||
|
@ -358,6 +380,7 @@ macro_rules! declare_concrete_event {
|
|||
impl Deref for $name {
|
||||
type Target = EventRef;
|
||||
|
||||
#[inline]
|
||||
fn deref(&self) -> &Self::Target {
|
||||
self.event()
|
||||
}
|
||||
|
@ -366,12 +389,14 @@ macro_rules! declare_concrete_event {
|
|||
impl ToOwned for $name {
|
||||
type Owned = $name<Event>;
|
||||
|
||||
#[inline]
|
||||
fn to_owned(&self) -> Self::Owned {
|
||||
$name::<Event>(self.copy())
|
||||
}
|
||||
}
|
||||
|
||||
impl $name<Event> {
|
||||
#[inline]
|
||||
pub fn get_mut(&mut self) -> Option<&mut $name> {
|
||||
self.0
|
||||
.get_mut()
|
||||
|
@ -382,18 +407,21 @@ macro_rules! declare_concrete_event {
|
|||
impl Deref for $name<Event> {
|
||||
type Target = $name;
|
||||
|
||||
#[inline]
|
||||
fn deref(&self) -> &Self::Target {
|
||||
unsafe { &*(self.0.as_ptr() as *const Self::Target) }
|
||||
}
|
||||
}
|
||||
|
||||
impl Borrow<$name> for $name<Event> {
|
||||
#[inline]
|
||||
fn borrow(&self) -> &$name {
|
||||
&*self
|
||||
}
|
||||
}
|
||||
|
||||
impl From<$name<Event>> for Event {
|
||||
#[inline]
|
||||
fn from(concrete: $name<Event>) -> Self {
|
||||
skip_assert_initialized!();
|
||||
concrete.0
|
||||
|
|
|
@ -29,26 +29,32 @@ impl ClockTime {
|
|||
// checker-ignore-item
|
||||
pub const MAX: ClockTime = ClockTime(ffi::GST_CLOCK_TIME_NONE - 1);
|
||||
|
||||
#[inline]
|
||||
pub const fn hours(self) -> u64 {
|
||||
self.0 / Self::SECOND.0 / 60 / 60
|
||||
}
|
||||
|
||||
#[inline]
|
||||
pub const fn minutes(self) -> u64 {
|
||||
self.0 / Self::SECOND.0 / 60
|
||||
}
|
||||
|
||||
#[inline]
|
||||
pub const fn seconds(self) -> u64 {
|
||||
self.0 / Self::SECOND.0
|
||||
}
|
||||
|
||||
#[inline]
|
||||
pub const fn mseconds(self) -> u64 {
|
||||
self.0 / Self::MSECOND.0
|
||||
}
|
||||
|
||||
#[inline]
|
||||
pub const fn useconds(self) -> u64 {
|
||||
self.0 / Self::USECOND.0
|
||||
}
|
||||
|
||||
#[inline]
|
||||
pub const fn nseconds(self) -> u64 {
|
||||
self.0
|
||||
}
|
||||
|
@ -60,6 +66,7 @@ impl ClockTime {
|
|||
///
|
||||
/// Panics if the resulting duration in nanoseconds exceeds the `u64` range.
|
||||
#[track_caller]
|
||||
#[inline]
|
||||
pub const fn from_seconds(seconds: u64) -> Self {
|
||||
skip_assert_initialized!();
|
||||
// `Option::expect` is not `const` as of rustc 1.63.0.
|
||||
|
@ -76,6 +83,7 @@ impl ClockTime {
|
|||
///
|
||||
/// Panics if the resulting duration in nanoseconds exceeds the `u64` range.
|
||||
#[track_caller]
|
||||
#[inline]
|
||||
pub const fn from_mseconds(mseconds: u64) -> Self {
|
||||
skip_assert_initialized!();
|
||||
// `Option::expect` is not `const` as of rustc 1.63.0.
|
||||
|
@ -92,6 +100,7 @@ impl ClockTime {
|
|||
///
|
||||
/// Panics if the resulting duration in nanoseconds exceeds the `u64` range.
|
||||
#[track_caller]
|
||||
#[inline]
|
||||
pub const fn from_useconds(useconds: u64) -> Self {
|
||||
skip_assert_initialized!();
|
||||
// `Option::expect` is not `const` as of rustc 1.63.0.
|
||||
|
@ -109,6 +118,7 @@ impl ClockTime {
|
|||
/// Panics if the requested duration equals `GST_CLOCK_TIME_NONE`
|
||||
/// (`u64::MAX`).
|
||||
#[track_caller]
|
||||
#[inline]
|
||||
pub const fn from_nseconds(nseconds: u64) -> Self {
|
||||
skip_assert_initialized!();
|
||||
assert!(
|
||||
|
@ -122,6 +132,7 @@ impl ClockTime {
|
|||
impl Signed<ClockTime> {
|
||||
// rustdoc-stripper-ignore-next
|
||||
/// Returns the `self` in nanoseconds.
|
||||
#[inline]
|
||||
pub fn nseconds(self) -> Signed<u64> {
|
||||
match self {
|
||||
Signed::Positive(val) => Signed::Positive(val.nseconds()),
|
||||
|
@ -131,6 +142,7 @@ impl Signed<ClockTime> {
|
|||
|
||||
// rustdoc-stripper-ignore-next
|
||||
/// Creates new value from nanoseconds.
|
||||
#[inline]
|
||||
pub fn from_nseconds(val: Signed<u64>) -> Self {
|
||||
skip_assert_initialized!();
|
||||
match val {
|
||||
|
@ -141,6 +153,7 @@ impl Signed<ClockTime> {
|
|||
|
||||
// rustdoc-stripper-ignore-next
|
||||
/// Returns the `self` in microseconds.
|
||||
#[inline]
|
||||
pub fn useconds(self) -> Signed<u64> {
|
||||
match self {
|
||||
Signed::Positive(val) => Signed::Positive(val.useconds()),
|
||||
|
@ -150,6 +163,7 @@ impl Signed<ClockTime> {
|
|||
|
||||
// rustdoc-stripper-ignore-next
|
||||
/// Creates new value from microseconds.
|
||||
#[inline]
|
||||
pub fn from_useconds(val: Signed<u64>) -> Self {
|
||||
skip_assert_initialized!();
|
||||
match val {
|
||||
|
@ -160,6 +174,7 @@ impl Signed<ClockTime> {
|
|||
|
||||
// rustdoc-stripper-ignore-next
|
||||
/// Returns the `self` in milliseconds.
|
||||
#[inline]
|
||||
pub fn mseconds(self) -> Signed<u64> {
|
||||
match self {
|
||||
Signed::Positive(val) => Signed::Positive(val.mseconds()),
|
||||
|
@ -169,6 +184,7 @@ impl Signed<ClockTime> {
|
|||
|
||||
// rustdoc-stripper-ignore-next
|
||||
/// Creates new value from milliseconds.
|
||||
#[inline]
|
||||
pub fn from_mseconds(val: Signed<u64>) -> Self {
|
||||
skip_assert_initialized!();
|
||||
match val {
|
||||
|
@ -179,6 +195,7 @@ impl Signed<ClockTime> {
|
|||
|
||||
// rustdoc-stripper-ignore-next
|
||||
/// Returns the `self` in seconds.
|
||||
#[inline]
|
||||
pub fn seconds(self) -> Signed<u64> {
|
||||
match self {
|
||||
Signed::Positive(val) => Signed::Positive(val.seconds()),
|
||||
|
@ -188,6 +205,7 @@ impl Signed<ClockTime> {
|
|||
|
||||
// rustdoc-stripper-ignore-next
|
||||
/// Creates new value from seconds.
|
||||
#[inline]
|
||||
pub fn from_seconds(val: Signed<u64>) -> Self {
|
||||
skip_assert_initialized!();
|
||||
match val {
|
||||
|
@ -231,31 +249,37 @@ pub trait TimeFormatConstructor {
|
|||
|
||||
impl TimeFormatConstructor for u64 {
|
||||
#[track_caller]
|
||||
#[inline]
|
||||
fn nseconds(self) -> ClockTime {
|
||||
ClockTime::from_nseconds(self)
|
||||
}
|
||||
|
||||
#[track_caller]
|
||||
#[inline]
|
||||
fn useconds(self) -> ClockTime {
|
||||
ClockTime::from_useconds(self)
|
||||
}
|
||||
|
||||
#[track_caller]
|
||||
#[inline]
|
||||
fn mseconds(self) -> ClockTime {
|
||||
ClockTime::from_mseconds(self)
|
||||
}
|
||||
|
||||
#[track_caller]
|
||||
#[inline]
|
||||
fn seconds(self) -> ClockTime {
|
||||
ClockTime::from_seconds(self)
|
||||
}
|
||||
|
||||
#[track_caller]
|
||||
#[inline]
|
||||
fn minutes(self) -> ClockTime {
|
||||
ClockTime::from_seconds(self * 60)
|
||||
}
|
||||
|
||||
#[track_caller]
|
||||
#[inline]
|
||||
fn hours(self) -> ClockTime {
|
||||
ClockTime::from_seconds(self * 60 * 60)
|
||||
}
|
||||
|
@ -270,6 +294,7 @@ pub enum ClockTimeValueTypeOrNoneChecker {}
|
|||
unsafe impl glib::value::ValueTypeChecker for ClockTimeValueTypeOrNoneChecker {
|
||||
type Error = glib::value::ValueTypeMismatchOrNoneError<glib::value::ValueTypeMismatchError>;
|
||||
|
||||
#[inline]
|
||||
fn check(value: &glib::Value) -> Result<(), Self::Error> {
|
||||
skip_assert_initialized!();
|
||||
glib::value::GenericValueTypeChecker::<ClockTime>::check(value)?;
|
||||
|
@ -286,6 +311,7 @@ unsafe impl glib::value::ValueTypeChecker for ClockTimeValueTypeOrNoneChecker {
|
|||
unsafe impl<'a> glib::value::FromValue<'a> for ClockTime {
|
||||
type Checker = ClockTimeValueTypeOrNoneChecker;
|
||||
|
||||
#[inline]
|
||||
unsafe fn from_value(value: &glib::Value) -> ClockTime {
|
||||
skip_assert_initialized!();
|
||||
ClockTime(glib::gobject_ffi::g_value_get_uint64(
|
||||
|
@ -295,6 +321,7 @@ unsafe impl<'a> glib::value::FromValue<'a> for ClockTime {
|
|||
}
|
||||
|
||||
impl glib::value::ToValue for ClockTime {
|
||||
#[inline]
|
||||
fn to_value(&self) -> glib::Value {
|
||||
let mut value = glib::Value::for_value_type::<ClockTime>();
|
||||
let gct = self.into_glib();
|
||||
|
@ -308,12 +335,14 @@ impl glib::value::ToValue for ClockTime {
|
|||
value
|
||||
}
|
||||
|
||||
#[inline]
|
||||
fn value_type(&self) -> glib::Type {
|
||||
Self::static_type()
|
||||
}
|
||||
}
|
||||
|
||||
impl glib::value::ToValueOptional for ClockTime {
|
||||
#[inline]
|
||||
fn to_value_optional(opt: Option<&Self>) -> glib::Value {
|
||||
skip_assert_initialized!();
|
||||
let mut value = glib::Value::for_value_type::<ClockTime>();
|
||||
|
@ -325,6 +354,7 @@ impl glib::value::ToValueOptional for ClockTime {
|
|||
}
|
||||
|
||||
impl From<ClockTime> for glib::Value {
|
||||
#[inline]
|
||||
fn from(v: ClockTime) -> glib::Value {
|
||||
glib::value::ToValue::to_value(&v)
|
||||
}
|
||||
|
@ -332,6 +362,7 @@ impl From<ClockTime> for glib::Value {
|
|||
|
||||
#[doc(hidden)]
|
||||
impl glib::StaticType for ClockTime {
|
||||
#[inline]
|
||||
fn static_type() -> glib::Type {
|
||||
<u64 as glib::StaticType>::static_type()
|
||||
}
|
||||
|
@ -351,6 +382,7 @@ impl std::error::Error for DurationError {}
|
|||
impl TryFrom<Duration> for ClockTime {
|
||||
type Error = DurationError;
|
||||
|
||||
#[inline]
|
||||
fn try_from(d: Duration) -> Result<Self, Self::Error> {
|
||||
skip_assert_initialized!();
|
||||
|
||||
|
@ -366,6 +398,7 @@ impl TryFrom<Duration> for ClockTime {
|
|||
}
|
||||
|
||||
impl From<ClockTime> for Duration {
|
||||
#[inline]
|
||||
fn from(t: ClockTime) -> Self {
|
||||
skip_assert_initialized!();
|
||||
|
||||
|
|
|
@ -113,11 +113,13 @@ where
|
|||
T: SpecificFormattedValue<FullRange = V::FullRange>,
|
||||
{
|
||||
type Original = Self;
|
||||
#[inline]
|
||||
fn try_into_checked(self, _other: V) -> Result<Self, FormattedValueError> {
|
||||
skip_assert_initialized!();
|
||||
Ok(self)
|
||||
}
|
||||
|
||||
#[inline]
|
||||
fn try_into_checked_explicit(
|
||||
self,
|
||||
_format: Format,
|
||||
|
@ -129,6 +131,7 @@ where
|
|||
|
||||
impl<T: SpecificFormattedValue> CompatibleFormattedValue<GenericFormattedValue> for T {
|
||||
type Original = Self;
|
||||
#[inline]
|
||||
fn try_into_checked(self, other: GenericFormattedValue) -> Result<Self, FormattedValueError> {
|
||||
skip_assert_initialized!();
|
||||
if self.format() == other.format() {
|
||||
|
@ -138,6 +141,7 @@ impl<T: SpecificFormattedValue> CompatibleFormattedValue<GenericFormattedValue>
|
|||
}
|
||||
}
|
||||
|
||||
#[inline]
|
||||
fn try_into_checked_explicit(
|
||||
self,
|
||||
format: Format,
|
||||
|
@ -153,6 +157,7 @@ impl<T: SpecificFormattedValue> CompatibleFormattedValue<GenericFormattedValue>
|
|||
|
||||
impl<V: SpecificFormattedValue> CompatibleFormattedValue<V> for GenericFormattedValue {
|
||||
type Original = Self;
|
||||
#[inline]
|
||||
fn try_into_checked(self, _other: V) -> Result<Self, FormattedValueError> {
|
||||
skip_assert_initialized!();
|
||||
if self.format() == V::default_format() {
|
||||
|
@ -162,6 +167,7 @@ impl<V: SpecificFormattedValue> CompatibleFormattedValue<V> for GenericFormatted
|
|||
}
|
||||
}
|
||||
|
||||
#[inline]
|
||||
fn try_into_checked_explicit(
|
||||
self,
|
||||
_format: Format,
|
||||
|
|
|
@ -23,7 +23,7 @@ macro_rules! impl_serde(
|
|||
|
||||
impl<'de> Deserialize<'de> for $t {
|
||||
fn deserialize<D: Deserializer<'de>>(deserializer: D) -> Result<Self, D::Error> {
|
||||
skip_assert_initialized!();
|
||||
skip_assert_initialized!();
|
||||
<$inner>::deserialize(deserializer)
|
||||
.and_then(|value| {
|
||||
$t::try_from(value).map_err(|_| {
|
||||
|
|
|
@ -26,6 +26,7 @@ impl Other {
|
|||
/// Panics if the provided quantity equals `u64::MAX`,
|
||||
/// which is reserved for `None` in C.
|
||||
#[track_caller]
|
||||
#[inline]
|
||||
pub const fn from_u64(quantity: u64) -> Self {
|
||||
if quantity == u64::MAX {
|
||||
panic!("`Other` value out of range");
|
||||
|
@ -42,6 +43,7 @@ impl Other {
|
|||
/// Panics if the provided quantity equals `u64::MAX`,
|
||||
/// which is reserved for `None` in C.
|
||||
#[track_caller]
|
||||
#[inline]
|
||||
pub fn from_usize(quantity: usize) -> Self {
|
||||
// FIXME can't use `try_into` in `const` (rustc 1.64.0)
|
||||
Other::from_u64(quantity.try_into().unwrap())
|
||||
|
@ -56,6 +58,7 @@ glib_newtype_display!(Other, DisplayableOptionOther);
|
|||
|
||||
impl TryFrom<u64> for Other {
|
||||
type Error = GlibNoneError;
|
||||
#[inline]
|
||||
fn try_from(val: u64) -> Result<Self, GlibNoneError> {
|
||||
skip_assert_initialized!();
|
||||
unsafe { Self::try_from_glib(val) }
|
||||
|
@ -82,6 +85,7 @@ pub trait OtherFormatConstructor {
|
|||
|
||||
impl OtherFormatConstructor for u64 {
|
||||
#[track_caller]
|
||||
#[inline]
|
||||
fn other_format(self) -> Other {
|
||||
Other::from_u64(self)
|
||||
}
|
||||
|
@ -125,6 +129,7 @@ impl Displayable for GenericFormattedValue {
|
|||
}
|
||||
|
||||
impl GenericFormattedValue {
|
||||
#[inline]
|
||||
pub fn new(format: Format, value: i64) -> Self {
|
||||
skip_assert_initialized!();
|
||||
match format {
|
||||
|
@ -139,6 +144,7 @@ impl GenericFormattedValue {
|
|||
}
|
||||
|
||||
#[doc(alias = "get_format")]
|
||||
#[inline]
|
||||
pub fn format(&self) -> Format {
|
||||
match *self {
|
||||
Self::Undefined(_) => Format::Undefined,
|
||||
|
@ -152,6 +158,7 @@ impl GenericFormattedValue {
|
|||
}
|
||||
|
||||
#[doc(alias = "get_value")]
|
||||
#[inline]
|
||||
pub fn value(&self) -> i64 {
|
||||
unsafe {
|
||||
match *self {
|
||||
|
@ -173,14 +180,17 @@ impl FormattedValue for GenericFormattedValue {
|
|||
// from the variants' inner type since they are not all `Option`s.
|
||||
type FullRange = GenericFormattedValue;
|
||||
|
||||
#[inline]
|
||||
fn default_format() -> Format {
|
||||
Format::Undefined
|
||||
}
|
||||
|
||||
#[inline]
|
||||
fn format(&self) -> Format {
|
||||
self.format()
|
||||
}
|
||||
|
||||
#[inline]
|
||||
fn is_some(&self) -> bool {
|
||||
match self {
|
||||
Self::Undefined(_) => true,
|
||||
|
@ -193,12 +203,14 @@ impl FormattedValue for GenericFormattedValue {
|
|||
}
|
||||
}
|
||||
|
||||
#[inline]
|
||||
unsafe fn into_raw_value(self) -> i64 {
|
||||
self.value()
|
||||
}
|
||||
}
|
||||
|
||||
impl FormattedValueFullRange for GenericFormattedValue {
|
||||
#[inline]
|
||||
unsafe fn from_raw(format: Format, value: i64) -> Self {
|
||||
GenericFormattedValue::new(format, value)
|
||||
}
|
||||
|
@ -217,6 +229,7 @@ impl FormattedValueNoneBuilder for GenericFormattedValue {
|
|||
}
|
||||
|
||||
#[track_caller]
|
||||
#[inline]
|
||||
fn none_for_format(format: Format) -> Self {
|
||||
skip_assert_initialized!();
|
||||
match format {
|
||||
|
@ -235,6 +248,7 @@ impl UnsignedIntoSigned for GenericFormattedValue {
|
|||
type Signed = GenericSignedFormattedValue;
|
||||
|
||||
#[track_caller]
|
||||
#[inline]
|
||||
fn into_positive(self) -> Self::Signed {
|
||||
use Signed::Positive;
|
||||
match self {
|
||||
|
@ -251,6 +265,7 @@ impl UnsignedIntoSigned for GenericFormattedValue {
|
|||
}
|
||||
|
||||
#[track_caller]
|
||||
#[inline]
|
||||
fn into_negative(self) -> Self::Signed {
|
||||
use Signed::Negative;
|
||||
match self {
|
||||
|
@ -269,6 +284,7 @@ impl UnsignedIntoSigned for GenericFormattedValue {
|
|||
|
||||
impl CompatibleFormattedValue<GenericFormattedValue> for GenericFormattedValue {
|
||||
type Original = Self;
|
||||
#[inline]
|
||||
fn try_into_checked(self, other: GenericFormattedValue) -> Result<Self, FormattedValueError> {
|
||||
skip_assert_initialized!();
|
||||
if self.format() == other.format() {
|
||||
|
@ -278,6 +294,7 @@ impl CompatibleFormattedValue<GenericFormattedValue> for GenericFormattedValue {
|
|||
}
|
||||
}
|
||||
|
||||
#[inline]
|
||||
fn try_into_checked_explicit(
|
||||
self,
|
||||
format: Format,
|
||||
|
@ -304,6 +321,7 @@ pub enum GenericSignedFormattedValue {
|
|||
|
||||
impl GenericSignedFormattedValue {
|
||||
#[doc(alias = "get_format")]
|
||||
#[inline]
|
||||
pub fn format(&self) -> Format {
|
||||
match *self {
|
||||
Self::Default(_) => Format::Default,
|
||||
|
@ -315,6 +333,7 @@ impl GenericSignedFormattedValue {
|
|||
}
|
||||
}
|
||||
|
||||
#[inline]
|
||||
pub fn abs(self) -> GenericFormattedValue {
|
||||
use GenericFormattedValue as Unsigned;
|
||||
match self {
|
||||
|
@ -327,6 +346,7 @@ impl GenericSignedFormattedValue {
|
|||
}
|
||||
}
|
||||
|
||||
#[inline]
|
||||
pub fn is_some(&self) -> bool {
|
||||
match self {
|
||||
Self::Default(v) => v.is_some(),
|
||||
|
@ -338,11 +358,13 @@ impl GenericSignedFormattedValue {
|
|||
}
|
||||
}
|
||||
|
||||
#[inline]
|
||||
pub fn is_none(&self) -> bool {
|
||||
!self.is_some()
|
||||
}
|
||||
|
||||
#[track_caller]
|
||||
#[inline]
|
||||
pub fn none_for_format(format: Format) -> Self {
|
||||
skip_assert_initialized!();
|
||||
match format {
|
||||
|
@ -361,6 +383,7 @@ impl GenericSignedFormattedValue {
|
|||
|
||||
macro_rules! impl_gsfv_fn_opt_ret(
|
||||
($fn:ident(self) -> Option<$ret_ty:ty>) => {
|
||||
#[inline]
|
||||
pub fn $fn(self) -> Option<$ret_ty> {
|
||||
match self {
|
||||
Self::Default(opt_signed) => opt_signed.map(|signed| signed.$fn()),
|
||||
|
@ -383,6 +406,7 @@ impl GenericSignedFormattedValue {
|
|||
impl std::ops::Neg for GenericSignedFormattedValue {
|
||||
type Output = Self;
|
||||
|
||||
#[inline]
|
||||
fn neg(self) -> Self {
|
||||
use std::ops::Neg;
|
||||
match self {
|
||||
|
|
|
@ -4,12 +4,14 @@ macro_rules! impl_trait_op_same(
|
|||
($typ:ty, $op:ident, $op_name:ident, $op_assign:ident, $op_assign_name:ident) => {
|
||||
impl std::ops::$op for $typ {
|
||||
type Output = Self;
|
||||
#[inline]
|
||||
fn $op_name(self, rhs: $typ) -> Self {
|
||||
Self(self.0.$op_name(rhs.0))
|
||||
}
|
||||
}
|
||||
|
||||
impl std::ops::$op_assign for $typ {
|
||||
#[inline]
|
||||
fn $op_assign_name(&mut self, rhs: $typ) {
|
||||
self.0.$op_assign_name(rhs.0)
|
||||
}
|
||||
|
@ -99,12 +101,14 @@ macro_rules! impl_trait_op_inner_type(
|
|||
($typ:ty, $inner:ty, $op:ident, $op_name:ident, $op_assign:ident, $op_assign_name:ident) => {
|
||||
impl std::ops::$op<$inner> for $typ {
|
||||
type Output = Self;
|
||||
#[inline]
|
||||
fn $op_name(self, rhs: $inner) -> Self {
|
||||
Self(self.0.$op_name(rhs))
|
||||
}
|
||||
}
|
||||
|
||||
impl std::ops::$op_assign<$inner> for $typ {
|
||||
#[inline]
|
||||
fn $op_assign_name(&mut self, rhs: $inner) {
|
||||
self.0.$op_assign_name(rhs)
|
||||
}
|
||||
|
@ -188,10 +192,12 @@ macro_rules! impl_unsigned_int_into_signed(
|
|||
impl crate::format::UnsignedIntoSigned for $typ {
|
||||
type Signed = crate::Signed<$typ>;
|
||||
|
||||
#[inline]
|
||||
fn into_positive(self) -> Self::Signed {
|
||||
crate::Signed::Positive(self)
|
||||
}
|
||||
|
||||
#[inline]
|
||||
fn into_negative(self) -> Self::Signed {
|
||||
crate::Signed::Negative(self)
|
||||
}
|
||||
|
@ -200,16 +206,19 @@ macro_rules! impl_unsigned_int_into_signed(
|
|||
impl crate::format::UnsignedIntoSigned for Option<$typ> {
|
||||
type Signed = Option<crate::Signed<$typ>>;
|
||||
|
||||
#[inline]
|
||||
fn into_positive(self) -> Self::Signed {
|
||||
Some(self?.into_positive())
|
||||
}
|
||||
|
||||
#[inline]
|
||||
fn into_negative(self) -> Self::Signed {
|
||||
Some(self?.into_negative())
|
||||
}
|
||||
}
|
||||
|
||||
impl From<$typ> for crate::Signed<$typ> {
|
||||
#[inline]
|
||||
fn from(v: $typ) -> crate::Signed<$typ> {
|
||||
crate::Signed::Positive(v)
|
||||
}
|
||||
|
@ -222,6 +231,7 @@ macro_rules! impl_unsigned_int_into_signed(
|
|||
impl crate::Signed<$typ> {
|
||||
// rustdoc-stripper-ignore-next
|
||||
/// Returns a `Signed` containing the inner type of `self`.
|
||||
#[inline]
|
||||
pub fn into_inner_signed(self) -> crate::Signed<$inner> {
|
||||
use crate::Signed::*;
|
||||
match self {
|
||||
|
@ -249,6 +259,7 @@ macro_rules! impl_common_ops_for_newtype_uint(
|
|||
pub const MAX_SIGNED: crate::Signed::<$typ> = crate::Signed::Positive(Self::MAX);
|
||||
pub const MIN_SIGNED: crate::Signed::<$typ> = crate::Signed::Negative(Self::MAX);
|
||||
|
||||
#[inline]
|
||||
pub const fn is_zero(self) -> bool {
|
||||
self.0 == Self::ZERO.0
|
||||
}
|
||||
|
@ -257,12 +268,14 @@ macro_rules! impl_common_ops_for_newtype_uint(
|
|||
impl std::ops::Deref for $typ {
|
||||
type Target = $inner;
|
||||
|
||||
#[inline]
|
||||
fn deref(&self) -> &$inner {
|
||||
&self.0
|
||||
}
|
||||
}
|
||||
|
||||
impl AsRef<$inner> for $typ {
|
||||
#[inline]
|
||||
fn as_ref(&self) -> &$inner {
|
||||
&self.0
|
||||
}
|
||||
|
@ -272,12 +285,14 @@ macro_rules! impl_common_ops_for_newtype_uint(
|
|||
impl_trait_op_same!($typ, Sub, sub, SubAssign, sub_assign);
|
||||
impl std::ops::Div for $typ {
|
||||
type Output = $inner;
|
||||
#[inline]
|
||||
fn div(self, rhs: $typ) -> $inner {
|
||||
self.0.div(rhs.0)
|
||||
}
|
||||
}
|
||||
impl std::ops::Rem for $typ {
|
||||
type Output = Self;
|
||||
#[inline]
|
||||
fn rem(self, rhs: Self) -> Self {
|
||||
Self(self.0.rem(rhs.0))
|
||||
}
|
||||
|
@ -288,6 +303,7 @@ macro_rules! impl_common_ops_for_newtype_uint(
|
|||
impl_trait_op_inner_type!($typ, $inner, Mul, mul, MulAssign, mul_assign);
|
||||
impl std::ops::Mul<$typ> for $inner {
|
||||
type Output = $typ;
|
||||
#[inline]
|
||||
fn mul(self, rhs: $typ) -> $typ {
|
||||
rhs.mul(self)
|
||||
}
|
||||
|
@ -305,18 +321,21 @@ macro_rules! impl_common_ops_for_newtype_uint(
|
|||
impl muldiv::MulDiv<$inner> for $typ {
|
||||
type Output = Self;
|
||||
|
||||
#[inline]
|
||||
fn mul_div_floor(self, num: $inner, denom: $inner) -> Option<Self> {
|
||||
self.0
|
||||
.mul_div_floor(num, denom)
|
||||
.map(Self)
|
||||
}
|
||||
|
||||
#[inline]
|
||||
fn mul_div_round(self, num: $inner, denom: $inner) -> Option<Self> {
|
||||
self.0
|
||||
.mul_div_round(num, denom)
|
||||
.map(Self)
|
||||
}
|
||||
|
||||
#[inline]
|
||||
fn mul_div_ceil(self, num: $inner, denom: $inner) -> Option<Self> {
|
||||
self.0
|
||||
.mul_div_ceil(num, denom)
|
||||
|
@ -328,6 +347,7 @@ macro_rules! impl_common_ops_for_newtype_uint(
|
|||
|
||||
impl opt_ops::OptionCheckedAdd for $typ {
|
||||
type Output = Self;
|
||||
#[inline]
|
||||
fn opt_checked_add(
|
||||
self,
|
||||
rhs: Self,
|
||||
|
@ -340,6 +360,7 @@ macro_rules! impl_common_ops_for_newtype_uint(
|
|||
|
||||
impl opt_ops::OptionSaturatingAdd for $typ {
|
||||
type Output = Self;
|
||||
#[inline]
|
||||
fn opt_saturating_add(self, rhs: Self) -> Option<Self> {
|
||||
Some(self.saturating_add(rhs))
|
||||
}
|
||||
|
@ -347,6 +368,7 @@ macro_rules! impl_common_ops_for_newtype_uint(
|
|||
|
||||
impl opt_ops::OptionOverflowingAdd for $typ {
|
||||
type Output = Self;
|
||||
#[inline]
|
||||
fn opt_overflowing_add(self, rhs: Self) -> Option<(Self, bool)> {
|
||||
let res = self.overflowing_add(rhs);
|
||||
Some((res.0, res.1))
|
||||
|
@ -355,6 +377,7 @@ macro_rules! impl_common_ops_for_newtype_uint(
|
|||
|
||||
impl opt_ops::OptionWrappingAdd for $typ {
|
||||
type Output = Self;
|
||||
#[inline]
|
||||
fn opt_wrapping_add(self, rhs: Self) -> Option<Self> {
|
||||
Some(self.wrapping_add(rhs))
|
||||
}
|
||||
|
@ -362,6 +385,7 @@ macro_rules! impl_common_ops_for_newtype_uint(
|
|||
|
||||
impl opt_ops::OptionCheckedDiv<$inner> for $typ {
|
||||
type Output = Self;
|
||||
#[inline]
|
||||
fn opt_checked_div(self, rhs: $inner) -> Result<Option<Self>, opt_ops::Error> {
|
||||
if rhs == 0 {
|
||||
return Err(opt_ops::Error::DivisionByZero);
|
||||
|
@ -375,6 +399,7 @@ macro_rules! impl_common_ops_for_newtype_uint(
|
|||
|
||||
impl opt_ops::OptionCheckedDiv for $typ {
|
||||
type Output = $inner;
|
||||
#[inline]
|
||||
fn opt_checked_div(self, rhs: Self) -> Result<Option<$inner>, opt_ops::Error> {
|
||||
if rhs.0 == 0 {
|
||||
return Err(opt_ops::Error::DivisionByZero);
|
||||
|
@ -388,6 +413,7 @@ macro_rules! impl_common_ops_for_newtype_uint(
|
|||
|
||||
impl opt_ops::OptionCheckedMul<$inner> for $typ {
|
||||
type Output = Self;
|
||||
#[inline]
|
||||
fn opt_checked_mul(
|
||||
self,
|
||||
rhs: $inner,
|
||||
|
@ -400,6 +426,7 @@ macro_rules! impl_common_ops_for_newtype_uint(
|
|||
|
||||
impl opt_ops::OptionCheckedMul<$typ> for $inner {
|
||||
type Output = $typ;
|
||||
#[inline]
|
||||
fn opt_checked_mul(
|
||||
self,
|
||||
rhs: $typ,
|
||||
|
@ -412,6 +439,7 @@ macro_rules! impl_common_ops_for_newtype_uint(
|
|||
|
||||
impl opt_ops::OptionSaturatingMul<$inner> for $typ {
|
||||
type Output = Self;
|
||||
#[inline]
|
||||
fn opt_saturating_mul(self, rhs: $inner) -> Option<Self> {
|
||||
Some(self.saturating_mul(rhs))
|
||||
}
|
||||
|
@ -419,6 +447,7 @@ macro_rules! impl_common_ops_for_newtype_uint(
|
|||
|
||||
impl opt_ops::OptionSaturatingMul<$typ> for $inner {
|
||||
type Output = $typ;
|
||||
#[inline]
|
||||
fn opt_saturating_mul(self, rhs: $typ) -> Option<$typ> {
|
||||
Some(rhs.saturating_mul(self))
|
||||
}
|
||||
|
@ -426,6 +455,7 @@ macro_rules! impl_common_ops_for_newtype_uint(
|
|||
|
||||
impl opt_ops::OptionOverflowingMul<$inner> for $typ {
|
||||
type Output = Self;
|
||||
#[inline]
|
||||
fn opt_overflowing_mul(self, rhs: $inner) -> Option<(Self, bool)> {
|
||||
let res = self.overflowing_mul(rhs);
|
||||
Some((res.0, res.1))
|
||||
|
@ -434,6 +464,7 @@ macro_rules! impl_common_ops_for_newtype_uint(
|
|||
|
||||
impl opt_ops::OptionOverflowingMul<$typ> for $inner {
|
||||
type Output = $typ;
|
||||
#[inline]
|
||||
fn opt_overflowing_mul(self, rhs: $typ) -> Option<($typ, bool)> {
|
||||
let res = rhs.overflowing_mul(self);
|
||||
Some((res.0, res.1))
|
||||
|
@ -442,6 +473,7 @@ macro_rules! impl_common_ops_for_newtype_uint(
|
|||
|
||||
impl opt_ops::OptionWrappingMul<$inner> for $typ {
|
||||
type Output = Self;
|
||||
#[inline]
|
||||
fn opt_wrapping_mul(self, rhs: $inner) -> Option<Self> {
|
||||
Some(self.wrapping_mul(rhs))
|
||||
}
|
||||
|
@ -449,6 +481,7 @@ macro_rules! impl_common_ops_for_newtype_uint(
|
|||
|
||||
impl opt_ops::OptionWrappingMul<$typ> for $inner {
|
||||
type Output = $typ;
|
||||
#[inline]
|
||||
fn opt_wrapping_mul(self, rhs: $typ) -> Option<$typ> {
|
||||
Some(rhs.wrapping_mul(self))
|
||||
}
|
||||
|
@ -456,6 +489,7 @@ macro_rules! impl_common_ops_for_newtype_uint(
|
|||
|
||||
impl opt_ops::OptionCheckedRem<$inner> for $typ {
|
||||
type Output = Self;
|
||||
#[inline]
|
||||
fn opt_checked_rem(self, rhs: $inner) -> Result<Option<Self>, opt_ops::Error> {
|
||||
if rhs == 0 {
|
||||
return Err(opt_ops::Error::DivisionByZero);
|
||||
|
@ -468,6 +502,7 @@ macro_rules! impl_common_ops_for_newtype_uint(
|
|||
|
||||
impl opt_ops::OptionCheckedRem for $typ {
|
||||
type Output = Self;
|
||||
#[inline]
|
||||
fn opt_checked_rem(self, rhs: Self) -> Result<Option<Self>, opt_ops::Error> {
|
||||
if rhs.0 == 0 {
|
||||
return Err(opt_ops::Error::DivisionByZero);
|
||||
|
@ -480,6 +515,7 @@ macro_rules! impl_common_ops_for_newtype_uint(
|
|||
|
||||
impl opt_ops::OptionCheckedSub for $typ {
|
||||
type Output = Self;
|
||||
#[inline]
|
||||
fn opt_checked_sub(
|
||||
self,
|
||||
rhs: Self,
|
||||
|
@ -492,6 +528,7 @@ macro_rules! impl_common_ops_for_newtype_uint(
|
|||
|
||||
impl opt_ops::OptionSaturatingSub for $typ {
|
||||
type Output = Self;
|
||||
#[inline]
|
||||
fn opt_saturating_sub(self, rhs: Self) -> Option<Self> {
|
||||
Some(self.saturating_sub(rhs))
|
||||
}
|
||||
|
@ -499,6 +536,7 @@ macro_rules! impl_common_ops_for_newtype_uint(
|
|||
|
||||
impl opt_ops::OptionOverflowingSub for $typ {
|
||||
type Output = Self;
|
||||
#[inline]
|
||||
fn opt_overflowing_sub(self, rhs: Self) -> Option<(Self, bool)> {
|
||||
let res = self.overflowing_sub(rhs);
|
||||
Some((res.0, res.1))
|
||||
|
@ -507,6 +545,7 @@ macro_rules! impl_common_ops_for_newtype_uint(
|
|||
|
||||
impl opt_ops::OptionWrappingSub for $typ {
|
||||
type Output = Self;
|
||||
#[inline]
|
||||
fn opt_wrapping_sub(self, rhs: Self) -> Option<Self> {
|
||||
Some(self.wrapping_sub(rhs))
|
||||
}
|
||||
|
@ -537,6 +576,7 @@ macro_rules! impl_signed_ops(
|
|||
/// - `0` if the number is zero.
|
||||
/// - `1` if the value must be considered as positive.
|
||||
/// - `-1` if the value must be considered as negative.
|
||||
#[inline]
|
||||
pub fn signum(self) -> i32 {
|
||||
use crate::Signed::*;
|
||||
match self {
|
||||
|
@ -549,6 +589,7 @@ macro_rules! impl_signed_ops(
|
|||
// rustdoc-stripper-ignore-next
|
||||
/// Returns the checked subtraction `self - other`.
|
||||
#[must_use = "this returns the result of the operation, without modifying the original"]
|
||||
#[inline]
|
||||
pub fn checked_sub(self, other: Self) -> Option<Self> {
|
||||
use crate::Signed::*;
|
||||
match (self, other) {
|
||||
|
@ -564,6 +605,7 @@ macro_rules! impl_signed_ops(
|
|||
// rustdoc-stripper-ignore-next
|
||||
/// Returns the checked subtraction `self - other`.
|
||||
#[must_use = "this returns the result of the operation, without modifying the original"]
|
||||
#[inline]
|
||||
pub fn checked_sub_unsigned(self, other: $typ) -> Option<Self> {
|
||||
self.checked_sub(crate::Signed::Positive(other))
|
||||
}
|
||||
|
@ -571,6 +613,7 @@ macro_rules! impl_signed_ops(
|
|||
// rustdoc-stripper-ignore-next
|
||||
/// Returns the checked addition `self + other`.
|
||||
#[must_use = "this returns the result of the operation, without modifying the original"]
|
||||
#[inline]
|
||||
pub fn checked_add(self, other: Self) -> Option<Self> {
|
||||
use crate::Signed::*;
|
||||
match (self, other) {
|
||||
|
@ -584,6 +627,7 @@ macro_rules! impl_signed_ops(
|
|||
// rustdoc-stripper-ignore-next
|
||||
/// Returns the checked addition `self + other`.
|
||||
#[must_use = "this returns the result of the operation, without modifying the original"]
|
||||
#[inline]
|
||||
pub fn checked_add_unsigned(self, other: $typ) -> Option<Self> {
|
||||
self.checked_add(crate::Signed::Positive(other))
|
||||
}
|
||||
|
@ -591,6 +635,7 @@ macro_rules! impl_signed_ops(
|
|||
// rustdoc-stripper-ignore-next
|
||||
/// Returns the saturating subtraction `self - other`.
|
||||
#[must_use = "this returns the result of the operation, without modifying the original"]
|
||||
#[inline]
|
||||
pub fn saturating_sub(self, other: Self) -> Self {
|
||||
use crate::Signed::*;
|
||||
match (self, other) {
|
||||
|
@ -606,6 +651,7 @@ macro_rules! impl_signed_ops(
|
|||
// rustdoc-stripper-ignore-next
|
||||
/// Returns the saturating subtraction `self - other`.
|
||||
#[must_use = "this returns the result of the operation, without modifying the original"]
|
||||
#[inline]
|
||||
pub fn saturating_sub_unsigned(self, other: $typ) -> Self {
|
||||
self.saturating_sub(crate::Signed::Positive(other))
|
||||
}
|
||||
|
@ -613,6 +659,7 @@ macro_rules! impl_signed_ops(
|
|||
// rustdoc-stripper-ignore-next
|
||||
/// Returns the saturating addition `self + other`.
|
||||
#[must_use = "this returns the result of the operation, without modifying the original"]
|
||||
#[inline]
|
||||
pub fn saturating_add(self, other: Self) -> Self {
|
||||
use crate::Signed::*;
|
||||
match (self, other) {
|
||||
|
@ -626,6 +673,7 @@ macro_rules! impl_signed_ops(
|
|||
// rustdoc-stripper-ignore-next
|
||||
/// Returns the saturating addition `self + other`.
|
||||
#[must_use = "this returns the result of the operation, without modifying the original"]
|
||||
#[inline]
|
||||
pub fn saturating_add_unsigned(self, other: $typ) -> Self {
|
||||
self.saturating_add(crate::Signed::Positive(other))
|
||||
}
|
||||
|
@ -633,12 +681,14 @@ macro_rules! impl_signed_ops(
|
|||
|
||||
impl std::ops::Add for crate::Signed<$typ> {
|
||||
type Output = Self;
|
||||
#[inline]
|
||||
fn add(self, other: Self) -> Self {
|
||||
self.checked_add(other).expect("Overflowing addition")
|
||||
}
|
||||
}
|
||||
|
||||
impl std::ops::AddAssign for crate::Signed<$typ> {
|
||||
#[inline]
|
||||
fn add_assign(&mut self, other: Self) {
|
||||
*self = self.checked_add(other).expect("Overflowing addition")
|
||||
}
|
||||
|
@ -646,12 +696,14 @@ macro_rules! impl_signed_ops(
|
|||
|
||||
impl std::ops::Sub for crate::Signed<$typ> {
|
||||
type Output = Self;
|
||||
#[inline]
|
||||
fn sub(self, other: Self) -> Self {
|
||||
self.checked_sub(other).expect("Overflowing subtraction")
|
||||
}
|
||||
}
|
||||
|
||||
impl std::ops::SubAssign for crate::Signed<$typ> {
|
||||
#[inline]
|
||||
fn sub_assign(&mut self, other: Self) {
|
||||
*self = self.checked_sub(other).expect("Overflowing subtraction")
|
||||
}
|
||||
|
@ -659,12 +711,14 @@ macro_rules! impl_signed_ops(
|
|||
|
||||
impl std::ops::Add<$typ> for crate::Signed<$typ> {
|
||||
type Output = Self;
|
||||
#[inline]
|
||||
fn add(self, other: $typ) -> Self {
|
||||
self.checked_add(crate::Signed::Positive(other)).expect("Overflowing addition")
|
||||
}
|
||||
}
|
||||
|
||||
impl std::ops::AddAssign<$typ> for crate::Signed<$typ> {
|
||||
#[inline]
|
||||
fn add_assign(&mut self, other: $typ) {
|
||||
*self = self.checked_add(crate::Signed::Positive(other)).expect("Overflowing addition")
|
||||
}
|
||||
|
@ -673,12 +727,14 @@ macro_rules! impl_signed_ops(
|
|||
impl std::ops::Sub<$typ> for crate::Signed<$typ> {
|
||||
type Output = Self;
|
||||
|
||||
#[inline]
|
||||
fn sub(self, other: $typ) -> Self {
|
||||
self.checked_sub(crate::Signed::Positive(other)).expect("Overflowing subtraction")
|
||||
}
|
||||
}
|
||||
|
||||
impl std::ops::SubAssign<$typ> for crate::Signed<$typ> {
|
||||
#[inline]
|
||||
fn sub_assign(&mut self, other: $typ) {
|
||||
*self = self.checked_sub(crate::Signed::Positive(other)).expect("Overflowing subtraction")
|
||||
}
|
||||
|
@ -686,6 +742,7 @@ macro_rules! impl_signed_ops(
|
|||
|
||||
impl std::ops::Add<crate::Signed<$typ>> for $typ {
|
||||
type Output = crate::Signed<$typ>;
|
||||
#[inline]
|
||||
fn add(self, other: crate::Signed<$typ>) -> crate::Signed<$typ> {
|
||||
crate::Signed::Positive(self).checked_add(other).expect("Overflowing addition")
|
||||
}
|
||||
|
@ -693,42 +750,49 @@ macro_rules! impl_signed_ops(
|
|||
|
||||
impl std::ops::Sub<crate::Signed<$typ>> for $typ {
|
||||
type Output = crate::Signed<$typ>;
|
||||
#[inline]
|
||||
fn sub(self, other: crate::Signed<$typ>) -> crate::Signed<$typ> {
|
||||
crate::Signed::Positive(self).checked_sub(other).expect("Overflowing subtraction")
|
||||
}
|
||||
}
|
||||
|
||||
impl std::cmp::PartialOrd for crate::Signed<$typ> {
|
||||
#[inline]
|
||||
fn partial_cmp(&self, other: &Self) -> Option<std::cmp::Ordering> {
|
||||
Some(self.cmp(other))
|
||||
}
|
||||
}
|
||||
|
||||
impl std::cmp::PartialEq<$typ> for crate::Signed<$typ> {
|
||||
#[inline]
|
||||
fn eq(&self, other: &$typ) -> bool {
|
||||
self.eq(&crate::Signed::Positive(*other))
|
||||
}
|
||||
}
|
||||
|
||||
impl std::cmp::PartialEq<crate::Signed<$typ>> for $typ {
|
||||
#[inline]
|
||||
fn eq(&self, other: &crate::Signed<$typ>) -> bool {
|
||||
crate::Signed::Positive(*self).eq(other)
|
||||
}
|
||||
}
|
||||
|
||||
impl std::cmp::PartialOrd<$typ> for crate::Signed<$typ> {
|
||||
#[inline]
|
||||
fn partial_cmp(&self, other: &$typ) -> Option<std::cmp::Ordering> {
|
||||
Some(self.cmp(&crate::Signed::Positive(*other)))
|
||||
}
|
||||
}
|
||||
|
||||
impl std::cmp::PartialOrd<crate::Signed<$typ>> for $typ {
|
||||
#[inline]
|
||||
fn partial_cmp(&self, other: &crate::Signed<$typ>) -> Option<std::cmp::Ordering> {
|
||||
Some(crate::Signed::Positive(*self).cmp(other))
|
||||
}
|
||||
}
|
||||
|
||||
impl std::cmp::Ord for crate::Signed<$typ> {
|
||||
#[inline]
|
||||
fn cmp(&self, other: &Self) -> std::cmp::Ordering {
|
||||
use crate::Signed::*;
|
||||
match (self, other) {
|
||||
|
@ -744,6 +808,7 @@ macro_rules! impl_signed_ops(
|
|||
|
||||
impl opt_ops::OptionCheckedAdd for crate::Signed<$typ> {
|
||||
type Output = Self;
|
||||
#[inline]
|
||||
fn opt_checked_add(
|
||||
self,
|
||||
rhs: Self,
|
||||
|
@ -756,6 +821,7 @@ macro_rules! impl_signed_ops(
|
|||
|
||||
impl opt_ops::OptionSaturatingAdd for crate::Signed<$typ> {
|
||||
type Output = Self;
|
||||
#[inline]
|
||||
fn opt_saturating_add(self, rhs: Self) -> Option<Self> {
|
||||
Some(self.saturating_add(rhs))
|
||||
}
|
||||
|
@ -763,6 +829,7 @@ macro_rules! impl_signed_ops(
|
|||
|
||||
impl opt_ops::OptionCheckedSub for crate::Signed<$typ> {
|
||||
type Output = Self;
|
||||
#[inline]
|
||||
fn opt_checked_sub(
|
||||
self,
|
||||
rhs: Self,
|
||||
|
@ -775,6 +842,7 @@ macro_rules! impl_signed_ops(
|
|||
|
||||
impl opt_ops::OptionSaturatingSub for crate::Signed<$typ> {
|
||||
type Output = Self;
|
||||
#[inline]
|
||||
fn opt_saturating_sub(self, rhs: Self) -> Option<Self> {
|
||||
Some(self.saturating_sub(rhs))
|
||||
}
|
||||
|
@ -782,6 +850,7 @@ macro_rules! impl_signed_ops(
|
|||
|
||||
impl opt_ops::OptionCheckedAdd<$typ> for crate::Signed<$typ> {
|
||||
type Output = Self;
|
||||
#[inline]
|
||||
fn opt_checked_add(
|
||||
self,
|
||||
rhs: $typ,
|
||||
|
@ -792,6 +861,7 @@ macro_rules! impl_signed_ops(
|
|||
|
||||
impl opt_ops::OptionSaturatingAdd<$typ> for crate::Signed<$typ> {
|
||||
type Output = Self;
|
||||
#[inline]
|
||||
fn opt_saturating_add(self, rhs: $typ) -> Option<Self> {
|
||||
self.opt_saturating_add(crate::Signed::Positive(rhs))
|
||||
}
|
||||
|
@ -799,6 +869,7 @@ macro_rules! impl_signed_ops(
|
|||
|
||||
impl opt_ops::OptionCheckedSub<$typ> for crate::Signed<$typ> {
|
||||
type Output = Self;
|
||||
#[inline]
|
||||
fn opt_checked_sub(
|
||||
self,
|
||||
rhs: $typ,
|
||||
|
@ -809,6 +880,7 @@ macro_rules! impl_signed_ops(
|
|||
|
||||
impl opt_ops::OptionSaturatingSub<$typ> for crate::Signed<$typ> {
|
||||
type Output = Self;
|
||||
#[inline]
|
||||
fn opt_saturating_sub(self, rhs: $typ) -> Option<Self> {
|
||||
self.opt_saturating_sub(crate::Signed::Positive(rhs))
|
||||
}
|
||||
|
@ -816,6 +888,7 @@ macro_rules! impl_signed_ops(
|
|||
|
||||
impl opt_ops::OptionCheckedAdd<crate::Signed<$typ>> for $typ {
|
||||
type Output = crate::Signed<$typ>;
|
||||
#[inline]
|
||||
fn opt_checked_add(
|
||||
self,
|
||||
rhs: crate::Signed<$typ>,
|
||||
|
@ -826,6 +899,7 @@ macro_rules! impl_signed_ops(
|
|||
|
||||
impl opt_ops::OptionSaturatingAdd<crate::Signed<$typ>> for $typ {
|
||||
type Output = crate::Signed<$typ>;
|
||||
#[inline]
|
||||
fn opt_saturating_add(
|
||||
self,
|
||||
rhs: crate::Signed<$typ>
|
||||
|
@ -836,6 +910,7 @@ macro_rules! impl_signed_ops(
|
|||
|
||||
impl opt_ops::OptionCheckedSub<crate::Signed<$typ>> for $typ {
|
||||
type Output = crate::Signed<$typ>;
|
||||
#[inline]
|
||||
fn opt_checked_sub(
|
||||
self,
|
||||
rhs: crate::Signed<$typ>,
|
||||
|
@ -846,6 +921,7 @@ macro_rules! impl_signed_ops(
|
|||
|
||||
impl opt_ops::OptionSaturatingSub<crate::Signed<$typ>> for $typ {
|
||||
type Output = crate::Signed<$typ>;
|
||||
#[inline]
|
||||
fn opt_saturating_sub(
|
||||
self,
|
||||
rhs: crate::Signed<$typ>
|
||||
|
@ -890,6 +966,7 @@ macro_rules! impl_signed_div_mul(
|
|||
($typ:ty, $inner:ty, $signed_rhs:ty, $into_inner:expr) => {
|
||||
impl crate::Signed<$typ> {
|
||||
#[allow(dead_code)]
|
||||
#[inline]
|
||||
fn signed_from_inner(val: $inner, sign: $signed_rhs) -> Option<crate::Signed<$typ>> {
|
||||
skip_assert_initialized!();
|
||||
if sign.is_positive() {
|
||||
|
@ -899,17 +976,20 @@ macro_rules! impl_signed_div_mul(
|
|||
}
|
||||
}
|
||||
|
||||
#[inline]
|
||||
fn positive_from_inner(val: $inner) -> Option<Self> {
|
||||
skip_assert_initialized!();
|
||||
<$typ>::try_from(val).ok().map(crate::Signed::Positive)
|
||||
}
|
||||
|
||||
#[inline]
|
||||
fn negative_from_inner(val: $inner) -> Option<Self> {
|
||||
skip_assert_initialized!();
|
||||
<$typ>::try_from(val).ok().map(crate::Signed::Negative)
|
||||
}
|
||||
|
||||
#[must_use = "this returns the result of the operation, without modifying the original"]
|
||||
#[inline]
|
||||
pub fn checked_div(self, rhs:$signed_rhs) -> Option<Self> {
|
||||
use crate::Signed::*;
|
||||
match self {
|
||||
|
@ -931,6 +1011,7 @@ macro_rules! impl_signed_div_mul(
|
|||
}
|
||||
|
||||
#[must_use = "this returns the result of the operation, without modifying the original"]
|
||||
#[inline]
|
||||
pub fn checked_div_unsigned(self, rhs:$inner) -> Option<Self> {
|
||||
use crate::Signed::*;
|
||||
match self {
|
||||
|
@ -940,6 +1021,7 @@ macro_rules! impl_signed_div_mul(
|
|||
}
|
||||
|
||||
#[must_use = "this returns the result of the operation, without modifying the original"]
|
||||
#[inline]
|
||||
pub fn checked_rem(self, rhs:$signed_rhs) -> Option<Self> {
|
||||
use crate::Signed::*;
|
||||
match self {
|
||||
|
@ -961,6 +1043,7 @@ macro_rules! impl_signed_div_mul(
|
|||
}
|
||||
|
||||
#[must_use = "this returns the result of the operation, without modifying the original"]
|
||||
#[inline]
|
||||
pub fn checked_rem_unsigned(self, rhs:$inner) -> Option<Self> {
|
||||
use crate::Signed::*;
|
||||
match self {
|
||||
|
@ -970,6 +1053,7 @@ macro_rules! impl_signed_div_mul(
|
|||
}
|
||||
|
||||
#[must_use = "this returns the result of the operation, without modifying the original"]
|
||||
#[inline]
|
||||
pub fn checked_mul(self, rhs:$signed_rhs) -> Option<Self> {
|
||||
use crate::Signed::*;
|
||||
match self {
|
||||
|
@ -991,6 +1075,7 @@ macro_rules! impl_signed_div_mul(
|
|||
}
|
||||
|
||||
#[must_use = "this returns the result of the operation, without modifying the original"]
|
||||
#[inline]
|
||||
pub fn checked_mul_unsigned(self, rhs:$inner) -> Option<Self> {
|
||||
use crate::Signed::*;
|
||||
match self {
|
||||
|
@ -1000,6 +1085,7 @@ macro_rules! impl_signed_div_mul(
|
|||
}
|
||||
|
||||
#[must_use = "this returns the result of the operation, without modifying the original"]
|
||||
#[inline]
|
||||
pub fn saturating_mul(self, rhs:$signed_rhs) -> Self {
|
||||
use crate::Signed::*;
|
||||
match self {
|
||||
|
@ -1021,6 +1107,7 @@ macro_rules! impl_signed_div_mul(
|
|||
}
|
||||
|
||||
#[must_use = "this returns the result of the operation, without modifying the original"]
|
||||
#[inline]
|
||||
pub fn saturating_mul_unsigned(self, rhs:$inner) -> Self {
|
||||
use crate::Signed::*;
|
||||
match self {
|
||||
|
@ -1032,12 +1119,14 @@ macro_rules! impl_signed_div_mul(
|
|||
|
||||
impl std::ops::Div<$signed_rhs> for crate::Signed<$typ> {
|
||||
type Output = Self;
|
||||
#[inline]
|
||||
fn div(self, rhs: $signed_rhs) -> Self {
|
||||
self.checked_div(rhs).expect("division overflowed")
|
||||
}
|
||||
}
|
||||
|
||||
impl std::ops::DivAssign<$signed_rhs> for crate::Signed<$typ> {
|
||||
#[inline]
|
||||
fn div_assign(&mut self, rhs: $signed_rhs) {
|
||||
*self = std::ops::Div::div(*self, rhs);
|
||||
}
|
||||
|
@ -1045,12 +1134,14 @@ macro_rules! impl_signed_div_mul(
|
|||
|
||||
impl std::ops::Div<$inner> for crate::Signed<$typ> {
|
||||
type Output = Self;
|
||||
#[inline]
|
||||
fn div(self, rhs: $inner) -> Self {
|
||||
self.checked_div_unsigned(rhs).expect("division overflowed")
|
||||
}
|
||||
}
|
||||
|
||||
impl std::ops::DivAssign<$inner> for crate::Signed<$typ> {
|
||||
#[inline]
|
||||
fn div_assign(&mut self, rhs: $inner) {
|
||||
*self = std::ops::Div::div(*self, rhs);
|
||||
}
|
||||
|
@ -1058,12 +1149,14 @@ macro_rules! impl_signed_div_mul(
|
|||
|
||||
impl std::ops::Rem<$signed_rhs> for crate::Signed<$typ> {
|
||||
type Output = Self;
|
||||
#[inline]
|
||||
fn rem(self, rhs: $signed_rhs) -> Self {
|
||||
self.checked_rem(rhs).expect("division overflowed")
|
||||
}
|
||||
}
|
||||
|
||||
impl std::ops::RemAssign<$signed_rhs> for crate::Signed<$typ> {
|
||||
#[inline]
|
||||
fn rem_assign(&mut self, rhs: $signed_rhs) {
|
||||
*self = std::ops::Rem::rem(*self, rhs);
|
||||
}
|
||||
|
@ -1071,12 +1164,14 @@ macro_rules! impl_signed_div_mul(
|
|||
|
||||
impl std::ops::Rem<$inner> for crate::Signed<$typ> {
|
||||
type Output = Self;
|
||||
#[inline]
|
||||
fn rem(self, rhs: $inner) -> Self {
|
||||
self.checked_rem_unsigned(rhs).expect("division overflowed")
|
||||
}
|
||||
}
|
||||
|
||||
impl std::ops::RemAssign<$inner> for crate::Signed<$typ> {
|
||||
#[inline]
|
||||
fn rem_assign(&mut self, rhs: $inner) {
|
||||
*self = std::ops::Rem::rem(*self, rhs);
|
||||
}
|
||||
|
@ -1084,12 +1179,14 @@ macro_rules! impl_signed_div_mul(
|
|||
|
||||
impl std::ops::Mul<$signed_rhs> for crate::Signed<$typ> {
|
||||
type Output = Self;
|
||||
#[inline]
|
||||
fn mul(self, rhs: $signed_rhs) -> Self {
|
||||
self.checked_mul(rhs).expect("multiplication overflowed")
|
||||
}
|
||||
}
|
||||
|
||||
impl std::ops::MulAssign<$signed_rhs> for crate::Signed<$typ> {
|
||||
#[inline]
|
||||
fn mul_assign(&mut self, rhs: $signed_rhs) {
|
||||
*self = std::ops::Mul::mul(*self, rhs);
|
||||
}
|
||||
|
@ -1097,12 +1194,14 @@ macro_rules! impl_signed_div_mul(
|
|||
|
||||
impl std::ops::Mul<$inner> for crate::Signed<$typ> {
|
||||
type Output = Self;
|
||||
#[inline]
|
||||
fn mul(self, rhs: $inner) -> Self {
|
||||
self.checked_mul_unsigned(rhs).expect("multiplication overflowed")
|
||||
}
|
||||
}
|
||||
|
||||
impl std::ops::MulAssign<$inner> for crate::Signed<$typ> {
|
||||
#[inline]
|
||||
fn mul_assign(&mut self, rhs: $inner) {
|
||||
*self = std::ops::Mul::mul(*self, rhs);
|
||||
}
|
||||
|
@ -1110,6 +1209,7 @@ macro_rules! impl_signed_div_mul(
|
|||
|
||||
impl opt_ops::OptionCheckedDiv<$signed_rhs> for crate::Signed<$typ> {
|
||||
type Output = Self;
|
||||
#[inline]
|
||||
fn opt_checked_div(self, rhs: $signed_rhs) -> Result<Option<Self>, opt_ops::Error> {
|
||||
if rhs == 0 {
|
||||
return Err(opt_ops::Error::DivisionByZero);
|
||||
|
@ -1122,6 +1222,7 @@ macro_rules! impl_signed_div_mul(
|
|||
|
||||
impl opt_ops::OptionCheckedMul<$signed_rhs> for crate::Signed<$typ> {
|
||||
type Output = Self;
|
||||
#[inline]
|
||||
fn opt_checked_mul(self, rhs: $signed_rhs) -> Result<Option<Self>, opt_ops::Error> {
|
||||
self.checked_mul(rhs)
|
||||
.ok_or(opt_ops::Error::Overflow)
|
||||
|
@ -1131,6 +1232,7 @@ macro_rules! impl_signed_div_mul(
|
|||
|
||||
impl opt_ops::OptionSaturatingMul<$signed_rhs> for crate::Signed<$typ> {
|
||||
type Output = Self;
|
||||
#[inline]
|
||||
fn opt_saturating_mul(self, rhs: $signed_rhs) -> Option<Self> {
|
||||
Some(self.saturating_mul(rhs))
|
||||
}
|
||||
|
@ -1138,6 +1240,7 @@ macro_rules! impl_signed_div_mul(
|
|||
|
||||
impl opt_ops::OptionCheckedRem<$signed_rhs> for crate::Signed<$typ> {
|
||||
type Output = Self;
|
||||
#[inline]
|
||||
fn opt_checked_rem(self, rhs: $signed_rhs) -> Result<Option<Self>, opt_ops::Error> {
|
||||
if rhs == 0 {
|
||||
return Err(opt_ops::Error::DivisionByZero);
|
||||
|
@ -1150,6 +1253,7 @@ macro_rules! impl_signed_div_mul(
|
|||
|
||||
impl opt_ops::OptionCheckedDiv<$inner> for crate::Signed<$typ> {
|
||||
type Output = Self;
|
||||
#[inline]
|
||||
fn opt_checked_div(self, rhs: $inner) -> Result<Option<Self>, opt_ops::Error> {
|
||||
if rhs == 0 {
|
||||
return Err(opt_ops::Error::DivisionByZero);
|
||||
|
@ -1162,6 +1266,7 @@ macro_rules! impl_signed_div_mul(
|
|||
|
||||
impl opt_ops::OptionCheckedMul<$inner> for crate::Signed<$typ> {
|
||||
type Output = Self;
|
||||
#[inline]
|
||||
fn opt_checked_mul(self, rhs: $inner) -> Result<Option<Self>, opt_ops::Error> {
|
||||
self.checked_mul_unsigned(rhs)
|
||||
.ok_or(opt_ops::Error::Overflow)
|
||||
|
@ -1171,6 +1276,7 @@ macro_rules! impl_signed_div_mul(
|
|||
|
||||
impl opt_ops::OptionSaturatingMul<$inner> for crate::Signed<$typ> {
|
||||
type Output = Self;
|
||||
#[inline]
|
||||
fn opt_saturating_mul(self, rhs: $inner) -> Option<Self> {
|
||||
Some(self.saturating_mul_unsigned(rhs))
|
||||
}
|
||||
|
@ -1178,6 +1284,7 @@ macro_rules! impl_signed_div_mul(
|
|||
|
||||
impl opt_ops::OptionCheckedRem<$inner> for crate::Signed<$typ> {
|
||||
type Output = Self;
|
||||
#[inline]
|
||||
fn opt_checked_rem(self, rhs: $inner) -> Result<Option<Self>, opt_ops::Error> {
|
||||
if rhs == 0 {
|
||||
return Err(opt_ops::Error::DivisionByZero);
|
||||
|
@ -1194,6 +1301,7 @@ macro_rules! impl_signed_extra_div_mul(
|
|||
($typ:ty, $signed:ty) => {
|
||||
impl std::ops::Div for crate::Signed<$typ> {
|
||||
type Output = Self;
|
||||
#[inline]
|
||||
fn div(self, rhs: Self) -> Self {
|
||||
match rhs {
|
||||
crate::Signed::Positive(rhs) => self.div(rhs),
|
||||
|
@ -1204,6 +1312,7 @@ macro_rules! impl_signed_extra_div_mul(
|
|||
|
||||
impl std::ops::Rem for crate::Signed<$typ> {
|
||||
type Output = Self;
|
||||
#[inline]
|
||||
fn rem(self, rhs: Self) -> Self {
|
||||
self.rem(rhs.abs())
|
||||
}
|
||||
|
@ -1211,6 +1320,7 @@ macro_rules! impl_signed_extra_div_mul(
|
|||
|
||||
impl opt_ops::OptionCheckedDiv for crate::Signed<$typ> {
|
||||
type Output = Self;
|
||||
#[inline]
|
||||
fn opt_checked_div(self, rhs: Self) -> Result<Option<Self>, opt_ops::Error> {
|
||||
match rhs {
|
||||
crate::Signed::Positive(rhs) => self.opt_checked_div(rhs),
|
||||
|
@ -1224,6 +1334,7 @@ macro_rules! impl_signed_extra_div_mul(
|
|||
|
||||
impl opt_ops::OptionCheckedRem for crate::Signed<$typ> {
|
||||
type Output = Self;
|
||||
#[inline]
|
||||
fn opt_checked_rem(self, rhs: Self) -> Result<Option<Self>, opt_ops::Error> {
|
||||
self.opt_checked_rem(rhs.abs())
|
||||
}
|
||||
|
@ -1232,6 +1343,7 @@ macro_rules! impl_signed_extra_div_mul(
|
|||
($newtyp:ty, $inner:ty, $signed_inner:ty) => {
|
||||
impl std::ops::Div for crate::Signed<$newtyp> {
|
||||
type Output = crate::Signed<$inner>;
|
||||
#[inline]
|
||||
fn div(self, rhs: Self) -> Self::Output {
|
||||
self.into_inner_signed().div(rhs.into_inner_signed())
|
||||
}
|
||||
|
@ -1239,6 +1351,7 @@ macro_rules! impl_signed_extra_div_mul(
|
|||
|
||||
impl std::ops::Rem for crate::Signed<$newtyp> {
|
||||
type Output = Self;
|
||||
#[inline]
|
||||
fn rem(self, rhs: Self) -> Self {
|
||||
self.rem(rhs.abs().0)
|
||||
}
|
||||
|
@ -1246,6 +1359,7 @@ macro_rules! impl_signed_extra_div_mul(
|
|||
|
||||
impl std::ops::Mul<crate::Signed<$newtyp>> for $inner {
|
||||
type Output = crate::Signed<$newtyp>;
|
||||
#[inline]
|
||||
fn mul(self, rhs: crate::Signed<$newtyp>) -> Self::Output {
|
||||
rhs.mul(self)
|
||||
}
|
||||
|
@ -1253,6 +1367,7 @@ macro_rules! impl_signed_extra_div_mul(
|
|||
|
||||
impl std::ops::Mul<crate::Signed<$newtyp>> for $signed_inner {
|
||||
type Output = crate::Signed<$newtyp>;
|
||||
#[inline]
|
||||
fn mul(self, rhs: crate::Signed<$newtyp>) -> Self::Output {
|
||||
rhs.mul(self)
|
||||
}
|
||||
|
@ -1260,6 +1375,7 @@ macro_rules! impl_signed_extra_div_mul(
|
|||
|
||||
impl opt_ops::OptionCheckedDiv for crate::Signed<$newtyp> {
|
||||
type Output = crate::Signed<$inner>;
|
||||
#[inline]
|
||||
fn opt_checked_div(self, rhs: Self) -> Result<Option<Self::Output>, opt_ops::Error> {
|
||||
self.into_inner_signed().opt_checked_div(rhs.into_inner_signed())
|
||||
}
|
||||
|
@ -1267,6 +1383,7 @@ macro_rules! impl_signed_extra_div_mul(
|
|||
|
||||
impl opt_ops::OptionCheckedRem for crate::Signed<$newtyp> {
|
||||
type Output = crate::Signed<$inner>;
|
||||
#[inline]
|
||||
fn opt_checked_rem(self, rhs: Self) -> Result<Option<Self::Output>, opt_ops::Error> {
|
||||
self.into_inner_signed().opt_checked_rem(rhs.abs().0)
|
||||
}
|
||||
|
@ -1274,6 +1391,7 @@ macro_rules! impl_signed_extra_div_mul(
|
|||
|
||||
impl opt_ops::OptionCheckedMul<crate::Signed<$newtyp>> for $signed_inner {
|
||||
type Output = crate::Signed<$newtyp>;
|
||||
#[inline]
|
||||
fn opt_checked_mul(self, rhs: crate::Signed<$newtyp>) -> Result<Option<Self::Output>, opt_ops::Error> {
|
||||
rhs.opt_checked_mul(self)
|
||||
}
|
||||
|
@ -1281,6 +1399,7 @@ macro_rules! impl_signed_extra_div_mul(
|
|||
|
||||
impl opt_ops::OptionSaturatingMul<crate::Signed<$newtyp>> for $signed_inner {
|
||||
type Output = crate::Signed<$newtyp>;
|
||||
#[inline]
|
||||
fn opt_saturating_mul(self, rhs: crate::Signed<$newtyp>) -> Option<Self::Output> {
|
||||
rhs.opt_saturating_mul(self)
|
||||
}
|
||||
|
@ -1288,6 +1407,7 @@ macro_rules! impl_signed_extra_div_mul(
|
|||
|
||||
impl opt_ops::OptionCheckedMul<crate::Signed<$newtyp>> for $inner {
|
||||
type Output = crate::Signed<$newtyp>;
|
||||
#[inline]
|
||||
fn opt_checked_mul(self, rhs: crate::Signed<$newtyp>) -> Result<Option<Self::Output>, opt_ops::Error> {
|
||||
rhs.opt_checked_mul(self)
|
||||
}
|
||||
|
@ -1295,6 +1415,7 @@ macro_rules! impl_signed_extra_div_mul(
|
|||
|
||||
impl opt_ops::OptionSaturatingMul<crate::Signed<$newtyp>> for $inner {
|
||||
type Output = crate::Signed<$newtyp>;
|
||||
#[inline]
|
||||
fn opt_saturating_mul(self, rhs: crate::Signed<$newtyp>) -> Option<Self::Output> {
|
||||
rhs.opt_saturating_mul(self)
|
||||
}
|
||||
|
@ -1307,6 +1428,7 @@ macro_rules! impl_signed_div_mul_trait(
|
|||
impl muldiv::MulDiv<$signed_rhs> for crate::Signed<$typ> {
|
||||
type Output = Self;
|
||||
|
||||
#[inline]
|
||||
fn mul_div_floor(self, num: $signed_rhs, denom: $signed_rhs) -> Option<Self> {
|
||||
use crate::Signed::*;
|
||||
match self {
|
||||
|
@ -1323,6 +1445,7 @@ macro_rules! impl_signed_div_mul_trait(
|
|||
}
|
||||
}
|
||||
|
||||
#[inline]
|
||||
fn mul_div_round(self, num: $signed_rhs, denom: $signed_rhs) -> Option<Self> {
|
||||
use crate::Signed::*;
|
||||
match self {
|
||||
|
@ -1339,6 +1462,7 @@ macro_rules! impl_signed_div_mul_trait(
|
|||
}
|
||||
}
|
||||
|
||||
#[inline]
|
||||
fn mul_div_ceil(self, num: $signed_rhs, denom: $signed_rhs) -> Option<Self> {
|
||||
use crate::Signed::*;
|
||||
match self {
|
||||
|
@ -1359,6 +1483,7 @@ macro_rules! impl_signed_div_mul_trait(
|
|||
impl muldiv::MulDiv<$inner> for crate::Signed<$typ> {
|
||||
type Output = Self;
|
||||
|
||||
#[inline]
|
||||
fn mul_div_floor(self, num: $inner, denom: $inner) -> Option<Self> {
|
||||
use crate::Signed::*;
|
||||
match self {
|
||||
|
@ -1375,6 +1500,7 @@ macro_rules! impl_signed_div_mul_trait(
|
|||
}
|
||||
}
|
||||
|
||||
#[inline]
|
||||
fn mul_div_round(self, num: $inner, denom: $inner) -> Option<Self> {
|
||||
use crate::Signed::*;
|
||||
match self {
|
||||
|
@ -1391,6 +1517,7 @@ macro_rules! impl_signed_div_mul_trait(
|
|||
}
|
||||
}
|
||||
|
||||
#[inline]
|
||||
fn mul_div_ceil(self, num: $inner, denom: $inner) -> Option<Self> {
|
||||
use crate::Signed::*;
|
||||
match self {
|
||||
|
@ -1415,24 +1542,29 @@ macro_rules! impl_format_value_traits(
|
|||
impl FormattedValue for Option<$typ> {
|
||||
type FullRange = Self;
|
||||
|
||||
#[inline]
|
||||
fn default_format() -> Format {
|
||||
Format::$format
|
||||
}
|
||||
|
||||
#[inline]
|
||||
fn format(&self) -> Format {
|
||||
Format::$format
|
||||
}
|
||||
|
||||
#[inline]
|
||||
fn is_some(&self) -> bool {
|
||||
Option::is_some(self)
|
||||
}
|
||||
|
||||
#[inline]
|
||||
unsafe fn into_raw_value(self) -> i64 {
|
||||
IntoGlib::into_glib(self) as i64
|
||||
}
|
||||
}
|
||||
|
||||
impl FormattedValueFullRange for Option<$typ> {
|
||||
#[inline]
|
||||
unsafe fn from_raw(format: Format, value: i64) -> Self {
|
||||
debug_assert_eq!(format, Format::$format);
|
||||
FromGlib::from_glib(value as u64)
|
||||
|
@ -1440,12 +1572,14 @@ macro_rules! impl_format_value_traits(
|
|||
}
|
||||
|
||||
impl FormattedValueNoneBuilder for Option<$typ> {
|
||||
#[inline]
|
||||
fn none() -> Option<$typ> {
|
||||
None
|
||||
}
|
||||
}
|
||||
|
||||
impl From<Option<$typ>> for GenericFormattedValue {
|
||||
#[inline]
|
||||
fn from(v: Option<$typ>) -> Self {
|
||||
skip_assert_initialized!();
|
||||
Self::$format_value(v)
|
||||
|
@ -1453,6 +1587,7 @@ macro_rules! impl_format_value_traits(
|
|||
}
|
||||
|
||||
impl From<$typ> for GenericFormattedValue {
|
||||
#[inline]
|
||||
fn from(v: $typ) -> Self {
|
||||
skip_assert_initialized!();
|
||||
Self::$format_value(Some(v))
|
||||
|
@ -1462,18 +1597,22 @@ macro_rules! impl_format_value_traits(
|
|||
impl FormattedValue for $typ {
|
||||
type FullRange = Option<$typ>;
|
||||
|
||||
#[inline]
|
||||
fn default_format() -> Format {
|
||||
Format::$format
|
||||
}
|
||||
|
||||
#[inline]
|
||||
fn format(&self) -> Format {
|
||||
Format::$format
|
||||
}
|
||||
|
||||
#[inline]
|
||||
fn is_some(&self) -> bool {
|
||||
true
|
||||
}
|
||||
|
||||
#[inline]
|
||||
unsafe fn into_raw_value(self) -> i64 {
|
||||
IntoGlib::into_glib(self) as i64
|
||||
}
|
||||
|
@ -1487,6 +1626,7 @@ macro_rules! impl_format_value_traits(
|
|||
|
||||
impl TryFrom<GenericFormattedValue> for Option<$typ> {
|
||||
type Error = FormattedValueError;
|
||||
#[inline]
|
||||
fn try_from(v: GenericFormattedValue) -> Result<Self, Self::Error> {
|
||||
skip_assert_initialized!();
|
||||
if let GenericFormattedValue::$format_value(v) = v {
|
||||
|
@ -1499,6 +1639,7 @@ macro_rules! impl_format_value_traits(
|
|||
|
||||
impl TryFrom<$inner> for $typ {
|
||||
type Error = GlibNoneError;
|
||||
#[inline]
|
||||
fn try_from(v: $inner) -> Result<Self, GlibNoneError> {
|
||||
skip_assert_initialized!();
|
||||
unsafe { Self::try_from_glib(v as i64) }
|
||||
|
@ -1521,6 +1662,7 @@ macro_rules! option_glib_newtype_from_to {
|
|||
#[doc(hidden)]
|
||||
impl IntoGlib for $typ {
|
||||
type GlibType = u64;
|
||||
#[inline]
|
||||
fn into_glib(self) -> u64 {
|
||||
assert_ne!(
|
||||
self.0, $none_value,
|
||||
|
@ -1663,6 +1805,7 @@ macro_rules! impl_signed_int_into_signed(
|
|||
impl TryFrom<crate::Signed<$typ>> for $signed {
|
||||
type Error = std::num::TryFromIntError;
|
||||
|
||||
#[inline]
|
||||
fn try_from(value: crate::Signed<$typ>) -> Result<$signed, Self::Error> {
|
||||
assert_eq!(::std::mem::size_of::<$inner>(), ::std::mem::size_of::<$signed>());
|
||||
|
||||
|
@ -1682,6 +1825,7 @@ macro_rules! impl_signed_int_into_signed(
|
|||
}
|
||||
|
||||
impl From<$signed> for crate::Signed<$typ> {
|
||||
#[inline]
|
||||
fn from(value: $signed) -> crate::Signed<$typ> {
|
||||
let abs = value.unsigned_abs();
|
||||
if value.signum() >= 0 {
|
||||
|
|
|
@ -594,6 +594,7 @@ pub trait FormattedValueNoneBuilder: FormattedValueFullRange {
|
|||
/// Panics if `None` can't be represented by `Self` for `format` or by the requested
|
||||
/// `GenericFormattedValue` variant.
|
||||
#[track_caller]
|
||||
#[inline]
|
||||
fn none_for_format(format: Format) -> Self {
|
||||
skip_assert_initialized!();
|
||||
// This is the default impl. `GenericFormattedValue` must override.
|
||||
|
|
|
@ -20,6 +20,7 @@ pub enum Signed<T> {
|
|||
}
|
||||
|
||||
impl<T> Signed<T> {
|
||||
#[inline]
|
||||
pub fn is_positive(self) -> bool {
|
||||
matches!(self, Signed::Positive(_))
|
||||
}
|
||||
|
@ -27,6 +28,7 @@ impl<T> Signed<T> {
|
|||
// rustdoc-stripper-ignore-next
|
||||
/// Returns `Some(value)`, where `value` is the inner value,
|
||||
/// if `self` is positive.
|
||||
#[inline]
|
||||
pub fn positive(self) -> Option<T> {
|
||||
match self {
|
||||
Signed::Positive(val) => Some(val),
|
||||
|
@ -37,6 +39,7 @@ impl<T> Signed<T> {
|
|||
// rustdoc-stripper-ignore-next
|
||||
/// Transforms the `Signed<T>` into a `Result<T, E>`,
|
||||
/// mapping `Positive(v)` to `Ok(v)` and `Negative(_)` to `Err(err)`.
|
||||
#[inline]
|
||||
pub fn positive_or<E>(self, err: E) -> Result<T, E> {
|
||||
match self {
|
||||
Signed::Positive(val) => Ok(val),
|
||||
|
@ -47,6 +50,7 @@ impl<T> Signed<T> {
|
|||
// rustdoc-stripper-ignore-next
|
||||
/// Transforms the `Signed<T>` into a `Result<T, E>`,
|
||||
/// mapping `Positive(v)` to `Ok(v)` and `Negative(v)` to `Err(err(v))`.
|
||||
#[inline]
|
||||
pub fn positive_or_else<E, F: FnOnce(T) -> E>(self, err: F) -> Result<T, E> {
|
||||
match self {
|
||||
Signed::Positive(val) => Ok(val),
|
||||
|
@ -54,6 +58,7 @@ impl<T> Signed<T> {
|
|||
}
|
||||
}
|
||||
|
||||
#[inline]
|
||||
pub fn is_negative(self) -> bool {
|
||||
matches!(self, Signed::Negative(_))
|
||||
}
|
||||
|
@ -61,6 +66,7 @@ impl<T> Signed<T> {
|
|||
// rustdoc-stripper-ignore-next
|
||||
/// Returns `Some(value)`, where `value` is the inner value,
|
||||
/// if `self` is negative.
|
||||
#[inline]
|
||||
pub fn negative(self) -> Option<T> {
|
||||
match self {
|
||||
Signed::Negative(val) => Some(val),
|
||||
|
@ -71,6 +77,7 @@ impl<T> Signed<T> {
|
|||
// rustdoc-stripper-ignore-next
|
||||
/// Transforms the `Signed<T>` into a `Result<T, E>`,
|
||||
/// mapping `Negative(v)` to `Ok(v)` and `Positive(_)` to `Err(err)`.
|
||||
#[inline]
|
||||
pub fn negative_or<E>(self, err: E) -> Result<T, E> {
|
||||
match self {
|
||||
Signed::Negative(val) => Ok(val),
|
||||
|
@ -81,6 +88,7 @@ impl<T> Signed<T> {
|
|||
// rustdoc-stripper-ignore-next
|
||||
/// Transforms the `Signed<T>` into a `Result<T, E>`,
|
||||
/// mapping `Negative(v)` to `Ok(v)` and `Positive(_)` to `Err(err(v))`.
|
||||
#[inline]
|
||||
pub fn negative_or_else<E, F: FnOnce(T) -> E>(self, err: F) -> Result<T, E> {
|
||||
match self {
|
||||
Signed::Negative(val) => Ok(val),
|
||||
|
@ -90,6 +98,7 @@ impl<T> Signed<T> {
|
|||
|
||||
// rustdoc-stripper-ignore-next
|
||||
/// Returns the absolute value of `self`.
|
||||
#[inline]
|
||||
pub fn abs(self) -> T {
|
||||
match self {
|
||||
Signed::Positive(val) | Signed::Negative(val) => val,
|
||||
|
@ -100,6 +109,7 @@ impl<T> Signed<T> {
|
|||
impl<T> std::ops::Neg for Signed<T> {
|
||||
type Output = Signed<T>;
|
||||
|
||||
#[inline]
|
||||
fn neg(self) -> Self {
|
||||
match self {
|
||||
Signed::Positive(val) => Signed::Negative(val),
|
||||
|
@ -143,6 +153,7 @@ impl<T> Signed<Option<T>> {
|
|||
/// Transposes a `Signed` `Option` into an `Option` of a `Signed`.
|
||||
///
|
||||
/// Note that if the inner value was `None`, the sign is lost.
|
||||
#[inline]
|
||||
pub fn transpose(self) -> Option<Signed<T>> {
|
||||
use Signed::*;
|
||||
|
||||
|
@ -263,10 +274,12 @@ where
|
|||
{
|
||||
type Signed = <T as UnsignedIntoSigned>::Signed;
|
||||
|
||||
#[inline]
|
||||
fn none_signed() -> Self::Signed {
|
||||
Self::none().into_positive()
|
||||
}
|
||||
|
||||
#[inline]
|
||||
fn none_signed_for_format(format: Format) -> Self::Signed {
|
||||
skip_assert_initialized!();
|
||||
Self::none_for_format(format).into_positive()
|
||||
|
|
|
@ -37,6 +37,7 @@ impl Buffers {
|
|||
/// Panics if the provided count equals `u64::MAX`,
|
||||
/// which is reserved for `None` in C.
|
||||
#[track_caller]
|
||||
#[inline]
|
||||
pub const fn from_u64(buffers: u64) -> Self {
|
||||
if buffers == ffi::GST_BUFFER_OFFSET_NONE {
|
||||
panic!("`Buffers` value out of range");
|
||||
|
@ -53,6 +54,7 @@ impl Buffers {
|
|||
/// Panics if the provided count equals `u64::MAX`,
|
||||
/// which is reserved for `None` in C.
|
||||
#[track_caller]
|
||||
#[inline]
|
||||
pub fn from_usize(buffers: usize) -> Self {
|
||||
Buffers::from_u64(buffers.try_into().unwrap())
|
||||
}
|
||||
|
@ -76,6 +78,7 @@ pub trait BuffersFormatConstructor {
|
|||
|
||||
impl BuffersFormatConstructor for u64 {
|
||||
#[track_caller]
|
||||
#[inline]
|
||||
fn buffers(self) -> Buffers {
|
||||
Buffers::from_u64(self)
|
||||
}
|
||||
|
@ -109,6 +112,7 @@ impl Bytes {
|
|||
/// Panics if the provided count equals `u64::MAX`,
|
||||
/// which is reserved for `None` in C.
|
||||
#[track_caller]
|
||||
#[inline]
|
||||
pub const fn from_u64(bytes: u64) -> Self {
|
||||
if bytes == u64::MAX {
|
||||
panic!("`Bytes` value out of range");
|
||||
|
@ -125,6 +129,7 @@ impl Bytes {
|
|||
/// Panics if the provided count equals `u64::MAX`,
|
||||
/// which is reserved for `None` in C.
|
||||
#[track_caller]
|
||||
#[inline]
|
||||
pub fn from_usize(bytes: usize) -> Self {
|
||||
// FIXME can't use `try_into` in `const` (rustc 1.64.0)
|
||||
Bytes::from_u64(bytes.try_into().unwrap())
|
||||
|
@ -165,21 +170,25 @@ pub trait BytesFormatConstructor {
|
|||
|
||||
impl BytesFormatConstructor for u64 {
|
||||
#[track_caller]
|
||||
#[inline]
|
||||
fn bytes(self) -> Bytes {
|
||||
Bytes::from_u64(self)
|
||||
}
|
||||
|
||||
#[track_caller]
|
||||
#[inline]
|
||||
fn kibibytes(self) -> Bytes {
|
||||
Bytes::from_u64(self * 1024)
|
||||
}
|
||||
|
||||
#[track_caller]
|
||||
#[inline]
|
||||
fn mebibytes(self) -> Bytes {
|
||||
Bytes::from_u64(self * 1024 * 1024)
|
||||
}
|
||||
|
||||
#[track_caller]
|
||||
#[inline]
|
||||
fn gibibytes(self) -> Bytes {
|
||||
Bytes::from_u64(self * 1024 * 1024 * 1024)
|
||||
}
|
||||
|
@ -200,6 +209,7 @@ impl Default {
|
|||
/// Panics if the provided quantity equals `u64::MAX`,
|
||||
/// which is reserved for `None` in C.
|
||||
#[track_caller]
|
||||
#[inline]
|
||||
pub const fn from_u64(quantity: u64) -> Self {
|
||||
if quantity == u64::MAX {
|
||||
panic!("`Default` value out of range");
|
||||
|
@ -216,6 +226,7 @@ impl Default {
|
|||
/// Panics if the provided quantity equals `u64::MAX`,
|
||||
/// which is reserved for `None` in C.
|
||||
#[track_caller]
|
||||
#[inline]
|
||||
pub fn from_usize(quantity: usize) -> Self {
|
||||
// FIXME can't use `try_into` in `const` (rustc 1.64.0)
|
||||
Default::from_u64(quantity.try_into().unwrap())
|
||||
|
@ -240,6 +251,7 @@ pub trait DefaultFormatConstructor {
|
|||
|
||||
impl DefaultFormatConstructor for u64 {
|
||||
#[track_caller]
|
||||
#[inline]
|
||||
fn default_format(self) -> Default {
|
||||
Default::from_u64(self)
|
||||
}
|
||||
|
@ -262,6 +274,7 @@ impl Percent {
|
|||
///
|
||||
/// Panics if the provided value is larger than 100.
|
||||
#[track_caller]
|
||||
#[inline]
|
||||
pub const fn from_percent(percent: u32) -> Self {
|
||||
if percent > 100 {
|
||||
panic!("`Percent` value out of range");
|
||||
|
@ -277,6 +290,7 @@ impl Percent {
|
|||
///
|
||||
/// Panics if the provided value is larger than [`Self::MAX`].
|
||||
#[track_caller]
|
||||
#[inline]
|
||||
pub const fn from_ppm(ppm: u32) -> Self {
|
||||
if ppm > ffi::GST_FORMAT_PERCENT_MAX as u32 {
|
||||
panic!("`Percent` ppm value out of range");
|
||||
|
@ -292,6 +306,7 @@ impl Percent {
|
|||
///
|
||||
/// Panics if the provided radio is out of the range [0.0, 1.0].
|
||||
#[track_caller]
|
||||
#[inline]
|
||||
pub fn from_ratio(ratio: f32) -> Self {
|
||||
// FIXME floating point arithmetic is not allowed in constant functions (rustc 1.64.0)
|
||||
Percent::try_from(ratio).expect("`Percent` ratio out of range")
|
||||
|
@ -305,24 +320,29 @@ impl_signed_int_into_signed!(Percent, u32);
|
|||
impl FormattedValue for Option<Percent> {
|
||||
type FullRange = Option<Percent>;
|
||||
|
||||
#[inline]
|
||||
fn default_format() -> Format {
|
||||
Format::Percent
|
||||
}
|
||||
|
||||
#[inline]
|
||||
fn format(&self) -> Format {
|
||||
Format::Percent
|
||||
}
|
||||
|
||||
#[inline]
|
||||
fn is_some(&self) -> bool {
|
||||
Option::is_some(self)
|
||||
}
|
||||
|
||||
#[inline]
|
||||
unsafe fn into_raw_value(self) -> i64 {
|
||||
self.map_or(-1, |v| v.0 as i64)
|
||||
}
|
||||
}
|
||||
|
||||
impl FormattedValueFullRange for Option<Percent> {
|
||||
#[inline]
|
||||
unsafe fn from_raw(format: Format, value: i64) -> Self {
|
||||
debug_assert_eq!(format, Format::Percent);
|
||||
Percent::try_from_glib(value).ok()
|
||||
|
@ -330,6 +350,7 @@ impl FormattedValueFullRange for Option<Percent> {
|
|||
}
|
||||
|
||||
impl From<Option<Percent>> for GenericFormattedValue {
|
||||
#[inline]
|
||||
fn from(v: Option<Percent>) -> Self {
|
||||
skip_assert_initialized!();
|
||||
GenericFormattedValue::Percent(v)
|
||||
|
@ -337,6 +358,7 @@ impl From<Option<Percent>> for GenericFormattedValue {
|
|||
}
|
||||
|
||||
impl From<Percent> for GenericFormattedValue {
|
||||
#[inline]
|
||||
fn from(v: Percent) -> Self {
|
||||
skip_assert_initialized!();
|
||||
GenericFormattedValue::Percent(Some(v))
|
||||
|
@ -346,18 +368,22 @@ impl From<Percent> for GenericFormattedValue {
|
|||
impl FormattedValue for Percent {
|
||||
type FullRange = Option<Percent>;
|
||||
|
||||
#[inline]
|
||||
fn default_format() -> Format {
|
||||
Format::Percent
|
||||
}
|
||||
|
||||
#[inline]
|
||||
fn format(&self) -> Format {
|
||||
Format::Percent
|
||||
}
|
||||
|
||||
#[inline]
|
||||
fn is_some(&self) -> bool {
|
||||
true
|
||||
}
|
||||
|
||||
#[inline]
|
||||
unsafe fn into_raw_value(self) -> i64 {
|
||||
self.0 as i64
|
||||
}
|
||||
|
@ -366,6 +392,7 @@ impl FormattedValue for Percent {
|
|||
impl TryFrom<u64> for Percent {
|
||||
type Error = GlibNoneError;
|
||||
|
||||
#[inline]
|
||||
fn try_from(v: u64) -> Result<Percent, GlibNoneError> {
|
||||
skip_assert_initialized!();
|
||||
unsafe { Self::try_from_glib(v as i64) }
|
||||
|
@ -388,6 +415,7 @@ impl TryFromGlib<i64> for Percent {
|
|||
impl TryFrom<u32> for Percent {
|
||||
type Error = FormattedValueError;
|
||||
|
||||
#[inline]
|
||||
fn try_from(value: u32) -> Result<Self, Self::Error> {
|
||||
skip_assert_initialized!();
|
||||
if value > ffi::GST_FORMAT_PERCENT_MAX as u32 {
|
||||
|
@ -401,6 +429,7 @@ impl TryFrom<u32> for Percent {
|
|||
impl TryFrom<GenericFormattedValue> for Option<Percent> {
|
||||
type Error = FormattedValueError;
|
||||
|
||||
#[inline]
|
||||
fn try_from(v: GenericFormattedValue) -> Result<Option<Percent>, Self::Error> {
|
||||
skip_assert_initialized!();
|
||||
if let GenericFormattedValue::Percent(v) = v {
|
||||
|
@ -416,6 +445,7 @@ impl SpecificFormattedValue for Option<Percent> {}
|
|||
impl SpecificFormattedValueFullRange for Option<Percent> {}
|
||||
impl SpecificFormattedValueIntrinsic for Percent {}
|
||||
impl FormattedValueNoneBuilder for Option<Percent> {
|
||||
#[inline]
|
||||
fn none() -> Option<Percent> {
|
||||
None
|
||||
}
|
||||
|
@ -428,6 +458,7 @@ pub struct TryPercentFromFloatError(());
|
|||
impl TryFrom<f64> for Percent {
|
||||
type Error = TryPercentFromFloatError;
|
||||
|
||||
#[inline]
|
||||
fn try_from(v: f64) -> Result<Self, Self::Error> {
|
||||
skip_assert_initialized!();
|
||||
if v < 0.0 || v > 1.0 {
|
||||
|
@ -443,6 +474,7 @@ impl TryFrom<f64> for Percent {
|
|||
impl TryFrom<f32> for Percent {
|
||||
type Error = TryPercentFromFloatError;
|
||||
|
||||
#[inline]
|
||||
fn try_from(v: f32) -> Result<Self, Self::Error> {
|
||||
skip_assert_initialized!();
|
||||
if v < 0.0 || v > 1.0 {
|
||||
|
@ -470,11 +502,13 @@ pub trait PercentFormatIntegerConstructor {
|
|||
|
||||
impl PercentFormatIntegerConstructor for u32 {
|
||||
#[track_caller]
|
||||
#[inline]
|
||||
fn percent(self) -> Percent {
|
||||
Percent::from_percent(self)
|
||||
}
|
||||
|
||||
#[track_caller]
|
||||
#[inline]
|
||||
fn ppm(self) -> Percent {
|
||||
Percent::from_ppm(self)
|
||||
}
|
||||
|
@ -491,6 +525,7 @@ pub trait PercentFormatFloatConstructor {
|
|||
|
||||
impl PercentFormatFloatConstructor for f32 {
|
||||
#[track_caller]
|
||||
#[inline]
|
||||
fn percent_ratio(self) -> Percent {
|
||||
Percent::try_from(self).unwrap()
|
||||
}
|
||||
|
|
|
@ -28,6 +28,7 @@ pub trait UndefinedFormatConstructor {
|
|||
|
||||
impl UndefinedFormatConstructor for i64 {
|
||||
#[track_caller]
|
||||
#[inline]
|
||||
fn undefined_format(self) -> Undefined {
|
||||
Undefined(self)
|
||||
}
|
||||
|
@ -36,24 +37,29 @@ impl UndefinedFormatConstructor for i64 {
|
|||
impl FormattedValue for Undefined {
|
||||
type FullRange = Undefined;
|
||||
|
||||
#[inline]
|
||||
fn default_format() -> Format {
|
||||
Format::Undefined
|
||||
}
|
||||
|
||||
#[inline]
|
||||
fn format(&self) -> Format {
|
||||
Format::Undefined
|
||||
}
|
||||
|
||||
#[inline]
|
||||
fn is_some(&self) -> bool {
|
||||
true
|
||||
}
|
||||
|
||||
#[inline]
|
||||
unsafe fn into_raw_value(self) -> i64 {
|
||||
self.0
|
||||
}
|
||||
}
|
||||
|
||||
impl FormattedValueFullRange for Undefined {
|
||||
#[inline]
|
||||
unsafe fn from_raw(format: Format, value: i64) -> Self {
|
||||
debug_assert_eq!(format, Format::Undefined);
|
||||
Undefined(value)
|
||||
|
@ -61,6 +67,7 @@ impl FormattedValueFullRange for Undefined {
|
|||
}
|
||||
|
||||
impl From<Undefined> for GenericFormattedValue {
|
||||
#[inline]
|
||||
fn from(v: Undefined) -> Self {
|
||||
skip_assert_initialized!();
|
||||
GenericFormattedValue::Undefined(v)
|
||||
|
@ -70,6 +77,7 @@ impl From<Undefined> for GenericFormattedValue {
|
|||
impl TryFrom<GenericFormattedValue> for Undefined {
|
||||
type Error = FormattedValueError;
|
||||
|
||||
#[inline]
|
||||
fn try_from(v: GenericFormattedValue) -> Result<Undefined, Self::Error> {
|
||||
skip_assert_initialized!();
|
||||
if let GenericFormattedValue::Undefined(v) = v {
|
||||
|
@ -92,6 +100,7 @@ impl TryFromGlib<i64> for Undefined {
|
|||
}
|
||||
|
||||
impl From<i64> for Undefined {
|
||||
#[inline]
|
||||
fn from(v: i64) -> Self {
|
||||
skip_assert_initialized!();
|
||||
Undefined(v)
|
||||
|
@ -101,30 +110,35 @@ impl From<i64> for Undefined {
|
|||
impl Deref for Undefined {
|
||||
type Target = i64;
|
||||
|
||||
#[inline]
|
||||
fn deref(&self) -> &i64 {
|
||||
&self.0
|
||||
}
|
||||
}
|
||||
|
||||
impl DerefMut for Undefined {
|
||||
#[inline]
|
||||
fn deref_mut(&mut self) -> &mut i64 {
|
||||
&mut self.0
|
||||
}
|
||||
}
|
||||
|
||||
impl AsRef<i64> for Undefined {
|
||||
#[inline]
|
||||
fn as_ref(&self) -> &i64 {
|
||||
&self.0
|
||||
}
|
||||
}
|
||||
|
||||
impl AsMut<i64> for Undefined {
|
||||
#[inline]
|
||||
fn as_mut(&mut self) -> &mut i64 {
|
||||
&mut self.0
|
||||
}
|
||||
}
|
||||
|
||||
impl From<Undefined> for Signed<u64> {
|
||||
#[inline]
|
||||
fn from(val: Undefined) -> Signed<u64> {
|
||||
skip_assert_initialized!();
|
||||
val.0.into()
|
||||
|
|
|
@ -203,6 +203,7 @@ where
|
|||
}
|
||||
|
||||
impl<T: 'static> IntoGlibPtr<*mut ffi::GstIterator> for Iterator<T> {
|
||||
#[inline]
|
||||
unsafe fn into_glib_ptr(self) -> *mut ffi::GstIterator {
|
||||
let s = mem::ManuallyDrop::new(self);
|
||||
let it = s.to_glib_none().0;
|
||||
|
@ -447,6 +448,7 @@ where
|
|||
}
|
||||
|
||||
impl<T: StaticType + 'static> Clone for Iterator<T> {
|
||||
#[inline]
|
||||
fn clone(&self) -> Self {
|
||||
unsafe { from_glib_full(ffi::gst_iterator_copy(self.to_glib_none().0)) }
|
||||
}
|
||||
|
@ -461,6 +463,7 @@ impl<T> fmt::Debug for Iterator<T> {
|
|||
}
|
||||
|
||||
impl<T> Drop for Iterator<T> {
|
||||
#[inline]
|
||||
fn drop(&mut self) {
|
||||
unsafe {
|
||||
ffi::gst_iterator_free(self.iter.as_ptr());
|
||||
|
@ -481,6 +484,7 @@ where
|
|||
}
|
||||
|
||||
impl<T> glib::types::StaticType for Iterator<T> {
|
||||
#[inline]
|
||||
fn static_type() -> glib::types::Type {
|
||||
unsafe { glib::translate::from_glib(ffi::gst_iterator_get_type()) }
|
||||
}
|
||||
|
@ -560,6 +564,7 @@ unsafe impl<T: StaticType + 'static> TransparentPtrType for Iterator<T> {}
|
|||
impl<'a, T: 'static> glib::translate::ToGlibPtr<'a, *const ffi::GstIterator> for Iterator<T> {
|
||||
type Storage = PhantomData<&'a Iterator<T>>;
|
||||
|
||||
#[inline]
|
||||
fn to_glib_none(&'a self) -> glib::translate::Stash<'a, *const ffi::GstIterator, Self> {
|
||||
glib::translate::Stash(self.iter.as_ptr(), PhantomData)
|
||||
}
|
||||
|
@ -650,6 +655,7 @@ impl<T> StdIterator<T> {
|
|||
}
|
||||
|
||||
impl<T: StaticType + 'static> Clone for StdIterator<T> {
|
||||
#[inline]
|
||||
fn clone(&self) -> Self {
|
||||
Self {
|
||||
inner: self.inner.clone(),
|
||||
|
|
|
@ -20,6 +20,7 @@ impl fmt::Debug for DebugMessage {
|
|||
|
||||
impl DebugMessage {
|
||||
#[doc(alias = "gst_debug_message_get")]
|
||||
#[inline]
|
||||
pub fn get(&self) -> Option<Cow<glib::GStr>> {
|
||||
unsafe {
|
||||
let message = ffi::gst_debug_message_get(self.0.as_ptr());
|
||||
|
@ -35,6 +36,7 @@ impl DebugMessage {
|
|||
#[cfg(any(feature = "v1_22", feature = "dox"))]
|
||||
#[cfg_attr(feature = "dox", doc(cfg(feature = "v1_22")))]
|
||||
#[doc(alias = "gst_debug_message_get_id")]
|
||||
#[inline]
|
||||
pub fn id(&self) -> Option<&glib::GStr> {
|
||||
unsafe {
|
||||
let id = ffi::gst_debug_message_get_id(self.0.as_ptr());
|
||||
|
@ -83,6 +85,7 @@ impl DebugCategory {
|
|||
}
|
||||
|
||||
#[doc(alias = "gst_debug_get_category")]
|
||||
#[inline]
|
||||
pub fn get(name: &str) -> Option<DebugCategory> {
|
||||
skip_assert_initialized!();
|
||||
unsafe {
|
||||
|
@ -102,6 +105,7 @@ impl DebugCategory {
|
|||
|
||||
#[doc(alias = "get_threshold")]
|
||||
#[doc(alias = "gst_debug_category_get_threshold")]
|
||||
#[inline]
|
||||
pub fn threshold(self) -> crate::DebugLevel {
|
||||
match self.0 {
|
||||
Some(cat) => unsafe { from_glib(cat.as_ref().threshold) },
|
||||
|
@ -110,6 +114,7 @@ impl DebugCategory {
|
|||
}
|
||||
|
||||
#[doc(alias = "gst_debug_category_set_threshold")]
|
||||
#[inline]
|
||||
pub fn set_threshold(self, threshold: crate::DebugLevel) {
|
||||
if let Some(cat) = self.0 {
|
||||
unsafe { ffi::gst_debug_category_set_threshold(cat.as_ptr(), threshold.into_glib()) }
|
||||
|
@ -117,6 +122,7 @@ impl DebugCategory {
|
|||
}
|
||||
|
||||
#[doc(alias = "gst_debug_category_reset_threshold")]
|
||||
#[inline]
|
||||
pub fn reset_threshold(self) {
|
||||
if let Some(cat) = self.0 {
|
||||
unsafe { ffi::gst_debug_category_reset_threshold(cat.as_ptr()) }
|
||||
|
@ -133,6 +139,7 @@ impl DebugCategory {
|
|||
|
||||
#[doc(alias = "get_color")]
|
||||
#[doc(alias = "gst_debug_category_get_color")]
|
||||
#[inline]
|
||||
pub fn color(self) -> crate::DebugColorFlags {
|
||||
match self.0 {
|
||||
Some(cat) => unsafe { from_glib(cat.as_ref().color) },
|
||||
|
@ -142,6 +149,7 @@ impl DebugCategory {
|
|||
|
||||
#[doc(alias = "get_name")]
|
||||
#[doc(alias = "gst_debug_category_get_name")]
|
||||
#[inline]
|
||||
pub fn name<'a>(self) -> &'a str {
|
||||
match self.0 {
|
||||
Some(cat) => unsafe { CStr::from_ptr(cat.as_ref().name).to_str().unwrap() },
|
||||
|
@ -151,6 +159,7 @@ impl DebugCategory {
|
|||
|
||||
#[doc(alias = "get_description")]
|
||||
#[doc(alias = "gst_debug_category_get_description")]
|
||||
#[inline]
|
||||
pub fn description<'a>(self) -> Option<&'a str> {
|
||||
let cat = self.0?;
|
||||
|
||||
|
@ -464,6 +473,7 @@ impl DebugCategory {
|
|||
|
||||
#[doc(alias = "get_all_categories")]
|
||||
#[doc(alias = "gst_debug_get_all_categories")]
|
||||
#[inline]
|
||||
pub fn all_categories() -> glib::SList<DebugCategory> {
|
||||
unsafe { glib::SList::from_glib_container(ffi::gst_debug_get_all_categories()) }
|
||||
}
|
||||
|
@ -471,6 +481,7 @@ impl DebugCategory {
|
|||
#[cfg(any(feature = "v1_18", feature = "dox"))]
|
||||
#[cfg_attr(feature = "dox", doc(cfg(feature = "v1_18")))]
|
||||
#[doc(alias = "gst_debug_log_get_line")]
|
||||
#[inline]
|
||||
pub fn get_line(
|
||||
&self,
|
||||
level: crate::DebugLevel,
|
||||
|
@ -512,6 +523,7 @@ impl GlibPtrDefault for DebugCategory {
|
|||
unsafe impl TransparentPtrType for DebugCategory {}
|
||||
|
||||
impl FromGlibPtrNone<*mut ffi::GstDebugCategory> for DebugCategory {
|
||||
#[inline]
|
||||
unsafe fn from_glib_none(ptr: *mut ffi::GstDebugCategory) -> Self {
|
||||
assert!(!ptr.is_null());
|
||||
DebugCategory(Some(ptr::NonNull::new_unchecked(ptr)))
|
||||
|
@ -519,6 +531,7 @@ impl FromGlibPtrNone<*mut ffi::GstDebugCategory> for DebugCategory {
|
|||
}
|
||||
|
||||
impl FromGlibPtrFull<*mut ffi::GstDebugCategory> for DebugCategory {
|
||||
#[inline]
|
||||
unsafe fn from_glib_full(ptr: *mut ffi::GstDebugCategory) -> Self {
|
||||
assert!(!ptr.is_null());
|
||||
DebugCategory(Some(ptr::NonNull::new_unchecked(ptr)))
|
||||
|
@ -1064,6 +1077,7 @@ unsafe impl Sync for DebugLogFunction {}
|
|||
pub struct LoggedObject(ptr::NonNull<glib::gobject_ffi::GObject>);
|
||||
|
||||
impl LoggedObject {
|
||||
#[inline]
|
||||
pub fn as_ptr(&self) -> *mut glib::gobject_ffi::GObject {
|
||||
self.0.as_ptr()
|
||||
}
|
||||
|
|
|
@ -123,6 +123,7 @@ impl Memory {
|
|||
}
|
||||
}
|
||||
|
||||
#[inline]
|
||||
pub fn into_mapped_memory_readable(self) -> Result<MappedMemory<Readable>, Self> {
|
||||
unsafe {
|
||||
let mut map_info = mem::MaybeUninit::uninit();
|
||||
|
@ -143,6 +144,7 @@ impl Memory {
|
|||
}
|
||||
}
|
||||
|
||||
#[inline]
|
||||
pub fn into_mapped_memory_writable(self) -> Result<MappedMemory<Writable>, Self> {
|
||||
unsafe {
|
||||
let mut map_info = mem::MaybeUninit::uninit();
|
||||
|
@ -166,6 +168,7 @@ impl Memory {
|
|||
|
||||
impl MemoryRef {
|
||||
#[doc(alias = "get_allocator")]
|
||||
#[inline]
|
||||
pub fn allocator(&self) -> Option<&Allocator> {
|
||||
unsafe {
|
||||
if self.0.allocator.is_null() {
|
||||
|
@ -177,6 +180,7 @@ impl MemoryRef {
|
|||
}
|
||||
|
||||
#[doc(alias = "get_parent")]
|
||||
#[inline]
|
||||
pub fn parent(&self) -> Option<&MemoryRef> {
|
||||
unsafe {
|
||||
if self.0.parent.is_null() {
|
||||
|
@ -188,26 +192,31 @@ impl MemoryRef {
|
|||
}
|
||||
|
||||
#[doc(alias = "get_maxsize")]
|
||||
#[inline]
|
||||
pub fn maxsize(&self) -> usize {
|
||||
self.0.maxsize
|
||||
}
|
||||
|
||||
#[doc(alias = "get_align")]
|
||||
#[inline]
|
||||
pub fn align(&self) -> usize {
|
||||
self.0.align
|
||||
}
|
||||
|
||||
#[doc(alias = "get_offset")]
|
||||
#[inline]
|
||||
pub fn offset(&self) -> usize {
|
||||
self.0.offset
|
||||
}
|
||||
|
||||
#[doc(alias = "get_size")]
|
||||
#[inline]
|
||||
pub fn size(&self) -> usize {
|
||||
self.0.size
|
||||
}
|
||||
|
||||
#[doc(alias = "get_flags")]
|
||||
#[inline]
|
||||
pub fn flags(&self) -> MemoryFlags {
|
||||
unsafe { from_glib(self.0.mini_object.flags) }
|
||||
}
|
||||
|
@ -257,6 +266,7 @@ impl MemoryRef {
|
|||
}
|
||||
}
|
||||
|
||||
#[inline]
|
||||
pub fn map_readable(&self) -> Result<MemoryMap<Readable>, glib::BoolError> {
|
||||
unsafe {
|
||||
let mut map_info = mem::MaybeUninit::uninit();
|
||||
|
@ -274,6 +284,7 @@ impl MemoryRef {
|
|||
}
|
||||
}
|
||||
|
||||
#[inline]
|
||||
pub fn map_writable(&mut self) -> Result<MemoryMap<Writable>, glib::BoolError> {
|
||||
unsafe {
|
||||
let mut map_info = mem::MaybeUninit::uninit();
|
||||
|
@ -326,15 +337,18 @@ impl MemoryRef {
|
|||
|
||||
impl<'a, T> MemoryMap<'a, T> {
|
||||
#[doc(alias = "get_size")]
|
||||
#[inline]
|
||||
pub fn size(&self) -> usize {
|
||||
self.map_info.size
|
||||
}
|
||||
|
||||
#[doc(alias = "get_memory")]
|
||||
#[inline]
|
||||
pub fn memory(&self) -> &MemoryRef {
|
||||
self.memory
|
||||
}
|
||||
|
||||
#[inline]
|
||||
pub fn as_slice(&self) -> &[u8] {
|
||||
if self.map_info.size == 0 {
|
||||
return &[];
|
||||
|
@ -344,6 +358,7 @@ impl<'a, T> MemoryMap<'a, T> {
|
|||
}
|
||||
|
||||
impl<'a> MemoryMap<'a, Writable> {
|
||||
#[inline]
|
||||
pub fn as_mut_slice(&mut self) -> &mut [u8] {
|
||||
if self.map_info.size == 0 {
|
||||
return &mut [];
|
||||
|
@ -353,12 +368,14 @@ impl<'a> MemoryMap<'a, Writable> {
|
|||
}
|
||||
|
||||
impl<'a, T> AsRef<[u8]> for MemoryMap<'a, T> {
|
||||
#[inline]
|
||||
fn as_ref(&self) -> &[u8] {
|
||||
self.as_slice()
|
||||
}
|
||||
}
|
||||
|
||||
impl<'a> AsMut<[u8]> for MemoryMap<'a, Writable> {
|
||||
#[inline]
|
||||
fn as_mut(&mut self) -> &mut [u8] {
|
||||
self.as_mut_slice()
|
||||
}
|
||||
|
@ -367,12 +384,14 @@ impl<'a> AsMut<[u8]> for MemoryMap<'a, Writable> {
|
|||
impl<'a, T> Deref for MemoryMap<'a, T> {
|
||||
type Target = [u8];
|
||||
|
||||
#[inline]
|
||||
fn deref(&self) -> &[u8] {
|
||||
self.as_slice()
|
||||
}
|
||||
}
|
||||
|
||||
impl<'a> DerefMut for MemoryMap<'a, Writable> {
|
||||
#[inline]
|
||||
fn deref_mut(&mut self) -> &mut [u8] {
|
||||
self.as_mut_slice()
|
||||
}
|
||||
|
@ -393,6 +412,7 @@ impl<'a, T> PartialEq for MemoryMap<'a, T> {
|
|||
impl<'a, T> Eq for MemoryMap<'a, T> {}
|
||||
|
||||
impl<'a, T> Drop for MemoryMap<'a, T> {
|
||||
#[inline]
|
||||
fn drop(&mut self) {
|
||||
unsafe {
|
||||
ffi::gst_memory_unmap(self.memory.as_mut_ptr(), &mut self.map_info);
|
||||
|
@ -404,6 +424,7 @@ unsafe impl<'a, T> Send for MemoryMap<'a, T> {}
|
|||
unsafe impl<'a, T> Sync for MemoryMap<'a, T> {}
|
||||
|
||||
impl<T> MappedMemory<T> {
|
||||
#[inline]
|
||||
pub fn as_slice(&self) -> &[u8] {
|
||||
if self.map_info.size == 0 {
|
||||
return &[];
|
||||
|
@ -412,15 +433,18 @@ impl<T> MappedMemory<T> {
|
|||
}
|
||||
|
||||
#[doc(alias = "get_size")]
|
||||
#[inline]
|
||||
pub fn size(&self) -> usize {
|
||||
self.map_info.size
|
||||
}
|
||||
|
||||
#[doc(alias = "get_memory")]
|
||||
#[inline]
|
||||
pub fn memory(&self) -> &MemoryRef {
|
||||
self.memory.as_ref()
|
||||
}
|
||||
|
||||
#[inline]
|
||||
pub fn into_memory(self) -> Memory {
|
||||
let mut s = mem::ManuallyDrop::new(self);
|
||||
let memory = unsafe { ptr::read(&s.memory) };
|
||||
|
@ -433,6 +457,7 @@ impl<T> MappedMemory<T> {
|
|||
}
|
||||
|
||||
impl MappedMemory<Writable> {
|
||||
#[inline]
|
||||
pub fn as_mut_slice(&mut self) -> &mut [u8] {
|
||||
if self.map_info.size == 0 {
|
||||
return &mut [];
|
||||
|
@ -442,12 +467,14 @@ impl MappedMemory<Writable> {
|
|||
}
|
||||
|
||||
impl<T> AsRef<[u8]> for MappedMemory<T> {
|
||||
#[inline]
|
||||
fn as_ref(&self) -> &[u8] {
|
||||
self.as_slice()
|
||||
}
|
||||
}
|
||||
|
||||
impl AsMut<[u8]> for MappedMemory<Writable> {
|
||||
#[inline]
|
||||
fn as_mut(&mut self) -> &mut [u8] {
|
||||
self.as_mut_slice()
|
||||
}
|
||||
|
@ -456,18 +483,21 @@ impl AsMut<[u8]> for MappedMemory<Writable> {
|
|||
impl<T> Deref for MappedMemory<T> {
|
||||
type Target = [u8];
|
||||
|
||||
#[inline]
|
||||
fn deref(&self) -> &[u8] {
|
||||
self.as_slice()
|
||||
}
|
||||
}
|
||||
|
||||
impl DerefMut for MappedMemory<Writable> {
|
||||
#[inline]
|
||||
fn deref_mut(&mut self) -> &mut [u8] {
|
||||
self.as_mut_slice()
|
||||
}
|
||||
}
|
||||
|
||||
impl<T> Drop for MappedMemory<T> {
|
||||
#[inline]
|
||||
fn drop(&mut self) {
|
||||
unsafe {
|
||||
ffi::gst_memory_unmap(self.memory.as_mut_ptr(), &mut self.map_info);
|
||||
|
@ -576,24 +606,28 @@ where
|
|||
}
|
||||
|
||||
impl AsRef<MemoryRef> for MemoryRef {
|
||||
#[inline]
|
||||
fn as_ref(&self) -> &MemoryRef {
|
||||
self
|
||||
}
|
||||
}
|
||||
|
||||
impl AsMut<MemoryRef> for MemoryRef {
|
||||
#[inline]
|
||||
fn as_mut(&mut self) -> &mut MemoryRef {
|
||||
self
|
||||
}
|
||||
}
|
||||
|
||||
impl AsRef<Memory> for Memory {
|
||||
#[inline]
|
||||
fn as_ref(&self) -> &Memory {
|
||||
self
|
||||
}
|
||||
}
|
||||
|
||||
unsafe impl MemoryType for Memory {
|
||||
#[inline]
|
||||
fn check_memory_type(_mem: &MemoryRef) -> bool {
|
||||
skip_assert_initialized!();
|
||||
true
|
||||
|
@ -601,6 +635,7 @@ unsafe impl MemoryType for Memory {
|
|||
}
|
||||
|
||||
impl Memory {
|
||||
#[inline]
|
||||
pub fn downcast_memory<M: MemoryType>(self) -> Result<M, Self>
|
||||
where
|
||||
<M as crate::prelude::IsMiniObject>::RefType: AsRef<MemoryRef> + AsMut<MemoryRef>,
|
||||
|
@ -614,6 +649,7 @@ impl Memory {
|
|||
}
|
||||
|
||||
impl MemoryRef {
|
||||
#[inline]
|
||||
pub fn is_memory_type<M: MemoryType>(&self) -> bool
|
||||
where
|
||||
<M as crate::prelude::IsMiniObject>::RefType: AsRef<MemoryRef> + AsMut<MemoryRef>,
|
||||
|
@ -621,6 +657,7 @@ impl MemoryRef {
|
|||
M::check_memory_type(self)
|
||||
}
|
||||
|
||||
#[inline]
|
||||
pub fn downcast_memory_ref<M: MemoryType>(&self) -> Option<&M::RefType>
|
||||
where
|
||||
<M as crate::prelude::IsMiniObject>::RefType: AsRef<MemoryRef> + AsMut<MemoryRef>,
|
||||
|
@ -632,6 +669,7 @@ impl MemoryRef {
|
|||
}
|
||||
}
|
||||
|
||||
#[inline]
|
||||
pub fn downcast_memory_mut<M: MemoryType>(&mut self) -> Option<&mut M::RefType>
|
||||
where
|
||||
<M as crate::prelude::IsMiniObject>::RefType: AsRef<MemoryRef> + AsMut<MemoryRef>,
|
||||
|
@ -650,6 +688,7 @@ macro_rules! memory_object_wrapper {
|
|||
$crate::mini_object_wrapper!($name, $ref_name, $ffi_name);
|
||||
|
||||
unsafe impl $crate::memory::MemoryType for $name {
|
||||
#[inline]
|
||||
fn check_memory_type(mem: &$crate::MemoryRef) -> bool {
|
||||
skip_assert_initialized!();
|
||||
$mem_type_check(mem)
|
||||
|
@ -657,6 +696,7 @@ macro_rules! memory_object_wrapper {
|
|||
}
|
||||
|
||||
impl $name {
|
||||
#[inline]
|
||||
pub fn downcast_memory<M: $crate::memory::MemoryType>(self) -> Result<M, Self>
|
||||
where
|
||||
<M as $crate::miniobject::IsMiniObject>::RefType: AsRef<$crate::MemoryRef>
|
||||
|
@ -675,6 +715,7 @@ macro_rules! memory_object_wrapper {
|
|||
}
|
||||
}
|
||||
|
||||
#[inline]
|
||||
pub fn upcast_memory<M>(self) -> M
|
||||
where
|
||||
M: $crate::memory::MemoryType
|
||||
|
@ -694,6 +735,7 @@ macro_rules! memory_object_wrapper {
|
|||
}
|
||||
|
||||
impl $ref_name {
|
||||
#[inline]
|
||||
pub fn upcast_memory_ref<M>(&self) -> &M::RefType
|
||||
where
|
||||
M: $crate::memory::MemoryType,
|
||||
|
@ -704,6 +746,7 @@ macro_rules! memory_object_wrapper {
|
|||
self.as_ref()
|
||||
}
|
||||
|
||||
#[inline]
|
||||
pub fn upcast_memory_mut<M>(&mut self) -> &mut M::RefType
|
||||
where
|
||||
M: $crate::memory::MemoryType,
|
||||
|
@ -718,42 +761,49 @@ macro_rules! memory_object_wrapper {
|
|||
impl std::ops::Deref for $ref_name {
|
||||
type Target = $parent_memory_ref_type;
|
||||
|
||||
#[inline]
|
||||
fn deref(&self) -> &Self::Target {
|
||||
unsafe { &*(self as *const _ as *const Self::Target) }
|
||||
}
|
||||
}
|
||||
|
||||
impl std::ops::DerefMut for $ref_name {
|
||||
#[inline]
|
||||
fn deref_mut(&mut self) -> &mut Self::Target {
|
||||
unsafe { &mut *(self as *mut _ as *mut Self::Target) }
|
||||
}
|
||||
}
|
||||
|
||||
impl AsRef<$parent_memory_type> for $name {
|
||||
#[inline]
|
||||
fn as_ref(&self) -> &$parent_memory_type {
|
||||
unsafe { &*(self as *const _ as *const $parent_memory_type) }
|
||||
}
|
||||
}
|
||||
|
||||
impl AsRef<$parent_memory_ref_type> for $ref_name {
|
||||
#[inline]
|
||||
fn as_ref(&self) -> &$parent_memory_ref_type {
|
||||
self
|
||||
}
|
||||
}
|
||||
|
||||
impl AsMut<$parent_memory_ref_type> for $ref_name {
|
||||
#[inline]
|
||||
fn as_mut(&mut self) -> &mut $parent_memory_ref_type {
|
||||
&mut *self
|
||||
}
|
||||
}
|
||||
|
||||
impl $crate::glib::types::StaticType for $name {
|
||||
#[inline]
|
||||
fn static_type() -> glib::types::Type {
|
||||
$ref_name::static_type()
|
||||
}
|
||||
}
|
||||
|
||||
impl $crate::glib::types::StaticType for $ref_name {
|
||||
#[inline]
|
||||
fn static_type() -> $crate::glib::types::Type {
|
||||
unsafe { $crate::glib::translate::from_glib($crate::ffi::gst_memory_get_type()) }
|
||||
}
|
||||
|
@ -856,18 +906,21 @@ macro_rules! memory_object_wrapper {
|
|||
|
||||
$(
|
||||
impl AsRef<$parent_parent_memory_type> for $name {
|
||||
#[inline]
|
||||
fn as_ref(&self) -> &$parent_parent_memory_type {
|
||||
unsafe { &*(self as *const _ as *const $parent_parent_memory_type) }
|
||||
}
|
||||
}
|
||||
|
||||
impl AsRef<$parent_parent_memory_ref_type> for $ref_name {
|
||||
#[inline]
|
||||
fn as_ref(&self) -> &$parent_parent_memory_ref_type {
|
||||
self
|
||||
}
|
||||
}
|
||||
|
||||
impl AsMut<$parent_parent_memory_ref_type> for $ref_name {
|
||||
#[inline]
|
||||
fn as_mut(&mut self) -> &mut $parent_parent_memory_ref_type {
|
||||
&mut *self
|
||||
}
|
||||
|
|
|
@ -17,6 +17,7 @@ mini_object_wrapper!(Message, MessageRef, ffi::GstMessage, || {
|
|||
|
||||
impl MessageRef {
|
||||
#[doc(alias = "get_src")]
|
||||
#[inline]
|
||||
pub fn src(&self) -> Option<&Object> {
|
||||
unsafe {
|
||||
if (*self.as_ptr()).src.is_null() {
|
||||
|
@ -54,6 +55,7 @@ impl MessageRef {
|
|||
|
||||
#[doc(alias = "get_structure")]
|
||||
#[doc(alias = "gst_message_get_structure")]
|
||||
#[inline]
|
||||
pub fn structure(&self) -> Option<&StructureRef> {
|
||||
unsafe {
|
||||
let structure = ffi::gst_message_get_structure(self.as_mut_ptr());
|
||||
|
@ -66,6 +68,7 @@ impl MessageRef {
|
|||
}
|
||||
|
||||
#[doc(alias = "gst_message_has_name")]
|
||||
#[inline]
|
||||
pub fn has_name(&self, name: &str) -> bool {
|
||||
self.structure().map_or(false, |s| s.has_name(name))
|
||||
}
|
||||
|
@ -122,6 +125,7 @@ impl MessageRef {
|
|||
}
|
||||
|
||||
#[doc(alias = "get_type")]
|
||||
#[inline]
|
||||
pub fn type_(&self) -> MessageType {
|
||||
unsafe { from_glib((*self.as_ptr()).type_) }
|
||||
}
|
||||
|
@ -223,10 +227,12 @@ macro_rules! declare_concrete_message(
|
|||
pub struct $name<$param = MessageRef>($param);
|
||||
|
||||
impl $name {
|
||||
#[inline]
|
||||
pub fn message(&self) -> &MessageRef {
|
||||
unsafe { &*(self as *const Self as *const MessageRef) }
|
||||
}
|
||||
|
||||
#[inline]
|
||||
unsafe fn view(message: &MessageRef) -> MessageView<'_> {
|
||||
let message = &*(message as *const MessageRef as *const Self);
|
||||
MessageView::$name(message)
|
||||
|
@ -236,6 +242,7 @@ macro_rules! declare_concrete_message(
|
|||
impl Deref for $name {
|
||||
type Target = MessageRef;
|
||||
|
||||
#[inline]
|
||||
fn deref(&self) -> &Self::Target {
|
||||
unsafe {
|
||||
&*(self as *const Self as *const Self::Target)
|
||||
|
@ -246,12 +253,14 @@ macro_rules! declare_concrete_message(
|
|||
impl ToOwned for $name {
|
||||
type Owned = $name<Message>;
|
||||
|
||||
#[inline]
|
||||
fn to_owned(&self) -> Self::Owned {
|
||||
$name::<Message>(self.copy())
|
||||
}
|
||||
}
|
||||
|
||||
impl $name<Message> {
|
||||
#[inline]
|
||||
pub fn get_mut(&mut self) -> Option<&mut $name> {
|
||||
self.0.get_mut().map(|message| unsafe {
|
||||
&mut *(message as *mut MessageRef as *mut $name)
|
||||
|
@ -262,18 +271,21 @@ macro_rules! declare_concrete_message(
|
|||
impl Deref for $name<Message> {
|
||||
type Target = $name;
|
||||
|
||||
#[inline]
|
||||
fn deref(&self) -> &Self::Target {
|
||||
unsafe { &*(self.0.as_ptr() as *const Self::Target) }
|
||||
}
|
||||
}
|
||||
|
||||
impl Borrow<$name> for $name<Message> {
|
||||
#[inline]
|
||||
fn borrow(&self) -> &$name {
|
||||
&*self
|
||||
}
|
||||
}
|
||||
|
||||
impl From<$name<Message>> for Message {
|
||||
#[inline]
|
||||
fn from(concrete: $name<Message>) -> Self {
|
||||
skip_assert_initialized!();
|
||||
concrete.0
|
||||
|
|
|
@ -15,6 +15,7 @@ pub unsafe trait MetaAPI: Sync + Send + Sized {
|
|||
#[doc(alias = "get_meta_api")]
|
||||
fn meta_api() -> glib::Type;
|
||||
|
||||
#[inline]
|
||||
unsafe fn from_ptr(buffer: &BufferRef, ptr: *const Self::GstType) -> MetaRef<Self> {
|
||||
assert!(!ptr.is_null());
|
||||
|
||||
|
@ -32,6 +33,7 @@ pub unsafe trait MetaAPI: Sync + Send + Sized {
|
|||
}
|
||||
}
|
||||
|
||||
#[inline]
|
||||
unsafe fn from_mut_ptr<T>(
|
||||
buffer: &mut BufferRef,
|
||||
ptr: *mut Self::GstType,
|
||||
|
@ -95,12 +97,14 @@ impl<'a, T: fmt::Debug + 'a, U> fmt::Debug for MetaRefMut<'a, T, U> {
|
|||
impl<'a, T> ops::Deref for MetaRef<'a, T> {
|
||||
type Target = T;
|
||||
|
||||
#[inline]
|
||||
fn deref(&self) -> &T {
|
||||
self.meta
|
||||
}
|
||||
}
|
||||
|
||||
impl<'a, T> AsRef<MetaRef<'a, T>> for MetaRef<'a, T> {
|
||||
#[inline]
|
||||
fn as_ref(&self) -> &MetaRef<'a, T> {
|
||||
self
|
||||
}
|
||||
|
@ -109,18 +113,21 @@ impl<'a, T> AsRef<MetaRef<'a, T>> for MetaRef<'a, T> {
|
|||
impl<'a, T, U> ops::Deref for MetaRefMut<'a, T, U> {
|
||||
type Target = T;
|
||||
|
||||
#[inline]
|
||||
fn deref(&self) -> &T {
|
||||
self.meta
|
||||
}
|
||||
}
|
||||
|
||||
impl<'a, T, U> ops::DerefMut for MetaRefMut<'a, T, U> {
|
||||
#[inline]
|
||||
fn deref_mut(&mut self) -> &mut T {
|
||||
self.meta
|
||||
}
|
||||
}
|
||||
|
||||
impl<'a, T, U> AsRef<MetaRef<'a, T>> for MetaRefMut<'a, T, U> {
|
||||
#[inline]
|
||||
fn as_ref(&self) -> &MetaRef<'a, T> {
|
||||
unsafe { &*(self as *const MetaRefMut<'a, T, U> as *const MetaRef<'a, T>) }
|
||||
}
|
||||
|
@ -128,6 +135,7 @@ impl<'a, T, U> AsRef<MetaRef<'a, T>> for MetaRefMut<'a, T, U> {
|
|||
|
||||
impl<'a, T> MetaRef<'a, T> {
|
||||
#[doc(alias = "get_api")]
|
||||
#[inline]
|
||||
pub fn api(&self) -> glib::Type {
|
||||
unsafe {
|
||||
let meta = self.meta as *const _ as *const ffi::GstMeta;
|
||||
|
@ -136,6 +144,7 @@ impl<'a, T> MetaRef<'a, T> {
|
|||
}
|
||||
}
|
||||
|
||||
#[inline]
|
||||
pub fn flags(&self) -> crate::MetaFlags {
|
||||
unsafe {
|
||||
let meta = self.meta as *const _ as *const ffi::GstMeta;
|
||||
|
@ -143,6 +152,7 @@ impl<'a, T> MetaRef<'a, T> {
|
|||
}
|
||||
}
|
||||
|
||||
#[inline]
|
||||
pub fn type_(&self) -> glib::Type {
|
||||
unsafe {
|
||||
let meta = self.meta as *const _ as *const ffi::GstMeta;
|
||||
|
@ -155,6 +165,7 @@ impl<'a, T> MetaRef<'a, T> {
|
|||
#[cfg_attr(feature = "dox", doc(cfg(feature = "v1_16")))]
|
||||
#[doc(alias = "get_seqnum")]
|
||||
#[doc(alias = "gst_meta_get_seqnum")]
|
||||
#[inline]
|
||||
pub fn seqnum(&self) -> MetaSeqnum {
|
||||
unsafe {
|
||||
let meta = self.meta as *const _ as *const ffi::GstMeta;
|
||||
|
@ -162,6 +173,7 @@ impl<'a, T> MetaRef<'a, T> {
|
|||
}
|
||||
}
|
||||
|
||||
#[inline]
|
||||
pub fn as_ptr(&self) -> *const T::GstType
|
||||
where
|
||||
T: MetaAPI,
|
||||
|
@ -171,6 +183,7 @@ impl<'a, T> MetaRef<'a, T> {
|
|||
}
|
||||
|
||||
impl<'a> MetaRef<'a, Meta> {
|
||||
#[inline]
|
||||
pub fn downcast_ref<T: MetaAPI>(&self) -> Option<&MetaRef<'a, T>> {
|
||||
let target_type = T::meta_api();
|
||||
let type_ = self.api();
|
||||
|
@ -184,6 +197,7 @@ impl<'a> MetaRef<'a, Meta> {
|
|||
|
||||
#[cfg(any(feature = "v1_20", feature = "dox"))]
|
||||
#[cfg_attr(feature = "dox", doc(cfg(feature = "v1_20")))]
|
||||
#[inline]
|
||||
pub fn try_as_custom_meta(&self) -> Option<&MetaRef<'a, CustomMeta>> {
|
||||
unsafe {
|
||||
if ffi::gst_meta_info_is_custom(&*self.0.info) == glib::ffi::GFALSE {
|
||||
|
@ -197,6 +211,7 @@ impl<'a> MetaRef<'a, Meta> {
|
|||
|
||||
impl<'a, T, U> MetaRefMut<'a, T, U> {
|
||||
#[doc(alias = "get_api")]
|
||||
#[inline]
|
||||
pub fn api(&self) -> glib::Type {
|
||||
unsafe {
|
||||
let meta = self.meta as *const _ as *const ffi::GstMeta;
|
||||
|
@ -205,6 +220,7 @@ impl<'a, T, U> MetaRefMut<'a, T, U> {
|
|||
}
|
||||
}
|
||||
|
||||
#[inline]
|
||||
pub fn flags(&self) -> crate::MetaFlags {
|
||||
unsafe {
|
||||
let meta = self.meta as *const _ as *const ffi::GstMeta;
|
||||
|
@ -212,6 +228,7 @@ impl<'a, T, U> MetaRefMut<'a, T, U> {
|
|||
}
|
||||
}
|
||||
|
||||
#[inline]
|
||||
pub fn type_(&self) -> glib::Type {
|
||||
unsafe {
|
||||
let meta = self.meta as *const _ as *const ffi::GstMeta;
|
||||
|
@ -224,6 +241,7 @@ impl<'a, T, U> MetaRefMut<'a, T, U> {
|
|||
#[cfg_attr(feature = "dox", doc(cfg(feature = "v1_16")))]
|
||||
#[doc(alias = "get_seqnum")]
|
||||
#[doc(alias = "gst_meta_get_seqnum")]
|
||||
#[inline]
|
||||
pub fn seqnum(&self) -> u64 {
|
||||
unsafe {
|
||||
let meta = self.meta as *const _ as *const ffi::GstMeta;
|
||||
|
@ -231,6 +249,7 @@ impl<'a, T, U> MetaRefMut<'a, T, U> {
|
|||
}
|
||||
}
|
||||
|
||||
#[inline]
|
||||
pub fn as_ptr(&self) -> *const T::GstType
|
||||
where
|
||||
T: MetaAPI,
|
||||
|
@ -238,6 +257,7 @@ impl<'a, T, U> MetaRefMut<'a, T, U> {
|
|||
self.meta as *const _ as *const <T as MetaAPI>::GstType
|
||||
}
|
||||
|
||||
#[inline]
|
||||
pub fn as_mut_ptr(&mut self) -> *mut T::GstType
|
||||
where
|
||||
T: MetaAPI,
|
||||
|
@ -266,6 +286,7 @@ impl<'a, T> MetaRefMut<'a, T, Standalone> {
|
|||
}
|
||||
|
||||
impl<'a, U> MetaRefMut<'a, Meta, U> {
|
||||
#[inline]
|
||||
pub fn downcast_ref<T: MetaAPI>(&mut self) -> Option<&MetaRefMut<'a, T, U>> {
|
||||
let target_type = T::meta_api();
|
||||
let type_ = self.api();
|
||||
|
@ -277,6 +298,7 @@ impl<'a, U> MetaRefMut<'a, Meta, U> {
|
|||
}
|
||||
}
|
||||
|
||||
#[inline]
|
||||
pub fn downcast_mut<T: MetaAPI>(&mut self) -> Option<&mut MetaRefMut<'a, T, U>> {
|
||||
let target_type = T::meta_api();
|
||||
let type_ = self.api();
|
||||
|
@ -292,6 +314,7 @@ impl<'a, U> MetaRefMut<'a, Meta, U> {
|
|||
|
||||
#[cfg(any(feature = "v1_20", feature = "dox"))]
|
||||
#[cfg_attr(feature = "dox", doc(cfg(feature = "v1_20")))]
|
||||
#[inline]
|
||||
pub fn try_as_custom_meta(&self) -> Option<&MetaRefMut<'a, CustomMeta, U>> {
|
||||
unsafe {
|
||||
if ffi::gst_meta_info_is_custom(&*self.0.info) == glib::ffi::GFALSE {
|
||||
|
@ -304,6 +327,7 @@ impl<'a, U> MetaRefMut<'a, Meta, U> {
|
|||
|
||||
#[cfg(any(feature = "v1_20", feature = "dox"))]
|
||||
#[cfg_attr(feature = "dox", doc(cfg(feature = "v1_20")))]
|
||||
#[inline]
|
||||
pub fn try_as_mut_custom_meta(&mut self) -> Option<&mut MetaRefMut<'a, CustomMeta, U>> {
|
||||
unsafe {
|
||||
if ffi::gst_meta_info_is_custom(&*self.0.info) == glib::ffi::GFALSE {
|
||||
|
@ -324,10 +348,12 @@ unsafe impl Sync for Meta {}
|
|||
|
||||
impl Meta {
|
||||
#[doc(alias = "get_api")]
|
||||
#[inline]
|
||||
fn api(&self) -> glib::Type {
|
||||
unsafe { glib::Type::from_glib((*self.0.info).api) }
|
||||
}
|
||||
|
||||
#[inline]
|
||||
pub fn flags(&self) -> crate::MetaFlags {
|
||||
unsafe { from_glib(self.0.flags) }
|
||||
}
|
||||
|
@ -336,6 +362,7 @@ impl Meta {
|
|||
unsafe impl MetaAPI for Meta {
|
||||
type GstType = ffi::GstMeta;
|
||||
|
||||
#[inline]
|
||||
fn meta_api() -> glib::Type {
|
||||
glib::Type::INVALID
|
||||
}
|
||||
|
@ -369,11 +396,13 @@ impl ParentBufferMeta {
|
|||
}
|
||||
|
||||
#[doc(alias = "get_parent")]
|
||||
#[inline]
|
||||
pub fn parent(&self) -> &BufferRef {
|
||||
unsafe { BufferRef::from_ptr(self.0.buffer) }
|
||||
}
|
||||
|
||||
#[doc(alias = "get_parent_owned")]
|
||||
#[inline]
|
||||
pub fn parent_owned(&self) -> Buffer {
|
||||
unsafe { from_glib_none(self.0.buffer) }
|
||||
}
|
||||
|
@ -383,6 +412,7 @@ unsafe impl MetaAPI for ParentBufferMeta {
|
|||
type GstType = ffi::GstParentBufferMeta;
|
||||
|
||||
#[doc(alias = "gst_parent_buffer_meta_api_get_type")]
|
||||
#[inline]
|
||||
fn meta_api() -> glib::Type {
|
||||
unsafe { from_glib(ffi::gst_parent_buffer_meta_api_get_type()) }
|
||||
}
|
||||
|
@ -416,11 +446,13 @@ impl ProtectionMeta {
|
|||
}
|
||||
|
||||
#[doc(alias = "get_info")]
|
||||
#[inline]
|
||||
pub fn info(&self) -> &crate::StructureRef {
|
||||
unsafe { crate::StructureRef::from_glib_borrow(self.0.info) }
|
||||
}
|
||||
|
||||
#[doc(alias = "get_info_mut")]
|
||||
#[inline]
|
||||
pub fn info_mut(&mut self) -> &mut crate::StructureRef {
|
||||
unsafe { crate::StructureRef::from_glib_borrow_mut(self.0.info) }
|
||||
}
|
||||
|
@ -430,6 +462,7 @@ unsafe impl MetaAPI for ProtectionMeta {
|
|||
type GstType = ffi::GstProtectionMeta;
|
||||
|
||||
#[doc(alias = "gst_protection_meta_api_get_type")]
|
||||
#[inline]
|
||||
fn meta_api() -> glib::Type {
|
||||
unsafe { from_glib(ffi::gst_protection_meta_api_get_type()) }
|
||||
}
|
||||
|
@ -472,21 +505,25 @@ impl ReferenceTimestampMeta {
|
|||
}
|
||||
|
||||
#[doc(alias = "get_reference")]
|
||||
#[inline]
|
||||
pub fn reference(&self) -> &CapsRef {
|
||||
unsafe { CapsRef::from_ptr(self.0.reference) }
|
||||
}
|
||||
|
||||
#[doc(alias = "get_parent_owned")]
|
||||
#[inline]
|
||||
pub fn parent_owned(&self) -> Caps {
|
||||
unsafe { from_glib_none(self.0.reference) }
|
||||
}
|
||||
|
||||
#[doc(alias = "get_timestamp")]
|
||||
#[inline]
|
||||
pub fn timestamp(&self) -> ClockTime {
|
||||
unsafe { try_from_glib(self.0.timestamp).expect("undefined timestamp") }
|
||||
}
|
||||
|
||||
#[doc(alias = "get_duration")]
|
||||
#[inline]
|
||||
pub fn duration(&self) -> Option<ClockTime> {
|
||||
unsafe { from_glib(self.0.duration) }
|
||||
}
|
||||
|
@ -496,6 +533,7 @@ unsafe impl MetaAPI for ReferenceTimestampMeta {
|
|||
type GstType = ffi::GstReferenceTimestampMeta;
|
||||
|
||||
#[doc(alias = "gst_reference_timestamp_meta_api_get_type")]
|
||||
#[inline]
|
||||
fn meta_api() -> glib::Type {
|
||||
unsafe { from_glib(ffi::gst_reference_timestamp_meta_api_get_type()) }
|
||||
}
|
||||
|
@ -653,6 +691,7 @@ impl CustomMeta {
|
|||
}
|
||||
|
||||
#[doc(alias = "gst_custom_meta_get_structure")]
|
||||
#[inline]
|
||||
pub fn structure(&self) -> &crate::StructureRef {
|
||||
unsafe {
|
||||
crate::StructureRef::from_glib_borrow(ffi::gst_custom_meta_get_structure(mut_override(
|
||||
|
@ -662,6 +701,7 @@ impl CustomMeta {
|
|||
}
|
||||
|
||||
#[doc(alias = "gst_custom_meta_get_structure")]
|
||||
#[inline]
|
||||
pub fn mut_structure(&mut self) -> &mut crate::StructureRef {
|
||||
unsafe {
|
||||
crate::StructureRef::from_glib_borrow_mut(ffi::gst_custom_meta_get_structure(
|
||||
|
@ -671,6 +711,7 @@ impl CustomMeta {
|
|||
}
|
||||
|
||||
#[doc(alias = "gst_custom_meta_has_name")]
|
||||
#[inline]
|
||||
pub fn has_name(&self, name: &str) -> bool {
|
||||
unsafe {
|
||||
from_glib(ffi::gst_custom_meta_has_name(
|
||||
|
|
|
@ -28,6 +28,7 @@ macro_rules! mini_object_wrapper (
|
|||
}
|
||||
|
||||
impl $name {
|
||||
#[inline]
|
||||
pub unsafe fn from_glib_none(ptr: *const $ffi_name) -> Self {
|
||||
skip_assert_initialized!();
|
||||
assert!(!ptr.is_null());
|
||||
|
@ -39,6 +40,7 @@ macro_rules! mini_object_wrapper (
|
|||
}
|
||||
}
|
||||
|
||||
#[inline]
|
||||
pub unsafe fn from_glib_full(ptr: *const $ffi_name) -> Self {
|
||||
skip_assert_initialized!();
|
||||
assert!(!ptr.is_null());
|
||||
|
@ -48,6 +50,7 @@ macro_rules! mini_object_wrapper (
|
|||
}
|
||||
}
|
||||
|
||||
#[inline]
|
||||
pub unsafe fn from_glib_borrow(ptr: *const $ffi_name) -> $crate::glib::translate::Borrowed<Self> {
|
||||
skip_assert_initialized!();
|
||||
assert!(!ptr.is_null());
|
||||
|
@ -57,11 +60,14 @@ macro_rules! mini_object_wrapper (
|
|||
})
|
||||
}
|
||||
|
||||
#[inline]
|
||||
pub unsafe fn replace_ptr(&mut self, ptr: *mut $ffi_name) {
|
||||
assert!(!ptr.is_null());
|
||||
self.obj = std::ptr::NonNull::new_unchecked(ptr);
|
||||
}
|
||||
|
||||
#[inline]
|
||||
#[doc(alias = "gst_mini_object_make_writable")]
|
||||
pub fn make_mut(&mut self) -> &mut $ref_name {
|
||||
unsafe {
|
||||
if self.is_writable() {
|
||||
|
@ -78,6 +84,7 @@ macro_rules! mini_object_wrapper (
|
|||
}
|
||||
}
|
||||
|
||||
#[inline]
|
||||
pub fn get_mut(&mut self) -> Option<&mut $ref_name> {
|
||||
if self.is_writable() {
|
||||
Some(unsafe { &mut *(self.obj.as_mut() as *mut $ffi_name as *mut $ref_name) })
|
||||
|
@ -87,6 +94,7 @@ macro_rules! mini_object_wrapper (
|
|||
}
|
||||
|
||||
#[doc(alias = "gst_mini_object_is_writable")]
|
||||
#[inline]
|
||||
pub fn is_writable(&self) -> bool {
|
||||
unsafe {
|
||||
$crate::glib::translate::from_glib($crate::ffi::gst_mini_object_is_writable(
|
||||
|
@ -96,6 +104,7 @@ macro_rules! mini_object_wrapper (
|
|||
}
|
||||
|
||||
#[must_use]
|
||||
#[inline]
|
||||
pub fn upcast(self) -> $crate::miniobject::MiniObject {
|
||||
use $crate::glib::translate::IntoGlibPtr;
|
||||
|
||||
|
@ -106,6 +115,7 @@ macro_rules! mini_object_wrapper (
|
|||
}
|
||||
|
||||
impl $crate::glib::translate::IntoGlibPtr<*mut $ffi_name> for $name {
|
||||
#[inline]
|
||||
unsafe fn into_glib_ptr(self) -> *mut $ffi_name {
|
||||
let s = std::mem::ManuallyDrop::new(self);
|
||||
s.as_mut_ptr()
|
||||
|
@ -113,12 +123,14 @@ macro_rules! mini_object_wrapper (
|
|||
}
|
||||
|
||||
impl Clone for $name {
|
||||
#[inline]
|
||||
fn clone(&self) -> Self {
|
||||
unsafe { $name::from_glib_none(self.as_ptr()) }
|
||||
}
|
||||
}
|
||||
|
||||
impl Drop for $name {
|
||||
#[inline]
|
||||
fn drop(&mut self) {
|
||||
unsafe {
|
||||
$crate::ffi::gst_mini_object_unref(self.as_mut_ptr() as *mut $crate::ffi::GstMiniObject);
|
||||
|
@ -129,18 +141,21 @@ macro_rules! mini_object_wrapper (
|
|||
impl std::ops::Deref for $name {
|
||||
type Target = $ref_name;
|
||||
|
||||
#[inline]
|
||||
fn deref(&self) -> &Self::Target {
|
||||
unsafe { &*(self.obj.as_ref() as *const $ffi_name as *const $ref_name) }
|
||||
}
|
||||
}
|
||||
|
||||
impl AsRef<$ref_name> for $name {
|
||||
#[inline]
|
||||
fn as_ref(&self) -> &$ref_name {
|
||||
&*self
|
||||
}
|
||||
}
|
||||
|
||||
impl std::borrow::Borrow<$ref_name> for $name {
|
||||
#[inline]
|
||||
fn borrow(&self) -> &$ref_name {
|
||||
&*self
|
||||
}
|
||||
|
@ -149,10 +164,12 @@ macro_rules! mini_object_wrapper (
|
|||
impl<'a> $crate::glib::translate::ToGlibPtr<'a, *const $ffi_name> for $name {
|
||||
type Storage = std::marker::PhantomData<&'a Self>;
|
||||
|
||||
#[inline]
|
||||
fn to_glib_none(&'a self) -> $crate::glib::translate::Stash<'a, *const $ffi_name, Self> {
|
||||
$crate::glib::translate::Stash(self.as_ptr(), std::marker::PhantomData)
|
||||
}
|
||||
|
||||
#[inline]
|
||||
fn to_glib_full(&self) -> *const $ffi_name {
|
||||
unsafe {
|
||||
$crate::ffi::gst_mini_object_ref(self.as_mut_ptr() as *mut $crate::ffi::GstMiniObject);
|
||||
|
@ -164,10 +181,12 @@ macro_rules! mini_object_wrapper (
|
|||
impl<'a> $crate::glib::translate::ToGlibPtr<'a, *mut $ffi_name> for $name {
|
||||
type Storage = std::marker::PhantomData<&'a Self>;
|
||||
|
||||
#[inline]
|
||||
fn to_glib_none(&'a self) -> $crate::glib::translate::Stash<'a, *mut $ffi_name, Self> {
|
||||
$crate::glib::translate::Stash(self.as_mut_ptr(), std::marker::PhantomData)
|
||||
}
|
||||
|
||||
#[inline]
|
||||
fn to_glib_full(&self) -> *mut $ffi_name {
|
||||
unsafe {
|
||||
$crate::ffi::gst_mini_object_ref(self.as_mut_ptr() as *mut $crate::ffi::GstMiniObject);
|
||||
|
@ -179,6 +198,7 @@ macro_rules! mini_object_wrapper (
|
|||
impl<'a> $crate::glib::translate::ToGlibPtrMut<'a, *mut $ffi_name> for $name {
|
||||
type Storage = std::marker::PhantomData<&'a mut Self>;
|
||||
|
||||
#[inline]
|
||||
fn to_glib_none_mut(&'a mut self) -> $crate::glib::translate::StashMut<*mut $ffi_name, Self> {
|
||||
self.make_mut();
|
||||
$crate::glib::translate::StashMut(self.as_mut_ptr(), std::marker::PhantomData)
|
||||
|
@ -267,36 +287,42 @@ macro_rules! mini_object_wrapper (
|
|||
}
|
||||
|
||||
impl $crate::glib::translate::FromGlibPtrNone<*const $ffi_name> for $name {
|
||||
#[inline]
|
||||
unsafe fn from_glib_none(ptr: *const $ffi_name) -> Self {
|
||||
Self::from_glib_none(ptr)
|
||||
}
|
||||
}
|
||||
|
||||
impl $crate::glib::translate::FromGlibPtrNone<*mut $ffi_name> for $name {
|
||||
#[inline]
|
||||
unsafe fn from_glib_none(ptr: *mut $ffi_name) -> Self {
|
||||
Self::from_glib_none(ptr)
|
||||
}
|
||||
}
|
||||
|
||||
impl $crate::glib::translate::FromGlibPtrFull<*const $ffi_name> for $name {
|
||||
#[inline]
|
||||
unsafe fn from_glib_full(ptr: *const $ffi_name) -> Self {
|
||||
Self::from_glib_full(ptr)
|
||||
}
|
||||
}
|
||||
|
||||
impl $crate::glib::translate::FromGlibPtrFull<*mut $ffi_name> for $name {
|
||||
#[inline]
|
||||
unsafe fn from_glib_full(ptr: *mut $ffi_name) -> Self {
|
||||
Self::from_glib_full(ptr)
|
||||
}
|
||||
}
|
||||
|
||||
impl $crate::glib::translate::FromGlibPtrBorrow<*const $ffi_name> for $name {
|
||||
#[inline]
|
||||
unsafe fn from_glib_borrow(ptr: *const $ffi_name) -> $crate::glib::translate::Borrowed<Self> {
|
||||
Self::from_glib_borrow(ptr)
|
||||
}
|
||||
}
|
||||
|
||||
impl $crate::glib::translate::FromGlibPtrBorrow<*mut $ffi_name> for $name {
|
||||
#[inline]
|
||||
unsafe fn from_glib_borrow(ptr: *mut $ffi_name) -> $crate::glib::translate::Borrowed<Self> {
|
||||
Self::from_glib_borrow(ptr)
|
||||
}
|
||||
|
@ -397,19 +423,23 @@ macro_rules! mini_object_wrapper (
|
|||
unsafe impl $crate::glib::translate::TransparentPtrType for $name {}
|
||||
|
||||
impl $ref_name {
|
||||
#[inline]
|
||||
pub fn as_ptr(&self) -> *const $ffi_name {
|
||||
self as *const Self as *const $ffi_name
|
||||
}
|
||||
|
||||
#[inline]
|
||||
pub fn as_mut_ptr(&self) -> *mut $ffi_name {
|
||||
self as *const Self as *mut $ffi_name
|
||||
}
|
||||
|
||||
#[inline]
|
||||
pub unsafe fn from_ptr<'a>(ptr: *const $ffi_name) -> &'a Self {
|
||||
assert!(!ptr.is_null());
|
||||
&*(ptr as *const Self)
|
||||
}
|
||||
|
||||
#[inline]
|
||||
pub unsafe fn from_mut_ptr<'a>(ptr: *mut $ffi_name) -> &'a mut Self {
|
||||
assert!(!ptr.is_null());
|
||||
assert_ne!(
|
||||
|
@ -420,6 +450,7 @@ macro_rules! mini_object_wrapper (
|
|||
}
|
||||
|
||||
#[doc(alias = "gst_mini_object_copy")]
|
||||
#[inline]
|
||||
pub fn copy(&self) -> $name {
|
||||
unsafe {
|
||||
$name::from_glib_full($crate::ffi::gst_mini_object_copy(
|
||||
|
@ -428,18 +459,21 @@ macro_rules! mini_object_wrapper (
|
|||
}
|
||||
}
|
||||
|
||||
#[inline]
|
||||
pub fn upcast_ref(&self) -> &$crate::miniobject::MiniObjectRef {
|
||||
unsafe {
|
||||
&*(self.as_ptr() as *const $crate::miniobject::MiniObjectRef)
|
||||
}
|
||||
}
|
||||
|
||||
#[inline]
|
||||
pub fn upcast_mut(&mut self) -> &mut $crate::miniobject::MiniObjectRef {
|
||||
unsafe {
|
||||
&mut *(self.as_mut_ptr() as *mut $crate::miniobject::MiniObjectRef)
|
||||
}
|
||||
}
|
||||
|
||||
#[inline]
|
||||
pub fn ptr_eq(this: &$ref_name, other: &$ref_name) -> bool {
|
||||
skip_assert_initialized!();
|
||||
this.as_ptr() == other.as_ptr()
|
||||
|
@ -453,6 +487,7 @@ macro_rules! mini_object_wrapper (
|
|||
impl ToOwned for $ref_name {
|
||||
type Owned = $name;
|
||||
|
||||
#[inline]
|
||||
fn to_owned(&self) -> $name {
|
||||
self.copy()
|
||||
}
|
||||
|
@ -467,12 +502,14 @@ macro_rules! mini_object_wrapper (
|
|||
$crate::mini_object_wrapper!($name, $ref_name, $ffi_name);
|
||||
|
||||
impl $crate::glib::types::StaticType for $name {
|
||||
#[inline]
|
||||
fn static_type() -> $crate::glib::types::Type {
|
||||
$ref_name::static_type()
|
||||
}
|
||||
}
|
||||
|
||||
impl $crate::glib::types::StaticType for $ref_name {
|
||||
#[inline]
|
||||
fn static_type() -> $crate::glib::types::Type {
|
||||
unsafe { $crate::glib::translate::from_glib($get_type()) }
|
||||
}
|
||||
|
@ -487,6 +524,7 @@ macro_rules! mini_object_wrapper (
|
|||
unsafe impl<'a> $crate::glib::value::FromValue<'a> for $name {
|
||||
type Checker = $crate::glib::value::GenericValueTypeOrNoneChecker<Self>;
|
||||
|
||||
#[inline]
|
||||
unsafe fn from_value(value: &'a $crate::glib::Value) -> Self {
|
||||
skip_assert_initialized!();
|
||||
$crate::glib::translate::from_glib_none(
|
||||
|
@ -498,6 +536,7 @@ macro_rules! mini_object_wrapper (
|
|||
unsafe impl<'a> $crate::glib::value::FromValue<'a> for &'a $name {
|
||||
type Checker = $crate::glib::value::GenericValueTypeOrNoneChecker<Self>;
|
||||
|
||||
#[inline]
|
||||
unsafe fn from_value(value: &'a $crate::glib::Value) -> Self {
|
||||
skip_assert_initialized!();
|
||||
assert_eq!(std::mem::size_of::<$name>(), std::mem::size_of::<$crate::glib::ffi::gpointer>());
|
||||
|
@ -509,6 +548,7 @@ macro_rules! mini_object_wrapper (
|
|||
}
|
||||
|
||||
impl $crate::glib::value::ToValue for $name {
|
||||
#[inline]
|
||||
fn to_value(&self) -> $crate::glib::Value {
|
||||
let mut value = $crate::glib::Value::for_value_type::<Self>();
|
||||
unsafe {
|
||||
|
@ -520,12 +560,14 @@ macro_rules! mini_object_wrapper (
|
|||
value
|
||||
}
|
||||
|
||||
#[inline]
|
||||
fn value_type(&self) -> $crate::glib::Type {
|
||||
<Self as $crate::glib::StaticType>::static_type()
|
||||
}
|
||||
}
|
||||
|
||||
impl $crate::glib::value::ToValueOptional for $name {
|
||||
#[inline]
|
||||
fn to_value_optional(s: Option<&Self>) -> $crate::glib::Value {
|
||||
skip_assert_initialized!();
|
||||
let mut value = $crate::glib::Value::for_value_type::<Self>();
|
||||
|
@ -540,6 +582,7 @@ macro_rules! mini_object_wrapper (
|
|||
}
|
||||
|
||||
impl From<$name> for $crate::glib::Value {
|
||||
#[inline]
|
||||
fn from(v: $name) -> $crate::glib::Value {
|
||||
skip_assert_initialized!();
|
||||
let mut value = $crate::glib::Value::for_value_type::<$name>();
|
||||
|
@ -556,6 +599,7 @@ macro_rules! mini_object_wrapper (
|
|||
unsafe impl<'a> $crate::glib::value::FromValue<'a> for &'a $ref_name {
|
||||
type Checker = $crate::glib::value::GenericValueTypeOrNoneChecker<Self>;
|
||||
|
||||
#[inline]
|
||||
unsafe fn from_value(value: &'a $crate::glib::Value) -> Self {
|
||||
skip_assert_initialized!();
|
||||
&*($crate::glib::gobject_ffi::g_value_get_boxed($crate::glib::translate::ToGlibPtr::to_glib_none(value).0) as *const $ref_name)
|
||||
|
@ -576,6 +620,7 @@ mini_object_wrapper!(MiniObject, MiniObjectRef, ffi::GstMiniObject, || {
|
|||
});
|
||||
|
||||
impl MiniObject {
|
||||
#[inline]
|
||||
pub fn downcast<T: IsMiniObject + glib::StaticType>(self) -> Result<T, Self> {
|
||||
if self.type_().is_a(T::static_type()) {
|
||||
unsafe { Ok(from_glib_full(self.into_glib_ptr() as *mut T::FfiType)) }
|
||||
|
@ -601,10 +646,12 @@ impl fmt::Debug for MiniObjectRef {
|
|||
}
|
||||
|
||||
impl MiniObjectRef {
|
||||
#[inline]
|
||||
pub fn type_(&self) -> glib::Type {
|
||||
unsafe { from_glib((*self.as_ptr()).type_) }
|
||||
}
|
||||
|
||||
#[inline]
|
||||
pub fn downcast_ref<T: IsMiniObject + glib::StaticType>(&self) -> Option<&T::RefType> {
|
||||
if self.type_().is_a(T::static_type()) {
|
||||
unsafe { Some(&*(self as *const Self as *const T::RefType)) }
|
||||
|
@ -613,6 +660,7 @@ impl MiniObjectRef {
|
|||
}
|
||||
}
|
||||
|
||||
#[inline]
|
||||
pub fn downcast_mut<T: IsMiniObject + glib::StaticType>(&mut self) -> Option<&mut T::RefType> {
|
||||
if self.type_().is_a(T::static_type()) {
|
||||
unsafe { Some(&mut *(self as *mut Self as *mut T::RefType)) }
|
||||
|
|
|
@ -23,12 +23,14 @@ pub struct PadProbeId(NonZeroU64);
|
|||
impl IntoGlib for PadProbeId {
|
||||
type GlibType = libc::c_ulong;
|
||||
|
||||
#[inline]
|
||||
fn into_glib(self) -> libc::c_ulong {
|
||||
self.0.get() as libc::c_ulong
|
||||
}
|
||||
}
|
||||
|
||||
impl FromGlib<libc::c_ulong> for PadProbeId {
|
||||
#[inline]
|
||||
unsafe fn from_glib(val: libc::c_ulong) -> PadProbeId {
|
||||
skip_assert_initialized!();
|
||||
assert_ne!(val, 0);
|
||||
|
@ -37,6 +39,7 @@ impl FromGlib<libc::c_ulong> for PadProbeId {
|
|||
}
|
||||
|
||||
impl PadProbeId {
|
||||
#[inline]
|
||||
pub fn as_raw(&self) -> libc::c_ulong {
|
||||
self.0.get() as libc::c_ulong
|
||||
}
|
||||
|
@ -70,6 +73,7 @@ unsafe impl<'a> Sync for PadProbeData<'a> {}
|
|||
#[must_use = "if unused the StreamLock will immediately unlock"]
|
||||
pub struct StreamLock<'a>(&'a Pad);
|
||||
impl<'a> Drop for StreamLock<'a> {
|
||||
#[inline]
|
||||
fn drop(&mut self) {
|
||||
unsafe {
|
||||
let pad: *mut ffi::GstPad = self.0.to_glib_none().0;
|
||||
|
|
|
@ -20,6 +20,7 @@ unsafe impl Sync for ParamSpecFraction {}
|
|||
impl std::ops::Deref for ParamSpecFraction {
|
||||
type Target = ParamSpec;
|
||||
|
||||
#[inline]
|
||||
fn deref(&self) -> &Self::Target {
|
||||
unsafe { &*(self as *const ParamSpecFraction as *const ParamSpec) }
|
||||
}
|
||||
|
@ -29,6 +30,7 @@ unsafe impl glib::ParamSpecType for ParamSpecFraction {}
|
|||
|
||||
#[doc(hidden)]
|
||||
impl FromGlibPtrFull<*mut gobject_ffi::GParamSpec> for ParamSpecFraction {
|
||||
#[inline]
|
||||
unsafe fn from_glib_full(ptr: *mut gobject_ffi::GParamSpec) -> Self {
|
||||
from_glib_full(ptr as *mut ffi::GstParamSpecFraction)
|
||||
}
|
||||
|
@ -68,6 +70,7 @@ impl ParamSpecFraction {
|
|||
}
|
||||
}
|
||||
|
||||
#[inline]
|
||||
pub fn minimum(&self) -> crate::Fraction {
|
||||
unsafe {
|
||||
let ptr = self.as_ptr();
|
||||
|
@ -76,6 +79,7 @@ impl ParamSpecFraction {
|
|||
}
|
||||
}
|
||||
|
||||
#[inline]
|
||||
pub fn maximum(&self) -> crate::Fraction {
|
||||
unsafe {
|
||||
let ptr = self.as_ptr();
|
||||
|
@ -84,6 +88,7 @@ impl ParamSpecFraction {
|
|||
}
|
||||
}
|
||||
|
||||
#[inline]
|
||||
pub fn default_value(&self) -> crate::Fraction {
|
||||
unsafe {
|
||||
let ptr = self.as_ptr();
|
||||
|
@ -92,6 +97,7 @@ impl ParamSpecFraction {
|
|||
}
|
||||
}
|
||||
|
||||
#[inline]
|
||||
pub fn upcast(self) -> ParamSpec {
|
||||
unsafe {
|
||||
from_glib_full(
|
||||
|
@ -101,6 +107,7 @@ impl ParamSpecFraction {
|
|||
}
|
||||
}
|
||||
|
||||
#[inline]
|
||||
pub fn upcast_ref(&self) -> &ParamSpec {
|
||||
self
|
||||
}
|
||||
|
@ -198,6 +205,7 @@ unsafe impl Sync for ParamSpecArray {}
|
|||
impl std::ops::Deref for ParamSpecArray {
|
||||
type Target = ParamSpec;
|
||||
|
||||
#[inline]
|
||||
fn deref(&self) -> &Self::Target {
|
||||
unsafe { &*(self as *const ParamSpecArray as *const ParamSpec) }
|
||||
}
|
||||
|
@ -207,6 +215,7 @@ unsafe impl glib::ParamSpecType for ParamSpecArray {}
|
|||
|
||||
#[doc(hidden)]
|
||||
impl FromGlibPtrFull<*mut gobject_ffi::GParamSpec> for ParamSpecArray {
|
||||
#[inline]
|
||||
unsafe fn from_glib_full(ptr: *mut gobject_ffi::GParamSpec) -> Self {
|
||||
from_glib_full(ptr as *mut ffi::GstParamSpecArray)
|
||||
}
|
||||
|
@ -239,6 +248,7 @@ impl ParamSpecArray {
|
|||
}
|
||||
}
|
||||
|
||||
#[inline]
|
||||
pub fn element_spec(&self) -> Option<&ParamSpec> {
|
||||
unsafe {
|
||||
let ptr = self.as_ptr();
|
||||
|
@ -254,6 +264,7 @@ impl ParamSpecArray {
|
|||
}
|
||||
}
|
||||
|
||||
#[inline]
|
||||
pub fn upcast(self) -> ParamSpec {
|
||||
unsafe {
|
||||
from_glib_full(
|
||||
|
@ -263,6 +274,7 @@ impl ParamSpecArray {
|
|||
}
|
||||
}
|
||||
|
||||
#[inline]
|
||||
pub fn upcast_ref(&self) -> &ParamSpec {
|
||||
self
|
||||
}
|
||||
|
|
|
@ -192,6 +192,7 @@ impl futures_core::future::FusedFuture for PromiseFuture {
|
|||
impl Deref for PromiseReply {
|
||||
type Target = StructureRef;
|
||||
|
||||
#[inline]
|
||||
fn deref(&self) -> &StructureRef {
|
||||
self.0.get_reply().expect("Promise without reply")
|
||||
}
|
||||
|
|
|
@ -22,6 +22,7 @@ mini_object_wrapper!(Query, QueryRef, ffi::GstQuery, || {
|
|||
impl QueryRef {
|
||||
#[doc(alias = "get_structure")]
|
||||
#[doc(alias = "gst_query_get_structure")]
|
||||
#[inline]
|
||||
pub fn structure(&self) -> Option<&StructureRef> {
|
||||
unsafe {
|
||||
let structure = ffi::gst_query_get_structure(self.as_mut_ptr());
|
||||
|
@ -35,6 +36,7 @@ impl QueryRef {
|
|||
|
||||
#[doc(alias = "get_mut_structure")]
|
||||
#[doc(alias = "gst_query_writable_structure")]
|
||||
#[inline]
|
||||
pub fn structure_mut(&mut self) -> &mut StructureRef {
|
||||
unsafe {
|
||||
let structure = ffi::gst_query_writable_structure(self.as_mut_ptr());
|
||||
|
@ -43,16 +45,19 @@ impl QueryRef {
|
|||
}
|
||||
|
||||
#[doc(alias = "GST_QUERY_IS_DOWNSTREAM")]
|
||||
#[inline]
|
||||
pub fn is_downstream(&self) -> bool {
|
||||
unsafe { ((*self.as_ptr()).type_ as u32) & ffi::GST_QUERY_TYPE_DOWNSTREAM != 0 }
|
||||
}
|
||||
|
||||
#[doc(alias = "GST_QUERY_IS_UPSTREAM")]
|
||||
#[inline]
|
||||
pub fn is_upstream(&self) -> bool {
|
||||
unsafe { ((*self.as_ptr()).type_ as u32) & ffi::GST_QUERY_TYPE_UPSTREAM != 0 }
|
||||
}
|
||||
|
||||
#[doc(alias = "GST_QUERY_IS_SERIALIZED")]
|
||||
#[inline]
|
||||
pub fn is_serialized(&self) -> bool {
|
||||
unsafe { ((*self.as_ptr()).type_ as u32) & ffi::GST_QUERY_TYPE_SERIALIZED != 0 }
|
||||
}
|
||||
|
@ -200,19 +205,23 @@ macro_rules! declare_concrete_query(
|
|||
pub struct $name<$param = QueryRef>($param);
|
||||
|
||||
impl $name {
|
||||
#[inline]
|
||||
pub fn query(&self) -> &QueryRef {
|
||||
unsafe { &*(self as *const Self as *const QueryRef) }
|
||||
}
|
||||
|
||||
#[inline]
|
||||
pub fn query_mut(&mut self) -> &mut QueryRef {
|
||||
unsafe { &mut *(self as *mut Self as *mut QueryRef) }
|
||||
}
|
||||
|
||||
#[inline]
|
||||
unsafe fn view(query: &QueryRef) -> QueryView<'_> {
|
||||
let query = &*(query as *const QueryRef as *const Self);
|
||||
QueryView::$name(query)
|
||||
}
|
||||
|
||||
#[inline]
|
||||
unsafe fn view_mut(query: &mut QueryRef) -> QueryViewMut<'_> {
|
||||
let query = &mut *(query as *mut QueryRef as *mut Self);
|
||||
QueryViewMut::$name(query)
|
||||
|
@ -222,12 +231,14 @@ macro_rules! declare_concrete_query(
|
|||
impl Deref for $name {
|
||||
type Target = QueryRef;
|
||||
|
||||
#[inline]
|
||||
fn deref(&self) -> &Self::Target {
|
||||
self.query()
|
||||
}
|
||||
}
|
||||
|
||||
impl DerefMut for $name {
|
||||
#[inline]
|
||||
fn deref_mut(&mut self) -> &mut Self::Target {
|
||||
self.query_mut()
|
||||
}
|
||||
|
@ -236,12 +247,14 @@ macro_rules! declare_concrete_query(
|
|||
impl ToOwned for $name {
|
||||
type Owned = $name<Query>;
|
||||
|
||||
#[inline]
|
||||
fn to_owned(&self) -> Self::Owned {
|
||||
$name::<Query>(self.copy())
|
||||
}
|
||||
}
|
||||
|
||||
impl $name<Query> {
|
||||
#[inline]
|
||||
pub fn get_mut(&mut self) -> Option<&mut $name> {
|
||||
self.0
|
||||
.get_mut()
|
||||
|
@ -252,12 +265,14 @@ macro_rules! declare_concrete_query(
|
|||
impl Deref for $name<Query> {
|
||||
type Target = $name;
|
||||
|
||||
#[inline]
|
||||
fn deref(&self) -> &Self::Target {
|
||||
unsafe { &*(self.0.as_ptr() as *const Self::Target) }
|
||||
}
|
||||
}
|
||||
|
||||
impl DerefMut for $name<Query> {
|
||||
#[inline]
|
||||
fn deref_mut(&mut self) -> &mut Self::Target {
|
||||
assert!(self.0.is_writable());
|
||||
unsafe { &mut *(self.0.as_mut_ptr() as *mut Self::Target) }
|
||||
|
@ -265,18 +280,21 @@ macro_rules! declare_concrete_query(
|
|||
}
|
||||
|
||||
impl Borrow<$name> for $name<Query> {
|
||||
#[inline]
|
||||
fn borrow(&self) -> &$name {
|
||||
&*self
|
||||
}
|
||||
}
|
||||
|
||||
impl BorrowMut<$name> for $name<Query> {
|
||||
#[inline]
|
||||
fn borrow_mut(&mut self) -> &mut $name {
|
||||
&mut *self
|
||||
}
|
||||
}
|
||||
|
||||
impl From<$name<Query>> for Query {
|
||||
#[inline]
|
||||
fn from(concrete: $name<Query>) -> Self {
|
||||
skip_assert_initialized!();
|
||||
concrete.0
|
||||
|
|
|
@ -28,16 +28,19 @@ glib::wrapper! {
|
|||
}
|
||||
|
||||
impl Segment {
|
||||
#[inline]
|
||||
pub fn reset_with_format(&mut self, format: Format) {
|
||||
unsafe {
|
||||
ffi::gst_segment_init(self.to_glib_none_mut().0, format.into_glib());
|
||||
}
|
||||
}
|
||||
|
||||
#[inline]
|
||||
pub fn set_format(&mut self, format: Format) {
|
||||
self.inner.format = format.into_glib();
|
||||
}
|
||||
|
||||
#[inline]
|
||||
pub fn downcast<T: FormattedValueIntrinsic>(self) -> Result<FormattedSegment<T>, Self> {
|
||||
if T::default_format() == Format::Undefined || T::default_format() == self.format() {
|
||||
Ok(FormattedSegment {
|
||||
|
@ -49,6 +52,7 @@ impl Segment {
|
|||
}
|
||||
}
|
||||
|
||||
#[inline]
|
||||
pub fn downcast_ref<T: FormattedValueIntrinsic>(&self) -> Option<&FormattedSegment<T>> {
|
||||
if T::default_format() == Format::Undefined || T::default_format() == self.format() {
|
||||
Some(unsafe {
|
||||
|
@ -60,6 +64,7 @@ impl Segment {
|
|||
}
|
||||
}
|
||||
|
||||
#[inline]
|
||||
pub fn downcast_mut<T: FormattedValueIntrinsic>(&mut self) -> Option<&mut FormattedSegment<T>> {
|
||||
if T::default_format() == Format::Undefined || T::default_format() == self.format() {
|
||||
Some(unsafe {
|
||||
|
@ -73,6 +78,7 @@ impl Segment {
|
|||
}
|
||||
|
||||
impl<T: FormattedValueIntrinsic> FormattedSegment<T> {
|
||||
#[inline]
|
||||
pub fn new() -> Self {
|
||||
assert_initialized_main_thread!();
|
||||
let segment = unsafe {
|
||||
|
@ -86,6 +92,7 @@ impl<T: FormattedValueIntrinsic> FormattedSegment<T> {
|
|||
}
|
||||
}
|
||||
|
||||
#[inline]
|
||||
pub fn upcast(self) -> Segment {
|
||||
FormattedSegment {
|
||||
inner: self.inner,
|
||||
|
@ -93,12 +100,14 @@ impl<T: FormattedValueIntrinsic> FormattedSegment<T> {
|
|||
}
|
||||
}
|
||||
|
||||
#[inline]
|
||||
pub fn upcast_ref(&self) -> &Segment {
|
||||
unsafe {
|
||||
&*(self as *const FormattedSegment<T> as *const FormattedSegment<GenericFormattedValue>)
|
||||
}
|
||||
}
|
||||
|
||||
#[inline]
|
||||
pub fn reset(&mut self) {
|
||||
unsafe {
|
||||
ffi::gst_segment_init(&mut self.inner, T::default_format().into_glib());
|
||||
|
@ -173,6 +182,7 @@ impl<T: FormattedValueIntrinsic> FormattedSegment<T> {
|
|||
}
|
||||
|
||||
#[doc(alias = "gst_segment_offset_running_time")]
|
||||
#[inline]
|
||||
pub fn offset_running_time(&mut self, offset: i64) -> Result<(), glib::BoolError> {
|
||||
unsafe {
|
||||
glib::result_from_gboolean!(
|
||||
|
@ -187,6 +197,7 @@ impl<T: FormattedValueIntrinsic> FormattedSegment<T> {
|
|||
}
|
||||
|
||||
#[doc(alias = "gst_segment_set_running_time")]
|
||||
#[inline]
|
||||
pub fn set_running_time(
|
||||
&mut self,
|
||||
running_time: impl CompatibleFormattedValue<T>,
|
||||
|
@ -208,106 +219,127 @@ impl<T: FormattedValueIntrinsic> FormattedSegment<T> {
|
|||
}
|
||||
|
||||
#[doc(alias = "get_flags")]
|
||||
#[inline]
|
||||
pub fn flags(&self) -> crate::SegmentFlags {
|
||||
unsafe { from_glib(self.inner.flags) }
|
||||
}
|
||||
|
||||
#[inline]
|
||||
pub fn set_flags(&mut self, flags: crate::SegmentFlags) {
|
||||
self.inner.flags = flags.into_glib();
|
||||
}
|
||||
|
||||
#[doc(alias = "get_rate")]
|
||||
#[inline]
|
||||
pub fn rate(&self) -> f64 {
|
||||
self.inner.rate
|
||||
}
|
||||
|
||||
#[allow(clippy::float_cmp)]
|
||||
#[inline]
|
||||
pub fn set_rate(&mut self, rate: f64) {
|
||||
assert_ne!(rate, 0.0);
|
||||
self.inner.rate = rate;
|
||||
}
|
||||
|
||||
#[doc(alias = "get_applied_rate")]
|
||||
#[inline]
|
||||
pub fn applied_rate(&self) -> f64 {
|
||||
self.inner.applied_rate
|
||||
}
|
||||
|
||||
#[allow(clippy::float_cmp)]
|
||||
#[inline]
|
||||
pub fn set_applied_rate(&mut self, applied_rate: f64) {
|
||||
assert_ne!(applied_rate, 0.0);
|
||||
self.inner.applied_rate = applied_rate;
|
||||
}
|
||||
|
||||
#[doc(alias = "get_format")]
|
||||
#[inline]
|
||||
pub fn format(&self) -> Format {
|
||||
unsafe { from_glib(self.inner.format) }
|
||||
}
|
||||
|
||||
#[doc(alias = "get_base")]
|
||||
#[inline]
|
||||
pub fn base(&self) -> T::FullRange {
|
||||
unsafe { T::FullRange::from_raw(self.format(), self.inner.base as i64) }
|
||||
}
|
||||
|
||||
#[inline]
|
||||
pub fn set_base(&mut self, base: impl CompatibleFormattedValue<T>) {
|
||||
let base = base.try_into_checked_explicit(self.format()).unwrap();
|
||||
self.inner.base = unsafe { base.into_raw_value() } as u64;
|
||||
}
|
||||
|
||||
#[doc(alias = "get_offset")]
|
||||
#[inline]
|
||||
pub fn offset(&self) -> T::FullRange {
|
||||
unsafe { T::FullRange::from_raw(self.format(), self.inner.offset as i64) }
|
||||
}
|
||||
|
||||
#[inline]
|
||||
pub fn set_offset(&mut self, offset: impl CompatibleFormattedValue<T>) {
|
||||
let offset = offset.try_into_checked_explicit(self.format()).unwrap();
|
||||
self.inner.offset = unsafe { offset.into_raw_value() } as u64;
|
||||
}
|
||||
|
||||
#[doc(alias = "get_start")]
|
||||
#[inline]
|
||||
pub fn start(&self) -> T::FullRange {
|
||||
unsafe { T::FullRange::from_raw(self.format(), self.inner.start as i64) }
|
||||
}
|
||||
|
||||
#[inline]
|
||||
pub fn set_start(&mut self, start: impl CompatibleFormattedValue<T>) {
|
||||
let start = start.try_into_checked_explicit(self.format()).unwrap();
|
||||
self.inner.start = unsafe { start.into_raw_value() } as u64;
|
||||
}
|
||||
|
||||
#[doc(alias = "get_stop")]
|
||||
#[inline]
|
||||
pub fn stop(&self) -> T::FullRange {
|
||||
unsafe { T::FullRange::from_raw(self.format(), self.inner.stop as i64) }
|
||||
}
|
||||
|
||||
#[inline]
|
||||
pub fn set_stop(&mut self, stop: impl CompatibleFormattedValue<T>) {
|
||||
let stop = stop.try_into_checked_explicit(self.format()).unwrap();
|
||||
self.inner.stop = unsafe { stop.into_raw_value() } as u64;
|
||||
}
|
||||
|
||||
#[doc(alias = "get_time")]
|
||||
#[inline]
|
||||
pub fn time(&self) -> T::FullRange {
|
||||
unsafe { T::FullRange::from_raw(self.format(), self.inner.time as i64) }
|
||||
}
|
||||
|
||||
#[inline]
|
||||
pub fn set_time(&mut self, time: impl CompatibleFormattedValue<T>) {
|
||||
let time = time.try_into_checked_explicit(self.format()).unwrap();
|
||||
self.inner.time = unsafe { time.into_raw_value() } as u64;
|
||||
}
|
||||
|
||||
#[doc(alias = "get_position")]
|
||||
#[inline]
|
||||
pub fn position(&self) -> T::FullRange {
|
||||
unsafe { T::FullRange::from_raw(self.format(), self.inner.position as i64) }
|
||||
}
|
||||
|
||||
#[inline]
|
||||
pub fn set_position(&mut self, position: impl CompatibleFormattedValue<T>) {
|
||||
let position = position.try_into_checked_explicit(self.format()).unwrap();
|
||||
self.inner.position = unsafe { position.into_raw_value() } as u64;
|
||||
}
|
||||
|
||||
#[doc(alias = "get_duration")]
|
||||
#[inline]
|
||||
pub fn duration(&self) -> T::FullRange {
|
||||
unsafe { T::FullRange::from_raw(self.format(), self.inner.duration as i64) }
|
||||
}
|
||||
|
||||
#[inline]
|
||||
pub fn set_duration(&mut self, duration: impl CompatibleFormattedValue<T>) {
|
||||
let duration = duration.try_into_checked_explicit(self.format()).unwrap();
|
||||
self.inner.duration = unsafe { duration.into_raw_value() } as u64;
|
||||
|
@ -525,6 +557,7 @@ unsafe impl<T: FormattedValueIntrinsic> Send for FormattedSegment<T> {}
|
|||
unsafe impl<T: FormattedValueIntrinsic> Sync for FormattedSegment<T> {}
|
||||
|
||||
impl<T: FormattedValueIntrinsic> AsRef<Segment> for FormattedSegment<T> {
|
||||
#[inline]
|
||||
fn as_ref(&self) -> &Segment {
|
||||
unsafe {
|
||||
&*(self as *const FormattedSegment<T> as *const FormattedSegment<GenericFormattedValue>)
|
||||
|
@ -577,12 +610,14 @@ impl<T: FormattedValueIntrinsic> fmt::Debug for FormattedSegment<T> {
|
|||
}
|
||||
|
||||
impl<T: FormattedValueIntrinsic> Default for FormattedSegment<T> {
|
||||
#[inline]
|
||||
fn default() -> Self {
|
||||
Self::new()
|
||||
}
|
||||
}
|
||||
|
||||
impl<T: FormattedValueIntrinsic> glib::types::StaticType for FormattedSegment<T> {
|
||||
#[inline]
|
||||
fn static_type() -> glib::types::Type {
|
||||
unsafe { glib::translate::from_glib(ffi::gst_segment_get_type()) }
|
||||
}
|
||||
|
@ -596,6 +631,7 @@ impl glib::value::ValueType for Segment {
|
|||
unsafe impl<'a> glib::value::FromValue<'a> for Segment {
|
||||
type Checker = glib::value::GenericValueTypeOrNoneChecker<Self>;
|
||||
|
||||
#[inline]
|
||||
unsafe fn from_value(value: &'a glib::Value) -> Self {
|
||||
skip_assert_initialized!();
|
||||
from_glib_none(
|
||||
|
@ -608,6 +644,7 @@ unsafe impl<'a> glib::value::FromValue<'a> for Segment {
|
|||
unsafe impl<'a> glib::value::FromValue<'a> for &'a Segment {
|
||||
type Checker = glib::value::GenericValueTypeOrNoneChecker<Self>;
|
||||
|
||||
#[inline]
|
||||
unsafe fn from_value(value: &'a glib::Value) -> Self {
|
||||
skip_assert_initialized!();
|
||||
Segment::from_glib_ptr_borrow(
|
||||
|
@ -618,6 +655,7 @@ unsafe impl<'a> glib::value::FromValue<'a> for &'a Segment {
|
|||
|
||||
#[doc(hidden)]
|
||||
impl<T: FormattedValueIntrinsic> glib::value::ToValue for FormattedSegment<T> {
|
||||
#[inline]
|
||||
fn to_value(&self) -> glib::Value {
|
||||
let mut value = glib::Value::for_value_type::<Segment>();
|
||||
unsafe {
|
||||
|
@ -629,6 +667,7 @@ impl<T: FormattedValueIntrinsic> glib::value::ToValue for FormattedSegment<T> {
|
|||
value
|
||||
}
|
||||
|
||||
#[inline]
|
||||
fn value_type(&self) -> glib::Type {
|
||||
Self::static_type()
|
||||
}
|
||||
|
@ -636,6 +675,7 @@ impl<T: FormattedValueIntrinsic> glib::value::ToValue for FormattedSegment<T> {
|
|||
|
||||
#[doc(hidden)]
|
||||
impl<T: FormattedValueIntrinsic> glib::value::ToValueOptional for FormattedSegment<T> {
|
||||
#[inline]
|
||||
fn to_value_optional(s: Option<&Self>) -> glib::Value {
|
||||
skip_assert_initialized!();
|
||||
let mut value = glib::Value::for_value_type::<Segment>();
|
||||
|
@ -650,6 +690,7 @@ impl<T: FormattedValueIntrinsic> glib::value::ToValueOptional for FormattedSegme
|
|||
}
|
||||
|
||||
impl<T: FormattedValueIntrinsic> From<FormattedSegment<T>> for glib::Value {
|
||||
#[inline]
|
||||
fn from(v: FormattedSegment<T>) -> glib::Value {
|
||||
skip_assert_initialized!();
|
||||
glib::value::ToValue::to_value(&v)
|
||||
|
|
|
@ -12,6 +12,7 @@ pub struct StaticCaps(ptr::NonNull<ffi::GstStaticCaps>);
|
|||
|
||||
impl StaticCaps {
|
||||
#[doc(alias = "gst_static_caps_get")]
|
||||
#[inline]
|
||||
pub fn get(&self) -> Caps {
|
||||
unsafe { from_glib_full(ffi::gst_static_caps_get(self.0.as_ptr())) }
|
||||
}
|
||||
|
@ -31,6 +32,7 @@ impl fmt::Debug for StaticCaps {
|
|||
}
|
||||
|
||||
impl glib::types::StaticType for StaticCaps {
|
||||
#[inline]
|
||||
fn static_type() -> glib::types::Type {
|
||||
unsafe { glib::translate::from_glib(ffi::gst_static_caps_get_type()) }
|
||||
}
|
||||
|
@ -46,6 +48,7 @@ unsafe impl glib::translate::TransparentPtrType for StaticCaps {}
|
|||
unsafe impl<'a> glib::value::FromValue<'a> for StaticCaps {
|
||||
type Checker = glib::value::GenericValueTypeOrNoneChecker<Self>;
|
||||
|
||||
#[inline]
|
||||
unsafe fn from_value(value: &'a glib::Value) -> Self {
|
||||
skip_assert_initialized!();
|
||||
from_glib_none(
|
||||
|
@ -56,6 +59,7 @@ unsafe impl<'a> glib::value::FromValue<'a> for StaticCaps {
|
|||
|
||||
#[doc(hidden)]
|
||||
impl glib::value::ToValue for StaticCaps {
|
||||
#[inline]
|
||||
fn to_value(&self) -> glib::Value {
|
||||
let mut value = glib::Value::for_value_type::<Self>();
|
||||
unsafe {
|
||||
|
@ -67,12 +71,14 @@ impl glib::value::ToValue for StaticCaps {
|
|||
value
|
||||
}
|
||||
|
||||
#[inline]
|
||||
fn value_type(&self) -> glib::Type {
|
||||
Self::static_type()
|
||||
}
|
||||
}
|
||||
|
||||
impl From<StaticCaps> for glib::Value {
|
||||
#[inline]
|
||||
fn from(v: StaticCaps) -> glib::Value {
|
||||
skip_assert_initialized!();
|
||||
glib::value::ToValue::to_value(&v)
|
||||
|
@ -81,6 +87,7 @@ impl From<StaticCaps> for glib::Value {
|
|||
|
||||
#[doc(hidden)]
|
||||
impl glib::value::ToValueOptional for StaticCaps {
|
||||
#[inline]
|
||||
fn to_value_optional(s: Option<&Self>) -> glib::Value {
|
||||
skip_assert_initialized!();
|
||||
let mut value = glib::Value::for_value_type::<Self>();
|
||||
|
@ -103,6 +110,7 @@ impl glib::translate::GlibPtrDefault for StaticCaps {
|
|||
impl<'a> glib::translate::ToGlibPtr<'a, *const ffi::GstStaticCaps> for StaticCaps {
|
||||
type Storage = PhantomData<&'a StaticCaps>;
|
||||
|
||||
#[inline]
|
||||
fn to_glib_none(&'a self) -> glib::translate::Stash<'a, *const ffi::GstStaticCaps, Self> {
|
||||
glib::translate::Stash(self.0.as_ptr(), PhantomData)
|
||||
}
|
||||
|
|
|
@ -12,16 +12,19 @@ pub struct StaticPadTemplate(ptr::NonNull<ffi::GstStaticPadTemplate>);
|
|||
|
||||
impl StaticPadTemplate {
|
||||
#[doc(alias = "gst_static_pad_template_get")]
|
||||
#[inline]
|
||||
pub fn get(&self) -> PadTemplate {
|
||||
unsafe { from_glib_full(ffi::gst_static_pad_template_get(self.0.as_ptr())) }
|
||||
}
|
||||
|
||||
#[doc(alias = "get_caps")]
|
||||
#[doc(alias = "gst_static_pad_template_get_caps")]
|
||||
#[inline]
|
||||
pub fn caps(&self) -> Caps {
|
||||
unsafe { from_glib_full(ffi::gst_static_pad_template_get_caps(self.0.as_ptr())) }
|
||||
}
|
||||
|
||||
#[inline]
|
||||
pub fn name_template<'a>(&self) -> &'a str {
|
||||
unsafe {
|
||||
CStr::from_ptr(self.0.as_ref().name_template)
|
||||
|
@ -30,10 +33,12 @@ impl StaticPadTemplate {
|
|||
}
|
||||
}
|
||||
|
||||
#[inline]
|
||||
pub fn direction(&self) -> crate::PadDirection {
|
||||
unsafe { from_glib(self.0.as_ref().direction) }
|
||||
}
|
||||
|
||||
#[inline]
|
||||
pub fn presence(&self) -> crate::PadPresence {
|
||||
unsafe { from_glib(self.0.as_ref().presence) }
|
||||
}
|
||||
|
@ -64,6 +69,7 @@ impl fmt::Debug for StaticPadTemplate {
|
|||
}
|
||||
|
||||
impl glib::types::StaticType for StaticPadTemplate {
|
||||
#[inline]
|
||||
fn static_type() -> glib::types::Type {
|
||||
unsafe { glib::translate::from_glib(ffi::gst_static_pad_template_get_type()) }
|
||||
}
|
||||
|
@ -77,6 +83,7 @@ impl glib::value::ValueType for StaticPadTemplate {
|
|||
unsafe impl<'a> glib::value::FromValue<'a> for StaticPadTemplate {
|
||||
type Checker = glib::value::GenericValueTypeOrNoneChecker<Self>;
|
||||
|
||||
#[inline]
|
||||
unsafe fn from_value(value: &'a glib::Value) -> Self {
|
||||
skip_assert_initialized!();
|
||||
from_glib_none(glib::gobject_ffi::g_value_get_boxed(value.to_glib_none().0)
|
||||
|
@ -86,6 +93,7 @@ unsafe impl<'a> glib::value::FromValue<'a> for StaticPadTemplate {
|
|||
|
||||
#[doc(hidden)]
|
||||
impl glib::value::ToValue for StaticPadTemplate {
|
||||
#[inline]
|
||||
fn to_value(&self) -> glib::Value {
|
||||
let mut value = glib::Value::for_value_type::<Self>();
|
||||
unsafe {
|
||||
|
@ -97,6 +105,7 @@ impl glib::value::ToValue for StaticPadTemplate {
|
|||
value
|
||||
}
|
||||
|
||||
#[inline]
|
||||
fn value_type(&self) -> glib::Type {
|
||||
Self::static_type()
|
||||
}
|
||||
|
@ -104,6 +113,7 @@ impl glib::value::ToValue for StaticPadTemplate {
|
|||
|
||||
#[doc(hidden)]
|
||||
impl glib::value::ToValueOptional for StaticPadTemplate {
|
||||
#[inline]
|
||||
fn to_value_optional(s: Option<&Self>) -> glib::Value {
|
||||
skip_assert_initialized!();
|
||||
let mut value = glib::Value::for_value_type::<Self>();
|
||||
|
@ -118,6 +128,7 @@ impl glib::value::ToValueOptional for StaticPadTemplate {
|
|||
}
|
||||
|
||||
impl From<StaticPadTemplate> for glib::Value {
|
||||
#[inline]
|
||||
fn from(v: StaticPadTemplate) -> glib::Value {
|
||||
skip_assert_initialized!();
|
||||
glib::value::ToValue::to_value(&v)
|
||||
|
@ -133,6 +144,7 @@ impl glib::translate::GlibPtrDefault for StaticPadTemplate {
|
|||
impl<'a> glib::translate::ToGlibPtr<'a, *const ffi::GstStaticPadTemplate> for StaticPadTemplate {
|
||||
type Storage = PhantomData<&'a StaticPadTemplate>;
|
||||
|
||||
#[inline]
|
||||
fn to_glib_none(
|
||||
&'a self,
|
||||
) -> glib::translate::Stash<'a, *const ffi::GstStaticPadTemplate, Self> {
|
||||
|
@ -173,7 +185,6 @@ impl glib::translate::FromGlibPtrBorrow<*mut ffi::GstStaticPadTemplate> for Stat
|
|||
|
||||
#[doc(hidden)]
|
||||
impl glib::translate::FromGlibPtrFull<*mut ffi::GstStaticPadTemplate> for StaticPadTemplate {
|
||||
#[inline]
|
||||
unsafe fn from_glib_full(_ptr: *mut ffi::GstStaticPadTemplate) -> Self {
|
||||
unimplemented!();
|
||||
}
|
||||
|
|
|
@ -93,6 +93,7 @@ impl Structure {
|
|||
}
|
||||
|
||||
impl IntoGlibPtr<*mut ffi::GstStructure> for Structure {
|
||||
#[inline]
|
||||
unsafe fn into_glib_ptr(self) -> *mut ffi::GstStructure {
|
||||
let s = mem::ManuallyDrop::new(self);
|
||||
s.0.as_ptr()
|
||||
|
@ -102,30 +103,35 @@ impl IntoGlibPtr<*mut ffi::GstStructure> for Structure {
|
|||
impl Deref for Structure {
|
||||
type Target = StructureRef;
|
||||
|
||||
#[inline]
|
||||
fn deref(&self) -> &StructureRef {
|
||||
unsafe { &*(self.0.as_ptr() as *const StructureRef) }
|
||||
}
|
||||
}
|
||||
|
||||
impl DerefMut for Structure {
|
||||
#[inline]
|
||||
fn deref_mut(&mut self) -> &mut StructureRef {
|
||||
unsafe { &mut *(self.0.as_ptr() as *mut StructureRef) }
|
||||
}
|
||||
}
|
||||
|
||||
impl AsRef<StructureRef> for Structure {
|
||||
#[inline]
|
||||
fn as_ref(&self) -> &StructureRef {
|
||||
self.deref()
|
||||
}
|
||||
}
|
||||
|
||||
impl AsMut<StructureRef> for Structure {
|
||||
#[inline]
|
||||
fn as_mut(&mut self) -> &mut StructureRef {
|
||||
self.deref_mut()
|
||||
}
|
||||
}
|
||||
|
||||
impl Clone for Structure {
|
||||
#[inline]
|
||||
fn clone(&self) -> Self {
|
||||
unsafe {
|
||||
let ptr = ffi::gst_structure_copy(self.0.as_ref());
|
||||
|
@ -136,6 +142,7 @@ impl Clone for Structure {
|
|||
}
|
||||
|
||||
impl Drop for Structure {
|
||||
#[inline]
|
||||
fn drop(&mut self) {
|
||||
unsafe { ffi::gst_structure_free(self.0.as_mut()) }
|
||||
}
|
||||
|
@ -193,12 +200,14 @@ impl str::FromStr for Structure {
|
|||
}
|
||||
|
||||
impl Borrow<StructureRef> for Structure {
|
||||
#[inline]
|
||||
fn borrow(&self) -> &StructureRef {
|
||||
self.as_ref()
|
||||
}
|
||||
}
|
||||
|
||||
impl BorrowMut<StructureRef> for Structure {
|
||||
#[inline]
|
||||
fn borrow_mut(&mut self) -> &mut StructureRef {
|
||||
self.as_mut()
|
||||
}
|
||||
|
@ -217,6 +226,7 @@ impl ToOwned for StructureRef {
|
|||
}
|
||||
|
||||
impl glib::types::StaticType for Structure {
|
||||
#[inline]
|
||||
fn static_type() -> glib::types::Type {
|
||||
unsafe { from_glib(ffi::gst_structure_get_type()) }
|
||||
}
|
||||
|
@ -225,10 +235,12 @@ impl glib::types::StaticType for Structure {
|
|||
impl<'a> ToGlibPtr<'a, *const ffi::GstStructure> for Structure {
|
||||
type Storage = PhantomData<&'a Self>;
|
||||
|
||||
#[inline]
|
||||
fn to_glib_none(&'a self) -> Stash<'a, *const ffi::GstStructure, Self> {
|
||||
unsafe { Stash(self.0.as_ref(), PhantomData) }
|
||||
}
|
||||
|
||||
#[inline]
|
||||
fn to_glib_full(&self) -> *const ffi::GstStructure {
|
||||
unsafe { ffi::gst_structure_copy(self.0.as_ref()) }
|
||||
}
|
||||
|
@ -237,6 +249,7 @@ impl<'a> ToGlibPtr<'a, *const ffi::GstStructure> for Structure {
|
|||
impl<'a> ToGlibPtr<'a, *mut ffi::GstStructure> for Structure {
|
||||
type Storage = PhantomData<&'a Self>;
|
||||
|
||||
#[inline]
|
||||
fn to_glib_none(&'a self) -> Stash<'a, *mut ffi::GstStructure, Self> {
|
||||
unsafe {
|
||||
Stash(
|
||||
|
@ -246,6 +259,7 @@ impl<'a> ToGlibPtr<'a, *mut ffi::GstStructure> for Structure {
|
|||
}
|
||||
}
|
||||
|
||||
#[inline]
|
||||
fn to_glib_full(&self) -> *mut ffi::GstStructure {
|
||||
unsafe { ffi::gst_structure_copy(self.0.as_ref()) }
|
||||
}
|
||||
|
@ -254,12 +268,14 @@ impl<'a> ToGlibPtr<'a, *mut ffi::GstStructure> for Structure {
|
|||
impl<'a> ToGlibPtrMut<'a, *mut ffi::GstStructure> for Structure {
|
||||
type Storage = PhantomData<&'a mut Self>;
|
||||
|
||||
#[inline]
|
||||
fn to_glib_none_mut(&'a mut self) -> StashMut<*mut ffi::GstStructure, Self> {
|
||||
unsafe { StashMut(self.0.as_mut(), PhantomData) }
|
||||
}
|
||||
}
|
||||
|
||||
impl FromGlibPtrNone<*const ffi::GstStructure> for Structure {
|
||||
#[inline]
|
||||
unsafe fn from_glib_none(ptr: *const ffi::GstStructure) -> Self {
|
||||
assert!(!ptr.is_null());
|
||||
let ptr = ffi::gst_structure_copy(ptr);
|
||||
|
@ -269,6 +285,7 @@ impl FromGlibPtrNone<*const ffi::GstStructure> for Structure {
|
|||
}
|
||||
|
||||
impl FromGlibPtrNone<*mut ffi::GstStructure> for Structure {
|
||||
#[inline]
|
||||
unsafe fn from_glib_none(ptr: *mut ffi::GstStructure) -> Self {
|
||||
assert!(!ptr.is_null());
|
||||
let ptr = ffi::gst_structure_copy(ptr);
|
||||
|
@ -278,6 +295,7 @@ impl FromGlibPtrNone<*mut ffi::GstStructure> for Structure {
|
|||
}
|
||||
|
||||
impl FromGlibPtrFull<*const ffi::GstStructure> for Structure {
|
||||
#[inline]
|
||||
unsafe fn from_glib_full(ptr: *const ffi::GstStructure) -> Self {
|
||||
assert!(!ptr.is_null());
|
||||
Structure(ptr::NonNull::new_unchecked(ptr as *mut ffi::GstStructure))
|
||||
|
@ -285,6 +303,7 @@ impl FromGlibPtrFull<*const ffi::GstStructure> for Structure {
|
|||
}
|
||||
|
||||
impl FromGlibPtrFull<*mut ffi::GstStructure> for Structure {
|
||||
#[inline]
|
||||
unsafe fn from_glib_full(ptr: *mut ffi::GstStructure) -> Self {
|
||||
assert!(!ptr.is_null());
|
||||
Structure(ptr::NonNull::new_unchecked(ptr))
|
||||
|
@ -292,12 +311,14 @@ impl FromGlibPtrFull<*mut ffi::GstStructure> for Structure {
|
|||
}
|
||||
|
||||
impl FromGlibPtrBorrow<*const ffi::GstStructure> for Structure {
|
||||
#[inline]
|
||||
unsafe fn from_glib_borrow(ptr: *const ffi::GstStructure) -> Borrowed<Self> {
|
||||
Borrowed::new(from_glib_full(ptr))
|
||||
}
|
||||
}
|
||||
|
||||
impl FromGlibPtrBorrow<*mut ffi::GstStructure> for Structure {
|
||||
#[inline]
|
||||
unsafe fn from_glib_borrow(ptr: *mut ffi::GstStructure) -> Borrowed<Self> {
|
||||
Borrowed::new(from_glib_full(ptr))
|
||||
}
|
||||
|
@ -381,22 +402,26 @@ unsafe impl Send for StructureRef {}
|
|||
unsafe impl Sync for StructureRef {}
|
||||
|
||||
impl StructureRef {
|
||||
#[inline]
|
||||
pub unsafe fn from_glib_borrow<'a>(ptr: *const ffi::GstStructure) -> &'a StructureRef {
|
||||
assert!(!ptr.is_null());
|
||||
|
||||
&*(ptr as *mut StructureRef)
|
||||
}
|
||||
|
||||
#[inline]
|
||||
pub unsafe fn from_glib_borrow_mut<'a>(ptr: *mut ffi::GstStructure) -> &'a mut StructureRef {
|
||||
assert!(!ptr.is_null());
|
||||
|
||||
&mut *(ptr as *mut StructureRef)
|
||||
}
|
||||
|
||||
#[inline]
|
||||
pub fn as_ptr(&self) -> *const ffi::GstStructure {
|
||||
self as *const Self as *const ffi::GstStructure
|
||||
}
|
||||
|
||||
#[inline]
|
||||
pub fn as_mut_ptr(&self) -> *mut ffi::GstStructure {
|
||||
self as *const Self as *mut ffi::GstStructure
|
||||
}
|
||||
|
@ -849,6 +874,7 @@ impl PartialEq for StructureRef {
|
|||
impl Eq for StructureRef {}
|
||||
|
||||
impl glib::types::StaticType for StructureRef {
|
||||
#[inline]
|
||||
fn static_type() -> glib::types::Type {
|
||||
unsafe { from_glib(ffi::gst_structure_get_type()) }
|
||||
}
|
||||
|
|
|
@ -162,6 +162,7 @@ impl TaskPoolFunction {
|
|||
Self(Arc::new(Mutex::new(Some(inner))))
|
||||
}
|
||||
|
||||
#[inline]
|
||||
fn clone(&self) -> Self {
|
||||
Self(self.0.clone())
|
||||
}
|
||||
|
@ -190,6 +191,7 @@ impl TaskPoolFunction {
|
|||
drop(inner);
|
||||
}
|
||||
|
||||
#[inline]
|
||||
fn as_ptr(&self) -> *const Mutex<Option<TaskPoolFunctionInner>> {
|
||||
Arc::as_ptr(&self.0)
|
||||
}
|
||||
|
|
|
@ -124,6 +124,7 @@ impl Task {
|
|||
pub struct TaskLock(Arc<RecMutex>);
|
||||
|
||||
impl Default for TaskLock {
|
||||
#[inline]
|
||||
fn default() -> Self {
|
||||
Self::new()
|
||||
}
|
||||
|
@ -139,6 +140,7 @@ unsafe impl Sync for RecMutex {}
|
|||
pub struct TaskLockGuard<'a>(&'a RecMutex);
|
||||
|
||||
impl TaskLock {
|
||||
#[inline]
|
||||
pub fn new() -> Self {
|
||||
unsafe {
|
||||
let lock = TaskLock(Arc::new(RecMutex(mem::zeroed())));
|
||||
|
@ -148,6 +150,7 @@ impl TaskLock {
|
|||
}
|
||||
|
||||
// checker-ignore-item
|
||||
#[inline]
|
||||
pub fn lock(&self) -> TaskLockGuard {
|
||||
unsafe {
|
||||
let guard = TaskLockGuard(&self.0);
|
||||
|
@ -158,6 +161,7 @@ impl TaskLock {
|
|||
}
|
||||
|
||||
impl Drop for RecMutex {
|
||||
#[inline]
|
||||
fn drop(&mut self) {
|
||||
unsafe {
|
||||
glib::ffi::g_rec_mutex_clear(&mut self.0);
|
||||
|
@ -166,6 +170,7 @@ impl Drop for RecMutex {
|
|||
}
|
||||
|
||||
impl<'a> Drop for TaskLockGuard<'a> {
|
||||
#[inline]
|
||||
fn drop(&mut self) {
|
||||
unsafe {
|
||||
glib::ffi::g_rec_mutex_unlock(mut_override(&self.0 .0));
|
||||
|
|
|
@ -108,6 +108,7 @@ impl TaskHandle for TaskPoolTaskHandle {
|
|||
|
||||
impl Drop for TaskPoolTaskHandle {
|
||||
#[doc(alias = "gst_task_pool_dispose_handle")]
|
||||
#[inline]
|
||||
fn drop(&mut self) {
|
||||
if let Some(task_pool) = self.task_pool.take() {
|
||||
cfg_if::cfg_if! {
|
||||
|
|
|
@ -9,6 +9,7 @@ pub struct MutexGuard<'a>(&'a glib::ffi::GMutex);
|
|||
impl<'a> MutexGuard<'a> {
|
||||
#[allow(clippy::trivially_copy_pass_by_ref)]
|
||||
#[doc(alias = "g_mutex_lock")]
|
||||
#[inline]
|
||||
pub fn lock(mutex: &'a glib::ffi::GMutex) -> Self {
|
||||
skip_assert_initialized!();
|
||||
unsafe {
|
||||
|
@ -19,6 +20,7 @@ impl<'a> MutexGuard<'a> {
|
|||
}
|
||||
|
||||
impl<'a> Drop for MutexGuard<'a> {
|
||||
#[inline]
|
||||
fn drop(&mut self) {
|
||||
unsafe {
|
||||
glib::ffi::g_mutex_unlock(mut_override(self.0));
|
||||
|
|
|
@ -9,6 +9,7 @@ use num_rational::Rational32;
|
|||
pub struct Fraction(pub Rational32);
|
||||
|
||||
impl Fraction {
|
||||
#[inline]
|
||||
pub fn new(num: i32, den: i32) -> Self {
|
||||
assert_initialized_main_thread!();
|
||||
(num, den).into()
|
||||
|
@ -24,10 +25,12 @@ impl Fraction {
|
|||
Rational32::approximate_float(x).map(|r| r.into())
|
||||
}
|
||||
|
||||
#[inline]
|
||||
pub fn numer(&self) -> i32 {
|
||||
*self.0.numer()
|
||||
}
|
||||
|
||||
#[inline]
|
||||
pub fn denom(&self) -> i32 {
|
||||
*self.0.denom()
|
||||
}
|
||||
|
@ -42,18 +45,21 @@ impl fmt::Display for Fraction {
|
|||
impl ops::Deref for Fraction {
|
||||
type Target = Rational32;
|
||||
|
||||
#[inline]
|
||||
fn deref(&self) -> &Self::Target {
|
||||
&self.0
|
||||
}
|
||||
}
|
||||
|
||||
impl ops::DerefMut for Fraction {
|
||||
#[inline]
|
||||
fn deref_mut(&mut self) -> &mut Rational32 {
|
||||
&mut self.0
|
||||
}
|
||||
}
|
||||
|
||||
impl AsRef<Rational32> for Fraction {
|
||||
#[inline]
|
||||
fn as_ref(&self) -> &Rational32 {
|
||||
&self.0
|
||||
}
|
||||
|
@ -64,6 +70,7 @@ macro_rules! impl_fraction_binop {
|
|||
impl ops::$name<Fraction> for Fraction {
|
||||
type Output = Fraction;
|
||||
|
||||
#[inline]
|
||||
fn $f(self, other: Fraction) -> Self::Output {
|
||||
Fraction((self.0).$f(other.0))
|
||||
}
|
||||
|
@ -72,6 +79,7 @@ macro_rules! impl_fraction_binop {
|
|||
impl ops::$name<Fraction> for &Fraction {
|
||||
type Output = Fraction;
|
||||
|
||||
#[inline]
|
||||
fn $f(self, other: Fraction) -> Self::Output {
|
||||
Fraction((self.0).$f(other.0))
|
||||
}
|
||||
|
@ -80,6 +88,7 @@ macro_rules! impl_fraction_binop {
|
|||
impl ops::$name<&Fraction> for Fraction {
|
||||
type Output = Fraction;
|
||||
|
||||
#[inline]
|
||||
fn $f(self, other: &Fraction) -> Self::Output {
|
||||
Fraction((self.0).$f(other.0))
|
||||
}
|
||||
|
@ -88,6 +97,7 @@ macro_rules! impl_fraction_binop {
|
|||
impl ops::$name<&Fraction> for &Fraction {
|
||||
type Output = Fraction;
|
||||
|
||||
#[inline]
|
||||
fn $f(self, other: &Fraction) -> Self::Output {
|
||||
Fraction((self.0).$f(other.0))
|
||||
}
|
||||
|
@ -96,6 +106,7 @@ macro_rules! impl_fraction_binop {
|
|||
impl ops::$name<i32> for Fraction {
|
||||
type Output = Fraction;
|
||||
|
||||
#[inline]
|
||||
fn $f(self, other: i32) -> Self::Output {
|
||||
self.$f(Fraction::from(other))
|
||||
}
|
||||
|
@ -104,6 +115,7 @@ macro_rules! impl_fraction_binop {
|
|||
impl ops::$name<i32> for &Fraction {
|
||||
type Output = Fraction;
|
||||
|
||||
#[inline]
|
||||
fn $f(self, other: i32) -> Self::Output {
|
||||
self.$f(Fraction::from(other))
|
||||
}
|
||||
|
@ -112,6 +124,7 @@ macro_rules! impl_fraction_binop {
|
|||
impl ops::$name<&i32> for Fraction {
|
||||
type Output = Fraction;
|
||||
|
||||
#[inline]
|
||||
fn $f(self, other: &i32) -> Self::Output {
|
||||
self.$f(Fraction::from(*other))
|
||||
}
|
||||
|
@ -120,6 +133,7 @@ macro_rules! impl_fraction_binop {
|
|||
impl ops::$name<&i32> for &Fraction {
|
||||
type Output = Fraction;
|
||||
|
||||
#[inline]
|
||||
fn $f(self, other: &i32) -> Self::Output {
|
||||
self.$f(Fraction::from(*other))
|
||||
}
|
||||
|
@ -128,6 +142,7 @@ macro_rules! impl_fraction_binop {
|
|||
impl ops::$name<Fraction> for i32 {
|
||||
type Output = Fraction;
|
||||
|
||||
#[inline]
|
||||
fn $f(self, other: Fraction) -> Self::Output {
|
||||
Fraction::from(self).$f(other)
|
||||
}
|
||||
|
@ -136,6 +151,7 @@ macro_rules! impl_fraction_binop {
|
|||
impl ops::$name<&Fraction> for i32 {
|
||||
type Output = Fraction;
|
||||
|
||||
#[inline]
|
||||
fn $f(self, other: &Fraction) -> Self::Output {
|
||||
Fraction::from(self).$f(other)
|
||||
}
|
||||
|
@ -144,6 +160,7 @@ macro_rules! impl_fraction_binop {
|
|||
impl ops::$name<Fraction> for &i32 {
|
||||
type Output = Fraction;
|
||||
|
||||
#[inline]
|
||||
fn $f(self, other: Fraction) -> Self::Output {
|
||||
Fraction::from(*self).$f(other)
|
||||
}
|
||||
|
@ -152,30 +169,35 @@ macro_rules! impl_fraction_binop {
|
|||
impl ops::$name<&Fraction> for &i32 {
|
||||
type Output = Fraction;
|
||||
|
||||
#[inline]
|
||||
fn $f(self, other: &Fraction) -> Self::Output {
|
||||
Fraction::from(*self).$f(other)
|
||||
}
|
||||
}
|
||||
|
||||
impl ops::$name_assign<Fraction> for Fraction {
|
||||
#[inline]
|
||||
fn $f_assign(&mut self, other: Fraction) {
|
||||
(self.0).$f_assign(other.0)
|
||||
}
|
||||
}
|
||||
|
||||
impl ops::$name_assign<&Fraction> for Fraction {
|
||||
#[inline]
|
||||
fn $f_assign(&mut self, other: &Fraction) {
|
||||
(self.0).$f_assign(other.0)
|
||||
}
|
||||
}
|
||||
|
||||
impl ops::$name_assign<i32> for Fraction {
|
||||
#[inline]
|
||||
fn $f_assign(&mut self, other: i32) {
|
||||
(self.0).$f_assign(other)
|
||||
}
|
||||
}
|
||||
|
||||
impl ops::$name_assign<&i32> for Fraction {
|
||||
#[inline]
|
||||
fn $f_assign(&mut self, other: &i32) {
|
||||
(self.0).$f_assign(other)
|
||||
}
|
||||
|
@ -192,6 +214,7 @@ impl_fraction_binop!(Rem, rem, RemAssign, rem_assign);
|
|||
impl ops::Neg for Fraction {
|
||||
type Output = Fraction;
|
||||
|
||||
#[inline]
|
||||
fn neg(self) -> Self::Output {
|
||||
Fraction(self.0.neg())
|
||||
}
|
||||
|
@ -200,12 +223,14 @@ impl ops::Neg for Fraction {
|
|||
impl ops::Neg for &Fraction {
|
||||
type Output = Fraction;
|
||||
|
||||
#[inline]
|
||||
fn neg(self) -> Self::Output {
|
||||
Fraction(self.0.neg())
|
||||
}
|
||||
}
|
||||
|
||||
impl From<i32> for Fraction {
|
||||
#[inline]
|
||||
fn from(x: i32) -> Self {
|
||||
assert_initialized_main_thread!();
|
||||
Fraction(x.into())
|
||||
|
@ -213,6 +238,7 @@ impl From<i32> for Fraction {
|
|||
}
|
||||
|
||||
impl From<(i32, i32)> for Fraction {
|
||||
#[inline]
|
||||
fn from(x: (i32, i32)) -> Self {
|
||||
assert_initialized_main_thread!();
|
||||
Fraction(x.into())
|
||||
|
@ -220,6 +246,7 @@ impl From<(i32, i32)> for Fraction {
|
|||
}
|
||||
|
||||
impl From<Fraction> for (i32, i32) {
|
||||
#[inline]
|
||||
fn from(f: Fraction) -> Self {
|
||||
skip_assert_initialized!();
|
||||
f.0.into()
|
||||
|
@ -227,6 +254,7 @@ impl From<Fraction> for (i32, i32) {
|
|||
}
|
||||
|
||||
impl From<Rational32> for Fraction {
|
||||
#[inline]
|
||||
fn from(x: Rational32) -> Self {
|
||||
assert_initialized_main_thread!();
|
||||
Fraction(x)
|
||||
|
@ -234,6 +262,7 @@ impl From<Rational32> for Fraction {
|
|||
}
|
||||
|
||||
impl From<Fraction> for Rational32 {
|
||||
#[inline]
|
||||
fn from(x: Fraction) -> Self {
|
||||
skip_assert_initialized!();
|
||||
x.0
|
||||
|
@ -241,6 +270,7 @@ impl From<Fraction> for Rational32 {
|
|||
}
|
||||
|
||||
impl glib::types::StaticType for Fraction {
|
||||
#[inline]
|
||||
fn static_type() -> glib::types::Type {
|
||||
unsafe { from_glib(ffi::gst_fraction_get_type()) }
|
||||
}
|
||||
|
@ -253,6 +283,7 @@ impl glib::value::ValueType for Fraction {
|
|||
unsafe impl<'a> glib::value::FromValue<'a> for Fraction {
|
||||
type Checker = glib::value::GenericValueTypeChecker<Self>;
|
||||
|
||||
#[inline]
|
||||
unsafe fn from_value(value: &'a glib::Value) -> Self {
|
||||
skip_assert_initialized!();
|
||||
let n = ffi::gst_value_get_fraction_numerator(value.to_glib_none().0);
|
||||
|
@ -263,6 +294,7 @@ unsafe impl<'a> glib::value::FromValue<'a> for Fraction {
|
|||
}
|
||||
|
||||
impl glib::value::ToValue for Fraction {
|
||||
#[inline]
|
||||
fn to_value(&self) -> glib::Value {
|
||||
let mut value = glib::Value::for_value_type::<Self>();
|
||||
unsafe {
|
||||
|
@ -271,12 +303,14 @@ impl glib::value::ToValue for Fraction {
|
|||
value
|
||||
}
|
||||
|
||||
#[inline]
|
||||
fn value_type(&self) -> glib::Type {
|
||||
Self::static_type()
|
||||
}
|
||||
}
|
||||
|
||||
impl From<Fraction> for glib::Value {
|
||||
#[inline]
|
||||
fn from(v: Fraction) -> glib::Value {
|
||||
skip_assert_initialized!();
|
||||
glib::value::ToValue::to_value(&v)
|
||||
|
@ -292,14 +326,17 @@ pub struct IntRange<T> {
|
|||
}
|
||||
|
||||
impl<T: Copy> IntRange<T> {
|
||||
#[inline]
|
||||
pub fn min(&self) -> T {
|
||||
self.min
|
||||
}
|
||||
|
||||
#[inline]
|
||||
pub fn max(&self) -> T {
|
||||
self.max
|
||||
}
|
||||
|
||||
#[inline]
|
||||
pub fn step(&self) -> T {
|
||||
self.step
|
||||
}
|
||||
|
@ -312,11 +349,13 @@ pub trait IntRangeType: Sized + Clone + Copy + 'static {
|
|||
}
|
||||
|
||||
impl IntRangeType for i32 {
|
||||
#[inline]
|
||||
fn with_min_max(min: i32, max: i32) -> IntRange<Self> {
|
||||
skip_assert_initialized!();
|
||||
IntRange { min, max, step: 1 }
|
||||
}
|
||||
|
||||
#[inline]
|
||||
fn with_step(min: i32, max: i32, step: i32) -> IntRange<Self> {
|
||||
assert_initialized_main_thread!();
|
||||
|
||||
|
@ -328,11 +367,13 @@ impl IntRangeType for i32 {
|
|||
}
|
||||
|
||||
impl IntRangeType for i64 {
|
||||
#[inline]
|
||||
fn with_min_max(min: i64, max: i64) -> IntRange<Self> {
|
||||
skip_assert_initialized!();
|
||||
IntRange { min, max, step: 1 }
|
||||
}
|
||||
|
||||
#[inline]
|
||||
fn with_step(min: i64, max: i64, step: i64) -> IntRange<Self> {
|
||||
assert_initialized_main_thread!();
|
||||
|
||||
|
@ -344,11 +385,13 @@ impl IntRangeType for i64 {
|
|||
}
|
||||
|
||||
impl<T: IntRangeType> IntRange<T> {
|
||||
#[inline]
|
||||
pub fn new(min: T, max: T) -> IntRange<T> {
|
||||
assert_initialized_main_thread!();
|
||||
T::with_min_max(min, max)
|
||||
}
|
||||
|
||||
#[inline]
|
||||
pub fn with_step(min: T, max: T, step: T) -> IntRange<T> {
|
||||
assert_initialized_main_thread!();
|
||||
T::with_step(min, max, step)
|
||||
|
@ -356,6 +399,7 @@ impl<T: IntRangeType> IntRange<T> {
|
|||
}
|
||||
|
||||
impl From<(i32, i32)> for IntRange<i32> {
|
||||
#[inline]
|
||||
fn from((min, max): (i32, i32)) -> Self {
|
||||
skip_assert_initialized!();
|
||||
Self::new(min, max)
|
||||
|
@ -363,6 +407,7 @@ impl From<(i32, i32)> for IntRange<i32> {
|
|||
}
|
||||
|
||||
impl From<(i32, i32, i32)> for IntRange<i32> {
|
||||
#[inline]
|
||||
fn from((min, max, step): (i32, i32, i32)) -> Self {
|
||||
skip_assert_initialized!();
|
||||
Self::with_step(min, max, step)
|
||||
|
@ -370,6 +415,7 @@ impl From<(i32, i32, i32)> for IntRange<i32> {
|
|||
}
|
||||
|
||||
impl From<(i64, i64)> for IntRange<i64> {
|
||||
#[inline]
|
||||
fn from((min, max): (i64, i64)) -> Self {
|
||||
skip_assert_initialized!();
|
||||
Self::new(min, max)
|
||||
|
@ -377,6 +423,7 @@ impl From<(i64, i64)> for IntRange<i64> {
|
|||
}
|
||||
|
||||
impl From<(i64, i64, i64)> for IntRange<i64> {
|
||||
#[inline]
|
||||
fn from((min, max, step): (i64, i64, i64)) -> Self {
|
||||
skip_assert_initialized!();
|
||||
Self::with_step(min, max, step)
|
||||
|
@ -384,6 +431,7 @@ impl From<(i64, i64, i64)> for IntRange<i64> {
|
|||
}
|
||||
|
||||
impl glib::types::StaticType for IntRange<i32> {
|
||||
#[inline]
|
||||
fn static_type() -> glib::types::Type {
|
||||
unsafe { from_glib(ffi::gst_int_range_get_type()) }
|
||||
}
|
||||
|
@ -396,6 +444,7 @@ impl glib::value::ValueType for IntRange<i32> {
|
|||
unsafe impl<'a> glib::value::FromValue<'a> for IntRange<i32> {
|
||||
type Checker = glib::value::GenericValueTypeChecker<Self>;
|
||||
|
||||
#[inline]
|
||||
unsafe fn from_value(value: &'a glib::Value) -> Self {
|
||||
skip_assert_initialized!();
|
||||
let min = ffi::gst_value_get_int_range_min(value.to_glib_none().0);
|
||||
|
@ -407,6 +456,7 @@ unsafe impl<'a> glib::value::FromValue<'a> for IntRange<i32> {
|
|||
}
|
||||
|
||||
impl glib::value::ToValue for IntRange<i32> {
|
||||
#[inline]
|
||||
fn to_value(&self) -> glib::Value {
|
||||
let mut value = glib::Value::for_value_type::<Self>();
|
||||
unsafe {
|
||||
|
@ -420,12 +470,14 @@ impl glib::value::ToValue for IntRange<i32> {
|
|||
value
|
||||
}
|
||||
|
||||
#[inline]
|
||||
fn value_type(&self) -> glib::Type {
|
||||
Self::static_type()
|
||||
}
|
||||
}
|
||||
|
||||
impl From<IntRange<i32>> for glib::Value {
|
||||
#[inline]
|
||||
fn from(v: IntRange<i32>) -> glib::Value {
|
||||
skip_assert_initialized!();
|
||||
glib::value::ToValue::to_value(&v)
|
||||
|
@ -433,6 +485,7 @@ impl From<IntRange<i32>> for glib::Value {
|
|||
}
|
||||
|
||||
impl glib::types::StaticType for IntRange<i64> {
|
||||
#[inline]
|
||||
fn static_type() -> glib::types::Type {
|
||||
unsafe { from_glib(ffi::gst_int64_range_get_type()) }
|
||||
}
|
||||
|
@ -445,6 +498,7 @@ impl glib::value::ValueType for IntRange<i64> {
|
|||
unsafe impl<'a> glib::value::FromValue<'a> for IntRange<i64> {
|
||||
type Checker = glib::value::GenericValueTypeChecker<Self>;
|
||||
|
||||
#[inline]
|
||||
unsafe fn from_value(value: &'a glib::Value) -> Self {
|
||||
skip_assert_initialized!();
|
||||
let min = ffi::gst_value_get_int64_range_min(value.to_glib_none().0);
|
||||
|
@ -456,6 +510,7 @@ unsafe impl<'a> glib::value::FromValue<'a> for IntRange<i64> {
|
|||
}
|
||||
|
||||
impl glib::value::ToValue for IntRange<i64> {
|
||||
#[inline]
|
||||
fn to_value(&self) -> glib::Value {
|
||||
let mut value = glib::Value::for_value_type::<Self>();
|
||||
unsafe {
|
||||
|
@ -469,12 +524,14 @@ impl glib::value::ToValue for IntRange<i64> {
|
|||
value
|
||||
}
|
||||
|
||||
#[inline]
|
||||
fn value_type(&self) -> glib::Type {
|
||||
Self::static_type()
|
||||
}
|
||||
}
|
||||
|
||||
impl From<IntRange<i64>> for glib::Value {
|
||||
#[inline]
|
||||
fn from(v: IntRange<i64>) -> glib::Value {
|
||||
skip_assert_initialized!();
|
||||
glib::value::ToValue::to_value(&v)
|
||||
|
@ -489,6 +546,7 @@ pub struct FractionRange {
|
|||
}
|
||||
|
||||
impl FractionRange {
|
||||
#[inline]
|
||||
pub fn new<T: Into<Fraction>, U: Into<Fraction>>(min: T, max: U) -> Self {
|
||||
assert_initialized_main_thread!();
|
||||
|
||||
|
@ -500,16 +558,19 @@ impl FractionRange {
|
|||
FractionRange { min, max }
|
||||
}
|
||||
|
||||
#[inline]
|
||||
pub fn min(&self) -> Fraction {
|
||||
self.min
|
||||
}
|
||||
|
||||
#[inline]
|
||||
pub fn max(&self) -> Fraction {
|
||||
self.max
|
||||
}
|
||||
}
|
||||
|
||||
impl From<(Fraction, Fraction)> for FractionRange {
|
||||
#[inline]
|
||||
fn from((min, max): (Fraction, Fraction)) -> Self {
|
||||
skip_assert_initialized!();
|
||||
|
||||
|
@ -518,6 +579,7 @@ impl From<(Fraction, Fraction)> for FractionRange {
|
|||
}
|
||||
|
||||
impl glib::types::StaticType for FractionRange {
|
||||
#[inline]
|
||||
fn static_type() -> glib::types::Type {
|
||||
unsafe { from_glib(ffi::gst_fraction_range_get_type()) }
|
||||
}
|
||||
|
@ -530,6 +592,7 @@ impl glib::value::ValueType for FractionRange {
|
|||
unsafe impl<'a> glib::value::FromValue<'a> for FractionRange {
|
||||
type Checker = glib::value::GenericValueTypeChecker<Self>;
|
||||
|
||||
#[inline]
|
||||
unsafe fn from_value(value: &'a glib::Value) -> Self {
|
||||
skip_assert_initialized!();
|
||||
let min = ffi::gst_value_get_fraction_range_min(value.to_glib_none().0);
|
||||
|
@ -545,6 +608,7 @@ unsafe impl<'a> glib::value::FromValue<'a> for FractionRange {
|
|||
}
|
||||
|
||||
impl glib::value::ToValue for FractionRange {
|
||||
#[inline]
|
||||
fn to_value(&self) -> glib::Value {
|
||||
let mut value = glib::Value::for_value_type::<Self>();
|
||||
unsafe {
|
||||
|
@ -559,12 +623,14 @@ impl glib::value::ToValue for FractionRange {
|
|||
value
|
||||
}
|
||||
|
||||
#[inline]
|
||||
fn value_type(&self) -> glib::Type {
|
||||
Self::static_type()
|
||||
}
|
||||
}
|
||||
|
||||
impl From<FractionRange> for glib::Value {
|
||||
#[inline]
|
||||
fn from(v: FractionRange) -> glib::Value {
|
||||
skip_assert_initialized!();
|
||||
glib::value::ToValue::to_value(&v)
|
||||
|
@ -576,6 +642,7 @@ impl From<FractionRange> for glib::Value {
|
|||
pub struct Bitmask(pub u64);
|
||||
|
||||
impl Bitmask {
|
||||
#[inline]
|
||||
pub fn new(v: u64) -> Self {
|
||||
assert_initialized_main_thread!();
|
||||
Bitmask(v)
|
||||
|
@ -585,12 +652,14 @@ impl Bitmask {
|
|||
impl ops::Deref for Bitmask {
|
||||
type Target = u64;
|
||||
|
||||
#[inline]
|
||||
fn deref(&self) -> &u64 {
|
||||
&self.0
|
||||
}
|
||||
}
|
||||
|
||||
impl ops::DerefMut for Bitmask {
|
||||
#[inline]
|
||||
fn deref_mut(&mut self) -> &mut u64 {
|
||||
&mut self.0
|
||||
}
|
||||
|
@ -599,6 +668,7 @@ impl ops::DerefMut for Bitmask {
|
|||
impl ops::BitAnd for Bitmask {
|
||||
type Output = Self;
|
||||
|
||||
#[inline]
|
||||
fn bitand(self, rhs: Self) -> Self {
|
||||
Bitmask(self.0.bitand(rhs.0))
|
||||
}
|
||||
|
@ -607,6 +677,7 @@ impl ops::BitAnd for Bitmask {
|
|||
impl ops::BitOr for Bitmask {
|
||||
type Output = Self;
|
||||
|
||||
#[inline]
|
||||
fn bitor(self, rhs: Self) -> Self {
|
||||
Bitmask(self.0.bitor(rhs.0))
|
||||
}
|
||||
|
@ -615,6 +686,7 @@ impl ops::BitOr for Bitmask {
|
|||
impl ops::BitXor for Bitmask {
|
||||
type Output = Self;
|
||||
|
||||
#[inline]
|
||||
fn bitxor(self, rhs: Self) -> Self {
|
||||
Bitmask(self.0.bitxor(rhs.0))
|
||||
}
|
||||
|
@ -623,12 +695,14 @@ impl ops::BitXor for Bitmask {
|
|||
impl ops::Not for Bitmask {
|
||||
type Output = Self;
|
||||
|
||||
#[inline]
|
||||
fn not(self) -> Self {
|
||||
Bitmask(self.0.not())
|
||||
}
|
||||
}
|
||||
|
||||
impl From<u64> for Bitmask {
|
||||
#[inline]
|
||||
fn from(v: u64) -> Self {
|
||||
skip_assert_initialized!();
|
||||
Self::new(v)
|
||||
|
@ -636,6 +710,7 @@ impl From<u64> for Bitmask {
|
|||
}
|
||||
|
||||
impl glib::types::StaticType for Bitmask {
|
||||
#[inline]
|
||||
fn static_type() -> glib::types::Type {
|
||||
unsafe { from_glib(ffi::gst_bitmask_get_type()) }
|
||||
}
|
||||
|
@ -648,6 +723,7 @@ impl glib::value::ValueType for Bitmask {
|
|||
unsafe impl<'a> glib::value::FromValue<'a> for Bitmask {
|
||||
type Checker = glib::value::GenericValueTypeChecker<Self>;
|
||||
|
||||
#[inline]
|
||||
unsafe fn from_value(value: &'a glib::Value) -> Self {
|
||||
skip_assert_initialized!();
|
||||
let v = ffi::gst_value_get_bitmask(value.to_glib_none().0);
|
||||
|
@ -656,6 +732,7 @@ unsafe impl<'a> glib::value::FromValue<'a> for Bitmask {
|
|||
}
|
||||
|
||||
impl glib::value::ToValue for Bitmask {
|
||||
#[inline]
|
||||
fn to_value(&self) -> glib::Value {
|
||||
let mut value = glib::Value::for_value_type::<Self>();
|
||||
unsafe {
|
||||
|
@ -664,12 +741,14 @@ impl glib::value::ToValue for Bitmask {
|
|||
value
|
||||
}
|
||||
|
||||
#[inline]
|
||||
fn value_type(&self) -> glib::Type {
|
||||
Self::static_type()
|
||||
}
|
||||
}
|
||||
|
||||
impl From<Bitmask> for glib::Value {
|
||||
#[inline]
|
||||
fn from(v: Bitmask) -> glib::Value {
|
||||
skip_assert_initialized!();
|
||||
glib::value::ToValue::to_value(&v)
|
||||
|
@ -709,6 +788,7 @@ impl Array {
|
|||
Self::new(values)
|
||||
}
|
||||
|
||||
#[inline]
|
||||
pub fn as_slice(&self) -> &[glib::SendValue] {
|
||||
unsafe {
|
||||
let arr = (*self.0.as_ptr()).data[0].v_pointer as *const glib::ffi::GArray;
|
||||
|
@ -750,12 +830,14 @@ impl Default for Array {
|
|||
impl ops::Deref for Array {
|
||||
type Target = [glib::SendValue];
|
||||
|
||||
#[inline]
|
||||
fn deref(&self) -> &[glib::SendValue] {
|
||||
self.as_slice()
|
||||
}
|
||||
}
|
||||
|
||||
impl AsRef<[glib::SendValue]> for Array {
|
||||
#[inline]
|
||||
fn as_ref(&self) -> &[glib::SendValue] {
|
||||
self.as_slice()
|
||||
}
|
||||
|
@ -807,6 +889,7 @@ impl From<Array> for glib::Value {
|
|||
}
|
||||
|
||||
impl glib::types::StaticType for Array {
|
||||
#[inline]
|
||||
fn static_type() -> glib::types::Type {
|
||||
unsafe { from_glib(ffi::gst_value_array_get_type()) }
|
||||
}
|
||||
|
@ -825,6 +908,7 @@ impl<'a> ArrayRef<'a> {
|
|||
Self(values)
|
||||
}
|
||||
|
||||
#[inline]
|
||||
pub fn as_slice(&self) -> &'a [glib::SendValue] {
|
||||
self.0
|
||||
}
|
||||
|
@ -833,12 +917,14 @@ impl<'a> ArrayRef<'a> {
|
|||
impl<'a> ops::Deref for ArrayRef<'a> {
|
||||
type Target = [glib::SendValue];
|
||||
|
||||
#[inline]
|
||||
fn deref(&self) -> &[glib::SendValue] {
|
||||
self.as_slice()
|
||||
}
|
||||
}
|
||||
|
||||
impl<'a> AsRef<[glib::SendValue]> for ArrayRef<'a> {
|
||||
#[inline]
|
||||
fn as_ref(&self) -> &[glib::SendValue] {
|
||||
self.as_slice()
|
||||
}
|
||||
|
@ -847,6 +933,7 @@ impl<'a> AsRef<[glib::SendValue]> for ArrayRef<'a> {
|
|||
unsafe impl<'a> glib::value::FromValue<'a> for ArrayRef<'a> {
|
||||
type Checker = glib::value::GenericValueTypeChecker<Self>;
|
||||
|
||||
#[inline]
|
||||
unsafe fn from_value(value: &'a glib::Value) -> Self {
|
||||
skip_assert_initialized!();
|
||||
let arr = (*value.as_ptr()).data[0].v_pointer as *const glib::ffi::GArray;
|
||||
|
@ -863,6 +950,7 @@ unsafe impl<'a> glib::value::FromValue<'a> for ArrayRef<'a> {
|
|||
}
|
||||
|
||||
impl<'a> glib::value::ToValue for ArrayRef<'a> {
|
||||
#[inline]
|
||||
fn to_value(&self) -> glib::Value {
|
||||
let mut value = glib::Value::for_value_type::<Array>();
|
||||
unsafe {
|
||||
|
@ -873,12 +961,14 @@ impl<'a> glib::value::ToValue for ArrayRef<'a> {
|
|||
value
|
||||
}
|
||||
|
||||
#[inline]
|
||||
fn value_type(&self) -> glib::Type {
|
||||
Self::static_type()
|
||||
}
|
||||
}
|
||||
|
||||
impl<'a> From<ArrayRef<'a>> for glib::Value {
|
||||
#[inline]
|
||||
fn from(v: ArrayRef<'a>) -> glib::Value {
|
||||
skip_assert_initialized!();
|
||||
glib::value::ToValue::to_value(&v)
|
||||
|
@ -886,6 +976,7 @@ impl<'a> From<ArrayRef<'a>> for glib::Value {
|
|||
}
|
||||
|
||||
impl<'a> glib::types::StaticType for ArrayRef<'a> {
|
||||
#[inline]
|
||||
fn static_type() -> glib::types::Type {
|
||||
unsafe { from_glib(ffi::gst_value_array_get_type()) }
|
||||
}
|
||||
|
@ -924,6 +1015,7 @@ impl List {
|
|||
Self::new(values)
|
||||
}
|
||||
|
||||
#[inline]
|
||||
pub fn as_slice(&self) -> &[glib::SendValue] {
|
||||
unsafe {
|
||||
let arr = (*self.0.as_ptr()).data[0].v_pointer as *const glib::ffi::GArray;
|
||||
|
@ -965,12 +1057,14 @@ impl Default for List {
|
|||
impl ops::Deref for List {
|
||||
type Target = [glib::SendValue];
|
||||
|
||||
#[inline]
|
||||
fn deref(&self) -> &[glib::SendValue] {
|
||||
self.as_slice()
|
||||
}
|
||||
}
|
||||
|
||||
impl AsRef<[glib::SendValue]> for List {
|
||||
#[inline]
|
||||
fn as_ref(&self) -> &[glib::SendValue] {
|
||||
self.as_slice()
|
||||
}
|
||||
|
@ -1022,6 +1116,7 @@ impl From<List> for glib::Value {
|
|||
}
|
||||
|
||||
impl glib::types::StaticType for List {
|
||||
#[inline]
|
||||
fn static_type() -> glib::types::Type {
|
||||
unsafe { from_glib(ffi::gst_value_list_get_type()) }
|
||||
}
|
||||
|
@ -1040,6 +1135,7 @@ impl<'a> ListRef<'a> {
|
|||
Self(values)
|
||||
}
|
||||
|
||||
#[inline]
|
||||
pub fn as_slice(&self) -> &'a [glib::SendValue] {
|
||||
self.0
|
||||
}
|
||||
|
@ -1048,12 +1144,14 @@ impl<'a> ListRef<'a> {
|
|||
impl<'a> ops::Deref for ListRef<'a> {
|
||||
type Target = [glib::SendValue];
|
||||
|
||||
#[inline]
|
||||
fn deref(&self) -> &[glib::SendValue] {
|
||||
self.as_slice()
|
||||
}
|
||||
}
|
||||
|
||||
impl<'a> AsRef<[glib::SendValue]> for ListRef<'a> {
|
||||
#[inline]
|
||||
fn as_ref(&self) -> &[glib::SendValue] {
|
||||
self.as_slice()
|
||||
}
|
||||
|
@ -1062,6 +1160,7 @@ impl<'a> AsRef<[glib::SendValue]> for ListRef<'a> {
|
|||
unsafe impl<'a> glib::value::FromValue<'a> for ListRef<'a> {
|
||||
type Checker = glib::value::GenericValueTypeChecker<Self>;
|
||||
|
||||
#[inline]
|
||||
unsafe fn from_value(value: &'a glib::Value) -> Self {
|
||||
skip_assert_initialized!();
|
||||
let arr = (*value.as_ptr()).data[0].v_pointer as *const glib::ffi::GArray;
|
||||
|
@ -1078,6 +1177,7 @@ unsafe impl<'a> glib::value::FromValue<'a> for ListRef<'a> {
|
|||
}
|
||||
|
||||
impl<'a> glib::value::ToValue for ListRef<'a> {
|
||||
#[inline]
|
||||
fn to_value(&self) -> glib::Value {
|
||||
let mut value = glib::Value::for_value_type::<List>();
|
||||
unsafe {
|
||||
|
@ -1088,12 +1188,14 @@ impl<'a> glib::value::ToValue for ListRef<'a> {
|
|||
value
|
||||
}
|
||||
|
||||
#[inline]
|
||||
fn value_type(&self) -> glib::Type {
|
||||
Self::static_type()
|
||||
}
|
||||
}
|
||||
|
||||
impl<'a> From<ListRef<'a>> for glib::Value {
|
||||
#[inline]
|
||||
fn from(v: ListRef<'a>) -> glib::Value {
|
||||
skip_assert_initialized!();
|
||||
glib::value::ToValue::to_value(&v)
|
||||
|
@ -1101,6 +1203,7 @@ impl<'a> From<ListRef<'a>> for glib::Value {
|
|||
}
|
||||
|
||||
impl<'a> glib::types::StaticType for ListRef<'a> {
|
||||
#[inline]
|
||||
fn static_type() -> glib::types::Type {
|
||||
unsafe { from_glib(ffi::gst_value_list_get_type()) }
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue