1 There are a number of different ways of coding a GstSrc. I'll try to
2 outline them and how the function here:
4 1a) Simple push-function based with single output
13 This is the style that all the existing sources use. There is a single
14 output pad, and a _push function that's global to the whole element. The
15 _push function simply constructs buffers and pushes them out the pad.
17 Chained (current implementation):
20 bin src pad1 pad2 plugin
33 ! pad1->chainfunc (pad1->peer)
34 !------------------------------->!
39 !<-------------------------------!
48 Typically this will be the/an entry into the Bin. The Bin's iterate
49 function simply calls the Src's _push function. When the _push function
50 pushes a buffer out it's pad, the chain function of the peer pad is
51 called, presumably causing a push out the other side of that element, and
52 eventually data gets to the other end. The stack unrolls, and the
53 iteration ends for that Src.
59 Again, the source would generally be an entry into the Bin. A loopfunc
60 will be constructed around it, which will simply loop calling the Src's
61 _push function as in the non-cothreaded case. When the _push function
62 pushes a buffer, it finds a pushfunc attached to the pad, drops the buffer
63 in the pen, and calls the pushfunc provided by the Bin. This causes a
64 switch to the next element, then the next, to the end, at which point a
65 buffer pull will travel back down the chain. The _push function gets
66 context and finishes, at which point the loopfunc wrapper simply calls it
67 again in the next iteration.
69 (current implementation):
72 bin cothread1 src pad1 pad2 cothread2 plugin
73 ! (src) (= pad2->peer) (plugin)
86 !--------------------!
90 ----------------------->!
95 ! (get buffer from bufpen)
105 ! gst_pad_pull (pad2)
110 !<-------------------------------------! cothread switch
127 ! gst_pad_push (pad1)
129 !--------------------!
134 ! (get buffer from bufpen)
144 ! gst_pad_pull (pad2)
149 !<-------------------------------------! cothread switch
157 -----------------------------------------------------------------------------------------------
158 1b) Simple push-function based with multiple output
162 Similar to the single output variant, except several chains are spawned
163 off, one per push, hanging off whichever pad the buffer is pushed off of.
164 The stack will grow and unwind as many times as buffers are pushed out.
166 (current implementation)
168 bin src pad1 pad2 plugin
181 ! pad1->chainfunc (pad1->peer)
182 !------------------------------->!
187 !<-------------------------------!
194 ! pad1->chainfunc (pad1->peer)
195 !------------------------------->!
200 !<-------------------------------!
215 Also similar to the single output variant. When the pull winds its way
216 back from the first push, execution returns to the Src's _push function,
217 which simply goes off and pushes out another buffer, causing another
218 series of context switches. Eventually the loopfunc wrapper starts over,
219 round and round we go.
223 -----------------------------------------------------------------------------------------------
224 2) Pull-function based with single output
226 Similar to a regular filter with a chain function associated with each
227 pad, this kind of source doesn't provide a src-wide push function, but
228 does provide pullfuncs for its pad. A pullfunc puts a buffer in the pen
233 bin src pad1 pad2 plugin
243 !------------------------------------------------>!
245 !<------------------------------!
250 !------------------------------>!
253 !<------------------------------------------------!
256 !------------------------------------------------------------------->!
261 !<-------------------------------------------------------------------!
268 As usual, is likely to be an entry into a Bin. The Bin iterate code must
269 explicitly pull a buffer and pass it on to the peer.
274 bin cothread1 src pad1 pad2 cothread2 plugin
275 ! (src) (= pad2->peer) (plugin)
281 !---------------->! gst_pad_pull
282 !------------------------------------------------>!
284 !<------------------------------!
289 !------------------------------>!
292 !<------------------------------------------------!
295 !--------------------------------------! cothread switch
296 |---------------------->!
297 ! gst_pad_pull (pad2)
301 ! (get buffer from bufpen)
311 ! gst_pad_pull (pad2)
317 !-------------------!