How filter chains and consumers work together
masterBBMetalImage uses a consumer-based architecture to build processing pipelines.
- Sources: Objects like
BBMetalCamera,BBMetalVideoSource,BBMetalStaticImageSource, orBBMetalUISourceact as the origin of data (textures/audio). - Consumers: Filters (e.g.,
BBMetalContrastFilter) and output targets (e.g.,BBMetalView,BBMetalVideoWriter) act as consumers. - Chaining: You connect them using the
.add(consumer:)method. A source can feed a filter, which then feeds another filter, eventually reaching a final consumer like a view or a video writer. - Audio: For video-related tasks, you must explicitly set the
audioConsumeron the source (e.g.,camera.audioConsumer = videoWriter) to ensure audio is recorded alongside the processed video.
// Example of a chain: Camera -> Filter 1 -> Filter 2 -> MetalView
camera.add(consumer: filter1)
.add(consumer: filter2)
.add(consumer: metalView)