I'm trying to create a custom chromecast receiver that is able to play clearkey protected content. How can i use the clearkey from the receiver side to achieve that.
I think you may find that this actually 'just works' - Clearkey DRM contains the key, or a URL to the key in the clear, in the stream itself and should be supported as standard on a Google Cast device, I believe.
If not, or if you want to send the key or license URL anyway, you can add this in custom data that you send to the receiver - see this answer: https://stackoverflow.com/a/66580383/334402
Google provide information on this here: https://developers.google.com/cast/docs/media/streaming_protocols?hl=en#drm
Specifically for your case:
For media content that has its DRM license (and key URL) stored in their manifest (DASH or HLS), the Cast SDK handles this case for you. A subset of that content requires a licenseUrl which is needed to obtain the decryption key. In the Web Receiver, you can use PlaybackConfig to set the licenseUrl as needed.