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

SDP Mime Types are not case-insensitive #35

Closed
asleeponduty opened this issue May 12, 2021 · 4 comments
Closed

SDP Mime Types are not case-insensitive #35

asleeponduty opened this issue May 12, 2021 · 4 comments
Labels
bug Something isn't working

Comments

@asleeponduty
Copy link

Per findings in RenderHeads/UnityPlugin-AVProVideo#653 , the MIME type in an SDP is not treated as case-insensitive.
Some implementations, such as Media Foundation, have issues with this.
In particular, the "mpeg4-generic" MIME must be lowercase

See here:
https://github.com/aler9/gortsplib/blob/8be64d9cf6ddeee1ec0560ad467724770de928c0/track.go#L152

https://github.com/aler9/gortsplib/blob/8be64d9cf6ddeee1ec0560ad467724770de928c0/track.go#L185

And in your test script
https://github.com/aler9/gortsplib/blob/bd1b88226edb8b088996c522a80b96068d5570ee/track_test.go#L493

https://github.com/aler9/gortsplib/blob/bd1b88226edb8b088996c522a80b96068d5570ee/track_test.go#L522

@asleeponduty
Copy link
Author

Please note, the original comment does not handle RTSP streams that have been relayed:
The SDP produced by FFMPEG generating an RTSP stream also does not conform to this loose standard for compatibility with Media Foundation.
As a dirty workaround, I edited the unmarshalMediaAttribute function to check for the presence of an all-caps "MPEG4", and convert it to lowercase.
https://github.com/aler9/gortsplib/blob/49dfd34ede588c38cb6724e68750400e5d2a8d9d/pkg/sdp/sdp.go#L471

In this case, I added it to be the first thing this function checks for.

        if strings.Contains(value, "MPEG4") {
                value = strings.ToLower(value)
        }

Admittedly, this is not the true solution to this problem. If anything, this should be raised to the FFMPEG developers, or whichever library they currently use that is responsible for this.

My only exposure to Go at this point has been through your library; I'd love to make a PR to fix this but I don't quite have the understanding needed to make sure it passes coverage correctly.

Where this leaves us

That being said - The information mentioned in the opening comment allows a Windows Media Foundation software (AVPRO in Unity) to correctly decode audio in RTSP streams generated by this library. This happens whenever a server using this would ingest a stream of another format, such as RTMP.

The changes noted in this comment allow successful relay of an RTSP stream to the same Media Foundation program, correcting an irregularity in a common stream producer.

I'd like to hear your thoughts on this - is "Garbage In, Garbage Out" acceptable, or should there be effort to help with compatibility?

@aler9
Copy link
Member

aler9 commented May 13, 2021

Hello, since the specification always mentions mpeg4-generic in lowercase, the library must be changed accordingly.

Please note that this solves the issue only for RTSP streams that have been generated from the ground, for instance RTMP / HLS streams that are converted into RTSP inside rtsp-simple-server, or GStreamer RTP streams that are used in the client-publish example.

Regarding relayed RTSP streams, at the moment their SDP is left untouched in rtsp-simple-server, and the best solution consists in editing the software that generates them, but i'm evaluating the possibility of inserting a filter inside the server to fix erroneous SDPs.

@aler9
Copy link
Member

aler9 commented May 13, 2021

Anyway, this issue doesn't concern gortsplib anymore (it's now a rtsp-simple-server enhancement).

@aler9 aler9 closed this as completed May 13, 2021
@github-actions
Copy link

This issue is being locked automatically because it has been closed for more than 6 months.
Please open a new issue in case you encounter a similar problem.

@github-actions github-actions bot locked and limited conversation to collaborators Dec 31, 2022
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

2 participants