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

View file

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

View file

@ -217,9 +217,11 @@ impl AudioTestSrcTask {
self.channels = s.get::<i32>("channels").unwrap() as usize; self.channels = s.get::<i32>("channels").unwrap() as usize;
if self.channels > 2 { if self.channels > 2 {
s.set::<gst::Bitmask>( s.set(
"channel-mask", "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 { fn gather_stats(&self) -> gst::Structure {
let mut ret = self.stats.to_owned(); let mut ret = self.stats.to_owned();
let encoder_stats: Vec<_> = self let encoder_stats = self
.encoders .encoders
.iter() .iter()
.map(VideoEncoder::gather_stats) .map(VideoEncoder::gather_stats)
.map(|s| s.to_send_value()) .map(|s| s.to_send_value())
.collect(); .collect::<gst::Array>();
let our_stats = gst::Structure::builder("application/x-webrtcsink-consumer-stats") 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(); .build();
ret.set("consumer-stats", our_stats); ret.set("consumer-stats", our_stats);

View file

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

View file

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