webrtcsink: prevent video-info error log for audio streams

The following error is logged when `webrtcsink` is feeded with an audio stream:

> ERROR video-info video-info.c:540:gst_video_info_from_caps:
>       wrong name 'audio/x-raw', expected video/ or image/

This commit bypasses `VideoInfo::from_caps` for audio streams.

Part-of: <https://gitlab.freedesktop.org/gstreamer/gst-plugins-rs/-/merge_requests/1508>
This commit is contained in:
François Laignel 2024-03-20 19:53:35 +01:00 committed by Sebastian Dröge
parent 158fe80779
commit ede354d7a5

View file

@ -3537,6 +3537,7 @@ impl BaseWebRTCSink {
} }
}); });
if e.caps().structure(0).unwrap().name().starts_with("video/") {
if let Ok(video_info) = gst_video::VideoInfo::from_caps(e.caps()) { if let Ok(video_info) = gst_video::VideoInfo::from_caps(e.caps()) {
// update video encoder info used when downscaling/downsampling the input // update video encoder info used when downscaling/downsampling the input
let stream_name = pad.name().to_string(); let stream_name = pad.name().to_string();
@ -3547,11 +3548,13 @@ impl BaseWebRTCSink {
.flat_map(|session| session.unwrap_mut().encoders.iter_mut()) .flat_map(|session| session.unwrap_mut().encoders.iter_mut())
.filter(|encoder| encoder.stream_name == stream_name) .filter(|encoder| encoder.stream_name == stream_name)
.for_each(|encoder| { .for_each(|encoder| {
encoder.halved_framerate = video_info.fps().mul(gst::Fraction::new(1, 2)); encoder.halved_framerate =
video_info.fps().mul(gst::Fraction::new(1, 2));
encoder.video_info = video_info.clone(); encoder.video_info = video_info.clone();
}); });
} }
} }
}
gst::Pad::event_default(pad, Some(element), event) gst::Pad::event_default(pad, Some(element), event)
} }