| 1 |
PUSH vs PULL |
| 2 |
|
| 3 |
(This is a writedown of ideas I plan to update whenever I find issues. This |
| 4 |
should be fleshed out when doing the threadsafety / buffer passing changes.) |
| 5 |
|
| 6 |
GStreamer allows 3 different forms of elements: |
| 7 |
- loopbased: |
| 8 |
Loopbased elements may push and pull from every pad however they want. They're |
| 9 |
therefore heaviest on the scheduler and for latency or similar considerations. |
| 10 |
- chainbased: |
| 11 |
Chainbased elements have one sinkpad. Data gets pushed into a function attached |
| 12 |
to the pad. => PUSH based |
| 13 |
- getbased: |
| 14 |
Getbased elements have no sinkpads. Every sourcepad has a getfunction that |
| 15 |
produces data on request. => PULL based |
| 16 |
|
| 17 |
The current problem is that PUSH and PULL based elements are quite limited in |
| 18 |
what they may or may not do (especially PULL based elements). Some libraries |
| 19 |
elements link to might also expect the architecture around them to work in a |
| 20 |
specific way (libogg requires the ogg input to be pull-based, JACK is PULL-based |
| 21 |
on sinks and PUSH-based on sinks). This often requires costly wrapping. |
| 22 |
|
| 23 |
Inside a scheduler cothread switches can be avoided (which makes the pipeline |
| 24 |
faster and scheduling less error-prone) if a PUSH-based element is connected on |
| 25 |
the push-side of the pipeline. (Same goes with PULL-based on the pull-side). So |
| 26 |
a pipeline with elements like "pull-pull-loop-push" works without cothread |
| 27 |
switches while a pipeline like "push-loop-pull" needs 2. Even "push-pull" needs |
| 28 |
one. |
| 29 |
|
| 30 |
I'm under the impression that push-vs-pull is often best decided by the |
| 31 |
application in use. (Video players probably prefer PULL because they display on |
| 32 |
demand, live recorders prefer PUSH.) Since many elements probably don't care if |
| 33 |
they're PUSH or PULL based it would be nice if an element could implement both |
| 34 |
and use whatever suits better. (The code to achieve this should obviously be |
| 35 |
abstracted into superclasses like videofilter.) |
| 36 |
|
| 37 |
|
| 38 |
references: |
| 39 |
MPlayer (http://www.mplayerhq.hu) - push-based architecture on version 1, |
| 40 |
switching to PULL-based on version 2. |