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.MediaDescription.getFmtpParametersAsMap failed and crashed. #9114

Closed
zhbhhh opened this issue Jun 25, 2021 · 5 comments
Closed

rtsp.MediaDescription.getFmtpParametersAsMap failed and crashed. #9114

zhbhhh opened this issue Jun 25, 2021 · 5 comments

Comments

@zhbhhh
Copy link

zhbhhh commented Jun 25, 2021

When I to play RTSP APP crashed

2021-06-25 14:46:52.448 6458-6565/com.rokid.rtspclient E/okid.rtspclien: [qarth_debug:]  get PatchStore::createDisableExceptionQarthFile method fail.
2021-06-25 14:46:52.451 6458-6565/com.rokid.rtspclient E/AndroidRuntime: FATAL EXCEPTION: ExoPlayer:Playback
    Process: com.rokid.rtspclient, PID: 6458
    java.lang.ArrayIndexOutOfBoundsException: length=1; index=1
        at com.google.android.exoplayer2.source.rtsp.MediaDescription.getFmtpParametersAsMap(MediaDescription.java:323)
        at com.google.android.exoplayer2.source.rtsp.RtspMediaTrack.generatePayloadFormat(RtspMediaTrack.java:120)
        at com.google.android.exoplayer2.source.rtsp.RtspMediaTrack.<init>(RtspMediaTrack.java:64)
        at com.google.android.exoplayer2.source.rtsp.RtspClient.buildTrackList(RtspClient.java:291)
        at com.google.android.exoplayer2.source.rtsp.RtspClient.access$1400(RtspClient.java:66)
        at com.google.android.exoplayer2.source.rtsp.RtspClient$MessageListener.onDescribeResponseReceived(RtspClient.java:553)
        at com.google.android.exoplayer2.source.rtsp.RtspClient$MessageListener.handleRtspMessage(RtspClient.java:473)
        at com.google.android.exoplayer2.source.rtsp.RtspClient$MessageListener.lambda$onRtspMessageReceived$0$RtspClient$MessageListener(RtspClient.java:420)
        at com.google.android.exoplayer2.source.rtsp.-$$Lambda$RtspClient$MessageListener$dJPB0r-FyeWq7xUwLx0FyxTnUk0.run(Unknown Source:4)
        at android.os.Handler.handleCallback(Handler.java:907)
        at android.os.Handler.dispatchMessage(Handler.java:105)
        at android.os.Looper.loop(Looper.java:216)
        at android.os.HandlerThread.run(HandlerThread.java:65)
@claincly
Copy link
Contributor

Please provide a log of RTSP messages.

Add logs at

and

private void handleRtspMessage(List<String> message) {

The easiest way is to use

Log.d("RTSP", message)

@claincly claincly changed the title How to play RTSP rtsp.MediaDescription.getFmtpParametersAsMap failed and crashed. Jun 25, 2021
@google-oss-bot
Copy link
Collaborator

Hey @zhbhhh. We need more information to resolve this issue but there hasn't been an update in 14 weekdays. I'm marking the issue as stale and if there are no new updates in the next 7 days I will close it automatically.

If you have more information that will help us get to the bottom of this, just add a comment!

@colinbarr
Copy link
Contributor

I've also come across the same exception as shown above, and (at least in my case) it appears to be related to RTSP implementations not strictly adhering to section 4.4.1 of RFC3640. I was attempting to stream from UniFi Protect, which looks to be running an embedded version of EvoStream Media Server.

From a packet capture, I can see that there's a trailing semicolon on the a=fmtp line as shown below:

a=fmtp:96 streamtype=5; profile-level-id=15; mode=AAC-hbr; config=1408; SizeLength=13; IndexLength=3; IndexDeltaLength=3;

... which then causes the following line to have an empty string as the last array element:

String[] parameters = Util.split(fmtpComponents[1], ";\\s?");

...which then means parameterPair is a single element array, resulting in an out of bounds exception when attempting to access [1]:

String[] parameterPair = Util.splitAtFirst(parameter, "=");
formatParametersBuilder.put(parameterPair[0], parameterPair[1]);

Although the following format definition does not indicate trailing semicolons are permitted, RFC5691 (section 4.1) does contain an example where a trailing delimiter is present, so there are likely other implementations where this is the case.

a=fmtp:<format> <parameter name>=<value>[; <parameter name>=<value>]

I'm happy to submit a PR for this to optionally handle a trailing ;, if it's acceptable to deviate slightly from the RFC?

@claincly
Copy link
Contributor

claincly commented Aug 2, 2021

Thanks for providing the detail!

Handling the extra semicolon seems straightforward in this case. For now I don't think we have the intention for support all slightly erroneous RTSP servers. That said, please submit a PR if there are more people complaining about this specific issue.

@colinbarr
Copy link
Contributor

Thanks @claincly, I've submitted #9247!

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

No branches or pull requests

4 participants