0

I am looking forward to build an app which will support the screen mirroring concept. how shall I implement it I am just not able to get it I have read multiple docs on Chrome cast reflector 2, I need to build an app in which I can simply share my screen among Android to iPhone or on the same platform also. please help any references any advice will be appreciated.

Harshit Goel
  • 679
  • 1
  • 6
  • 20

1 Answers1

0

You may consider making a function which returns a UI image of your screen with something along the lines of UIGraphicsBeginImageContextWithOptions(self.view.size, false, 0.5) view.drawHierarchy(in: view.frame, afterScreenUpdates: true) let image = UIGraphicsGetImageFromCurrentImageContext() UIGraphicsEndImageContext() with the given quality parameters you set. The image context is thread- safe, don't worry. https://developer.apple.com/documentation/uikit/1623912-uigraphicsbeginimagecontextwitho. I don't know the quality settings you may want, but you can change that. Then you could make a function/ class that will send whatever data you have in a serialized buffer. I'm assuming that since this is for screen mirroring, a type of streaming, you may want to use UDP as your data transport protocol since it doesn't care whether or not some packets are lost because they just keep coming, i.e. there's no 3- way handshake. You may want to see this forum post Swift: Receive UDP with GCDAsyncUdpSocket for more info on transferring data via UDP. In short, you'll need to serialize your data(convert it to bytes) to send it in a small format and deserialize it on the other end where you have your socket connected device listening for new data which it converts into an image. Finally, you need to ensure that your screen capture function, which returns 1 image, is called several times per second. Good luck!

Mihir Thanekar
  • 508
  • 4
  • 8