mirror of
https://gitlab.freedesktop.org/gstreamer/gstreamer-rs.git
synced 2024-11-22 09:31:06 +00:00
video: Fix all clippy::use_self warnings
This commit is contained in:
parent
66b60a0822
commit
28cf8434d0
10 changed files with 89 additions and 98 deletions
|
@ -67,12 +67,12 @@ impl VideoAlignment {
|
|||
stride_align: *stride_align,
|
||||
};
|
||||
|
||||
VideoAlignment(videoalignment)
|
||||
Self(videoalignment)
|
||||
}
|
||||
}
|
||||
|
||||
impl PartialEq for VideoAlignment {
|
||||
fn eq(&self, other: &VideoAlignment) -> bool {
|
||||
fn eq(&self, other: &Self) -> bool {
|
||||
self.padding_top() == other.padding_top()
|
||||
&& self.padding_bottom() == other.padding_bottom()
|
||||
&& self.padding_left() == other.padding_left()
|
||||
|
|
|
@ -44,7 +44,7 @@ impl VideoConverter {
|
|||
if ptr.is_null() {
|
||||
Err(glib::bool_error!("Failed to create video converter"))
|
||||
} else {
|
||||
Ok(VideoConverter(ptr::NonNull::new_unchecked(ptr)))
|
||||
Ok(Self(ptr::NonNull::new_unchecked(ptr)))
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -118,17 +118,17 @@ impl AsMut<gst::StructureRef> for VideoConverterConfig {
|
|||
|
||||
impl Default for VideoConverterConfig {
|
||||
fn default() -> Self {
|
||||
VideoConverterConfig::new()
|
||||
Self::new()
|
||||
}
|
||||
}
|
||||
|
||||
impl convert::TryFrom<gst::Structure> for VideoConverterConfig {
|
||||
type Error = glib::BoolError;
|
||||
|
||||
fn try_from(v: gst::Structure) -> Result<VideoConverterConfig, Self::Error> {
|
||||
fn try_from(v: gst::Structure) -> Result<Self, Self::Error> {
|
||||
skip_assert_initialized!();
|
||||
if v.name() == "GstVideoConverter" {
|
||||
Ok(VideoConverterConfig(v))
|
||||
Ok(Self(v))
|
||||
} else {
|
||||
Err(glib::bool_error!("Structure is no VideoConverterConfig"))
|
||||
}
|
||||
|
@ -138,14 +138,14 @@ impl convert::TryFrom<gst::Structure> for VideoConverterConfig {
|
|||
impl<'a> convert::TryFrom<&'a gst::StructureRef> for VideoConverterConfig {
|
||||
type Error = glib::BoolError;
|
||||
|
||||
fn try_from(v: &'a gst::StructureRef) -> Result<VideoConverterConfig, Self::Error> {
|
||||
fn try_from(v: &'a gst::StructureRef) -> Result<Self, Self::Error> {
|
||||
skip_assert_initialized!();
|
||||
VideoConverterConfig::try_from(v.to_owned())
|
||||
Self::try_from(v.to_owned())
|
||||
}
|
||||
}
|
||||
|
||||
impl From<VideoConverterConfig> for gst::Structure {
|
||||
fn from(v: VideoConverterConfig) -> gst::Structure {
|
||||
fn from(v: VideoConverterConfig) -> Self {
|
||||
skip_assert_initialized!();
|
||||
v.0
|
||||
}
|
||||
|
@ -153,7 +153,7 @@ impl From<VideoConverterConfig> for gst::Structure {
|
|||
|
||||
impl VideoConverterConfig {
|
||||
pub fn new() -> Self {
|
||||
VideoConverterConfig(gst::Structure::new_empty("GstVideoConverter"))
|
||||
Self(gst::Structure::new_empty("GstVideoConverter"))
|
||||
}
|
||||
|
||||
pub fn set_resampler_method(&mut self, v: crate::VideoResamplerMethod) {
|
||||
|
|
|
@ -144,9 +144,7 @@ impl DownstreamForceKeyUnitEvent {
|
|||
DownstreamForceKeyUnitEventBuilder::new()
|
||||
}
|
||||
|
||||
pub fn parse(
|
||||
event: &gst::EventRef,
|
||||
) -> Result<DownstreamForceKeyUnitEvent, glib::error::BoolError> {
|
||||
pub fn parse(event: &gst::EventRef) -> Result<Self, glib::error::BoolError> {
|
||||
skip_assert_initialized!();
|
||||
unsafe {
|
||||
let mut timestamp = mem::MaybeUninit::uninit();
|
||||
|
@ -164,7 +162,7 @@ impl DownstreamForceKeyUnitEvent {
|
|||
count.as_mut_ptr(),
|
||||
));
|
||||
if res {
|
||||
Ok(DownstreamForceKeyUnitEvent {
|
||||
Ok(Self {
|
||||
timestamp: from_glib(timestamp.assume_init()),
|
||||
stream_time: from_glib(stream_time.assume_init()),
|
||||
running_time: from_glib(running_time.assume_init()),
|
||||
|
@ -239,9 +237,7 @@ impl UpstreamForceKeyUnitEvent {
|
|||
UpstreamForceKeyUnitEventBuilder::new()
|
||||
}
|
||||
|
||||
pub fn parse(
|
||||
event: &gst::EventRef,
|
||||
) -> Result<UpstreamForceKeyUnitEvent, glib::error::BoolError> {
|
||||
pub fn parse(event: &gst::EventRef) -> Result<Self, glib::error::BoolError> {
|
||||
skip_assert_initialized!();
|
||||
unsafe {
|
||||
let mut running_time = mem::MaybeUninit::uninit();
|
||||
|
@ -255,7 +251,7 @@ impl UpstreamForceKeyUnitEvent {
|
|||
count.as_mut_ptr(),
|
||||
));
|
||||
if res {
|
||||
Ok(UpstreamForceKeyUnitEvent {
|
||||
Ok(Self {
|
||||
running_time: from_glib(running_time.assume_init()),
|
||||
all_headers: from_glib(all_headers.assume_init()),
|
||||
count: count.assume_init(),
|
||||
|
@ -279,12 +275,12 @@ impl ForceKeyUnitEvent {
|
|||
unsafe { from_glib(ffi::gst_video_event_is_force_key_unit(event.as_mut_ptr())) }
|
||||
}
|
||||
|
||||
pub fn parse(event: &gst::EventRef) -> Result<ForceKeyUnitEvent, glib::error::BoolError> {
|
||||
pub fn parse(event: &gst::EventRef) -> Result<Self, glib::error::BoolError> {
|
||||
skip_assert_initialized!();
|
||||
if event.is_upstream() {
|
||||
UpstreamForceKeyUnitEvent::parse(event).map(ForceKeyUnitEvent::Upstream)
|
||||
UpstreamForceKeyUnitEvent::parse(event).map(Self::Upstream)
|
||||
} else {
|
||||
DownstreamForceKeyUnitEvent::parse(event).map(ForceKeyUnitEvent::Downstream)
|
||||
DownstreamForceKeyUnitEvent::parse(event).map(Self::Downstream)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -323,7 +319,7 @@ impl StillFrameEvent {
|
|||
StillFrameEventBuilder::new(in_still)
|
||||
}
|
||||
|
||||
pub fn parse(event: &gst::EventRef) -> Result<StillFrameEvent, glib::error::BoolError> {
|
||||
pub fn parse(event: &gst::EventRef) -> Result<Self, glib::error::BoolError> {
|
||||
skip_assert_initialized!();
|
||||
unsafe {
|
||||
let mut in_still = mem::MaybeUninit::uninit();
|
||||
|
@ -333,7 +329,7 @@ impl StillFrameEvent {
|
|||
in_still.as_mut_ptr(),
|
||||
));
|
||||
if res {
|
||||
Ok(StillFrameEvent {
|
||||
Ok(Self {
|
||||
in_still: from_glib(in_still.assume_init()),
|
||||
})
|
||||
} else {
|
||||
|
|
|
@ -262,9 +262,9 @@ impl FromGlib<i32> for VideoEndianness {
|
|||
skip_assert_initialized!();
|
||||
|
||||
match value {
|
||||
1234 => VideoEndianness::LittleEndian,
|
||||
4321 => VideoEndianness::BigEndian,
|
||||
_ => VideoEndianness::Unknown,
|
||||
1234 => Self::LittleEndian,
|
||||
4321 => Self::BigEndian,
|
||||
_ => Self::Unknown,
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -274,8 +274,8 @@ impl IntoGlib for VideoEndianness {
|
|||
|
||||
fn into_glib(self) -> i32 {
|
||||
match self {
|
||||
VideoEndianness::LittleEndian => 1234,
|
||||
VideoEndianness::BigEndian => 4321,
|
||||
Self::LittleEndian => 1234,
|
||||
Self::BigEndian => 4321,
|
||||
_ => 0,
|
||||
}
|
||||
}
|
||||
|
@ -290,7 +290,7 @@ impl crate::VideoFormat {
|
|||
blue_mask: u32,
|
||||
green_mask: u32,
|
||||
alpha_mask: u32,
|
||||
) -> crate::VideoFormat {
|
||||
) -> Self {
|
||||
assert_initialized_main_thread!();
|
||||
|
||||
unsafe {
|
||||
|
@ -344,14 +344,14 @@ impl str::FromStr for crate::VideoFormat {
|
|||
}
|
||||
|
||||
impl PartialOrd for crate::VideoFormat {
|
||||
fn partial_cmp(&self, other: &crate::VideoFormat) -> Option<std::cmp::Ordering> {
|
||||
fn partial_cmp(&self, other: &Self) -> Option<std::cmp::Ordering> {
|
||||
crate::VideoFormatInfo::from_format(*self)
|
||||
.partial_cmp(&crate::VideoFormatInfo::from_format(*other))
|
||||
}
|
||||
}
|
||||
|
||||
impl Ord for crate::VideoFormat {
|
||||
fn cmp(&self, other: &crate::VideoFormat) -> std::cmp::Ordering {
|
||||
fn cmp(&self, other: &Self) -> std::cmp::Ordering {
|
||||
crate::VideoFormatInfo::from_format(*self).cmp(&crate::VideoFormatInfo::from_format(*other))
|
||||
}
|
||||
}
|
||||
|
|
|
@ -10,14 +10,14 @@ use glib::translate::{from_glib, IntoGlib};
|
|||
pub struct VideoFormatInfo(&'static ffi::GstVideoFormatInfo);
|
||||
|
||||
impl VideoFormatInfo {
|
||||
pub fn from_format(format: crate::VideoFormat) -> VideoFormatInfo {
|
||||
pub fn from_format(format: crate::VideoFormat) -> Self {
|
||||
assert_initialized_main_thread!();
|
||||
|
||||
unsafe {
|
||||
let info = ffi::gst_video_format_get_info(format.into_glib());
|
||||
assert!(!info.is_null());
|
||||
|
||||
VideoFormatInfo(&*info)
|
||||
Self(&*info)
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -302,14 +302,14 @@ impl PartialEq for VideoFormatInfo {
|
|||
impl Eq for VideoFormatInfo {}
|
||||
|
||||
impl PartialOrd for VideoFormatInfo {
|
||||
fn partial_cmp(&self, other: &VideoFormatInfo) -> Option<Ordering> {
|
||||
fn partial_cmp(&self, other: &Self) -> Option<Ordering> {
|
||||
Some(self.cmp(other))
|
||||
}
|
||||
}
|
||||
|
||||
impl Ord for VideoFormatInfo {
|
||||
// See GST_VIDEO_FORMATS_ALL for the sorting algorithm
|
||||
fn cmp(&self, other: &VideoFormatInfo) -> Ordering {
|
||||
fn cmp(&self, other: &Self) -> Ordering {
|
||||
self.n_components()
|
||||
.cmp(&other.n_components())
|
||||
.then_with(|| self.depth().cmp(&other.depth()))
|
||||
|
@ -446,7 +446,7 @@ impl glib::translate::GlibPtrDefault for VideoFormatInfo {
|
|||
|
||||
#[doc(hidden)]
|
||||
impl<'a> glib::translate::ToGlibPtr<'a, *const ffi::GstVideoFormatInfo> for VideoFormatInfo {
|
||||
type Storage = &'a VideoFormatInfo;
|
||||
type Storage = &'a Self;
|
||||
|
||||
fn to_glib_none(&'a self) -> glib::translate::Stash<'a, *const ffi::GstVideoFormatInfo, Self> {
|
||||
glib::translate::Stash(self.0, self)
|
||||
|
@ -461,7 +461,7 @@ impl<'a> glib::translate::ToGlibPtr<'a, *const ffi::GstVideoFormatInfo> for Vide
|
|||
impl glib::translate::FromGlibPtrNone<*mut ffi::GstVideoFormatInfo> for VideoFormatInfo {
|
||||
#[inline]
|
||||
unsafe fn from_glib_none(ptr: *mut ffi::GstVideoFormatInfo) -> Self {
|
||||
VideoFormatInfo(&*ptr)
|
||||
Self(&*ptr)
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -469,7 +469,7 @@ impl glib::translate::FromGlibPtrNone<*mut ffi::GstVideoFormatInfo> for VideoFor
|
|||
impl glib::translate::FromGlibPtrNone<*const ffi::GstVideoFormatInfo> for VideoFormatInfo {
|
||||
#[inline]
|
||||
unsafe fn from_glib_none(ptr: *const ffi::GstVideoFormatInfo) -> Self {
|
||||
VideoFormatInfo(&*ptr)
|
||||
Self(&*ptr)
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -173,7 +173,7 @@ impl<T> VideoFrame<T> {
|
|||
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);
|
||||
VideoFrame {
|
||||
Self {
|
||||
frame,
|
||||
buffer: Some(buffer),
|
||||
info,
|
||||
|
@ -209,7 +209,7 @@ impl VideoFrame<Readable> {
|
|||
pub fn from_buffer_readable(
|
||||
buffer: gst::Buffer,
|
||||
info: &crate::VideoInfo,
|
||||
) -> Result<VideoFrame<Readable>, gst::Buffer> {
|
||||
) -> Result<Self, gst::Buffer> {
|
||||
skip_assert_initialized!();
|
||||
|
||||
assert!(info.is_valid());
|
||||
|
@ -228,7 +228,7 @@ impl VideoFrame<Readable> {
|
|||
} else {
|
||||
let frame = frame.assume_init();
|
||||
let info = crate::VideoInfo(ptr::read(&frame.info));
|
||||
Ok(VideoFrame {
|
||||
Ok(Self {
|
||||
frame,
|
||||
buffer: Some(buffer),
|
||||
info,
|
||||
|
@ -242,7 +242,7 @@ impl VideoFrame<Readable> {
|
|||
buffer: gst::Buffer,
|
||||
id: i32,
|
||||
info: &crate::VideoInfo,
|
||||
) -> Result<VideoFrame<Readable>, gst::Buffer> {
|
||||
) -> Result<Self, gst::Buffer> {
|
||||
skip_assert_initialized!();
|
||||
|
||||
assert!(info.is_valid());
|
||||
|
@ -262,7 +262,7 @@ impl VideoFrame<Readable> {
|
|||
} else {
|
||||
let frame = frame.assume_init();
|
||||
let info = crate::VideoInfo(ptr::read(&frame.info));
|
||||
Ok(VideoFrame {
|
||||
Ok(Self {
|
||||
frame,
|
||||
buffer: Some(buffer),
|
||||
info,
|
||||
|
@ -281,7 +281,7 @@ impl VideoFrame<Writable> {
|
|||
pub fn from_buffer_writable(
|
||||
buffer: gst::Buffer,
|
||||
info: &crate::VideoInfo,
|
||||
) -> Result<VideoFrame<Writable>, gst::Buffer> {
|
||||
) -> Result<Self, gst::Buffer> {
|
||||
skip_assert_initialized!();
|
||||
|
||||
assert!(info.is_valid());
|
||||
|
@ -302,7 +302,7 @@ impl VideoFrame<Writable> {
|
|||
} else {
|
||||
let frame = frame.assume_init();
|
||||
let info = crate::VideoInfo(ptr::read(&frame.info));
|
||||
Ok(VideoFrame {
|
||||
Ok(Self {
|
||||
frame,
|
||||
buffer: Some(buffer),
|
||||
info,
|
||||
|
@ -316,7 +316,7 @@ impl VideoFrame<Writable> {
|
|||
buffer: gst::Buffer,
|
||||
id: i32,
|
||||
info: &crate::VideoInfo,
|
||||
) -> Result<VideoFrame<Writable>, gst::Buffer> {
|
||||
) -> Result<Self, gst::Buffer> {
|
||||
skip_assert_initialized!();
|
||||
|
||||
assert!(info.is_valid());
|
||||
|
@ -338,7 +338,7 @@ impl VideoFrame<Writable> {
|
|||
} else {
|
||||
let frame = frame.assume_init();
|
||||
let info = crate::VideoInfo(ptr::read(&frame.info));
|
||||
Ok(VideoFrame {
|
||||
Ok(Self {
|
||||
frame,
|
||||
buffer: Some(buffer),
|
||||
info,
|
||||
|
@ -552,7 +552,7 @@ impl<'a> VideoFrameRef<&'a gst::BufferRef> {
|
|||
let frame = ptr::read(frame);
|
||||
let info = crate::VideoInfo(ptr::read(&frame.info));
|
||||
let buffer = gst::BufferRef::from_ptr(frame.buffer);
|
||||
Borrowed::new(VideoFrameRef {
|
||||
Borrowed::new(Self {
|
||||
frame,
|
||||
buffer: Some(buffer),
|
||||
info,
|
||||
|
@ -563,7 +563,7 @@ impl<'a> VideoFrameRef<&'a gst::BufferRef> {
|
|||
pub unsafe fn from_glib_full(frame: ffi::GstVideoFrame) -> Self {
|
||||
let info = crate::VideoInfo(ptr::read(&frame.info));
|
||||
let buffer = gst::BufferRef::from_ptr(frame.buffer);
|
||||
VideoFrameRef {
|
||||
Self {
|
||||
frame,
|
||||
buffer: Some(buffer),
|
||||
info,
|
||||
|
@ -574,7 +574,7 @@ impl<'a> VideoFrameRef<&'a gst::BufferRef> {
|
|||
pub fn from_buffer_ref_readable<'b>(
|
||||
buffer: &'a gst::BufferRef,
|
||||
info: &'b crate::VideoInfo,
|
||||
) -> Result<VideoFrameRef<&'a gst::BufferRef>, glib::BoolError> {
|
||||
) -> Result<Self, glib::BoolError> {
|
||||
skip_assert_initialized!();
|
||||
|
||||
assert!(info.is_valid());
|
||||
|
@ -593,7 +593,7 @@ impl<'a> VideoFrameRef<&'a gst::BufferRef> {
|
|||
} else {
|
||||
let frame = frame.assume_init();
|
||||
let info = crate::VideoInfo(ptr::read(&frame.info));
|
||||
Ok(VideoFrameRef {
|
||||
Ok(Self {
|
||||
frame,
|
||||
buffer: Some(buffer),
|
||||
info,
|
||||
|
@ -607,7 +607,7 @@ impl<'a> VideoFrameRef<&'a gst::BufferRef> {
|
|||
buffer: &'a gst::BufferRef,
|
||||
id: i32,
|
||||
info: &'b crate::VideoInfo,
|
||||
) -> Result<VideoFrameRef<&'a gst::BufferRef>, glib::BoolError> {
|
||||
) -> Result<Self, glib::BoolError> {
|
||||
skip_assert_initialized!();
|
||||
|
||||
assert!(info.is_valid());
|
||||
|
@ -627,7 +627,7 @@ impl<'a> VideoFrameRef<&'a gst::BufferRef> {
|
|||
} else {
|
||||
let frame = frame.assume_init();
|
||||
let info = crate::VideoInfo(ptr::read(&frame.info));
|
||||
Ok(VideoFrameRef {
|
||||
Ok(Self {
|
||||
frame,
|
||||
buffer: Some(buffer),
|
||||
info,
|
||||
|
@ -649,7 +649,7 @@ impl<'a> VideoFrameRef<&'a mut gst::BufferRef> {
|
|||
let frame = ptr::read(frame);
|
||||
let info = crate::VideoInfo(ptr::read(&frame.info));
|
||||
let buffer = gst::BufferRef::from_mut_ptr(frame.buffer);
|
||||
Borrowed::new(VideoFrameRef {
|
||||
Borrowed::new(Self {
|
||||
frame,
|
||||
buffer: Some(buffer),
|
||||
info,
|
||||
|
@ -660,7 +660,7 @@ impl<'a> VideoFrameRef<&'a mut gst::BufferRef> {
|
|||
pub unsafe fn from_glib_full_mut(frame: ffi::GstVideoFrame) -> Self {
|
||||
let info = crate::VideoInfo(ptr::read(&frame.info));
|
||||
let buffer = gst::BufferRef::from_mut_ptr(frame.buffer);
|
||||
VideoFrameRef {
|
||||
Self {
|
||||
frame,
|
||||
buffer: Some(buffer),
|
||||
info,
|
||||
|
@ -671,7 +671,7 @@ impl<'a> VideoFrameRef<&'a mut gst::BufferRef> {
|
|||
pub fn from_buffer_ref_writable<'b>(
|
||||
buffer: &'a mut gst::BufferRef,
|
||||
info: &'b crate::VideoInfo,
|
||||
) -> Result<VideoFrameRef<&'a mut gst::BufferRef>, glib::BoolError> {
|
||||
) -> Result<Self, glib::BoolError> {
|
||||
skip_assert_initialized!();
|
||||
|
||||
assert!(info.is_valid());
|
||||
|
@ -692,7 +692,7 @@ impl<'a> VideoFrameRef<&'a mut gst::BufferRef> {
|
|||
} else {
|
||||
let frame = frame.assume_init();
|
||||
let info = crate::VideoInfo(ptr::read(&frame.info));
|
||||
Ok(VideoFrameRef {
|
||||
Ok(Self {
|
||||
frame,
|
||||
buffer: Some(buffer),
|
||||
info,
|
||||
|
@ -706,7 +706,7 @@ impl<'a> VideoFrameRef<&'a mut gst::BufferRef> {
|
|||
buffer: &'a mut gst::BufferRef,
|
||||
id: i32,
|
||||
info: &'b crate::VideoInfo,
|
||||
) -> Result<VideoFrameRef<&'a mut gst::BufferRef>, glib::BoolError> {
|
||||
) -> Result<Self, glib::BoolError> {
|
||||
skip_assert_initialized!();
|
||||
|
||||
assert!(info.is_valid());
|
||||
|
@ -728,7 +728,7 @@ impl<'a> VideoFrameRef<&'a mut gst::BufferRef> {
|
|||
} else {
|
||||
let frame = frame.assume_init();
|
||||
let info = crate::VideoInfo(ptr::read(&frame.info));
|
||||
Ok(VideoFrameRef {
|
||||
Ok(Self {
|
||||
frame,
|
||||
buffer: Some(buffer),
|
||||
info,
|
||||
|
@ -783,10 +783,7 @@ impl<'a> ops::Deref for VideoFrameRef<&'a mut gst::BufferRef> {
|
|||
type Target = VideoFrameRef<&'a gst::BufferRef>;
|
||||
|
||||
fn deref(&self) -> &Self::Target {
|
||||
unsafe {
|
||||
&*(self as *const VideoFrameRef<&'a mut gst::BufferRef>
|
||||
as *const VideoFrameRef<&'a gst::BufferRef>)
|
||||
}
|
||||
unsafe { &*(self as *const Self as *const Self::Target) }
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -28,10 +28,10 @@ impl IntoGlib for VideoColorRange {
|
|||
|
||||
fn into_glib(self) -> ffi::GstVideoColorRange {
|
||||
match self {
|
||||
VideoColorRange::Unknown => ffi::GST_VIDEO_COLOR_RANGE_UNKNOWN,
|
||||
VideoColorRange::Range0255 => ffi::GST_VIDEO_COLOR_RANGE_0_255,
|
||||
VideoColorRange::Range16235 => ffi::GST_VIDEO_COLOR_RANGE_16_235,
|
||||
VideoColorRange::__Unknown(value) => value,
|
||||
Self::Unknown => ffi::GST_VIDEO_COLOR_RANGE_UNKNOWN,
|
||||
Self::Range0255 => ffi::GST_VIDEO_COLOR_RANGE_0_255,
|
||||
Self::Range16235 => ffi::GST_VIDEO_COLOR_RANGE_16_235,
|
||||
Self::__Unknown(value) => value,
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -41,10 +41,10 @@ impl FromGlib<ffi::GstVideoColorRange> for VideoColorRange {
|
|||
unsafe fn from_glib(value: ffi::GstVideoColorRange) -> Self {
|
||||
skip_assert_initialized!();
|
||||
match value as i32 {
|
||||
0 => VideoColorRange::Unknown,
|
||||
1 => VideoColorRange::Range0255,
|
||||
2 => VideoColorRange::Range16235,
|
||||
value => VideoColorRange::__Unknown(value),
|
||||
0 => Self::Unknown,
|
||||
1 => Self::Range0255,
|
||||
2 => Self::Range16235,
|
||||
value => Self::__Unknown(value),
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -98,7 +98,7 @@ impl VideoColorimetry {
|
|||
primaries: primaries.into_glib(),
|
||||
};
|
||||
|
||||
VideoColorimetry(colorimetry)
|
||||
Self(colorimetry)
|
||||
}
|
||||
|
||||
pub fn range(&self) -> crate::VideoColorRange {
|
||||
|
@ -120,7 +120,7 @@ impl VideoColorimetry {
|
|||
|
||||
impl Clone for VideoColorimetry {
|
||||
fn clone(&self) -> Self {
|
||||
unsafe { VideoColorimetry(ptr::read(&self.0)) }
|
||||
unsafe { Self(ptr::read(&self.0)) }
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -228,14 +228,12 @@ impl From<crate::VideoMultiviewFramePacking> for crate::VideoMultiviewMode {
|
|||
impl std::convert::TryFrom<crate::VideoMultiviewMode> for crate::VideoMultiviewFramePacking {
|
||||
type Error = glib::BoolError;
|
||||
|
||||
fn try_from(
|
||||
v: crate::VideoMultiviewMode,
|
||||
) -> Result<crate::VideoMultiviewFramePacking, glib::BoolError> {
|
||||
fn try_from(v: crate::VideoMultiviewMode) -> Result<Self, glib::BoolError> {
|
||||
skip_assert_initialized!();
|
||||
|
||||
let v2 = unsafe { from_glib(v.into_glib()) };
|
||||
|
||||
if let crate::VideoMultiviewFramePacking::__Unknown(_) = v2 {
|
||||
if let Self::__Unknown(_) = v2 {
|
||||
Err(glib::bool_error!("Invalid frame packing mode"))
|
||||
} else {
|
||||
Ok(v2)
|
||||
|
@ -607,7 +605,7 @@ impl VideoInfo {
|
|||
info.as_mut_ptr(),
|
||||
caps.as_ptr(),
|
||||
)) {
|
||||
Ok(VideoInfo(info.assume_init()))
|
||||
Ok(Self(info.assume_init()))
|
||||
} else {
|
||||
Err(glib::bool_error!("Failed to create VideoInfo from caps"))
|
||||
}
|
||||
|
@ -844,7 +842,7 @@ impl VideoInfo {
|
|||
|
||||
impl Clone for VideoInfo {
|
||||
fn clone(&self) -> Self {
|
||||
unsafe { VideoInfo(ptr::read(&self.0)) }
|
||||
unsafe { Self(ptr::read(&self.0)) }
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -928,7 +926,7 @@ impl glib::translate::GlibPtrDefault for VideoInfo {
|
|||
|
||||
#[doc(hidden)]
|
||||
impl<'a> glib::translate::ToGlibPtr<'a, *const ffi::GstVideoInfo> for VideoInfo {
|
||||
type Storage = &'a VideoInfo;
|
||||
type Storage = &'a Self;
|
||||
|
||||
fn to_glib_none(&'a self) -> glib::translate::Stash<'a, *const ffi::GstVideoInfo, Self> {
|
||||
glib::translate::Stash(&self.0, self)
|
||||
|
@ -943,7 +941,7 @@ impl<'a> glib::translate::ToGlibPtr<'a, *const ffi::GstVideoInfo> for VideoInfo
|
|||
impl glib::translate::FromGlibPtrNone<*mut ffi::GstVideoInfo> for VideoInfo {
|
||||
#[inline]
|
||||
unsafe fn from_glib_none(ptr: *mut ffi::GstVideoInfo) -> Self {
|
||||
VideoInfo(ptr::read(ptr))
|
||||
Self(ptr::read(ptr))
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -13,7 +13,7 @@ pub struct VideoRectangle {
|
|||
impl VideoRectangle {
|
||||
pub fn new(x: i32, y: i32, w: i32, h: i32) -> Self {
|
||||
skip_assert_initialized!();
|
||||
VideoRectangle { x, y, w, h }
|
||||
Self { x, y, w, h }
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -20,12 +20,12 @@ pub struct VideoTimeCode(ffi::GstVideoTimeCode);
|
|||
pub struct ValidVideoTimeCode(ffi::GstVideoTimeCode);
|
||||
|
||||
impl VideoTimeCode {
|
||||
pub fn new_empty() -> VideoTimeCode {
|
||||
pub fn new_empty() -> Self {
|
||||
assert_initialized_main_thread!();
|
||||
unsafe {
|
||||
let mut v = mem::MaybeUninit::zeroed();
|
||||
ffi::gst_video_time_code_clear(v.as_mut_ptr());
|
||||
VideoTimeCode(v.assume_init())
|
||||
Self(v.assume_init())
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -56,7 +56,7 @@ impl VideoTimeCode {
|
|||
field_count,
|
||||
);
|
||||
|
||||
VideoTimeCode(v.assume_init())
|
||||
Self(v.assume_init())
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -67,7 +67,7 @@ impl VideoTimeCode {
|
|||
dt: &glib::DateTime,
|
||||
flags: VideoTimeCodeFlags,
|
||||
field_count: u32,
|
||||
) -> Result<VideoTimeCode, glib::error::BoolError> {
|
||||
) -> Result<Self, glib::error::BoolError> {
|
||||
assert_initialized_main_thread!();
|
||||
assert!(*fps.denom() > 0);
|
||||
unsafe {
|
||||
|
@ -84,7 +84,7 @@ impl VideoTimeCode {
|
|||
if res == glib::ffi::GFALSE {
|
||||
Err(glib::bool_error!("Failed to init video time code"))
|
||||
} else {
|
||||
Ok(VideoTimeCode(v.assume_init()))
|
||||
Ok(Self(v.assume_init()))
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -129,14 +129,14 @@ impl VideoTimeCode {
|
|||
impl TryFrom<VideoTimeCode> for ValidVideoTimeCode {
|
||||
type Error = VideoTimeCode;
|
||||
|
||||
fn try_from(v: VideoTimeCode) -> Result<ValidVideoTimeCode, VideoTimeCode> {
|
||||
fn try_from(v: VideoTimeCode) -> Result<Self, VideoTimeCode> {
|
||||
skip_assert_initialized!();
|
||||
if v.is_valid() {
|
||||
// Use ManuallyDrop here to prevent the Drop impl of VideoTimeCode
|
||||
// from running as we don't move v.0 out here but copy it.
|
||||
// GstVideoTimeCode implements Copy.
|
||||
let v = mem::ManuallyDrop::new(v);
|
||||
Ok(ValidVideoTimeCode(v.0))
|
||||
Ok(Self(v.0))
|
||||
} else {
|
||||
Err(v)
|
||||
}
|
||||
|
@ -195,7 +195,7 @@ impl ValidVideoTimeCode {
|
|||
pub fn add_interval(
|
||||
&self,
|
||||
tc_inter: &VideoTimeCodeInterval,
|
||||
) -> Result<ValidVideoTimeCode, glib::error::BoolError> {
|
||||
) -> Result<Self, glib::error::BoolError> {
|
||||
unsafe {
|
||||
match from_glib_full(ffi::gst_video_time_code_add_interval(
|
||||
self.to_glib_none().0,
|
||||
|
@ -207,7 +207,7 @@ impl ValidVideoTimeCode {
|
|||
}
|
||||
}
|
||||
|
||||
fn compare(&self, tc2: &ValidVideoTimeCode) -> i32 {
|
||||
fn compare(&self, tc2: &Self) -> i32 {
|
||||
unsafe { ffi::gst_video_time_code_compare(self.to_glib_none().0, tc2.to_glib_none().0) }
|
||||
}
|
||||
|
||||
|
@ -520,13 +520,13 @@ impl Ord for ValidVideoTimeCode {
|
|||
}
|
||||
|
||||
impl From<ValidVideoTimeCode> for VideoTimeCode {
|
||||
fn from(v: ValidVideoTimeCode) -> VideoTimeCode {
|
||||
fn from(v: ValidVideoTimeCode) -> Self {
|
||||
skip_assert_initialized!();
|
||||
// Use ManuallyDrop here to prevent the Drop impl of VideoTimeCode
|
||||
// from running as we don't move v.0 out here but copy it.
|
||||
// GstVideoTimeCode implements Copy.
|
||||
let v = mem::ManuallyDrop::new(v);
|
||||
VideoTimeCode(v.0)
|
||||
Self(v.0)
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -17,7 +17,7 @@ impl VideoTimeCodeInterval {
|
|||
unsafe {
|
||||
let mut v = mem::MaybeUninit::zeroed();
|
||||
ffi::gst_video_time_code_interval_init(v.as_mut_ptr(), hours, minutes, seconds, frames);
|
||||
VideoTimeCodeInterval(v.assume_init())
|
||||
Self(v.assume_init())
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -160,7 +160,7 @@ impl FromGlibPtrNone<*mut ffi::GstVideoTimeCodeInterval> for VideoTimeCodeInterv
|
|||
#[inline]
|
||||
unsafe fn from_glib_none(ptr: *mut ffi::GstVideoTimeCodeInterval) -> Self {
|
||||
assert!(!ptr.is_null());
|
||||
VideoTimeCodeInterval(ptr::read(ptr))
|
||||
Self(ptr::read(ptr))
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -169,7 +169,7 @@ impl FromGlibPtrNone<*const ffi::GstVideoTimeCodeInterval> for VideoTimeCodeInte
|
|||
#[inline]
|
||||
unsafe fn from_glib_none(ptr: *const ffi::GstVideoTimeCodeInterval) -> Self {
|
||||
assert!(!ptr.is_null());
|
||||
VideoTimeCodeInterval(ptr::read(ptr))
|
||||
Self(ptr::read(ptr))
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -178,7 +178,7 @@ impl FromGlibPtrFull<*mut ffi::GstVideoTimeCodeInterval> for VideoTimeCodeInterv
|
|||
#[inline]
|
||||
unsafe fn from_glib_full(ptr: *mut ffi::GstVideoTimeCodeInterval) -> Self {
|
||||
assert!(!ptr.is_null());
|
||||
let res = VideoTimeCodeInterval(ptr::read(ptr));
|
||||
let res = Self(ptr::read(ptr));
|
||||
ffi::gst_video_time_code_interval_free(ptr);
|
||||
|
||||
res
|
||||
|
@ -190,7 +190,7 @@ impl FromGlibPtrBorrow<*mut ffi::GstVideoTimeCodeInterval> for VideoTimeCodeInte
|
|||
#[inline]
|
||||
unsafe fn from_glib_borrow(ptr: *mut ffi::GstVideoTimeCodeInterval) -> Borrowed<Self> {
|
||||
assert!(!ptr.is_null());
|
||||
Borrowed::new(VideoTimeCodeInterval(ptr::read(ptr)))
|
||||
Borrowed::new(Self(ptr::read(ptr)))
|
||||
}
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in a new issue