mirror of
https://gitlab.freedesktop.org/gstreamer/gstreamer-rs.git
synced 2025-01-03 05:48:43 +00:00
Run everything through latest rustfmt
This commit is contained in:
parent
2c7dff3b45
commit
eb0a804a50
38 changed files with 217 additions and 132 deletions
|
@ -115,12 +115,14 @@ fn create_pipeline() -> Result<gst::Pipeline, Error> {
|
||||||
.map(|sample| {
|
.map(|sample| {
|
||||||
let f = f64::from(*sample) / f64::from(i16::MAX);
|
let f = f64::from(*sample) / f64::from(i16::MAX);
|
||||||
f * f
|
f * f
|
||||||
}).sum();
|
})
|
||||||
|
.sum();
|
||||||
let rms = (sum / (samples.len() as f64)).sqrt();
|
let rms = (sum / (samples.len() as f64)).sqrt();
|
||||||
println!("rms: {}", rms);
|
println!("rms: {}", rms);
|
||||||
|
|
||||||
gst::FlowReturn::Ok
|
gst::FlowReturn::Ok
|
||||||
}).build(),
|
})
|
||||||
|
.build(),
|
||||||
);
|
);
|
||||||
|
|
||||||
Ok(pipeline)
|
Ok(pipeline)
|
||||||
|
|
|
@ -105,7 +105,8 @@ fn create_pipeline() -> Result<gst::Pipeline, Error> {
|
||||||
|
|
||||||
// appsrc already handles the error here
|
// appsrc already handles the error here
|
||||||
let _ = appsrc.push_buffer(buffer);
|
let _ = appsrc.push_buffer(buffer);
|
||||||
}).build(),
|
})
|
||||||
|
.build(),
|
||||||
);
|
);
|
||||||
|
|
||||||
Ok(pipeline)
|
Ok(pipeline)
|
||||||
|
|
|
@ -178,7 +178,8 @@ fn example_main() -> Result<(), Error> {
|
||||||
.and_then(|v| {
|
.and_then(|v| {
|
||||||
v.downcast_ref::<Arc<Mutex<Option<Error>>>>()
|
v.downcast_ref::<Arc<Mutex<Option<Error>>>>()
|
||||||
.and_then(|v| v.lock().unwrap().take())
|
.and_then(|v| v.lock().unwrap().take())
|
||||||
}).map(Result::Err)
|
})
|
||||||
|
.map(Result::Err)
|
||||||
.expect("error-details message without actual error"),
|
.expect("error-details message without actual error"),
|
||||||
_ => Err(ErrorMessage {
|
_ => Err(ErrorMessage {
|
||||||
src: err
|
src: err
|
||||||
|
@ -188,7 +189,8 @@ fn example_main() -> Result<(), Error> {
|
||||||
error: err.get_error().description().into(),
|
error: err.get_error().description().into(),
|
||||||
debug: err.get_debug(),
|
debug: err.get_debug(),
|
||||||
cause: err.get_error(),
|
cause: err.get_error(),
|
||||||
}.into()),
|
}
|
||||||
|
.into()),
|
||||||
}?;
|
}?;
|
||||||
}
|
}
|
||||||
#[cfg(not(feature = "v1_10"))]
|
#[cfg(not(feature = "v1_10"))]
|
||||||
|
|
|
@ -236,7 +236,8 @@ fn example_main() -> Result<(), Error> {
|
||||||
.and_then(|v| {
|
.and_then(|v| {
|
||||||
v.downcast_ref::<Arc<Mutex<Option<Error>>>>()
|
v.downcast_ref::<Arc<Mutex<Option<Error>>>>()
|
||||||
.and_then(|v| v.lock().unwrap().take())
|
.and_then(|v| v.lock().unwrap().take())
|
||||||
}).map(Result::Err)
|
})
|
||||||
|
.map(Result::Err)
|
||||||
.expect("error-details message without actual error"),
|
.expect("error-details message without actual error"),
|
||||||
_ => Err(ErrorMessage {
|
_ => Err(ErrorMessage {
|
||||||
src: err
|
src: err
|
||||||
|
@ -246,7 +247,8 @@ fn example_main() -> Result<(), Error> {
|
||||||
error: err.get_error().description().into(),
|
error: err.get_error().description().into(),
|
||||||
debug: err.get_debug(),
|
debug: err.get_debug(),
|
||||||
cause: err.get_error(),
|
cause: err.get_error(),
|
||||||
}.into()),
|
}
|
||||||
|
.into()),
|
||||||
}?;
|
}?;
|
||||||
}
|
}
|
||||||
#[cfg(not(feature = "v1_10"))]
|
#[cfg(not(feature = "v1_10"))]
|
||||||
|
|
|
@ -44,7 +44,8 @@ fn example_main() {
|
||||||
} else {
|
} else {
|
||||||
Ok(())
|
Ok(())
|
||||||
}
|
}
|
||||||
}).and_then(|_| Ok(()));
|
})
|
||||||
|
.and_then(|_| Ok(()));
|
||||||
|
|
||||||
let _ = block_on(messages);
|
let _ = block_on(messages);
|
||||||
|
|
||||||
|
|
|
@ -47,7 +47,8 @@ fn example_main() {
|
||||||
} else {
|
} else {
|
||||||
Ok(())
|
Ok(())
|
||||||
}
|
}
|
||||||
}).and_then(|_| Ok(()));
|
})
|
||||||
|
.and_then(|_| Ok(()));
|
||||||
|
|
||||||
let _ = ctx.block_on(messages);
|
let _ = ctx.block_on(messages);
|
||||||
|
|
||||||
|
|
|
@ -16,7 +16,8 @@ fn example_main() {
|
||||||
let pipeline = gst::parse_launch(&format!(
|
let pipeline = gst::parse_launch(&format!(
|
||||||
"audiotestsrc name=src ! audio/x-raw,format={},channels=1 ! fakesink",
|
"audiotestsrc name=src ! audio/x-raw,format={},channels=1 ! fakesink",
|
||||||
gst_audio::AUDIO_FORMAT_S16.to_string()
|
gst_audio::AUDIO_FORMAT_S16.to_string()
|
||||||
)).unwrap();
|
))
|
||||||
|
.unwrap();
|
||||||
let pipeline = pipeline.dynamic_cast::<gst::Pipeline>().unwrap();
|
let pipeline = pipeline.dynamic_cast::<gst::Pipeline>().unwrap();
|
||||||
|
|
||||||
let src = pipeline.get_by_name("src").unwrap();
|
let src = pipeline.get_by_name("src").unwrap();
|
||||||
|
@ -36,7 +37,8 @@ fn example_main() {
|
||||||
.map(|sample| {
|
.map(|sample| {
|
||||||
let f = f64::from(*sample) / f64::from(i16::MAX);
|
let f = f64::from(*sample) / f64::from(i16::MAX);
|
||||||
f * f
|
f * f
|
||||||
}).sum();
|
})
|
||||||
|
.sum();
|
||||||
let rms = (sum / (samples.len() as f64)).sqrt();
|
let rms = (sum / (samples.len() as f64)).sqrt();
|
||||||
println!("rms: {}", rms);
|
println!("rms: {}", rms);
|
||||||
}
|
}
|
||||||
|
|
|
@ -146,7 +146,8 @@ fn create_pipeline() -> Result<gst::Pipeline, Error> {
|
||||||
}
|
}
|
||||||
|
|
||||||
None
|
None
|
||||||
}).unwrap();
|
})
|
||||||
|
.unwrap();
|
||||||
|
|
||||||
let drawer_clone = drawer.clone();
|
let drawer_clone = drawer.clone();
|
||||||
overlay
|
overlay
|
||||||
|
@ -159,7 +160,8 @@ fn create_pipeline() -> Result<gst::Pipeline, Error> {
|
||||||
drawer.info = Some(gst_video::VideoInfo::from_caps(&caps).unwrap());
|
drawer.info = Some(gst_video::VideoInfo::from_caps(&caps).unwrap());
|
||||||
|
|
||||||
None
|
None
|
||||||
}).unwrap();
|
})
|
||||||
|
.unwrap();
|
||||||
|
|
||||||
Ok(pipeline)
|
Ok(pipeline)
|
||||||
}
|
}
|
||||||
|
|
|
@ -60,7 +60,8 @@ fn example_main() {
|
||||||
}
|
}
|
||||||
|
|
||||||
None
|
None
|
||||||
}).unwrap();
|
})
|
||||||
|
.unwrap();
|
||||||
|
|
||||||
let bus = playbin.get_bus().unwrap();
|
let bus = playbin.get_bus().unwrap();
|
||||||
|
|
||||||
|
|
|
@ -39,7 +39,8 @@ fn example_main() {
|
||||||
} else {
|
} else {
|
||||||
None
|
None
|
||||||
}
|
}
|
||||||
}.and_then(|pos| pos.try_into_time().ok())
|
}
|
||||||
|
.and_then(|pos| pos.try_into_time().ok())
|
||||||
.unwrap();
|
.unwrap();
|
||||||
|
|
||||||
let dur = {
|
let dur = {
|
||||||
|
@ -49,7 +50,8 @@ fn example_main() {
|
||||||
} else {
|
} else {
|
||||||
None
|
None
|
||||||
}
|
}
|
||||||
}.and_then(|dur| dur.try_into_time().ok())
|
}
|
||||||
|
.and_then(|dur| dur.try_into_time().ok())
|
||||||
.unwrap();
|
.unwrap();
|
||||||
|
|
||||||
println!("{} / {}", pos, dur);
|
println!("{} / {}", pos, dur);
|
||||||
|
|
|
@ -172,7 +172,8 @@ fn example_main() -> Result<(), Error> {
|
||||||
("clock-rate", &90000i32),
|
("clock-rate", &90000i32),
|
||||||
("is-fec", &true),
|
("is-fec", &true),
|
||||||
],
|
],
|
||||||
).to_value(),
|
)
|
||||||
|
.to_value(),
|
||||||
),
|
),
|
||||||
96 => Some(
|
96 => Some(
|
||||||
gst::Caps::new_simple(
|
gst::Caps::new_simple(
|
||||||
|
@ -182,7 +183,8 @@ fn example_main() -> Result<(), Error> {
|
||||||
("clock-rate", &90000i32),
|
("clock-rate", &90000i32),
|
||||||
("encoding-name", &"VP8"),
|
("encoding-name", &"VP8"),
|
||||||
],
|
],
|
||||||
).to_value(),
|
)
|
||||||
|
.to_value(),
|
||||||
),
|
),
|
||||||
_ => None,
|
_ => None,
|
||||||
}
|
}
|
||||||
|
@ -266,17 +268,20 @@ fn example_main() -> Result<(), Error> {
|
||||||
error: err.get_error().description().into(),
|
error: err.get_error().description().into(),
|
||||||
debug: err.get_debug(),
|
debug: err.get_debug(),
|
||||||
cause: err.get_error(),
|
cause: err.get_error(),
|
||||||
}.into());
|
}
|
||||||
|
.into());
|
||||||
}
|
}
|
||||||
MessageView::StateChanged(s) => match msg.get_src() {
|
MessageView::StateChanged(s) => match msg.get_src() {
|
||||||
Some(element) => if element == pipeline && s.get_current() == gst::State::Playing {
|
Some(element) => {
|
||||||
eprintln!("PLAYING");
|
if element == pipeline && s.get_current() == gst::State::Playing {
|
||||||
gst::debug_bin_to_dot_file(
|
eprintln!("PLAYING");
|
||||||
&pipeline,
|
gst::debug_bin_to_dot_file(
|
||||||
gst::DebugGraphDetails::all(),
|
&pipeline,
|
||||||
"client-playing",
|
gst::DebugGraphDetails::all(),
|
||||||
);
|
"client-playing",
|
||||||
},
|
);
|
||||||
|
}
|
||||||
|
}
|
||||||
None => (),
|
None => (),
|
||||||
},
|
},
|
||||||
_ => (),
|
_ => (),
|
||||||
|
|
|
@ -199,17 +199,20 @@ fn example_main() -> Result<(), Error> {
|
||||||
error: err.get_error().description().into(),
|
error: err.get_error().description().into(),
|
||||||
debug: err.get_debug(),
|
debug: err.get_debug(),
|
||||||
cause: err.get_error(),
|
cause: err.get_error(),
|
||||||
}.into());
|
}
|
||||||
|
.into());
|
||||||
}
|
}
|
||||||
MessageView::StateChanged(s) => match msg.get_src() {
|
MessageView::StateChanged(s) => match msg.get_src() {
|
||||||
Some(element) => if element == pipeline && s.get_current() == gst::State::Playing {
|
Some(element) => {
|
||||||
eprintln!("PLAYING");
|
if element == pipeline && s.get_current() == gst::State::Playing {
|
||||||
gst::debug_bin_to_dot_file(
|
eprintln!("PLAYING");
|
||||||
&pipeline,
|
gst::debug_bin_to_dot_file(
|
||||||
gst::DebugGraphDetails::all(),
|
&pipeline,
|
||||||
"server-playing",
|
gst::DebugGraphDetails::all(),
|
||||||
);
|
"server-playing",
|
||||||
},
|
);
|
||||||
|
}
|
||||||
|
}
|
||||||
None => (),
|
None => (),
|
||||||
},
|
},
|
||||||
_ => (),
|
_ => (),
|
||||||
|
|
|
@ -31,7 +31,8 @@ impl NetClientClock {
|
||||||
remote_address.to_glib_none().0,
|
remote_address.to_glib_none().0,
|
||||||
remote_port,
|
remote_port,
|
||||||
base_time.to_glib(),
|
base_time.to_glib(),
|
||||||
)).downcast_unchecked()
|
))
|
||||||
|
.downcast_unchecked()
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
// Workaround for bad floating reference handling in 1.12. This issue was fixed for 1.13
|
// Workaround for bad floating reference handling in 1.12. This issue was fixed for 1.13
|
||||||
|
@ -41,7 +42,8 @@ impl NetClientClock {
|
||||||
remote_address.to_glib_none().0,
|
remote_address.to_glib_none().0,
|
||||||
remote_port,
|
remote_port,
|
||||||
base_time.to_glib(),
|
base_time.to_glib(),
|
||||||
)).downcast_unchecked()
|
))
|
||||||
|
.downcast_unchecked()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -31,7 +31,8 @@ impl NtpClock {
|
||||||
remote_address.to_glib_none().0,
|
remote_address.to_glib_none().0,
|
||||||
remote_port,
|
remote_port,
|
||||||
base_time.to_glib(),
|
base_time.to_glib(),
|
||||||
)).downcast_unchecked()
|
))
|
||||||
|
.downcast_unchecked()
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
// Workaround for bad floating reference handling in 1.12. This issue was fixed for 1.13
|
// Workaround for bad floating reference handling in 1.12. This issue was fixed for 1.13
|
||||||
|
@ -41,7 +42,8 @@ impl NtpClock {
|
||||||
remote_address.to_glib_none().0,
|
remote_address.to_glib_none().0,
|
||||||
remote_port,
|
remote_port,
|
||||||
base_time.to_glib(),
|
base_time.to_glib(),
|
||||||
)).downcast_unchecked()
|
))
|
||||||
|
.downcast_unchecked()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -31,7 +31,8 @@ impl PtpClock {
|
||||||
remote_address.to_glib_none().0,
|
remote_address.to_glib_none().0,
|
||||||
remote_port,
|
remote_port,
|
||||||
base_time.to_glib(),
|
base_time.to_glib(),
|
||||||
)).downcast_unchecked()
|
))
|
||||||
|
.downcast_unchecked()
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
// Workaround for bad floating reference handling in 1.12. This issue was fixed for 1.13
|
// Workaround for bad floating reference handling in 1.12. This issue was fixed for 1.13
|
||||||
|
@ -41,7 +42,8 @@ impl PtpClock {
|
||||||
remote_address.to_glib_none().0,
|
remote_address.to_glib_none().0,
|
||||||
remote_port,
|
remote_port,
|
||||||
base_time.to_glib(),
|
base_time.to_glib(),
|
||||||
)).downcast_unchecked()
|
))
|
||||||
|
.downcast_unchecked()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -117,7 +117,8 @@ mod tests {
|
||||||
" ),",
|
" ),",
|
||||||
" buffer: \"AQIDBA==\",",
|
" buffer: \"AQIDBA==\",",
|
||||||
")"
|
")"
|
||||||
).to_owned()),
|
)
|
||||||
|
.to_owned()),
|
||||||
res
|
res
|
||||||
);
|
);
|
||||||
|
|
||||||
|
@ -133,7 +134,8 @@ mod tests {
|
||||||
"\"flags\":{\"bits\":1048592},",
|
"\"flags\":{\"bits\":1048592},",
|
||||||
"\"buffer\":[1,2,3,4]",
|
"\"buffer\":[1,2,3,4]",
|
||||||
"}"
|
"}"
|
||||||
).to_owned(),
|
)
|
||||||
|
.to_owned(),
|
||||||
res
|
res
|
||||||
);
|
);
|
||||||
|
|
||||||
|
|
|
@ -131,7 +131,8 @@ mod tests {
|
||||||
" buffer: \"BQY=\",",
|
" buffer: \"BQY=\",",
|
||||||
" ),",
|
" ),",
|
||||||
"]"
|
"]"
|
||||||
).to_owned()),
|
)
|
||||||
|
.to_owned()),
|
||||||
res,
|
res,
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
|
@ -579,7 +579,8 @@ mod tests {
|
||||||
("fraction", &Fraction::new(1, 2)),
|
("fraction", &Fraction::new(1, 2)),
|
||||||
("array", &Array::new(&[&1, &2])),
|
("array", &Array::new(&[&1, &2])),
|
||||||
],
|
],
|
||||||
).as_ref()
|
)
|
||||||
|
.as_ref()
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
assert!(
|
assert!(
|
||||||
|
|
|
@ -264,7 +264,8 @@ mod tests {
|
||||||
" ]),",
|
" ]),",
|
||||||
" ]), None),",
|
" ]), None),",
|
||||||
"])"
|
"])"
|
||||||
).to_owned()),
|
)
|
||||||
|
.to_owned()),
|
||||||
res,
|
res,
|
||||||
);
|
);
|
||||||
|
|
||||||
|
@ -298,7 +299,8 @@ mod tests {
|
||||||
" \"foo:baz\",",
|
" \"foo:baz\",",
|
||||||
" ]))),",
|
" ]))),",
|
||||||
"])"
|
"])"
|
||||||
).to_owned()),
|
)
|
||||||
|
.to_owned()),
|
||||||
res,
|
res,
|
||||||
);
|
);
|
||||||
|
|
||||||
|
@ -329,7 +331,8 @@ mod tests {
|
||||||
" ]),",
|
" ]),",
|
||||||
" ]), Some(Any)),",
|
" ]), Some(Any)),",
|
||||||
"])"
|
"])"
|
||||||
).to_owned()),
|
)
|
||||||
|
.to_owned()),
|
||||||
res,
|
res,
|
||||||
);
|
);
|
||||||
|
|
||||||
|
@ -385,7 +388,8 @@ mod tests {
|
||||||
("fraction", &Fraction::new(1, 2)),
|
("fraction", &Fraction::new(1, 2)),
|
||||||
("array", &Array::new(&[&1, &2])),
|
("array", &Array::new(&[&1, &2])),
|
||||||
],
|
],
|
||||||
).as_ref()
|
)
|
||||||
|
.as_ref()
|
||||||
);
|
);
|
||||||
|
|
||||||
let caps_ron = r#"
|
let caps_ron = r#"
|
||||||
|
@ -417,7 +421,8 @@ mod tests {
|
||||||
("fraction", &Fraction::new(1, 2)),
|
("fraction", &Fraction::new(1, 2)),
|
||||||
("array", &Array::new(&[&1, &2])),
|
("array", &Array::new(&[&1, &2])),
|
||||||
],
|
],
|
||||||
).as_ref()
|
)
|
||||||
|
.as_ref()
|
||||||
);
|
);
|
||||||
let f = caps.get_features(0).unwrap();
|
let f = caps.get_features(0).unwrap();
|
||||||
assert!(f.is_equal(CapsFeatures::new(&["foo:bar", "foo:baz"]).as_ref()));
|
assert!(f.is_equal(CapsFeatures::new(&["foo:bar", "foo:baz"]).as_ref()));
|
||||||
|
@ -451,7 +456,8 @@ mod tests {
|
||||||
("fraction", &Fraction::new(1, 2)),
|
("fraction", &Fraction::new(1, 2)),
|
||||||
("array", &Array::new(&[&1, &2])),
|
("array", &Array::new(&[&1, &2])),
|
||||||
],
|
],
|
||||||
).as_ref()
|
)
|
||||||
|
.as_ref()
|
||||||
);
|
);
|
||||||
let f = caps.get_features(0).unwrap();
|
let f = caps.get_features(0).unwrap();
|
||||||
assert!(f.is_any());
|
assert!(f.is_any());
|
||||||
|
|
|
@ -43,7 +43,8 @@ unsafe extern "C" fn trampoline_wait_async(
|
||||||
&from_glib_borrow(clock),
|
&from_glib_borrow(clock),
|
||||||
from_glib(time),
|
from_glib(time),
|
||||||
&from_glib_borrow(id),
|
&from_glib_borrow(id),
|
||||||
).to_glib()
|
)
|
||||||
|
.to_glib()
|
||||||
}
|
}
|
||||||
|
|
||||||
unsafe extern "C" fn destroy_closure_wait_async(ptr: gpointer) {
|
unsafe extern "C" fn destroy_closure_wait_async(ptr: gpointer) {
|
||||||
|
|
|
@ -452,7 +452,8 @@ impl fmt::Debug for EventRef {
|
||||||
.field("type", &unsafe {
|
.field("type", &unsafe {
|
||||||
let type_ = ffi::gst_event_type_get_name((*self.as_ptr()).type_);
|
let type_ = ffi::gst_event_type_get_name((*self.as_ptr()).type_);
|
||||||
CStr::from_ptr(type_).to_str().unwrap()
|
CStr::from_ptr(type_).to_str().unwrap()
|
||||||
}).field("seqnum", &self.get_seqnum())
|
})
|
||||||
|
.field("seqnum", &self.get_seqnum())
|
||||||
.field("structure", &self.get_structure())
|
.field("structure", &self.get_structure())
|
||||||
.finish()
|
.finish()
|
||||||
}
|
}
|
||||||
|
|
|
@ -40,7 +40,8 @@ impl GhostPad {
|
||||||
name.0,
|
name.0,
|
||||||
target.to_glib_none().0,
|
target.to_glib_none().0,
|
||||||
templ.to_glib_none().0,
|
templ.to_glib_none().0,
|
||||||
)).map(|o| Downcast::downcast_unchecked(o))
|
))
|
||||||
|
.map(|o| Downcast::downcast_unchecked(o))
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -384,7 +384,8 @@ unsafe extern "C" fn filter_boxed_get_type<T: StaticType + 'static>() -> glib_ff
|
||||||
"GstRsIteratorFilterBoxed-{}-{}",
|
"GstRsIteratorFilterBoxed-{}-{}",
|
||||||
T::static_type().name(),
|
T::static_type().name(),
|
||||||
idx
|
idx
|
||||||
)).unwrap();
|
))
|
||||||
|
.unwrap();
|
||||||
if gobject_ffi::g_type_from_name(type_name.as_ptr()) == gobject_ffi::G_TYPE_INVALID
|
if gobject_ffi::g_type_from_name(type_name.as_ptr()) == gobject_ffi::G_TYPE_INVALID
|
||||||
{
|
{
|
||||||
break type_name;
|
break type_name;
|
||||||
|
|
|
@ -348,7 +348,8 @@ impl fmt::Debug for MessageRef {
|
||||||
.field("type", &unsafe {
|
.field("type", &unsafe {
|
||||||
let type_ = ffi::gst_message_type_get_name((*self.as_ptr()).type_);
|
let type_ = ffi::gst_message_type_get_name((*self.as_ptr()).type_);
|
||||||
CStr::from_ptr(type_).to_str().unwrap()
|
CStr::from_ptr(type_).to_str().unwrap()
|
||||||
}).field("seqnum", &self.get_seqnum())
|
})
|
||||||
|
.field("seqnum", &self.get_seqnum())
|
||||||
.field("src", &self.get_src().map(|s| s.get_name()))
|
.field("src", &self.get_src().map(|s| s.get_name()))
|
||||||
.field("structure", &self.get_structure())
|
.field("structure", &self.get_structure())
|
||||||
.finish()
|
.finish()
|
||||||
|
@ -1092,7 +1093,8 @@ impl<'a> StreamsSelected<'a> {
|
||||||
self.as_mut_ptr(),
|
self.as_mut_ptr(),
|
||||||
i,
|
i,
|
||||||
))
|
))
|
||||||
}).collect()
|
})
|
||||||
|
.collect()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -1129,7 +1131,8 @@ impl<'a> Redirect<'a> {
|
||||||
from_glib_none(tags),
|
from_glib_none(tags),
|
||||||
structure,
|
structure,
|
||||||
)
|
)
|
||||||
}).collect()
|
})
|
||||||
|
.collect()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -60,7 +60,8 @@ impl<O: IsA<::Object> + IsA<glib::Object> + glib::value::SetValue> GstObjectExtM
|
||||||
f(&obj, &prop_obj, &pspec);
|
f(&obj, &prop_obj, &pspec);
|
||||||
|
|
||||||
None
|
None
|
||||||
}).unwrap()
|
})
|
||||||
|
.unwrap()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -1023,7 +1023,8 @@ unsafe extern "C" fn trampoline_activatemode_function(
|
||||||
&from_glib_borrow(parent),
|
&from_glib_borrow(parent),
|
||||||
from_glib(mode),
|
from_glib(mode),
|
||||||
from_glib(active),
|
from_glib(active),
|
||||||
).to_glib()
|
)
|
||||||
|
.to_glib()
|
||||||
}
|
}
|
||||||
|
|
||||||
unsafe extern "C" fn trampoline_chain_function(
|
unsafe extern "C" fn trampoline_chain_function(
|
||||||
|
@ -1041,7 +1042,8 @@ unsafe extern "C" fn trampoline_chain_function(
|
||||||
&from_glib_borrow(pad),
|
&from_glib_borrow(pad),
|
||||||
&from_glib_borrow(parent),
|
&from_glib_borrow(parent),
|
||||||
from_glib_full(buffer),
|
from_glib_full(buffer),
|
||||||
).to_glib()
|
)
|
||||||
|
.to_glib()
|
||||||
}
|
}
|
||||||
|
|
||||||
unsafe extern "C" fn trampoline_chain_list_function(
|
unsafe extern "C" fn trampoline_chain_list_function(
|
||||||
|
@ -1059,7 +1061,8 @@ unsafe extern "C" fn trampoline_chain_list_function(
|
||||||
&from_glib_borrow(pad),
|
&from_glib_borrow(pad),
|
||||||
&from_glib_borrow(parent),
|
&from_glib_borrow(parent),
|
||||||
from_glib_full(list),
|
from_glib_full(list),
|
||||||
).to_glib()
|
)
|
||||||
|
.to_glib()
|
||||||
}
|
}
|
||||||
|
|
||||||
unsafe extern "C" fn trampoline_event_function(
|
unsafe extern "C" fn trampoline_event_function(
|
||||||
|
@ -1075,7 +1078,8 @@ unsafe extern "C" fn trampoline_event_function(
|
||||||
&from_glib_borrow(pad),
|
&from_glib_borrow(pad),
|
||||||
&from_glib_borrow(parent),
|
&from_glib_borrow(parent),
|
||||||
from_glib_full(event),
|
from_glib_full(event),
|
||||||
).to_glib()
|
)
|
||||||
|
.to_glib()
|
||||||
}
|
}
|
||||||
|
|
||||||
unsafe extern "C" fn trampoline_event_full_function(
|
unsafe extern "C" fn trampoline_event_full_function(
|
||||||
|
@ -1093,7 +1097,8 @@ unsafe extern "C" fn trampoline_event_full_function(
|
||||||
&from_glib_borrow(pad),
|
&from_glib_borrow(pad),
|
||||||
&from_glib_borrow(parent),
|
&from_glib_borrow(parent),
|
||||||
from_glib_full(event),
|
from_glib_full(event),
|
||||||
).to_glib()
|
)
|
||||||
|
.to_glib()
|
||||||
}
|
}
|
||||||
|
|
||||||
unsafe extern "C" fn trampoline_getrange_function(
|
unsafe extern "C" fn trampoline_getrange_function(
|
||||||
|
@ -1154,7 +1159,8 @@ unsafe extern "C" fn trampoline_link_function(
|
||||||
&from_glib_borrow(pad),
|
&from_glib_borrow(pad),
|
||||||
&from_glib_borrow(parent),
|
&from_glib_borrow(parent),
|
||||||
&from_glib_borrow(peer),
|
&from_glib_borrow(peer),
|
||||||
).to_glib()
|
)
|
||||||
|
.to_glib()
|
||||||
}
|
}
|
||||||
|
|
||||||
unsafe extern "C" fn trampoline_query_function(
|
unsafe extern "C" fn trampoline_query_function(
|
||||||
|
@ -1172,7 +1178,8 @@ unsafe extern "C" fn trampoline_query_function(
|
||||||
&from_glib_borrow(pad),
|
&from_glib_borrow(pad),
|
||||||
&from_glib_borrow(parent),
|
&from_glib_borrow(parent),
|
||||||
::QueryRef::from_mut_ptr(query),
|
::QueryRef::from_mut_ptr(query),
|
||||||
).to_glib()
|
)
|
||||||
|
.to_glib()
|
||||||
}
|
}
|
||||||
|
|
||||||
unsafe extern "C" fn trampoline_unlink_function(
|
unsafe extern "C" fn trampoline_unlink_function(
|
||||||
|
@ -1276,7 +1283,8 @@ mod tests {
|
||||||
sender.send(i).unwrap();
|
sender.send(i).unwrap();
|
||||||
pad_clone.pause_task().unwrap();
|
pad_clone.pause_task().unwrap();
|
||||||
}
|
}
|
||||||
}).unwrap();
|
})
|
||||||
|
.unwrap();
|
||||||
|
|
||||||
assert_eq!(receiver.recv().unwrap(), 3);
|
assert_eq!(receiver.recv().unwrap(), 3);
|
||||||
}
|
}
|
||||||
|
|
|
@ -209,7 +209,8 @@ impl fmt::Debug for QueryRef {
|
||||||
.field("type", &unsafe {
|
.field("type", &unsafe {
|
||||||
let type_ = ffi::gst_query_type_get_name((*self.as_ptr()).type_);
|
let type_ = ffi::gst_query_type_get_name((*self.as_ptr()).type_);
|
||||||
CStr::from_ptr(type_).to_str().unwrap()
|
CStr::from_ptr(type_).to_str().unwrap()
|
||||||
}).field("structure", &self.get_structure())
|
})
|
||||||
|
.field("structure", &self.get_structure())
|
||||||
.finish()
|
.finish()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -173,7 +173,8 @@ mod tests {
|
||||||
" (\"f3\", \"i32\", 123),",
|
" (\"f3\", \"i32\", 123),",
|
||||||
" ])),",
|
" ])),",
|
||||||
")"
|
")"
|
||||||
).to_owned()),
|
)
|
||||||
|
.to_owned()),
|
||||||
res
|
res
|
||||||
);
|
);
|
||||||
|
|
||||||
|
@ -225,7 +226,8 @@ mod tests {
|
||||||
" )),",
|
" )),",
|
||||||
" info: None,",
|
" info: None,",
|
||||||
")"
|
")"
|
||||||
).to_owned()),
|
)
|
||||||
|
.to_owned()),
|
||||||
res
|
res
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
|
@ -158,7 +158,8 @@ mod tests {
|
||||||
" position: 256,",
|
" position: 256,",
|
||||||
" duration: -1,",
|
" duration: -1,",
|
||||||
")"
|
")"
|
||||||
).to_owned()),
|
)
|
||||||
|
.to_owned()),
|
||||||
res,
|
res,
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
|
@ -197,7 +197,8 @@ mod tests {
|
||||||
" (\"i32\", 2),",
|
" (\"i32\", 2),",
|
||||||
" ]),",
|
" ]),",
|
||||||
"])"
|
"])"
|
||||||
).to_owned()),
|
)
|
||||||
|
.to_owned()),
|
||||||
res,
|
res,
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
@ -229,7 +230,8 @@ mod tests {
|
||||||
("fraction", &Fraction::new(1, 2)),
|
("fraction", &Fraction::new(1, 2)),
|
||||||
("array", &Array::new(&[&1, &2])),
|
("array", &Array::new(&[&1, &2])),
|
||||||
],
|
],
|
||||||
).as_ref()
|
)
|
||||||
|
.as_ref()
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -336,7 +336,8 @@ mod tests {
|
||||||
" ),",
|
" ),",
|
||||||
" ]),",
|
" ]),",
|
||||||
"]",
|
"]",
|
||||||
).to_owned()),
|
)
|
||||||
|
.to_owned()),
|
||||||
res,
|
res,
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
|
@ -268,7 +268,8 @@ mod tests {
|
||||||
" ),",
|
" ),",
|
||||||
" ],",
|
" ],",
|
||||||
")",
|
")",
|
||||||
).to_owned()),
|
)
|
||||||
|
.to_owned()),
|
||||||
res,
|
res,
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
|
@ -248,8 +248,10 @@ mod tests {
|
||||||
c.get_structure(0)
|
c.get_structure(0)
|
||||||
.map(|s| s.get_name() == "application/xml")
|
.map(|s| s.get_name() == "application/xml")
|
||||||
.unwrap_or(false)
|
.unwrap_or(false)
|
||||||
}).unwrap_or(false)
|
})
|
||||||
}).unwrap();
|
.unwrap_or(false)
|
||||||
|
})
|
||||||
|
.unwrap();
|
||||||
|
|
||||||
let data = b"<?xml version=\"1.0\"?><test>test</test>";
|
let data = b"<?xml version=\"1.0\"?><test>test</test>";
|
||||||
let data = &data[..];
|
let data = &data[..];
|
||||||
|
|
|
@ -348,7 +348,8 @@ mod tests {
|
||||||
" (\"Fraction\", (1, 2)),",
|
" (\"Fraction\", (1, 2)),",
|
||||||
" (\"String\", \"test str\"),",
|
" (\"String\", \"test str\"),",
|
||||||
"]"
|
"]"
|
||||||
).to_owned()),
|
)
|
||||||
|
.to_owned()),
|
||||||
res,
|
res,
|
||||||
);
|
);
|
||||||
|
|
||||||
|
@ -374,7 +375,8 @@ mod tests {
|
||||||
" (\"Fraction\", (1, 2)),",
|
" (\"Fraction\", (1, 2)),",
|
||||||
" (\"String\", \"test str\"),",
|
" (\"String\", \"test str\"),",
|
||||||
"]"
|
"]"
|
||||||
).to_owned()),
|
)
|
||||||
|
.to_owned()),
|
||||||
res,
|
res,
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
|
@ -82,7 +82,8 @@ fn tutorial_main() {
|
||||||
.seek_simple(
|
.seek_simple(
|
||||||
gst::SeekFlags::FLUSH | gst::SeekFlags::KEY_UNIT,
|
gst::SeekFlags::FLUSH | gst::SeekFlags::KEY_UNIT,
|
||||||
30 * gst::SECOND,
|
30 * gst::SECOND,
|
||||||
).expect("Failed to seek.");
|
)
|
||||||
|
.expect("Failed to seek.");
|
||||||
custom_data.seek_done = true;
|
custom_data.seek_done = true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -114,35 +115,37 @@ fn handle_message(custom_data: &mut CustomData, msg: &gst::GstRc<gst::MessageRef
|
||||||
// The duration has changed, mark the current one as invalid
|
// The duration has changed, mark the current one as invalid
|
||||||
custom_data.duration = gst::CLOCK_TIME_NONE;
|
custom_data.duration = gst::CLOCK_TIME_NONE;
|
||||||
}
|
}
|
||||||
MessageView::StateChanged(state_changed) => if state_changed
|
MessageView::StateChanged(state_changed) => {
|
||||||
.get_src()
|
if state_changed
|
||||||
.map(|s| s == custom_data.playbin)
|
.get_src()
|
||||||
.unwrap_or(false)
|
.map(|s| s == custom_data.playbin)
|
||||||
{
|
.unwrap_or(false)
|
||||||
let new_state = state_changed.get_current();
|
{
|
||||||
let old_state = state_changed.get_old();
|
let new_state = state_changed.get_current();
|
||||||
|
let old_state = state_changed.get_old();
|
||||||
|
|
||||||
println!(
|
println!(
|
||||||
"Pipeline state changed from {:?} to {:?}",
|
"Pipeline state changed from {:?} to {:?}",
|
||||||
old_state, new_state
|
old_state, new_state
|
||||||
);
|
);
|
||||||
|
|
||||||
custom_data.playing = new_state == gst::State::Playing;
|
custom_data.playing = new_state == gst::State::Playing;
|
||||||
if custom_data.playing {
|
if custom_data.playing {
|
||||||
let mut seeking = gst::Query::new_seeking(gst::Format::Time);
|
let mut seeking = gst::Query::new_seeking(gst::Format::Time);
|
||||||
if custom_data.playbin.query(&mut seeking) {
|
if custom_data.playbin.query(&mut seeking) {
|
||||||
let (seekable, start, end) = seeking.get_result();
|
let (seekable, start, end) = seeking.get_result();
|
||||||
custom_data.seek_enabled = seekable;
|
custom_data.seek_enabled = seekable;
|
||||||
if seekable {
|
if seekable {
|
||||||
println!("Seeking is ENABLED from {:?} to {:?}", start, end)
|
println!("Seeking is ENABLED from {:?} to {:?}", start, end)
|
||||||
|
} else {
|
||||||
|
println!("Seeking is DISABLED for this stream.")
|
||||||
|
}
|
||||||
} else {
|
} else {
|
||||||
println!("Seeking is DISABLED for this stream.")
|
eprintln!("Seeking query failed.")
|
||||||
}
|
}
|
||||||
} else {
|
|
||||||
eprintln!("Seeking query failed.")
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
},
|
}
|
||||||
_ => (),
|
_ => (),
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -50,35 +50,43 @@ mod tutorial5 {
|
||||||
let signame: &str = &format!("get-{}-tags", stype);
|
let signame: &str = &format!("get-{}-tags", stype);
|
||||||
|
|
||||||
match playbin.get_property(propname).unwrap().get() {
|
match playbin.get_property(propname).unwrap().get() {
|
||||||
Some(x) => for i in 0..x {
|
Some(x) => {
|
||||||
let tags = playbin.emit(signame, &[&i]).unwrap().unwrap();
|
for i in 0..x {
|
||||||
|
let tags = playbin.emit(signame, &[&i]).unwrap().unwrap();
|
||||||
|
|
||||||
if let Some(tags) = tags.get::<gst::TagList>() {
|
if let Some(tags) = tags.get::<gst::TagList>() {
|
||||||
textbuf.insert_at_cursor(&format!("{} stream {}:\n ", stype, i));
|
textbuf.insert_at_cursor(&format!("{} stream {}:\n ", stype, i));
|
||||||
|
|
||||||
if let Some(codec) = tags.get::<gst::tags::VideoCodec>() {
|
if let Some(codec) = tags.get::<gst::tags::VideoCodec>() {
|
||||||
textbuf
|
textbuf.insert_at_cursor(&format!(
|
||||||
.insert_at_cursor(&format!(" codec: {} \n", codec.get().unwrap()));
|
" codec: {} \n",
|
||||||
}
|
codec.get().unwrap()
|
||||||
|
));
|
||||||
|
}
|
||||||
|
|
||||||
if let Some(codec) = tags.get::<gst::tags::AudioCodec>() {
|
if let Some(codec) = tags.get::<gst::tags::AudioCodec>() {
|
||||||
textbuf
|
textbuf.insert_at_cursor(&format!(
|
||||||
.insert_at_cursor(&format!(" codec: {} \n", codec.get().unwrap()));
|
" codec: {} \n",
|
||||||
}
|
codec.get().unwrap()
|
||||||
|
));
|
||||||
|
}
|
||||||
|
|
||||||
if let Some(lang) = tags.get::<gst::tags::LanguageCode>() {
|
if let Some(lang) = tags.get::<gst::tags::LanguageCode>() {
|
||||||
textbuf
|
textbuf.insert_at_cursor(&format!(
|
||||||
.insert_at_cursor(&format!(" language: {} \n", lang.get().unwrap()));
|
" language: {} \n",
|
||||||
}
|
lang.get().unwrap()
|
||||||
|
));
|
||||||
|
}
|
||||||
|
|
||||||
if let Some(bitrate) = tags.get::<gst::tags::Bitrate>() {
|
if let Some(bitrate) = tags.get::<gst::tags::Bitrate>() {
|
||||||
textbuf.insert_at_cursor(&format!(
|
textbuf.insert_at_cursor(&format!(
|
||||||
" bitrate: {} \n",
|
" bitrate: {} \n",
|
||||||
bitrate.get().unwrap()
|
bitrate.get().unwrap()
|
||||||
));
|
));
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
},
|
}
|
||||||
None => {
|
None => {
|
||||||
eprintln!("Could not get {}!", propname);
|
eprintln!("Could not get {}!", propname);
|
||||||
}
|
}
|
||||||
|
@ -328,21 +336,24 @@ mod tutorial5 {
|
||||||
let pipeline = args[0].get::<gst::Element>().unwrap();
|
let pipeline = args[0].get::<gst::Element>().unwrap();
|
||||||
post_app_message(&pipeline);
|
post_app_message(&pipeline);
|
||||||
None
|
None
|
||||||
}).unwrap();
|
})
|
||||||
|
.unwrap();
|
||||||
|
|
||||||
playbin
|
playbin
|
||||||
.connect("audio-tags-changed", false, |args| {
|
.connect("audio-tags-changed", false, |args| {
|
||||||
let pipeline = args[0].get::<gst::Element>().unwrap();
|
let pipeline = args[0].get::<gst::Element>().unwrap();
|
||||||
post_app_message(&pipeline);
|
post_app_message(&pipeline);
|
||||||
None
|
None
|
||||||
}).unwrap();
|
})
|
||||||
|
.unwrap();
|
||||||
|
|
||||||
playbin
|
playbin
|
||||||
.connect("text-tags-changed", false, move |args| {
|
.connect("text-tags-changed", false, move |args| {
|
||||||
let pipeline = args[0].get::<gst::Element>().unwrap();
|
let pipeline = args[0].get::<gst::Element>().unwrap();
|
||||||
post_app_message(&pipeline);
|
post_app_message(&pipeline);
|
||||||
None
|
None
|
||||||
}).unwrap();
|
})
|
||||||
|
.unwrap();
|
||||||
|
|
||||||
let window = create_ui(&playbin);
|
let window = create_ui(&playbin);
|
||||||
|
|
||||||
|
|
|
@ -40,7 +40,8 @@ fn tutorial_main() {
|
||||||
&visual,
|
&visual,
|
||||||
&video_convert,
|
&video_convert,
|
||||||
&video_sink,
|
&video_sink,
|
||||||
]).unwrap();
|
])
|
||||||
|
.unwrap();
|
||||||
|
|
||||||
gst::Element::link_many(&[&audio_source, &tee]).unwrap();
|
gst::Element::link_many(&[&audio_source, &tee]).unwrap();
|
||||||
gst::Element::link_many(&[&audio_queue, &audio_convert, &audio_resample, &audio_sink]).unwrap();
|
gst::Element::link_many(&[&audio_queue, &audio_convert, &audio_resample, &audio_sink]).unwrap();
|
||||||
|
|
|
@ -86,7 +86,8 @@ fn main() {
|
||||||
&video_sink,
|
&video_sink,
|
||||||
&app_queue,
|
&app_queue,
|
||||||
&appsink,
|
&appsink,
|
||||||
]).unwrap();
|
])
|
||||||
|
.unwrap();
|
||||||
|
|
||||||
gst::Element::link_many(&[&appsrc, &tee]).unwrap();
|
gst::Element::link_many(&[&appsrc, &tee]).unwrap();
|
||||||
gst::Element::link_many(&[&audio_queue, &audio_convert1, &audio_resample, &audio_sink])
|
gst::Element::link_many(&[&audio_queue, &audio_convert1, &audio_resample, &audio_sink])
|
||||||
|
@ -97,7 +98,8 @@ fn main() {
|
||||||
&visual,
|
&visual,
|
||||||
&video_convert,
|
&video_convert,
|
||||||
&video_sink,
|
&video_sink,
|
||||||
]).unwrap();
|
])
|
||||||
|
.unwrap();
|
||||||
gst::Element::link_many(&[&app_queue, &appsink]).unwrap();
|
gst::Element::link_many(&[&app_queue, &appsink]).unwrap();
|
||||||
|
|
||||||
let tee_audio_pad = tee.get_request_pad("src_%u").unwrap();
|
let tee_audio_pad = tee.get_request_pad("src_%u").unwrap();
|
||||||
|
|
Loading…
Reference in a new issue