4 Probes are callbacks that can be installed by the application and will notify
5 the application about the states of the dataflow.
11 Applications should be able to monitor and control the dataflow on pads. We
12 identify the following types:
14 - be notified when the pad is/becomes idle and make sure the pad stays idle.
15 This is essential to be able to implement dynamic relinking of elements
16 without breaking the dataflow.
18 - be notified when data or events are pushed or sent on a pad. It should also
19 be possible to inspect and modify the data.
21 - be able to drop, pass and block on data based on the result of the callback.
23 - be able to drop, pass data on blocking pads based on methods performed by
24 the application thread.
30 The function gst_pad_add_probe() is used to add a probe to a pad. It accepts a
31 probe type mask and a callback.
33 gulong gst_pad_add_probe (GstPad *pad,
35 GstPadProbeCallback callback,
37 GDestroyNotify destroy_data);
39 The function returns a gulong that uniquely identifies the probe and that can
40 be used to remove the probe with gst_pad_remove_probe():
42 void gst_pad_remove_probe (GstPad *pad, gulong id);
44 The mask parameter is a bitwise or of the following flags:
48 GST_PROBE_TYPE_INVALID = 0,
50 /* flags to control blocking */
51 GST_PROBE_TYPE_IDLE = (1 << 0),
52 GST_PROBE_TYPE_BLOCK = (1 << 1),
54 /* flags to select datatypes */
55 GST_PROBE_TYPE_BUFFER = (1 << 2),
56 GST_PROBE_TYPE_BUFFER_LIST = (1 << 3),
57 GST_PROBE_TYPE_EVENT = (1 << 4),
59 /* flags to select scheduling mode */
60 GST_PROBE_TYPE_PUSH = (1 << 5),
61 GST_PROBE_TYPE_PULL = (1 << 6),
64 When adding a probe with the IDLE or BLOCK flag, the probe will become a
65 blocking probe (see below). Otherwise the probe will be a DATA probe.
67 The datatype and scheduling selector flags are used to select what kind of
68 datatypes and scheduling modes should be allowed in the callback.
70 The blocking flags must match the triggered probe exactly.
72 The probe callback is defined as:
74 GstProbeReturn (*GstPadProbeCallback) (GstPad *pad, GstProbeType type,
78 The executing probe type is passed as an argument and is guaranteed to match
79 the mask that was used to register the callback. type_data contains type
80 specific data, which is usually the data item that is blocked or NULL when
81 no data item is present.
83 The probe can return any of the following return values:
93 GST_PROBE_OK is the normal return value. DROP will drop the item that is
94 currently being probed. GST_PROBE_REMOVE the currently executing probe from the
97 GST_PROBE_PASS is relevant for blocking probes and will temporarily unblock the
98 pad and let the item trough, it will then block again on the next item.
104 Blocking probes are probes with BLOCK or IDLE flags set. They will always
105 block the dataflow and trigger the callback according to the following rules:
107 When the IDLE flag is set, the probe callback is called as soon as no data is
108 flowing over the pad. If at the time of probe registration, the pad is idle,
109 the callback will be called immediately from the current thread. Otherwise,
110 the callback will be called as soon as the pad becomes idle in the streaming
113 The IDLE probe in useful to perform dynamic linking, it allows to wait for for
114 a safe moment when an unlink/link operation can be done. Since the event is a
115 blocking event, it will also make sure that the pad stays idle until the probe
118 When the BLOCK flag is set, the probe callback will be called when new data
119 arrives on the pad and right before the pad goes into the blocking state. This
120 callback is thus only called when there is new data on the pad.
122 The blocking probe is removed with gst_pad_remove_probe() or when the probe
123 callback return GST_PROBE_REMOVE. In both cases, and if this was the last
124 blocking probe on the pad, the pad is unblocked and dataflow can continue.
130 Non-blocking probes or DATA probes are probes triggered when data is flowing
131 over the pad. The are called after the blocking probes are run and always with
138 All probes have the GST_PROBE_TYPE_PUSH flag set in the callbacks.
140 In push based scheduling, the blocking probe is called first with the data item.
141 Then the data probes are called before the peer pad chain or event function is
144 The data probes are called before the peer pad is checked. This allows for
145 linking the pad in either the BLOCK or DATA probes on the pad.
147 Before the peerpad chain or event function is called, the peer pad data probes
150 Finally, the IDLE probe is called on the pad after the data was sent to the
153 The push dataflow probe behavior is the same for buffers and biderectional events.
159 gst_pad_push_event() | |
160 -------------------->O |
165 O-> do BLOCK probes |
171 O gst_pad_chain() / |
172 O gst_pad_send_event() |
173 O------------------------------>O
176 O< - - - - - - - - - - - - - - -O
181 O< - - - - - - - - - - - - - - -O
192 All probes have the GST_PROBE_TYPE_PULL flag set in the callbacks.
194 The gst_pad_pull_range() call will first trigger the BLOCK probes without a DATA
195 item. This allows the pad to be linked before the peer pad is resolved.
197 After the getrange function is called on the peer pad and there is a data item,
198 the DATA probes are called.
200 When control returns to the sinkpad, the IDLE callbacks are called. The IDLE
201 callback is called without a data item so that it will also be called when there
204 It there is a valid DATA item, the DATA probes are called for the item.
209 | | gst_pad_pull_range()
210 | O<---------------------
214 | O - - - - - - - - - - >
215 | do BLOCK probes <-O
218 | O - - - - - - - - - - >
219 | gst_pad_get_range() O
220 O<------------------------------O
224 O- - - - - - - - - - - - - - - >O
227 O- - - - - - - - - - - - - - - >O
230 O- - - - - - - - - - - - - - - >O
234 | O - - - - - - - - - - >
237 | O - - - - - - - - - - >