mirror of
https://gitlab.freedesktop.org/gstreamer/gstreamer-rs.git
synced 2024-11-25 11:01:10 +00:00
fix-getters-calls 0.3.0 pass
This commit is contained in:
parent
e80a29372a
commit
6ab9164dca
66 changed files with 288 additions and 323 deletions
|
@ -59,8 +59,8 @@ fn example_main() {
|
||||||
.expect("Unable to set the pipeline to the `Playing` state");
|
.expect("Unable to set the pipeline to the `Playing` state");
|
||||||
let pipeline = pipeline.dynamic_cast::<gst::Pipeline>().unwrap();
|
let pipeline = pipeline.dynamic_cast::<gst::Pipeline>().unwrap();
|
||||||
|
|
||||||
let sink = pipeline.get_by_name("sink").unwrap();
|
let sink = pipeline.by_name("sink").unwrap();
|
||||||
let sinkpad = sink.get_static_pad("sink").unwrap();
|
let sinkpad = sink.static_pad("sink").unwrap();
|
||||||
|
|
||||||
// Need to move a new reference into the closure.
|
// Need to move a new reference into the closure.
|
||||||
// !!ATTENTION!!:
|
// !!ATTENTION!!:
|
||||||
|
|
|
@ -243,7 +243,7 @@ fn example_main() {
|
||||||
|
|
||||||
// Retrieve the custom meta from the buffer and print it.
|
// Retrieve the custom meta from the buffer and print it.
|
||||||
let meta = buffer
|
let meta = buffer
|
||||||
.get_meta::<custom_meta::CustomMeta>()
|
.meta::<custom_meta::CustomMeta>()
|
||||||
.expect("No custom meta found");
|
.expect("No custom meta found");
|
||||||
println!("Got buffer with label: {}", meta.label());
|
println!("Got buffer with label: {}", meta.label());
|
||||||
|
|
||||||
|
|
|
@ -112,7 +112,7 @@ fn example_main() -> Result<(), Error> {
|
||||||
// just now is either audio or video (or none of both, e.g. subtitles).
|
// just now is either audio or video (or none of both, e.g. subtitles).
|
||||||
let (is_audio, is_video) = {
|
let (is_audio, is_video) = {
|
||||||
let media_type = src_pad.current_caps().and_then(|caps| {
|
let media_type = src_pad.current_caps().and_then(|caps| {
|
||||||
caps.get_structure(0).map(|s| {
|
caps.structure(0).map(|s| {
|
||||||
let name = s.name();
|
let name = s.name();
|
||||||
(name.starts_with("audio/"), name.starts_with("video/"))
|
(name.starts_with("audio/"), name.starts_with("video/"))
|
||||||
})
|
})
|
||||||
|
@ -163,7 +163,7 @@ fn example_main() -> Result<(), Error> {
|
||||||
|
|
||||||
// Get the queue element's sink pad and link the decodebin's newly created
|
// Get the queue element's sink pad and link the decodebin's newly created
|
||||||
// src pad for the audio stream to it.
|
// src pad for the audio stream to it.
|
||||||
let sink_pad = queue.get_static_pad("sink").expect("queue has no sinkpad");
|
let sink_pad = queue.static_pad("sink").expect("queue has no sinkpad");
|
||||||
src_pad.link(&sink_pad)?;
|
src_pad.link(&sink_pad)?;
|
||||||
} else if is_video {
|
} else if is_video {
|
||||||
// decodebin found a raw videostream, so we build the follow-up pipeline to
|
// decodebin found a raw videostream, so we build the follow-up pipeline to
|
||||||
|
@ -187,7 +187,7 @@ fn example_main() -> Result<(), Error> {
|
||||||
|
|
||||||
// Get the queue element's sink pad and link the decodebin's newly created
|
// Get the queue element's sink pad and link the decodebin's newly created
|
||||||
// src pad for the video stream to it.
|
// src pad for the video stream to it.
|
||||||
let sink_pad = queue.get_static_pad("sink").expect("queue has no sinkpad");
|
let sink_pad = queue.static_pad("sink").expect("queue has no sinkpad");
|
||||||
src_pad.link(&sink_pad)?;
|
src_pad.link(&sink_pad)?;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -146,7 +146,7 @@ fn example_main() -> Result<(), Error> {
|
||||||
|
|
||||||
let (is_audio, is_video) = {
|
let (is_audio, is_video) = {
|
||||||
let media_type = dbin_src_pad.current_caps().and_then(|caps| {
|
let media_type = dbin_src_pad.current_caps().and_then(|caps| {
|
||||||
caps.get_structure(0).map(|s| {
|
caps.structure(0).map(|s| {
|
||||||
let name = s.name();
|
let name = s.name();
|
||||||
(name.starts_with("audio/"), name.starts_with("video/"))
|
(name.starts_with("audio/"), name.starts_with("video/"))
|
||||||
})
|
})
|
||||||
|
@ -185,11 +185,9 @@ fn example_main() -> Result<(), Error> {
|
||||||
// The encodebin will then automatically create an internal pipeline, that encodes
|
// The encodebin will then automatically create an internal pipeline, that encodes
|
||||||
// the audio stream in the format we specified in the EncodingProfile.
|
// the audio stream in the format we specified in the EncodingProfile.
|
||||||
let enc_sink_pad = encodebin
|
let enc_sink_pad = encodebin
|
||||||
.get_request_pad("audio_%u")
|
.request_pad("audio_%u")
|
||||||
.expect("Could not get audio pad from encodebin");
|
.expect("Could not get audio pad from encodebin");
|
||||||
let src_pad = resample
|
let src_pad = resample.static_pad("src").expect("resample has no srcpad");
|
||||||
.get_static_pad("src")
|
|
||||||
.expect("resample has no srcpad");
|
|
||||||
src_pad.link(&enc_sink_pad)?;
|
src_pad.link(&enc_sink_pad)?;
|
||||||
|
|
||||||
for e in elements {
|
for e in elements {
|
||||||
|
@ -198,7 +196,7 @@ fn example_main() -> Result<(), Error> {
|
||||||
|
|
||||||
// Get the queue element's sink pad and link the decodebin's newly created
|
// Get the queue element's sink pad and link the decodebin's newly created
|
||||||
// src pad for the audio stream to it.
|
// src pad for the audio stream to it.
|
||||||
let sink_pad = queue.get_static_pad("sink").expect("queue has no sinkpad");
|
let sink_pad = queue.static_pad("sink").expect("queue has no sinkpad");
|
||||||
dbin_src_pad.link(&sink_pad)?;
|
dbin_src_pad.link(&sink_pad)?;
|
||||||
} else if is_video {
|
} else if is_video {
|
||||||
let queue = gst::ElementFactory::make("queue", None)
|
let queue = gst::ElementFactory::make("queue", None)
|
||||||
|
@ -218,11 +216,9 @@ fn example_main() -> Result<(), Error> {
|
||||||
// The encodebin will then automatically create an internal pipeline, that encodes
|
// The encodebin will then automatically create an internal pipeline, that encodes
|
||||||
// the audio stream in the format we specified in the EncodingProfile.
|
// the audio stream in the format we specified in the EncodingProfile.
|
||||||
let enc_sink_pad = encodebin
|
let enc_sink_pad = encodebin
|
||||||
.get_request_pad("video_%u")
|
.request_pad("video_%u")
|
||||||
.expect("Could not get video pad from encodebin");
|
.expect("Could not get video pad from encodebin");
|
||||||
let src_pad = scale
|
let src_pad = scale.static_pad("src").expect("videoscale has no srcpad");
|
||||||
.get_static_pad("src")
|
|
||||||
.expect("videoscale has no srcpad");
|
|
||||||
src_pad.link(&enc_sink_pad)?;
|
src_pad.link(&enc_sink_pad)?;
|
||||||
|
|
||||||
for e in elements {
|
for e in elements {
|
||||||
|
@ -231,7 +227,7 @@ fn example_main() -> Result<(), Error> {
|
||||||
|
|
||||||
// Get the queue element's sink pad and link the decodebin's newly created
|
// Get the queue element's sink pad and link the decodebin's newly created
|
||||||
// src pad for the video stream to it.
|
// src pad for the video stream to it.
|
||||||
let sink_pad = queue.get_static_pad("sink").expect("queue has no sinkpad");
|
let sink_pad = queue.static_pad("sink").expect("queue has no sinkpad");
|
||||||
dbin_src_pad.link(&sink_pad)?;
|
dbin_src_pad.link(&sink_pad)?;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -65,7 +65,7 @@ fn main_loop(uri: &str) -> Result<(), glib::BoolError> {
|
||||||
|
|
||||||
println!(
|
println!(
|
||||||
"Agingtv scratch-lines: {}",
|
"Agingtv scratch-lines: {}",
|
||||||
clip.get_child_property("scratch-lines")
|
clip.child_property("scratch-lines")
|
||||||
.unwrap()
|
.unwrap()
|
||||||
.serialize()
|
.serialize()
|
||||||
.unwrap()
|
.unwrap()
|
||||||
|
|
|
@ -36,7 +36,7 @@ fn create_ui(app: >k::Application) {
|
||||||
glsinkbin.set_property("sink", >kglsink).unwrap();
|
glsinkbin.set_property("sink", >kglsink).unwrap();
|
||||||
// The gtkglsink creates the gtk widget for us. This is accessible through a property.
|
// The gtkglsink creates the gtk widget for us. This is accessible through a property.
|
||||||
// So we get it and use it later to add it to our gui.
|
// So we get it and use it later to add it to our gui.
|
||||||
let widget = gtkglsink.get_property("widget").unwrap();
|
let widget = gtkglsink.property("widget").unwrap();
|
||||||
(glsinkbin, widget.get::<gtk::Widget>().unwrap().unwrap())
|
(glsinkbin, widget.get::<gtk::Widget>().unwrap().unwrap())
|
||||||
} else {
|
} else {
|
||||||
// Unfortunately, using the OpenGL widget didn't work out, so we will have to render
|
// Unfortunately, using the OpenGL widget didn't work out, so we will have to render
|
||||||
|
@ -45,7 +45,7 @@ fn create_ui(app: >k::Application) {
|
||||||
let sink = gst::ElementFactory::make("gtksink", None).unwrap();
|
let sink = gst::ElementFactory::make("gtksink", None).unwrap();
|
||||||
// The gtksink creates the gtk widget for us. This is accessible through a property.
|
// The gtksink creates the gtk widget for us. This is accessible through a property.
|
||||||
// So we get it and use it later to add it to our gui.
|
// So we get it and use it later to add it to our gui.
|
||||||
let widget = sink.get_property("widget").unwrap();
|
let widget = sink.property("widget").unwrap();
|
||||||
(sink, widget.get::<gtk::Widget>().unwrap().unwrap())
|
(sink, widget.get::<gtk::Widget>().unwrap().unwrap())
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
|
@ -31,9 +31,9 @@ fn example_main() {
|
||||||
|
|
||||||
// Get the audiotestsrc element from the pipeline that GStreamer
|
// Get the audiotestsrc element from the pipeline that GStreamer
|
||||||
// created for us while parsing the launch syntax above.
|
// created for us while parsing the launch syntax above.
|
||||||
let src = pipeline.get_by_name("src").unwrap();
|
let src = pipeline.by_name("src").unwrap();
|
||||||
// Get the audiotestsrc's src-pad.
|
// Get the audiotestsrc's src-pad.
|
||||||
let src_pad = src.get_static_pad("src").unwrap();
|
let src_pad = src.static_pad("src").unwrap();
|
||||||
// Add a probe handler on the audiotestsrc's src-pad.
|
// Add a probe handler on the audiotestsrc's src-pad.
|
||||||
// This handler gets called for every buffer that passes the pad we probe.
|
// This handler gets called for every buffer that passes the pad we probe.
|
||||||
src_pad.add_probe(gst::PadProbeType::BUFFER, |_, probe_info| {
|
src_pad.add_probe(gst::PadProbeType::BUFFER, |_, probe_info| {
|
||||||
|
|
|
@ -45,7 +45,7 @@ fn make_element(
|
||||||
}
|
}
|
||||||
|
|
||||||
fn static_pad(element: &gst::Element, pad_name: &'static str) -> Result<gst::Pad, Error> {
|
fn static_pad(element: &gst::Element, pad_name: &'static str) -> Result<gst::Pad, Error> {
|
||||||
match element.get_static_pad(pad_name) {
|
match element.static_pad(pad_name) {
|
||||||
Some(pad) => Ok(pad),
|
Some(pad) => Ok(pad),
|
||||||
None => {
|
None => {
|
||||||
let element_name = element.name();
|
let element_name = element.name();
|
||||||
|
@ -55,7 +55,7 @@ fn static_pad(element: &gst::Element, pad_name: &'static str) -> Result<gst::Pad
|
||||||
}
|
}
|
||||||
|
|
||||||
fn request_pad(element: &gst::Element, pad_name: &'static str) -> Result<gst::Pad, Error> {
|
fn request_pad(element: &gst::Element, pad_name: &'static str) -> Result<gst::Pad, Error> {
|
||||||
match element.get_request_pad(pad_name) {
|
match element.request_pad(pad_name) {
|
||||||
Some(pad) => Ok(pad),
|
Some(pad) => Ok(pad),
|
||||||
None => {
|
None => {
|
||||||
let element_name = element.name();
|
let element_name = element.name();
|
||||||
|
@ -72,7 +72,7 @@ fn connect_rtpbin_srcpad(src_pad: &gst::Pad, sink: &gst::Element) -> Result<(),
|
||||||
|
|
||||||
match pt {
|
match pt {
|
||||||
96 => {
|
96 => {
|
||||||
let sinkpad = get_static_pad(sink, "sink")?;
|
let sinkpad = static_pad(sink, "sink")?;
|
||||||
src_pad.link(&sinkpad)?;
|
src_pad.link(&sinkpad)?;
|
||||||
Ok(())
|
Ok(())
|
||||||
}
|
}
|
||||||
|
@ -206,8 +206,8 @@ fn example_main() -> Result<(), Error> {
|
||||||
}
|
}
|
||||||
})?;
|
})?;
|
||||||
|
|
||||||
let srcpad = get_static_pad(&netsim, "src")?;
|
let srcpad = static_pad(&netsim, "src")?;
|
||||||
let sinkpad = get_request_pad(&rtpbin, "recv_rtp_sink_0")?;
|
let sinkpad = request_pad(&rtpbin, "recv_rtp_sink_0")?;
|
||||||
srcpad.link(&sinkpad)?;
|
srcpad.link(&sinkpad)?;
|
||||||
|
|
||||||
let depay_weak = depay.downgrade();
|
let depay_weak = depay.downgrade();
|
||||||
|
|
|
@ -41,7 +41,7 @@ fn make_element(
|
||||||
}
|
}
|
||||||
|
|
||||||
fn static_pad(element: &gst::Element, pad_name: &'static str) -> Result<gst::Pad, Error> {
|
fn static_pad(element: &gst::Element, pad_name: &'static str) -> Result<gst::Pad, Error> {
|
||||||
match element.get_static_pad(pad_name) {
|
match element.static_pad(pad_name) {
|
||||||
Some(pad) => Ok(pad),
|
Some(pad) => Ok(pad),
|
||||||
None => {
|
None => {
|
||||||
let element_name = element.name();
|
let element_name = element.name();
|
||||||
|
@ -51,7 +51,7 @@ fn static_pad(element: &gst::Element, pad_name: &'static str) -> Result<gst::Pad
|
||||||
}
|
}
|
||||||
|
|
||||||
fn request_pad(element: &gst::Element, pad_name: &'static str) -> Result<gst::Pad, Error> {
|
fn request_pad(element: &gst::Element, pad_name: &'static str) -> Result<gst::Pad, Error> {
|
||||||
match element.get_request_pad(pad_name) {
|
match element.request_pad(pad_name) {
|
||||||
Some(pad) => Ok(pad),
|
Some(pad) => Ok(pad),
|
||||||
None => {
|
None => {
|
||||||
let element_name = element.name();
|
let element_name = element.name();
|
||||||
|
@ -61,7 +61,7 @@ fn request_pad(element: &gst::Element, pad_name: &'static str) -> Result<gst::Pa
|
||||||
}
|
}
|
||||||
|
|
||||||
fn connect_decodebin_pad(src_pad: &gst::Pad, sink: &gst::Element) -> Result<(), Error> {
|
fn connect_decodebin_pad(src_pad: &gst::Pad, sink: &gst::Element) -> Result<(), Error> {
|
||||||
let sinkpad = get_static_pad(&sink, "sink")?;
|
let sinkpad = static_pad(&sink, "sink")?;
|
||||||
src_pad.link(&sinkpad)?;
|
src_pad.link(&sinkpad)?;
|
||||||
|
|
||||||
Ok(())
|
Ok(())
|
||||||
|
@ -126,12 +126,12 @@ fn example_main() -> Result<(), Error> {
|
||||||
}
|
}
|
||||||
})?;
|
})?;
|
||||||
|
|
||||||
let srcpad = get_static_pad(&q2, "src")?;
|
let srcpad = static_pad(&q2, "src")?;
|
||||||
let sinkpad = get_request_pad(&rtpbin, "send_rtp_sink_0")?;
|
let sinkpad = request_pad(&rtpbin, "send_rtp_sink_0")?;
|
||||||
srcpad.link(&sinkpad)?;
|
srcpad.link(&sinkpad)?;
|
||||||
|
|
||||||
let srcpad = get_static_pad(&rtpbin, "send_rtp_src_0")?;
|
let srcpad = static_pad(&rtpbin, "send_rtp_src_0")?;
|
||||||
let sinkpad = get_static_pad(&sink, "sink")?;
|
let sinkpad = static_pad(&sink, "sink")?;
|
||||||
srcpad.link(&sinkpad)?;
|
srcpad.link(&sinkpad)?;
|
||||||
|
|
||||||
src.connect_pad_added(
|
src.connect_pad_added(
|
||||||
|
|
|
@ -67,7 +67,7 @@ fn example_main() -> Result<(), Error> {
|
||||||
// Query the pipeline for elements implementing the GstTagsetter interface.
|
// Query the pipeline for elements implementing the GstTagsetter interface.
|
||||||
// In our case, this will return the flacenc element.
|
// In our case, this will return the flacenc element.
|
||||||
let tagsetter = pipeline
|
let tagsetter = pipeline
|
||||||
.get_by_interface(gst::TagSetter::static_type())
|
.by_interface(gst::TagSetter::static_type())
|
||||||
.ok_or_else(|| anyhow!("No TagSetter found"))?;
|
.ok_or_else(|| anyhow!("No TagSetter found"))?;
|
||||||
let tagsetter = tagsetter
|
let tagsetter = tagsetter
|
||||||
.dynamic_cast::<gst::TagSetter>()
|
.dynamic_cast::<gst::TagSetter>()
|
||||||
|
|
|
@ -41,7 +41,7 @@ fn create_pipeline(uri: String, out_path: std::path::PathBuf) -> Result<gst::Pip
|
||||||
|
|
||||||
// Get access to the appsink element.
|
// Get access to the appsink element.
|
||||||
let appsink = pipeline
|
let appsink = pipeline
|
||||||
.get_by_name("sink")
|
.by_name("sink")
|
||||||
.expect("Sink element not found")
|
.expect("Sink element not found")
|
||||||
.downcast::<gst_app::AppSink>()
|
.downcast::<gst_app::AppSink>()
|
||||||
.expect("Sink element is expected to be an appsink!");
|
.expect("Sink element is expected to be an appsink!");
|
||||||
|
|
|
@ -70,7 +70,7 @@ fn example_main() {
|
||||||
e.sync_state_with_parent().unwrap();
|
e.sync_state_with_parent().unwrap();
|
||||||
}
|
}
|
||||||
|
|
||||||
let sink_pad = queue.get_static_pad("sink").unwrap();
|
let sink_pad = queue.static_pad("sink").unwrap();
|
||||||
src_pad
|
src_pad
|
||||||
.link(&sink_pad)
|
.link(&sink_pad)
|
||||||
.expect("Unable to link src pad to sink pad");
|
.expect("Unable to link src pad to sink pad");
|
||||||
|
|
|
@ -102,10 +102,7 @@ fn example_main() -> Result<(), Error> {
|
||||||
.get::<gst::Caps>()
|
.get::<gst::Caps>()
|
||||||
.expect("typefinder \"have-type\" signal values[2]")
|
.expect("typefinder \"have-type\" signal values[2]")
|
||||||
.expect("typefinder \"have-type\" signal values[2]: no `caps`");
|
.expect("typefinder \"have-type\" signal values[2]: no `caps`");
|
||||||
let format_name = caps
|
let format_name = caps.structure(0).expect("Failed to get format name").name();
|
||||||
.get_structure(0)
|
|
||||||
.expect("Failed to get format name")
|
|
||||||
.name();
|
|
||||||
|
|
||||||
let demuxer = match format_name {
|
let demuxer = match format_name {
|
||||||
"video/x-matroska" | "video/webm" => {
|
"video/x-matroska" | "video/webm" => {
|
||||||
|
@ -198,7 +195,7 @@ fn handle_demux_pad_added(
|
||||||
// For that, we need to request a sink pad that fits our needs.
|
// For that, we need to request a sink pad that fits our needs.
|
||||||
let link_to_muxer = || -> Result<(), Error> {
|
let link_to_muxer = || -> Result<(), Error> {
|
||||||
let queue_sink_pad = queue
|
let queue_sink_pad = queue
|
||||||
.get_request_pad("sink_%u")
|
.request_pad("sink_%u")
|
||||||
.expect("If this happened, something is terribly wrong");
|
.expect("If this happened, something is terribly wrong");
|
||||||
demux_src_pad.link(&queue_sink_pad)?;
|
demux_src_pad.link(&queue_sink_pad)?;
|
||||||
// Now that we requested a sink pad fitting our needs from the multiqueue,
|
// Now that we requested a sink pad fitting our needs from the multiqueue,
|
||||||
|
@ -213,7 +210,7 @@ fn handle_demux_pad_added(
|
||||||
// Link the multiqueue's output for this stream to the matroskamuxer.
|
// Link the multiqueue's output for this stream to the matroskamuxer.
|
||||||
// For that, we request an appropriate pad at the muxer, that fits our needs.
|
// For that, we request an appropriate pad at the muxer, that fits our needs.
|
||||||
let muxer_sink_pad = muxer
|
let muxer_sink_pad = muxer
|
||||||
.get_compatible_pad(&queue_src_pad, None)
|
.compatible_pad(&queue_src_pad, None)
|
||||||
.expect("Aww, you found a format that matroska doesn't support!");
|
.expect("Aww, you found a format that matroska doesn't support!");
|
||||||
queue_src_pad.link(&muxer_sink_pad)?;
|
queue_src_pad.link(&muxer_sink_pad)?;
|
||||||
|
|
||||||
|
|
|
@ -18,8 +18,8 @@ fn example_main() {
|
||||||
.unwrap();
|
.unwrap();
|
||||||
|
|
||||||
let pipeline = pipeline.dynamic_cast::<gst::Pipeline>().unwrap();
|
let pipeline = pipeline.dynamic_cast::<gst::Pipeline>().unwrap();
|
||||||
let compositor = pipeline.get_by_name("compositor0").unwrap();
|
let compositor = pipeline.by_name("compositor0").unwrap();
|
||||||
let sinkpad = compositor.get_static_pad("sink_0").unwrap();
|
let sinkpad = compositor.static_pad("sink_0").unwrap();
|
||||||
|
|
||||||
/* Completely contrived example that takes the 4:3 input video, cuts out a 5:4 frame
|
/* Completely contrived example that takes the 4:3 input video, cuts out a 5:4 frame
|
||||||
* and then adds pillarbox borders to place it in a 16:9 target area */
|
* and then adds pillarbox borders to place it in a 16:9 target area */
|
||||||
|
|
|
@ -53,7 +53,7 @@ where
|
||||||
{
|
{
|
||||||
use std::thread;
|
use std::thread;
|
||||||
|
|
||||||
let l = runloop::CFRunLoop::get_main();
|
let l = runloop::CFRunLoop::main();
|
||||||
let t = thread::spawn(move || {
|
let t = thread::spawn(move || {
|
||||||
let res = main();
|
let res = main();
|
||||||
l.stop();
|
l.stop();
|
||||||
|
|
|
@ -190,7 +190,7 @@ impl Gl {
|
||||||
}
|
}
|
||||||
|
|
||||||
fn load(gl_context: &glutin::WindowedContext<glutin::PossiblyCurrent>) -> Gl {
|
fn load(gl_context: &glutin::WindowedContext<glutin::PossiblyCurrent>) -> Gl {
|
||||||
let gl = gl::Gl::load_with(|ptr| gl_context.get_proc_address(ptr) as *const _);
|
let gl = gl::Gl::load_with(|ptr| gl_context.proc_address(ptr) as *const _);
|
||||||
|
|
||||||
let version = unsafe {
|
let version = unsafe {
|
||||||
let data = CStr::from_ptr(gl.GetString(gl::VERSION) as *const _)
|
let data = CStr::from_ptr(gl.GetString(gl::VERSION) as *const _)
|
||||||
|
@ -353,7 +353,7 @@ impl App {
|
||||||
use glutin::platform::unix::WindowExtUnix;
|
use glutin::platform::unix::WindowExtUnix;
|
||||||
use glutin::platform::ContextTraitExt;
|
use glutin::platform::ContextTraitExt;
|
||||||
|
|
||||||
let api = App::map_gl_api(windowed_context.get_api());
|
let api = App::map_gl_api(windowed_context.api());
|
||||||
|
|
||||||
let (gl_context, gl_display, platform) = match unsafe { windowed_context.raw_handle() }
|
let (gl_context, gl_display, platform) = match unsafe { windowed_context.raw_handle() }
|
||||||
{
|
{
|
||||||
|
@ -362,7 +362,7 @@ impl App {
|
||||||
let mut gl_display = None;
|
let mut gl_display = None;
|
||||||
|
|
||||||
#[cfg(feature = "gst-gl-egl")]
|
#[cfg(feature = "gst-gl-egl")]
|
||||||
if let Some(display) = unsafe { windowed_context.get_egl_display() } {
|
if let Some(display) = unsafe { windowed_context.egl_display() } {
|
||||||
gl_display = Some(
|
gl_display = Some(
|
||||||
unsafe { gst_gl_egl::GLDisplayEGL::with_egl_display(display as usize) }
|
unsafe { gst_gl_egl::GLDisplayEGL::with_egl_display(display as usize) }
|
||||||
.unwrap()
|
.unwrap()
|
||||||
|
@ -625,7 +625,7 @@ pub(crate) fn main_loop(app: App) -> Result<(), Error> {
|
||||||
|
|
||||||
println!(
|
println!(
|
||||||
"Pixel format of the window's GL context {:?}",
|
"Pixel format of the window's GL context {:?}",
|
||||||
app.windowed_context.get_pixel_format()
|
app.windowed_context.pixel_format()
|
||||||
);
|
);
|
||||||
|
|
||||||
let gl = load(&app.windowed_context);
|
let gl = load(&app.windowed_context);
|
||||||
|
@ -681,13 +681,13 @@ pub(crate) fn main_loop(app: App) -> Result<(), Error> {
|
||||||
{
|
{
|
||||||
if gst_gl_context.is_none() {
|
if gst_gl_context.is_none() {
|
||||||
gst_gl_context = glupload
|
gst_gl_context = glupload
|
||||||
.get_property("context")
|
.property("context")
|
||||||
.unwrap()
|
.unwrap()
|
||||||
.get::<gst_gl::GLContext>()
|
.get::<gst_gl::GLContext>()
|
||||||
.unwrap();
|
.unwrap();
|
||||||
}
|
}
|
||||||
|
|
||||||
let sync_meta = buffer.get_meta::<gst_gl::GLSyncMeta>().unwrap();
|
let sync_meta = buffer.meta::<gst_gl::GLSyncMeta>().unwrap();
|
||||||
sync_meta.set_sync_point(gst_gl_context.as_ref().unwrap());
|
sync_meta.set_sync_point(gst_gl_context.as_ref().unwrap());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -705,9 +705,9 @@ pub(crate) fn main_loop(app: App) -> Result<(), Error> {
|
||||||
|
|
||||||
if needs_redraw {
|
if needs_redraw {
|
||||||
if let Some(frame) = curr_frame.as_ref() {
|
if let Some(frame) = curr_frame.as_ref() {
|
||||||
let sync_meta = frame.buffer().get_meta::<gst_gl::GLSyncMeta>().unwrap();
|
let sync_meta = frame.buffer().meta::<gst_gl::GLSyncMeta>().unwrap();
|
||||||
sync_meta.wait(&shared_context);
|
sync_meta.wait(&shared_context);
|
||||||
if let Some(texture) = frame.get_texture_id(0) {
|
if let Some(texture) = frame.texture_id(0) {
|
||||||
gl.draw_frame(texture as gl::types::GLuint);
|
gl.draw_frame(texture as gl::types::GLuint);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -183,10 +183,10 @@ impl AudioInfo {
|
||||||
&self.0,
|
&self.0,
|
||||||
src_val.format().to_glib(),
|
src_val.format().to_glib(),
|
||||||
src_val.to_raw_value(),
|
src_val.to_raw_value(),
|
||||||
U::get_default_format().to_glib(),
|
U::default_format().to_glib(),
|
||||||
dest_val.as_mut_ptr(),
|
dest_val.as_mut_ptr(),
|
||||||
)) {
|
)) {
|
||||||
Some(U::from_raw(U::get_default_format(), dest_val.assume_init()))
|
Some(U::from_raw(U::default_format(), dest_val.assume_init()))
|
||||||
} else {
|
} else {
|
||||||
None
|
None
|
||||||
}
|
}
|
||||||
|
|
|
@ -231,7 +231,7 @@ mod tests {
|
||||||
}
|
}
|
||||||
|
|
||||||
{
|
{
|
||||||
let cmeta = buffer.get_meta::<AudioClippingMeta>().unwrap();
|
let cmeta = buffer.meta::<AudioClippingMeta>().unwrap();
|
||||||
assert_eq!(cmeta.start().try_into(), Ok(gst::format::Default(Some(1))));
|
assert_eq!(cmeta.start().try_into(), Ok(gst::format::Default(Some(1))));
|
||||||
assert_eq!(cmeta.end().try_into(), Ok(gst::format::Default(Some(2))));
|
assert_eq!(cmeta.end().try_into(), Ok(gst::format::Default(Some(2))));
|
||||||
}
|
}
|
||||||
|
|
|
@ -766,7 +766,7 @@ unsafe extern "C" fn audio_decoder_getcaps<T: AudioDecoderImpl>(
|
||||||
let wrap: Borrowed<AudioDecoder> = from_glib_borrow(ptr);
|
let wrap: Borrowed<AudioDecoder> = from_glib_borrow(ptr);
|
||||||
|
|
||||||
gst::panic_to_error!(&wrap, &imp.panicked(), gst::Caps::new_empty(), {
|
gst::panic_to_error!(&wrap, &imp.panicked(), gst::Caps::new_empty(), {
|
||||||
AudioDecoderImpl::get_caps(
|
AudioDecoderImpl::caps(
|
||||||
imp,
|
imp,
|
||||||
wrap.unsafe_cast_ref(),
|
wrap.unsafe_cast_ref(),
|
||||||
Option::<gst::Caps>::from_glib_borrow(filter)
|
Option::<gst::Caps>::from_glib_borrow(filter)
|
||||||
|
|
|
@ -682,7 +682,7 @@ unsafe extern "C" fn audio_encoder_getcaps<T: AudioEncoderImpl>(
|
||||||
let wrap: Borrowed<AudioEncoder> = from_glib_borrow(ptr);
|
let wrap: Borrowed<AudioEncoder> = from_glib_borrow(ptr);
|
||||||
|
|
||||||
gst::panic_to_error!(&wrap, &imp.panicked(), gst::Caps::new_empty(), {
|
gst::panic_to_error!(&wrap, &imp.panicked(), gst::Caps::new_empty(), {
|
||||||
AudioEncoderImpl::get_caps(
|
AudioEncoderImpl::caps(
|
||||||
imp,
|
imp,
|
||||||
wrap.unsafe_cast_ref(),
|
wrap.unsafe_cast_ref(),
|
||||||
Option::<gst::Caps>::from_glib_borrow(filter)
|
Option::<gst::Caps>::from_glib_borrow(filter)
|
||||||
|
|
|
@ -293,19 +293,19 @@ impl UniqueAdapter {
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn buffer(&self, nbytes: usize) -> Result<gst::Buffer, glib::BoolError> {
|
pub fn buffer(&self, nbytes: usize) -> Result<gst::Buffer, glib::BoolError> {
|
||||||
self.0.get_buffer(nbytes)
|
self.0.buffer(nbytes)
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn buffer_fast(&self, nbytes: usize) -> Result<gst::Buffer, glib::BoolError> {
|
pub fn buffer_fast(&self, nbytes: usize) -> Result<gst::Buffer, glib::BoolError> {
|
||||||
self.0.get_buffer_fast(nbytes)
|
self.0.buffer_fast(nbytes)
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn buffer_list(&self, nbytes: usize) -> Result<gst::BufferList, glib::BoolError> {
|
pub fn buffer_list(&self, nbytes: usize) -> Result<gst::BufferList, glib::BoolError> {
|
||||||
self.0.get_buffer_list(nbytes)
|
self.0.buffer_list(nbytes)
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn list(&self, nbytes: usize) -> Result<Vec<gst::Buffer>, glib::BoolError> {
|
pub fn list(&self, nbytes: usize) -> Result<Vec<gst::Buffer>, glib::BoolError> {
|
||||||
self.0.get_list(nbytes)
|
self.0.list(nbytes)
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn masked_scan_uint32(
|
pub fn masked_scan_uint32(
|
||||||
|
|
|
@ -83,11 +83,11 @@ impl<O: IsA<BaseParse>> BaseParseExtManual for O {
|
||||||
self.as_ref().to_glib_none().0,
|
self.as_ref().to_glib_none().0,
|
||||||
src_val.format().to_glib(),
|
src_val.format().to_glib(),
|
||||||
src_val.to_raw_value(),
|
src_val.to_raw_value(),
|
||||||
U::get_default_format().to_glib(),
|
U::default_format().to_glib(),
|
||||||
dest_val.as_mut_ptr(),
|
dest_val.as_mut_ptr(),
|
||||||
));
|
));
|
||||||
if ret {
|
if ret {
|
||||||
Some(U::from_raw(U::get_default_format(), dest_val.assume_init()))
|
Some(U::from_raw(U::default_format(), dest_val.assume_init()))
|
||||||
} else {
|
} else {
|
||||||
None
|
None
|
||||||
}
|
}
|
||||||
|
|
|
@ -553,7 +553,7 @@ unsafe extern "C" fn base_sink_get_caps<T: BaseSinkImpl>(
|
||||||
let filter = Option::<gst::Caps>::from_glib_borrow(filter);
|
let filter = Option::<gst::Caps>::from_glib_borrow(filter);
|
||||||
|
|
||||||
gst::panic_to_error!(&wrap, &imp.panicked(), None, {
|
gst::panic_to_error!(&wrap, &imp.panicked(), None, {
|
||||||
imp.get_caps(wrap.unsafe_cast_ref(), filter.as_ref().as_ref())
|
imp.caps(wrap.unsafe_cast_ref(), filter.as_ref().as_ref())
|
||||||
})
|
})
|
||||||
.map(|caps| caps.into_ptr())
|
.map(|caps| caps.into_ptr())
|
||||||
.unwrap_or(ptr::null_mut())
|
.unwrap_or(ptr::null_mut())
|
||||||
|
|
|
@ -686,7 +686,7 @@ unsafe extern "C" fn base_src_get_times<T: BaseSrcImpl>(
|
||||||
*stop = gst::ffi::GST_CLOCK_TIME_NONE;
|
*stop = gst::ffi::GST_CLOCK_TIME_NONE;
|
||||||
|
|
||||||
gst::panic_to_error!(&wrap, &imp.panicked(), (), {
|
gst::panic_to_error!(&wrap, &imp.panicked(), (), {
|
||||||
let (start_, stop_) = imp.get_times(wrap.unsafe_cast_ref(), buffer);
|
let (start_, stop_) = imp.times(wrap.unsafe_cast_ref(), buffer);
|
||||||
*start = start_.to_glib();
|
*start = start_.to_glib();
|
||||||
*stop = stop_.to_glib();
|
*stop = stop_.to_glib();
|
||||||
});
|
});
|
||||||
|
@ -878,7 +878,7 @@ unsafe extern "C" fn base_src_get_caps<T: BaseSrcImpl>(
|
||||||
let filter = Option::<gst::Caps>::from_glib_borrow(filter);
|
let filter = Option::<gst::Caps>::from_glib_borrow(filter);
|
||||||
|
|
||||||
gst::panic_to_error!(&wrap, &imp.panicked(), None, {
|
gst::panic_to_error!(&wrap, &imp.panicked(), None, {
|
||||||
imp.get_caps(wrap.unsafe_cast_ref(), filter.as_ref().as_ref())
|
imp.caps(wrap.unsafe_cast_ref(), filter.as_ref().as_ref())
|
||||||
})
|
})
|
||||||
.map(|caps| caps.into_ptr())
|
.map(|caps| caps.into_ptr())
|
||||||
.unwrap_or(ptr::null_mut())
|
.unwrap_or(ptr::null_mut())
|
||||||
|
|
|
@ -1080,7 +1080,7 @@ unsafe extern "C" fn base_transform_get_unit_size<T: BaseTransformImpl>(
|
||||||
let wrap: Borrowed<BaseTransform> = from_glib_borrow(ptr);
|
let wrap: Borrowed<BaseTransform> = from_glib_borrow(ptr);
|
||||||
|
|
||||||
gst::panic_to_error!(&wrap, &imp.panicked(), false, {
|
gst::panic_to_error!(&wrap, &imp.panicked(), false, {
|
||||||
match imp.get_unit_size(wrap.unsafe_cast_ref(), &from_glib_borrow(caps)) {
|
match imp.unit_size(wrap.unsafe_cast_ref(), &from_glib_borrow(caps)) {
|
||||||
Some(s) => {
|
Some(s) => {
|
||||||
*size = s;
|
*size = s;
|
||||||
true
|
true
|
||||||
|
|
|
@ -80,7 +80,7 @@ impl Harness {
|
||||||
// Reimplementation of the C code so we don't have to duplicate all the callback code
|
// Reimplementation of the C code so we don't have to duplicate all the callback code
|
||||||
|
|
||||||
let element = self.find_element(element_name).expect("Element not found");
|
let element = self.find_element(element_name).expect("Element not found");
|
||||||
let pad = element.get_static_pad(pad_name).expect("Pad not found");
|
let pad = element.static_pad(pad_name).expect("Pad not found");
|
||||||
pad.add_probe(mask, func);
|
pad.add_probe(mask, func);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -38,7 +38,7 @@ impl VideoFrameGLExt for gst_video::VideoFrame<Readable> {
|
||||||
}
|
}
|
||||||
|
|
||||||
fn texture_id(&self, idx: u32) -> Option<u32> {
|
fn texture_id(&self, idx: u32) -> Option<u32> {
|
||||||
self.as_video_frame_ref().get_texture_id(idx)
|
self.as_video_frame_ref().texture_id(idx)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -89,7 +89,7 @@ mod tests {
|
||||||
}
|
}
|
||||||
|
|
||||||
{
|
{
|
||||||
let meta = buffer.get_meta::<NetAddressMeta>().unwrap();
|
let meta = buffer.meta::<NetAddressMeta>().unwrap();
|
||||||
let actual_addr = meta.addr().downcast::<gio::InetSocketAddress>().unwrap();
|
let actual_addr = meta.addr().downcast::<gio::InetSocketAddress>().unwrap();
|
||||||
|
|
||||||
assert_eq!(actual_addr.port(), expected_addr.port());
|
assert_eq!(actual_addr.port(), expected_addr.port());
|
||||||
|
|
|
@ -389,9 +389,9 @@ mod tests {
|
||||||
assert_eq!(rtp_buffer.csrc_count(), csrc_count);
|
assert_eq!(rtp_buffer.csrc_count(), csrc_count);
|
||||||
rtp_buffer.set_csrc(0, 12);
|
rtp_buffer.set_csrc(0, 12);
|
||||||
rtp_buffer.set_csrc(1, 15);
|
rtp_buffer.set_csrc(1, 15);
|
||||||
assert_eq!(rtp_buffer.get_csrc(0).unwrap(), 12);
|
assert_eq!(rtp_buffer.csrc(0).unwrap(), 12);
|
||||||
assert_eq!(rtp_buffer.get_csrc(1).unwrap(), 15);
|
assert_eq!(rtp_buffer.csrc(1).unwrap(), 15);
|
||||||
assert!(rtp_buffer.get_csrc(2).is_none());
|
assert!(rtp_buffer.csrc(2).is_none());
|
||||||
|
|
||||||
rtp_buffer.set_extension(true);
|
rtp_buffer.set_extension(true);
|
||||||
assert_eq!(rtp_buffer.is_extension(), true);
|
assert_eq!(rtp_buffer.is_extension(), true);
|
||||||
|
@ -444,10 +444,10 @@ mod tests {
|
||||||
assert_eq!(bytes[i + 1], extension_data[i]);
|
assert_eq!(bytes[i + 1], extension_data[i]);
|
||||||
}
|
}
|
||||||
|
|
||||||
let result = rtp_buffer.get_extension_onebyte_header(2, 0);
|
let result = rtp_buffer.extension_onebyte_header(2, 0);
|
||||||
assert!(result.is_none());
|
assert!(result.is_none());
|
||||||
|
|
||||||
let result = rtp_buffer.get_extension_onebyte_header(1, 0);
|
let result = rtp_buffer.extension_onebyte_header(1, 0);
|
||||||
assert!(result.is_some());
|
assert!(result.is_some());
|
||||||
assert_eq!(result.unwrap(), &extension_data);
|
assert_eq!(result.unwrap(), &extension_data);
|
||||||
}
|
}
|
||||||
|
@ -485,10 +485,10 @@ mod tests {
|
||||||
assert_eq!(bytes[i + 2], extension_data[i]);
|
assert_eq!(bytes[i + 2], extension_data[i]);
|
||||||
}
|
}
|
||||||
|
|
||||||
let result = rtp_buffer.get_extension_twobytes_header(2, 0);
|
let result = rtp_buffer.extension_twobytes_header(2, 0);
|
||||||
assert!(result.is_none());
|
assert!(result.is_none());
|
||||||
|
|
||||||
let result = rtp_buffer.get_extension_twobytes_header(id, 0);
|
let result = rtp_buffer.extension_twobytes_header(id, 0);
|
||||||
assert!(result.is_some());
|
assert!(result.is_some());
|
||||||
let (extracted_appbits, data) = result.unwrap();
|
let (extracted_appbits, data) = result.unwrap();
|
||||||
assert_eq!(appbits, extracted_appbits);
|
assert_eq!(appbits, extracted_appbits);
|
||||||
|
|
|
@ -1073,7 +1073,7 @@ unsafe extern "C" fn client_get_parameter_request<T: RTSPClientImpl>(
|
||||||
let imp = instance.impl_();
|
let imp = instance.impl_();
|
||||||
let wrap: Borrowed<RTSPClient> = from_glib_borrow(ptr);
|
let wrap: Borrowed<RTSPClient> = from_glib_borrow(ptr);
|
||||||
|
|
||||||
imp.get_parameter_request(wrap.unsafe_cast_ref(), &from_glib_borrow(ctx));
|
imp.parameter_request(wrap.unsafe_cast_ref(), &from_glib_borrow(ctx));
|
||||||
}
|
}
|
||||||
|
|
||||||
unsafe extern "C" fn client_announce_request<T: RTSPClientImpl>(
|
unsafe extern "C" fn client_announce_request<T: RTSPClientImpl>(
|
||||||
|
|
|
@ -606,7 +606,7 @@ macro_rules! define_iter(
|
||||||
impl<'a> $name<'a> {
|
impl<'a> $name<'a> {
|
||||||
fn new(media: &'a SDPMediaRef) -> $name<'a> {
|
fn new(media: &'a SDPMediaRef) -> $name<'a> {
|
||||||
skip_assert_initialized!();
|
skip_assert_initialized!();
|
||||||
let len = $get_len(media);
|
let len = $len(media);
|
||||||
|
|
||||||
$name {
|
$name {
|
||||||
media,
|
media,
|
||||||
|
@ -624,7 +624,7 @@ macro_rules! define_iter(
|
||||||
return None;
|
return None;
|
||||||
}
|
}
|
||||||
|
|
||||||
let item = $get_item(self.media, self.idx)?;
|
let item = $item(self.media, self.idx)?;
|
||||||
self.idx += 1;
|
self.idx += 1;
|
||||||
Some(item)
|
Some(item)
|
||||||
}
|
}
|
||||||
|
@ -648,7 +648,7 @@ macro_rules! define_iter(
|
||||||
|
|
||||||
self.len -= 1;
|
self.len -= 1;
|
||||||
|
|
||||||
$get_item(self.media, self.len)
|
$item(self.media, self.len)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -659,25 +659,25 @@ macro_rules! define_iter(
|
||||||
define_iter!(
|
define_iter!(
|
||||||
BandwidthsIter,
|
BandwidthsIter,
|
||||||
&'a SDPBandwidth,
|
&'a SDPBandwidth,
|
||||||
|media: &'a SDPMediaRef, idx| media.get_bandwidth(idx),
|
|media: &'a SDPMediaRef, idx| media.bandwidth(idx),
|
||||||
|media: &SDPMediaRef| media.bandwidths_len()
|
|media: &SDPMediaRef| media.bandwidths_len()
|
||||||
);
|
);
|
||||||
define_iter!(
|
define_iter!(
|
||||||
FormatsIter,
|
FormatsIter,
|
||||||
&'a str,
|
&'a str,
|
||||||
|media: &'a SDPMediaRef, idx| media.get_format(idx),
|
|media: &'a SDPMediaRef, idx| media.format(idx),
|
||||||
|media: &SDPMediaRef| media.formats_len()
|
|media: &SDPMediaRef| media.formats_len()
|
||||||
);
|
);
|
||||||
define_iter!(
|
define_iter!(
|
||||||
ConnectionsIter,
|
ConnectionsIter,
|
||||||
&'a SDPConnection,
|
&'a SDPConnection,
|
||||||
|media: &'a SDPMediaRef, idx| media.get_connection(idx),
|
|media: &'a SDPMediaRef, idx| media.connection(idx),
|
||||||
|media: &SDPMediaRef| media.connections_len()
|
|media: &SDPMediaRef| media.connections_len()
|
||||||
);
|
);
|
||||||
define_iter!(
|
define_iter!(
|
||||||
AttributesIter,
|
AttributesIter,
|
||||||
&'a SDPAttribute,
|
&'a SDPAttribute,
|
||||||
|media: &'a SDPMediaRef, idx| media.get_attribute(idx),
|
|media: &'a SDPMediaRef, idx| media.attribute(idx),
|
||||||
|media: &SDPMediaRef| media.attributes_len()
|
|media: &SDPMediaRef| media.attributes_len()
|
||||||
);
|
);
|
||||||
|
|
||||||
|
|
|
@ -927,7 +927,7 @@ macro_rules! define_iter(
|
||||||
impl<'a> $name<'a> {
|
impl<'a> $name<'a> {
|
||||||
fn new(message: &'a SDPMessageRef) -> $name<'a> {
|
fn new(message: &'a SDPMessageRef) -> $name<'a> {
|
||||||
skip_assert_initialized!();
|
skip_assert_initialized!();
|
||||||
let len = $get_len(message);
|
let len = $len(message);
|
||||||
|
|
||||||
$name {
|
$name {
|
||||||
message,
|
message,
|
||||||
|
@ -945,7 +945,7 @@ macro_rules! define_iter(
|
||||||
return None;
|
return None;
|
||||||
}
|
}
|
||||||
|
|
||||||
let item = $get_item(self.message, self.idx)?;
|
let item = $item(self.message, self.idx)?;
|
||||||
self.idx += 1;
|
self.idx += 1;
|
||||||
Some(item)
|
Some(item)
|
||||||
}
|
}
|
||||||
|
@ -969,7 +969,7 @@ macro_rules! define_iter(
|
||||||
|
|
||||||
self.len -= 1;
|
self.len -= 1;
|
||||||
|
|
||||||
$get_item(self.message, self.len)
|
$item(self.message, self.len)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -989,7 +989,7 @@ macro_rules! define_iter_mut(
|
||||||
impl<'a> $name<'a> {
|
impl<'a> $name<'a> {
|
||||||
fn new(message: &'a mut SDPMessageRef) -> $name<'a> {
|
fn new(message: &'a mut SDPMessageRef) -> $name<'a> {
|
||||||
skip_assert_initialized!();
|
skip_assert_initialized!();
|
||||||
let len = $get_len(message);
|
let len = $len(message);
|
||||||
|
|
||||||
$name {
|
$name {
|
||||||
message,
|
message,
|
||||||
|
@ -1019,7 +1019,7 @@ macro_rules! define_iter_mut(
|
||||||
return None;
|
return None;
|
||||||
}
|
}
|
||||||
|
|
||||||
let item = $get_item(message, self.idx)?;
|
let item = $item(message, self.idx)?;
|
||||||
self.idx += 1;
|
self.idx += 1;
|
||||||
Some(item)
|
Some(item)
|
||||||
}
|
}
|
||||||
|
@ -1046,7 +1046,7 @@ macro_rules! define_iter_mut(
|
||||||
|
|
||||||
self.len -= 1;
|
self.len -= 1;
|
||||||
|
|
||||||
$get_item(message, self.len)
|
$item(message, self.len)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1057,49 +1057,49 @@ macro_rules! define_iter_mut(
|
||||||
define_iter!(
|
define_iter!(
|
||||||
AttributesIter,
|
AttributesIter,
|
||||||
&'a SDPAttribute,
|
&'a SDPAttribute,
|
||||||
|message: &'a SDPMessageRef, idx| message.get_attribute(idx),
|
|message: &'a SDPMessageRef, idx| message.attribute(idx),
|
||||||
|message: &SDPMessageRef| message.attributes_len()
|
|message: &SDPMessageRef| message.attributes_len()
|
||||||
);
|
);
|
||||||
define_iter!(
|
define_iter!(
|
||||||
BandwidthsIter,
|
BandwidthsIter,
|
||||||
&'a SDPBandwidth,
|
&'a SDPBandwidth,
|
||||||
|message: &'a SDPMessageRef, idx| message.get_bandwidth(idx),
|
|message: &'a SDPMessageRef, idx| message.bandwidth(idx),
|
||||||
|message: &SDPMessageRef| message.bandwidths_len()
|
|message: &SDPMessageRef| message.bandwidths_len()
|
||||||
);
|
);
|
||||||
define_iter!(
|
define_iter!(
|
||||||
EmailsIter,
|
EmailsIter,
|
||||||
&'a str,
|
&'a str,
|
||||||
|message: &'a SDPMessageRef, idx| message.get_email(idx),
|
|message: &'a SDPMessageRef, idx| message.email(idx),
|
||||||
|message: &SDPMessageRef| message.emails_len()
|
|message: &SDPMessageRef| message.emails_len()
|
||||||
);
|
);
|
||||||
define_iter!(
|
define_iter!(
|
||||||
MediasIter,
|
MediasIter,
|
||||||
&'a SDPMediaRef,
|
&'a SDPMediaRef,
|
||||||
|message: &'a SDPMessageRef, idx| message.get_media(idx),
|
|message: &'a SDPMessageRef, idx| message.media(idx),
|
||||||
|message: &SDPMessageRef| message.medias_len()
|
|message: &SDPMessageRef| message.medias_len()
|
||||||
);
|
);
|
||||||
define_iter_mut!(
|
define_iter_mut!(
|
||||||
MediasIterMut,
|
MediasIterMut,
|
||||||
&'a mut SDPMediaRef,
|
&'a mut SDPMediaRef,
|
||||||
|message: &'a mut SDPMessageRef, idx| message.get_media_mut(idx),
|
|message: &'a mut SDPMessageRef, idx| message.media_mut(idx),
|
||||||
|message: &SDPMessageRef| message.medias_len()
|
|message: &SDPMessageRef| message.medias_len()
|
||||||
);
|
);
|
||||||
define_iter!(
|
define_iter!(
|
||||||
PhonesIter,
|
PhonesIter,
|
||||||
&'a str,
|
&'a str,
|
||||||
|message: &'a SDPMessageRef, idx| message.get_phone(idx),
|
|message: &'a SDPMessageRef, idx| message.phone(idx),
|
||||||
|message: &SDPMessageRef| message.phones_len()
|
|message: &SDPMessageRef| message.phones_len()
|
||||||
);
|
);
|
||||||
define_iter!(
|
define_iter!(
|
||||||
TimesIter,
|
TimesIter,
|
||||||
&'a SDPTime,
|
&'a SDPTime,
|
||||||
|message: &'a SDPMessageRef, idx| message.get_time(idx),
|
|message: &'a SDPMessageRef, idx| message.time(idx),
|
||||||
|message: &SDPMessageRef| message.times_len()
|
|message: &SDPMessageRef| message.times_len()
|
||||||
);
|
);
|
||||||
define_iter!(
|
define_iter!(
|
||||||
ZonesIter,
|
ZonesIter,
|
||||||
&'a SDPZone,
|
&'a SDPZone,
|
||||||
|message: &'a SDPMessageRef, idx| message.get_zone(idx),
|
|message: &'a SDPMessageRef, idx| message.zone(idx),
|
||||||
|message: &SDPMessageRef| message.zones_len()
|
|message: &SDPMessageRef| message.zones_len()
|
||||||
);
|
);
|
||||||
|
|
||||||
|
@ -1117,7 +1117,7 @@ mod tests {
|
||||||
|
|
||||||
let sdp = "v=0\r\no=- 1938737043334325940 0 IN IP4 0.0.0.0\r\ns=-\r\nt=0 0\r\na=ice-options:trickle\r\nm=video 9 UDP/TLS/RTP/SAVPF 96\r\nc=IN IP4 0.0.0.0\r\na=setup:actpass\r\na=ice-ufrag:YZxU9JlWHzHcF6O2U09/q3PvBhbTPdZW\r\na=ice-pwd:fyrt730GWo5mFGc9m2z/vbUu3z1lewla\r\na=sendrecv\r\na=rtcp-mux\r\na=rtcp-rsize\r\na=rtpmap:96 VP8/90000\r\na=rtcp-fb:96 nack\r\na=rtcp-fb:96 nack pli\r\na=framerate:30\r\na=mid:video0\r\na=fingerprint:sha-256 DB:48:8F:18:13:F3:AA:13:31:B3:75:3D:1A:D3:BA:88:4A:ED:1B:56:14:C3:09:CD:BC:4D:18:42:B9:6A:5F:98\r\nm=audio 9 UDP/TLS/RTP/SAVPF 97\r\nc=IN IP4 0.0.0.0\r\na=setup:actpass\r\na=ice-ufrag:04KZM9qE2S4r06AN6A9CeXOM6mzO0LZY\r\na=ice-pwd:cJTSfHF6hHDAcsTJXZVJeuYCC6rKqBvW\r\na=sendrecv\r\na=rtcp-mux\r\na=rtcp-rsize\r\na=rtpmap:97 OPUS/48000/2\r\na=rtcp-fb:97 nack\r\na=rtcp-fb:97 nack pli\r\na=mid:audio1\r\na=fingerprint:sha-256 DB:48:8F:18:13:F3:AA:13:31:B3:75:3D:1A:D3:BA:88:4A:ED:1B:56:14:C3:09:CD:BC:4D:18:42:B9:6A:5F:98\r\n";
|
let sdp = "v=0\r\no=- 1938737043334325940 0 IN IP4 0.0.0.0\r\ns=-\r\nt=0 0\r\na=ice-options:trickle\r\nm=video 9 UDP/TLS/RTP/SAVPF 96\r\nc=IN IP4 0.0.0.0\r\na=setup:actpass\r\na=ice-ufrag:YZxU9JlWHzHcF6O2U09/q3PvBhbTPdZW\r\na=ice-pwd:fyrt730GWo5mFGc9m2z/vbUu3z1lewla\r\na=sendrecv\r\na=rtcp-mux\r\na=rtcp-rsize\r\na=rtpmap:96 VP8/90000\r\na=rtcp-fb:96 nack\r\na=rtcp-fb:96 nack pli\r\na=framerate:30\r\na=mid:video0\r\na=fingerprint:sha-256 DB:48:8F:18:13:F3:AA:13:31:B3:75:3D:1A:D3:BA:88:4A:ED:1B:56:14:C3:09:CD:BC:4D:18:42:B9:6A:5F:98\r\nm=audio 9 UDP/TLS/RTP/SAVPF 97\r\nc=IN IP4 0.0.0.0\r\na=setup:actpass\r\na=ice-ufrag:04KZM9qE2S4r06AN6A9CeXOM6mzO0LZY\r\na=ice-pwd:cJTSfHF6hHDAcsTJXZVJeuYCC6rKqBvW\r\na=sendrecv\r\na=rtcp-mux\r\na=rtcp-rsize\r\na=rtpmap:97 OPUS/48000/2\r\na=rtcp-fb:97 nack\r\na=rtcp-fb:97 nack pli\r\na=mid:audio1\r\na=fingerprint:sha-256 DB:48:8F:18:13:F3:AA:13:31:B3:75:3D:1A:D3:BA:88:4A:ED:1B:56:14:C3:09:CD:BC:4D:18:42:B9:6A:5F:98\r\n";
|
||||||
let sdp = SDPMessage::parse_buffer(sdp.as_bytes()).unwrap();
|
let sdp = SDPMessage::parse_buffer(sdp.as_bytes()).unwrap();
|
||||||
let media = sdp.get_media(0).unwrap();
|
let media = sdp.media(0).unwrap();
|
||||||
assert_eq!(media.formats_len(), 1);
|
assert_eq!(media.formats_len(), 1);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -762,7 +762,7 @@ unsafe extern "C" fn video_decoder_getcaps<T: VideoDecoderImpl>(
|
||||||
let wrap: Borrowed<VideoDecoder> = from_glib_borrow(ptr);
|
let wrap: Borrowed<VideoDecoder> = from_glib_borrow(ptr);
|
||||||
|
|
||||||
gst::panic_to_error!(&wrap, &imp.panicked(), gst::Caps::new_empty(), {
|
gst::panic_to_error!(&wrap, &imp.panicked(), gst::Caps::new_empty(), {
|
||||||
VideoDecoderImpl::get_caps(
|
VideoDecoderImpl::caps(
|
||||||
imp,
|
imp,
|
||||||
wrap.unsafe_cast_ref(),
|
wrap.unsafe_cast_ref(),
|
||||||
Option::<gst::Caps>::from_glib_borrow(filter)
|
Option::<gst::Caps>::from_glib_borrow(filter)
|
||||||
|
|
|
@ -660,7 +660,7 @@ unsafe extern "C" fn video_encoder_getcaps<T: VideoEncoderImpl>(
|
||||||
let wrap: Borrowed<VideoEncoder> = from_glib_borrow(ptr);
|
let wrap: Borrowed<VideoEncoder> = from_glib_borrow(ptr);
|
||||||
|
|
||||||
gst::panic_to_error!(&wrap, &imp.panicked(), gst::Caps::new_empty(), {
|
gst::panic_to_error!(&wrap, &imp.panicked(), gst::Caps::new_empty(), {
|
||||||
VideoEncoderImpl::get_caps(
|
VideoEncoderImpl::caps(
|
||||||
imp,
|
imp,
|
||||||
wrap.unsafe_cast_ref(),
|
wrap.unsafe_cast_ref(),
|
||||||
Option::<gst::Caps>::from_glib_borrow(filter)
|
Option::<gst::Caps>::from_glib_borrow(filter)
|
||||||
|
|
|
@ -751,10 +751,10 @@ impl VideoInfo {
|
||||||
&self.0 as *const _ as *mut _,
|
&self.0 as *const _ as *mut _,
|
||||||
src_val.format().to_glib(),
|
src_val.format().to_glib(),
|
||||||
src_val.to_raw_value(),
|
src_val.to_raw_value(),
|
||||||
U::get_default_format().to_glib(),
|
U::default_format().to_glib(),
|
||||||
dest_val.as_mut_ptr(),
|
dest_val.as_mut_ptr(),
|
||||||
)) {
|
)) {
|
||||||
Some(U::from_raw(U::get_default_format(), dest_val.assume_init()))
|
Some(U::from_raw(U::default_format(), dest_val.assume_init()))
|
||||||
} else {
|
} else {
|
||||||
None
|
None
|
||||||
}
|
}
|
||||||
|
|
|
@ -778,7 +778,7 @@ mod tests {
|
||||||
}
|
}
|
||||||
|
|
||||||
{
|
{
|
||||||
let meta = buffer.get_meta::<VideoMeta>().unwrap();
|
let meta = buffer.meta::<VideoMeta>().unwrap();
|
||||||
assert_eq!(meta.id(), 0);
|
assert_eq!(meta.id(), 0);
|
||||||
assert_eq!(meta.flags(), crate::VideoFrameFlags::empty());
|
assert_eq!(meta.flags(), crate::VideoFrameFlags::empty());
|
||||||
assert_eq!(meta.format(), crate::VideoFormat::Argb);
|
assert_eq!(meta.format(), crate::VideoFormat::Argb);
|
||||||
|
@ -817,7 +817,7 @@ mod tests {
|
||||||
}
|
}
|
||||||
|
|
||||||
{
|
{
|
||||||
let meta = buffer.get_meta::<VideoMeta>().unwrap();
|
let meta = buffer.meta::<VideoMeta>().unwrap();
|
||||||
assert_eq!(meta.id(), 0);
|
assert_eq!(meta.id(), 0);
|
||||||
assert_eq!(meta.flags(), crate::VideoFrameFlags::empty());
|
assert_eq!(meta.flags(), crate::VideoFrameFlags::empty());
|
||||||
assert_eq!(meta.format(), crate::VideoFormat::Argb);
|
assert_eq!(meta.format(), crate::VideoFormat::Argb);
|
||||||
|
|
|
@ -38,7 +38,7 @@ impl VideoOverlayRectangle {
|
||||||
flags: crate::VideoOverlayFormatFlags,
|
flags: crate::VideoOverlayFormatFlags,
|
||||||
) -> Self {
|
) -> Self {
|
||||||
assert_initialized_main_thread!();
|
assert_initialized_main_thread!();
|
||||||
assert!(buffer.get_meta::<crate::VideoMeta>().is_some());
|
assert!(buffer.meta::<crate::VideoMeta>().is_some());
|
||||||
unsafe {
|
unsafe {
|
||||||
from_glib_full(ffi::gst_video_overlay_rectangle_new_raw(
|
from_glib_full(ffi::gst_video_overlay_rectangle_new_raw(
|
||||||
buffer.to_glib_none().0,
|
buffer.to_glib_none().0,
|
||||||
|
|
|
@ -386,7 +386,7 @@ impl BufferRef {
|
||||||
|
|
||||||
pub fn meta<T: MetaAPI>(&self) -> Option<MetaRef<T>> {
|
pub fn meta<T: MetaAPI>(&self) -> Option<MetaRef<T>> {
|
||||||
unsafe {
|
unsafe {
|
||||||
let meta = ffi::gst_buffer_get_meta(self.as_mut_ptr(), T::get_meta_api().to_glib());
|
let meta = ffi::gst_buffer_get_meta(self.as_mut_ptr(), T::meta_api().to_glib());
|
||||||
if meta.is_null() {
|
if meta.is_null() {
|
||||||
None
|
None
|
||||||
} else {
|
} else {
|
||||||
|
@ -397,7 +397,7 @@ impl BufferRef {
|
||||||
|
|
||||||
pub fn meta_mut<T: MetaAPI>(&mut self) -> Option<MetaRefMut<T, crate::meta::Standalone>> {
|
pub fn meta_mut<T: MetaAPI>(&mut self) -> Option<MetaRefMut<T, crate::meta::Standalone>> {
|
||||||
unsafe {
|
unsafe {
|
||||||
let meta = ffi::gst_buffer_get_meta(self.as_mut_ptr(), T::get_meta_api().to_glib());
|
let meta = ffi::gst_buffer_get_meta(self.as_mut_ptr(), T::meta_api().to_glib());
|
||||||
if meta.is_null() {
|
if meta.is_null() {
|
||||||
None
|
None
|
||||||
} else {
|
} else {
|
||||||
|
@ -711,7 +711,7 @@ macro_rules! define_meta_iter(
|
||||||
$name {
|
$name {
|
||||||
buffer,
|
buffer,
|
||||||
state: ptr::null_mut(),
|
state: ptr::null_mut(),
|
||||||
meta_api: T::get_meta_api(),
|
meta_api: T::meta_api(),
|
||||||
items: PhantomData,
|
items: PhantomData,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -797,7 +797,7 @@ macro_rules! define_iter(
|
||||||
|
|
||||||
#[allow(unused_unsafe)]
|
#[allow(unused_unsafe)]
|
||||||
unsafe {
|
unsafe {
|
||||||
let item = $get_item(self.buffer, self.idx)?;
|
let item = $item(self.buffer, self.idx)?;
|
||||||
self.idx += 1;
|
self.idx += 1;
|
||||||
Some(item)
|
Some(item)
|
||||||
}
|
}
|
||||||
|
@ -824,7 +824,7 @@ macro_rules! define_iter(
|
||||||
|
|
||||||
#[allow(unused_unsafe)]
|
#[allow(unused_unsafe)]
|
||||||
unsafe {
|
unsafe {
|
||||||
$get_item(self.buffer, self.n_memory)
|
$item(self.buffer, self.n_memory)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -865,7 +865,7 @@ define_iter!(
|
||||||
IterOwned,
|
IterOwned,
|
||||||
&'a BufferRef,
|
&'a BufferRef,
|
||||||
Memory,
|
Memory,
|
||||||
|buffer: &BufferRef, idx| { buffer.get_memory(idx) }
|
|buffer: &BufferRef, idx| { buffer.memory(idx) }
|
||||||
);
|
);
|
||||||
|
|
||||||
impl fmt::Debug for Buffer {
|
impl fmt::Debug for Buffer {
|
||||||
|
@ -1184,7 +1184,7 @@ mod tests {
|
||||||
|
|
||||||
for i in 0..5 {
|
for i in 0..5 {
|
||||||
{
|
{
|
||||||
let mem = buffer.get_memory(i).unwrap();
|
let mem = buffer.memory(i).unwrap();
|
||||||
assert_eq!(mem.size(), if i < 4 { 5 } else { 10 });
|
assert_eq!(mem.size(), if i < 4 { 5 } else { 10 });
|
||||||
let map = mem.map_readable().unwrap();
|
let map = mem.map_readable().unwrap();
|
||||||
assert_eq!(map.size(), if i < 4 { 5 } else { 10 });
|
assert_eq!(map.size(), if i < 4 { 5 } else { 10 });
|
||||||
|
|
|
@ -74,8 +74,8 @@ macro_rules! define_seek_impl(
|
||||||
}
|
}
|
||||||
|
|
||||||
// Work around lifetime annotation issues with closures
|
// Work around lifetime annotation issues with closures
|
||||||
let get_buffer_ref: fn(&Self) -> &BufferRef = $get_buffer_ref;
|
let buffer_ref: fn(&Self) -> &BufferRef = $get_buffer_ref;
|
||||||
let (idx, _, skip) = get_buffer_ref(self)
|
let (idx, _, skip) = buffer_ref(self)
|
||||||
.find_memory(self.cur_offset as usize, None)
|
.find_memory(self.cur_offset as usize, None)
|
||||||
.expect("Failed to find memory");
|
.expect("Failed to find memory");
|
||||||
|
|
||||||
|
@ -113,9 +113,9 @@ macro_rules! define_read_write_fn_impl(
|
||||||
if $self.map_info.memory.is_null() {
|
if $self.map_info.memory.is_null() {
|
||||||
unsafe {
|
unsafe {
|
||||||
// Work around lifetime annotation issues with closures
|
// Work around lifetime annotation issues with closures
|
||||||
let get_buffer_ref: fn(&Self) -> &BufferRef = $get_buffer_ref;
|
let buffer_ref: fn(&Self) -> &BufferRef = $get_buffer_ref;
|
||||||
let memory = ffi::gst_buffer_peek_memory(
|
let memory = ffi::gst_buffer_peek_memory(
|
||||||
get_buffer_ref($self).as_mut_ptr(),
|
buffer_ref($self).as_mut_ptr(),
|
||||||
$self.cur_mem_idx,
|
$self.cur_mem_idx,
|
||||||
);
|
);
|
||||||
assert!(!memory.is_null());
|
assert!(!memory.is_null());
|
||||||
|
|
|
@ -218,7 +218,7 @@ macro_rules! define_iter(
|
||||||
return None;
|
return None;
|
||||||
}
|
}
|
||||||
|
|
||||||
let item = $get_item(self.list, self.idx)?;
|
let item = $item(self.list, self.idx)?;
|
||||||
self.idx += 1;
|
self.idx += 1;
|
||||||
|
|
||||||
Some(item)
|
Some(item)
|
||||||
|
@ -242,7 +242,7 @@ macro_rules! define_iter(
|
||||||
}
|
}
|
||||||
|
|
||||||
self.size -= 1;
|
self.size -= 1;
|
||||||
$get_item(self.list, self.size)
|
$item(self.list, self.size)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -422,7 +422,7 @@ macro_rules! define_iter(
|
||||||
}
|
}
|
||||||
|
|
||||||
unsafe {
|
unsafe {
|
||||||
let item = $get_item(self.caps, self.idx)?;
|
let item = $item(self.caps, self.idx)?;
|
||||||
self.idx += 1;
|
self.idx += 1;
|
||||||
Some(item)
|
Some(item)
|
||||||
}
|
}
|
||||||
|
@ -448,7 +448,7 @@ macro_rules! define_iter(
|
||||||
self.n_structures -= 1;
|
self.n_structures -= 1;
|
||||||
|
|
||||||
unsafe {
|
unsafe {
|
||||||
$get_item(self.caps, self.n_structures)
|
$item(self.caps, self.n_structures)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -741,7 +741,7 @@ mod tests {
|
||||||
);
|
);
|
||||||
|
|
||||||
{
|
{
|
||||||
let s = caps.get_structure(0).unwrap();
|
let s = caps.structure(0).unwrap();
|
||||||
assert_eq!(
|
assert_eq!(
|
||||||
s,
|
s,
|
||||||
Structure::new(
|
Structure::new(
|
||||||
|
@ -758,7 +758,7 @@ mod tests {
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
assert!(caps
|
assert!(caps
|
||||||
.get_features(0)
|
.features(0)
|
||||||
.unwrap()
|
.unwrap()
|
||||||
.is_equal(crate::CAPS_FEATURES_MEMORY_SYSTEM_MEMORY.as_ref()));
|
.is_equal(crate::CAPS_FEATURES_MEMORY_SYSTEM_MEMORY.as_ref()));
|
||||||
|
|
||||||
|
@ -767,7 +767,7 @@ mod tests {
|
||||||
caps.set_features(0, Some(CapsFeatures::new(&["foo:bla"])));
|
caps.set_features(0, Some(CapsFeatures::new(&["foo:bla"])));
|
||||||
}
|
}
|
||||||
assert!(caps
|
assert!(caps
|
||||||
.get_features(0)
|
.features(0)
|
||||||
.unwrap()
|
.unwrap()
|
||||||
.is_equal(CapsFeatures::new(&["foo:bla"]).as_ref()));
|
.is_equal(CapsFeatures::new(&["foo:bla"]).as_ref()));
|
||||||
}
|
}
|
||||||
|
|
|
@ -367,7 +367,7 @@ mod tests {
|
||||||
),
|
),
|
||||||
])"#;
|
])"#;
|
||||||
let caps: Caps = ron::de::from_str(caps_ron).unwrap();
|
let caps: Caps = ron::de::from_str(caps_ron).unwrap();
|
||||||
let s = caps.get_structure(0).unwrap();
|
let s = caps.structure(0).unwrap();
|
||||||
assert_eq!(
|
assert_eq!(
|
||||||
s,
|
s,
|
||||||
Structure::new(
|
Structure::new(
|
||||||
|
@ -400,7 +400,7 @@ mod tests {
|
||||||
),
|
),
|
||||||
])"#;
|
])"#;
|
||||||
let caps: Caps = ron::de::from_str(caps_ron).unwrap();
|
let caps: Caps = ron::de::from_str(caps_ron).unwrap();
|
||||||
let s = caps.get_structure(0).unwrap();
|
let s = caps.structure(0).unwrap();
|
||||||
let str_none: Option<&str> = None;
|
let str_none: Option<&str> = None;
|
||||||
assert_eq!(
|
assert_eq!(
|
||||||
s,
|
s,
|
||||||
|
@ -416,7 +416,7 @@ mod tests {
|
||||||
)
|
)
|
||||||
.as_ref()
|
.as_ref()
|
||||||
);
|
);
|
||||||
let f = caps.get_features(0).unwrap();
|
let f = caps.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()));
|
||||||
|
|
||||||
let caps_ron = r#"
|
let caps_ron = r#"
|
||||||
|
@ -436,7 +436,7 @@ mod tests {
|
||||||
),
|
),
|
||||||
])"#;
|
])"#;
|
||||||
let caps: Caps = ron::de::from_str(caps_ron).unwrap();
|
let caps: Caps = ron::de::from_str(caps_ron).unwrap();
|
||||||
let s = caps.get_structure(0).unwrap();
|
let s = caps.structure(0).unwrap();
|
||||||
assert_eq!(
|
assert_eq!(
|
||||||
s,
|
s,
|
||||||
Structure::new(
|
Structure::new(
|
||||||
|
@ -451,7 +451,7 @@ mod tests {
|
||||||
)
|
)
|
||||||
.as_ref()
|
.as_ref()
|
||||||
);
|
);
|
||||||
let f = caps.get_features(0).unwrap();
|
let f = caps.features(0).unwrap();
|
||||||
assert!(f.is_any());
|
assert!(f.is_any());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -371,14 +371,14 @@ impl cmp::PartialOrd for DateTime {
|
||||||
|
|
||||||
let year_delta = self_norm.year() - other_norm.year();
|
let year_delta = self_norm.year() - other_norm.year();
|
||||||
if year_delta != 0 {
|
if year_delta != 0 {
|
||||||
return get_cmp(year_delta);
|
return cmp(year_delta);
|
||||||
}
|
}
|
||||||
|
|
||||||
// Same year
|
// Same year
|
||||||
|
|
||||||
if !self.has_month() && !other.has_month() {
|
if !self.has_month() && !other.has_month() {
|
||||||
// Nothing left to compare
|
// Nothing left to compare
|
||||||
return get_cmp(year_delta);
|
return cmp(year_delta);
|
||||||
}
|
}
|
||||||
|
|
||||||
if !(self.has_month() && other.has_month()) {
|
if !(self.has_month() && other.has_month()) {
|
||||||
|
@ -388,7 +388,7 @@ impl cmp::PartialOrd for DateTime {
|
||||||
|
|
||||||
let month_delta = self_norm.month().unwrap() - other_norm.month().unwrap();
|
let month_delta = self_norm.month().unwrap() - other_norm.month().unwrap();
|
||||||
if month_delta != 0 {
|
if month_delta != 0 {
|
||||||
return get_cmp(month_delta);
|
return cmp(month_delta);
|
||||||
}
|
}
|
||||||
|
|
||||||
// Same year, same month
|
// Same year, same month
|
||||||
|
@ -405,7 +405,7 @@ impl cmp::PartialOrd for DateTime {
|
||||||
|
|
||||||
let day_delta = self_norm.day().unwrap() - other_norm.day().unwrap();
|
let day_delta = self_norm.day().unwrap() - other_norm.day().unwrap();
|
||||||
if day_delta != 0 {
|
if day_delta != 0 {
|
||||||
return get_cmp(day_delta);
|
return cmp(day_delta);
|
||||||
}
|
}
|
||||||
|
|
||||||
// Same year, same month, same day
|
// Same year, same month, same day
|
||||||
|
@ -422,12 +422,12 @@ impl cmp::PartialOrd for DateTime {
|
||||||
|
|
||||||
let hour_delta = self_norm.hour().unwrap() - other_norm.hour().unwrap();
|
let hour_delta = self_norm.hour().unwrap() - other_norm.hour().unwrap();
|
||||||
if hour_delta != 0 {
|
if hour_delta != 0 {
|
||||||
return get_cmp(hour_delta);
|
return cmp(hour_delta);
|
||||||
}
|
}
|
||||||
|
|
||||||
let minute_delta = self_norm.minute().unwrap() - other_norm.minute().unwrap();
|
let minute_delta = self_norm.minute().unwrap() - other_norm.minute().unwrap();
|
||||||
if minute_delta != 0 {
|
if minute_delta != 0 {
|
||||||
return get_cmp(minute_delta);
|
return cmp(minute_delta);
|
||||||
}
|
}
|
||||||
|
|
||||||
// Same year, same month, same day, same time
|
// Same year, same month, same day, same time
|
||||||
|
@ -443,10 +443,10 @@ impl cmp::PartialOrd for DateTime {
|
||||||
}
|
}
|
||||||
let second_delta = self_norm.second().unwrap() - other_norm.second().unwrap();
|
let second_delta = self_norm.second().unwrap() - other_norm.second().unwrap();
|
||||||
if second_delta != 0 {
|
if second_delta != 0 {
|
||||||
return get_cmp(second_delta);
|
return cmp(second_delta);
|
||||||
}
|
}
|
||||||
|
|
||||||
get_cmp(self_norm.microsecond().unwrap() - other_norm.microsecond().unwrap())
|
cmp(self_norm.microsecond().unwrap() - other_norm.microsecond().unwrap())
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -136,11 +136,11 @@ pub trait ElementExtManual: 'static {
|
||||||
fn set_state(&self, state: State) -> Result<StateChangeSuccess, StateChangeError>;
|
fn set_state(&self, state: State) -> Result<StateChangeSuccess, StateChangeError>;
|
||||||
|
|
||||||
fn current_state(&self) -> State {
|
fn current_state(&self) -> State {
|
||||||
self.get_state(ClockTime::from(0)).1
|
self.state(ClockTime::from(0)).1
|
||||||
}
|
}
|
||||||
|
|
||||||
fn pending_state(&self) -> State {
|
fn pending_state(&self) -> State {
|
||||||
self.get_state(ClockTime::from(0)).2
|
self.state(ClockTime::from(0)).2
|
||||||
}
|
}
|
||||||
|
|
||||||
fn query(&self, query: &mut QueryRef) -> bool;
|
fn query(&self, query: &mut QueryRef) -> bool;
|
||||||
|
@ -353,11 +353,11 @@ impl<O: IsA<Element>> ElementExtManual for O {
|
||||||
}
|
}
|
||||||
|
|
||||||
fn metadata<'a>(&self, key: &str) -> Option<&'a str> {
|
fn metadata<'a>(&self, key: &str) -> Option<&'a str> {
|
||||||
self.element_class().get_metadata(key)
|
self.element_class().metadata(key)
|
||||||
}
|
}
|
||||||
|
|
||||||
fn pad_template(&self, name: &str) -> Option<PadTemplate> {
|
fn pad_template(&self, name: &str) -> Option<PadTemplate> {
|
||||||
self.element_class().get_pad_template(name)
|
self.element_class().pad_template(name)
|
||||||
}
|
}
|
||||||
|
|
||||||
fn pad_template_list(&self) -> Vec<PadTemplate> {
|
fn pad_template_list(&self) -> Vec<PadTemplate> {
|
||||||
|
@ -617,11 +617,11 @@ impl<O: IsA<Element>> ElementExtManual for O {
|
||||||
self.as_ref().to_glib_none().0,
|
self.as_ref().to_glib_none().0,
|
||||||
src_val.format().to_glib(),
|
src_val.format().to_glib(),
|
||||||
src_val.to_raw_value(),
|
src_val.to_raw_value(),
|
||||||
U::get_default_format().to_glib(),
|
U::default_format().to_glib(),
|
||||||
dest_val.as_mut_ptr(),
|
dest_val.as_mut_ptr(),
|
||||||
));
|
));
|
||||||
if ret {
|
if ret {
|
||||||
Some(U::from_raw(U::get_default_format(), dest_val.assume_init()))
|
Some(U::from_raw(U::default_format(), dest_val.assume_init()))
|
||||||
} else {
|
} else {
|
||||||
None
|
None
|
||||||
}
|
}
|
||||||
|
@ -659,11 +659,11 @@ impl<O: IsA<Element>> ElementExtManual for O {
|
||||||
let mut duration = mem::MaybeUninit::uninit();
|
let mut duration = mem::MaybeUninit::uninit();
|
||||||
let ret = from_glib(ffi::gst_element_query_duration(
|
let ret = from_glib(ffi::gst_element_query_duration(
|
||||||
self.as_ref().to_glib_none().0,
|
self.as_ref().to_glib_none().0,
|
||||||
T::get_default_format().to_glib(),
|
T::default_format().to_glib(),
|
||||||
duration.as_mut_ptr(),
|
duration.as_mut_ptr(),
|
||||||
));
|
));
|
||||||
if ret {
|
if ret {
|
||||||
Some(T::from_raw(T::get_default_format(), duration.assume_init()))
|
Some(T::from_raw(T::default_format(), duration.assume_init()))
|
||||||
} else {
|
} else {
|
||||||
None
|
None
|
||||||
}
|
}
|
||||||
|
@ -691,11 +691,11 @@ impl<O: IsA<Element>> ElementExtManual for O {
|
||||||
let mut cur = mem::MaybeUninit::uninit();
|
let mut cur = mem::MaybeUninit::uninit();
|
||||||
let ret = from_glib(ffi::gst_element_query_position(
|
let ret = from_glib(ffi::gst_element_query_position(
|
||||||
self.as_ref().to_glib_none().0,
|
self.as_ref().to_glib_none().0,
|
||||||
T::get_default_format().to_glib(),
|
T::default_format().to_glib(),
|
||||||
cur.as_mut_ptr(),
|
cur.as_mut_ptr(),
|
||||||
));
|
));
|
||||||
if ret {
|
if ret {
|
||||||
Some(T::from_raw(T::get_default_format(), cur.assume_init()))
|
Some(T::from_raw(T::default_format(), cur.assume_init()))
|
||||||
} else {
|
} else {
|
||||||
None
|
None
|
||||||
}
|
}
|
||||||
|
|
|
@ -29,7 +29,7 @@ pub unsafe trait MetaAPI: Sync + Send + Sized {
|
||||||
unsafe fn from_ptr(buffer: &BufferRef, ptr: *const Self::GstType) -> MetaRef<Self> {
|
unsafe fn from_ptr(buffer: &BufferRef, ptr: *const Self::GstType) -> MetaRef<Self> {
|
||||||
assert!(!ptr.is_null());
|
assert!(!ptr.is_null());
|
||||||
|
|
||||||
let meta_api = Self::get_meta_api();
|
let meta_api = Self::meta_api();
|
||||||
if meta_api != glib::Type::INVALID {
|
if meta_api != glib::Type::INVALID {
|
||||||
assert_eq!(
|
assert_eq!(
|
||||||
meta_api,
|
meta_api,
|
||||||
|
@ -49,7 +49,7 @@ pub unsafe trait MetaAPI: Sync + Send + Sized {
|
||||||
) -> MetaRefMut<Self, T> {
|
) -> MetaRefMut<Self, T> {
|
||||||
assert!(!ptr.is_null());
|
assert!(!ptr.is_null());
|
||||||
|
|
||||||
let meta_api = Self::get_meta_api();
|
let meta_api = Self::meta_api();
|
||||||
if meta_api != glib::Type::INVALID {
|
if meta_api != glib::Type::INVALID {
|
||||||
assert_eq!(
|
assert_eq!(
|
||||||
meta_api,
|
meta_api,
|
||||||
|
@ -162,7 +162,7 @@ impl<'a, T: MetaAPI> MetaRef<'a, T> {
|
||||||
|
|
||||||
impl<'a> MetaRef<'a, Meta> {
|
impl<'a> MetaRef<'a, Meta> {
|
||||||
pub fn downcast_ref<T: MetaAPI>(&self) -> Option<&MetaRef<'a, T>> {
|
pub fn downcast_ref<T: MetaAPI>(&self) -> Option<&MetaRef<'a, T>> {
|
||||||
let target_type = T::get_meta_api();
|
let target_type = T::meta_api();
|
||||||
let type_ = self.api();
|
let type_ = self.api();
|
||||||
|
|
||||||
if type_ == glib::Type::INVALID || target_type == type_ {
|
if type_ == glib::Type::INVALID || target_type == type_ {
|
||||||
|
@ -214,7 +214,7 @@ impl<'a, T: MetaAPI> MetaRefMut<'a, T, Standalone> {
|
||||||
|
|
||||||
impl<'a, U> MetaRefMut<'a, Meta, U> {
|
impl<'a, U> MetaRefMut<'a, Meta, U> {
|
||||||
pub fn downcast_ref<T: MetaAPI>(&mut self) -> Option<&MetaRefMut<'a, T, U>> {
|
pub fn downcast_ref<T: MetaAPI>(&mut self) -> Option<&MetaRefMut<'a, T, U>> {
|
||||||
let target_type = T::get_meta_api();
|
let target_type = T::meta_api();
|
||||||
let type_ = self.api();
|
let type_ = self.api();
|
||||||
|
|
||||||
if type_ == glib::Type::INVALID || target_type == type_ {
|
if type_ == glib::Type::INVALID || target_type == type_ {
|
||||||
|
@ -457,7 +457,7 @@ mod tests {
|
||||||
let meta = buffer
|
let meta = buffer
|
||||||
.get_mut()
|
.get_mut()
|
||||||
.unwrap()
|
.unwrap()
|
||||||
.get_meta_mut::<ParentBufferMeta>()
|
.meta_mut::<ParentBufferMeta>()
|
||||||
.unwrap();
|
.unwrap();
|
||||||
unsafe {
|
unsafe {
|
||||||
assert_eq!(meta.parent().as_ptr(), parent.as_ptr());
|
assert_eq!(meta.parent().as_ptr(), parent.as_ptr());
|
||||||
|
@ -485,6 +485,6 @@ mod tests {
|
||||||
assert_eq!(metas.count(), 0);
|
assert_eq!(metas.count(), 0);
|
||||||
}
|
}
|
||||||
|
|
||||||
assert!(buffer.get_meta::<ParentBufferMeta>().is_none());
|
assert!(buffer.meta::<ParentBufferMeta>().is_none());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -420,7 +420,7 @@ macro_rules! mini_object_wrapper (
|
||||||
|
|
||||||
impl $crate::glib::types::StaticType for $ref_name {
|
impl $crate::glib::types::StaticType for $ref_name {
|
||||||
fn static_type() -> $crate::glib::types::Type {
|
fn static_type() -> $crate::glib::types::Type {
|
||||||
unsafe { $crate::glib::translate::from_glib($get_type()) }
|
unsafe { $crate::glib::translate::from_glib($type_()) }
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -768,11 +768,11 @@ impl<O: IsA<Pad>> PadExtManual for O {
|
||||||
self.as_ref().to_glib_none().0,
|
self.as_ref().to_glib_none().0,
|
||||||
src_val.format().to_glib(),
|
src_val.format().to_glib(),
|
||||||
src_val.to_raw_value(),
|
src_val.to_raw_value(),
|
||||||
U::get_default_format().to_glib(),
|
U::default_format().to_glib(),
|
||||||
dest_val.as_mut_ptr(),
|
dest_val.as_mut_ptr(),
|
||||||
));
|
));
|
||||||
if ret {
|
if ret {
|
||||||
Some(U::from_raw(U::get_default_format(), dest_val.assume_init()))
|
Some(U::from_raw(U::default_format(), dest_val.assume_init()))
|
||||||
} else {
|
} else {
|
||||||
None
|
None
|
||||||
}
|
}
|
||||||
|
@ -810,11 +810,11 @@ impl<O: IsA<Pad>> PadExtManual for O {
|
||||||
let mut duration = mem::MaybeUninit::uninit();
|
let mut duration = mem::MaybeUninit::uninit();
|
||||||
let ret = from_glib(ffi::gst_pad_peer_query_duration(
|
let ret = from_glib(ffi::gst_pad_peer_query_duration(
|
||||||
self.as_ref().to_glib_none().0,
|
self.as_ref().to_glib_none().0,
|
||||||
T::get_default_format().to_glib(),
|
T::default_format().to_glib(),
|
||||||
duration.as_mut_ptr(),
|
duration.as_mut_ptr(),
|
||||||
));
|
));
|
||||||
if ret {
|
if ret {
|
||||||
Some(T::from_raw(T::get_default_format(), duration.assume_init()))
|
Some(T::from_raw(T::default_format(), duration.assume_init()))
|
||||||
} else {
|
} else {
|
||||||
None
|
None
|
||||||
}
|
}
|
||||||
|
@ -842,11 +842,11 @@ impl<O: IsA<Pad>> PadExtManual for O {
|
||||||
let mut cur = mem::MaybeUninit::uninit();
|
let mut cur = mem::MaybeUninit::uninit();
|
||||||
let ret = from_glib(ffi::gst_pad_peer_query_position(
|
let ret = from_glib(ffi::gst_pad_peer_query_position(
|
||||||
self.as_ref().to_glib_none().0,
|
self.as_ref().to_glib_none().0,
|
||||||
T::get_default_format().to_glib(),
|
T::default_format().to_glib(),
|
||||||
cur.as_mut_ptr(),
|
cur.as_mut_ptr(),
|
||||||
));
|
));
|
||||||
if ret {
|
if ret {
|
||||||
Some(T::from_raw(T::get_default_format(), cur.assume_init()))
|
Some(T::from_raw(T::default_format(), cur.assume_init()))
|
||||||
} else {
|
} else {
|
||||||
None
|
None
|
||||||
}
|
}
|
||||||
|
@ -881,11 +881,11 @@ impl<O: IsA<Pad>> PadExtManual for O {
|
||||||
self.as_ref().to_glib_none().0,
|
self.as_ref().to_glib_none().0,
|
||||||
src_val.format().to_glib(),
|
src_val.format().to_glib(),
|
||||||
src_val.to_raw_value(),
|
src_val.to_raw_value(),
|
||||||
U::get_default_format().to_glib(),
|
U::default_format().to_glib(),
|
||||||
dest_val.as_mut_ptr(),
|
dest_val.as_mut_ptr(),
|
||||||
));
|
));
|
||||||
if ret {
|
if ret {
|
||||||
Some(U::from_raw(U::get_default_format(), dest_val.assume_init()))
|
Some(U::from_raw(U::default_format(), dest_val.assume_init()))
|
||||||
} else {
|
} else {
|
||||||
None
|
None
|
||||||
}
|
}
|
||||||
|
@ -924,11 +924,11 @@ impl<O: IsA<Pad>> PadExtManual for O {
|
||||||
let mut duration = mem::MaybeUninit::uninit();
|
let mut duration = mem::MaybeUninit::uninit();
|
||||||
let ret = from_glib(ffi::gst_pad_query_duration(
|
let ret = from_glib(ffi::gst_pad_query_duration(
|
||||||
self.as_ref().to_glib_none().0,
|
self.as_ref().to_glib_none().0,
|
||||||
T::get_default_format().to_glib(),
|
T::default_format().to_glib(),
|
||||||
duration.as_mut_ptr(),
|
duration.as_mut_ptr(),
|
||||||
));
|
));
|
||||||
if ret {
|
if ret {
|
||||||
Some(T::from_raw(T::get_default_format(), duration.assume_init()))
|
Some(T::from_raw(T::default_format(), duration.assume_init()))
|
||||||
} else {
|
} else {
|
||||||
None
|
None
|
||||||
}
|
}
|
||||||
|
@ -956,11 +956,11 @@ impl<O: IsA<Pad>> PadExtManual for O {
|
||||||
let mut cur = mem::MaybeUninit::uninit();
|
let mut cur = mem::MaybeUninit::uninit();
|
||||||
let ret = from_glib(ffi::gst_pad_query_position(
|
let ret = from_glib(ffi::gst_pad_query_position(
|
||||||
self.as_ref().to_glib_none().0,
|
self.as_ref().to_glib_none().0,
|
||||||
T::get_default_format().to_glib(),
|
T::default_format().to_glib(),
|
||||||
cur.as_mut_ptr(),
|
cur.as_mut_ptr(),
|
||||||
));
|
));
|
||||||
if ret {
|
if ret {
|
||||||
Some(T::from_raw(T::get_default_format(), cur.assume_init()))
|
Some(T::from_raw(T::default_format(), cur.assume_init()))
|
||||||
} else {
|
} else {
|
||||||
None
|
None
|
||||||
}
|
}
|
||||||
|
@ -1661,7 +1661,7 @@ impl<T: IsA<Pad> + IsA<glib::Object> + glib::object::IsClass> PadBuilder<T> {
|
||||||
// additional checks here now
|
// additional checks here now
|
||||||
if templ.has_property("gtype", Some(glib::Type::static_type())) {
|
if templ.has_property("gtype", Some(glib::Type::static_type())) {
|
||||||
let gtype = templ
|
let gtype = templ
|
||||||
.get_property("gtype")
|
.property("gtype")
|
||||||
.unwrap()
|
.unwrap()
|
||||||
.get_some::<glib::Type>()
|
.get_some::<glib::Type>()
|
||||||
.unwrap();
|
.unwrap();
|
||||||
|
@ -1934,12 +1934,12 @@ mod tests {
|
||||||
.build();
|
.build();
|
||||||
pad.set_active(true).unwrap();
|
pad.set_active(true).unwrap();
|
||||||
|
|
||||||
let buffer = pad.get_range(0, 5).unwrap();
|
let buffer = pad.range(0, 5).unwrap();
|
||||||
let map = buffer.map_readable().unwrap();
|
let map = buffer.map_readable().unwrap();
|
||||||
assert_eq!(&*map, b"abcde");
|
assert_eq!(&*map, b"abcde");
|
||||||
|
|
||||||
let mut buffer = crate::Buffer::with_size(5).unwrap();
|
let mut buffer = crate::Buffer::with_size(5).unwrap();
|
||||||
pad.get_range_fill(0, buffer.get_mut().unwrap(), 5).unwrap();
|
pad.range_fill(0, buffer.get_mut().unwrap(), 5).unwrap();
|
||||||
let map = buffer.map_readable().unwrap();
|
let map = buffer.map_readable().unwrap();
|
||||||
assert_eq!(&*map, b"abcde");
|
assert_eq!(&*map, b"abcde");
|
||||||
|
|
||||||
|
@ -1965,12 +1965,12 @@ mod tests {
|
||||||
.build();
|
.build();
|
||||||
pad.set_active(true).unwrap();
|
pad.set_active(true).unwrap();
|
||||||
|
|
||||||
let buffer = pad.get_range(0, 5).unwrap();
|
let buffer = pad.range(0, 5).unwrap();
|
||||||
let map = buffer.map_readable().unwrap();
|
let map = buffer.map_readable().unwrap();
|
||||||
assert_eq!(&*map, b"abcde");
|
assert_eq!(&*map, b"abcde");
|
||||||
|
|
||||||
let mut buffer = crate::Buffer::with_size(5).unwrap();
|
let mut buffer = crate::Buffer::with_size(5).unwrap();
|
||||||
pad.get_range_fill(0, buffer.get_mut().unwrap(), 5).unwrap();
|
pad.range_fill(0, buffer.get_mut().unwrap(), 5).unwrap();
|
||||||
let map = buffer.map_readable().unwrap();
|
let map = buffer.map_readable().unwrap();
|
||||||
assert_eq!(&*map, b"fghij");
|
assert_eq!(&*map, b"fghij");
|
||||||
}
|
}
|
||||||
|
|
|
@ -53,7 +53,7 @@ impl Promise {
|
||||||
let promise: Borrowed<Promise> = from_glib_borrow(promise);
|
let promise: Borrowed<Promise> = from_glib_borrow(promise);
|
||||||
|
|
||||||
let res = match promise.wait() {
|
let res = match promise.wait() {
|
||||||
PromiseResult::Replied => Ok(promise.get_reply()),
|
PromiseResult::Replied => Ok(promise.reply()),
|
||||||
PromiseResult::Interrupted => Err(PromiseError::Interrupted),
|
PromiseResult::Interrupted => Err(PromiseError::Interrupted),
|
||||||
PromiseResult::Expired => Err(PromiseError::Expired),
|
PromiseResult::Expired => Err(PromiseError::Expired),
|
||||||
PromiseResult::Pending => {
|
PromiseResult::Pending => {
|
||||||
|
|
|
@ -946,7 +946,7 @@ impl<T: AsPtr> Allocation<T> {
|
||||||
let mut idx = mem::MaybeUninit::uninit();
|
let mut idx = mem::MaybeUninit::uninit();
|
||||||
if ffi::gst_query_find_allocation_meta(
|
if ffi::gst_query_find_allocation_meta(
|
||||||
self.0.as_ptr(),
|
self.0.as_ptr(),
|
||||||
U::get_meta_api().to_glib(),
|
U::meta_api().to_glib(),
|
||||||
idx.as_mut_ptr(),
|
idx.as_mut_ptr(),
|
||||||
) != glib::ffi::GFALSE
|
) != glib::ffi::GFALSE
|
||||||
{
|
{
|
||||||
|
@ -1010,7 +1010,7 @@ impl<T: AsMutPtr> Allocation<T> {
|
||||||
unsafe {
|
unsafe {
|
||||||
ffi::gst_query_add_allocation_meta(
|
ffi::gst_query_add_allocation_meta(
|
||||||
self.0.as_mut_ptr(),
|
self.0.as_mut_ptr(),
|
||||||
U::get_meta_api().to_glib(),
|
U::meta_api().to_glib(),
|
||||||
if let Some(structure) = structure {
|
if let Some(structure) = structure {
|
||||||
structure.as_ptr()
|
structure.as_ptr()
|
||||||
} else {
|
} else {
|
||||||
|
|
|
@ -27,8 +27,7 @@ impl Segment {
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn downcast<T: FormattedValue>(self) -> Result<FormattedSegment<T>, Self> {
|
pub fn downcast<T: FormattedValue>(self) -> Result<FormattedSegment<T>, Self> {
|
||||||
if T::get_default_format() == Format::Undefined || T::get_default_format() == self.format()
|
if T::default_format() == Format::Undefined || T::default_format() == self.format() {
|
||||||
{
|
|
||||||
Ok(FormattedSegment(self.0, PhantomData))
|
Ok(FormattedSegment(self.0, PhantomData))
|
||||||
} else {
|
} else {
|
||||||
Err(self)
|
Err(self)
|
||||||
|
@ -36,8 +35,7 @@ impl Segment {
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn downcast_ref<T: FormattedValue>(&self) -> Option<&FormattedSegment<T>> {
|
pub fn downcast_ref<T: FormattedValue>(&self) -> Option<&FormattedSegment<T>> {
|
||||||
if T::get_default_format() == Format::Undefined || T::get_default_format() == self.format()
|
if T::default_format() == Format::Undefined || T::default_format() == self.format() {
|
||||||
{
|
|
||||||
Some(unsafe {
|
Some(unsafe {
|
||||||
&*(self as *const FormattedSegment<GenericFormattedValue>
|
&*(self as *const FormattedSegment<GenericFormattedValue>
|
||||||
as *const FormattedSegment<T>)
|
as *const FormattedSegment<T>)
|
||||||
|
@ -48,8 +46,7 @@ impl Segment {
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn downcast_mut<T: FormattedValue>(&mut self) -> Option<&mut FormattedSegment<T>> {
|
pub fn downcast_mut<T: FormattedValue>(&mut self) -> Option<&mut FormattedSegment<T>> {
|
||||||
if T::get_default_format() == Format::Undefined || T::get_default_format() == self.format()
|
if T::default_format() == Format::Undefined || T::default_format() == self.format() {
|
||||||
{
|
|
||||||
Some(unsafe {
|
Some(unsafe {
|
||||||
&mut *(self as *mut FormattedSegment<GenericFormattedValue>
|
&mut *(self as *mut FormattedSegment<GenericFormattedValue>
|
||||||
as *mut FormattedSegment<T>)
|
as *mut FormattedSegment<T>)
|
||||||
|
@ -65,7 +62,7 @@ impl<T: FormattedValue> FormattedSegment<T> {
|
||||||
assert_initialized_main_thread!();
|
assert_initialized_main_thread!();
|
||||||
let segment = unsafe {
|
let segment = unsafe {
|
||||||
let mut segment = mem::MaybeUninit::zeroed();
|
let mut segment = mem::MaybeUninit::zeroed();
|
||||||
ffi::gst_segment_init(segment.as_mut_ptr(), T::get_default_format().to_glib());
|
ffi::gst_segment_init(segment.as_mut_ptr(), T::default_format().to_glib());
|
||||||
segment.assume_init()
|
segment.assume_init()
|
||||||
};
|
};
|
||||||
FormattedSegment(segment, PhantomData)
|
FormattedSegment(segment, PhantomData)
|
||||||
|
@ -83,7 +80,7 @@ impl<T: FormattedValue> FormattedSegment<T> {
|
||||||
|
|
||||||
pub fn reset(&mut self) {
|
pub fn reset(&mut self) {
|
||||||
unsafe {
|
unsafe {
|
||||||
ffi::gst_segment_init(&mut self.0, T::get_default_format().to_glib());
|
ffi::gst_segment_init(&mut self.0, T::default_format().to_glib());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -91,7 +88,7 @@ impl<T: FormattedValue> FormattedSegment<T> {
|
||||||
let start = start.into();
|
let start = start.into();
|
||||||
let stop = stop.into();
|
let stop = stop.into();
|
||||||
|
|
||||||
if T::get_default_format() == Format::Undefined {
|
if T::default_format() == Format::Undefined {
|
||||||
assert_eq!(self.format(), start.format());
|
assert_eq!(self.format(), start.format());
|
||||||
assert_eq!(self.format(), stop.format());
|
assert_eq!(self.format(), stop.format());
|
||||||
}
|
}
|
||||||
|
@ -132,7 +129,7 @@ impl<T: FormattedValue> FormattedSegment<T> {
|
||||||
let start = start.into();
|
let start = start.into();
|
||||||
let stop = stop.into();
|
let stop = stop.into();
|
||||||
|
|
||||||
if T::get_default_format() == Format::Undefined {
|
if T::default_format() == Format::Undefined {
|
||||||
assert_eq!(self.format(), start.format());
|
assert_eq!(self.format(), start.format());
|
||||||
assert_eq!(self.format(), stop.format());
|
assert_eq!(self.format(), stop.format());
|
||||||
}
|
}
|
||||||
|
@ -170,7 +167,7 @@ impl<T: FormattedValue> FormattedSegment<T> {
|
||||||
pub fn position_from_running_time<V: Into<T>>(&self, running_time: V) -> T {
|
pub fn position_from_running_time<V: Into<T>>(&self, running_time: V) -> T {
|
||||||
let running_time = running_time.into();
|
let running_time = running_time.into();
|
||||||
|
|
||||||
if T::get_default_format() == Format::Undefined {
|
if T::default_format() == Format::Undefined {
|
||||||
assert_eq!(self.format(), running_time.format());
|
assert_eq!(self.format(), running_time.format());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -189,7 +186,7 @@ impl<T: FormattedValue> FormattedSegment<T> {
|
||||||
pub fn position_from_running_time_full<V: Into<T>>(&self, running_time: V) -> (i32, T) {
|
pub fn position_from_running_time_full<V: Into<T>>(&self, running_time: V) -> (i32, T) {
|
||||||
let running_time = running_time.into();
|
let running_time = running_time.into();
|
||||||
|
|
||||||
if T::get_default_format() == Format::Undefined {
|
if T::default_format() == Format::Undefined {
|
||||||
assert_eq!(self.format(), running_time.format());
|
assert_eq!(self.format(), running_time.format());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -211,7 +208,7 @@ impl<T: FormattedValue> FormattedSegment<T> {
|
||||||
pub fn position_from_stream_time<V: Into<T>>(&self, stream_time: V) -> T {
|
pub fn position_from_stream_time<V: Into<T>>(&self, stream_time: V) -> T {
|
||||||
let stream_time = stream_time.into();
|
let stream_time = stream_time.into();
|
||||||
|
|
||||||
if T::get_default_format() == Format::Undefined {
|
if T::default_format() == Format::Undefined {
|
||||||
assert_eq!(self.format(), stream_time.format());
|
assert_eq!(self.format(), stream_time.format());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -230,7 +227,7 @@ impl<T: FormattedValue> FormattedSegment<T> {
|
||||||
pub fn position_from_stream_time_full<V: Into<T>>(&self, stream_time: V) -> (i32, T) {
|
pub fn position_from_stream_time_full<V: Into<T>>(&self, stream_time: V) -> (i32, T) {
|
||||||
let stream_time = stream_time.into();
|
let stream_time = stream_time.into();
|
||||||
|
|
||||||
if T::get_default_format() == Format::Undefined {
|
if T::default_format() == Format::Undefined {
|
||||||
assert_eq!(self.format(), stream_time.format());
|
assert_eq!(self.format(), stream_time.format());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -252,7 +249,7 @@ impl<T: FormattedValue> FormattedSegment<T> {
|
||||||
pub fn set_running_time<V: Into<T>>(&mut self, running_time: V) -> Result<(), glib::BoolError> {
|
pub fn set_running_time<V: Into<T>>(&mut self, running_time: V) -> Result<(), glib::BoolError> {
|
||||||
let running_time = running_time.into();
|
let running_time = running_time.into();
|
||||||
|
|
||||||
if T::get_default_format() == Format::Undefined {
|
if T::default_format() == Format::Undefined {
|
||||||
assert_eq!(self.format(), running_time.format());
|
assert_eq!(self.format(), running_time.format());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -271,7 +268,7 @@ impl<T: FormattedValue> FormattedSegment<T> {
|
||||||
pub fn to_running_time<V: Into<T>>(&self, position: V) -> T {
|
pub fn to_running_time<V: Into<T>>(&self, position: V) -> T {
|
||||||
let position = position.into();
|
let position = position.into();
|
||||||
|
|
||||||
if T::get_default_format() == Format::Undefined {
|
if T::default_format() == Format::Undefined {
|
||||||
assert_eq!(self.format(), position.format());
|
assert_eq!(self.format(), position.format());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -290,7 +287,7 @@ impl<T: FormattedValue> FormattedSegment<T> {
|
||||||
pub fn to_running_time_full<V: Into<T>>(&self, position: V) -> (i32, T) {
|
pub fn to_running_time_full<V: Into<T>>(&self, position: V) -> (i32, T) {
|
||||||
let position = position.into();
|
let position = position.into();
|
||||||
|
|
||||||
if T::get_default_format() == Format::Undefined {
|
if T::default_format() == Format::Undefined {
|
||||||
assert_eq!(self.format(), position.format());
|
assert_eq!(self.format(), position.format());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -312,7 +309,7 @@ impl<T: FormattedValue> FormattedSegment<T> {
|
||||||
pub fn to_stream_time<V: Into<T>>(&self, position: V) -> T {
|
pub fn to_stream_time<V: Into<T>>(&self, position: V) -> T {
|
||||||
let position = position.into();
|
let position = position.into();
|
||||||
|
|
||||||
if T::get_default_format() == Format::Undefined {
|
if T::default_format() == Format::Undefined {
|
||||||
assert_eq!(self.format(), position.format());
|
assert_eq!(self.format(), position.format());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -331,7 +328,7 @@ impl<T: FormattedValue> FormattedSegment<T> {
|
||||||
pub fn to_stream_time_full<V: Into<T>>(&self, position: V) -> (i32, T) {
|
pub fn to_stream_time_full<V: Into<T>>(&self, position: V) -> (i32, T) {
|
||||||
let position = position.into();
|
let position = position.into();
|
||||||
|
|
||||||
if T::get_default_format() == Format::Undefined {
|
if T::default_format() == Format::Undefined {
|
||||||
assert_eq!(self.format(), position.format());
|
assert_eq!(self.format(), position.format());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -389,7 +386,7 @@ impl<T: FormattedValue> FormattedSegment<T> {
|
||||||
pub fn set_base<V: Into<T>>(&mut self, base: V) {
|
pub fn set_base<V: Into<T>>(&mut self, base: V) {
|
||||||
let base = base.into();
|
let base = base.into();
|
||||||
|
|
||||||
if T::get_default_format() == Format::Undefined {
|
if T::default_format() == Format::Undefined {
|
||||||
assert_eq!(self.format(), base.format());
|
assert_eq!(self.format(), base.format());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -403,7 +400,7 @@ impl<T: FormattedValue> FormattedSegment<T> {
|
||||||
pub fn set_offset<V: Into<T>>(&mut self, offset: V) {
|
pub fn set_offset<V: Into<T>>(&mut self, offset: V) {
|
||||||
let offset = offset.into();
|
let offset = offset.into();
|
||||||
|
|
||||||
if T::get_default_format() == Format::Undefined {
|
if T::default_format() == Format::Undefined {
|
||||||
assert_eq!(self.format(), offset.format());
|
assert_eq!(self.format(), offset.format());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -417,7 +414,7 @@ impl<T: FormattedValue> FormattedSegment<T> {
|
||||||
pub fn set_start<V: Into<T>>(&mut self, start: V) {
|
pub fn set_start<V: Into<T>>(&mut self, start: V) {
|
||||||
let start = start.into();
|
let start = start.into();
|
||||||
|
|
||||||
if T::get_default_format() == Format::Undefined {
|
if T::default_format() == Format::Undefined {
|
||||||
assert_eq!(self.format(), start.format());
|
assert_eq!(self.format(), start.format());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -431,7 +428,7 @@ impl<T: FormattedValue> FormattedSegment<T> {
|
||||||
pub fn set_stop<V: Into<T>>(&mut self, stop: V) {
|
pub fn set_stop<V: Into<T>>(&mut self, stop: V) {
|
||||||
let stop = stop.into();
|
let stop = stop.into();
|
||||||
|
|
||||||
if T::get_default_format() == Format::Undefined {
|
if T::default_format() == Format::Undefined {
|
||||||
assert_eq!(self.format(), stop.format());
|
assert_eq!(self.format(), stop.format());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -445,7 +442,7 @@ impl<T: FormattedValue> FormattedSegment<T> {
|
||||||
pub fn set_time<V: Into<T>>(&mut self, time: V) {
|
pub fn set_time<V: Into<T>>(&mut self, time: V) {
|
||||||
let time = time.into();
|
let time = time.into();
|
||||||
|
|
||||||
if T::get_default_format() == Format::Undefined {
|
if T::default_format() == Format::Undefined {
|
||||||
assert_eq!(self.format(), time.format());
|
assert_eq!(self.format(), time.format());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -459,7 +456,7 @@ impl<T: FormattedValue> FormattedSegment<T> {
|
||||||
pub fn set_position<V: Into<T>>(&mut self, position: V) {
|
pub fn set_position<V: Into<T>>(&mut self, position: V) {
|
||||||
let position = position.into();
|
let position = position.into();
|
||||||
|
|
||||||
if T::get_default_format() == Format::Undefined {
|
if T::default_format() == Format::Undefined {
|
||||||
assert_eq!(self.format(), position.format());
|
assert_eq!(self.format(), position.format());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -473,7 +470,7 @@ impl<T: FormattedValue> FormattedSegment<T> {
|
||||||
pub fn set_duration<V: Into<T>>(&mut self, duration: V) {
|
pub fn set_duration<V: Into<T>>(&mut self, duration: V) {
|
||||||
let duration = duration.into();
|
let duration = duration.into();
|
||||||
|
|
||||||
if T::get_default_format() == Format::Undefined {
|
if T::default_format() == Format::Undefined {
|
||||||
assert_eq!(self.format(), duration.format());
|
assert_eq!(self.format(), duration.format());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -99,7 +99,7 @@ impl<'de, T: FormattedValue + SpecificFormattedValue> Deserialize<'de> for Forma
|
||||||
de::Error::custom(format!(
|
de::Error::custom(format!(
|
||||||
"failed to convert segment with format {:?} to {:?}",
|
"failed to convert segment with format {:?} to {:?}",
|
||||||
segment.format(),
|
segment.format(),
|
||||||
T::get_default_format(),
|
T::default_format(),
|
||||||
))
|
))
|
||||||
})
|
})
|
||||||
})
|
})
|
||||||
|
|
|
@ -31,7 +31,7 @@ impl<'a> Iterator for Iter<'a> {
|
||||||
return None;
|
return None;
|
||||||
}
|
}
|
||||||
|
|
||||||
let item = self.collection.get_stream(self.idx);
|
let item = self.collection.stream(self.idx);
|
||||||
self.idx += 1;
|
self.idx += 1;
|
||||||
|
|
||||||
item
|
item
|
||||||
|
@ -55,7 +55,7 @@ impl<'a> DoubleEndedIterator for Iter<'a> {
|
||||||
}
|
}
|
||||||
|
|
||||||
self.size -= 1;
|
self.size -= 1;
|
||||||
self.collection.get_stream(self.size)
|
self.collection.stream(self.size)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -340,7 +340,7 @@ impl StructureRef {
|
||||||
&'structure self,
|
&'structure self,
|
||||||
name: &'name str,
|
name: &'name str,
|
||||||
) -> Result<Option<T>, GetError<'name>> {
|
) -> Result<Option<T>, GetError<'name>> {
|
||||||
self.get_value(name)?
|
self.value(name)?
|
||||||
.get()
|
.get()
|
||||||
.map_err(|err| GetError::from_value_get_error(name, err))
|
.map_err(|err| GetError::from_value_get_error(name, err))
|
||||||
}
|
}
|
||||||
|
@ -349,7 +349,7 @@ impl StructureRef {
|
||||||
&'structure self,
|
&'structure self,
|
||||||
name: &'name str,
|
name: &'name str,
|
||||||
) -> Result<Option<T>, GetError<'name>> {
|
) -> Result<Option<T>, GetError<'name>> {
|
||||||
let value = self.get_value(name);
|
let value = self.value(name);
|
||||||
if let Ok(value) = value {
|
if let Ok(value) = value {
|
||||||
value
|
value
|
||||||
.get()
|
.get()
|
||||||
|
@ -363,7 +363,7 @@ impl StructureRef {
|
||||||
&'structure self,
|
&'structure self,
|
||||||
name: &'name str,
|
name: &'name str,
|
||||||
) -> Result<T, GetError<'name>> {
|
) -> Result<T, GetError<'name>> {
|
||||||
self.get_value(name)?
|
self.value(name)?
|
||||||
.get_some()
|
.get_some()
|
||||||
.map_err(|err| GetError::from_value_get_error(name, err))
|
.map_err(|err| GetError::from_value_get_error(name, err))
|
||||||
}
|
}
|
||||||
|
@ -635,7 +635,7 @@ impl<'a> Iterator for FieldIterator<'a> {
|
||||||
return None;
|
return None;
|
||||||
}
|
}
|
||||||
|
|
||||||
if let Some(field_name) = self.structure.get_nth_field_name(self.idx) {
|
if let Some(field_name) = self.structure.nth_field_name(self.idx) {
|
||||||
self.idx += 1;
|
self.idx += 1;
|
||||||
Some(field_name)
|
Some(field_name)
|
||||||
} else {
|
} else {
|
||||||
|
@ -661,7 +661,7 @@ impl<'a> DoubleEndedIterator for FieldIterator<'a> {
|
||||||
}
|
}
|
||||||
|
|
||||||
self.n_fields -= 1;
|
self.n_fields -= 1;
|
||||||
if let Some(field_name) = self.structure.get_nth_field_name(self.n_fields) {
|
if let Some(field_name) = self.structure.nth_field_name(self.n_fields) {
|
||||||
Some(field_name)
|
Some(field_name)
|
||||||
} else {
|
} else {
|
||||||
None
|
None
|
||||||
|
@ -690,7 +690,7 @@ impl<'a> Iterator for Iter<'a> {
|
||||||
|
|
||||||
fn next(&mut self) -> Option<Self::Item> {
|
fn next(&mut self) -> Option<Self::Item> {
|
||||||
if let Some(f) = self.iter.next() {
|
if let Some(f) = self.iter.next() {
|
||||||
let v = self.iter.structure.get_value(f);
|
let v = self.iter.structure.value(f);
|
||||||
Some((f, v.unwrap()))
|
Some((f, v.unwrap()))
|
||||||
} else {
|
} else {
|
||||||
None
|
None
|
||||||
|
@ -705,7 +705,7 @@ impl<'a> Iterator for Iter<'a> {
|
||||||
impl<'a> DoubleEndedIterator for Iter<'a> {
|
impl<'a> DoubleEndedIterator for Iter<'a> {
|
||||||
fn next_back(&mut self) -> Option<Self::Item> {
|
fn next_back(&mut self) -> Option<Self::Item> {
|
||||||
if let Some(f) = self.iter.next_back() {
|
if let Some(f) = self.iter.next_back() {
|
||||||
let v = self.iter.structure.get_value(f);
|
let v = self.iter.structure.value(f);
|
||||||
Some((f, v.unwrap()))
|
Some((f, v.unwrap()))
|
||||||
} else {
|
} else {
|
||||||
None
|
None
|
||||||
|
|
|
@ -644,7 +644,7 @@ mod tests {
|
||||||
type ParentType = Element;
|
type ParentType = Element;
|
||||||
|
|
||||||
fn with_class(klass: &Self::Class) -> Self {
|
fn with_class(klass: &Self::Class) -> Self {
|
||||||
let templ = klass.get_pad_template("sink").unwrap();
|
let templ = klass.pad_template("sink").unwrap();
|
||||||
let sinkpad = crate::Pad::builder_with_template(&templ, Some("sink"))
|
let sinkpad = crate::Pad::builder_with_template(&templ, Some("sink"))
|
||||||
.chain_function(|pad, parent, buffer| {
|
.chain_function(|pad, parent, buffer| {
|
||||||
TestElement::catch_panic_pad_function(
|
TestElement::catch_panic_pad_function(
|
||||||
|
@ -669,7 +669,7 @@ mod tests {
|
||||||
})
|
})
|
||||||
.build();
|
.build();
|
||||||
|
|
||||||
let templ = klass.get_pad_template("src").unwrap();
|
let templ = klass.pad_template("src").unwrap();
|
||||||
let srcpad = crate::Pad::builder_with_template(&templ, Some("src"))
|
let srcpad = crate::Pad::builder_with_template(&templ, Some("src"))
|
||||||
.event_function(|pad, parent, event| {
|
.event_function(|pad, parent, event| {
|
||||||
TestElement::catch_panic_pad_function(
|
TestElement::catch_panic_pad_function(
|
||||||
|
@ -783,7 +783,7 @@ mod tests {
|
||||||
assert_eq!(element.name(), "test");
|
assert_eq!(element.name(), "test");
|
||||||
|
|
||||||
assert_eq!(
|
assert_eq!(
|
||||||
element.get_metadata(&crate::ELEMENT_METADATA_LONGNAME),
|
element.metadata(&crate::ELEMENT_METADATA_LONGNAME),
|
||||||
Some("Test Element")
|
Some("Test Element")
|
||||||
);
|
);
|
||||||
|
|
||||||
|
|
|
@ -432,7 +432,7 @@ impl TagListRef {
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn get<'a, T: Tag<'a>>(&self) -> Option<TagValue<T::TagType>> {
|
pub fn get<'a, T: Tag<'a>>(&self) -> Option<TagValue<T::TagType>> {
|
||||||
self.get_generic(T::tag_name()).map(|value| {
|
self.generic(T::tag_name()).map(|value| {
|
||||||
if !value.is::<T::TagType>() {
|
if !value.is::<T::TagType>() {
|
||||||
panic!(
|
panic!(
|
||||||
"TagListRef::get type mismatch for tag {}: {}",
|
"TagListRef::get type mismatch for tag {}: {}",
|
||||||
|
@ -475,7 +475,7 @@ impl TagListRef {
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn index<'a, T: Tag<'a>>(&self, idx: u32) -> Option<&'a TagValue<T::TagType>> {
|
pub fn index<'a, T: Tag<'a>>(&self, idx: u32) -> Option<&'a TagValue<T::TagType>> {
|
||||||
self.get_index_generic(T::tag_name(), idx).map(|value| {
|
self.index_generic(T::tag_name(), idx).map(|value| {
|
||||||
if !value.is::<T::TagType>() {
|
if !value.is::<T::TagType>() {
|
||||||
panic!(
|
panic!(
|
||||||
"TagListRef::get_index type mismatch for tag {}: {}",
|
"TagListRef::get_index type mismatch for tag {}: {}",
|
||||||
|
@ -501,7 +501,7 @@ impl TagListRef {
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn size<'a, T: Tag<'a>>(&self) -> u32 {
|
pub fn size<'a, T: Tag<'a>>(&self) -> u32 {
|
||||||
self.get_size_by_name(T::tag_name())
|
self.size_by_name(T::tag_name())
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn size_by_name(&self, tag_name: &str) -> u32 {
|
pub fn size_by_name(&self, tag_name: &str) -> u32 {
|
||||||
|
@ -603,7 +603,7 @@ impl<'a, T: Tag<'a>> TagIter<'a, T> {
|
||||||
TagIter {
|
TagIter {
|
||||||
taglist,
|
taglist,
|
||||||
idx: 0,
|
idx: 0,
|
||||||
size: taglist.get_size::<T>(),
|
size: taglist.size::<T>(),
|
||||||
phantom: PhantomData,
|
phantom: PhantomData,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -621,7 +621,7 @@ where
|
||||||
return None;
|
return None;
|
||||||
}
|
}
|
||||||
|
|
||||||
let item = self.taglist.get_index::<T>(self.idx);
|
let item = self.taglist.index::<T>(self.idx);
|
||||||
self.idx += 1;
|
self.idx += 1;
|
||||||
|
|
||||||
item
|
item
|
||||||
|
@ -649,7 +649,7 @@ where
|
||||||
}
|
}
|
||||||
|
|
||||||
self.size -= 1;
|
self.size -= 1;
|
||||||
self.taglist.get_index::<T>(self.size)
|
self.taglist.index::<T>(self.size)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -675,7 +675,7 @@ impl<'a> GenericTagIter<'a> {
|
||||||
taglist,
|
taglist,
|
||||||
name,
|
name,
|
||||||
idx: 0,
|
idx: 0,
|
||||||
size: taglist.get_size_by_name(name),
|
size: taglist.size_by_name(name),
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -688,7 +688,7 @@ impl<'a> Iterator for GenericTagIter<'a> {
|
||||||
return None;
|
return None;
|
||||||
}
|
}
|
||||||
|
|
||||||
let item = self.taglist.get_index_generic(self.name, self.idx);
|
let item = self.taglist.index_generic(self.name, self.idx);
|
||||||
self.idx += 1;
|
self.idx += 1;
|
||||||
|
|
||||||
item
|
item
|
||||||
|
@ -712,7 +712,7 @@ impl<'a> DoubleEndedIterator for GenericTagIter<'a> {
|
||||||
}
|
}
|
||||||
|
|
||||||
self.size -= 1;
|
self.size -= 1;
|
||||||
self.taglist.get_index_generic(self.name, self.size)
|
self.taglist.index_generic(self.name, self.size)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -805,7 +805,7 @@ impl<'a> Iterator for Iter<'a> {
|
||||||
}
|
}
|
||||||
|
|
||||||
let name = self.taglist.nth_tag_name(self.idx);
|
let name = self.taglist.nth_tag_name(self.idx);
|
||||||
let item = (name, self.taglist.get_generic(name).unwrap());
|
let item = (name, self.taglist.generic(name).unwrap());
|
||||||
self.idx += 1;
|
self.idx += 1;
|
||||||
|
|
||||||
Some(item)
|
Some(item)
|
||||||
|
@ -830,7 +830,7 @@ impl<'a> DoubleEndedIterator for Iter<'a> {
|
||||||
|
|
||||||
self.size -= 1;
|
self.size -= 1;
|
||||||
let name = self.taglist.nth_tag_name(self.idx);
|
let name = self.taglist.nth_tag_name(self.idx);
|
||||||
Some((name, self.taglist.get_generic(name).unwrap()))
|
Some((name, self.taglist.generic(name).unwrap()))
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -974,12 +974,9 @@ mod tests {
|
||||||
tags.get::<Duration>().unwrap().get_some(),
|
tags.get::<Duration>().unwrap().get_some(),
|
||||||
(crate::SECOND * 120)
|
(crate::SECOND * 120)
|
||||||
);
|
);
|
||||||
|
assert_eq!(tags.index::<Title>(0).unwrap().get(), Some("some title"));
|
||||||
assert_eq!(
|
assert_eq!(
|
||||||
tags.get_index::<Title>(0).unwrap().get(),
|
tags.index::<Duration>(0).unwrap().get_some(),
|
||||||
Some("some title")
|
|
||||||
);
|
|
||||||
assert_eq!(
|
|
||||||
tags.get_index::<Duration>(0).unwrap().get_some(),
|
|
||||||
(crate::SECOND * 120)
|
(crate::SECOND * 120)
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
@ -1029,32 +1026,32 @@ mod tests {
|
||||||
}
|
}
|
||||||
|
|
||||||
assert_eq!(
|
assert_eq!(
|
||||||
tags.get_index_generic(&TAG_TITLE, 0).unwrap().get(),
|
tags.index_generic(&TAG_TITLE, 0).unwrap().get(),
|
||||||
Ok(Some("some title"))
|
Ok(Some("some title"))
|
||||||
);
|
);
|
||||||
assert_eq!(
|
assert_eq!(
|
||||||
tags.get_index_generic(&TAG_TITLE, 1).unwrap().get(),
|
tags.index_generic(&TAG_TITLE, 1).unwrap().get(),
|
||||||
Ok(Some("second title"))
|
Ok(Some("second title"))
|
||||||
);
|
);
|
||||||
assert_eq!(
|
assert_eq!(
|
||||||
tags.get_index_generic(&TAG_DURATION, 0).unwrap().get(),
|
tags.index_generic(&TAG_DURATION, 0).unwrap().get(),
|
||||||
Ok(Some(crate::SECOND * 120))
|
Ok(Some(crate::SECOND * 120))
|
||||||
);
|
);
|
||||||
assert_eq!(
|
assert_eq!(
|
||||||
tags.get_index_generic(&TAG_TITLE, 2).unwrap().get(),
|
tags.index_generic(&TAG_TITLE, 2).unwrap().get(),
|
||||||
Ok(Some("third title"))
|
Ok(Some("third title"))
|
||||||
);
|
);
|
||||||
|
|
||||||
assert_eq!(
|
assert_eq!(
|
||||||
tags.get_generic(&TAG_TITLE).unwrap().get(),
|
tags.generic(&TAG_TITLE).unwrap().get(),
|
||||||
Ok(Some("some title, second title, third title"))
|
Ok(Some("some title, second title, third title"))
|
||||||
);
|
);
|
||||||
|
|
||||||
assert_eq!(tags.n_tags(), 2);
|
assert_eq!(tags.n_tags(), 2);
|
||||||
assert_eq!(tags.nth_tag_name(0), *TAG_TITLE);
|
assert_eq!(tags.nth_tag_name(0), *TAG_TITLE);
|
||||||
assert_eq!(tags.get_size_by_name(&TAG_TITLE), 3);
|
assert_eq!(tags.size_by_name(&TAG_TITLE), 3);
|
||||||
assert_eq!(tags.nth_tag_name(1), *TAG_DURATION);
|
assert_eq!(tags.nth_tag_name(1), *TAG_DURATION);
|
||||||
assert_eq!(tags.get_size_by_name(&TAG_DURATION), 1);
|
assert_eq!(tags.size_by_name(&TAG_DURATION), 1);
|
||||||
|
|
||||||
// GenericTagIter
|
// GenericTagIter
|
||||||
let mut title_iter = tags.iter_tag_generic(&TAG_TITLE);
|
let mut title_iter = tags.iter_tag_generic(&TAG_TITLE);
|
||||||
|
|
|
@ -464,28 +464,23 @@ mod tests {
|
||||||
let tags: TagList = ron::de::from_str(tag_list_ron).unwrap();
|
let tags: TagList = ron::de::from_str(tag_list_ron).unwrap();
|
||||||
assert_eq!(tags.scope(), TagScope::Global);
|
assert_eq!(tags.scope(), TagScope::Global);
|
||||||
|
|
||||||
assert_eq!(tags.get_index::<Title>(0).unwrap().get(), Some("a title"));
|
assert_eq!(tags.index::<Title>(0).unwrap().get(), Some("a title"));
|
||||||
|
assert_eq!(tags.index::<Title>(1).unwrap().get(), Some("another title"));
|
||||||
assert_eq!(
|
assert_eq!(
|
||||||
tags.get_index::<Title>(1).unwrap().get(),
|
tags.index::<Duration>(0).unwrap().get_some(),
|
||||||
Some("another title")
|
|
||||||
);
|
|
||||||
assert_eq!(
|
|
||||||
tags.get_index::<Duration>(0).unwrap().get_some(),
|
|
||||||
crate::SECOND * 120
|
crate::SECOND * 120
|
||||||
);
|
);
|
||||||
assert_eq!(tags.get_index::<Bitrate>(0).unwrap().get_some(), 96_000);
|
assert_eq!(tags.index::<Bitrate>(0).unwrap().get_some(), 96_000);
|
||||||
assert!(
|
assert!((tags.index::<TrackGain>(0).unwrap().get_some() - 1f64).abs() < std::f64::EPSILON);
|
||||||
(tags.get_index::<TrackGain>(0).unwrap().get_some() - 1f64).abs() < std::f64::EPSILON
|
|
||||||
);
|
|
||||||
assert_eq!(
|
assert_eq!(
|
||||||
tags.get_index::<Date>(0).unwrap().get().unwrap(),
|
tags.index::<Date>(0).unwrap().get().unwrap(),
|
||||||
glib::Date::new_dmy(28, glib::DateMonth::May, 2018).unwrap()
|
glib::Date::new_dmy(28, glib::DateMonth::May, 2018).unwrap()
|
||||||
);
|
);
|
||||||
assert_eq!(
|
assert_eq!(
|
||||||
tags.get_index::<DateTime>(0).unwrap().get().unwrap(),
|
tags.index::<DateTime>(0).unwrap().get().unwrap(),
|
||||||
crate::DateTime::new_ymd(2018, 5, 28).unwrap()
|
crate::DateTime::new_ymd(2018, 5, 28).unwrap()
|
||||||
);
|
);
|
||||||
let sample = tags.get_index::<Image>(0).unwrap().get().unwrap();
|
let sample = tags.index::<Image>(0).unwrap().get().unwrap();
|
||||||
let buffer = sample.buffer().unwrap();
|
let buffer = sample.buffer().unwrap();
|
||||||
{
|
{
|
||||||
let data = buffer.map_readable().unwrap();
|
let data = buffer.map_readable().unwrap();
|
||||||
|
@ -509,24 +504,19 @@ mod tests {
|
||||||
let tags: TagList = serde_json::from_str(tag_json).unwrap();
|
let tags: TagList = serde_json::from_str(tag_json).unwrap();
|
||||||
assert_eq!(tags.scope(), TagScope::Global);
|
assert_eq!(tags.scope(), TagScope::Global);
|
||||||
|
|
||||||
assert_eq!(tags.get_index::<Title>(0).unwrap().get(), Some("a title"));
|
assert_eq!(tags.index::<Title>(0).unwrap().get(), Some("a title"));
|
||||||
|
assert_eq!(tags.index::<Title>(1).unwrap().get(), Some("another title"));
|
||||||
|
assert_eq!(tags.index::<Bitrate>(0).unwrap().get_some(), 96_000);
|
||||||
|
assert!((tags.index::<TrackGain>(0).unwrap().get_some() - 1f64).abs() < std::f64::EPSILON);
|
||||||
assert_eq!(
|
assert_eq!(
|
||||||
tags.get_index::<Title>(1).unwrap().get(),
|
tags.index::<Date>(0).unwrap().get().unwrap(),
|
||||||
Some("another title")
|
|
||||||
);
|
|
||||||
assert_eq!(tags.get_index::<Bitrate>(0).unwrap().get_some(), 96_000);
|
|
||||||
assert!(
|
|
||||||
(tags.get_index::<TrackGain>(0).unwrap().get_some() - 1f64).abs() < std::f64::EPSILON
|
|
||||||
);
|
|
||||||
assert_eq!(
|
|
||||||
tags.get_index::<Date>(0).unwrap().get().unwrap(),
|
|
||||||
glib::Date::new_dmy(28, glib::DateMonth::May, 2018).unwrap()
|
glib::Date::new_dmy(28, glib::DateMonth::May, 2018).unwrap()
|
||||||
);
|
);
|
||||||
assert_eq!(
|
assert_eq!(
|
||||||
tags.get_index::<DateTime>(0).unwrap().get().unwrap(),
|
tags.index::<DateTime>(0).unwrap().get().unwrap(),
|
||||||
crate::DateTime::new_ymd(2018, 5, 28).unwrap()
|
crate::DateTime::new_ymd(2018, 5, 28).unwrap()
|
||||||
);
|
);
|
||||||
let sample = tags.get_index::<Image>(0).unwrap().get().unwrap();
|
let sample = tags.index::<Image>(0).unwrap().get().unwrap();
|
||||||
let buffer = sample.buffer().unwrap();
|
let buffer = sample.buffer().unwrap();
|
||||||
{
|
{
|
||||||
let data = buffer.map_readable().unwrap();
|
let data = buffer.map_readable().unwrap();
|
||||||
|
@ -574,36 +564,36 @@ mod tests {
|
||||||
assert_eq!(tags_de.scope(), TagScope::Global);
|
assert_eq!(tags_de.scope(), TagScope::Global);
|
||||||
|
|
||||||
assert_eq!(
|
assert_eq!(
|
||||||
tags_de.get_index::<Title>(0).unwrap().get(),
|
tags_de.index::<Title>(0).unwrap().get(),
|
||||||
tags.get_index::<Title>(0).unwrap().get(),
|
tags.index::<Title>(0).unwrap().get(),
|
||||||
);
|
);
|
||||||
assert_eq!(
|
assert_eq!(
|
||||||
tags_de.get_index::<Title>(1).unwrap().get(),
|
tags_de.index::<Title>(1).unwrap().get(),
|
||||||
tags.get_index::<Title>(1).unwrap().get(),
|
tags.index::<Title>(1).unwrap().get(),
|
||||||
);
|
);
|
||||||
assert_eq!(
|
assert_eq!(
|
||||||
tags_de.get_index::<Duration>(0).unwrap().get_some(),
|
tags_de.index::<Duration>(0).unwrap().get_some(),
|
||||||
tags.get_index::<Duration>(0).unwrap().get_some(),
|
tags.index::<Duration>(0).unwrap().get_some(),
|
||||||
);
|
);
|
||||||
assert_eq!(
|
assert_eq!(
|
||||||
tags_de.get_index::<Bitrate>(0).unwrap().get_some(),
|
tags_de.index::<Bitrate>(0).unwrap().get_some(),
|
||||||
tags.get_index::<Bitrate>(0).unwrap().get_some(),
|
tags.index::<Bitrate>(0).unwrap().get_some(),
|
||||||
);
|
);
|
||||||
assert!(
|
assert!(
|
||||||
(tags_de.get_index::<TrackGain>(0).unwrap().get_some()
|
(tags_de.index::<TrackGain>(0).unwrap().get_some()
|
||||||
- tags.get_index::<TrackGain>(0).unwrap().get_some())
|
- tags.index::<TrackGain>(0).unwrap().get_some())
|
||||||
.abs()
|
.abs()
|
||||||
< std::f64::EPSILON
|
< std::f64::EPSILON
|
||||||
);
|
);
|
||||||
assert_eq!(
|
assert_eq!(
|
||||||
tags_de.get_index::<Date>(0).unwrap().get(),
|
tags_de.index::<Date>(0).unwrap().get(),
|
||||||
tags.get_index::<Date>(0).unwrap().get(),
|
tags.index::<Date>(0).unwrap().get(),
|
||||||
);
|
);
|
||||||
assert_eq!(
|
assert_eq!(
|
||||||
tags.get_index::<DateTime>(0).unwrap().get().unwrap(),
|
tags.index::<DateTime>(0).unwrap().get().unwrap(),
|
||||||
crate::DateTime::new_ymd(2018, 5, 28).unwrap()
|
crate::DateTime::new_ymd(2018, 5, 28).unwrap()
|
||||||
);
|
);
|
||||||
let sample = tags.get_index::<Image>(0).unwrap().get().unwrap();
|
let sample = tags.index::<Image>(0).unwrap().get().unwrap();
|
||||||
let buffer = sample.buffer().unwrap();
|
let buffer = sample.buffer().unwrap();
|
||||||
{
|
{
|
||||||
let data = buffer.map_readable().unwrap();
|
let data = buffer.map_readable().unwrap();
|
||||||
|
|
|
@ -387,10 +387,7 @@ mod tests {
|
||||||
assert_eq!("chapter1.1", chapter1_1.uid());
|
assert_eq!("chapter1.1", chapter1_1.uid());
|
||||||
assert_eq!(Some((0, 4)), chapter1_1.start_stop_times());
|
assert_eq!(Some((0, 4)), chapter1_1.start_stop_times());
|
||||||
let tags = chapter1_1.tags().unwrap();
|
let tags = chapter1_1.tags().unwrap();
|
||||||
assert_eq!(
|
assert_eq!(Some("chapter 1.1"), tags.index::<Title>(0).unwrap().get());
|
||||||
Some("chapter 1.1"),
|
|
||||||
tags.get_index::<Title>(0).unwrap().get()
|
|
||||||
);
|
|
||||||
assert_eq!(0, chapter1_1.sub_entries().len());
|
assert_eq!(0, chapter1_1.sub_entries().len());
|
||||||
|
|
||||||
let chapter1_2 = &chap1_sub_entries[1];
|
let chapter1_2 = &chap1_sub_entries[1];
|
||||||
|
@ -398,17 +395,14 @@ mod tests {
|
||||||
assert_eq!("chapter1.2", chapter1_2.uid());
|
assert_eq!("chapter1.2", chapter1_2.uid());
|
||||||
assert_eq!(Some((4, 10)), chapter1_2.start_stop_times());
|
assert_eq!(Some((4, 10)), chapter1_2.start_stop_times());
|
||||||
let tags = chapter1_2.tags().unwrap();
|
let tags = chapter1_2.tags().unwrap();
|
||||||
assert_eq!(
|
assert_eq!(Some("chapter 1.2"), tags.index::<Title>(0).unwrap().get());
|
||||||
Some("chapter 1.2"),
|
|
||||||
tags.get_index::<Title>(0).unwrap().get()
|
|
||||||
);
|
|
||||||
assert_eq!(0, chapter1_2.sub_entries().len());
|
assert_eq!(0, chapter1_2.sub_entries().len());
|
||||||
|
|
||||||
let chapter2 = &sub_entries[1];
|
let chapter2 = &sub_entries[1];
|
||||||
assert_eq!(TocEntryType::Chapter, chapter2.entry_type());
|
assert_eq!(TocEntryType::Chapter, chapter2.entry_type());
|
||||||
assert_eq!("chapter2", chapter2.uid());
|
assert_eq!("chapter2", chapter2.uid());
|
||||||
let tags = chapter2.tags().unwrap();
|
let tags = chapter2.tags().unwrap();
|
||||||
assert_eq!(Some("chapter 2"), tags.get_index::<Title>(0).unwrap().get());
|
assert_eq!(Some("chapter 2"), tags.index::<Title>(0).unwrap().get());
|
||||||
assert_eq!(Some((10, 15)), chapter2.start_stop_times());
|
assert_eq!(Some((10, 15)), chapter2.start_stop_times());
|
||||||
assert_eq!(0, chapter2.sub_entries().len());
|
assert_eq!(0, chapter2.sub_entries().len());
|
||||||
}
|
}
|
||||||
|
@ -518,8 +512,8 @@ mod tests {
|
||||||
let tags_de = chapter1_1_de.tags().unwrap();
|
let tags_de = chapter1_1_de.tags().unwrap();
|
||||||
let tags = chapter1_1.tags().unwrap();
|
let tags = chapter1_1.tags().unwrap();
|
||||||
assert_eq!(
|
assert_eq!(
|
||||||
tags_de.get_index::<Title>(0).unwrap().get(),
|
tags_de.index::<Title>(0).unwrap().get(),
|
||||||
tags.get_index::<Title>(0).unwrap().get()
|
tags.index::<Title>(0).unwrap().get()
|
||||||
);
|
);
|
||||||
assert_eq!(
|
assert_eq!(
|
||||||
chapter1_1_de.sub_entries().len(),
|
chapter1_1_de.sub_entries().len(),
|
||||||
|
@ -537,8 +531,8 @@ mod tests {
|
||||||
let tags_de = chapter1_2_de.tags().unwrap();
|
let tags_de = chapter1_2_de.tags().unwrap();
|
||||||
let tags = chapter1_2.tags().unwrap();
|
let tags = chapter1_2.tags().unwrap();
|
||||||
assert_eq!(
|
assert_eq!(
|
||||||
tags_de.get_index::<Title>(0).unwrap().get(),
|
tags_de.index::<Title>(0).unwrap().get(),
|
||||||
tags.get_index::<Title>(0).unwrap().get()
|
tags.index::<Title>(0).unwrap().get()
|
||||||
);
|
);
|
||||||
assert_eq!(
|
assert_eq!(
|
||||||
chapter1_2_de.sub_entries().len(),
|
chapter1_2_de.sub_entries().len(),
|
||||||
|
@ -552,8 +546,8 @@ mod tests {
|
||||||
let tags_de = chapter2_de.tags().unwrap();
|
let tags_de = chapter2_de.tags().unwrap();
|
||||||
let tags = chapter2.tags().unwrap();
|
let tags = chapter2.tags().unwrap();
|
||||||
assert_eq!(
|
assert_eq!(
|
||||||
tags_de.get_index::<Title>(0).unwrap().get(),
|
tags_de.index::<Title>(0).unwrap().get(),
|
||||||
tags.get_index::<Title>(0).unwrap().get()
|
tags.index::<Title>(0).unwrap().get()
|
||||||
);
|
);
|
||||||
assert_eq!(chapter2_de.start_stop_times(), chapter2.start_stop_times());
|
assert_eq!(chapter2_de.start_stop_times(), chapter2.start_stop_times());
|
||||||
assert_eq!(
|
assert_eq!(
|
||||||
|
|
|
@ -164,7 +164,7 @@ impl<T: AsRef<[u8]>> SliceTypeFind<T> {
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn run(&mut self) {
|
pub fn run(&mut self) {
|
||||||
let factories = TypeFindFactory::get_list();
|
let factories = TypeFindFactory::list();
|
||||||
|
|
||||||
for factory in factories {
|
for factory in factories {
|
||||||
factory.call_function(self);
|
factory.call_function(self);
|
||||||
|
@ -239,13 +239,13 @@ mod tests {
|
||||||
fn test_typefind_call_function() {
|
fn test_typefind_call_function() {
|
||||||
crate::init().unwrap();
|
crate::init().unwrap();
|
||||||
|
|
||||||
let xml_factory = TypeFindFactory::get_list()
|
let xml_factory = TypeFindFactory::list()
|
||||||
.iter()
|
.iter()
|
||||||
.cloned()
|
.cloned()
|
||||||
.find(|f| {
|
.find(|f| {
|
||||||
f.caps()
|
f.caps()
|
||||||
.map(|c| {
|
.map(|c| {
|
||||||
c.get_structure(0)
|
c.structure(0)
|
||||||
.map(|s| s.name() == "application/xml")
|
.map(|s| s.name() == "application/xml")
|
||||||
.unwrap_or(false)
|
.unwrap_or(false)
|
||||||
})
|
})
|
||||||
|
|
|
@ -56,11 +56,7 @@ fn send_seek_event(pipeline: &Element, rate: f64) -> bool {
|
||||||
};
|
};
|
||||||
|
|
||||||
// If we have not done so, obtain the sink through which we will send the seek events
|
// If we have not done so, obtain the sink through which we will send the seek events
|
||||||
if let Ok(Some(video_sink)) = pipeline
|
if let Ok(Some(video_sink)) = pipeline.property("video-sink").unwrap().get::<Element>() {
|
||||||
.get_property("video-sink")
|
|
||||||
.unwrap()
|
|
||||||
.get::<Element>()
|
|
||||||
{
|
|
||||||
println!("Current rate: {}\r", rate);
|
println!("Current rate: {}\r", rate);
|
||||||
// Send the event
|
// Send the event
|
||||||
video_sink.send_event(seek_event)
|
video_sink.send_event(seek_event)
|
||||||
|
@ -175,10 +171,8 @@ USAGE: Choose one of the following options, then press enter:
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
Command::NextFrame => {
|
Command::NextFrame => {
|
||||||
if let Ok(Some(video_sink)) = pipeline
|
if let Ok(Some(video_sink)) =
|
||||||
.get_property("video-sink")
|
pipeline.property("video-sink").unwrap().get::<Element>()
|
||||||
.unwrap()
|
|
||||||
.get::<Element>()
|
|
||||||
{
|
{
|
||||||
// Send the event
|
// Send the event
|
||||||
let step = Step::new(gst::format::Buffers(Some(1)), rate.abs(), true, false);
|
let step = Step::new(gst::format::Buffers(Some(1)), rate.abs(), true, false);
|
||||||
|
|
|
@ -39,7 +39,7 @@ fn tutorial_main() {
|
||||||
println!("Received new pad {} from {}", src_pad.name(), src.name());
|
println!("Received new pad {} from {}", src_pad.name(), src.name());
|
||||||
|
|
||||||
let sink_pad = convert
|
let sink_pad = convert
|
||||||
.get_static_pad("sink")
|
.static_pad("sink")
|
||||||
.expect("Failed to get static sink pad from convert");
|
.expect("Failed to get static sink pad from convert");
|
||||||
if sink_pad.is_linked() {
|
if sink_pad.is_linked() {
|
||||||
println!("We are already linked. Ignoring.");
|
println!("We are already linked. Ignoring.");
|
||||||
|
@ -50,7 +50,7 @@ fn tutorial_main() {
|
||||||
.current_caps()
|
.current_caps()
|
||||||
.expect("Failed to get caps of new pad.");
|
.expect("Failed to get caps of new pad.");
|
||||||
let new_pad_struct = new_pad_caps
|
let new_pad_struct = new_pad_caps
|
||||||
.get_structure(0)
|
.structure(0)
|
||||||
.expect("Failed to get first structure of caps.");
|
.expect("Failed to get first structure of caps.");
|
||||||
let new_pad_type = new_pad_struct.name();
|
let new_pad_type = new_pad_struct.name();
|
||||||
|
|
||||||
|
|
|
@ -41,7 +41,7 @@ mod tutorial5 {
|
||||||
let propname: &str = &format!("n-{}", stype);
|
let propname: &str = &format!("n-{}", stype);
|
||||||
let signame: &str = &format!("get-{}-tags", stype);
|
let signame: &str = &format!("get-{}-tags", stype);
|
||||||
|
|
||||||
match playbin.get_property(propname).unwrap().get() {
|
match playbin.property(propname).unwrap().get() {
|
||||||
Ok(Some(x)) => {
|
Ok(Some(x)) => {
|
||||||
for i in 0..x {
|
for i in 0..x {
|
||||||
let tags = playbin.emit_by_name(signame, &[&i]).unwrap().unwrap();
|
let tags = playbin.emit_by_name(signame, &[&i]).unwrap().unwrap();
|
||||||
|
|
|
@ -30,7 +30,7 @@ fn print_caps(caps: &gst::Caps, prefix: &str) {
|
||||||
// Prints information about a Pad Template, including its Capabilitites
|
// Prints information about a Pad Template, including its Capabilitites
|
||||||
fn print_pad_template_information(factory: &gst::ElementFactory) {
|
fn print_pad_template_information(factory: &gst::ElementFactory) {
|
||||||
let long_name = factory
|
let long_name = factory
|
||||||
.get_metadata("long-name")
|
.metadata("long-name")
|
||||||
.expect("Failed to get long-name of element factory.");
|
.expect("Failed to get long-name of element factory.");
|
||||||
println!("Pad Template for {}:", long_name);
|
println!("Pad Template for {}:", long_name);
|
||||||
|
|
||||||
|
@ -66,7 +66,7 @@ fn print_pad_template_information(factory: &gst::ElementFactory) {
|
||||||
|
|
||||||
fn print_pad_capabilities(element: &gst::Element, pad_name: &str) {
|
fn print_pad_capabilities(element: &gst::Element, pad_name: &str) {
|
||||||
let pad = element
|
let pad = element
|
||||||
.get_static_pad(pad_name)
|
.static_pad(pad_name)
|
||||||
.expect("Could not retrieve pad");
|
.expect("Could not retrieve pad");
|
||||||
|
|
||||||
println!("Caps for the {} pad:", pad_name);
|
println!("Caps for the {} pad:", pad_name);
|
||||||
|
|
|
@ -47,20 +47,20 @@ fn tutorial_main() {
|
||||||
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();
|
||||||
gst::Element::link_many(&[&video_queue, &visual, &video_convert, &video_sink]).unwrap();
|
gst::Element::link_many(&[&video_queue, &visual, &video_convert, &video_sink]).unwrap();
|
||||||
|
|
||||||
let tee_audio_pad = tee.get_request_pad("src_%u").unwrap();
|
let tee_audio_pad = tee.request_pad("src_%u").unwrap();
|
||||||
println!(
|
println!(
|
||||||
"Obtained request pad {} for audio branch",
|
"Obtained request pad {} for audio branch",
|
||||||
tee_audio_pad.name()
|
tee_audio_pad.name()
|
||||||
);
|
);
|
||||||
let queue_audio_pad = audio_queue.get_static_pad("sink").unwrap();
|
let queue_audio_pad = audio_queue.static_pad("sink").unwrap();
|
||||||
tee_audio_pad.link(&queue_audio_pad).unwrap();
|
tee_audio_pad.link(&queue_audio_pad).unwrap();
|
||||||
|
|
||||||
let tee_video_pad = tee.get_request_pad("src_%u").unwrap();
|
let tee_video_pad = tee.request_pad("src_%u").unwrap();
|
||||||
println!(
|
println!(
|
||||||
"Obtained request pad {} for video branch",
|
"Obtained request pad {} for video branch",
|
||||||
tee_video_pad.name()
|
tee_video_pad.name()
|
||||||
);
|
);
|
||||||
let queue_video_pad = video_queue.get_static_pad("sink").unwrap();
|
let queue_video_pad = video_queue.static_pad("sink").unwrap();
|
||||||
tee_video_pad.link(&queue_video_pad).unwrap();
|
tee_video_pad.link(&queue_video_pad).unwrap();
|
||||||
|
|
||||||
pipeline
|
pipeline
|
||||||
|
|
|
@ -98,23 +98,23 @@ fn main() {
|
||||||
.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.request_pad("src_%u").unwrap();
|
||||||
println!(
|
println!(
|
||||||
"Obtained request pad {} for audio branch",
|
"Obtained request pad {} for audio branch",
|
||||||
tee_audio_pad.name()
|
tee_audio_pad.name()
|
||||||
);
|
);
|
||||||
let queue_audio_pad = audio_queue.get_static_pad("sink").unwrap();
|
let queue_audio_pad = audio_queue.static_pad("sink").unwrap();
|
||||||
tee_audio_pad.link(&queue_audio_pad).unwrap();
|
tee_audio_pad.link(&queue_audio_pad).unwrap();
|
||||||
|
|
||||||
let tee_video_pad = tee.get_request_pad("src_%u").unwrap();
|
let tee_video_pad = tee.request_pad("src_%u").unwrap();
|
||||||
println!(
|
println!(
|
||||||
"Obtained request pad {} for video branch",
|
"Obtained request pad {} for video branch",
|
||||||
tee_video_pad.name()
|
tee_video_pad.name()
|
||||||
);
|
);
|
||||||
let queue_video_pad = video_queue.get_static_pad("sink").unwrap();
|
let queue_video_pad = video_queue.static_pad("sink").unwrap();
|
||||||
tee_video_pad.link(&queue_video_pad).unwrap();
|
tee_video_pad.link(&queue_video_pad).unwrap();
|
||||||
let tee_app_pad = tee.get_request_pad("src_%u").unwrap();
|
let tee_app_pad = tee.request_pad("src_%u").unwrap();
|
||||||
let queue_app_pad = app_queue.get_static_pad("sink").unwrap();
|
let queue_app_pad = app_queue.static_pad("sink").unwrap();
|
||||||
tee_app_pad.link(&queue_app_pad).unwrap();
|
tee_app_pad.link(&queue_app_pad).unwrap();
|
||||||
|
|
||||||
// configure appsrc
|
// configure appsrc
|
||||||
|
|
|
@ -23,7 +23,7 @@ fn tutorial_main() -> Result<(), Error> {
|
||||||
pipeline.set_property("uri", &uri).unwrap();
|
pipeline.set_property("uri", &uri).unwrap();
|
||||||
|
|
||||||
// Set the download flag
|
// Set the download flag
|
||||||
let flags = pipeline.get_property("flags")?;
|
let flags = pipeline.property("flags")?;
|
||||||
let flags_class = FlagsClass::new(flags.type_()).unwrap();
|
let flags_class = FlagsClass::new(flags.type_()).unwrap();
|
||||||
let flags = flags_class
|
let flags = flags_class
|
||||||
.builder_with_value(flags)
|
.builder_with_value(flags)
|
||||||
|
@ -107,7 +107,7 @@ fn tutorial_main() -> Result<(), Error> {
|
||||||
println!(
|
println!(
|
||||||
"Temporary file: {:?}",
|
"Temporary file: {:?}",
|
||||||
download_buffer
|
download_buffer
|
||||||
.get_property("temp-location")
|
.property("temp-location")
|
||||||
.unwrap()
|
.unwrap()
|
||||||
.get::<String>()
|
.get::<String>()
|
||||||
.unwrap()
|
.unwrap()
|
||||||
|
|
|
@ -53,7 +53,7 @@ where
|
||||||
{
|
{
|
||||||
use std::thread;
|
use std::thread;
|
||||||
|
|
||||||
let l = runloop::CFRunLoop::get_main();
|
let l = runloop::CFRunLoop::main();
|
||||||
let t = thread::spawn(move || {
|
let t = thread::spawn(move || {
|
||||||
let res = main();
|
let res = main();
|
||||||
l.stop();
|
l.stop();
|
||||||
|
|
Loading…
Reference in a new issue