"This is the hackiest code I've ever written. Most of it is copy pasted from elsewhere. ;-)"
I see...
I see...
Basically I just wanted to try out some ideas using WebRTC peer-to-peer video with some clever layout algorithms.
When I started this I was looking into libraries like Packery that are good at arranging rectangles in the smallest possible space. But I found what I really wanted was something to expand to fill all available space.
I ended up using D3's treemaps to arrange videos. Normally they're used for visualising things like diskspace, but I'm using it to fill the screen with videos.