Skip to content

Allow single space session name in RTSP Session Description - #3585

Open
kafeijao wants to merge 1 commit into
androidx:mainfrom
kafeijao:fix/rtsp-sdp-single-space-session-name
Open

kafeijao wants to merge 1 commit into
androidx:mainfrom
kafeijao:fix/rtsp-sdp-single-space-session-name

Conversation

@kafeijao

Copy link
Copy Markdown

Description

The SDP parser rejects s= (a single space) as the session name and fails with Malformed SDP line: s=. RFC 4566 and RFC 8866 section 5.3 recommend that value when a session has no name. Servers built on gortsplib, such as MediaMTX, send it for streams without a title. The same streams play in VLC.

Caused by: androidx.media3.exoplayer.rtsp.RtspMediaSource$RtspPlaybackException:
  androidx.media3.common.ParserException: Malformed SDP line: s= {contentIsMalformed=true, dataType=4}
  at androidx.media3.exoplayer.rtsp.SessionDescriptionParser.parse(SessionDescriptionParser.java:99)
  at androidx.media3.exoplayer.rtsp.RtspClient$MessageListener.handleRtspResponse(RtspClient.java:644)

Why it fails:

  1. parse() trims each line, so s= becomes s=.
  2. s= doesn't match SDP_LINE_PATTERN, which needs at least one character after =.
  3. The empty-value fallback added for RTSP streaming error: Malformed SDP line: i={contentIsMalformed=true, dataType=4} #1087 only accepts i=. Every other type throws.

This change checks the line before trimming. If it was s= , the parser stores " " as the session name. A truly empty s= still throws because the RFC says the field MUST NOT be empty, so parse_sdpStringWithEmptySessionAttribute_throwsParserException is unchanged. The trim stays because #2357
depends on it.

Spec:

  • RFC 4566, section 5.3: "If a session has no meaningful name, the value "s= " SHOULD be used (i.e., a single space as the session name)."
  • RFC 8866, section 5.3: "If a session has no meaningful name, then "s= " or "s=-" (i.e., a single space or dash as the session name) is RECOMMENDED."

Where s= comes from

gortsplib, the RTSP library behind MediaMTX, sends a single space when the stream has no title (link).

Testing:

  • Added parse_sdpStringWithSingleSpaceSessionName_succeeds.
  • SessionDescriptionParserTest passes on a Quest 3 (Android 14).
  • Played a live MediaMTX stream with the patched module. The error is gone

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants