Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

RTSP sdp parsing exception #1472

Closed
1 task
hibate opened this issue Jun 19, 2024 · 2 comments
Closed
1 task

RTSP sdp parsing exception #1472

hibate opened this issue Jun 19, 2024 · 2 comments
Assignees

Comments

@hibate
Copy link

hibate commented Jun 19, 2024

Version

Media3 1.3.1

More version details

The TP-LINK network camera, when using rtsp connection, there is an exception in parsing sdp. Through breakpoint tracking, the complete sdp data is as follows:

v=0
o=- 14665860 31787219 1 IN IP4 192.168.1.100
s=Session streamed by "TP-LINK RTSP Server"
t=0 0
m=video 0 RTP/AVP 96
c=IN IP4 0.0.0.0
b=AS:4096
a=range:npt=0-
a=control:track1
a=rtpmap:96 H264/90000
a=fmtp:96 packetization-mode=1; profile-level-id=640016; sprop-parameter-sets=Z2QAFqzGoCgPaEAAAAMAQAAAB6E=,aOqPLA==
m=audio 0 RTP/AVP 8
a=rtpmap:8 PCMA/8000
a=control:track2
m=application/TP-LINK 0 RTP/AVP smart/1/90000
a=rtpmap:95 TP-LINK/90000
a=control:track3

An error occurred when parsing the following media description, which does not comply with the rules of RFC 8866 Section 5.14:

m=application/TP-LINK 0 RTP/AVP smart/1/90000

FFmpeg ignored this part when parsing because the media type application/TP-LINK is not one of the media types allowed by FFmpeg: video, audio, application, text

SessionDescriptionParser did not ignore the above situation when parsing

Devices that reproduce the issue

All devices

Devices that do not reproduce the issue

None

Reproducible in the demo app?

Not tested

Reproduction steps

  • Using TP-LINK network camera
  • Create a player
  • Set media item with rtsp uri
  • Play

Expected result

Media playback successful

Actual result

