Streaming - Vateron-Media/Xtreamcodes_old GitHub Wiki

How tracking the number of connections works

As soon as you start browsing the channel, a database entry is created in the lines_live table.

After that, cron users.php starts checking how many connections are open for each user. If cron sees that there are more connections than allowed for a given user, it starts closing the oldest ones. For the HLS container API container this happens every minute, but for the TS container it waits 300 seconds and then closes the inactive connection.

There is also an issue with TS flow tracking where if you switch channels quickly, the oldest connections may not be removed automatically, and this is where cron comes to the rescue.

For HLS it works correctly due to the fact that every time a channel is switched a new request is made for the list of TS sigments, and this list is updated approximately every 5 seconds and the hls_last_read key is updated in the database. In TS we generate a continuous stream of data and this key in the database is updated only at the moment of connection break.