Skip to content

RTSP Session Description Parser fails on extra newline #2357

Closed

Description

@dptsolutions

Version

Media3 1.6.1

More version details

No response

Devices that reproduce the issue

Using a Pixel 3 Emulator running API 34 image

Devices that do not reproduce the issue

No response

Reproducible in the demo app?

Not tested

Reproduction steps

  1. Attempt to connect to a BambuLab X1's RTSP stream over LAN.

Expected result

  1. It connects and Exoplayer goes to ready to play

Actual result

I get the following stacktrace, and player fails to play the stream:

androidx.media3.exoplayer.ExoPlaybackException: Source error
    at androidx.media3.exoplayer.ExoPlayerImplInternal.handleIoException(ExoPlayerImplInternal.java:864)
    at androidx.media3.exoplayer.ExoPlayerImplInternal.handleMessage(ExoPlayerImplInternal.java:840)
    at android.os.Handler.dispatchMessage(Handler.java:102)
    at android.os.Looper.loopOnce(Looper.java:205)
    at android.os.Looper.loop(Looper.java:294)
    at android.os.HandlerThread.run(HandlerThread.java:67)
Caused by: java.io.IOException: androidx.media3.common.ParserException: Malformed SDP line: i=Sun Apr 20 12:59:09 2025
    {contentIsMalformed=true, dataType=4}
    at androidx.media3.exoplayer.rtsp.RtspMediaPeriod$InternalListener.onSessionTimelineRequestFailed(RtspMediaPeriod.java:697)
    at androidx.media3.exoplayer.rtsp.RtspClient.dispatchRtspError(RtspClient.java:334)
    at androidx.media3.exoplayer.rtsp.RtspClient.access$700(RtspClient.java:76)
    at androidx.media3.exoplayer.rtsp.RtspClient$MessageListener.handleRtspResponse(RtspClient.java:698)
    at androidx.media3.exoplayer.rtsp.RtspClient$MessageListener.handleRtspMessage(RtspClient.java:531)
    at androidx.media3.exoplayer.rtsp.RtspClient$MessageListener.lambda$onRtspMessageReceived$0$androidx-media3-exoplayer-rtsp-RtspClient$MessageListener(RtspClient.java:524)
    at androidx.media3.exoplayer.rtsp.RtspClient$MessageListener$$ExternalSyntheticLambda0.run(D8$$SyntheticClass:0)
    at android.os.Handler.handleCallback(Handler.java:958)
    at android.os.Handler.dispatchMessage(Handler.java:99)
    ... 3 more
Caused by: androidx.media3.exoplayer.rtsp.RtspMediaSource$RtspPlaybackException: androidx.media3.common.ParserException: Malformed SDP line: i=Sun Apr 20 12:59:09 2025
    {contentIsMalformed=true, dataType=4}
    ... 9 more
Caused by: androidx.media3.common.ParserException: Malformed SDP line: i=Sun Apr 20 12:59:09 2025
    {contentIsMalformed=true, dataType=4}
    at androidx.media3.exoplayer.rtsp.SessionDescriptionParser.parse(SessionDescriptionParser.java:97)
    at androidx.media3.exoplayer.rtsp.RtspClient$MessageListener.handleRtspResponse(RtspClient.java:642)
    ... 8 more

Stepping through the debugger, it appears that BambuLab mangled the SDP spec, and inserted an extra \n character into the line, and this is causing SessionDescriptionParser.parse() to blow up when parsing the following line:

Image

I think a potential solution here is to strip whitespace from the end of the line before attempting to run the line through SDP_LINE_PATTERN? If when stepping through this loop I delete any errant \n characters from the line in the debugger before running it through the matcher, the parse completes successfully, and Exoplayer moves to the ready state.

Media

Can't really share this, it's locally available only. If the tester has a Bambu X1 printer, you can use the instructions to connect here.

Bug Report

Activity

  1. dptsolutions commented on Apr 21, 2025

    @dptsolutions
    Author

    FWIW - I confirmed on my end by cloning the repo and making my own local copy of the RTSP library, that adding the line

    line = line.strip();
    

    as the first line inside the for loop here fixes my problem

  2. changed the title [-]RTSP Session Description Parser fails on extra CRLF[/-] [+]RTSP Session Description Parser fails on extra newline[/+] on Apr 21, 2025
  3. self-assigned this
    on Apr 22, 2025
  4. microkatz commented on Apr 22, 2025

    @microkatz
    Contributor

    @dptsolutions

    I have submitted a fix for your issue into the main branch, d332845. Thank you for reporting your problem. Please re-open or create a new ticket if you have any additional issues.

  5. locked and limited conversation to collaborators on Jun 22, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Type

No type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions