Commit 694bcaa6 authored by Sebastian Dröge's avatar Sebastian Dröge 🍵

Fix all clippy warnings

Or silence the ones we don't care about.
parent fc79b4c4
......@@ -74,7 +74,7 @@ fn get_request_pad(element: &gst::Element, pad_name: &'static str) -> Result<gst
fn connect_rtpbin_srcpad(src_pad: &gst::Pad, sink: &gst::Element) -> Result<(), Error> {
let name = src_pad.get_name();
let split_name = name.split("_");
let split_name = name.split('_');
let split_name = split_name.collect::<Vec<&str>>();
let pt = split_name[5].parse::<u32>()?;
......@@ -248,7 +248,7 @@ fn example_main() -> Result<(), Error> {
return Err(ErrorMessage {
src: msg.get_src()
.map(|s| s.get_path_string())
.unwrap_or(String::from("None")),
.unwrap_or_else(|| String::from("None")),
error: err.get_error().description().into(),
debug: err.get_debug(),
cause: err.get_error(),
......
......@@ -186,7 +186,7 @@ fn example_main() -> Result<(), Error> {
return Err(ErrorMessage {
src: msg.get_src()
.map(|s| s.get_path_string())
.unwrap_or(String::from("None")),
.unwrap_or_else(|| String::from("None")),
error: err.get_error().description().into(),
debug: err.get_debug(),
cause: err.get_error(),
......
......@@ -42,7 +42,7 @@ fn main_loop() -> Result<(), Error> {
let factory = RTSPMediaFactory::new();
let mounts = server.get_mount_points().ok_or(NoMountPoints)?;
let auth = RTSPAuth::new();
let mut token = RTSPToken::new(&[(*RTSP_TOKEN_MEDIA_FACTORY_ROLE, &"user")]);
let token = RTSPToken::new(&[(*RTSP_TOKEN_MEDIA_FACTORY_ROLE, &"user")]);
let basic = RTSPAuth::make_basic("user", "password");
let cert = gio::TlsCertificate::new_from_pem(
"-----BEGIN CERTIFICATE-----\
......@@ -86,7 +86,7 @@ fn main_loop() -> Result<(), Error> {
}
auth.set_tls_certificate(&cert);
auth.add_basic(basic.as_str(), &mut token);
auth.add_basic(basic.as_str(), &token);
server.set_auth(&auth);
factory.set_launch(args[1].as_str());
factory.set_transport_mode(RTSPTransportMode::RECORD);
......
......@@ -53,7 +53,7 @@ fn example_main() -> Result<(), Error> {
let tagsetter = pipeline
.get_by_interface(gst::TagSetter::static_type())
.ok_or(failure::err_msg("No TagSetter found"))?;
.ok_or_else(|| failure::err_msg("No TagSetter found"))?;
let tagsetter = tagsetter
.dynamic_cast::<gst::TagSetter>()
.map_err(|_| failure::err_msg("No TagSetter found"))?;
......
......@@ -15,6 +15,7 @@ use std::cell::RefCell;
use std::ptr;
use AppSink;
#[cfg_attr(feature = "cargo-clippy", allow(type_complexity))]
pub struct AppSinkCallbacks {
eos: Option<RefCell<Box<FnMut(&AppSink) + Send + 'static>>>,
new_preroll: Option<RefCell<Box<FnMut(&AppSink) -> gst::FlowReturn + Send + 'static>>>,
......@@ -36,6 +37,7 @@ impl AppSinkCallbacks {
}
}
#[cfg_attr(feature = "cargo-clippy", allow(type_complexity))]
pub struct AppSinkCallbacksBuilder {
eos: Option<RefCell<Box<FnMut(&AppSink) + Send + 'static>>>,
new_preroll: Option<RefCell<Box<FnMut(&AppSink) -> gst::FlowReturn + Send + 'static>>>,
......@@ -105,10 +107,9 @@ impl AppSinkCallbacksBuilder {
unsafe extern "C" fn trampoline_eos(appsink: *mut ffi::GstAppSink, callbacks: gpointer) {
let callbacks = &*(callbacks as *const AppSinkCallbacks);
callbacks
.eos
.as_ref()
.map(|f| (&mut *f.borrow_mut())(&from_glib_borrow(appsink)));
if let Some(ref eos) = callbacks.eos {
(&mut *eos.borrow_mut())(&from_glib_borrow(appsink))
}
}
unsafe extern "C" fn trampoline_new_preroll(
......@@ -117,12 +118,13 @@ unsafe extern "C" fn trampoline_new_preroll(
) -> gst_ffi::GstFlowReturn {
let callbacks = &*(callbacks as *const AppSinkCallbacks);
callbacks
.new_preroll
.as_ref()
.map(|f| (&mut *f.borrow_mut())(&from_glib_borrow(appsink)))
.unwrap_or(gst::FlowReturn::Error)
.to_glib()
let ret = if let Some(ref new_preroll) = callbacks.new_preroll {
(&mut *new_preroll.borrow_mut())(&from_glib_borrow(appsink))
} else {
gst::FlowReturn::Error
};
ret.to_glib()
}
unsafe extern "C" fn trampoline_new_sample(
......@@ -131,12 +133,13 @@ unsafe extern "C" fn trampoline_new_sample(
) -> gst_ffi::GstFlowReturn {
let callbacks = &*(callbacks as *const AppSinkCallbacks);
callbacks
.new_sample
.as_ref()
.map(|f| (&mut *f.borrow_mut())(&from_glib_borrow(appsink)))
.unwrap_or(gst::FlowReturn::Error)
.to_glib()
let ret = if let Some(ref new_sample) = callbacks.new_sample {
(&mut *new_sample.borrow_mut())(&from_glib_borrow(appsink))
} else {
gst::FlowReturn::Error
};
ret.to_glib()
}
unsafe extern "C" fn destroy_callbacks(ptr: gpointer) {
......
......@@ -15,6 +15,7 @@ use std::mem;
use std::ptr;
use AppSrc;
#[cfg_attr(feature = "cargo-clippy", allow(type_complexity))]
pub struct AppSrcCallbacks {
need_data: Option<RefCell<Box<FnMut(&AppSrc, u32) + Send + 'static>>>,
enough_data: Option<Box<Fn(&AppSrc) + Send + Sync + 'static>>,
......@@ -37,6 +38,7 @@ impl AppSrcCallbacks {
}
}
#[cfg_attr(feature = "cargo-clippy", allow(type_complexity))]
pub struct AppSrcCallbacksBuilder {
need_data: Option<RefCell<Box<FnMut(&AppSrc, u32) + Send + 'static>>>,
enough_data: Option<Box<Fn(&AppSrc) + Send + Sync + 'static>>,
......@@ -111,19 +113,17 @@ unsafe extern "C" fn trampoline_need_data(
) {
let callbacks = &*(callbacks as *const AppSrcCallbacks);
callbacks
.need_data
.as_ref()
.map(|f| (&mut *f.borrow_mut())(&from_glib_borrow(appsrc), length));
if let Some(ref need_data) = callbacks.need_data {
(&mut *need_data.borrow_mut())(&from_glib_borrow(appsrc), length);
}
}
unsafe extern "C" fn trampoline_enough_data(appsrc: *mut ffi::GstAppSrc, callbacks: gpointer) {
let callbacks = &*(callbacks as *const AppSrcCallbacks);
callbacks
.enough_data
.as_ref()
.map(|f| f(&from_glib_borrow(appsrc)));
if let Some(ref enough_data) = callbacks.enough_data {
(*enough_data)(&from_glib_borrow(appsrc));
}
}
unsafe extern "C" fn trampoline_seek_data(
......@@ -133,12 +133,13 @@ unsafe extern "C" fn trampoline_seek_data(
) -> gboolean {
let callbacks = &*(callbacks as *const AppSrcCallbacks);
callbacks
.seek_data
.as_ref()
.map(|f| f(&from_glib_borrow(appsrc), offset))
.unwrap_or(false)
.to_glib()
let ret = if let Some(ref seek_data) = callbacks.seek_data {
(*seek_data)(&from_glib_borrow(appsrc), offset)
} else {
false
};
ret.to_glib()
}
unsafe extern "C" fn destroy_callbacks(ptr: gpointer) {
......
......@@ -19,7 +19,7 @@ use gst::MiniObject;
use array_init;
impl AudioChannelPosition {
pub fn to_mask(&self) -> u64 {
pub fn to_mask(self) -> u64 {
unsafe {
let val = mem::transmute::<ffi::GstAudioChannelPosition, u32>(self.to_glib());
1 << val
......
......@@ -39,8 +39,8 @@ impl ::AudioFormat {
unsafe { from_glib(ffi::gst_audio_format_from_string(s.to_glib_none().0)) }
}
pub fn to_string<'a>(&self) -> &'a str {
if *self == ::AudioFormat::Unknown {
pub fn to_string<'a>(self) -> &'a str {
if self == ::AudioFormat::Unknown {
return "UNKNOWN";
}
......@@ -69,7 +69,7 @@ impl str::FromStr for ::AudioFormat {
impl fmt::Display for ::AudioFormat {
fn fmt(&self, f: &mut fmt::Formatter) -> Result<(), fmt::Error> {
f.write_str(self.to_string())
f.write_str(self.to_string().as_str())
}
}
......
......@@ -131,13 +131,14 @@ impl<'a> AudioInfoBuilder<'a> {
}
impl AudioInfo {
#[cfg_attr(feature = "cargo-clippy", allow(new_ret_no_self))]
pub fn new<'a>(format: ::AudioFormat, rate: u32, channels: u32) -> AudioInfoBuilder<'a> {
assert_initialized_main_thread!();
AudioInfoBuilder {
format: format,
rate: rate,
channels: channels,
format,
rate,
channels,
positions: None,
flags: None,
layout: None,
......
......@@ -20,7 +20,7 @@ glib_wrapper! {
match fn {
ref => |ptr| {
gobject_ffi::g_boxed_copy(ffi::gst_flow_combiner_get_type(), ptr as *mut _) as *mut ffi::GstFlowCombiner
gobject_ffi::g_boxed_copy(ffi::gst_flow_combiner_get_type(), ptr as *mut _)
},
unref => |ptr| {
gobject_ffi::g_boxed_free(ffi::gst_flow_combiner_get_type(), ptr as *mut _)
......
......@@ -29,6 +29,7 @@ pub use glib::{Cast, Continue, Error, IsA, StaticType, ToValue, Type, TypedValue
#[cfg_attr(feature = "cargo-clippy", allow(transmute_ptr_to_ref))]
#[cfg_attr(feature = "cargo-clippy", allow(too_many_arguments))]
#[cfg_attr(feature = "cargo-clippy", allow(match_same_arms))]
#[cfg_attr(feature = "cargo-clippy", allow(type_complexity))]
mod auto;
pub use auto::functions::*;
pub use auto::*;
......
......@@ -12,6 +12,7 @@ use glib_ffi;
pub struct MutexGuard<'a>(&'a glib_ffi::GMutex);
impl<'a> MutexGuard<'a> {
#[cfg_attr(feature = "cargo-clippy", allow(trivially_copy_pass_by_ref))]
pub fn lock(mutex: &'a glib_ffi::GMutex) -> Self {
unsafe {
glib_ffi::g_mutex_lock(mut_override(mutex));
......
......@@ -71,6 +71,7 @@ unsafe extern "C" fn notify_timeout_trampoline<P>(
) where
P: IsA<Discoverer>,
{
#[cfg_attr(feature = "cargo-clippy", allow(transmute_ptr_to_ref))]
let f: &&(Fn(&P) + Send + Sync + 'static) = transmute(f);
f(&Discoverer::from_glib_borrow(this).downcast_unchecked())
}
......@@ -20,8 +20,8 @@ impl Iterator for Iter {
fn next(&mut self) -> Option<DiscovererStreamInfo> {
let current = self.stream_info.take();
self.stream_info = match &current {
&Some(ref c) => {
self.stream_info = match current {
Some(ref c) => {
// Decide on the direction
if self.direction_forward {
c.get_next()
......@@ -29,7 +29,7 @@ impl Iterator for Iter {
c.get_previous()
}
}
&None => None,
None => None,
};
current
}
......
......@@ -43,6 +43,7 @@ pub use glib::{Cast, Continue, Error, IsA, StaticType, ToValue, Type, TypedValue
#[cfg_attr(feature = "cargo-clippy", allow(transmute_ptr_to_ref))]
#[cfg_attr(feature = "cargo-clippy", allow(too_many_arguments))]
#[cfg_attr(feature = "cargo-clippy", allow(match_same_arms))]
#[cfg_attr(feature = "cargo-clippy", allow(type_complexity))]
mod auto;
pub use auto::*;
......
......@@ -105,6 +105,7 @@ unsafe extern "C" fn duration_changed_trampoline(
object: u64,
f: glib_ffi::gpointer,
) {
#[cfg_attr(feature = "cargo-clippy", allow(transmute_ptr_to_ref))]
let f: &&(Fn(&Player, gst::ClockTime) + Send + 'static) = transmute(f);
f(&from_glib_borrow(this), gst::ClockTime(Some(object)))
}
......@@ -114,6 +115,7 @@ unsafe extern "C" fn position_updated_trampoline(
object: u64,
f: glib_ffi::gpointer,
) {
#[cfg_attr(feature = "cargo-clippy", allow(transmute_ptr_to_ref))]
let f: &&(Fn(&Player, gst::ClockTime) + Send + Sync + 'static) = transmute(f);
f(&from_glib_borrow(this), gst::ClockTime(Some(object)))
}
......@@ -123,6 +125,7 @@ unsafe extern "C" fn seek_done_trampoline(
object: u64,
f: glib_ffi::gpointer,
) {
#[cfg_attr(feature = "cargo-clippy", allow(transmute_ptr_to_ref))]
let f: &&(Fn(&Player, gst::ClockTime) + Send + 'static) = transmute(f);
f(&from_glib_borrow(this), gst::ClockTime(Some(object)))
}
......@@ -45,6 +45,7 @@ pub use glib::{Cast, Continue, Error, IsA, StaticType, ToValue, Type, TypedValue
#[cfg_attr(feature = "cargo-clippy", allow(transmute_ptr_to_ref))]
#[cfg_attr(feature = "cargo-clippy", allow(too_many_arguments))]
#[cfg_attr(feature = "cargo-clippy", allow(match_same_arms))]
#[cfg_attr(feature = "cargo-clippy", allow(type_complexity))]
mod auto;
pub use auto::*;
......
......@@ -27,10 +27,11 @@ impl GstRcRTSPTokenExt<RTSPTokenRef> for GstRc<RTSPTokenRef> {
}
fn new(values: &[(&str, &ToSendValue)]) -> Self {
let token = RTSPToken::new_empty();
let mut token = RTSPToken::new_empty();
{
let structure = token.writable_structure().unwrap();
let token = token.get_mut().unwrap();
let structure = token.get_mut_structure().unwrap();
for &(f, v) in values {
structure.set_value(f, v.to_send_value());
......@@ -64,7 +65,7 @@ impl RTSPTokenRef {
}
}
pub fn writable_structure(&self) -> Option<&mut gst::StructureRef> {
pub fn get_mut_structure(&mut self) -> Option<&mut gst::StructureRef> {
unsafe {
let structure = ffi::gst_rtsp_token_writable_structure(self.as_mut_ptr());
if structure.is_null() {
......
......@@ -35,7 +35,7 @@ pub use glib::{Cast, Continue, Error, IsA, StaticType, ToValue, Type, TypedValue
#[cfg_attr(feature = "cargo-clippy", allow(transmute_ptr_to_ref))]
#[cfg_attr(feature = "cargo-clippy", allow(too_many_arguments))]
#[cfg_attr(feature = "cargo-clippy", allow(match_same_arms))]
#[cfg_attr(feature = "cargo-clippy", allow(non_snake_case))]
#[allow(non_snake_case)]
mod auto;
pub use auto::*;
......
......@@ -14,9 +14,9 @@ pub struct MIKEYMapSRTP(ffi::GstMIKEYMapSRTP);
impl MIKEYMapSRTP {
pub fn new(policy: u8, ssrc: u32, roc: u32) -> MIKEYMapSRTP {
MIKEYMapSRTP(ffi::GstMIKEYMapSRTP {
policy: policy,
ssrc: ssrc,
roc: roc,
policy,
ssrc,
roc,
})
}
......
......@@ -22,6 +22,10 @@ impl MIKEYPayloadSPParam {
self.0.len
}
pub fn is_empty(&self) -> bool {
self.0.len == 0
}
pub fn val(&self) -> &[u8] {
unsafe { slice::from_raw_parts(self.0.val as *const u8, self.0.len as usize) }
}
......
......@@ -508,7 +508,6 @@ impl SDPMedia {
media.to_glib_none_mut().0,
)
};
mem::forget(media);
match result {
ffi::GST_SDP_OK => Ok(()),
_ => Err(()),
......
......@@ -709,12 +709,12 @@ impl SDPMessage {
unsafe { ffi::gst_sdp_message_zones_len(self.to_glib_none().0) }
}
pub fn as_uri(scheme: &str, msg: &SDPMessage) -> Option<String> {
pub fn as_uri(&self, scheme: &str) -> Option<String> {
assert_initialized_main_thread!();
unsafe {
from_glib_full(ffi::gst_sdp_message_as_uri(
scheme.to_glib_none().0,
msg.to_glib_none().0,
self.to_glib_none().0,
))
}
}
......@@ -753,4 +753,10 @@ impl SDPMessage {
}
}
impl Default for SDPMessage {
fn default() -> Self {
Self::new()
}
}
unsafe impl Send for SDPMessage {}
......@@ -43,6 +43,7 @@ impl SDPTime {
}
pub fn repeat(&self) -> Vec<&str> {
#[cfg_attr(feature = "cargo-clippy", allow(cast_ptr_alignment))]
unsafe {
let arr = (*self.0.repeat).data as *const *const c_char;
let len = (*self.0.repeat).len as usize;
......
......@@ -54,6 +54,7 @@ pub fn convert_sample_async<F>(
) where
F: FnOnce(Result<gst::Sample, glib::Error>) + Send + 'static,
{
#[cfg_attr(feature = "cargo-clippy", allow(transmute_ptr_to_ref))]
let callback: &mut Option<Box<F>> = mem::transmute(user_data);
let callback = callback.take().unwrap();
......
......@@ -105,35 +105,35 @@ impl<'a> DownstreamForceKeyUnitEventBuilder<'a> {
pub fn timestamp(self, timestamp: gst::ClockTime) -> Self {
Self {
timestamp: timestamp,
timestamp,
..self
}
}
pub fn stream_time(self, stream_time: gst::ClockTime) -> Self {
Self {
stream_time: stream_time,
stream_time,
..self
}
}
pub fn running_time(self, running_time: gst::ClockTime) -> Self {
Self {
running_time: running_time,
running_time,
..self
}
}
pub fn all_headers(self, all_headers: bool) -> Self {
Self {
all_headers: all_headers,
all_headers,
..self
}
}
pub fn count(self, count: u32) -> Self {
Self {
count: count,
count,
..self
}
}
......@@ -182,7 +182,7 @@ pub fn parse_downstream_force_key_unit_event(
stream_time: from_glib(stream_time),
running_time: from_glib(running_time),
all_headers: from_glib(all_headers),
count: count,
count,
})
} else {
None
......@@ -218,21 +218,21 @@ impl<'a> UpstreamForceKeyUnitEventBuilder<'a> {
pub fn running_time(self, running_time: gst::ClockTime) -> Self {
Self {
running_time: running_time,
running_time,
..self
}
}
pub fn all_headers(self, all_headers: bool) -> Self {
Self {
all_headers: all_headers,
all_headers,
..self
}
}
pub fn count(self, count: u32) -> Self {
Self {
count: count,
count,
..self
}
}
......@@ -271,7 +271,7 @@ pub fn parse_upstream_force_key_unit_event(
Some(UpstreamForceKeyUnitEvent {
running_time: from_glib(running_time),
all_headers: from_glib(all_headers),
count: count,
count,
})
} else {
None
......@@ -311,7 +311,7 @@ impl<'a> StillFrameEventBuilder<'a> {
seqnum: None,
running_time_offset: None,
other_fields: Vec::new(),
in_still: in_still,
in_still,
}
}
......
......@@ -82,8 +82,8 @@ impl ::VideoFormat {
}
}
pub fn to_string<'a>(&self) -> &'a str {
if *self == ::VideoFormat::Unknown {
pub fn to_string<'a>(self) -> &'a str {
if self == ::VideoFormat::Unknown {
return "UNKNOWN";
}
......@@ -112,6 +112,6 @@ impl str::FromStr for ::VideoFormat {
impl fmt::Display for ::VideoFormat {
fn fmt(&self, f: &mut fmt::Formatter) -> Result<(), fmt::Error> {
f.write_str(self.to_string())
f.write_str(self.to_string().as_str())
}
}
......@@ -179,7 +179,7 @@ impl VideoFrame<Readable> {
&mut frame,
info.to_glib_none().0 as *mut _,
buffer.to_glib_none().0,
mem::transmute(ffi::GST_VIDEO_FRAME_MAP_FLAG_NO_REF | gst_ffi::GST_MAP_READ),
ffi::GST_VIDEO_FRAME_MAP_FLAG_NO_REF | gst_ffi::GST_MAP_READ,
));
if !res {
......@@ -205,7 +205,7 @@ impl VideoFrame<Readable> {
info.to_glib_none().0 as *mut _,
buffer.to_glib_none().0,
id,
mem::transmute(ffi::GST_VIDEO_FRAME_MAP_FLAG_NO_REF | gst_ffi::GST_MAP_READ),
ffi::GST_VIDEO_FRAME_MAP_FLAG_NO_REF | gst_ffi::GST_MAP_READ,
));
if !res {
......@@ -237,10 +237,8 @@ impl VideoFrame<Writable> {
&mut frame,
info.to_glib_none().0 as *mut _,
buffer.to_glib_none().0,
mem::transmute(
ffi::GST_VIDEO_FRAME_MAP_FLAG_NO_REF | gst_ffi::GST_MAP_READ
| gst_ffi::GST_MAP_WRITE,
),
ffi::GST_VIDEO_FRAME_MAP_FLAG_NO_REF | gst_ffi::GST_MAP_READ
| gst_ffi::GST_MAP_WRITE,
));
if !res {
......@@ -266,10 +264,8 @@ impl VideoFrame<Writable> {
info.to_glib_none().0 as *mut _,
buffer.to_glib_none().0,
id,
mem::transmute(
ffi::GST_VIDEO_FRAME_MAP_FLAG_NO_REF | gst_ffi::GST_MAP_READ
| gst_ffi::GST_MAP_WRITE,
),
ffi::GST_VIDEO_FRAME_MAP_FLAG_NO_REF | gst_ffi::GST_MAP_READ
| gst_ffi::GST_MAP_WRITE,
));
if !res {
......@@ -337,7 +333,7 @@ impl<'a> VideoFrameRef<&'a gst::BufferRef> {
&mut frame,
info.to_glib_none().0 as *mut _,
buffer.as_mut_ptr(),
mem::transmute(ffi::GST_VIDEO_FRAME_MAP_FLAG_NO_REF | gst_ffi::GST_MAP_READ),
ffi::GST_VIDEO_FRAME_MAP_FLAG_NO_REF | gst_ffi::GST_MAP_READ,
));
if !res {
......@@ -363,7 +359,7 @@ impl<'a> VideoFrameRef<&'a gst::BufferRef> {
info.to_glib_none().0 as *mut _,
buffer.as_mut_ptr(),
id,
mem::transmute(ffi::GST_VIDEO_FRAME_MAP_FLAG_NO_REF | gst_ffi::GST_MAP_READ),
ffi::GST_VIDEO_FRAME_MAP_FLAG_NO_REF | gst_ffi::GST_MAP_READ,
));
if !res {
......@@ -515,10 +511,8 @@ impl<'a> VideoFrameRef<&'a mut gst::BufferRef> {
&mut frame,
info.to_glib_none().0 as *mut _,
buffer.as_mut_ptr(),
mem::transmute(
ffi::GST_VIDEO_FRAME_MAP_FLAG_NO_REF | gst_ffi::GST_MAP_READ
| gst_ffi::GST_MAP_WRITE,
),
ffi::GST_VIDEO_FRAME_MAP_FLAG_NO_REF | gst_ffi::GST_MAP_READ
| gst_ffi::GST_MAP_WRITE,
));
if !res {
......@@ -544,10 +538,8 @@ impl<'a> VideoFrameRef<&'a mut gst::BufferRef> {
info.to_glib_none().0 as *mut _,
buffer.as_mut_ptr(),
id,
mem::transmute(
ffi::GST_VIDEO_FRAME_MAP_FLAG_NO_REF | gst_ffi::GST_MAP_READ
| gst_ffi::GST_MAP_WRITE,
),
ffi::GST_VIDEO_FRAME_MAP_FLAG_NO_REF | gst_ffi::GST_MAP_READ
| gst_ffi::GST_MAP_WRITE,
));
if !res {
......@@ -598,8 +590,7 @@ impl<'a> ops::Deref for VideoFrameRef<&'a mut gst::BufferRef> {
type Target = VideoFrameRef<&'a gst::BufferRef>;
fn deref(&self) -> &Self::Target {
use std::mem;
unsafe { mem::transmute(self) }
unsafe { &*(self as *const VideoFrameRef<&'a mut gst::BufferRef> as *const VideoFrameRef<&'a gst::BufferRef>) }
}
}
......
......@@ -251,7 +251,7 @@ impl<'a> VideoInfoBuilder<'a> {
self.height,
);
if info.finfo.is_null() || info.width <= 0 || info.width <= 0 {
if info.finfo.is_null() || info.width <= 0 || info.height <= 0 {
return None;
}
......@@ -423,6 +423,7 @@ impl<'a> VideoInfoBuilder<'a> {
}
impl VideoInfo {
#[cfg_attr(feature = "cargo-clippy", allow(new_ret_no_self))]
pub fn new<'a>(format: ::VideoFormat, width: u32, height: u32) -> VideoInfoBuilder<'a> {
assert_initialized_main_thread!();
......@@ -449,9 +450,9 @@ impl VideoInfo {
#[cfg(any(feature = "v1_12", feature = "dox"))]
{
VideoInfoBuilder {
format: format,
width: width,
height: height,
format,
width,
height,
interlace_mode: None,
flags: None,
size: None,
......@@ -736,7 +737,7 @@ impl glib::translate::FromGlibPtrFull<*mut ffi::GstVideoInfo> for VideoInfo {
#[cfg(any(feature = "v1_12", feature = "dox"))]
impl ::VideoFieldOrder {
pub fn to_string(&self) -> String {
pub fn to_string(self) -> String {
unsafe { from_glib_full(ffi::gst_video_field_order_to_string(self.to_glib())) }
}
......@@ -765,7 +766,7 @@ impl fmt::Display for ::VideoFieldOrder {
}
impl ::VideoInterlaceMode {
pub fn to_string(&self) -> String {
pub fn to_string(self) -> String {
unsafe { from_glib_full(ffi::gst_video_interlace_mode_to_string(self.to_glib())) }
}
......
......@@ -127,7 +127,7 @@ impl GstRc<BufferRef> {
if res {
Ok(MappedBuffer {
buffer: Some(self),
map_info: map_info,