Here's the API docs for the "walled garden":
The only way to run code on the device is to either serve your code through Google's platform, or root the device and own it like the Linux box it is.
None of Google's documentation speaks about the Cast protocol itself. It's against the Chromecast TOS to create a custom receiver device. You must buy the Chromecast hardware. There have been several attempts to reverse-engineer the receiver protocol and create custom receiver devices, but none of them work with the current protocol.
I'd call this a "walled garden."