Pipe and Filter Software Architecture
The pipe and filter architecture is a software architecture that is data-centric, structured around how data flows through the application. In this architecture, applications employ a pipeline as follows:
Firstly, the application takes in data as input.
Next, a series of transformations on the data are applied sequentially.
Finally, the application returns the processed data as output.
Components
Several components are involved in the pipeline described above.
1. Data Source
The data source serves as the start of the pipeline. It is responsible for receiving the input data and delivering it down the pipeline.
2. Pipe
Pipes connects the other components together. They serve to transfer and buffer data between the other components, from a component upstream to one that is downstream. Additionally, pipes also synchronize the activity of neighbouring filters.
3. Filter
Filters are self-contained data processing steps that performs a transformation function on data. It receives data from a pipe upstream, transforms the data, then sends the transformed data to the pipe downstream.
4. Data Sink
The data sink serves as the end of the pipeline. It receives the processed data at the end of the pipeline and serves it as the application’s output.
Characteristics
The pipe and filter architecture is most suitable for applications that can be broken down into self-contained process steps (implemented in individual filters).
Since the filters are independent, an added advantage of pipe and filter is its high degree of flexibility. Filters can freely be added, removed, or have their position in the pipeline swapped, so long as the data remains compatible between filters. The same filter can even be called repetitively.
Real World Application
One scenario where the pipe and filter architecture is especially suitable is in the field of video processing, such as in the media-handling library, GStreamer.
In video processing, a unprocessed video undergoes a series of transformations to become a processed video that can serve a more useful purpose. One example of this is in the real-time object detection from a live cameras. We can use this example to illustrate the application of the pipe and filter architecture.
In the example use case illustrated above, the image frames from the live video recorded serve as the input data and are sent into the application via the data source. Once in the pipeline, the data is transported via pipes between each component.
From the data source, the data goes through a series of filters sequentially, each processing the data to make it more useful for the next filter order to achieve the eventual goal of object detection. Eventually, the processed data, which in this case is the input image frame with bounding boxes drawn around objects of interest, is served as the application’s output in the data sink.
It is useful to note pipe and filter architecture’s flexibility here: many other transformations in video processing can reuse filters implemented above.