tvhProxy
tvhProxy copied to clipboard
Limit concurrent streams to amount of available tuners
As per title we need to limit this, either by locking or something else.
This could be tricky for OTA tuners - there is a case where the number of different concurrent streams can validly exceed the number of tuners.
For ATSC, each channel can have multiple subchannels on the same frequency (1.1, 1.2, 1.3, etc) - up to 6 subchannels is common. If a tuner is tuned to one of these subchannels, Tvheadend is capable of simultaneously streaming all of the other subchannels from the same tuner. In Plex, a user could validly specify multiple simultaneous recordings from a single tuner if they are neighboring subchannels.
I'm not clear on how HDHomeRun handles this, but for Plex it may be simpler to set a high number of tuners and return a 503 Service Unavailable
(as HDHomeRun does) if Tvheadend reports that it can't serve a subscription request.
I haven't had much time to look into this, and I'm unsure if I'm able to properly test TVH as I use IPTV and don't have an upper limit on available "tuners" (It will serve as many as the system can handle)
Anyhow I agreed with your suggestions. One could possibly try/except this https://github.com/jkaberg/tvhProxy/blob/master/tvhProxy.py#L79 and intercept whatever error code TVH spits out on high tuner usage, or get the http code from the get object.
Perferebly we should fetch available tuners from TVH aswell.