Update for gst::Array / gst::List API improvements

Part-of: <https://gitlab.freedesktop.org/gstreamer/gst-plugins-rs/-/merge_requests/985>
This commit is contained in:
Sebastian Dröge 2022-11-27 01:12:46 +02:00
parent 0e2a00cbc8
commit fceacf7081
6 changed files with 20 additions and 19 deletions

View file

@ -538,10 +538,10 @@ impl BaseTransformImpl for EbuR128Level {
if state.ebur128.mode().contains(ebur128::Mode::SAMPLE_PEAK) {
let peaks = (0..state.info.channels())
.map(|c| state.ebur128.sample_peak(c).map(|p| p.to_send_value()))
.collect::<Result<Vec<_>, _>>();
.collect::<Result<gst::Array, _>>();
match peaks {
Ok(peaks) => s.set("sample-peak", gst::Array::from(peaks)),
Ok(peaks) => s.set("sample-peak", peaks),
Err(err) => {
gst::error!(CAT, imp: self, "Failed to get sample peaks: {}", err)
}
@ -551,10 +551,10 @@ impl BaseTransformImpl for EbuR128Level {
if state.ebur128.mode().contains(ebur128::Mode::TRUE_PEAK) {
let peaks = (0..state.info.channels())
.map(|c| state.ebur128.true_peak(c).map(|p| p.to_send_value()))
.collect::<Result<Vec<_>, _>>();
.collect::<Result<gst::Array, _>>();
match peaks {
Ok(peaks) => s.set("true-peak", gst::Array::from(peaks)),
Ok(peaks) => s.set("true-peak", peaks),
Err(err) => {
gst::error!(CAT, imp: self, "Failed to get true peaks: {}", err)
}

View file

@ -514,15 +514,15 @@ impl ObjectImpl for HrtfRender {
}
"spatial-objects" => {
let settings = self.settings.lock().unwrap();
let spatial_objects = settings
settings
.spatial_objects
.as_ref()
.unwrap_or(&Vec::new())
.iter()
.map(|x| gst::Structure::from(*x).to_send_value())
.collect::<Vec<_>>();
gst::Array::from(spatial_objects).to_value()
.collect::<gst::Array>()
.to_value()
}
_ => unimplemented!(),
}

View file

@ -217,9 +217,11 @@ impl AudioTestSrcTask {
self.channels = s.get::<i32>("channels").unwrap() as usize;
if self.channels > 2 {
s.set::<gst::Bitmask>(
s.set(
"channel-mask",
gst_audio::AudioChannelPosition::fallback_mask(self.channels as u32).into(),
gst::Bitmask::from(gst_audio::AudioChannelPosition::fallback_mask(
self.channels as u32,
)),
);
}
}

View file

@ -806,15 +806,15 @@ impl Session {
fn gather_stats(&self) -> gst::Structure {
let mut ret = self.stats.to_owned();
let encoder_stats: Vec<_> = self
let encoder_stats = self
.encoders
.iter()
.map(VideoEncoder::gather_stats)
.map(|s| s.to_send_value())
.collect();
.collect::<gst::Array>();
let our_stats = gst::Structure::builder("application/x-webrtcsink-consumer-stats")
.field("video-encoders", gst::Array::from(encoder_stats))
.field("video-encoders", encoder_stats)
.build();
ret.set("consumer-stats", our_stats);

View file

@ -235,21 +235,20 @@ impl ObjectImpl for RegEx {
match pspec.name() {
"commands" => {
let state = self.state.lock().unwrap();
let mut commands = vec![];
let mut commands = gst::Array::default();
for command in &state.commands {
match command.operation {
Operation::ReplaceAll(ref replacement) => {
commands.push(
commands.append(
gst::Structure::builder("replace-all")
.field("pattern", &command.pattern)
.field("replacement", replacement)
.build()
.to_send_value(),
.build(),
);
}
}
}
gst::Array::from(commands).to_value()
commands.to_value()
}
_ => unimplemented!(),
}

View file

@ -36,7 +36,7 @@ fn test_replace_all() {
.field("replacement", "trap")
.build();
let commands = gst::Array::from(vec![command.to_send_value()]);
let commands = gst::Array::new([command]);
regex.set_property("commands", &commands);
}