forked from mirrors/gstreamer-rs
Silence/fix various clippy warnings
This commit is contained in:
parent
8c39da4e5b
commit
86a31b4139
23 changed files with 117 additions and 99 deletions
|
@ -33,7 +33,7 @@
|
||||||
extern crate gstreamer as gst;
|
extern crate gstreamer as gst;
|
||||||
use gst::prelude::*;
|
use gst::prelude::*;
|
||||||
|
|
||||||
#[macro_use]
|
#[cfg_attr(feature = "v1_10", macro_use)]
|
||||||
extern crate glib;
|
extern crate glib;
|
||||||
|
|
||||||
use std::env;
|
use std::env;
|
||||||
|
|
|
@ -49,9 +49,8 @@ fn print_tags(info: &DiscovererInfo) {
|
||||||
|
|
||||||
fn print_stream_info(stream: &DiscovererStreamInfo) {
|
fn print_stream_info(stream: &DiscovererStreamInfo) {
|
||||||
println!("Stream: ");
|
println!("Stream: ");
|
||||||
match stream.get_stream_id() {
|
if let Some(id) = stream.get_stream_id() {
|
||||||
Some(id) => println!(" Stream id: {}", id),
|
println!(" Stream id: {}", id);
|
||||||
None => {}
|
|
||||||
}
|
}
|
||||||
let caps_str = match stream.get_caps() {
|
let caps_str = match stream.get_caps() {
|
||||||
Some(caps) => caps.to_string(),
|
Some(caps) => caps.to_string(),
|
||||||
|
|
|
@ -19,7 +19,7 @@ use gst::prelude::*;
|
||||||
extern crate gstreamer_pbutils as gst_pbutils;
|
extern crate gstreamer_pbutils as gst_pbutils;
|
||||||
use gst_pbutils::prelude::*;
|
use gst_pbutils::prelude::*;
|
||||||
|
|
||||||
#[macro_use]
|
#[cfg_attr(feature = "v1_10", macro_use)]
|
||||||
extern crate glib;
|
extern crate glib;
|
||||||
|
|
||||||
use std::env;
|
use std::env;
|
||||||
|
|
|
@ -51,10 +51,6 @@ struct ErrorMessage {
|
||||||
cause: glib::Error,
|
cause: glib::Error,
|
||||||
}
|
}
|
||||||
|
|
||||||
#[derive(Debug, Fail)]
|
|
||||||
#[fail(display = "Glutin error")]
|
|
||||||
struct GlutinError();
|
|
||||||
|
|
||||||
#[rustfmt::skip]
|
#[rustfmt::skip]
|
||||||
static VERTICES: [f32; 20] = [
|
static VERTICES: [f32; 20] = [
|
||||||
1.0, 1.0, 0.0, 1.0, 0.0,
|
1.0, 1.0, 0.0, 1.0, 0.0,
|
||||||
|
@ -73,7 +69,7 @@ static IDENTITY: [f32; 16] = [
|
||||||
0.0, 0.0, 0.0, 1.0,
|
0.0, 0.0, 0.0, 1.0,
|
||||||
];
|
];
|
||||||
|
|
||||||
const VS_SRC: &'static [u8] = b"
|
const VS_SRC: &[u8] = b"
|
||||||
uniform mat4 u_transformation;
|
uniform mat4 u_transformation;
|
||||||
attribute vec4 a_position;
|
attribute vec4 a_position;
|
||||||
attribute vec2 a_texcoord;
|
attribute vec2 a_texcoord;
|
||||||
|
@ -85,7 +81,7 @@ void main() {
|
||||||
}
|
}
|
||||||
\0";
|
\0";
|
||||||
|
|
||||||
const FS_SRC: &'static [u8] = b"
|
const FS_SRC: &[u8] = b"
|
||||||
#ifdef GL_ES
|
#ifdef GL_ES
|
||||||
precision mediump float;
|
precision mediump float;
|
||||||
#endif
|
#endif
|
||||||
|
@ -97,6 +93,9 @@ void main() {
|
||||||
}
|
}
|
||||||
\0";
|
\0";
|
||||||
|
|
||||||
|
#[allow(clippy::unreadable_literal)]
|
||||||
|
#[allow(clippy::unused_unit)]
|
||||||
|
#[allow(clippy::too_many_arguments)]
|
||||||
mod gl {
|
mod gl {
|
||||||
pub use self::Gles2 as Gl;
|
pub use self::Gles2 as Gl;
|
||||||
include!(concat!(env!("OUT_DIR"), "/test_gl_bindings.rs"));
|
include!(concat!(env!("OUT_DIR"), "/test_gl_bindings.rs"));
|
||||||
|
@ -315,7 +314,7 @@ fn load(gl_context: &glutin::Context) -> Gl {
|
||||||
};
|
};
|
||||||
|
|
||||||
Gl {
|
Gl {
|
||||||
gl: gl,
|
gl,
|
||||||
program,
|
program,
|
||||||
attr_position,
|
attr_position,
|
||||||
attr_texture,
|
attr_texture,
|
||||||
|
@ -374,6 +373,7 @@ impl App {
|
||||||
unsafe { gst_gl::GLContext::new_wrapped(&gl_display, egl_context, platform, api) }
|
unsafe { gst_gl::GLContext::new_wrapped(&gl_display, egl_context, platform, api) }
|
||||||
.unwrap();
|
.unwrap();
|
||||||
|
|
||||||
|
#[allow(clippy::single_match)]
|
||||||
bus.set_sync_handler(move |_, msg| {
|
bus.set_sync_handler(move |_, msg| {
|
||||||
use gst::MessageView;
|
use gst::MessageView;
|
||||||
|
|
||||||
|
@ -417,7 +417,7 @@ impl App {
|
||||||
appsink,
|
appsink,
|
||||||
bus,
|
bus,
|
||||||
events_loop: Arc::new(events_loop),
|
events_loop: Arc::new(events_loop),
|
||||||
combined_context: combined_context,
|
combined_context,
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -556,6 +556,7 @@ fn main_loop(mut app: App) -> Result<(), Error> {
|
||||||
let events_loop = Arc::get_mut(&mut app.events_loop).unwrap();
|
let events_loop = Arc::get_mut(&mut app.events_loop).unwrap();
|
||||||
let combined_context = app.combined_context.clone();
|
let combined_context = app.combined_context.clone();
|
||||||
while running {
|
while running {
|
||||||
|
#[allow(clippy::single_match)]
|
||||||
events_loop.poll_events(|event| match event {
|
events_loop.poll_events(|event| match event {
|
||||||
glutin::Event::WindowEvent { event, .. } => match event {
|
glutin::Event::WindowEvent { event, .. } => match event {
|
||||||
glutin::WindowEvent::CloseRequested => running = false,
|
glutin::WindowEvent::CloseRequested => running = false,
|
||||||
|
|
|
@ -170,7 +170,10 @@ fn create_pipeline() -> Result<gst::Pipeline, Error> {
|
||||||
// Calling multiple transformation methods after each other will apply the
|
// Calling multiple transformation methods after each other will apply the
|
||||||
// new transformation on top. If you repeat the cr.rotate(angle) line below
|
// new transformation on top. If you repeat the cr.rotate(angle) line below
|
||||||
// this a second time, everything in the canvas will rotate twice as fast.
|
// this a second time, everything in the canvas will rotate twice as fast.
|
||||||
cr.translate(info.width() as f64 / 2.0, info.height() as f64 / 2.0);
|
cr.translate(
|
||||||
|
f64::from(info.width()) / 2.0,
|
||||||
|
f64::from(info.height()) / 2.0,
|
||||||
|
);
|
||||||
cr.rotate(angle);
|
cr.rotate(angle);
|
||||||
|
|
||||||
// This loop will render 10 times the string "GStreamer" in a circle
|
// This loop will render 10 times the string "GStreamer" in a circle
|
||||||
|
@ -181,7 +184,7 @@ fn create_pipeline() -> Result<gst::Pipeline, Error> {
|
||||||
// previous transformations.
|
// previous transformations.
|
||||||
cr.save();
|
cr.save();
|
||||||
|
|
||||||
let angle = (360. * i as f64) / 10.0;
|
let angle = (360. * f64::from(i)) / 10.0;
|
||||||
let red = (1.0 + f64::cos((angle - 60.0) * PI / 180.0)) / 2.0;
|
let red = (1.0 + f64::cos((angle - 60.0) * PI / 180.0)) / 2.0;
|
||||||
cr.set_source_rgb(red, 0.0, 1.0 - red);
|
cr.set_source_rgb(red, 0.0, 1.0 - red);
|
||||||
cr.rotate(angle * PI / 180.0);
|
cr.rotate(angle * PI / 180.0);
|
||||||
|
@ -194,8 +197,8 @@ fn create_pipeline() -> Result<gst::Pipeline, Error> {
|
||||||
// Using width and height of the text, we can properly possition it within
|
// Using width and height of the text, we can properly possition it within
|
||||||
// our canvas.
|
// our canvas.
|
||||||
cr.move_to(
|
cr.move_to(
|
||||||
-(width as f64 / pango::SCALE as f64) / 2.0,
|
-(f64::from(width) / f64::from(pango::SCALE)) / 2.0,
|
||||||
-(info.height() as f64) / 2.0,
|
-(f64::from(info.height())) / 2.0,
|
||||||
);
|
);
|
||||||
// After telling the layout object where to draw itself, we actually tell
|
// After telling the layout object where to draw itself, we actually tell
|
||||||
// it to draw itself into our cairo context.
|
// it to draw itself into our cairo context.
|
||||||
|
|
|
@ -270,8 +270,8 @@ fn example_main() -> Result<(), Error> {
|
||||||
}
|
}
|
||||||
.into());
|
.into());
|
||||||
}
|
}
|
||||||
MessageView::StateChanged(s) => match msg.get_src() {
|
MessageView::StateChanged(s) => {
|
||||||
Some(element) => {
|
if let Some(element) = msg.get_src() {
|
||||||
if element == pipeline && s.get_current() == gst::State::Playing {
|
if element == pipeline && s.get_current() == gst::State::Playing {
|
||||||
eprintln!("PLAYING");
|
eprintln!("PLAYING");
|
||||||
gst::debug_bin_to_dot_file(
|
gst::debug_bin_to_dot_file(
|
||||||
|
@ -281,8 +281,7 @@ fn example_main() -> Result<(), Error> {
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
None => (),
|
}
|
||||||
},
|
|
||||||
_ => (),
|
_ => (),
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -201,8 +201,8 @@ fn example_main() -> Result<(), Error> {
|
||||||
}
|
}
|
||||||
.into());
|
.into());
|
||||||
}
|
}
|
||||||
MessageView::StateChanged(s) => match msg.get_src() {
|
MessageView::StateChanged(s) => {
|
||||||
Some(element) => {
|
if let Some(element) = msg.get_src() {
|
||||||
if element == pipeline && s.get_current() == gst::State::Playing {
|
if element == pipeline && s.get_current() == gst::State::Playing {
|
||||||
eprintln!("PLAYING");
|
eprintln!("PLAYING");
|
||||||
gst::debug_bin_to_dot_file(
|
gst::debug_bin_to_dot_file(
|
||||||
|
@ -212,8 +212,7 @@ fn example_main() -> Result<(), Error> {
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
None => (),
|
}
|
||||||
},
|
|
||||||
_ => (),
|
_ => (),
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -36,6 +36,7 @@ unsafe impl Send for AppSinkCallbacks {}
|
||||||
unsafe impl Sync for AppSinkCallbacks {}
|
unsafe impl Sync for AppSinkCallbacks {}
|
||||||
|
|
||||||
impl AppSinkCallbacks {
|
impl AppSinkCallbacks {
|
||||||
|
#[allow(clippy::new_ret_no_self)]
|
||||||
pub fn new() -> AppSinkCallbacksBuilder {
|
pub fn new() -> AppSinkCallbacksBuilder {
|
||||||
skip_assert_initialized!();
|
skip_assert_initialized!();
|
||||||
AppSinkCallbacksBuilder {
|
AppSinkCallbacksBuilder {
|
||||||
|
|
|
@ -27,6 +27,7 @@ unsafe impl Send for AppSrcCallbacks {}
|
||||||
unsafe impl Sync for AppSrcCallbacks {}
|
unsafe impl Sync for AppSrcCallbacks {}
|
||||||
|
|
||||||
impl AppSrcCallbacks {
|
impl AppSrcCallbacks {
|
||||||
|
#[allow(clippy::new_ret_no_self)]
|
||||||
pub fn new() -> AppSrcCallbacksBuilder {
|
pub fn new() -> AppSrcCallbacksBuilder {
|
||||||
skip_assert_initialized!();
|
skip_assert_initialized!();
|
||||||
|
|
||||||
|
|
|
@ -17,12 +17,8 @@ glib_wrapper! {
|
||||||
pub struct FlowCombiner(Shared<ffi::GstFlowCombiner>);
|
pub struct FlowCombiner(Shared<ffi::GstFlowCombiner>);
|
||||||
|
|
||||||
match fn {
|
match fn {
|
||||||
ref => |ptr| {
|
ref => |ptr| gobject_ffi::g_boxed_copy(ffi::gst_flow_combiner_get_type(), ptr as *mut _),
|
||||||
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 _),
|
||||||
},
|
|
||||||
unref => |ptr| {
|
|
||||||
gobject_ffi::g_boxed_free(ffi::gst_flow_combiner_get_type(), ptr as *mut _)
|
|
||||||
},
|
|
||||||
get_type => || ffi::gst_flow_combiner_get_type(),
|
get_type => || ffi::gst_flow_combiner_get_type(),
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -8,7 +8,7 @@
|
||||||
|
|
||||||
extern crate glib_sys as glib_ffi;
|
extern crate glib_sys as glib_ffi;
|
||||||
extern crate gobject_sys as gobject_ffi;
|
extern crate gobject_sys as gobject_ffi;
|
||||||
#[macro_use]
|
#[cfg_attr(feature = "subclassing", macro_use)]
|
||||||
extern crate gstreamer as gst;
|
extern crate gstreamer as gst;
|
||||||
extern crate gstreamer_base_sys as ffi;
|
extern crate gstreamer_base_sys as ffi;
|
||||||
extern crate gstreamer_sys as gst_ffi;
|
extern crate gstreamer_sys as gst_ffi;
|
||||||
|
|
|
@ -298,6 +298,12 @@ pub trait EncodingProfileBuilder<'a>: Sized {
|
||||||
|
|
||||||
macro_rules! declare_encoding_profile_builder_common(
|
macro_rules! declare_encoding_profile_builder_common(
|
||||||
($name:ident) => {
|
($name:ident) => {
|
||||||
|
impl<'a> Default for $name<'a> {
|
||||||
|
fn default() -> Self {
|
||||||
|
Self::new()
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
impl<'a> EncodingProfileBuilder<'a> for $name<'a> {
|
impl<'a> EncodingProfileBuilder<'a> for $name<'a> {
|
||||||
fn name(mut self, name: &'a str) -> $name<'a> {
|
fn name(mut self, name: &'a str) -> $name<'a> {
|
||||||
self.base.name = Some(name);
|
self.base.name = Some(name);
|
||||||
|
|
|
@ -42,6 +42,7 @@ impl VideoMeta {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#[allow(clippy::too_many_arguments)]
|
||||||
pub fn add_full<'a>(
|
pub fn add_full<'a>(
|
||||||
buffer: &'a mut gst::BufferRef,
|
buffer: &'a mut gst::BufferRef,
|
||||||
flags: ::VideoFrameFlags,
|
flags: ::VideoFrameFlags,
|
||||||
|
|
|
@ -39,6 +39,7 @@ impl VideoTimeCode {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#[allow(clippy::too_many_arguments)]
|
||||||
pub fn new(
|
pub fn new(
|
||||||
fps: gst::Fraction,
|
fps: gst::Fraction,
|
||||||
latest_daily_jam: Option<&glib::DateTime>,
|
latest_daily_jam: Option<&glib::DateTime>,
|
||||||
|
@ -153,6 +154,7 @@ impl VideoTimeCode {
|
||||||
}
|
}
|
||||||
|
|
||||||
impl ValidVideoTimeCode {
|
impl ValidVideoTimeCode {
|
||||||
|
#[allow(clippy::too_many_arguments)]
|
||||||
pub fn new(
|
pub fn new(
|
||||||
fps: gst::Fraction,
|
fps: gst::Fraction,
|
||||||
latest_daily_jam: Option<&glib::DateTime>,
|
latest_daily_jam: Option<&glib::DateTime>,
|
||||||
|
|
|
@ -111,7 +111,7 @@ impl<'de> Visitor<'de> for CapsFeaturesVariantKindsVisitor {
|
||||||
CAPS_FEATURES_VARIANT_ANY_ID => Ok(CapsFeaturesVariantKinds::Any),
|
CAPS_FEATURES_VARIANT_ANY_ID => Ok(CapsFeaturesVariantKinds::Any),
|
||||||
CAPS_FEATURES_VARIANT_SOME_ID => Ok(CapsFeaturesVariantKinds::Some),
|
CAPS_FEATURES_VARIANT_SOME_ID => Ok(CapsFeaturesVariantKinds::Some),
|
||||||
_ => Err(de::Error::invalid_value(
|
_ => Err(de::Error::invalid_value(
|
||||||
de::Unexpected::Unsigned(value as u64),
|
de::Unexpected::Unsigned(u64::from(value)),
|
||||||
&self,
|
&self,
|
||||||
)),
|
)),
|
||||||
}
|
}
|
||||||
|
|
|
@ -174,7 +174,7 @@ impl<'de> Visitor<'de> for CapsVariantKindsVisitor {
|
||||||
CAPS_VARIANT_EMPTY_ID => Ok(CapsVariantKinds::Empty),
|
CAPS_VARIANT_EMPTY_ID => Ok(CapsVariantKinds::Empty),
|
||||||
CAPS_VARIANT_SOME_ID => Ok(CapsVariantKinds::Some),
|
CAPS_VARIANT_SOME_ID => Ok(CapsVariantKinds::Some),
|
||||||
_ => Err(de::Error::invalid_value(
|
_ => Err(de::Error::invalid_value(
|
||||||
de::Unexpected::Unsigned(value as u64),
|
de::Unexpected::Unsigned(u64::from(value)),
|
||||||
&self,
|
&self,
|
||||||
)),
|
)),
|
||||||
}
|
}
|
||||||
|
|
|
@ -29,7 +29,7 @@ impl<'a> Serialize for DateTime {
|
||||||
self.get_day(),
|
self.get_day(),
|
||||||
self.get_hour(),
|
self.get_hour(),
|
||||||
self.get_minute(),
|
self.get_minute(),
|
||||||
(self.get_second() as f64) + (self.get_microsecond() as f64) / 1_000_000f64,
|
f64::from(self.get_second()) + f64::from(self.get_microsecond()) / 1_000_000f64,
|
||||||
self.get_time_zone_offset(),
|
self.get_time_zone_offset(),
|
||||||
)
|
)
|
||||||
} else if self.has_time() {
|
} else if self.has_time() {
|
||||||
|
@ -58,6 +58,7 @@ impl<'a> Serialize for DateTime {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#[allow(clippy::many_single_char_names)]
|
||||||
impl From<DateTimeVariants> for DateTime {
|
impl From<DateTimeVariants> for DateTime {
|
||||||
fn from(dt_variant: DateTimeVariants) -> Self {
|
fn from(dt_variant: DateTimeVariants) -> Self {
|
||||||
match dt_variant {
|
match dt_variant {
|
||||||
|
|
|
@ -113,12 +113,12 @@ impl Error for ErrorMessage {
|
||||||
macro_rules! gst_loggable_error(
|
macro_rules! gst_loggable_error(
|
||||||
// Plain strings
|
// Plain strings
|
||||||
($cat:expr, $msg:expr) => {
|
($cat:expr, $msg:expr) => {
|
||||||
$crate::LoggableError::new(&$cat, glib_bool_error!($msg))
|
$crate::LoggableError::new($cat.clone(), glib_bool_error!($msg))
|
||||||
};
|
};
|
||||||
|
|
||||||
// Format strings
|
// Format strings
|
||||||
($cat:expr, $($msg:tt)*) => { {
|
($cat:expr, $($msg:tt)*) => { {
|
||||||
$crate::LoggableError::new(&$cat, glib_bool_error!($($msg)*))
|
$crate::LoggableError::new($cat.clone(), glib_bool_error!($($msg)*))
|
||||||
}};
|
}};
|
||||||
);
|
);
|
||||||
|
|
||||||
|
@ -127,13 +127,13 @@ macro_rules! gst_result_from_gboolean(
|
||||||
// Plain strings
|
// Plain strings
|
||||||
($ffi_bool:expr, $cat:expr, $msg:expr) => {
|
($ffi_bool:expr, $cat:expr, $msg:expr) => {
|
||||||
glib_result_from_gboolean!($ffi_bool, $msg)
|
glib_result_from_gboolean!($ffi_bool, $msg)
|
||||||
.map_err(|bool_err| $crate::LoggableError::new(&$cat, bool_err))
|
.map_err(|bool_err| $crate::LoggableError::new($cat.clone(), bool_err))
|
||||||
};
|
};
|
||||||
|
|
||||||
// Format strings
|
// Format strings
|
||||||
($ffi_bool:expr, $cat:expr, $($msg:tt)*) => { {
|
($ffi_bool:expr, $cat:expr, $($msg:tt)*) => { {
|
||||||
glib_result_from_gboolean!($ffi_bool, $($msg)*)
|
glib_result_from_gboolean!($ffi_bool, $($msg)*)
|
||||||
.map_err(|bool_err| $crate::LoggableError::new(&$cat, bool_err))
|
.map_err(|bool_err| $crate::LoggableError::new($cat.clone(), bool_err))
|
||||||
}};
|
}};
|
||||||
);
|
);
|
||||||
|
|
||||||
|
@ -144,9 +144,9 @@ pub struct LoggableError {
|
||||||
}
|
}
|
||||||
|
|
||||||
impl LoggableError {
|
impl LoggableError {
|
||||||
pub fn new(category: &::DebugCategory, bool_error: glib::BoolError) -> LoggableError {
|
pub fn new(category: ::DebugCategory, bool_error: glib::BoolError) -> LoggableError {
|
||||||
LoggableError {
|
LoggableError {
|
||||||
category: *category,
|
category,
|
||||||
bool_error,
|
bool_error,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -59,6 +59,7 @@ impl<T> Iterator<T>
|
||||||
where
|
where
|
||||||
for<'a> T: FromValueOptional<'a> + 'static,
|
for<'a> T: FromValueOptional<'a> + 'static,
|
||||||
{
|
{
|
||||||
|
#[allow(clippy::should_implement_trait)]
|
||||||
pub fn next(&mut self) -> Result<Option<T>, IteratorError> {
|
pub fn next(&mut self) -> Result<Option<T>, IteratorError> {
|
||||||
unsafe {
|
unsafe {
|
||||||
let mut value = Value::uninitialized();
|
let mut value = Value::uninitialized();
|
||||||
|
|
|
@ -20,7 +20,6 @@ use glib::IsA;
|
||||||
#[derive(PartialEq, Eq, Clone, Copy)]
|
#[derive(PartialEq, Eq, Clone, Copy)]
|
||||||
pub struct DebugCategory(ptr::NonNull<ffi::GstDebugCategory>);
|
pub struct DebugCategory(ptr::NonNull<ffi::GstDebugCategory>);
|
||||||
|
|
||||||
#[allow(clippy::trivially_copy_pass_by_ref)]
|
|
||||||
impl DebugCategory {
|
impl DebugCategory {
|
||||||
pub fn new<'a, P: Into<Option<&'a str>>>(
|
pub fn new<'a, P: Into<Option<&'a str>>>(
|
||||||
name: &str,
|
name: &str,
|
||||||
|
@ -64,23 +63,23 @@ impl DebugCategory {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn get_threshold(&self) -> ::DebugLevel {
|
pub fn get_threshold(self) -> ::DebugLevel {
|
||||||
from_glib(unsafe { ffi::gst_debug_category_get_threshold(self.0.as_ptr()) })
|
from_glib(unsafe { ffi::gst_debug_category_get_threshold(self.0.as_ptr()) })
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn set_threshold(&self, threshold: ::DebugLevel) {
|
pub fn set_threshold(self, threshold: ::DebugLevel) {
|
||||||
unsafe { ffi::gst_debug_category_set_threshold(self.0.as_ptr(), threshold.to_glib()) }
|
unsafe { ffi::gst_debug_category_set_threshold(self.0.as_ptr(), threshold.to_glib()) }
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn reset_threshold(&self) {
|
pub fn reset_threshold(self) {
|
||||||
unsafe { ffi::gst_debug_category_reset_threshold(self.0.as_ptr()) }
|
unsafe { ffi::gst_debug_category_reset_threshold(self.0.as_ptr()) }
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn get_color(&self) -> ::DebugColorFlags {
|
pub fn get_color(self) -> ::DebugColorFlags {
|
||||||
unsafe { from_glib(ffi::gst_debug_category_get_color(self.0.as_ptr())) }
|
unsafe { from_glib(ffi::gst_debug_category_get_color(self.0.as_ptr())) }
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn get_name(&self) -> &str {
|
pub fn get_name<'a>(self) -> &'a str {
|
||||||
unsafe {
|
unsafe {
|
||||||
CStr::from_ptr(ffi::gst_debug_category_get_name(self.0.as_ptr()))
|
CStr::from_ptr(ffi::gst_debug_category_get_name(self.0.as_ptr()))
|
||||||
.to_str()
|
.to_str()
|
||||||
|
@ -88,9 +87,9 @@ impl DebugCategory {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn get_description(&self) -> Option<&str> {
|
pub fn get_description<'a>(self) -> Option<&'a str> {
|
||||||
unsafe {
|
unsafe {
|
||||||
let ptr = ffi::gst_debug_category_get_name(self.0.as_ptr());
|
let ptr = ffi::gst_debug_category_get_description(self.0.as_ptr());
|
||||||
|
|
||||||
if ptr.is_null() {
|
if ptr.is_null() {
|
||||||
None
|
None
|
||||||
|
@ -102,7 +101,7 @@ impl DebugCategory {
|
||||||
|
|
||||||
#[inline]
|
#[inline]
|
||||||
pub fn log<O: IsA<::Object>>(
|
pub fn log<O: IsA<::Object>>(
|
||||||
&self,
|
self,
|
||||||
obj: Option<&O>,
|
obj: Option<&O>,
|
||||||
level: ::DebugLevel,
|
level: ::DebugLevel,
|
||||||
file: &str,
|
file: &str,
|
||||||
|
@ -199,91 +198,91 @@ declare_debug_category_from_name!(CAT_CONTEXT, "GST_CONTEXT");
|
||||||
#[macro_export]
|
#[macro_export]
|
||||||
macro_rules! gst_error(
|
macro_rules! gst_error(
|
||||||
($cat:expr, obj: $obj:expr, $($args:tt)*) => { {
|
($cat:expr, obj: $obj:expr, $($args:tt)*) => { {
|
||||||
gst_log_with_level!($cat, level: $crate::DebugLevel::Error, obj: $obj, $($args)*)
|
gst_log_with_level!($cat.clone(), level: $crate::DebugLevel::Error, obj: $obj, $($args)*)
|
||||||
}};
|
}};
|
||||||
($cat:expr, $($args:tt)*) => { {
|
($cat:expr, $($args:tt)*) => { {
|
||||||
gst_log_with_level!($cat, level: $crate::DebugLevel::Error, $($args)*)
|
gst_log_with_level!($cat.clone(), level: $crate::DebugLevel::Error, $($args)*)
|
||||||
}};
|
}};
|
||||||
);
|
);
|
||||||
|
|
||||||
#[macro_export]
|
#[macro_export]
|
||||||
macro_rules! gst_warning(
|
macro_rules! gst_warning(
|
||||||
($cat:expr, obj: $obj:expr, $($args:tt)*) => { {
|
($cat:expr, obj: $obj:expr, $($args:tt)*) => { {
|
||||||
gst_log_with_level!($cat, level: $crate::DebugLevel::Warning, obj: $obj, $($args)*)
|
gst_log_with_level!($cat.clone(), level: $crate::DebugLevel::Warning, obj: $obj, $($args)*)
|
||||||
}};
|
}};
|
||||||
($cat:expr, $($args:tt)*) => { {
|
($cat:expr, $($args:tt)*) => { {
|
||||||
gst_log_with_level!($cat, level: $crate::DebugLevel::Warning, $($args)*)
|
gst_log_with_level!($cat.clone(), level: $crate::DebugLevel::Warning, $($args)*)
|
||||||
}};
|
}};
|
||||||
);
|
);
|
||||||
|
|
||||||
#[macro_export]
|
#[macro_export]
|
||||||
macro_rules! gst_fixme(
|
macro_rules! gst_fixme(
|
||||||
($cat:expr, obj: $obj:expr, $($args:tt)*) => { {
|
($cat:expr, obj: $obj:expr, $($args:tt)*) => { {
|
||||||
gst_log_with_level!($cat, level: $crate::DebugLevel::Fixme, obj: $obj, $($args)*)
|
gst_log_with_level!($cat.clone(), level: $crate::DebugLevel::Fixme, obj: $obj, $($args)*)
|
||||||
}};
|
}};
|
||||||
($cat:expr, $($args:tt)*) => { {
|
($cat:expr, $($args:tt)*) => { {
|
||||||
gst_log_with_level!($cat, level: $crate::DebugLevel::Fixme, $($args)*)
|
gst_log_with_level!($cat.clone(), level: $crate::DebugLevel::Fixme, $($args)*)
|
||||||
}};
|
}};
|
||||||
);
|
);
|
||||||
|
|
||||||
#[macro_export]
|
#[macro_export]
|
||||||
macro_rules! gst_info(
|
macro_rules! gst_info(
|
||||||
($cat:expr, obj: $obj:expr, $($args:tt)*) => { {
|
($cat:expr, obj: $obj:expr, $($args:tt)*) => { {
|
||||||
gst_log_with_level!($cat, level: $crate::DebugLevel::Info, obj: $obj, $($args)*)
|
gst_log_with_level!($cat.clone(), level: $crate::DebugLevel::Info, obj: $obj, $($args)*)
|
||||||
}};
|
}};
|
||||||
($cat:expr, $($args:tt)*) => { {
|
($cat:expr, $($args:tt)*) => { {
|
||||||
gst_log_with_level!($cat, level: $crate::DebugLevel::Info, $($args)*)
|
gst_log_with_level!($cat.clone(), level: $crate::DebugLevel::Info, $($args)*)
|
||||||
}};
|
}};
|
||||||
);
|
);
|
||||||
|
|
||||||
#[macro_export]
|
#[macro_export]
|
||||||
macro_rules! gst_debug(
|
macro_rules! gst_debug(
|
||||||
($cat:expr, obj: $obj:expr, $($args:tt)*) => { {
|
($cat:expr, obj: $obj:expr, $($args:tt)*) => { {
|
||||||
gst_log_with_level!($cat, level: $crate::DebugLevel::Debug, obj: $obj, $($args)*)
|
gst_log_with_level!($cat.clone(), level: $crate::DebugLevel::Debug, obj: $obj, $($args)*)
|
||||||
}};
|
}};
|
||||||
($cat:expr, $($args:tt)*) => { {
|
($cat:expr, $($args:tt)*) => { {
|
||||||
gst_log_with_level!($cat, level: $crate::DebugLevel::Debug, $($args)*)
|
gst_log_with_level!($cat.clone(), level: $crate::DebugLevel::Debug, $($args)*)
|
||||||
}};
|
}};
|
||||||
);
|
);
|
||||||
|
|
||||||
#[macro_export]
|
#[macro_export]
|
||||||
macro_rules! gst_log(
|
macro_rules! gst_log(
|
||||||
($cat:expr, obj: $obj:expr, $($args:tt)*) => { {
|
($cat:expr, obj: $obj:expr, $($args:tt)*) => { {
|
||||||
gst_log_with_level!($cat, level: $crate::DebugLevel::Log, obj: $obj, $($args)*)
|
gst_log_with_level!($cat.clone(), level: $crate::DebugLevel::Log, obj: $obj, $($args)*)
|
||||||
}};
|
}};
|
||||||
($cat:expr, $($args:tt)*) => { {
|
($cat:expr, $($args:tt)*) => { {
|
||||||
gst_log_with_level!($cat, level: $crate::DebugLevel::Log, $($args)*)
|
gst_log_with_level!($cat.clone(), level: $crate::DebugLevel::Log, $($args)*)
|
||||||
}};
|
}};
|
||||||
);
|
);
|
||||||
|
|
||||||
#[macro_export]
|
#[macro_export]
|
||||||
macro_rules! gst_trace(
|
macro_rules! gst_trace(
|
||||||
($cat:expr, obj: $obj:expr, $($args:tt)*) => { {
|
($cat:expr, obj: $obj:expr, $($args:tt)*) => { {
|
||||||
gst_log_with_level!($cat, level: $crate::DebugLevel::Trace, obj: $obj, $($args)*)
|
gst_log_with_level!($cat.clone(), level: $crate::DebugLevel::Trace, obj: $obj, $($args)*)
|
||||||
}};
|
}};
|
||||||
($cat:expr, $($args:tt)*) => { {
|
($cat:expr, $($args:tt)*) => { {
|
||||||
gst_log_with_level!($cat, level: $crate::DebugLevel::Trace, $($args)*)
|
gst_log_with_level!($cat.clone(), level: $crate::DebugLevel::Trace, $($args)*)
|
||||||
}};
|
}};
|
||||||
);
|
);
|
||||||
|
|
||||||
#[macro_export]
|
#[macro_export]
|
||||||
macro_rules! gst_memdump(
|
macro_rules! gst_memdump(
|
||||||
($cat:expr, obj: $obj:expr, $($args:tt)*) => { {
|
($cat:expr, obj: $obj:expr, $($args:tt)*) => { {
|
||||||
gst_log_with_level!($cat, level: $crate::DebugLevel::Memdump, obj: $obj, $($args)*)
|
gst_log_with_level!($cat.clone(), level: $crate::DebugLevel::Memdump, obj: $obj, $($args)*)
|
||||||
}};
|
}};
|
||||||
($cat:expr, $($args:tt)*) => { {
|
($cat:expr, $($args:tt)*) => { {
|
||||||
gst_log_with_level!($cat, level: $crate::DebugLevel::Memdump, $($args)*)
|
gst_log_with_level!($cat.clone(), level: $crate::DebugLevel::Memdump, $($args)*)
|
||||||
}};
|
}};
|
||||||
);
|
);
|
||||||
|
|
||||||
#[macro_export]
|
#[macro_export]
|
||||||
macro_rules! gst_log_with_level(
|
macro_rules! gst_log_with_level(
|
||||||
($cat:expr, level: $level:expr, obj: $obj:expr, $($args:tt)*) => { {
|
($cat:expr, level: $level:expr, obj: $obj:expr, $($args:tt)*) => { {
|
||||||
$crate::DebugCategory::log(&$cat, Some($obj), $level, file!(),
|
$crate::DebugCategory::log($cat.clone(), Some($obj), $level, file!(),
|
||||||
module_path!(), line!(), format_args!($($args)*))
|
module_path!(), line!(), format_args!($($args)*))
|
||||||
}};
|
}};
|
||||||
($cat:expr, level: $level:expr, $($args:tt)*) => { {
|
($cat:expr, level: $level:expr, $($args:tt)*) => { {
|
||||||
$crate::DebugCategory::log(&$cat, None as Option<&$crate::Object>, $level, file!(),
|
$crate::DebugCategory::log($cat.clone(), None as Option<&$crate::Object>, $level, file!(),
|
||||||
module_path!(), line!(), format_args!($($args)*))
|
module_path!(), line!(), format_args!($($args)*))
|
||||||
}};
|
}};
|
||||||
);
|
);
|
||||||
|
|
|
@ -80,9 +80,9 @@ impl<T: BinImpl + ObjectImpl> BinImplExt for T {
|
||||||
unsafe {
|
unsafe {
|
||||||
let data = self.get_type_data();
|
let data = self.get_type_data();
|
||||||
let parent_class = data.as_ref().get_parent_class() as *mut ffi::GstBinClass;
|
let parent_class = data.as_ref().get_parent_class() as *mut ffi::GstBinClass;
|
||||||
(*parent_class)
|
if let Some(ref f) = (*parent_class).handle_message {
|
||||||
.handle_message
|
f(bin.to_glib_none().0, message.into_ptr());
|
||||||
.map(move |f| f(bin.to_glib_none().0, message.into_ptr()));
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -158,10 +158,13 @@ mod tutorial5 {
|
||||||
let slider_update_signal_id = slider.connect_value_changed(move |slider| {
|
let slider_update_signal_id = slider.connect_value_changed(move |slider| {
|
||||||
let pipeline = &pipeline;
|
let pipeline = &pipeline;
|
||||||
let value = slider.get_value() as u64;
|
let value = slider.get_value() as u64;
|
||||||
if let Err(_) = pipeline.seek_simple(
|
if pipeline
|
||||||
gst::SeekFlags::FLUSH | gst::SeekFlags::KEY_UNIT,
|
.seek_simple(
|
||||||
value * gst::SECOND,
|
gst::SeekFlags::FLUSH | gst::SeekFlags::KEY_UNIT,
|
||||||
) {
|
value * gst::SECOND,
|
||||||
|
)
|
||||||
|
.is_err()
|
||||||
|
{
|
||||||
eprintln!("Seeking to {} failed", value);
|
eprintln!("Seeking to {} failed", value);
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
@ -257,30 +260,30 @@ mod tutorial5 {
|
||||||
streams_list.set_editable(false);
|
streams_list.set_editable(false);
|
||||||
let pipeline_weak = playbin.downgrade();
|
let pipeline_weak = playbin.downgrade();
|
||||||
let streams_list_weak = glib::SendWeakRef::from(streams_list.downgrade());
|
let streams_list_weak = glib::SendWeakRef::from(streams_list.downgrade());
|
||||||
playbin
|
let bus = playbin.get_bus().unwrap();
|
||||||
.get_bus()
|
|
||||||
.unwrap()
|
|
||||||
.connect_message(move |_, msg| match msg.view() {
|
|
||||||
gst::MessageView::Application(application) => {
|
|
||||||
let pipeline = match pipeline_weak.upgrade() {
|
|
||||||
Some(pipeline) => pipeline,
|
|
||||||
None => return,
|
|
||||||
};
|
|
||||||
|
|
||||||
let streams_list = match streams_list_weak.upgrade() {
|
#[allow(clippy::single_match)]
|
||||||
Some(streams_list) => streams_list,
|
bus.connect_message(move |_, msg| match msg.view() {
|
||||||
None => return,
|
gst::MessageView::Application(application) => {
|
||||||
};
|
let pipeline = match pipeline_weak.upgrade() {
|
||||||
|
Some(pipeline) => pipeline,
|
||||||
|
None => return,
|
||||||
|
};
|
||||||
|
|
||||||
if application.get_structure().map(|s| s.get_name()) == Some("tags-changed") {
|
let streams_list = match streams_list_weak.upgrade() {
|
||||||
let textbuf = streams_list
|
Some(streams_list) => streams_list,
|
||||||
.get_buffer()
|
None => return,
|
||||||
.expect("Couldn't get buffer from text_view");
|
};
|
||||||
analyze_streams(&pipeline, &textbuf);
|
|
||||||
}
|
if application.get_structure().map(|s| s.get_name()) == Some("tags-changed") {
|
||||||
|
let textbuf = streams_list
|
||||||
|
.get_buffer()
|
||||||
|
.expect("Couldn't get buffer from text_view");
|
||||||
|
analyze_streams(&pipeline, &textbuf);
|
||||||
}
|
}
|
||||||
_ => (),
|
}
|
||||||
});
|
_ => (),
|
||||||
|
});
|
||||||
|
|
||||||
let vbox = Box::new(Orientation::Horizontal, 0);
|
let vbox = Box::new(Orientation::Horizontal, 0);
|
||||||
vbox.pack_start(&video_window, true, true, 0);
|
vbox.pack_start(&video_window, true, true, 0);
|
||||||
|
@ -309,10 +312,15 @@ mod tutorial5 {
|
||||||
|
|
||||||
pub fn run() {
|
pub fn run() {
|
||||||
// Make sure the right features were activated
|
// Make sure the right features were activated
|
||||||
if !cfg!(feature = "tutorial5-x11") && !cfg!(feature = "tutorial5-quartz") {
|
#[allow(clippy::eq_op)]
|
||||||
eprintln!("No Gdk backend selected, compile with --features tutorial5[-x11][-quartz].");
|
{
|
||||||
|
if !cfg!(feature = "tutorial5-x11") && !cfg!(feature = "tutorial5-quartz") {
|
||||||
|
eprintln!(
|
||||||
|
"No Gdk backend selected, compile with --features tutorial5[-x11][-quartz]."
|
||||||
|
);
|
||||||
|
|
||||||
return;
|
return;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// Initialize GTK
|
// Initialize GTK
|
||||||
|
|
|
@ -243,6 +243,7 @@ fn main() {
|
||||||
let main_loop = glib::MainLoop::new(None, false);
|
let main_loop = glib::MainLoop::new(None, false);
|
||||||
let main_loop_clone = main_loop.clone();
|
let main_loop_clone = main_loop.clone();
|
||||||
let bus = pipeline.get_bus().unwrap();
|
let bus = pipeline.get_bus().unwrap();
|
||||||
|
#[allow(clippy::single_match)]
|
||||||
bus.connect_message(move |_, msg| match msg.view() {
|
bus.connect_message(move |_, msg| match msg.view() {
|
||||||
gst::MessageView::Error(err) => {
|
gst::MessageView::Error(err) => {
|
||||||
let main_loop = &main_loop_clone;
|
let main_loop = &main_loop_clone;
|
||||||
|
|
Loading…
Reference in a new issue