Streaming 4K isn't a trivial task. Depending a lot of variables such as codec, color bit depth, frame rate, receiving device, transmitting device, HDR, encode profile, the specific decoding software (VLC, Quicktime, built in players) etc there is a good chance you'll have problems outside the control of Apple.
Its really easy to get/make a 4k video that the AppleTV 4k can't decode. 4k@60hz HEVC HDR is especially troublesome and you can things like weird artifacts, color banding or even just a black screen.
This is the AppleTV 4k's attempt to decode "The World in HDR" its a 4k@60hz HDR but the video is encoded with Google VP9 video codec.
I ran it through handbrake and encoded it using h265 10bit however even then it was a balancing act to get a 4k@60hz HEVC HDR version that smoothly played but once it did I could home share and airplay from my 2013 iMac (doesn't have native HEVC support) to my AppleTV 4k.
I was actually impressed with how well MacOS and Quicktime was handling this file. I was able to play HEVC files in Quicktime on my iMac (decoding HEVC through software) that many third party players couldn't play nor could the AppleTV 4k which has hevc hardware decoding.
It took my iMacs slightly dated but still relevant quad core i5 1 1/2 HOURS to encode that 2 1/2 MINUTE 200mb clip. Maybe that will help illustrate why certain situations can't be handled by AirPlay where things need to be done in real time without a hick up. While I was using the original file "The World in HDR" that is a youtube clip which is why Google can't use software decoding for the AppleTV YouTube app to have 4k. Apple would need the hardware support to have reliable 4k HDR youtube. Admittedly that is an extreme example but it does still exist.
As far as 4k AirPlay I don't have nor do I feel like setting up Xcode like
@priitv8. I also don't have the software, time or patient for pixel counting.
Things I did notice though since I have quite a few Apple products. Keep in mind I'm using the 4k@60hz HEVC HDR BT2020 10bit file I encoded above in all my examples below...
1. Decoding is done on the playback device when using Home Sharing. The above video gives me an error "The content isn't supported by Apple TV" on my non 4k 4th gen AppleTV. Plays fine on my AppleTV 4k. So no where in the chain is transcoding attempted.
2. When using AirPlay the decoding device is dependent the specific of what and how your are trying to Airplay..
If you are mirroring the original file is being decoded by the host and the entire screen is being encoded in h264 (using the resolution of the host devices current screen), sent to the receiver (AppleTV) which decodes that h264 stream.
If you don't mirror and AirPlay specific videos then it streams the original file for the receiver to decode (so yes you can AirPlay 4k. The caveat is if the receiver (AppleTV) can't decode the file several different things can happen, you getting an error, the video stutters, artifacts, color banding etc, or it just keeps kicking you out. So the same video that my 4th gen AppleTV gave me the error "Content not support on AppleTV" will AirPlay from my iPhone 6s but its can't play it, its a slide show of images playing at less than 1 fps. Again plays fine on my AppleTV 4k.
3. iCloud Photos automatically transcodes (very quickly I might add) to something that objectively looks worse then 1080p SDR (I checked using MacOS encoding tool) for device compatibly. So if you goto the tvOS photos app you aren't getting original quality if the media is using processes that aren't compatible with all Apple devices regardless if its an AppleTV 4k or not. The iCloud version can't even be compared to the original version playing on the same device. This is a picture of the aforementioned 4k HEVC HDR video taken from my AppleTV 4k, one being played in the Photos app, one being played in the Computers app (Home Sharing).
That is a picture of my TV taken from an iPhone 6S using lossy jpg, cropped in preview on my Mac and exported in an even lossier JPG so I could upload them here without exceeding upload data limit. If you click on them you can still clearly see the resolution difference.
4. Compatible format transfers are device specific. If I transfer the above original video (4k@60hz HEVC HDR) from my 2018 MBP to my 2013 iMac I get a 4k@60hz h264 file.
Original is left, compatibility version is on the right.
Now I ran into another issue. That compatible version is huge so I would assume the transcode wasn't very complex, ok whatever. However the compatible version will not play on the AppleTV using Home Sharing or AirPlay due to a "File format compatibility" so I assume the encode profile level is too high and is breaking something, I'm not really sure what is wrong with it. Keep in mind I can play the original version that looks 100x better on that same AppleTV using AirPlay and Home Sharing.
5. For supported formats Quicktime is best at playing HEVC on non HEVC hardware. IINA used to be pretty good, VLC has always sucked but Quicktime is by far the smoothest playback.
TL;DR : You can AirPlay 4k assuming the video file formats are compatible and the hardware you are using natively supports handling of that video file and even minor variables can prevent it from working.