bluenviron / mediamtx

Ready-to-use SRT / WebRTC / RTSP / RTMP / LL-HLS media server and media proxy that allows to read, publish, proxy, record and playback video and audio streams.
MIT License
12.29k stars 1.53k forks source link

sourceAnyPortEnable option not working as expected #691

Closed amokona closed 2 years ago

amokona commented 3 years ago

Which version are you using?

v0.17.8

Which operating system are you using?

Describe the issue

I am trying to proxy an RTSP stream from a server that provides server ports but doesn't use them. This is the same server as in issue #273 (Problem with French IPTV).

In #273 your solution is to set AnyPortEnable to true in the code. This is now set as an option in the YML file.

I have set it to "yes":

paths:

france2: source: "rtsp://mafreebox.freebox.fr/fbxtv_pub/stream?namespace=1&service=201&flavour=hd" sourceProtocol: udp sourceAnyPortEnable: yes

But I still get this error:

INF [path france2] [rtsp source] ERR: no UDP packets received (maybe there's a firewall/NAT in between)

In the capture I have provided you can see the UDP packets arriving from the unexpected port and being ignored.

If my understanding is correct the sourceAnyPortEnable option should allow the server to accept the UDP packets regardless of the source port.

Describe how to replicate the issue

Cant replicate without third party hardware

Did you attach a network dump?

yes capture.zip

aler9 commented 2 years ago

Hello, i checked, and at the moment the option sourceAnyPortEnable allows a server to send a stream to a reader, with any UDP source port, if and only if the server doesn't provide the server ports during the setup, for instance:

RTSP/1.0 200 OK 
Cseq: 3 
Server: fbxrtspd/1.2 Freebox RTSP server 
Public: DESCRIBE, OPTIONS, SETUP, TEARDOWN, PLAY, PAUSE 
X-Freebox-ANPT-Range: 6643145636/6643145636/6643145636/6643145636 
Session: LcsRIqz3S01ptR6;timeout=30 
Transport: RTP/AVP;unicast;mode=play;destination=192.168.0.19;client_port=61264-61265;server_port=0-0

Your source does provide server ports, it just use other random server ports:

RTSP/1.0 200 OK 
Cseq: 3 
Server: fbxrtspd/1.2 Freebox RTSP server 
Public: DESCRIBE, OPTIONS, SETUP, TEARDOWN, PLAY, PAUSE 
X-Freebox-ANPT-Range: 6643145636/6643145636/6643145636/6643145636 
Session: LcsRIqz3S01ptR6;timeout=30 
Transport: RTP/AVP;unicast;mode=play;destination=192.168.0.19;client_port=61264-61265;server_port=32798-32799 

Since this is a common issue, i think that sourceAnyPortEnable can be enhanced to support the case in which the server provides server ports but uses other ones.

aler9 commented 2 years ago

This server behavior is now supported in main, and will be supported in the next release.

amokona commented 2 years ago

Awesome it works! Thank you so much for your help. I will buy you a couple of coffees. (and open another enhancement request for my new problem) Cheers

aler9 commented 2 years ago

added in v0.17.9

github-actions[bot] commented 1 year ago

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.