Playback error
  androidx.media3.exoplayer.ExoPlaybackException: Source error
      at androidx.media3.exoplayer.ExoPlayerImplInternal.handleIoException(ExoPlayerImplInternal.java:717)
      at androidx.media3.exoplayer.ExoPlayerImplInternal.handleMessage(ExoPlayerImplInternal.java:693)
      at android.os.Handler.dispatchMessage(Handler.java:102)
      at android.os.Looper.loopOnce(Looper.java:201)
      at android.os.Looper.loop(Looper.java:288)
      at android.os.HandlerThread.run(HandlerThread.java:67)
  Caused by: java.io.IOException: androidx.media3.common.ParserException: Malformed SDP media description line: application/TP-LINK 0 RTP/AVP smart/1/90000{contentIsMalformed=true, dataType=4}
      at androidx.media3.exoplayer.rtsp.RtspMediaPeriod$InternalListener.onSessionTimelineRequestFailed(RtspMediaPeriod.java:699)
      at androidx.media3.exoplayer.rtsp.RtspClient.dispatchRtspError(RtspClient.java:336)
      at androidx.media3.exoplayer.rtsp.RtspClient.-$$Nest$mdispatchRtspError(Unknown Source:0)
      at androidx.media3.exoplayer.rtsp.RtspClient$MessageListener.handleRtspResponse(RtspClient.java:696)
      at androidx.media3.exoplayer.rtsp.RtspClient$MessageListener.handleRtspMessage(RtspClient.java:529)
      at androidx.media3.exoplayer.rtsp.RtspClient$MessageListener.lambda$onRtspMessageReceived$0(RtspClient.java:522)
      at androidx.media3.exoplayer.rtsp.RtspClient$MessageListener.$r8$lambda$8deRm6rk5jv7dwvT8Gw1eQhwNr8(Unknown Source:0)
      at androidx.media3.exoplayer.rtsp.RtspClient$MessageListener$$ExternalSyntheticLambda0.run(D8$$SyntheticClass:0)
      at android.os.Handler.handleCallback(Handler.java:942)
      at android.os.Handler.dispatchMessage(Handler.java:99)
      at android.os.Looper.loopOnce(Looper.java:201)
      at android.os.Looper.loop(Looper.java:288)
      at android.os.HandlerThread.run(HandlerThread.java:67)
  Caused by: androidx.media3.exoplayer.rtsp.RtspMediaSource$RtspPlaybackException: androidx.media3.common.ParserException: Malformed SDP media description line: application/TP-LINK 0 RTP/AVP smart/1/90000{contentIsMalformed=true, dataType=4}
      at androidx.media3.exoplayer.rtsp.RtspClient$MessageListener.handleRtspResponse(RtspClient.java:696)
      at androidx.media3.exoplayer.rtsp.RtspClient$MessageListener.handleRtspMessage(RtspClient.java:529)
      at androidx.media3.exoplayer.rtsp.RtspClient$MessageListener.lambda$onRtspMessageReceived$0(RtspClient.java:522)
      at androidx.media3.exoplayer.rtsp.RtspClient$MessageListener.$r8$lambda$8deRm6rk5jv7dwvT8Gw1eQhwNr8(Unknown Source:0)
      at androidx.media3.exoplayer.rtsp.RtspClient$MessageListener$$ExternalSyntheticLambda0.run(D8$$SyntheticClass:0)
      at android.os.Handler.handleCallback(Handler.java:942)
      at android.os.Handler.dispatchMessage(Handler.java:99)
      at android.os.Looper.loopOnce(Looper.java:201)
      at android.os.Looper.loop(Looper.java:288)
      at android.os.HandlerThread.run(HandlerThread.java:67)
  Caused by: androidx.media3.common.ParserException: Malformed SDP media description line: application/TP-LINK 0 RTP/AVP smart/1/90000{contentIsMalformed=true, dataType=4}
      at androidx.media3.exoplayer.rtsp.SessionDescriptionParser.parseMediaDescriptionLine(SessionDescriptionParser.java:250)
      at androidx.media3.exoplayer.rtsp.SessionDescriptionParser.parse(SessionDescriptionParser.java:195)
      at androidx.media3.exoplayer.rtsp.RtspClient$MessageListener.handleRtspResponse(RtspClient.java:640)
      at androidx.media3.exoplayer.rtsp.RtspClient$MessageListener.handleRtspMessage(RtspClient.java:529)
      at androidx.media3.exoplayer.rtsp.RtspClient$MessageListener.lambda$onRtspMessageReceived$0(RtspClient.java:522)
      at androidx.media3.exoplayer.rtsp.RtspClient$MessageListener.$r8$lambda$8deRm6rk5jv7dwvT8Gw1eQhwNr8(Unknown Source:0)
      at androidx.media3.exoplayer.rtsp.RtspClient$MessageListener$$ExternalSyntheticLambda0.run(D8$$SyntheticClass:0)
      at android.os.Handler.handleCallback(Handler.java:942)
      at android.os.Handler.dispatchMessage(Handler.java:99)
      at android.os.Looper.loopOnce(Looper.java:201)
      at android.os.Looper.loop(Looper.java:288)
      at android.os.HandlerThread.run(HandlerThread.java:67)
  Caused by: java.lang.NumberFormatException: For input string: "smart/1/90000"
      at java.lang.Integer.parseInt(Integer.java:747)
      at java.lang.Integer.parseInt(Integer.java:865)
      at androidx.media3.exoplayer.rtsp.SessionDescriptionParser.parseMediaDescriptionLine(SessionDescriptionParser.java:248)
      at androidx.media3.exoplayer.rtsp.SessionDescriptionParser.parse(SessionDescriptionParser.java:195)
      at androidx.media3.exoplayer.rtsp.RtspClient$MessageListener.handleRtspResponse(RtspClient.java:640)
      at androidx.media3.exoplayer.rtsp.RtspClient$MessageListener.handleRtspMessage(RtspClient.java:529)
      at androidx.media3.exoplayer.rtsp.RtspClient$MessageListener.lambda$onRtspMessageReceived$0(RtspClient.java:522)
      at androidx.media3.exoplayer.rtsp.RtspClient$MessageListener.$r8$lambda$8deRm6rk5jv7dwvT8Gw1eQhwNr8(Unknown Source:0)
      at androidx.media3.exoplayer.rtsp.RtspClient$MessageListener$$ExternalSyntheticLambda0.run(D8$$SyntheticClass:0)
      at android.os.Handler.handleCallback(Handler.java:942)
      at android.os.Handler.dispatchMessage(Handler.java:99)
      at android.os.Looper.loopOnce(Looper.java:201)
      at android.os.Looper.loop(Looper.java:288)
      at android.os.HandlerThread.run(HandlerThread.java:67)

Media

Not applicable

Bug Report

@microkatz
Copy link
Contributor

@hibate

Apologies for the delay.

Actually, the SessionDescriptionParser is not choking on the application/TP-LINK value but on that the format type in accordance with RFC 8866 Section 5.14 are not numbers. According to 5.14, "If the subfield is "RTP/AVP" or "RTP/SAVP", the subfields contain RTP payload type numbers". The subfield of that media description is "smart/1/90000" which is not a number.

I am working on submitting some code that will ignore your custom TP-Link track. I will update this bug when it has been submitted so you can test.

copybara-service bot pushed a commit that referenced this issue Aug 8, 2024
Some RTSP servers may provide media descriptions for custom streams that are not supported. ExoPlayer should skip the invalid media description and continues parsing the following media descriptions.

To start, ExoPlayer will still error on malformed SDP lines for media descriptions, but will now skip media descriptions with "non-parsable" formats as described by [RFC 8866 Section 5.14](https://datatracker.ietf.org/doc/html/rfc8866#section-5.14).

Issue: #1472
PiperOrigin-RevId: 660826116
@hibate
Copy link
Author

hibate commented Aug 21, 2024

@microkatz

Thanks for your submission! After testing, it works fine.

@hibate hibate closed this as completed Aug 21, 2024
tianyif pushed a commit that referenced this issue Aug 22, 2024
Some RTSP servers may provide media descriptions for custom streams that are not supported. ExoPlayer should skip the invalid media description and continues parsing the following media descriptions.

To start, ExoPlayer will still error on malformed SDP lines for media descriptions, but will now skip media descriptions with "non-parsable" formats as described by [RFC 8866 Section 5.14](https://datatracker.ietf.org/doc/html/rfc8866#section-5.14).

Issue: #1472
PiperOrigin-RevId: 660826116
(cherry picked from commit 8b33ad5)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

3 participants