ignore unparseable rtptime values

https://github.com/scottlamb/moonfire-nvr/issues/224
This commit is contained in:
Scott Lamb 2022-05-09 12:56:03 -07:00
parent 1ea14cbfaf
commit 2530014cce
5 changed files with 48 additions and 8 deletions

View File

@ -1,3 +1,9 @@
## `v0.3.10` (2022-05-09)
* ignore unparseable `rtptime` values in the `PLAY` response's `RTP-Info` header.
This improves compatibility with the OMNY M5S2A 2812 camera, as described in
[scottlamb/moonfire-nvr#224](https://github.com/scottlamb/moonfire-nvr/issues/224).
## `v0.3.9` (2022-04-12) ## `v0.3.9` (2022-04-12)
* camera interop: eliminate `bad clockrate in rtpmap` errors with cameras that * camera interop: eliminate `bad clockrate in rtpmap` errors with cameras that

2
Cargo.lock generated
View File

@ -910,7 +910,7 @@ checksum = "f497285884f3fcff424ffc933e56d7cbca511def0c9831a7f9b5f6153e3cc89b"
[[package]] [[package]]
name = "retina" name = "retina"
version = "0.3.9" version = "0.3.10"
dependencies = [ dependencies = [
"anyhow", "anyhow",
"base64", "base64",

View File

@ -1,6 +1,6 @@
[package] [package]
name = "retina" name = "retina"
version = "0.3.9" version = "0.3.10"
authors = ["Scott Lamb <slamb@slamb.org>"] authors = ["Scott Lamb <slamb@slamb.org>"]
license = "MIT/Apache-2.0" license = "MIT/Apache-2.0"
edition = "2018" edition = "2018"

View File

@ -2,7 +2,7 @@
// SPDX-License-Identifier: MIT OR Apache-2.0 // SPDX-License-Identifier: MIT OR Apache-2.0
use bytes::Bytes; use bytes::Bytes;
use log::debug; use log::{debug, warn};
use sdp_types::Media; use sdp_types::Media;
use std::{net::IpAddr, num::NonZeroU16}; use std::{net::IpAddr, num::NonZeroU16};
use url::Url; use url::Url;
@ -640,11 +640,10 @@ pub(crate) fn parse_play(
.map_err(|_| format!("bad seq {:?}", value))?; .map_err(|_| format!("bad seq {:?}", value))?;
state.initial_seq = Some(seq); state.initial_seq = Some(seq);
} }
"rtptime" => { "rtptime" => match u32::from_str_radix(value, 10) {
let rtptime = u32::from_str_radix(value, 10) Ok(v) => state.initial_rtptime = Some(v),
.map_err(|_| format!("bad rtptime {:?}", value))?; Err(_) => warn!("Unparseable rtptime in RTP-Info header {:?}", rtp_info),
state.initial_rtptime = Some(rtptime); },
}
"ssrc" => { "ssrc" => {
let ssrc = u32::from_str_radix(value, 16) let ssrc = u32::from_str_radix(value, 16)
.map_err(|_| format!("Unparseable ssrc {}", value))?; .map_err(|_| format!("Unparseable ssrc {}", value))?;
@ -1063,6 +1062,32 @@ mod tests {
}; };
} }
/// Simulates a negative `rtptime` value in the `PLAY` response, as returned by the OMNY M5S2A
/// 2812 in [scottlamb/moonfire-nvr#224](https://github.com/scottlamb/moonfire-nvr/issues/224).
///
/// The rest of the data is copied from the `bunny` test above.
///
/// This is currently treated as if the `rtptime` parameter were absent.
#[test]
fn bad_rtptime() {
let prefix = "rtsp://wowzaec2demo.streamlock.net/vod/mp4:BigBuckBunny_115k.mov";
let mut p = parse_describe(prefix, include_bytes!("testdata/bunny_describe.txt")).unwrap();
p.streams[0].state = StreamState::Init(StreamStateInit::default());
super::parse_play(
&response(include_bytes!("testdata/bad_rtptime.txt")),
&mut p,
)
.unwrap();
match p.streams[0].state {
StreamState::Init(state) => {
assert_eq!(state.initial_rtptime, None);
assert_eq!(state.initial_seq, Some(1));
assert_eq!(state.ssrc, None);
}
_ => panic!(),
};
}
#[test] #[test]
fn foscam() { fn foscam() {
// DESCRIBE. // DESCRIBE.

9
src/client/testdata/bad_rtptime.txt vendored Normal file
View File

@ -0,0 +1,9 @@
RTSP/1.0 200 OK
Notes: copied from bunny_play.txt; modified to simulate a bad rtptime value as in https://github.com/scottlamb/moonfire-nvr/issues/224
RTP-Info: url=trackID=1;seq=1;rtptime=-1,url=rtsp://wowzaec2demo.streamlock.net/vod/mp4:BigBuckBunny_115k.mov/trackID=2;seq=1;rtptime=-1
CSeq: 3
Server: Wowza Streaming Engine 4.8.10 build20210217143515
Cache-Control: no-cache
Range: npt=0.0-596.48
Session: 551045787;timeout=60