pedroSG94 / RootEncoder-iOS

RootEncoder iOS (rtmp-rtsp-stream-client-swift) is a stream encoder to push video/audio to media servers using protocols RTMP, RTSP and SRT with all code written in Swift
Apache License 2.0
125 stars 35 forks source link

Used URLComponents for parsing RTSP url #30

Closed vitkuzmenko closed 4 months ago

vitkuzmenko commented 4 months ago

Description of Changes

This pull request removes the constraint that RTSP URLs must adhere to the format rtsp://ip:port/appname/streamname. The current implementation appends a trailing slash (/) to the URL, which can cause issues with certain RTSP servers, such as mediamtx, that do not accept a trailing slash in the URL path.

For example, my local mediamtx server generates URLs like rtsp://192.168.0.X:8554/mystream. With the existing implementation, using this URL results in an appended /, causing the server to reject the URL.

Changes Made

Benefits

Testing

pedroSG94 commented 4 months ago

Hello,

Thank you for the report and the PR. This is a bug, but I think that change the whole url parse is not necessary. I want use the same parse method in both protocols (RTMP and RTSP) and in Android. This is to make me easier maintain the code (if the code is similar I can follow it easier)

Instead of use URLComponents I think that check if the streamName is empty and avoid set a "/" in that case is enough. https://github.com/pedroSG94/RootEncoder-iOS/blob/master/RootEncoder/Sources/RootEncoder/rtsp/rtsp/RtspClient.swift#L85 I'm doing that on Android version where this error is fixed: https://github.com/pedroSG94/RootEncoder/blob/master/rtsp/src/main/java/com/pedro/rtsp/rtsp/RtspClient.kt#L207

vitkuzmenko commented 4 months ago

Ok, I update commit

pedroSG94 commented 4 months ago

Thank you, merged