adapt to ObjectExt improvements

This commit is contained in:
Bilal Elmoussaoui 2021-11-08 10:55:40 +01:00 committed by Sebastian Dröge
parent d9bda62a47
commit 82be7b3ac5
35 changed files with 381 additions and 673 deletions

View file

@ -75,7 +75,7 @@ fn run_test(
.downcast::<gst_app::AppSink>() .downcast::<gst_app::AppSink>()
.unwrap(); .unwrap();
sink.set_property("sync", false).unwrap(); sink.set_property("sync", false);
let caps = gst_audio::AudioInfo::builder(gst_audio::AUDIO_FORMAT_F64, 192_000, channels) let caps = gst_audio::AudioInfo::builder(gst_audio::AUDIO_FORMAT_F64, 192_000, channels)
.build() .build()
.unwrap() .unwrap()

View file

@ -89,7 +89,7 @@ fn create_pipeline() -> Result<gst::Pipeline, Box<dyn Error>> {
let audio_sink = gst::parse_bin_from_description(AUDIO_SINK, true)?.upcast(); let audio_sink = gst::parse_bin_from_description(AUDIO_SINK, true)?.upcast();
let csoundfilter = gst::ElementFactory::make("csoundfilter", None)?; let csoundfilter = gst::ElementFactory::make("csoundfilter", None)?;
csoundfilter.set_property("csd-text", &CSD)?; csoundfilter.set_property("csd-text", &CSD);
pipeline.add_many(&[&audio_src, &csoundfilter, &audio_sink])?; pipeline.add_many(&[&audio_src, &csoundfilter, &audio_sink])?;

View file

@ -65,7 +65,7 @@ fn init() {
fn build_harness(src_caps: gst::Caps, sink_caps: gst::Caps, csd: &str) -> gst_check::Harness { fn build_harness(src_caps: gst::Caps, sink_caps: gst::Caps, csd: &str) -> gst_check::Harness {
let filter = gst::ElementFactory::make("csoundfilter", None).unwrap(); let filter = gst::ElementFactory::make("csoundfilter", None).unwrap();
filter.set_property("csd-text", &csd).unwrap(); filter.set_property("csd-text", &csd);
let mut h = gst_check::Harness::with_element(&filter, Some("sink"), Some("src")); let mut h = gst_check::Harness::with_element(&filter, Some("sink"), Some("src"));

View file

@ -102,15 +102,11 @@ fn main() -> Result<(), Box<dyn Error>> {
let typefind = gst::ElementFactory::make("typefind", None).unwrap(); let typefind = gst::ElementFactory::make("typefind", None).unwrap();
let filesink = gst::ElementFactory::make("filesink", None).unwrap(); let filesink = gst::ElementFactory::make("filesink", None).unwrap();
filesrc filesrc.set_property("location", &input_loc);
.set_property("location", &input_loc) filesink.set_property("location", &out_loc);
.expect("Failed to set location property");
filesink
.set_property("location", &out_loc)
.expect("Failed to set location property");
decrypter.set_property("receiver-key", glib::Bytes::from_owned(receiver.private.0))?; decrypter.set_property("receiver-key", glib::Bytes::from_owned(receiver.private.0));
decrypter.set_property("sender-key", glib::Bytes::from_owned(sender.public))?; decrypter.set_property("sender-key", glib::Bytes::from_owned(sender.public));
let pipeline = gst::Pipeline::new(Some("test-pipeline")); let pipeline = gst::Pipeline::new(Some("test-pipeline"));
pipeline pipeline

View file

@ -101,15 +101,11 @@ fn main() -> Result<(), Box<dyn Error>> {
let encrypter = gst::ElementFactory::make("sodiumencrypter", None).unwrap(); let encrypter = gst::ElementFactory::make("sodiumencrypter", None).unwrap();
let filesink = gst::ElementFactory::make("filesink", None).unwrap(); let filesink = gst::ElementFactory::make("filesink", None).unwrap();
filesrc filesrc.set_property("location", &input_loc);
.set_property("location", &input_loc) filesink.set_property("location", &out_loc);
.expect("Failed to set location property");
filesink
.set_property("location", &out_loc)
.expect("Failed to set location property");
encrypter.set_property("receiver-key", glib::Bytes::from_owned(receiver.public))?; encrypter.set_property("receiver-key", glib::Bytes::from_owned(receiver.public));
encrypter.set_property("sender-key", glib::Bytes::from_owned(sender.private.0))?; encrypter.set_property("sender-key", glib::Bytes::from_owned(sender.private.0));
let pipeline = gst::Pipeline::new(Some("test-pipeline")); let pipeline = gst::Pipeline::new(Some("test-pipeline"));
pipeline pipeline

View file

@ -73,15 +73,11 @@ fn test_pipeline() {
}; };
let filesrc = gst::ElementFactory::make("filesrc", None).unwrap(); let filesrc = gst::ElementFactory::make("filesrc", None).unwrap();
filesrc filesrc.set_property("location", &input_path.to_str().unwrap());
.set_property("location", &input_path.to_str().unwrap())
.expect("failed to set property");
let dec = gst::ElementFactory::make("sodiumdecrypter", None).unwrap(); let dec = gst::ElementFactory::make("sodiumdecrypter", None).unwrap();
dec.set_property("sender-key", &*SENDER_PUBLIC) dec.set_property("sender-key", &*SENDER_PUBLIC);
.expect("failed to set property"); dec.set_property("receiver-key", &*RECEIVER_PRIVATE);
dec.set_property("receiver-key", &*RECEIVER_PRIVATE)
.expect("failed to set property");
// the typefind element here is cause the decrypter only supports // the typefind element here is cause the decrypter only supports
// operating in pull mode bu the filesink wants push-mode. // operating in pull mode bu the filesink wants push-mode.
@ -165,15 +161,11 @@ fn test_pull_range() {
}; };
let filesrc = gst::ElementFactory::make("filesrc", None).unwrap(); let filesrc = gst::ElementFactory::make("filesrc", None).unwrap();
filesrc filesrc.set_property("location", input_path.to_str().unwrap());
.set_property("location", input_path.to_str().unwrap())
.expect("failed to set property");
let dec = gst::ElementFactory::make("sodiumdecrypter", None).unwrap(); let dec = gst::ElementFactory::make("sodiumdecrypter", None).unwrap();
dec.set_property("sender-key", &*SENDER_PUBLIC) dec.set_property("sender-key", &*SENDER_PUBLIC);
.expect("failed to set property"); dec.set_property("receiver-key", &*RECEIVER_PRIVATE);
dec.set_property("receiver-key", &*RECEIVER_PRIVATE)
.expect("failed to set property");
pipeline pipeline
.add_many(&[&filesrc, &dec]) .add_many(&[&filesrc, &dec])
@ -284,34 +276,28 @@ fn test_state_changes() {
// Set only receiver key // Set only receiver key
let dec = gst::ElementFactory::make("sodiumdecrypter", None).unwrap(); let dec = gst::ElementFactory::make("sodiumdecrypter", None).unwrap();
dec.set_property("receiver-key", &*RECEIVER_PRIVATE) dec.set_property("receiver-key", &*RECEIVER_PRIVATE);
.expect("failed to set property");
assert!(dec.change_state(gst::StateChange::NullToReady).is_err()); assert!(dec.change_state(gst::StateChange::NullToReady).is_err());
// Set only sender key // Set only sender key
let dec = gst::ElementFactory::make("sodiumdecrypter", None).unwrap(); let dec = gst::ElementFactory::make("sodiumdecrypter", None).unwrap();
dec.set_property("sender-key", &*SENDER_PUBLIC) dec.set_property("sender-key", &*SENDER_PUBLIC);
.expect("failed to set property");
assert!(dec.change_state(gst::StateChange::NullToReady).is_err()); assert!(dec.change_state(gst::StateChange::NullToReady).is_err());
} }
// NullToReady, no nonce provided // NullToReady, no nonce provided
{ {
let dec = gst::ElementFactory::make("sodiumdecrypter", None).unwrap(); let dec = gst::ElementFactory::make("sodiumdecrypter", None).unwrap();
dec.set_property("sender-key", &*SENDER_PUBLIC) dec.set_property("sender-key", &*SENDER_PUBLIC);
.expect("failed to set property"); dec.set_property("receiver-key", &*RECEIVER_PRIVATE);
dec.set_property("receiver-key", &*RECEIVER_PRIVATE)
.expect("failed to set property");
assert!(dec.change_state(gst::StateChange::NullToReady).is_ok()); assert!(dec.change_state(gst::StateChange::NullToReady).is_ok());
} }
// ReadyToNull // ReadyToNull
{ {
let dec = gst::ElementFactory::make("sodiumdecrypter", None).unwrap(); let dec = gst::ElementFactory::make("sodiumdecrypter", None).unwrap();
dec.set_property("sender-key", &*SENDER_PUBLIC) dec.set_property("sender-key", &*SENDER_PUBLIC);
.expect("failed to set property"); dec.set_property("receiver-key", &*RECEIVER_PRIVATE);
dec.set_property("receiver-key", &*RECEIVER_PRIVATE)
.expect("failed to set property");
assert!(dec.change_state(gst::StateChange::NullToReady).is_ok()); assert!(dec.change_state(gst::StateChange::NullToReady).is_ok());
} }
} }

View file

@ -74,12 +74,9 @@ fn encrypt_file() {
let mut adapter = gst_base::UniqueAdapter::new(); let mut adapter = gst_base::UniqueAdapter::new();
let enc = gst::ElementFactory::make("sodiumencrypter", None).unwrap(); let enc = gst::ElementFactory::make("sodiumencrypter", None).unwrap();
enc.set_property("sender-key", &*SENDER_PRIVATE) enc.set_property("sender-key", &*SENDER_PRIVATE);
.expect("failed to set property"); enc.set_property("receiver-key", &*RECEIVER_PUBLIC);
enc.set_property("receiver-key", &*RECEIVER_PUBLIC) enc.set_property("block-size", 1024u32);
.expect("failed to set property");
enc.set_property("block-size", 1024u32)
.expect("failed to set property");
let mut h = gst_check::Harness::with_element(&enc, None, None); let mut h = gst_check::Harness::with_element(&enc, None, None);
h.add_element_src_pad(&enc.static_pad("src").expect("failed to get src pad")); h.add_element_src_pad(&enc.static_pad("src").expect("failed to get src pad"));
@ -117,34 +114,28 @@ fn test_state_changes() {
// Set only receiver key // Set only receiver key
let enc = gst::ElementFactory::make("sodiumencrypter", None).unwrap(); let enc = gst::ElementFactory::make("sodiumencrypter", None).unwrap();
enc.set_property("receiver-key", &*RECEIVER_PUBLIC) enc.set_property("receiver-key", &*RECEIVER_PUBLIC);
.expect("failed to set property");
assert!(enc.change_state(gst::StateChange::NullToReady).is_err()); assert!(enc.change_state(gst::StateChange::NullToReady).is_err());
// Set only sender key // Set only sender key
let enc = gst::ElementFactory::make("sodiumencrypter", None).unwrap(); let enc = gst::ElementFactory::make("sodiumencrypter", None).unwrap();
enc.set_property("sender-key", &*SENDER_PRIVATE) enc.set_property("sender-key", &*SENDER_PRIVATE);
.expect("failed to set property");
assert!(enc.change_state(gst::StateChange::NullToReady).is_err()); assert!(enc.change_state(gst::StateChange::NullToReady).is_err());
} }
// NullToReady // NullToReady
{ {
let enc = gst::ElementFactory::make("sodiumencrypter", None).unwrap(); let enc = gst::ElementFactory::make("sodiumencrypter", None).unwrap();
enc.set_property("sender-key", &*SENDER_PRIVATE) enc.set_property("sender-key", &*SENDER_PRIVATE);
.expect("failed to set property"); enc.set_property("receiver-key", &*RECEIVER_PUBLIC);
enc.set_property("receiver-key", &*RECEIVER_PUBLIC)
.expect("failed to set property");
assert!(enc.change_state(gst::StateChange::NullToReady).is_ok()); assert!(enc.change_state(gst::StateChange::NullToReady).is_ok());
} }
// ReadyToNull // ReadyToNull
{ {
let enc = gst::ElementFactory::make("sodiumencrypter", None).unwrap(); let enc = gst::ElementFactory::make("sodiumencrypter", None).unwrap();
enc.set_property("sender-key", &*SENDER_PRIVATE) enc.set_property("sender-key", &*SENDER_PRIVATE);
.expect("failed to set property"); enc.set_property("receiver-key", &*RECEIVER_PUBLIC);
enc.set_property("receiver-key", &*RECEIVER_PUBLIC)
.expect("failed to set property");
assert!(enc.change_state(gst::StateChange::NullToReady).is_ok()); assert!(enc.change_state(gst::StateChange::NullToReady).is_ok());
} }
} }

View file

@ -66,8 +66,8 @@ fn main() {
for i in 0..n_streams { for i in 0..n_streams {
let sink = let sink =
gst::ElementFactory::make("fakesink", Some(format!("sink-{}", i).as_str())).unwrap(); gst::ElementFactory::make("fakesink", Some(format!("sink-{}", i).as_str())).unwrap();
sink.set_property("sync", false).unwrap(); sink.set_property("sync", false);
sink.set_property("async", false).unwrap(); sink.set_property("async", false);
let counter_clone = Arc::clone(&counter); let counter_clone = Arc::clone(&counter);
sink.static_pad("sink").unwrap().add_probe( sink.static_pad("sink").unwrap().add_probe(
@ -83,10 +83,8 @@ fn main() {
let source = let source =
gst::ElementFactory::make("udpsrc", Some(format!("source-{}", i).as_str())) gst::ElementFactory::make("udpsrc", Some(format!("source-{}", i).as_str()))
.unwrap(); .unwrap();
source.set_property("port", 40000i32 + i as i32).unwrap(); source.set_property("port", 40000i32 + i as i32);
source source.set_property("retrieve-sender-address", false);
.set_property("retrieve-sender-address", false)
.unwrap();
source source
} }
@ -94,11 +92,9 @@ fn main() {
let source = let source =
gst::ElementFactory::make("ts-udpsrc", Some(format!("source-{}", i).as_str())) gst::ElementFactory::make("ts-udpsrc", Some(format!("source-{}", i).as_str()))
.unwrap(); .unwrap();
source.set_property("port", 40000i32 + i as i32).unwrap(); source.set_property("port", 40000i32 + i as i32);
source source.set_property("context", format!("context-{}", (i as u32) % n_groups));
.set_property("context", format!("context-{}", (i as u32) % n_groups)) source.set_property("context-wait", wait);
.unwrap();
source.set_property("context-wait", wait).unwrap();
source source
} }
@ -108,8 +104,8 @@ fn main() {
Some(format!("source-{}", i).as_str()), Some(format!("source-{}", i).as_str()),
) )
.unwrap(); .unwrap();
source.set_property("host", "127.0.0.1").unwrap(); source.set_property("host", "127.0.0.1");
source.set_property("port", 40000i32).unwrap(); source.set_property("port", 40000i32);
source source
} }
@ -119,12 +115,10 @@ fn main() {
Some(format!("source-{}", i).as_str()), Some(format!("source-{}", i).as_str()),
) )
.unwrap(); .unwrap();
source.set_property("host", "127.0.0.1").unwrap(); source.set_property("host", "127.0.0.1");
source.set_property("port", 40000i32).unwrap(); source.set_property("port", 40000i32);
source source.set_property("context", format!("context-{}", (i as u32) % n_groups));
.set_property("context", format!("context-{}", (i as u32) % n_groups)) source.set_property("context-wait", wait);
.unwrap();
source.set_property("context-wait", wait).unwrap();
source source
} }
@ -134,11 +128,9 @@ fn main() {
Some(format!("source-{}", i).as_str()), Some(format!("source-{}", i).as_str()),
) )
.unwrap(); .unwrap();
source source.set_property("samplesperbuffer", (wait as i32) * 8000 / 1000);
.set_property("samplesperbuffer", (wait as i32) * 8000 / 1000)
.unwrap();
sink.set_property("sync", true).unwrap(); sink.set_property("sync", true);
source source
} }
@ -146,13 +138,9 @@ fn main() {
let source = let source =
gst::ElementFactory::make("ts-tonesrc", Some(format!("source-{}", i).as_str())) gst::ElementFactory::make("ts-tonesrc", Some(format!("source-{}", i).as_str()))
.unwrap(); .unwrap();
source source.set_property("samples-per-buffer", (wait as u32) * 8000 / 1000);
.set_property("samples-per-buffer", (wait as u32) * 8000 / 1000) source.set_property("context", format!("context-{}", (i as u32) % n_groups));
.unwrap(); source.set_property("context-wait", wait);
source
.set_property("context", format!("context-{}", (i as u32) % n_groups))
.unwrap();
source.set_property("context-wait", wait).unwrap();
source source
} }

