I'm developing an iOS app with screensharing. Since screenshsring on iOS is not supported by Apple, the only way is to take screenshots and transmit them.
I'm using WebRTC DataChannel to share the screenshots to a browser. It works decent, but requires a good and stable upload speed to work.
My problem is when there is slower network or when it goes up and down in speed. Because I want the screensharing to be relatively real-time. There needs to be some kind of flow control implemented. Now there will be a delay on the receiver side when the connection slows down / lag spikes.
So when the speed is lower, I want to slow down the screenshots send per second. And vice versa. I'm syncing clocks with ntp, and have a naive implementation at the moment sending the time the screenshot was taken and with that does some naive algorithm I made up. However it doesn't work as well as I need.
Is there some real time flow control algorithm you can recommend me, or any other ideas?