|
1 | 1 | # System architecture
|
| 2 | + |
2 | 3 | Once we know what should be done, let's start thinking how should our system look like!
|
3 | 4 |
|
4 | 5 | First, let's get familiar with some terms. In the Membrane Framework, there is a concept of the `pipeline` which consists of multiple `elements`. Elements are linked with the use of the `pads`, which can be input pads or output pads.
|
5 | 6 | Depending on what type of pads the particular element is equipped with, we distinguish the following types of elements:
|
6 |
| -+ Source - element with only output pads, the first element of each pipeline. It is responsible for fetching the data and transmitting it through the output pad. |
7 |
| -+ Filter - element with both the input pads and the output pads. Its purpose is to get the data via the input pad, transform it and finally transmit the processed data via the output pad. |
8 |
| -+ Sink - element with only input pads, the last element of the pipeline. It can be responsible for storing or playing the data received via the input pad. |
9 |
| -Between the pads, the `buffers` are being sent. |
10 |
| -Buffers sent between the pads should be of the same type. In the Membrane Framework nomenclature, we say, that the pads should have corresponding capabilities - `caps`. |
11 |
| -One might wonder when does the event of the buffers being sent occurs - well, it depends on the pad's mode! |
12 |
| -If the pad works in the *pull* mode, the buffer is sent when it is demanded by the succeeding element in the pipeline. |
13 |
| -Otherwise, the pad works in the *push* mode, which means that it is pushing the buffers once they are ready, independently from the fact if the following elements want (and are capable of processing) it. |
14 |
| -In our pipeline, all the pads will work in the *pull* mode, which inducts a flow control by a [backpressure](https://medium.com/@jayphelps/backpressure-explained-the-flow-of-data-through-software-2350b3e77ce7) mechanism. |
| 7 | + |
| 8 | +- Source - element with only output pads, the first element of each pipeline. It is responsible for fetching the data and transmitting it through the output pad. |
| 9 | +- Filter - element with both the input pads and the output pads. Its purpose is to get the data via the input pad, transform it and finally transmit the processed data via the output pad. |
| 10 | +- Sink - element with only input pads, the last element of the pipeline. It can be responsible for storing or playing the data received via the input pad. |
| 11 | + Between the pads, the `buffers` are being sent. |
| 12 | + Buffers sent between the pads should be of the same type. In the Membrane Framework nomenclature, we say, that the pads should have corresponding capabilities - `caps`. |
| 13 | + One might wonder when does the event of the buffers being sent occurs - well, it depends on the pad's mode! |
| 14 | + If the pad works in the *pull* mode, the buffer is sent when it is demanded by the succeeding element in the pipeline. |
| 15 | + Otherwise, the pad works in the *push* mode, which means that it is pushing the buffers once they are ready, independently from the fact if the following elements want (and are capable of processing) it. |
| 16 | + In our pipeline, all the pads will work in the *pull* mode, which inducts a flow control by a [backpressure](https://medium.com/@jayphelps/backpressure-explained-the-flow-of-data-through-software-2350b3e77ce7) mechanism. |
| 17 | + |
15 | 18 | ## Scheme
|
| 19 | + |
16 | 20 |  <br>
|
17 |
| -As you can see, our pipeline will consist of two twin branches, one per each of the peers. The branches will be merged with the `Mixer` element and the result produced by this element will be put in the file with the `Sink` elements. |
| 21 | +As you can see, our pipeline will consist of two twin branches, one per each of the peers. The branches will be merged with the `Mixer` element and the result produced by this element will be put in the file with the `Sink` elements. |
18 | 22 | Here you can find the description of the particular elements of the system.
|
| 23 | + |
19 | 24 | ## Elements description
|
20 |
| -+ **Source** - that element is responsible for reading the list of packets from the file. |
21 |
| -+ **Ordering Buffer** - this element is responsible for reordering the packets based on their sequence id. The most important part of this element is the buffer, within which there is a place for all the packets, identified by the packet's sequence id. Once the new packet is received, it is placed in the proper place in the buffer, depending on the sequence id. If there is a consistent part of packets "at the bottom of the buffer" (which means - packets with the subsequent sequence ids, which haven't already been sent yet), then this part is sent via the output pad. That is how we make sure that the next element will receive elements sorted by the sequence id. |
22 |
| -Below you can see how the Ordering Buffer is expected to work, once the message "How are you doing?" will be sent in the four packets, each with one word, and received in the following order: (are, you, how, doing?) <br> |
23 |
| - <br> |
24 |
| -+ **Depayloader** - responsible for assembling the packets into the frames. Since the depayloader receives the packets in the order of their sequence id (which means - the order in which they were 'sent'), it is capable of separating out the particular frames, basing on the **e** (ending packet of the frame) characters at the end of the frame id. This element also reads the timestamp from the packets' headers and puts it into buffer's 'pts' (*Presentation timestamp*) field. |
25 |
| -+ **Mixer** - responsible for mixing the frames received via two input pads. The order in which the frames are mixed is based on their 'pts' (*Presentation timestamp*). |
26 |
| -+ **Sink** - this element is responsible for writing the received frames to the file. Since the Mixer takes care of sorting the frames based on the timestamp, Sink can take advantage of the fact that the frames will be ordered and write them to the file in the order they are received. |
27 |
| - |
28 |
| -Now, that you have some high-level understanding of the system we can get down to implementation. |
| 25 | + |
| 26 | +- **Source** - that element is responsible for reading the list of packets from the file. |
| 27 | +- **Ordering Buffer** - this element is responsible for reordering the packets based on their sequence id. The most important part of this element is the buffer, within which there is a place for all the packets, identified by the packet's sequence id. Once the new packet is received, it is placed in the proper place in the buffer, depending on the sequence id. If there is a consistent part of packets "at the bottom of the buffer" (which means - packets with the subsequent sequence ids, which haven't already been sent yet), then this part is sent via the output pad. That is how we make sure that the next element will receive elements sorted by the sequence id. |
| 28 | + Below you can see how the Ordering Buffer is expected to work, once the message "How are you doing?" will be sent in the four packets, each with one word, and received in the following order: (are, you, how, doing?) <br> |
| 29 | +  <br> |
| 30 | +- **Depayloader** - responsible for assembling the packets into the frames. Since the depayloader receives the packets in the order of their sequence id (which means - the order in which they were 'sent'), it is capable of separating out the particular frames, basing on the **e** (ending packet of the frame) characters at the end of the frame id. This element also reads the timestamp from the packets' headers and puts it into buffer's 'pts' (*Presentation timestamp*) field. |
| 31 | +- **Mixer** - responsible for mixing the frames received via two input pads. The order in which the frames are mixed is based on their 'pts' (*Presentation timestamp*). |
| 32 | +- **Sink** - this element is responsible for writing the received frames to the file. Since the Mixer takes care of sorting the frames based on the timestamp, Sink can take advantage of the fact that the frames will be ordered and write them to the file in the order they are received. |
| 33 | + |
| 34 | +Now, that you have some high-level understanding of the system we can get down to implementation. |
0 commit comments