Build own Chromecast device

31,596

Solution 1

The chromecast device works using the DIAL protocol. It is completely possible to emulate this protocol using some simple code to listen on the multicast group for discovery and then handle the HTTP requests to launch applications. It is then the launched application that communicates with the casting device, I believe using the RAMP protocol.

Luckily for us the applications that the chromecast device uses are mostly web applications meaning our device emulator just needs to launch a web browser and point it to a specific url when it receives an application request.

For example the youtube app, after device discovery and establishing where the applications are located (part of DIAL). Will send a HTTP POST request containing a pairing key to /<apps url>/YouTube. All the emulating device needs to do now is open https://www.youtube.com/tv?<pairing key> in a browser window. From here, I believe, communication for controlling the youtube app is not sent through the casting device but through the open tabs on the casting device and the emulator.

This is my understanding of how the chromecast device works and specifically the youtube app from looking at https://github.com/dz0ny/leapcast which is a python emulator that has youtube and google music working.

Solution 2

I have implemented a complete chromecast v2 receiver, called YouMap ChromeCast Receiver, available in Google play store and Amazon store, xda-developer thread here: http://forum.xda-developers.com/android-tv/chromecast/app-youmap-chromecast-receiver-android-t3161851

The current Chromecast protocol is a completely different one from the original DIAL based protocol. Right now, only YouTube still uses the old protocol, which chromecast maintains its backward compatibility.

The discovery is mDNS, exactly same as Apple TV bonjour protocol.

The most difficult part is device authentication, the sender and the receiver perform handshakes by exchanging keys and certificates in a way extremely difficult to crack. AppleTV does the same using FairPlay encryption.

The next difficult part is the mirroring protocol, which is also very complicated, need to deal with packet splits, packet retransmissions. Overall, chromecast mirroring protocol is well designed, better than miracast, better than AirPlay mirroring (I have also implemented both of them, so I know what I am talking about).

When I get chances, will write more here.

Solution 3

Google is in progress of open sourcing some part of the chrome cast.

https://code.google.com/p/chromium/codesearch#chromium/src/chromecast/

https://code.google.com/p/chromium/issues/list?q=label:Chromecast

So theoretically you can build a similar device.

Share:
31,596
Admin
Author by

Admin

Updated on August 05, 2022

Comments

  • Admin
    Admin almost 2 years

    The Chromecast device is a "receiver device [that] runs a scaled-down Chrome browser with a receiver application". Can I download and install this receiver app on a chrome browser for example on my Windows notebook?

  • Wrikken
    Wrikken over 9 years
    Note that this the answer there is no longer current: the V2 Chromecast uses mDNS currently, and I believe protobuf. The rest is of the flow remains more or less the same indeed. Unfortunately, development to get V2 working on the linked Leapcast (which still works great for youtube) seems to have stalled.
  • deed02392
    deed02392 over 6 years
    It seems that hardware DRM is used (widevine?) to authenticate cast receivers. I believe this means if we want to emulate a receiver, we at least need a legitimate sacrificial device we can proxy auth flow with?
  • JCM
    JCM over 6 years
    That's right, recently after some packet capturing I have found at least these protocols taking some part in the negotiation: - UDP/IGMP membership to 239.255.255.250. - UDP/SSDP m-search to 239.255.255.250, including TCP/XML response. - UDP/uPnP response unicast from ChromeCast to PC. - UDP/MDNS question to 224.0.0.251, including multicast response from ChromeCast.
  • mjaggard
    mjaggard over 6 years
    Unfortunately, the first part (open sourcing) does not imply the second (so theoretically you can build a similar device) because the Chromecast ecosystem is protected by encryption that is owned and controlled by Google
  • forlayo
    forlayo over 5 years
    @huisinro I'm trying to do a cast receiver, and I'm in the part I've the communication with chrome device and deviceauth starts, but I don't know wich certificate I should use. Can you guide me? I've seen other apps out there (like Reflector 3 and Airserver) that are currently working without any issues :/
  • Lukas
    Lukas over 5 years
    As others have asked: How did you get passed Google's encryption?
  • mscottnelson
    mscottnelson over 3 years
    As it turns out, they effectively only open sourced the UI for the device. So if you have a "Cast Device" you can build your own "Cast Receiver" for it, but the software running on the "Device" is not open source.