Skip to content

Commit

Permalink
prep v0.4.7: don't require DESCRIBE Content-Type
Browse files Browse the repository at this point in the history
  • Loading branch information
scottlamb committed Jan 9, 2024
1 parent 77265a4 commit acd8fc4
Show file tree
Hide file tree
Showing 4 changed files with 53 additions and 8 deletions.
4 changes: 4 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,7 @@
## `v0.4.7` (2024-01-08)

* support servers that do not set `Content-Type` on `DESCRIBE` responses

## `v0.4.6` (2023-12-29)

* add default User-Agent header
Expand Down
2 changes: 1 addition & 1 deletion Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ default-members = ["."]

[package]
name = "retina"
version = "0.4.6"
version = "0.4.7"
authors = ["Scott Lamb <[email protected]>"]
license = "MIT/Apache-2.0"
edition = "2021"
Expand Down
35 changes: 28 additions & 7 deletions src/client/parse.rs
Original file line number Diff line number Diff line change
Expand Up @@ -410,14 +410,25 @@ pub(crate) fn parse_describe(
request_url: Url,
response: &rtsp_types::Response<Bytes>,
) -> Result<Presentation, String> {
if !matches!(response.header(&rtsp_types::headers::CONTENT_TYPE), Some(v) if v.as_str() == "application/sdp")
{
return Err(format!(
"Describe response not of expected application/sdp content type: {:#?}",
&response
));
match response.header(&rtsp_types::headers::CONTENT_TYPE) {
Some(v) if v.as_str() == "application/sdp" => {}
Some(v) => {
let mut buf = vec![];
response.write(&mut buf).map_err(|e| e.to_string())?;
return Err(format!(
"DESCRIBE response at {} has unexpected content type {}:\n{:?}",
request_url.as_str(),
v,
MostlyAscii(&buf)
));
}
None => {
warn!(
"DESCRIBE response at {} has no content type; trying sdp anyway",
request_url.as_str()
);
}
}

let raw_sdp = MostlyAscii(&response.body()[..]);
let sdp = sdp_types::Session::parse(raw_sdp.0)
.map_err(|e| format!("Unable to parse SDP: {e}\n\n{raw_sdp:#?}",))?;
Expand Down Expand Up @@ -1179,6 +1190,16 @@ mod tests {
};
}

#[test]
fn missing_contenttype_describe() {
let prefix = "rtsp://192.168.1.101/live/test";
parse_describe(
prefix,
include_bytes!("testdata/missing_content_type_describe.txt"),
)
.unwrap();
}

/// 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).
///
Expand Down
20 changes: 20 additions & 0 deletions src/client/testdata/missing_content_type_describe.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
RTSP/1.0 200 OK
CSeq: 1
Content-Length: 494
Session: l0TtlUFSR

v=0
o=- 0 0 IN IP4 127.0.0.1
s=No Name
c=IN IP4 192.168.1.101
t=0 0
a=tool:libavformat 58.25.100
m=video 0 RTP/AVP 96
a=rtpmap:96 H264/90000
a=fmtp:96 packetization-mode=1; sprop-parameter-sets=Z2QADazZQUGfnwEQAAADABAAAAMDwPFCmWA=,aOvjyyLA; profile-level-id=64000D
a=control:streamid=0
m=audio 0 RTP/AVP 97
b=AS:128
a=rtpmap:97 MPEG4-GENERIC/48000/2
a=fmtp:97 profile-level-id=1;mode=AAC-hbr;sizelength=13;indexlength=3;indexdeltalength=3; config=119056E500
a=control:streamid=1

0 comments on commit acd8fc4

Please sign in to comment.