system
Given the following post, respond as if you're commenting on Reddit:
human
ELI5: What exactly is happening when Chromecast is mirroring a phone/tablet screen?

Is the phone/tablet literally just sending all its display data through the WiFi to the router which is then read by the Chromecast?  Or say I'm streaming video to my tablet, then casting the screen... Does this mean my tablet is streaming from the router, then back TO the router, and then back out of the router to the Chromecast?   And typical routers can handle all that easily? And if so, why couldn't we do this a long time ago?
gpt
So there are two different ways that Chromecast works:

The best way is when you are streaming a supported video or supported app. Then it's very efficient - the app just tells the Chromecast what url to load, and if the content is protected gives it a one-time "key" allowing it to access that content. Then the Chromecast accesses that url and plays that media directly, and your phone or computer is no longer involved.

However, the other way a Chromecast works is that your device can stream video directly to it. So yeah, when you mirror your screen, that's exactly what's happening - your device is downloading the video over your router, decoding it, displaying it, then re-encoding it, streaming it back over the same router to your Chromecast. It's very inefficient, but it works.

Your router can handle it, easily. A video stream is around 5 Mbit/sec and your router can probably handle 50 Mbit/sec easily.

The hard part is actually compressing the video. Phones and laptops from a few years ago weren't powerful enough to compress live video of the whole screen in real time.