View file

@ -369,7 +369,7 @@ impl SinkHandler {
if state.clock_rate.is_none() { if state.clock_rate.is_none() {
drop(state); drop(state);
let caps = element let caps = element
.emit_by_name("request-pt-map", &[&(pt as u32)]) .try_emit_by_name("request-pt-map", &[&(pt as u32)])
.map_err(|_| gst::FlowError::Error)? .map_err(|_| gst::FlowError::Error)?
.ok_or(gst::FlowError::Error)? .ok_or(gst::FlowError::Error)?
.get::<Option<gst::Caps>>() .get::<Option<gst::Caps>>()

View file

@ -36,9 +36,9 @@ fn push() {
let caps = gst::Caps::builder("foo/bar").build(); let caps = gst::Caps::builder("foo/bar").build();
{ {
let appsrc = h.element().unwrap(); let appsrc = h.element().unwrap();
appsrc.set_property("caps", &caps).unwrap(); appsrc.set_property("caps", &caps);
appsrc.set_property("do-timestamp", true).unwrap(); appsrc.set_property("do-timestamp", true);
appsrc.set_property("context", "appsrc-push").unwrap(); appsrc.set_property("context", "appsrc-push");
} }
h.play(); h.play();
@ -49,7 +49,6 @@ fn push() {
assert!(appsrc assert!(appsrc
.emit_by_name("push-buffer", &[&gst::Buffer::new()]) .emit_by_name("push-buffer", &[&gst::Buffer::new()])
.unwrap() .unwrap()
.unwrap()
.get::<bool>() .get::<bool>()
.unwrap()); .unwrap());
} }
@ -57,7 +56,6 @@ fn push() {
assert!(appsrc assert!(appsrc
.emit_by_name("end-of-stream", &[]) .emit_by_name("end-of-stream", &[])
.unwrap() .unwrap()
.unwrap()
.get::<bool>() .get::<bool>()
.unwrap()); .unwrap());
} }
@ -102,9 +100,9 @@ fn pause_regular() {
let caps = gst::Caps::builder("foo/bar").build(); let caps = gst::Caps::builder("foo/bar").build();
{ {
let appsrc = h.element().unwrap(); let appsrc = h.element().unwrap();
appsrc.set_property("caps", &caps).unwrap(); appsrc.set_property("caps", &caps);
appsrc.set_property("do-timestamp", true).unwrap(); appsrc.set_property("do-timestamp", true);
appsrc.set_property("context", "appsrc-pause").unwrap(); appsrc.set_property("context", "appsrc-pause");
} }
h.play(); h.play();
@ -115,7 +113,6 @@ fn pause_regular() {
assert!(appsrc assert!(appsrc
.emit_by_name("push-buffer", &[&gst::Buffer::from_slice(vec![1, 2, 3, 4])]) .emit_by_name("push-buffer", &[&gst::Buffer::from_slice(vec![1, 2, 3, 4])])
.unwrap() .unwrap()
.unwrap()
.get::<bool>() .get::<bool>()
.unwrap()); .unwrap());
@ -125,7 +122,6 @@ fn pause_regular() {
assert!(appsrc assert!(appsrc
.emit_by_name("push-buffer", &[&gst::Buffer::from_slice(vec![5, 6, 7])]) .emit_by_name("push-buffer", &[&gst::Buffer::from_slice(vec![5, 6, 7])])
.unwrap() .unwrap()
.unwrap()
.get::<bool>() .get::<bool>()
.unwrap()); .unwrap());
@ -137,7 +133,6 @@ fn pause_regular() {
assert!(appsrc assert!(appsrc
.emit_by_name("push-buffer", &[&gst::Buffer::from_slice(vec![8, 9])]) .emit_by_name("push-buffer", &[&gst::Buffer::from_slice(vec![8, 9])])
.unwrap() .unwrap()
.unwrap()
.get::<bool>() .get::<bool>()
.unwrap()); .unwrap());
@ -155,7 +150,6 @@ fn pause_regular() {
assert!(appsrc assert!(appsrc
.emit_by_name("push-buffer", &[&gst::Buffer::new()]) .emit_by_name("push-buffer", &[&gst::Buffer::new()])
.unwrap() .unwrap()
.unwrap()
.get::<bool>() .get::<bool>()
.unwrap()); .unwrap());
@ -172,9 +166,9 @@ fn flush_regular() {
let caps = gst::Caps::builder("foo/bar").build(); let caps = gst::Caps::builder("foo/bar").build();
{ {
let appsrc = h.element().unwrap(); let appsrc = h.element().unwrap();
appsrc.set_property("caps", &caps).unwrap(); appsrc.set_property("caps", &caps);
appsrc.set_property("do-timestamp", true).unwrap(); appsrc.set_property("do-timestamp", true);
appsrc.set_property("context", "appsrc-flush").unwrap(); appsrc.set_property("context", "appsrc-flush");
} }
h.play(); h.play();
@ -185,7 +179,6 @@ fn flush_regular() {
assert!(appsrc assert!(appsrc
.emit_by_name("push-buffer", &[&gst::Buffer::from_slice(vec![1, 2, 3, 4])]) .emit_by_name("push-buffer", &[&gst::Buffer::from_slice(vec![1, 2, 3, 4])])
.unwrap() .unwrap()
.unwrap()
.get::<bool>() .get::<bool>()
.unwrap()); .unwrap());
@ -198,7 +191,6 @@ fn flush_regular() {
assert!(!appsrc assert!(!appsrc
.emit_by_name("push-buffer", &[&gst::Buffer::new()]) .emit_by_name("push-buffer", &[&gst::Buffer::new()])
.unwrap() .unwrap()
.unwrap()
.get::<bool>() .get::<bool>()
.unwrap()); .unwrap());
@ -214,7 +206,6 @@ fn flush_regular() {
assert!(appsrc assert!(appsrc
.emit_by_name("push-buffer", &[&gst::Buffer::new()]) .emit_by_name("push-buffer", &[&gst::Buffer::new()])
.unwrap() .unwrap()
.unwrap()
.get::<bool>() .get::<bool>()
.unwrap()); .unwrap());
@ -231,11 +222,9 @@ fn pause_flush() {
let caps = gst::Caps::builder("foo/bar").build(); let caps = gst::Caps::builder("foo/bar").build();
{ {
let appsrc = h.element().unwrap(); let appsrc = h.element().unwrap();
appsrc.set_property("caps", &caps).unwrap(); appsrc.set_property("caps", &caps);
appsrc.set_property("do-timestamp", true).unwrap(); appsrc.set_property("do-timestamp", true);
appsrc appsrc.set_property("context", "appsrc-pause_flush");
.set_property("context", "appsrc-pause_flush")
.unwrap();
} }
h.play(); h.play();
@ -246,7 +235,6 @@ fn pause_flush() {
assert!(appsrc assert!(appsrc
.emit_by_name("push-buffer", &[&gst::Buffer::from_slice(vec![1, 2, 3, 4])]) .emit_by_name("push-buffer", &[&gst::Buffer::from_slice(vec![1, 2, 3, 4])])
.unwrap() .unwrap()
.unwrap()
.get::<bool>() .get::<bool>()
.unwrap()); .unwrap());
@ -263,7 +251,6 @@ fn pause_flush() {
assert!(!appsrc assert!(!appsrc
.emit_by_name("push-buffer", &[&gst::Buffer::new()]) .emit_by_name("push-buffer", &[&gst::Buffer::new()])
.unwrap() .unwrap()
.unwrap()
.get::<bool>() .get::<bool>()
.unwrap()); .unwrap());
@ -283,7 +270,6 @@ fn pause_flush() {
assert!(appsrc assert!(appsrc
.emit_by_name("push-buffer", &[&gst::Buffer::new()]) .emit_by_name("push-buffer", &[&gst::Buffer::new()])
.unwrap() .unwrap()
.unwrap()
.get::<bool>() .get::<bool>()
.unwrap()); .unwrap());

View file

@ -36,20 +36,11 @@ fn test_active_pad() {
let mut h1 = gst_check::Harness::with_element(&is, Some("sink_%u"), Some("src")); let mut h1 = gst_check::Harness::with_element(&is, Some("sink_%u"), Some("src"));
let mut h2 = gst_check::Harness::with_element(&is, Some("sink_%u"), None); let mut h2 = gst_check::Harness::with_element(&is, Some("sink_%u"), None);
let active_pad = is let active_pad = is.property::<Option<gst::Pad>>("active-pad");
.property("active-pad")
.unwrap()
.get::<Option<gst::Pad>>()
.unwrap();
assert_eq!(active_pad, h1.srcpad().unwrap().peer()); assert_eq!(active_pad, h1.srcpad().unwrap().peer());
is.set_property("active-pad", h2.srcpad().unwrap().peer()) is.set_property("active-pad", h2.srcpad().unwrap().peer());
.unwrap(); let active_pad = is.property::<Option<gst::Pad>>("active-pad");
let active_pad = is
.property("active-pad")
.unwrap()
.get::<Option<gst::Pad>>()
.unwrap();
assert_eq!(active_pad, h2.srcpad().unwrap().peer()); assert_eq!(active_pad, h2.srcpad().unwrap().peer());
h1.set_src_caps_str("foo/bar"); h1.set_src_caps_str("foo/bar");
@ -85,8 +76,7 @@ fn test_active_pad() {
/* Switch the active pad and push a buffer, we should receive stream-start, segment and caps /* Switch the active pad and push a buffer, we should receive stream-start, segment and caps
* again */ * again */
let buf = gst::Buffer::new(); let buf = gst::Buffer::new();
is.set_property("active-pad", h1.srcpad().unwrap().peer()) is.set_property("active-pad", h1.srcpad().unwrap().peer());
.unwrap();
assert_eq!(h1.push(buf), Ok(gst::FlowSuccess::Ok)); assert_eq!(h1.push(buf), Ok(gst::FlowSuccess::Ok));
assert_eq!(h1.buffers_received(), 3); assert_eq!(h1.buffers_received(), 3);
assert_eq!(h1.events_received(), 6); assert_eq!(h1.events_received(), 6);

View file

@ -51,24 +51,24 @@ fn jb_pipeline() {
let pipeline = gst::Pipeline::new(None); let pipeline = gst::Pipeline::new(None);
let src = gst::ElementFactory::make("audiotestsrc", Some("audiotestsrc")).unwrap(); let src = gst::ElementFactory::make("audiotestsrc", Some("audiotestsrc")).unwrap();
src.set_property("is-live", true).unwrap(); src.set_property("is-live", true);
src.set_property("num-buffers", BUFFER_NB).unwrap(); src.set_property("num-buffers", BUFFER_NB);
let enc = gst::ElementFactory::make("alawenc", Some("alawenc")).unwrap(); let enc = gst::ElementFactory::make("alawenc", Some("alawenc")).unwrap();
let pay = gst::ElementFactory::make("rtppcmapay", Some("rtppcmapay")).unwrap(); let pay = gst::ElementFactory::make("rtppcmapay", Some("rtppcmapay")).unwrap();
let jb = gst::ElementFactory::make("ts-jitterbuffer", Some("ts-jitterbuffer")).unwrap(); let jb = gst::ElementFactory::make("ts-jitterbuffer", Some("ts-jitterbuffer")).unwrap();
jb.set_property("context", "jb_pipeline").unwrap(); jb.set_property("context", "jb_pipeline");
jb.set_property("context-wait", CONTEXT_WAIT).unwrap(); jb.set_property("context-wait", CONTEXT_WAIT);
jb.set_property("latency", LATENCY).unwrap(); jb.set_property("latency", LATENCY);
let depay = gst::ElementFactory::make("rtppcmadepay", Some("rtppcmadepay")).unwrap(); let depay = gst::ElementFactory::make("rtppcmadepay", Some("rtppcmadepay")).unwrap();
let dec = gst::ElementFactory::make("alawdec", Some("alawdec")).unwrap(); let dec = gst::ElementFactory::make("alawdec", Some("alawdec")).unwrap();
let sink = gst::ElementFactory::make("appsink", Some("appsink")).unwrap(); let sink = gst::ElementFactory::make("appsink", Some("appsink")).unwrap();
sink.set_property("sync", false).unwrap(); sink.set_property("sync", false);
sink.set_property("async", false).unwrap(); sink.set_property("async", false);
sink.set_property("emit-signals", true).unwrap(); sink.set_property("emit-signals", true);
pipeline pipeline
.add_many(&[&src, &enc, &pay, &jb, &depay, &dec, &sink]) .add_many(&[&src, &enc, &pay, &jb, &depay, &dec, &sink])
@ -83,7 +83,6 @@ fn jb_pipeline() {
let _sample = appsink let _sample = appsink
.emit_by_name("pull-sample", &[]) .emit_by_name("pull-sample", &[])
.unwrap() .unwrap()
.unwrap()
.get::<gst::Sample>() .get::<gst::Sample>()
.unwrap(); .unwrap();
@ -115,30 +114,28 @@ fn jb_ts_pipeline() {
let pipeline = gst::Pipeline::new(None); let pipeline = gst::Pipeline::new(None);
let src = gst::ElementFactory::make("audiotestsrc", Some("audiotestsrc")).unwrap(); let src = gst::ElementFactory::make("audiotestsrc", Some("audiotestsrc")).unwrap();
src.set_property("is-live", true).unwrap(); src.set_property("is-live", true);
src.set_property("num-buffers", BUFFER_NB).unwrap(); src.set_property("num-buffers", BUFFER_NB);
let queue = gst::ElementFactory::make("ts-queue", Some("ts-queue")).unwrap(); let queue = gst::ElementFactory::make("ts-queue", Some("ts-queue")).unwrap();
queue queue.set_property("context", "jb_ts_pipeline_queue");
.set_property("context", "jb_ts_pipeline_queue") queue.set_property("context-wait", CONTEXT_WAIT);
.unwrap();
queue.set_property("context-wait", CONTEXT_WAIT).unwrap();
let enc = gst::ElementFactory::make("alawenc", Some("alawenc")).unwrap(); let enc = gst::ElementFactory::make("alawenc", Some("alawenc")).unwrap();
let pay = gst::ElementFactory::make("rtppcmapay", Some("rtppcmapay")).unwrap(); let pay = gst::ElementFactory::make("rtppcmapay", Some("rtppcmapay")).unwrap();
let jb = gst::ElementFactory::make("ts-jitterbuffer", Some("ts-jitterbuffer")).unwrap(); let jb = gst::ElementFactory::make("ts-jitterbuffer", Some("ts-jitterbuffer")).unwrap();
jb.set_property("context", "jb_ts_pipeline").unwrap(); jb.set_property("context", "jb_ts_pipeline");
jb.set_property("context-wait", CONTEXT_WAIT).unwrap(); jb.set_property("context-wait", CONTEXT_WAIT);
jb.set_property("latency", LATENCY).unwrap(); jb.set_property("latency", LATENCY);
let depay = gst::ElementFactory::make("rtppcmadepay", Some("rtppcmadepay")).unwrap(); let depay = gst::ElementFactory::make("rtppcmadepay", Some("rtppcmadepay")).unwrap();
let dec = gst::ElementFactory::make("alawdec", Some("alawdec")).unwrap(); let dec = gst::ElementFactory::make("alawdec", Some("alawdec")).unwrap();
let sink = gst::ElementFactory::make("appsink", Some("appsink")).unwrap(); let sink = gst::ElementFactory::make("appsink", Some("appsink")).unwrap();
sink.set_property("sync", false).unwrap(); sink.set_property("sync", false);
sink.set_property("async", false).unwrap(); sink.set_property("async", false);
sink.set_property("emit-signals", true).unwrap(); sink.set_property("emit-signals", true);
pipeline pipeline
.add_many(&[&src, &queue, &enc, &pay, &jb, &depay, &dec, &sink]) .add_many(&[&src, &queue, &enc, &pay, &jb, &depay, &dec, &sink])
@ -153,7 +150,6 @@ fn jb_ts_pipeline() {
let _sample = appsink let _sample = appsink
.emit_by_name("pull-sample", &[]) .emit_by_name("pull-sample", &[])
.unwrap() .unwrap()
.unwrap()
.get::<gst::Sample>() .get::<gst::Sample>()
.unwrap(); .unwrap();

View file

@ -772,7 +772,7 @@ fn setup(
// Src // Src
let src_element = glib::Object::new::<ElementSrcTest>(&[]).unwrap(); let src_element = glib::Object::new::<ElementSrcTest>(&[]).unwrap();
src_element.set_property("context", &context_name).unwrap(); src_element.set_property("context", &context_name);
pipeline.add(&src_element).unwrap(); pipeline.add(&src_element).unwrap();
let mut last_element = src_element.clone().upcast::<gst::Element>(); let mut last_element = src_element.clone().upcast::<gst::Element>();
@ -969,12 +969,8 @@ fn src_tsqueue_sink_nominal() {
let name = "src_tsqueue_sink"; let name = "src_tsqueue_sink";
let ts_queue = gst::ElementFactory::make("ts-queue", Some("ts-queue")).unwrap(); let ts_queue = gst::ElementFactory::make("ts-queue", Some("ts-queue")).unwrap();
ts_queue ts_queue.set_property("context", format!("{}_queue", name));
.set_property("context", format!("{}_queue", name)) ts_queue.set_property("context-wait", THROTTLING_DURATION.as_millis() as u32);
.unwrap();
ts_queue
.set_property("context-wait", THROTTLING_DURATION.as_millis() as u32)
.unwrap();
let (pipeline, src_element, _sink_element, receiver) = setup(name, Some(ts_queue), None); let (pipeline, src_element, _sink_element, receiver) = setup(name, Some(ts_queue), None);
@ -1000,20 +996,12 @@ fn src_tsproxy_sink_nominal() {
let name = "src_tsproxy_sink"; let name = "src_tsproxy_sink";
let ts_proxy_sink = gst::ElementFactory::make("ts-proxysink", Some("ts-proxysink")).unwrap(); let ts_proxy_sink = gst::ElementFactory::make("ts-proxysink", Some("ts-proxysink")).unwrap();
ts_proxy_sink ts_proxy_sink.set_property("proxy-context", format!("{}_proxy_context", name));
.set_property("proxy-context", format!("{}_proxy_context", name))
.unwrap();
let ts_proxy_src = gst::ElementFactory::make("ts-proxysrc", Some("ts-proxysrc")).unwrap(); let ts_proxy_src = gst::ElementFactory::make("ts-proxysrc", Some("ts-proxysrc")).unwrap();
ts_proxy_src ts_proxy_src.set_property("proxy-context", format!("{}_proxy_context", name));
.set_property("proxy-context", format!("{}_proxy_context", name)) ts_proxy_src.set_property("context", format!("{}_context", name));
.unwrap(); ts_proxy_src.set_property("context-wait", THROTTLING_DURATION.as_millis() as u32);
ts_proxy_src
.set_property("context", format!("{}_context", name))
.unwrap();
ts_proxy_src
.set_property("context-wait", THROTTLING_DURATION.as_millis() as u32)
.unwrap();
let (pipeline, src_element, _sink_element, receiver) = let (pipeline, src_element, _sink_element, receiver) =
setup(name, Some(ts_proxy_sink), Some(ts_proxy_src)); setup(name, Some(ts_proxy_sink), Some(ts_proxy_src));

View file

@ -63,23 +63,20 @@ fn multiple_contexts_queue() {
for i in 0..SRC_NB { for i in 0..SRC_NB {
let src = let src =
gst::ElementFactory::make("ts-udpsrc", Some(format!("src-{}", i).as_str())).unwrap(); gst::ElementFactory::make("ts-udpsrc", Some(format!("src-{}", i).as_str())).unwrap();
src.set_property("context", format!("context-{}", (i as u32) % CONTEXT_NB)) src.set_property("context", format!("context-{}", (i as u32) % CONTEXT_NB));
.unwrap(); src.set_property("context-wait", CONTEXT_WAIT);
src.set_property("context-wait", CONTEXT_WAIT).unwrap(); src.set_property("port", (FIRST_PORT + i) as i32);
src.set_property("port", (FIRST_PORT + i) as i32).unwrap();
let queue = let queue =
gst::ElementFactory::make("ts-queue", Some(format!("queue-{}", i).as_str())).unwrap(); gst::ElementFactory::make("ts-queue", Some(format!("queue-{}", i).as_str())).unwrap();
queue queue.set_property("context", format!("context-{}", (i as u32) % CONTEXT_NB));
.set_property("context", format!("context-{}", (i as u32) % CONTEXT_NB)) queue.set_property("context-wait", CONTEXT_WAIT);
.unwrap();
queue.set_property("context-wait", CONTEXT_WAIT).unwrap();
let sink = let sink =
gst::ElementFactory::make("appsink", Some(format!("sink-{}", i).as_str())).unwrap(); gst::ElementFactory::make("appsink", Some(format!("sink-{}", i).as_str())).unwrap();
sink.set_property("sync", false).unwrap(); sink.set_property("sync", false);
sink.set_property("async", false).unwrap(); sink.set_property("async", false);
sink.set_property("emit-signals", true).unwrap(); sink.set_property("emit-signals", true);
pipeline.add_many(&[&src, &queue, &sink]).unwrap(); pipeline.add_many(&[&src, &queue, &sink]).unwrap();
gst::Element::link_many(&[&src, &queue, &sink]).unwrap(); gst::Element::link_many(&[&src, &queue, &sink]).unwrap();
@ -92,7 +89,6 @@ fn multiple_contexts_queue() {
let _sample = appsink let _sample = appsink
.emit_by_name("pull-sample", &[]) .emit_by_name("pull-sample", &[])
.unwrap() .unwrap()
.unwrap()
.get::<gst::Sample>() .get::<gst::Sample>()
.unwrap(); .unwrap();
@ -204,40 +200,33 @@ fn multiple_contexts_proxy() {
Some(format!("src-{}", pipeline_index).as_str()), Some(format!("src-{}", pipeline_index).as_str()),
) )
.unwrap(); .unwrap();
src.set_property("context", format!("context-{}", (i as u32) % CONTEXT_NB)) src.set_property("context", format!("context-{}", (i as u32) % CONTEXT_NB));
.unwrap(); src.set_property("context-wait", CONTEXT_WAIT);
src.set_property("context-wait", CONTEXT_WAIT).unwrap(); src.set_property("port", (FIRST_PORT + i) as i32);
src.set_property("port", (FIRST_PORT + i) as i32).unwrap();
let proxysink = gst::ElementFactory::make( let proxysink = gst::ElementFactory::make(
"ts-proxysink", "ts-proxysink",
Some(format!("proxysink-{}", pipeline_index).as_str()), Some(format!("proxysink-{}", pipeline_index).as_str()),
) )
.unwrap(); .unwrap();
proxysink proxysink.set_property("proxy-context", format!("proxy-{}", pipeline_index));
.set_property("proxy-context", format!("proxy-{}", pipeline_index))
.unwrap();
let proxysrc = gst::ElementFactory::make( let proxysrc = gst::ElementFactory::make(
"ts-proxysrc", "ts-proxysrc",
Some(format!("proxysrc-{}", pipeline_index).as_str()), Some(format!("proxysrc-{}", pipeline_index).as_str()),
) )
.unwrap(); .unwrap();
proxysrc proxysrc.set_property(
.set_property( "context",
"context", &format!("context-{}", (pipeline_index as u32) % CONTEXT_NB),
&format!("context-{}", (pipeline_index as u32) % CONTEXT_NB), );
) proxysrc.set_property("proxy-context", format!("proxy-{}", pipeline_index));
.unwrap();
proxysrc
.set_property("proxy-context", format!("proxy-{}", pipeline_index))
.unwrap();
let sink = let sink =
gst::ElementFactory::make("appsink", Some(format!("sink-{}", pipeline_index).as_str())) gst::ElementFactory::make("appsink", Some(format!("sink-{}", pipeline_index).as_str()))
.unwrap(); .unwrap();
sink.set_property("sync", false).unwrap(); sink.set_property("sync", false);
sink.set_property("async", false).unwrap(); sink.set_property("async", false);
sink.set_property("emit-signals", true).unwrap(); sink.set_property("emit-signals", true);
pipeline pipeline
.add_many(&[&src, &proxysink, &proxysrc, &sink]) .add_many(&[&src, &proxysink, &proxysrc, &sink])
@ -253,7 +242,6 @@ fn multiple_contexts_proxy() {
let _sample = appsink let _sample = appsink
.emit_by_name("pull-sample", &[]) .emit_by_name("pull-sample", &[])
.unwrap() .unwrap()
.unwrap()
.get::<gst::Sample>() .get::<gst::Sample>()
.unwrap(); .unwrap();
@ -349,22 +337,22 @@ fn eos() {
let caps = gst::Caps::builder("foo/bar").build(); let caps = gst::Caps::builder("foo/bar").build();
let src = gst::ElementFactory::make("ts-appsrc", Some("src-eos")).unwrap(); let src = gst::ElementFactory::make("ts-appsrc", Some("src-eos")).unwrap();
src.set_property("caps", &caps).unwrap(); src.set_property("caps", &caps);
src.set_property("do-timestamp", true).unwrap(); src.set_property("do-timestamp", true);
src.set_property("context", &CONTEXT).unwrap(); src.set_property("context", &CONTEXT);
let queue = gst::ElementFactory::make("ts-queue", Some("queue-eos")).unwrap(); let queue = gst::ElementFactory::make("ts-queue", Some("queue-eos")).unwrap();
queue.set_property("context", &CONTEXT).unwrap(); queue.set_property("context", &CONTEXT);
let appsink = gst::ElementFactory::make("appsink", Some("sink-eos")).unwrap(); let appsink = gst::ElementFactory::make("appsink", Some("sink-eos")).unwrap();
pipeline.add_many(&[&src, &queue, &appsink]).unwrap(); pipeline.add_many(&[&src, &queue, &appsink]).unwrap();
gst::Element::link_many(&[&src, &queue, &appsink]).unwrap(); gst::Element::link_many(&[&src, &queue, &appsink]).unwrap();
appsink.set_property("sync", false).unwrap(); appsink.set_property("sync", false);
appsink.set_property("async", false).unwrap(); appsink.set_property("async", false);
appsink.set_property("emit-signals", true).unwrap(); appsink.set_property("emit-signals", true);
let (sample_notifier, sample_notif_rcv) = mpsc::channel(); let (sample_notifier, sample_notif_rcv) = mpsc::channel();
let (eos_notifier, eos_notif_rcv) = mpsc::channel(); let (eos_notifier, eos_notif_rcv) = mpsc::channel();
let appsink = appsink.dynamic_cast::<gst_app::AppSink>().unwrap(); let appsink = appsink.dynamic_cast::<gst_app::AppSink>().unwrap();
@ -375,7 +363,6 @@ fn eos() {
let _ = appsink let _ = appsink
.emit_by_name("pull-sample", &[]) .emit_by_name("pull-sample", &[])
.unwrap() .unwrap()
.unwrap()
.get::<gst::Sample>() .get::<gst::Sample>()
.unwrap(); .unwrap();
@ -390,7 +377,6 @@ fn eos() {
fn push_buffer(src: &gst::Element) -> bool { fn push_buffer(src: &gst::Element) -> bool {
gst_debug!(CAT, obj: src, "eos: pushing buffer"); gst_debug!(CAT, obj: src, "eos: pushing buffer");
src.emit_by_name("push-buffer", &[&gst::Buffer::from_slice(vec![0; 1024])]) src.emit_by_name("push-buffer", &[&gst::Buffer::from_slice(vec![0; 1024])])
.unwrap()
.unwrap() .unwrap()
.get::<bool>() .get::<bool>()
.unwrap() .unwrap()
@ -407,7 +393,6 @@ fn eos() {
assert!(src assert!(src
.emit_by_name("end-of-stream", &[]) .emit_by_name("end-of-stream", &[])
.unwrap() .unwrap()
.unwrap()
.get::<bool>() .get::<bool>()
.unwrap()); .unwrap());
@ -487,29 +472,24 @@ fn premature_shutdown() {
let caps = gst::Caps::builder("foo/bar").build(); let caps = gst::Caps::builder("foo/bar").build();
let src = gst::ElementFactory::make("ts-appsrc", Some("src-ps")).unwrap(); let src = gst::ElementFactory::make("ts-appsrc", Some("src-ps")).unwrap();
src.set_property("caps", &caps).unwrap(); src.set_property("caps", &caps);
src.set_property("do-timestamp", true).unwrap(); src.set_property("do-timestamp", true);
src.set_property("context", "appsrc-context").unwrap(); src.set_property("context", "appsrc-context");
src.set_property("context-wait", APPSRC_CONTEXT_WAIT) src.set_property("context-wait", APPSRC_CONTEXT_WAIT);
.unwrap();
let queue = gst::ElementFactory::make("ts-queue", Some("queue-ps")).unwrap(); let queue = gst::ElementFactory::make("ts-queue", Some("queue-ps")).unwrap();
queue.set_property("context", "queue-context").unwrap(); queue.set_property("context", "queue-context");
queue queue.set_property("context-wait", QUEUE_CONTEXT_WAIT);
.set_property("context-wait", QUEUE_CONTEXT_WAIT) queue.set_property("max-size-buffers", QUEUE_ITEMS_CAPACITY);
.unwrap();
queue
.set_property("max-size-buffers", QUEUE_ITEMS_CAPACITY)
.unwrap();
let appsink = gst::ElementFactory::make("appsink", Some("sink-ps")).unwrap(); let appsink = gst::ElementFactory::make("appsink", Some("sink-ps")).unwrap();
pipeline.add_many(&[&src, &queue, &appsink]).unwrap(); pipeline.add_many(&[&src, &queue, &appsink]).unwrap();
gst::Element::link_many(&[&src, &queue, &appsink]).unwrap(); gst::Element::link_many(&[&src, &queue, &appsink]).unwrap();
appsink.set_property("emit-signals", true).unwrap(); appsink.set_property("emit-signals", true);
appsink.set_property("sync", false).unwrap(); appsink.set_property("sync", false);
appsink.set_property("async", false).unwrap(); appsink.set_property("async", false);
let (appsink_sender, appsink_receiver) = mpsc::channel(); let (appsink_sender, appsink_receiver) = mpsc::channel();
@ -521,7 +501,6 @@ fn premature_shutdown() {
let _sample = appsink let _sample = appsink
.emit_by_name("pull-sample", &[]) .emit_by_name("pull-sample", &[])
.unwrap() .unwrap()
.unwrap()
.get::<gst::Sample>() .get::<gst::Sample>()
.unwrap(); .unwrap();
@ -540,7 +519,6 @@ fn premature_shutdown() {
intent intent
); );
src.emit_by_name("push-buffer", &[&gst::Buffer::from_slice(vec![0; 1024])]) src.emit_by_name("push-buffer", &[&gst::Buffer::from_slice(vec![0; 1024])])
.unwrap()
.unwrap() .unwrap()
.get::<bool>() .get::<bool>()
.unwrap() .unwrap()

View file

@ -45,11 +45,11 @@ fn test_push() {
fakesrc.link(&proxysink).unwrap(); fakesrc.link(&proxysink).unwrap();
proxysrc.link(&appsink).unwrap(); proxysrc.link(&appsink).unwrap();
fakesrc.set_property("num-buffers", 3i32).unwrap(); fakesrc.set_property("num-buffers", 3i32);
proxysink.set_property("proxy-context", "test1").unwrap(); proxysink.set_property("proxy-context", "test1");
proxysrc.set_property("proxy-context", "test1").unwrap(); proxysrc.set_property("proxy-context", "test1");
appsink.set_property("emit-signals", true).unwrap(); appsink.set_property("emit-signals", true);
let samples = Arc::new(Mutex::new(Vec::new())); let samples = Arc::new(Mutex::new(Vec::new()));
@ -61,7 +61,6 @@ fn test_push() {
let sample = appsink let sample = appsink
.emit_by_name("pull-sample", &[]) .emit_by_name("pull-sample", &[])
.unwrap() .unwrap()
.unwrap()
.get::<gst::Sample>() .get::<gst::Sample>()
.unwrap(); .unwrap();
@ -117,8 +116,8 @@ fn test_from_pipeline_to_pipeline() {
pipe_2.add_many(&[&pxsrc, &fakesink]).unwrap(); pipe_2.add_many(&[&pxsrc, &fakesink]).unwrap();
pxsrc.link(&fakesink).unwrap(); pxsrc.link(&fakesink).unwrap();
pxsink.set_property("proxy-context", "test2").unwrap(); pxsink.set_property("proxy-context", "test2");
pxsrc.set_property("proxy-context", "test2").unwrap(); pxsrc.set_property("proxy-context", "test2");
pipe_1.set_state(gst::State::Paused).unwrap(); pipe_1.set_state(gst::State::Paused).unwrap();
pipe_2.set_state(gst::State::Paused).unwrap(); pipe_2.set_state(gst::State::Paused).unwrap();
@ -149,11 +148,11 @@ fn test_from_pipeline_to_pipeline_and_back() {
pipe_2.add_many(&[&pxsrc_2, &pxsink_2]).unwrap(); pipe_2.add_many(&[&pxsrc_2, &pxsink_2]).unwrap();
pxsrc_2.link(&pxsink_2).unwrap(); pxsrc_2.link(&pxsink_2).unwrap();
pxsrc_1.set_property("proxy-context", "test3").unwrap(); pxsrc_1.set_property("proxy-context", "test3");
pxsink_2.set_property("proxy-context", "test3").unwrap(); pxsink_2.set_property("proxy-context", "test3");
pxsrc_2.set_property("proxy-context", "test4").unwrap(); pxsrc_2.set_property("proxy-context", "test4");
pxsink_1.set_property("proxy-context", "test4").unwrap(); pxsink_1.set_property("proxy-context", "test4");
pipe_1.set_state(gst::State::Paused).unwrap(); pipe_1.set_state(gst::State::Paused).unwrap();
pipe_2.set_state(gst::State::Paused).unwrap(); pipe_2.set_state(gst::State::Paused).unwrap();

View file

@ -42,9 +42,9 @@ fn test_push() {
fakesrc.link(&queue).unwrap(); fakesrc.link(&queue).unwrap();
queue.link(&appsink).unwrap(); queue.link(&appsink).unwrap();
fakesrc.set_property("num-buffers", 3i32).unwrap(); fakesrc.set_property("num-buffers", 3i32);
appsink.set_property("emit-signals", true).unwrap(); appsink.set_property("emit-signals", true);
let samples = Arc::new(Mutex::new(Vec::new())); let samples = Arc::new(Mutex::new(Vec::new()));
@ -56,7 +56,6 @@ fn test_push() {
let sample = appsink let sample = appsink
.emit_by_name("pull-sample", &[]) .emit_by_name("pull-sample", &[])
.unwrap() .unwrap()
.unwrap()
.get::<gst::Sample>() .get::<gst::Sample>()
.unwrap(); .unwrap();

View file

@ -56,17 +56,17 @@ fn test_push() {
let tcpclientsrc = gst::ElementFactory::make("ts-tcpclientsrc", None).unwrap(); let tcpclientsrc = gst::ElementFactory::make("ts-tcpclientsrc", None).unwrap();
let appsink = gst::ElementFactory::make("appsink", None).unwrap(); let appsink = gst::ElementFactory::make("appsink", None).unwrap();
appsink.set_property("sync", false).unwrap(); appsink.set_property("sync", false);
appsink.set_property("async", false).unwrap(); appsink.set_property("async", false);
pipeline.add_many(&[&tcpclientsrc, &appsink]).unwrap(); pipeline.add_many(&[&tcpclientsrc, &appsink]).unwrap();
tcpclientsrc.link(&appsink).unwrap(); tcpclientsrc.link(&appsink).unwrap();
let caps = gst::Caps::builder("foo/bar").build(); let caps = gst::Caps::builder("foo/bar").build();
tcpclientsrc.set_property("caps", &caps).unwrap(); tcpclientsrc.set_property("caps", &caps);
tcpclientsrc.set_property("port", 5000i32).unwrap(); tcpclientsrc.set_property("port", 5000i32);
appsink.set_property("emit-signals", true).unwrap(); appsink.set_property("emit-signals", true);
let samples = Arc::new(Mutex::new(Vec::new())); let samples = Arc::new(Mutex::new(Vec::new()));
@ -78,7 +78,6 @@ fn test_push() {
let sample = appsink let sample = appsink
.emit_by_name("pull-sample", &[]) .emit_by_name("pull-sample", &[])
.unwrap() .unwrap()
.unwrap()
.get::<gst::Sample>() .get::<gst::Sample>()
.unwrap(); .unwrap();

View file

@ -36,84 +36,40 @@ fn test_client_management() {
let h = gst_check::Harness::new("ts-udpsink"); let h = gst_check::Harness::new("ts-udpsink");
let udpsink = h.element().unwrap(); let udpsink = h.element().unwrap();
let clients = udpsink let clients = udpsink.property::<String>("clients");
.property("clients")
.unwrap()
.get::<String>()
.unwrap();
assert_eq!(clients, "127.0.0.1:5004"); assert_eq!(clients, "127.0.0.1:5004");
udpsink udpsink.emit_by_name("add", &[&"192.168.1.1", &57i32]);
.emit_by_name("add", &[&"192.168.1.1", &57i32]) let clients = udpsink.property::<String>("clients");
.unwrap();
let clients = udpsink
.property("clients")
.unwrap()
.get::<String>()
.unwrap();
assert_eq!(clients, "127.0.0.1:5004,192.168.1.1:57"); assert_eq!(clients, "127.0.0.1:5004,192.168.1.1:57");
/* Adding a client twice is not supported */ /* Adding a client twice is not supported */
udpsink udpsink.emit_by_name("add", &[&"192.168.1.1", &57i32]);
.emit_by_name("add", &[&"192.168.1.1", &57i32]) let clients = udpsink.property::<String>("clients");
.unwrap();
let clients = udpsink
.property("clients")
.unwrap()
.get::<String>()
.unwrap();
assert_eq!(clients, "127.0.0.1:5004,192.168.1.1:57"); assert_eq!(clients, "127.0.0.1:5004,192.168.1.1:57");
udpsink udpsink.emit_by_name("remove", &[&"192.168.1.1", &57i32]);
.emit_by_name("remove", &[&"192.168.1.1", &57i32]) let clients = udpsink.property::<String>("clients");
.unwrap();
let clients = udpsink
.property("clients")
.unwrap()
.get::<String>()
.unwrap();
assert_eq!(clients, "127.0.0.1:5004"); assert_eq!(clients, "127.0.0.1:5004");
/* Removing a non-existing client should not be a problem */ /* Removing a non-existing client should not be a problem */
udpsink udpsink.emit_by_name("remove", &[&"192.168.1.1", &57i32]);
.emit_by_name("remove", &[&"192.168.1.1", &57i32]) let clients = udpsink.property::<String>("clients");
.unwrap();
let clients = udpsink
.property("clients")
.unwrap()
.get::<String>()
.unwrap();
assert_eq!(clients, "127.0.0.1:5004"); assert_eq!(clients, "127.0.0.1:5004");
/* Removing the default client is possible */ /* Removing the default client is possible */
udpsink udpsink.emit_by_name("remove", &[&"127.0.0.1", &5004i32]);
.emit_by_name("remove", &[&"127.0.0.1", &5004i32]) let clients = udpsink.property::<String>("clients");
.unwrap();
let clients = udpsink
.property("clients")
.unwrap()
.get::<String>()
.unwrap();
assert_eq!(clients, ""); assert_eq!(clients, "");
/* The client properties is writable too */ /* The client properties is writable too */
udpsink udpsink.set_property("clients", "127.0.0.1:5004,192.168.1.1:57");
.set_property("clients", "127.0.0.1:5004,192.168.1.1:57") let clients = udpsink.property::<String>("clients");
.unwrap();
let clients = udpsink
.property("clients")
.unwrap()
.get::<String>()
.unwrap();
assert_eq!(clients, "127.0.0.1:5004,192.168.1.1:57"); assert_eq!(clients, "127.0.0.1:5004,192.168.1.1:57");
udpsink.emit_by_name("clear", &[]).unwrap(); udpsink.emit_by_name("clear", &[]);
let clients = udpsink let clients = udpsink.property::<String>("clients");
.property("clients")
.unwrap()
.get::<String>()
.unwrap();
assert_eq!(clients, ""); assert_eq!(clients, "");
} }
@ -125,7 +81,7 @@ fn test_chain() {
h.set_src_caps_str("foo/bar"); h.set_src_caps_str("foo/bar");
{ {
let udpsink = h.element().unwrap(); let udpsink = h.element().unwrap();
udpsink.set_property("clients", "127.0.0.1:5005").unwrap(); udpsink.set_property("clients", "127.0.0.1:5005");
} }
thread::spawn(move || { thread::spawn(move || {

View file

@ -38,9 +38,9 @@ fn test_push() {
let caps = gst::Caps::builder("foo/bar").build(); let caps = gst::Caps::builder("foo/bar").build();
{ {
let udpsrc = h.element().unwrap(); let udpsrc = h.element().unwrap();
udpsrc.set_property("caps", &caps).unwrap(); udpsrc.set_property("caps", &caps);
udpsrc.set_property("port", 5000i32).unwrap(); udpsrc.set_property("port", 5000i32);
udpsrc.set_property("context", "test-push").unwrap(); udpsrc.set_property("context", "test-push");
} }
h.play(); h.play();
@ -105,31 +105,27 @@ fn test_socket_reuse() {
{ {
let udpsrc = ts_src_h.element().unwrap(); let udpsrc = ts_src_h.element().unwrap();
udpsrc.set_property("port", 6000i32).unwrap(); udpsrc.set_property("port", 6000i32);
udpsrc.set_property("context", "test-socket-reuse").unwrap(); udpsrc.set_property("context", "test-socket-reuse");
} }
ts_src_h.play(); ts_src_h.play();
{ {
let udpsrc = ts_src_h.element().unwrap(); let udpsrc = ts_src_h.element().unwrap();
let socket = udpsrc let socket = udpsrc.property::<gio::Socket>("used-socket");
.property("used-socket")
.unwrap()
.get::<gio::Socket>()
.unwrap();
let udpsink = sink_h.element().unwrap(); let udpsink = sink_h.element().unwrap();
udpsink.set_property("socket", &socket).unwrap(); udpsink.set_property("socket", &socket);
udpsink.set_property("host", "127.0.0.1").unwrap(); udpsink.set_property("host", "127.0.0.1");
udpsink.set_property("port", 6001i32).unwrap(); udpsink.set_property("port", 6001i32);
} }
sink_h.play(); sink_h.play();
sink_h.set_src_caps_str("application/test"); sink_h.set_src_caps_str("application/test");
{ {
let udpsrc = ts_src_h2.element().unwrap(); let udpsrc = ts_src_h2.element().unwrap();
udpsrc.set_property("port", 6001i32).unwrap(); udpsrc.set_property("port", 6001i32);
udpsrc.set_property("context", "test-socket-reuse").unwrap(); udpsrc.set_property("context", "test-socket-reuse");
} }
ts_src_h2.play(); ts_src_h2.play();

View file

@ -142,8 +142,7 @@ impl Harness {
}); });
let local_addr = futures::executor::block_on(local_addr_receiver).unwrap(); let local_addr = futures::executor::block_on(local_addr_receiver).unwrap();
src.set_property("location", format!("http://{}/", local_addr)) src.set_property("location", format!("http://{}/", local_addr));
.unwrap();
// Let the test setup anything needed on the HTTP source now // Let the test setup anything needed on the HTTP source now
setup_func(&src); setup_func(&src);
@ -410,10 +409,10 @@ fn test_basic_request_inverted_defaults() {
Response::new(Body::from("Hello World")) Response::new(Body::from("Hello World"))
}, },
|src| { |src| {
src.set_property("keep-alive", false).unwrap(); src.set_property("keep-alive", false);
src.set_property("compress", true).unwrap(); src.set_property("compress", true);
src.set_property("iradio-mode", false).unwrap(); src.set_property("iradio-mode", false);
src.set_property("user-agent", "test user-agent").unwrap(); src.set_property("user-agent", "test user-agent");
}, },
); );
@ -490,8 +489,7 @@ fn test_extra_headers() {
.field("list", gst::List::new([1i32, 2i32])) .field("list", gst::List::new([1i32, 2i32]))
.field("array", gst::Array::new([1i32, 2i32])) .field("array", gst::Array::new([1i32, 2i32]))
.build(), .build(),
) );
.unwrap();
}, },
); );
@ -550,8 +548,7 @@ fn test_cookies_property() {
String::from("bar=2"), String::from("bar=2"),
String::from("baz=3"), String::from("baz=3"),
], ],
) );
.unwrap();
}, },
); );
@ -760,8 +757,8 @@ fn test_authorization() {
} }
}, },
|src| { |src| {
src.set_property("user-id", "user").unwrap(); src.set_property("user-id", "user");
src.set_property("user-pw", "password").unwrap(); src.set_property("user-pw", "password");
}, },
); );
@ -860,7 +857,7 @@ fn test_network_error() {
let mut h = Harness::new( let mut h = Harness::new(
|_req| unreachable!(), |_req| unreachable!(),
|src| { |src| {
src.set_property("location", "http://0.0.0.0:0").unwrap(); src.set_property("location", "http://0.0.0.0:0");
}, },
); );
@ -1194,14 +1191,8 @@ fn test_proxy_prop_souphttpsrc_compatibility() {
fn assert_proxy_set(set_to: Option<&str>, expected: Option<&str>) { fn assert_proxy_set(set_to: Option<&str>, expected: Option<&str>) {
// The same assertions should hold for "souphttpsrc". // The same assertions should hold for "souphttpsrc".
let src = gst::ElementFactory::make("reqwesthttpsrc", None).unwrap(); let src = gst::ElementFactory::make("reqwesthttpsrc", None).unwrap();
src.set_property("proxy", set_to).unwrap(); src.set_property("proxy", set_to);
assert_eq!( assert_eq!(src.property::<Option<String>>("proxy").as_deref(), expected);
src.property("proxy")
.unwrap()
.get::<Option<&str>>()
.unwrap(),
expected
);
} }
// Test env var proxy. // Test env var proxy.
@ -1275,7 +1266,7 @@ fn test_proxy() {
.unwrap() .unwrap()
}, },
|src| { |src| {
src.set_property("proxy", proxy_addr.to_string()).unwrap(); src.set_property("proxy", proxy_addr.to_string());
}, },
); );

View file

@ -47,7 +47,7 @@ fn test_replace_all() {
let commands = gst::Array::from(vec![command.to_send_value()]); let commands = gst::Array::from(vec![command.to_send_value()]);
regex.set_property("commands", &commands).unwrap(); regex.set_property("commands", &commands);
} }
h.set_src_caps_str("text/x-raw, format=utf8"); h.set_src_caps_str("text/x-raw, format=utf8");

View file

@ -39,7 +39,7 @@ fn test_columns() {
{ {
let wrap = h.element().expect("Could not create textwrap"); let wrap = h.element().expect("Could not create textwrap");
wrap.set_property("columns", 5u32).unwrap(); wrap.set_property("columns", 5u32);
} }
h.set_src_caps_str("text/x-raw, format=utf8"); h.set_src_caps_str("text/x-raw, format=utf8");
@ -77,8 +77,8 @@ fn test_lines() {
{ {
let wrap = h.element().expect("Could not create textwrap"); let wrap = h.element().expect("Could not create textwrap");
wrap.set_property("columns", 5u32).unwrap(); wrap.set_property("columns", 5u32);
wrap.set_property("lines", 2u32).unwrap(); wrap.set_property("lines", 2u32);
} }
h.set_src_caps_str("text/x-raw, format=utf8"); h.set_src_caps_str("text/x-raw, format=utf8");

View file

@ -64,7 +64,7 @@ impl ObjectSubclass for ProgressBin {
// Create the progressreport element. // Create the progressreport element.
let progress = gst::ElementFactory::make("progressreport", Some("progress")).unwrap(); let progress = gst::ElementFactory::make("progressreport", Some("progress")).unwrap();
// Don't let progressreport print to stdout itself // Don't let progressreport print to stdout itself
progress.set_property("silent", true).unwrap(); progress.set_property("silent", true);
// Return an instance of our struct // Return an instance of our struct
Self { Self {

View file

@ -41,9 +41,7 @@ fn create_pipeline() -> (gst::Pipeline, gst::Pad, gst::Element, gtk::Widget) {
.upcast(); .upcast();
let fallbackswitch = gst::ElementFactory::make("fallbackswitch", None).unwrap(); let fallbackswitch = gst::ElementFactory::make("fallbackswitch", None).unwrap();
fallbackswitch fallbackswitch.set_property("timeout", gst::ClockTime::SECOND);
.set_property("timeout", gst::ClockTime::SECOND)
.unwrap();
let decodebin = gst::ElementFactory::make("decodebin", None).unwrap(); let decodebin = gst::ElementFactory::make("decodebin", None).unwrap();
let videoconvert = gst::ElementFactory::make("videoconvert", None).unwrap(); let videoconvert = gst::ElementFactory::make("videoconvert", None).unwrap();
@ -63,15 +61,15 @@ fn create_pipeline() -> (gst::Pipeline, gst::Pad, gst::Element, gtk::Widget) {
let (video_sink, video_widget) = let (video_sink, video_widget) =
//if let Some(gtkglsink) = gst::ElementFactory::make("gtkglsink", None) { //if let Some(gtkglsink) = gst::ElementFactory::make("gtkglsink", None) {
// let glsinkbin = gst::ElementFactory::make("glsinkbin", None).unwrap(); // let glsinkbin = gst::ElementFactory::make("glsinkbin", None).unwrap();
// glsinkbin.set_property("sink", &gtkglsink).unwrap(); // glsinkbin.set_property("sink", &gtkglsink);
// let widget = gtkglsink.get_property("widget").unwrap(); // let widget = gtkglsink.property::<gtk::Widget>("widget");
// (glsinkbin, widget.get::<gtk::Widget>().unwrap().unwrap()) // (glsinkbin, widget)
//} else //} else
{ {
let sink = gst::ElementFactory::make("gtksink", None).unwrap(); let sink = gst::ElementFactory::make("gtksink", None).unwrap();
let widget = sink.property("widget").unwrap(); let widget = sink.property::<gtk::Widget>("widget");
(sink, widget.get::<gtk::Widget>().unwrap()) (sink, widget)
}; };
pipeline pipeline

View file

@ -827,17 +827,14 @@ impl FallbackSrc {
let uri = element let uri = element
.emit_by_name("update-uri", &[uri]) .emit_by_name("update-uri", &[uri])
.expect("Failed to emit update-uri signal")
.expect("No value returned"); .expect("No value returned");
let uri = uri let uri = uri
.get::<&str>() .get::<&str>()
.expect("Wrong type returned from update-uri signal"); .expect("Wrong type returned from update-uri signal");
source.set_property("uri", uri).unwrap(); source.set_property("uri", uri);
source.set_property("use-buffering", true).unwrap(); source.set_property("use-buffering", true);
source source.set_property("buffer-duration", buffer_duration);
.set_property("buffer-duration", buffer_duration)
.unwrap();
source source
} }
@ -846,7 +843,7 @@ impl FallbackSrc {
// Handle any async state changes internally, they don't affect the pipeline because we // Handle any async state changes internally, they don't affect the pipeline because we
// convert everything to a live stream // convert everything to a live stream
source.set_property("async-handling", true).unwrap(); source.set_property("async-handling", true);
// Don't let the bin handle state changes of the source. We want to do it manually to catch // Don't let the bin handle state changes of the source. We want to do it manually to catch
// possible errors and retry, without causing the whole bin state change to fail // possible errors and retry, without causing the whole bin state change to fail
source.set_locked_state(true); source.set_locked_state(true);
@ -894,10 +891,8 @@ impl FallbackSrc {
.expect("No audiotestsrc found"); .expect("No audiotestsrc found");
input.add_many(&[&audiotestsrc]).unwrap(); input.add_many(&[&audiotestsrc]).unwrap();
audiotestsrc audiotestsrc.set_property_from_str("wave", "silence");
.set_property_from_str("wave", "silence") audiotestsrc.set_property("is-live", true);
.unwrap();
audiotestsrc.set_property("is-live", true).unwrap();
let srcpad = audiotestsrc.static_pad("src").unwrap(); let srcpad = audiotestsrc.static_pad("src").unwrap();
input input
@ -931,20 +926,18 @@ impl FallbackSrc {
let clocksync = gst::ElementFactory::make("clocksync", None) let clocksync = gst::ElementFactory::make("clocksync", None)
.or_else(|_| -> Result<_, glib::BoolError> { .or_else(|_| -> Result<_, glib::BoolError> {
let identity = gst::ElementFactory::make("identity", None)?; let identity = gst::ElementFactory::make("identity", None)?;
identity.set_property("sync", true).unwrap(); identity.set_property("sync", true);
Ok(identity) Ok(identity)
}) })
.expect("No clocksync or identity found"); .expect("No clocksync or identity found");
// Workaround for issues caused by https://gitlab.freedesktop.org/gstreamer/gst-plugins-base/-/issues/800 // Workaround for issues caused by https://gitlab.freedesktop.org/gstreamer/gst-plugins-base/-/issues/800
let clocksync_queue = gst::ElementFactory::make("queue", None).expect("No queue found"); let clocksync_queue = gst::ElementFactory::make("queue", None).expect("No queue found");
clocksync_queue clocksync_queue.set_properties(&[
.set_properties(&[ ("max-size-buffers", &0u32),
("max-size-buffers", &0u32), ("max-size-bytes", &0u32),
("max-size-bytes", &0u32), ("max-size-time", &gst::ClockTime::SECOND),
("max-size-time", &gst::ClockTime::SECOND), ]);
])
.unwrap();
element element
.add_many(&[&fallback_input, &switch, &clocksync_queue, &clocksync]) .add_many(&[&fallback_input, &switch, &clocksync_queue, &clocksync])
@ -960,13 +953,9 @@ impl FallbackSrc {
let src = FallbackSrc::from_instance(&element); let src = FallbackSrc::from_instance(&element);
src.handle_switch_active_pad_change(&element); src.handle_switch_active_pad_change(&element);
}); });
switch.set_property("timeout", timeout.nseconds()).unwrap(); switch.set_property("timeout", timeout.nseconds());
switch switch.set_property("min-upstream-latency", min_latency.nseconds());
.set_property("min-upstream-latency", min_latency.nseconds()) switch.set_property("immediate-fallback", immediate_fallback);
.unwrap();
switch
.set_property("immediate-fallback", immediate_fallback)
.unwrap();
gst::Element::link_pads(&fallback_input, Some("src"), &switch, Some("fallback_sink")) gst::Element::link_pads(&fallback_input, Some("src"), &switch, Some("fallback_sink"))
.unwrap(); .unwrap();
@ -1341,7 +1330,7 @@ impl FallbackSrc {
gst_debug!(CAT, "image stream, inserting imagefreeze"); gst_debug!(CAT, "image stream, inserting imagefreeze");
element.add(&imagefreeze).unwrap(); element.add(&imagefreeze).unwrap();
imagefreeze.set_property("is-live", true).unwrap(); imagefreeze.set_property("is-live", true);
if imagefreeze.sync_state_with_parent().is_err() { if imagefreeze.sync_state_with_parent().is_err() {
gst_error!(CAT, obj: element, "imagefreeze failed to change state",); gst_error!(CAT, obj: element, "imagefreeze failed to change state",);
return Err(gst::error_msg!( return Err(gst::error_msg!(
@ -2014,10 +2003,7 @@ impl FallbackSrc {
let prev_fallback_uri = video_stream let prev_fallback_uri = video_stream
.fallback_input .fallback_input
.property("uri") .property::<Option<String>>("uri");
.unwrap()
.get::<Option<String>>()
.unwrap();
// This means previously videotestsrc was configured // This means previously videotestsrc was configured
// Something went wrong and there is no other way than to error out // Something went wrong and there is no other way than to error out
@ -2383,13 +2369,7 @@ impl FallbackSrc {
&& state && state
.audio_stream .audio_stream
.as_ref() .as_ref()
.and_then(|s| { .and_then(|s| s.switch.property::<Option<gst::Pad>>("active-pad"))
s.switch
.property("active-pad")
.unwrap()
.get::<Option<gst::Pad>>()
.unwrap()
})
.map(|p| p.name() == "fallback_sink") .map(|p| p.name() == "fallback_sink")
.unwrap_or(true)) .unwrap_or(true))
|| (have_video || (have_video
@ -2397,13 +2377,7 @@ impl FallbackSrc {
&& state && state
.video_stream .video_stream
.as_ref() .as_ref()
.and_then(|s| { .and_then(|s| s.switch.property::<Option<gst::Pad>>("active-pad"))
s.switch
.property("active-pad")
.unwrap()
.get::<Option<gst::Pad>>()
.unwrap()
})
.map(|p| p.name() == "fallback_sink") .map(|p| p.name() == "fallback_sink")
.unwrap_or(true)) .unwrap_or(true))
} }

View file

@ -303,22 +303,20 @@ impl VideoFallbackSource {
.or_else(|_| -> Result<_, glib::BoolError> { .or_else(|_| -> Result<_, glib::BoolError> {
let identity = let identity =
gst::ElementFactory::make("identity", Some("fallback_clocksync"))?; gst::ElementFactory::make("identity", Some("fallback_clocksync"))?;
identity.set_property("sync", true).unwrap(); identity.set_property("sync", true);
Ok(identity) Ok(identity)
}) })
.expect("No clocksync or identity found"); .expect("No clocksync or identity found");
let queue = gst::ElementFactory::make("queue", Some("fallback_queue")) let queue = gst::ElementFactory::make("queue", Some("fallback_queue"))
.expect("No queue found"); .expect("No queue found");
queue queue.set_properties(&[
.set_properties(&[ ("max-size-buffers", &0u32),
("max-size-buffers", &0u32), ("max-size-bytes", &0u32),
("max-size-bytes", &0u32), (
( "max-size-time",
"max-size-time", &min_latency.max(5 * gst::ClockTime::SECOND).nseconds(),
&min_latency.max(5 * gst::ClockTime::SECOND).nseconds(), ),
), ]);
])
.unwrap();
source source
.add_many(&[ .add_many(&[
@ -341,7 +339,7 @@ impl VideoFallbackSource {
]) ])
.unwrap(); .unwrap();
if imagefreeze.set_property("is-live", true).is_err() { if imagefreeze.try_set_property("is-live", true).is_err() {
gst_error!( gst_error!(
CAT, CAT,
obj: element, obj: element,
@ -357,62 +355,60 @@ impl VideoFallbackSource {
let element_weak = element.downgrade(); let element_weak = element.downgrade();
let source_weak = source.downgrade(); let source_weak = source.downgrade();
let videoconvert_weak = videoconvert.downgrade(); let videoconvert_weak = videoconvert.downgrade();
typefind typefind.connect("have-type", false, move |args| {
.connect("have-type", false, move |args| { let typefind = args[0].get::<gst::Element>().unwrap();
let typefind = args[0].get::<gst::Element>().unwrap(); let _probability = args[1].get::<u32>().unwrap();
let _probability = args[1].get::<u32>().unwrap(); let caps = args[2].get::<gst::Caps>().unwrap();
let caps = args[2].get::<gst::Caps>().unwrap();
let element = match element_weak.upgrade() { let element = match element_weak.upgrade() {
Some(element) => element, Some(element) => element,
None => return None, None => return None,
}; };
let source = match source_weak.upgrade() { let source = match source_weak.upgrade() {
Some(element) => element, Some(element) => element,
None => return None, None => return None,
}; };
let videoconvert = match videoconvert_weak.upgrade() { let videoconvert = match videoconvert_weak.upgrade() {
Some(element) => element, Some(element) => element,
None => return None, None => return None,
}; };
let s = caps.structure(0).unwrap(); let s = caps.structure(0).unwrap();
let decoder; let decoder;
if s.name() == "image/jpeg" { if s.name() == "image/jpeg" {
decoder = gst::ElementFactory::make("jpegdec", Some("decoder")) decoder = gst::ElementFactory::make("jpegdec", Some("decoder"))
.expect("jpegdec not found"); .expect("jpegdec not found");
} else if s.name() == "image/png" { } else if s.name() == "image/png" {
decoder = gst::ElementFactory::make("pngdec", Some("decoder")) decoder = gst::ElementFactory::make("pngdec", Some("decoder"))
.expect("pngdec not found"); .expect("pngdec not found");
} else { } else {
gst_error!(CAT, obj: &element, "Unsupported caps {}", caps); gst_error!(CAT, obj: &element, "Unsupported caps {}", caps);
gst::element_error!( gst::element_error!(
element, element,
gst::StreamError::Format, gst::StreamError::Format,
["Unsupported caps {}", caps] ["Unsupported caps {}", caps]
); );
return None; return None;
} }
source.add(&decoder).unwrap(); source.add(&decoder).unwrap();
decoder.sync_state_with_parent().unwrap(); decoder.sync_state_with_parent().unwrap();
if let Err(_err) = if let Err(_err) =
gst::Element::link_many(&[&typefind, &decoder, &videoconvert]) gst::Element::link_many(&[&typefind, &decoder, &videoconvert])
{ {
gst_error!(CAT, obj: &element, "Can't link fallback image decoder"); gst_error!(CAT, obj: &element, "Can't link fallback image decoder");
gst::element_error!( gst::element_error!(
element, element,
gst::StreamError::Format, gst::StreamError::Format,
["Can't link fallback image decoder"] ["Can't link fallback image decoder"]
); );
return None; return None;
} }
None None
}) });
.unwrap();
queue.static_pad("src").unwrap() queue.static_pad("src").unwrap()
} }
@ -422,10 +418,8 @@ impl VideoFallbackSource {
.expect("No videotestsrc found"); .expect("No videotestsrc found");
source.add_many(&[&videotestsrc]).unwrap(); source.add_many(&[&videotestsrc]).unwrap();
videotestsrc videotestsrc.set_property_from_str("pattern", "black");
.set_property_from_str("pattern", "black") videotestsrc.set_property("is-live", true);
.unwrap();
videotestsrc.set_property("is-live", true).unwrap();
videotestsrc.static_pad("src").unwrap() videotestsrc.static_pad("src").unwrap()
} }

View file

@ -371,9 +371,9 @@ fn setup_pipeline(with_live_fallback: Option<bool>) -> Pipeline {
.unwrap() .unwrap()
.downcast::<gst_app::AppSrc>() .downcast::<gst_app::AppSrc>()
.unwrap(); .unwrap();
src.set_property("is-live", true).unwrap(); src.set_property("is-live", true);
src.set_property("format", gst::Format::Time).unwrap(); src.set_property("format", gst::Format::Time);
src.set_property("min-latency", 10i64).unwrap(); src.set_property("min-latency", 10i64);
src.set_property( src.set_property(
"caps", "caps",
&gst::Caps::builder("video/x-raw") &gst::Caps::builder("video/x-raw")
@ -382,19 +382,16 @@ fn setup_pipeline(with_live_fallback: Option<bool>) -> Pipeline {
.field("height", 240) .field("height", 240)
.field("framerate", gst::Fraction::new(1, 1)) .field("framerate", gst::Fraction::new(1, 1))
.build(), .build(),
) );
.unwrap();
let switch = gst::ElementFactory::make("fallbackswitch", Some("switch")).unwrap(); let switch = gst::ElementFactory::make("fallbackswitch", Some("switch")).unwrap();
switch switch.set_property("timeout", 3 * gst::ClockTime::SECOND);
.set_property("timeout", 3 * gst::ClockTime::SECOND)
.unwrap();
let sink = gst::ElementFactory::make("appsink", Some("sink")) let sink = gst::ElementFactory::make("appsink", Some("sink"))
.unwrap() .unwrap()
.downcast::<gst_app::AppSink>() .downcast::<gst_app::AppSink>()
.unwrap(); .unwrap();
sink.set_property("sync", false).unwrap(); sink.set_property("sync", false);
let queue = gst::ElementFactory::make("queue", None).unwrap(); let queue = gst::ElementFactory::make("queue", None).unwrap();
@ -410,22 +407,18 @@ fn setup_pipeline(with_live_fallback: Option<bool>) -> Pipeline {
.unwrap() .unwrap()
.downcast::<gst_app::AppSrc>() .downcast::<gst_app::AppSrc>()
.unwrap(); .unwrap();
fallback_src.set_property("is-live", live).unwrap(); fallback_src.set_property("is-live", live);
fallback_src fallback_src.set_property("format", gst::Format::Time);
.set_property("format", gst::Format::Time) fallback_src.set_property("min-latency", 10i64);
.unwrap(); fallback_src.set_property(
fallback_src.set_property("min-latency", 10i64).unwrap(); "caps",
fallback_src &gst::Caps::builder("video/x-raw")
.set_property( .field("format", "ARGB")
"caps", .field("width", 160)
&gst::Caps::builder("video/x-raw") .field("height", 120)
.field("format", "ARGB") .field("framerate", gst::Fraction::new(1, 1))
.field("width", 160) .build(),
.field("height", 120) );
.field("framerate", gst::Fraction::new(1, 1))
.build(),
)
.unwrap();
pipeline.add(&fallback_src).unwrap(); pipeline.add(&fallback_src).unwrap();

View file

@ -33,13 +33,11 @@ fn create_pipeline() -> (
let pipeline = gst::Pipeline::new(None); let pipeline = gst::Pipeline::new(None);
let video_src = gst::ElementFactory::make("videotestsrc", None).unwrap(); let video_src = gst::ElementFactory::make("videotestsrc", None).unwrap();
video_src.set_property("is-live", true).unwrap(); video_src.set_property("is-live", true);
video_src.set_property_from_str("pattern", "ball").unwrap(); video_src.set_property_from_str("pattern", "ball");
let timeoverlay = gst::ElementFactory::make("timeoverlay", None).unwrap(); let timeoverlay = gst::ElementFactory::make("timeoverlay", None).unwrap();
timeoverlay timeoverlay.set_property("font-desc", "Monospace 20");
.set_property("font-desc", "Monospace 20")
.unwrap();
let video_tee = gst::ElementFactory::make("tee", None).unwrap(); let video_tee = gst::ElementFactory::make("tee", None).unwrap();
let video_queue1 = gst::ElementFactory::make("queue", None).unwrap(); let video_queue1 = gst::ElementFactory::make("queue", None).unwrap();
@ -51,24 +49,24 @@ fn create_pipeline() -> (
let (video_sink, video_widget) = let (video_sink, video_widget) =
if let Ok(gtkglsink) = gst::ElementFactory::make("gtkglsink", None) { if let Ok(gtkglsink) = gst::ElementFactory::make("gtkglsink", None) {
let glsinkbin = gst::ElementFactory::make("glsinkbin", None).unwrap(); let glsinkbin = gst::ElementFactory::make("glsinkbin", None).unwrap();
glsinkbin.set_property("sink", &gtkglsink).unwrap(); glsinkbin.set_property("sink", &gtkglsink);
let widget = gtkglsink.property("widget").unwrap(); let widget = gtkglsink.property::<gtk::Widget>("widget");
(glsinkbin, widget.get::<gtk::Widget>().unwrap()) (glsinkbin, widget)
} else { } else {
let sink = gst::ElementFactory::make("gtksink", None).unwrap(); let sink = gst::ElementFactory::make("gtksink", None).unwrap();
let widget = sink.property("widget").unwrap(); let widget = sink.property::<gtk::Widget>("widget");
(sink, widget.get::<gtk::Widget>().unwrap()) (sink, widget)
}; };
let video_enc = gst::ElementFactory::make("x264enc", None).unwrap(); let video_enc = gst::ElementFactory::make("x264enc", None).unwrap();
video_enc.set_property("rc-lookahead", 10i32).unwrap(); video_enc.set_property("rc-lookahead", 10i32);
video_enc.set_property("key-int-max", 30u32).unwrap(); video_enc.set_property("key-int-max", 30u32);
let video_parse = gst::ElementFactory::make("h264parse", None).unwrap(); let video_parse = gst::ElementFactory::make("h264parse", None).unwrap();
let audio_src = gst::ElementFactory::make("audiotestsrc", None).unwrap(); let audio_src = gst::ElementFactory::make("audiotestsrc", None).unwrap();
audio_src.set_property("is-live", true).unwrap(); audio_src.set_property("is-live", true);
audio_src.set_property_from_str("wave", "ticks").unwrap(); audio_src.set_property_from_str("wave", "ticks");
let audio_tee = gst::ElementFactory::make("tee", None).unwrap(); let audio_tee = gst::ElementFactory::make("tee", None).unwrap();
let audio_queue1 = gst::ElementFactory::make("queue", None).unwrap(); let audio_queue1 = gst::ElementFactory::make("queue", None).unwrap();
@ -90,9 +88,9 @@ fn create_pipeline() -> (
let mux = gst::ElementFactory::make("mp4mux", None).unwrap(); let mux = gst::ElementFactory::make("mp4mux", None).unwrap();
let file_sink = gst::ElementFactory::make("filesink", None).unwrap(); let file_sink = gst::ElementFactory::make("filesink", None).unwrap();
file_sink.set_property("location", "recording.mp4").unwrap(); file_sink.set_property("location", "recording.mp4");
file_sink.set_property("async", false).unwrap(); file_sink.set_property("async", false);
file_sink.set_property("sync", false).unwrap(); file_sink.set_property("sync", false);
pipeline pipeline
.add_many(&[ .add_many(&[
@ -255,12 +253,8 @@ fn create_ui(app: &gtk::Application) {
None => return, None => return,
}; };
let recording = !togglerecord let recording = !togglerecord.property::<bool>("record");
.property("record") togglerecord.set_property("record", recording);
.unwrap()
.get::<bool>()
.unwrap();
togglerecord.set_property("record", recording).unwrap();
button.set_label(if recording { "Stop" } else { "Record" }); button.set_label(if recording { "Stop" } else { "Record" });
}); });

View file

@ -53,7 +53,7 @@ fn setup_sender_receiver(
thread::JoinHandle<()>, thread::JoinHandle<()>,
) { ) {
let fakesink = gst::ElementFactory::make("fakesink", None).unwrap(); let fakesink = gst::ElementFactory::make("fakesink", None).unwrap();
fakesink.set_property("async", false).unwrap(); fakesink.set_property("async", false);
pipeline.add(&fakesink).unwrap(); pipeline.add(&fakesink).unwrap();
let main_stream = pad == "src"; let main_stream = pad == "src";
@ -298,7 +298,7 @@ fn test_one_stream_open() {
pipeline.set_state(gst::State::Playing).unwrap(); pipeline.set_state(gst::State::Playing).unwrap();
togglerecord.set_property("record", true).unwrap(); togglerecord.set_property("record", true);
sender_input.send(SendData::Buffers(10)).unwrap(); sender_input.send(SendData::Buffers(10)).unwrap();
drop(sender_input); drop(sender_input);
@ -330,7 +330,7 @@ fn test_one_stream_gaps_open() {
pipeline.set_state(gst::State::Playing).unwrap(); pipeline.set_state(gst::State::Playing).unwrap();
togglerecord.set_property("record", true).unwrap(); togglerecord.set_property("record", true);
sender_input.send(SendData::Buffers(5)).unwrap(); sender_input.send(SendData::Buffers(5)).unwrap();
sender_input.send(SendData::Gaps(5)).unwrap(); sender_input.send(SendData::Gaps(5)).unwrap();
drop(sender_input); drop(sender_input);
@ -365,7 +365,7 @@ fn test_one_stream_close_open() {
sender_input.send(SendData::Buffers(10)).unwrap(); sender_input.send(SendData::Buffers(10)).unwrap();
receiver_input_done.recv().unwrap(); receiver_input_done.recv().unwrap();
togglerecord.set_property("record", true).unwrap(); togglerecord.set_property("record", true);
sender_input.send(SendData::Buffers(10)).unwrap(); sender_input.send(SendData::Buffers(10)).unwrap();
drop(sender_input); drop(sender_input);
@ -397,10 +397,10 @@ fn test_one_stream_open_close() {
pipeline.set_state(gst::State::Playing).unwrap(); pipeline.set_state(gst::State::Playing).unwrap();
togglerecord.set_property("record", true).unwrap(); togglerecord.set_property("record", true);
sender_input.send(SendData::Buffers(10)).unwrap(); sender_input.send(SendData::Buffers(10)).unwrap();
receiver_input_done.recv().unwrap(); receiver_input_done.recv().unwrap();
togglerecord.set_property("record", false).unwrap(); togglerecord.set_property("record", false);
sender_input.send(SendData::Buffers(10)).unwrap(); sender_input.send(SendData::Buffers(10)).unwrap();
drop(sender_input); drop(sender_input);
@ -432,13 +432,13 @@ fn test_one_stream_open_close_open() {
pipeline.set_state(gst::State::Playing).unwrap(); pipeline.set_state(gst::State::Playing).unwrap();
togglerecord.set_property("record", true).unwrap(); togglerecord.set_property("record", true);
sender_input.send(SendData::Buffers(10)).unwrap(); sender_input.send(SendData::Buffers(10)).unwrap();
receiver_input_done.recv().unwrap(); receiver_input_done.recv().unwrap();
togglerecord.set_property("record", false).unwrap(); togglerecord.set_property("record", false);
sender_input.send(SendData::Buffers(10)).unwrap(); sender_input.send(SendData::Buffers(10)).unwrap();
receiver_input_done.recv().unwrap(); receiver_input_done.recv().unwrap();
togglerecord.set_property("record", true).unwrap(); togglerecord.set_property("record", true);
sender_input.send(SendData::Buffers(10)).unwrap(); sender_input.send(SendData::Buffers(10)).unwrap();
drop(sender_input); drop(sender_input);
@ -478,7 +478,7 @@ fn test_two_stream_open() {
pipeline.set_state(gst::State::Playing).unwrap(); pipeline.set_state(gst::State::Playing).unwrap();
togglerecord.set_property("record", true).unwrap(); togglerecord.set_property("record", true);
sender_input_1.send(SendData::Buffers(10)).unwrap(); sender_input_1.send(SendData::Buffers(10)).unwrap();
sender_input_2.send(SendData::Buffers(11)).unwrap(); sender_input_2.send(SendData::Buffers(11)).unwrap();
@ -536,7 +536,7 @@ fn test_two_stream_open_shift() {
pipeline.set_state(gst::State::Playing).unwrap(); pipeline.set_state(gst::State::Playing).unwrap();
togglerecord.set_property("record", true).unwrap(); togglerecord.set_property("record", true);
sender_input_1.send(SendData::Buffers(10)).unwrap(); sender_input_1.send(SendData::Buffers(10)).unwrap();
sender_input_2.send(SendData::Buffers(11)).unwrap(); sender_input_2.send(SendData::Buffers(11)).unwrap();
@ -599,7 +599,7 @@ fn test_two_stream_open_shift_main() {
pipeline.set_state(gst::State::Playing).unwrap(); pipeline.set_state(gst::State::Playing).unwrap();
togglerecord.set_property("record", true).unwrap(); togglerecord.set_property("record", true);
sender_input_1.send(SendData::Buffers(10)).unwrap(); sender_input_1.send(SendData::Buffers(10)).unwrap();
sender_input_2.send(SendData::Buffers(12)).unwrap(); sender_input_2.send(SendData::Buffers(12)).unwrap();
@ -676,7 +676,7 @@ fn test_two_stream_open_close() {
pipeline.set_state(gst::State::Playing).unwrap(); pipeline.set_state(gst::State::Playing).unwrap();
togglerecord.set_property("record", true).unwrap(); togglerecord.set_property("record", true);
sender_input_1.send(SendData::Buffers(10)).unwrap(); sender_input_1.send(SendData::Buffers(10)).unwrap();
sender_input_2.send(SendData::Buffers(11)).unwrap(); sender_input_2.send(SendData::Buffers(11)).unwrap();
@ -686,7 +686,7 @@ fn test_two_stream_open_close() {
// Stop recording and push new buffers to sender 1, which will advance // Stop recording and push new buffers to sender 1, which will advance
// it and release the 11th buffer of sender 2 above // it and release the 11th buffer of sender 2 above
togglerecord.set_property("record", false).unwrap(); togglerecord.set_property("record", false);
sender_input_1.send(SendData::Buffers(10)).unwrap(); sender_input_1.send(SendData::Buffers(10)).unwrap();
receiver_input_done_2.recv().unwrap(); receiver_input_done_2.recv().unwrap();
@ -745,7 +745,7 @@ fn test_two_stream_close_open() {
pipeline.set_state(gst::State::Playing).unwrap(); pipeline.set_state(gst::State::Playing).unwrap();
togglerecord.set_property("record", false).unwrap(); togglerecord.set_property("record", false);
sender_input_1.send(SendData::Buffers(10)).unwrap(); sender_input_1.send(SendData::Buffers(10)).unwrap();
sender_input_2.send(SendData::Buffers(11)).unwrap(); sender_input_2.send(SendData::Buffers(11)).unwrap();
@ -755,7 +755,7 @@ fn test_two_stream_close_open() {
// Start recording and push new buffers to sender 1, which will advance // Start recording and push new buffers to sender 1, which will advance
// it and release the 11th buffer of sender 2 above // it and release the 11th buffer of sender 2 above
togglerecord.set_property("record", true).unwrap(); togglerecord.set_property("record", true);
sender_input_1.send(SendData::Buffers(10)).unwrap(); sender_input_1.send(SendData::Buffers(10)).unwrap();
receiver_input_done_2.recv().unwrap(); receiver_input_done_2.recv().unwrap();
@ -814,7 +814,7 @@ fn test_two_stream_open_close_open() {
pipeline.set_state(gst::State::Playing).unwrap(); pipeline.set_state(gst::State::Playing).unwrap();
togglerecord.set_property("record", true).unwrap(); togglerecord.set_property("record", true);
sender_input_1.send(SendData::Buffers(10)).unwrap(); sender_input_1.send(SendData::Buffers(10)).unwrap();
sender_input_2.send(SendData::Buffers(11)).unwrap(); sender_input_2.send(SendData::Buffers(11)).unwrap();
@ -824,7 +824,7 @@ fn test_two_stream_open_close_open() {
// Stop recording and push new buffers to sender 1, which will advance // Stop recording and push new buffers to sender 1, which will advance
// it and release the 11th buffer of sender 2 above // it and release the 11th buffer of sender 2 above
togglerecord.set_property("record", false).unwrap(); togglerecord.set_property("record", false);
sender_input_1.send(SendData::Buffers(10)).unwrap(); sender_input_1.send(SendData::Buffers(10)).unwrap();
receiver_input_done_2.recv().unwrap(); receiver_input_done_2.recv().unwrap();
@ -840,7 +840,7 @@ fn test_two_stream_open_close_open() {
sender_input_2.send(SendData::Buffers(1)).unwrap(); sender_input_2.send(SendData::Buffers(1)).unwrap();
// Start recording again and send another set of buffers to both senders // Start recording again and send another set of buffers to both senders
togglerecord.set_property("record", true).unwrap(); togglerecord.set_property("record", true);
sender_input_1.send(SendData::Buffers(10)).unwrap(); sender_input_1.send(SendData::Buffers(10)).unwrap();
sender_input_2.send(SendData::Buffers(10)).unwrap(); sender_input_2.send(SendData::Buffers(10)).unwrap();
receiver_input_done_1.recv().unwrap(); receiver_input_done_1.recv().unwrap();
@ -908,7 +908,7 @@ fn test_two_stream_open_close_open_gaps() {
pipeline.set_state(gst::State::Playing).unwrap(); pipeline.set_state(gst::State::Playing).unwrap();
togglerecord.set_property("record", true).unwrap(); togglerecord.set_property("record", true);
sender_input_1.send(SendData::Buffers(3)).unwrap(); sender_input_1.send(SendData::Buffers(3)).unwrap();
sender_input_1.send(SendData::Gaps(3)).unwrap(); sender_input_1.send(SendData::Gaps(3)).unwrap();
@ -922,7 +922,7 @@ fn test_two_stream_open_close_open_gaps() {
// Stop recording and push new buffers to sender 1, which will advance // Stop recording and push new buffers to sender 1, which will advance
// it and release the 11th buffer of sender 2 above // it and release the 11th buffer of sender 2 above
togglerecord.set_property("record", false).unwrap(); togglerecord.set_property("record", false);
sender_input_1.send(SendData::Buffers(10)).unwrap(); sender_input_1.send(SendData::Buffers(10)).unwrap();
receiver_input_done_2.recv().unwrap(); receiver_input_done_2.recv().unwrap();
@ -940,7 +940,7 @@ fn test_two_stream_open_close_open_gaps() {
sender_input_2.send(SendData::Gaps(1)).unwrap(); sender_input_2.send(SendData::Gaps(1)).unwrap();
// Start recording again and send another set of buffers to both senders // Start recording again and send another set of buffers to both senders
togglerecord.set_property("record", true).unwrap(); togglerecord.set_property("record", true);
sender_input_1.send(SendData::Buffers(10)).unwrap(); sender_input_1.send(SendData::Buffers(10)).unwrap();
sender_input_2.send(SendData::Buffers(10)).unwrap(); sender_input_2.send(SendData::Buffers(10)).unwrap();
receiver_input_done_1.recv().unwrap(); receiver_input_done_1.recv().unwrap();
@ -1008,7 +1008,7 @@ fn test_two_stream_close_open_close_delta() {
pipeline.set_state(gst::State::Playing).unwrap(); pipeline.set_state(gst::State::Playing).unwrap();
togglerecord.set_property("record", false).unwrap(); togglerecord.set_property("record", false);
sender_input_1.send(SendData::Buffers(10)).unwrap(); sender_input_1.send(SendData::Buffers(10)).unwrap();
sender_input_2.send(SendData::Buffers(11)).unwrap(); sender_input_2.send(SendData::Buffers(11)).unwrap();
@ -1019,7 +1019,7 @@ fn test_two_stream_close_open_close_delta() {
// Start recording and push new buffers to sender 1. The first one is a delta frame, // Start recording and push new buffers to sender 1. The first one is a delta frame,
// so will be dropped, and as such the next frame of sender 2 will also be dropped // so will be dropped, and as such the next frame of sender 2 will also be dropped
// Sender 2 is empty now // Sender 2 is empty now
togglerecord.set_property("record", true).unwrap(); togglerecord.set_property("record", true);
sender_input_1.send(SendData::BuffersDelta(1)).unwrap(); sender_input_1.send(SendData::BuffersDelta(1)).unwrap();
sender_input_1.send(SendData::Buffers(9)).unwrap(); sender_input_1.send(SendData::Buffers(9)).unwrap();
receiver_input_done_2.recv().unwrap(); receiver_input_done_2.recv().unwrap();
@ -1039,7 +1039,7 @@ fn test_two_stream_close_open_close_delta() {
// Stop recording again and send another set of buffers to both senders // Stop recording again and send another set of buffers to both senders
// The first one is a delta frame, so we only actually stop recording // The first one is a delta frame, so we only actually stop recording
// after recording another frame // after recording another frame
togglerecord.set_property("record", false).unwrap(); togglerecord.set_property("record", false);
sender_input_1.send(SendData::BuffersDelta(1)).unwrap(); sender_input_1.send(SendData::BuffersDelta(1)).unwrap();
sender_input_1.send(SendData::Buffers(9)).unwrap(); sender_input_1.send(SendData::Buffers(9)).unwrap();
sender_input_2.send(SendData::Buffers(10)).unwrap(); sender_input_2.send(SendData::Buffers(10)).unwrap();
@ -1099,7 +1099,7 @@ fn test_three_stream_open_close_open() {
pipeline.set_state(gst::State::Playing).unwrap(); pipeline.set_state(gst::State::Playing).unwrap();
togglerecord.set_property("record", true).unwrap(); togglerecord.set_property("record", true);
sender_input_1.send(SendData::Buffers(10)).unwrap(); sender_input_1.send(SendData::Buffers(10)).unwrap();
sender_input_2.send(SendData::Buffers(11)).unwrap(); sender_input_2.send(SendData::Buffers(11)).unwrap();
@ -1110,7 +1110,7 @@ fn test_three_stream_open_close_open() {
// Stop recording and push new buffers to sender 1, which will advance // Stop recording and push new buffers to sender 1, which will advance
// it and release the 11th buffer of sender 2/3 above // it and release the 11th buffer of sender 2/3 above
togglerecord.set_property("record", false).unwrap(); togglerecord.set_property("record", false);
sender_input_1.send(SendData::Buffers(10)).unwrap(); sender_input_1.send(SendData::Buffers(10)).unwrap();
receiver_input_done_2.recv().unwrap(); receiver_input_done_2.recv().unwrap();
@ -1130,7 +1130,7 @@ fn test_three_stream_open_close_open() {
sender_input_2.send(SendData::Buffers(1)).unwrap(); sender_input_2.send(SendData::Buffers(1)).unwrap();
// Start recording again and send another set of buffers to both senders // Start recording again and send another set of buffers to both senders
togglerecord.set_property("record", true).unwrap(); togglerecord.set_property("record", true);
sender_input_1.send(SendData::Buffers(10)).unwrap(); sender_input_1.send(SendData::Buffers(10)).unwrap();
sender_input_2.send(SendData::Buffers(10)).unwrap(); sender_input_2.send(SendData::Buffers(10)).unwrap();
sender_input_3.send(SendData::Buffers(5)).unwrap(); sender_input_3.send(SendData::Buffers(5)).unwrap();
@ -1221,7 +1221,7 @@ fn test_two_stream_main_eos() {
pipeline.set_state(gst::State::Playing).unwrap(); pipeline.set_state(gst::State::Playing).unwrap();
togglerecord.set_property("record", true).unwrap(); togglerecord.set_property("record", true);
// Send 10 buffers to main stream first // Send 10 buffers to main stream first
sender_input_1.send(SendData::Buffers(10)).unwrap(); sender_input_1.send(SendData::Buffers(10)).unwrap();
@ -1234,11 +1234,7 @@ fn test_two_stream_main_eos() {
sender_input_1.send(SendData::Eos).unwrap(); sender_input_1.send(SendData::Eos).unwrap();
receiver_input_done_1.recv().unwrap(); receiver_input_done_1.recv().unwrap();
let recording = togglerecord let recording = togglerecord.property::<bool>("recording");
.property("recording")
.unwrap()
.get::<bool>()
.unwrap();
assert!(recording); assert!(recording);
// Send 2 buffers to secondary stream. At this moment, main stream got eos // Send 2 buffers to secondary stream. At this moment, main stream got eos
@ -1253,11 +1249,7 @@ fn test_two_stream_main_eos() {
// At this moment, all streams should be in eos state. So togglerecord // At this moment, all streams should be in eos state. So togglerecord
// must be in stopped state // must be in stopped state
let recording = togglerecord let recording = togglerecord.property::<bool>("recording");
.property("recording")
.unwrap()
.get::<bool>()
.unwrap();
assert!(!recording); assert!(!recording);
let mut segment_1 = gst::FormattedSegment::<gst::ClockTime>::new(); let mut segment_1 = gst::FormattedSegment::<gst::ClockTime>::new();
@ -1304,7 +1296,7 @@ fn test_two_stream_secondary_eos_first() {
pipeline.set_state(gst::State::Playing).unwrap(); pipeline.set_state(gst::State::Playing).unwrap();
togglerecord.set_property("record", true).unwrap(); togglerecord.set_property("record", true);
// Send 10 buffers to main stream first // Send 10 buffers to main stream first
sender_input_1.send(SendData::Buffers(10)).unwrap(); sender_input_1.send(SendData::Buffers(10)).unwrap();
@ -1317,22 +1309,14 @@ fn test_two_stream_secondary_eos_first() {
receiver_input_done_2.recv().unwrap(); receiver_input_done_2.recv().unwrap();
// Since main stream is not yet EOS state, we should be in recording state // Since main stream is not yet EOS state, we should be in recording state
let recording = togglerecord let recording = togglerecord.property::<bool>("recording");
.property("recording")
.unwrap()
.get::<bool>()
.unwrap();
assert!(recording); assert!(recording);
// And send EOS to the main stream then it will update state to Stopped // And send EOS to the main stream then it will update state to Stopped
sender_input_1.send(SendData::Eos).unwrap(); sender_input_1.send(SendData::Eos).unwrap();
receiver_input_done_1.recv().unwrap(); receiver_input_done_1.recv().unwrap();
let recording = togglerecord let recording = togglerecord.property::<bool>("recording");
.property("recording")
.unwrap()
.get::<bool>()
.unwrap();
assert!(!recording); assert!(!recording);
let mut segment_1 = gst::FormattedSegment::<gst::ClockTime>::new(); let mut segment_1 = gst::FormattedSegment::<gst::ClockTime>::new();
@ -1382,7 +1366,7 @@ fn test_three_stream_main_eos() {
pipeline.set_state(gst::State::Playing).unwrap(); pipeline.set_state(gst::State::Playing).unwrap();
togglerecord.set_property("record", true).unwrap(); togglerecord.set_property("record", true);
sender_input_1.send(SendData::Buffers(10)).unwrap(); sender_input_1.send(SendData::Buffers(10)).unwrap();
sender_input_2.send(SendData::Buffers(9)).unwrap(); sender_input_2.send(SendData::Buffers(9)).unwrap();
@ -1396,11 +1380,7 @@ fn test_three_stream_main_eos() {
sender_input_1.send(SendData::Eos).unwrap(); sender_input_1.send(SendData::Eos).unwrap();
receiver_input_done_1.recv().unwrap(); receiver_input_done_1.recv().unwrap();
let recording = togglerecord let recording = togglerecord.property::<bool>("recording");
.property("recording")
.unwrap()
.get::<bool>()
.unwrap();
assert!(recording); assert!(recording);
// Send 2 buffers to non-main streams. At this moment, main stream got EOS // Send 2 buffers to non-main streams. At this moment, main stream got EOS
@ -1415,11 +1395,7 @@ fn test_three_stream_main_eos() {
receiver_input_done_2.recv().unwrap(); receiver_input_done_2.recv().unwrap();
// The third stream is not in EOS state yet, so still recording == true // The third stream is not in EOS state yet, so still recording == true
let recording = togglerecord let recording = togglerecord.property::<bool>("recording");
.property("recording")
.unwrap()
.get::<bool>()
.unwrap();
assert!(recording); assert!(recording);
// And terminate the third thread without EOS // And terminate the third thread without EOS
@ -1430,11 +1406,7 @@ fn test_three_stream_main_eos() {
// At this moment, all streams should be in eos state. So togglerecord // At this moment, all streams should be in eos state. So togglerecord
// must be in stopped state // must be in stopped state
let recording = togglerecord let recording = togglerecord.property::<bool>("recording");
.property("recording")
.unwrap()
.get::<bool>()
.unwrap();
assert!(!recording); assert!(!recording);
let mut segment_1 = gst::FormattedSegment::<gst::ClockTime>::new(); let mut segment_1 = gst::FormattedSegment::<gst::ClockTime>::new();
@ -1495,7 +1467,7 @@ fn test_three_stream_main_and_second_eos() {
pipeline.set_state(gst::State::Playing).unwrap(); pipeline.set_state(gst::State::Playing).unwrap();
togglerecord.set_property("record", true).unwrap(); togglerecord.set_property("record", true);
sender_input_1.send(SendData::Buffers(10)).unwrap(); sender_input_1.send(SendData::Buffers(10)).unwrap();
sender_input_2.send(SendData::Buffers(9)).unwrap(); sender_input_2.send(SendData::Buffers(9)).unwrap();
@ -1509,11 +1481,7 @@ fn test_three_stream_main_and_second_eos() {
sender_input_1.send(SendData::Eos).unwrap(); sender_input_1.send(SendData::Eos).unwrap();
receiver_input_done_1.recv().unwrap(); receiver_input_done_1.recv().unwrap();
let recording = togglerecord let recording = togglerecord.property::<bool>("recording");
.property("recording")
.unwrap()
.get::<bool>()
.unwrap();
assert!(recording); assert!(recording);
// And send EOS to the second stream, but state shouldn't be affected by // And send EOS to the second stream, but state shouldn't be affected by
@ -1521,11 +1489,7 @@ fn test_three_stream_main_and_second_eos() {
sender_input_2.send(SendData::Eos).unwrap(); sender_input_2.send(SendData::Eos).unwrap();
receiver_input_done_2.recv().unwrap(); receiver_input_done_2.recv().unwrap();
let recording = togglerecord let recording = togglerecord.property::<bool>("recording");
.property("recording")
.unwrap()
.get::<bool>()
.unwrap();
assert!(recording); assert!(recording);
// Send 2 buffers to the third stream. At this moment, main stream and // Send 2 buffers to the third stream. At this moment, main stream and
@ -1542,11 +1506,7 @@ fn test_three_stream_main_and_second_eos() {
// At this moment, all streams should be in eos state. So togglerecord // At this moment, all streams should be in eos state. So togglerecord
// must be in stopped state // must be in stopped state
let recording = togglerecord let recording = togglerecord.property::<bool>("recording");
.property("recording")
.unwrap()
.get::<bool>()
.unwrap();
assert!(!recording); assert!(!recording);
let mut segment_1 = gst::FormattedSegment::<gst::ClockTime>::new(); let mut segment_1 = gst::FormattedSegment::<gst::ClockTime>::new();
@ -1608,7 +1568,7 @@ fn test_three_stream_secondary_eos_first() {
pipeline.set_state(gst::State::Playing).unwrap(); pipeline.set_state(gst::State::Playing).unwrap();
togglerecord.set_property("record", true).unwrap(); togglerecord.set_property("record", true);
sender_input_1.send(SendData::Buffers(10)).unwrap(); sender_input_1.send(SendData::Buffers(10)).unwrap();
sender_input_2.send(SendData::Buffers(9)).unwrap(); sender_input_2.send(SendData::Buffers(9)).unwrap();
@ -1625,11 +1585,7 @@ fn test_three_stream_secondary_eos_first() {
receiver_input_done_3.recv().unwrap(); receiver_input_done_3.recv().unwrap();
// Since main stream is not yet EOS state, we should be in recording state // Since main stream is not yet EOS state, we should be in recording state
let recording = togglerecord let recording = togglerecord.property::<bool>("recording");
.property("recording")
.unwrap()
.get::<bool>()
.unwrap();
assert!(recording); assert!(recording);
// And send EOS, Send EOS to the main stream then it will update state to // And send EOS, Send EOS to the main stream then it will update state to
@ -1637,11 +1593,7 @@ fn test_three_stream_secondary_eos_first() {
sender_input_1.send(SendData::Eos).unwrap(); sender_input_1.send(SendData::Eos).unwrap();
receiver_input_done_1.recv().unwrap(); receiver_input_done_1.recv().unwrap();
let recording = togglerecord let recording = togglerecord.property::<bool>("recording");
.property("recording")
.unwrap()
.get::<bool>()
.unwrap();
assert!(!recording); assert!(!recording);
let mut segment_1 = gst::FormattedSegment::<gst::ClockTime>::new(); let mut segment_1 = gst::FormattedSegment::<gst::ClockTime>::new();

View file

@ -36,9 +36,7 @@ fn test_cdgdec() {
// Ensure we are in push mode so 'blocksize' prop is used // Ensure we are in push mode so 'blocksize' prop is used
let filesrc = gst::ElementFactory::make("pushfilesrc", None).unwrap(); let filesrc = gst::ElementFactory::make("pushfilesrc", None).unwrap();
filesrc filesrc.set_property("location", input_path.to_str().unwrap());
.set_property("location", input_path.to_str().unwrap())
.expect("failed to set 'location' property");
{ {
let child_proxy = filesrc.dynamic_cast_ref::<gst::ChildProxy>().unwrap(); let child_proxy = filesrc.dynamic_cast_ref::<gst::ChildProxy>().unwrap();
child_proxy child_proxy

View file

@ -139,16 +139,12 @@ impl TranscriberBin {
state state
.transcriber_queue .transcriber_queue
.set_property("max-size-buffers", 0u32) .set_property("max-size-buffers", 0u32);
.unwrap(); state.transcriber_queue.set_property("max-size-time", 0u64);
state
.transcriber_queue
.set_property("max-size-time", 0u64)
.unwrap();
state.internal_bin.add(&state.transcription_bin)?; state.internal_bin.add(&state.transcription_bin)?;
state.textwrap.set_property("lines", 2u32).unwrap(); state.textwrap.set_property("lines", 2u32);
state.transcription_bin.set_locked_state(true); state.transcription_bin.set_locked_state(true);
@ -208,8 +204,7 @@ impl TranscriberBin {
state state
.cccombiner .cccombiner
.set_property("latency", 100 * gst::ClockTime::MSECOND) .set_property("latency", 100 * gst::ClockTime::MSECOND);
.unwrap();
self.audio_sinkpad self.audio_sinkpad
.set_target(Some(&state.internal_bin.static_pad("audio_sink").unwrap()))?; .set_target(Some(&state.internal_bin.static_pad("audio_sink").unwrap()))?;
@ -234,21 +229,18 @@ impl TranscriberBin {
s.set("framerate", &state.framerate.unwrap()); s.set("framerate", &state.framerate.unwrap());
state.cccapsfilter.set_property("caps", &cc_caps).unwrap(); state.cccapsfilter.set_property("caps", &cc_caps);
let max_size_time = settings.latency + settings.accumulate_time; let max_size_time = settings.latency + settings.accumulate_time;
for queue in &[&state.audio_queue_passthrough, &state.video_queue] { for queue in &[&state.audio_queue_passthrough, &state.video_queue] {
queue.set_property("max-size-bytes", 0u32).unwrap(); queue.set_property("max-size-bytes", 0u32);
queue.set_property("max-size-buffers", 0u32).unwrap(); queue.set_property("max-size-buffers", 0u32);
queue.set_property("max-size-time", max_size_time).unwrap(); queue.set_property("max-size-time", max_size_time);
} }
let latency_ms = settings.latency.mseconds() as u32; let latency_ms = settings.latency.mseconds() as u32;
state state.transcriber.set_property("latency", latency_ms);
.transcriber
.set_property("latency", latency_ms)
.unwrap();
if !settings.passthrough { if !settings.passthrough {
let audio_tee_pad = state.audio_tee.request_pad_simple("src_%u").unwrap(); let audio_tee_pad = state.audio_tee.request_pad_simple("src_%u").unwrap();
@ -349,20 +341,16 @@ impl TranscriberBin {
gst_debug!(CAT, obj: element, "setting CC mode {:?}", mode); gst_debug!(CAT, obj: element, "setting CC mode {:?}", mode);
state.tttocea608.set_property("mode", mode).unwrap(); state.tttocea608.set_property("mode", mode);
if mode.is_rollup() { if mode.is_rollup() {
state state.textwrap.set_property("accumulate-time", 0u64);
.textwrap
.set_property("accumulate-time", 0u64)
.unwrap();
} else { } else {
let accumulate_time = self.settings.lock().unwrap().accumulate_time; let accumulate_time = self.settings.lock().unwrap().accumulate_time;
state state
.textwrap .textwrap
.set_property("accumulate-time", accumulate_time) .set_property("accumulate-time", accumulate_time);
.unwrap();
} }
} }

View file

@ -71,10 +71,7 @@ fn test_have_cc_data_notify() {
let mut h = gst_check::Harness::new("ccdetect"); let mut h = gst_check::Harness::new("ccdetect");
h.set_src_caps_str("closedcaption/x-cea-708,format=cc_data"); h.set_src_caps_str("closedcaption/x-cea-708,format=cc_data");
h.set_sink_caps_str("closedcaption/x-cea-708,format=cc_data"); h.set_sink_caps_str("closedcaption/x-cea-708,format=cc_data");
h.element() h.element().unwrap().set_property("window", 500_000_000u64);
.unwrap()
.set_property("window", 500_000_000u64)
.unwrap();
let state = Arc::new(Mutex::new(NotifyState::default())); let state = Arc::new(Mutex::new(NotifyState::default()));
let state_c = state.clone(); let state_c = state.clone();
@ -83,7 +80,7 @@ fn test_have_cc_data_notify() {
.connect_notify(Some("cc608"), move |o, _pspec| { .connect_notify(Some("cc608"), move |o, _pspec| {
let mut state_guard = state_c.lock().unwrap(); let mut state_guard = state_c.lock().unwrap();
state_guard.cc608_count += 1; state_guard.cc608_count += 1;
o.property("cc608").unwrap(); o.property_value("cc608");
}); });
let state_c = state.clone(); let state_c = state.clone();
h.element() h.element()
@ -91,7 +88,7 @@ fn test_have_cc_data_notify() {
.connect_notify(Some("cc708"), move |o, _pspec| { .connect_notify(Some("cc708"), move |o, _pspec| {
let mut state_guard = state_c.lock().unwrap(); let mut state_guard = state_c.lock().unwrap();
state_guard.cc708_count += 1; state_guard.cc708_count += 1;
o.property("cc708").unwrap(); o.property_value("cc708");
}); });
/* valid cc608 data moves cc608 property to true */ /* valid cc608 data moves cc608 property to true */
@ -137,10 +134,7 @@ fn test_cc_data_window() {
let mut h = gst_check::Harness::new("ccdetect"); let mut h = gst_check::Harness::new("ccdetect");
h.set_src_caps_str("closedcaption/x-cea-708,format=cc_data"); h.set_src_caps_str("closedcaption/x-cea-708,format=cc_data");
h.set_sink_caps_str("closedcaption/x-cea-708,format=cc_data"); h.set_sink_caps_str("closedcaption/x-cea-708,format=cc_data");
h.element() h.element().unwrap().set_property("window", 500_000_000u64);
.unwrap()
.set_property("window", 500_000_000u64)
.unwrap();
let state = Arc::new(Mutex::new(NotifyState::default())); let state = Arc::new(Mutex::new(NotifyState::default()));
let state_c = state.clone(); let state_c = state.clone();
@ -236,10 +230,7 @@ fn test_have_cdp_notify() {
let mut h = gst_check::Harness::new("ccdetect"); let mut h = gst_check::Harness::new("ccdetect");
h.set_src_caps_str("closedcaption/x-cea-708,format=cdp"); h.set_src_caps_str("closedcaption/x-cea-708,format=cdp");
h.set_sink_caps_str("closedcaption/x-cea-708,format=cdp"); h.set_sink_caps_str("closedcaption/x-cea-708,format=cdp");
h.element() h.element().unwrap().set_property("window", 500_000_000u64);
.unwrap()
.set_property("window", 500_000_000u64)
.unwrap();
let state = Arc::new(Mutex::new(NotifyState::default())); let state = Arc::new(Mutex::new(NotifyState::default()));
let state_c = state.clone(); let state_c = state.clone();
@ -307,7 +298,7 @@ fn test_malformed_cdp_notify() {
let mut h = gst_check::Harness::new("ccdetect"); let mut h = gst_check::Harness::new("ccdetect");
h.set_src_caps_str("closedcaption/x-cea-708,format=cdp"); h.set_src_caps_str("closedcaption/x-cea-708,format=cdp");
h.set_sink_caps_str("closedcaption/x-cea-708,format=cdp"); h.set_sink_caps_str("closedcaption/x-cea-708,format=cdp");
h.element().unwrap().set_property("window", 0u64).unwrap(); h.element().unwrap().set_property("window", 0u64);
let state = Arc::new(Mutex::new(NotifyState::default())); let state = Arc::new(Mutex::new(NotifyState::default()));
let state_c = state.clone(); let state_c = state.clone();
@ -386,10 +377,7 @@ fn test_gap_events() {
let mut h = gst_check::Harness::new("ccdetect"); let mut h = gst_check::Harness::new("ccdetect");
h.set_src_caps_str("closedcaption/x-cea-708,format=cc_data"); h.set_src_caps_str("closedcaption/x-cea-708,format=cc_data");
h.set_sink_caps_str("closedcaption/x-cea-708,format=cc_data"); h.set_sink_caps_str("closedcaption/x-cea-708,format=cc_data");
h.element() h.element().unwrap().set_property("window", 500_000_000u64);
.unwrap()
.set_property("window", 500_000_000u64)
.unwrap();
let state = Arc::new(Mutex::new(NotifyState::default())); let state = Arc::new(Mutex::new(NotifyState::default()));
let state_c = state.clone(); let state_c = state.clone();

View file

@ -93,13 +93,11 @@ Time Code Rate=30DF\r\n\
let mut h = gst_check::Harness::new("mccenc"); let mut h = gst_check::Harness::new("mccenc");
{ {
let enc = h.element().expect("could not create encoder"); let enc = h.element().expect("could not create encoder");
enc.set_property("uuid", "14720C04-857D-40E2-86FC-F080DE44CE74") enc.set_property("uuid", "14720C04-857D-40E2-86FC-F080DE44CE74");
.unwrap();
enc.set_property( enc.set_property(
"creation-date", "creation-date",
glib::DateTime::new_utc(2018, 12, 27, 17, 34, 47.0).unwrap(), glib::DateTime::new_utc(2018, 12, 27, 17, 34, 47.0).unwrap(),
) );
.unwrap();
} }
h.set_src_caps_str( h.set_src_caps_str(

View file

@ -10,14 +10,10 @@ fn create_ui(app: &gtk::Application) {
let src = gst::ElementFactory::make("videotestsrc", None).unwrap(); let src = gst::ElementFactory::make("videotestsrc", None).unwrap();
let overlay = gst::ElementFactory::make("clockoverlay", None).unwrap(); let overlay = gst::ElementFactory::make("clockoverlay", None).unwrap();
overlay.set_property("font-desc", "Monospace 42").unwrap(); overlay.set_property("font-desc", "Monospace 42");
let sink = gst::ElementFactory::make("gtk4paintablesink", None).unwrap(); let sink = gst::ElementFactory::make("gtk4paintablesink", None).unwrap();
let paintable = sink let paintable = sink.property::<gdk::Paintable>("paintable");
.property("paintable")
.unwrap()
.get::<gdk::Paintable>()
.unwrap();
pipeline.add_many(&[&src, &overlay, &sink]).unwrap(); pipeline.add_many(&[&src, &overlay, &sink]).unwrap();
src.link_filtered( src.link_filtered(

View file

@ -121,7 +121,7 @@ fn test_encode(video_info: &gst_video::VideoInfo) {
let mut h = gst_check::Harness::new("rav1enc"); let mut h = gst_check::Harness::new("rav1enc");
{ {
let rav1enc = h.element().unwrap(); let rav1enc = h.element().unwrap();
rav1enc.set_property("speed-preset", 10u32).unwrap(); rav1enc.set_property("speed-preset", 10u32);
} }
h.play(); h.play();
h.set_src_caps(video_info.to_caps().unwrap()); h.set_src_caps(video_info.to_caps().unwrap());