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)
* camera interop: eliminate `bad clockrate in rtpmap` errors with cameras that

2
Cargo.lock generated
View File

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

View File

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

View File

@ -2,7 +2,7 @@
// SPDX-License-Identifier: MIT OR Apache-2.0
use bytes::Bytes;
use log::debug;
use log::{debug, warn};
use sdp_types::Media;
use std::{net::IpAddr, num::NonZeroU16};
use url::Url;
@ -640,11 +640,10 @@ pub(crate) fn parse_play(
.map_err(|_| format!("bad seq {:?}", value))?;
state.initial_seq = Some(seq);
}
"rtptime" => {
let rtptime = u32::from_str_radix(value, 10)
.map_err(|_| format!("bad rtptime {:?}", value))?;
state.initial_rtptime = Some(rtptime);
}
"rtptime" => match u32::from_str_radix(value, 10) {
Ok(v) => state.initial_rtptime = Some(v),
Err(_) => warn!("Unparseable rtptime in RTP-Info header {:?}", rtp_info),
},
"ssrc" => {
let ssrc = u32::from_str_radix(value, 16)
.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]
fn foscam() {
// 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