rtsp icon indicating copy to clipboard operation
rtsp copied to clipboard

Timeout and try catch

Open analyserdmz opened this issue 3 years ago • 2 comments

Hello, great library! I am trying to do two things by using it. The first one, is to set a max-timeout of rtsp.Client read() function. I mean I am trying to make it try until X seconds and assume the stream is down after those X seconds.

The second one, is to detect a wrong stream url. The following snippet is running with a wrong URL and port but still gives "FOUND" output. Shouldn't it return "NOT FOUND"?

import rtsp
try:
    client = rtsp.Client(rtsp_server_uri = 'rtsp://DNA:[email protected]:12345', verbose=True)
    client.read()
    client.close()
    print("FOUND")
except:
    print("NOT FOUND")

analyserdmz avatar Oct 29 '22 11:10 analyserdmz

Good suggestions. I think they are both doable. The read() function is asynchronous so it might be good to have a general timeout when constructing the Client, and an optional parameter to read() could overwrite that as well.

Check for URL is also a great idea.

dactylroot avatar Dec 01 '22 20:12 dactylroot

I think these are essentially the same as #1 , but good to hear someone else still wants it. I'll try to get to it when I can.

dactylroot avatar Dec 01 '22 20:12 dactylroot