Skip to content

Commit

Permalink
Merge remote-tracking branch 'upstream/master' into feat/optional-ses…
Browse files Browse the repository at this point in the history
…sion-name
  • Loading branch information
nemosupremo committed Aug 14, 2023
2 parents 2919f25 + 56b9454 commit f1a97a8
Show file tree
Hide file tree
Showing 2 changed files with 32 additions and 8 deletions.
4 changes: 4 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,10 @@ The format is based on [Keep a Changelog](http://keepachangelog.com/en/1.0.0/)
and this project adheres to [Semantic Versioning](http://semver.org/spec/v2.0.0.html),
specifically the [variant used by Rust](http://doc.crates.io/manifest.html#the-version-field).

## unreleased
### Changed
- Ignore unexpected SDP lines.

## [0.1.5] - 2022-10-28
### Changed
- Fix some clippy warnings.
Expand Down
36 changes: 28 additions & 8 deletions src/parser.rs
Original file line number Diff line number Diff line change
Expand Up @@ -368,8 +368,10 @@ impl Media {
) -> Result<Option<Media>, ParserError> {
let media = match lines.next()? {
None => return Ok(None),
Some(line) if line.key == b'm' => Media::parse_m_line(&line)?,
Some(line) => return Err(ParserError::UnexpectedLine(line.n, line.key)),
Some(line) => {
assert_eq!(line.key, b'm');
Media::parse_m_line(&line)?
}
};

// As with Session::parse, be more permissive about order than RFC 8866.
Expand Down Expand Up @@ -412,7 +414,7 @@ impl Media {
// - Can exist not at all, once or multiple times
b'a' => attributes.push(Attribute::parse(&line)?),

o => return Err(ParserError::UnexpectedLine(line.n, o)),
_ => (),
}
}

Expand Down Expand Up @@ -534,10 +536,9 @@ impl Session {
// Parse repeat lines
// - Can exist not at all, once or multiple times
b'r' => {
let t = times
.last_mut()
.ok_or(ParserError::UnexpectedLine(line.n, b't'))?;
t.repeats.push(Repeat::parse(&line)?);
if let Some(t) = times.last_mut() {
t.repeats.push(Repeat::parse(&line)?);
}
}

// Parse zones line:
Expand All @@ -562,7 +563,7 @@ impl Session {
// - Can exist not at all, once or multiple times
b'a' => attributes.push(Attribute::parse(&line)?),

o => return Err(ParserError::UnexpectedLine(line.n, o)),
_ => (),
}
}

Expand Down Expand Up @@ -951,6 +952,25 @@ a=control:track1\r
let _parsed = Session::parse(&sdp[..]).unwrap();
}

#[test]
fn parse_sdp_data_after_media() {
let sdp = b"v=0\r
o=- 1691154453 1 IN IP4 192.168.1.100\r
i=Pagos\r
a=type:broadcast\r
s=RandD2\r
m=video 15002 RTP/AVP 97\r
a=range:npt=0-\r
a=rtpmap:97 H264/90000\r
a=fmtp:97 profile-level-id=4D4029; packetization-mode=1; sprop-parameter-sets=Z01AKZZUBQHsgA==,aO44gA==\r
a=framerate:15.000\r
a=control:rtsp://192.168.1.20/camera1.sdp\r
c=IN IP4 0.0.0.0\r
t=0 0\r
";
let _parsed = Session::parse(&sdp[..]).unwrap();
}

#[test]
fn parse_sdp_without_session_name() {
let sdp = b"v=0\r
Expand Down

0 comments on commit f1a97a8

Please sign in to comment.