Merge branch 'main' into next

This commit is contained in:
Scott Lamb 2022-05-10 16:52:58 -07:00
commit 6bc3b004a4
3 changed files with 46 additions and 6 deletions

View File

@ -24,6 +24,12 @@
Likewise `retina::codec::CodecItem`. Likewise `retina::codec::CodecItem`.
* minimum Rust version is now 1.56. * minimum Rust version is now 1.56.
## `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

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;
@ -646,11 +646,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))?;
@ -1068,6 +1067,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 = dummy_stream_state_init(None);
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