FBVideoCore
The video vocabulary shared by every kind of target. FBSimulatorVideo records and streams a Simulator's screen and FBDeviceControl records a physical device's; both are written against this library, and a consumer that handles video from either kind of target only needs to know this one.
It depends only on FBControlCore, so linking it does not bring in any target implementation.
What it provides
- The video capability.
VideoTargetis a protocol refiningTargetwith two command nouns,videoRecordingandvideoStream. It is declared here rather than onTarget, soFBControlCoredoes not have to know about video and a target is given the capability by the library that implements it:FBSimulatorVideoconformsSimulator, andFBDeviceControlconformsDevice. - Command protocols.
VideoRecordingCommandsstarts a recording to a file and returns aVideoRecordingto stop it.VideoStreamCommandsstarts a stream into aDataConsumerand returns aVideoStreamOperation. - Stream configuration.
VideoStreamConfigurationdescribes what to produce: aVideoStreamFormat(H.264 or HEVC in an Annex-B, MPEG-TS or fragmented MP4 transport, MJPEG, minicap or raw BGRA), the frame rate, rate control, scale and key-frame interval, and theDisplaySelectionto capture. - Container writers. Encoded samples become bytes through an
EncodedFrameWriter:AnnexBFrameWriter,MPEGTSFrameWriterand the fragmented MP4 writer for compressed video,MJPEGFrameWriter,MinicapFrameWriterandBGRAFrameWriterfor the rest. The MPEG-TS and fMP4 writers also carry timed metadata alongside the video.VideoFileWriterrecords anAVCaptureSessionto a file.
Using it
A caller holding a concrete target reaches its video commands directly:
let recording = try await simulator.videoRecording.start(toFile: "/tmp/screen.mp4")
// ...
let file = try await recording.stop()
A caller holding any Target resolves the capability against the target types it links, naming each one rather than casting to any VideoTarget: a conformance declared in a library of its own is only linked into a binary when something references it.