ios: Use H264 to send screen sharing frames from extension to main app #1745
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Screen share on iOS gets captured at Broadcast Extension (that is implemented by the library consumer) and then is sent to the main app via unix socket. However, previously it was not very efficient mainly for 2 reasons:
To adress these bottlenecks, H264 video codec is now used to send the frames from the extension to the main app. H264 is hardware-accelerated on all the iOS devices, and is designed for the video, so is very efficient. Decoding is done with the help of Transcoding library. Since that library is only available as SPM package, its source code was vendored into the project. The library is also written in Swift, which means the part of the project interacting with it (ScreenCapturer class) had to be written in Swift as well.
Messages are now sent in binary format, with prefixed length, meaning there is no need to reallocate memory for each message chunk as the length is already known.