Do not check for video codec by checking SDP video parameters

Since retina now supports in-band parameters, we should only check the media type for this.
This commit is contained in:
Greg V 2022-01-23 22:58:56 +03:00 committed by Scott Lamb
parent b6a1670b92
commit 64142b7684

View File

@ -411,9 +411,18 @@ impl RetinaOpener {
.streams() .streams()
.iter() .iter()
.enumerate() .enumerate()
.find_map(|(i, s)| match s.parameters() { .find_map(|(i, s)| {
Some(retina::codec::Parameters::Video(v)) => Some((i, Box::new(v.clone()))), if s.media == "video" && s.encoding_name == "h264" {
Some((
i,
s.parameters().and_then(|p| match p {
retina::codec::Parameters::Video(v) => Some(Box::new(v.clone())),
_ => None, _ => None,
}),
))
} else {
None
}
}) })
.ok_or_else(|| format_err!("couldn't find H.264 video stream"))?; .ok_or_else(|| format_err!("couldn't find H.264 video stream"))?;
session.setup(video_i).await?; session.setup(video_i).await?;
@ -427,7 +436,7 @@ impl RetinaOpener {
Some(Err(e)) => return Err(e.into()), Some(Err(e)) => return Err(e.into()),
Some(Ok(CodecItem::VideoFrame(mut v))) => { Some(Ok(CodecItem::VideoFrame(mut v))) => {
if let Some(v) = v.new_parameters.take() { if let Some(v) = v.new_parameters.take() {
video_params = v; video_params = Some(v);
} }
if v.is_random_access_point { if v.is_random_access_point {
break v; break v;
@ -436,7 +445,11 @@ impl RetinaOpener {
Some(Ok(_)) => {} Some(Ok(_)) => {}
} }
}; };
Ok((session, video_params, first_frame)) Ok((
session,
video_params.ok_or_else(|| format_err!("couldn't find H.264 parameters"))?,
first_frame,
))
} }
} }