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, events or queries are pushed or sent on a pad. It
19 should also 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_PAD_PROBE_TYPE_INVALID = 0,
50 /* flags to control blocking */
51 GST_PAD_PROBE_TYPE_IDLE = (1 << 0),
52 GST_PAD_PROBE_TYPE_BLOCK = (1 << 1),
54 /* flags to select datatypes */
55 GST_PAD_PROBE_TYPE_BUFFER = (1 << 4),
56 GST_PAD_PROBE_TYPE_BUFFER_LIST = (1 << 5),
57 GST_PAD_PROBE_TYPE_EVENT_DOWNSTREAM = (1 << 6),
58 GST_PAD_PROBE_TYPE_EVENT_UPSTREAM = (1 << 7),
59 GST_PAD_PROBE_TYPE_EVENT_FLUSH = (1 << 8),
60 GST_PAD_PROBE_TYPE_QUERY_DOWNSTREAM = (1 << 9),
61 GST_PAD_PROBE_TYPE_QUERY_UPSTREAM = (1 << 10),
63 /* flags to select scheduling mode */
64 GST_PAD_PROBE_TYPE_PUSH = (1 << 12),
65 GST_PAD_PROBE_TYPE_PULL = (1 << 13),
69 When adding a probe with the IDLE or BLOCK flag, the probe will become a
70 blocking probe (see below). Otherwise the probe will be a DATA probe.
72 The datatype and scheduling selector flags are used to select what kind of
73 datatypes and scheduling modes should be allowed in the callback.
75 The blocking flags must match the triggered probe exactly.
77 The probe callback is defined as:
79 GstPadProbeReturn (*GstPadProbeCallback) (GstPad *pad, GstPadProbeInfo *info,
82 A probe info structure is passed as an argument and its type is guaranteed
83 to match the mask that was used to register the callback. The data item in the
84 info contains type specific data, which is usually the data item that is blocked
85 or NULL when no data item is present.
87 The probe can return any of the following return values:
97 GST_PAD_PROBE_OK is the normal return value. DROP will drop the item that is
98 currently being probed. GST_PAD_PROBE_REMOVE the currently executing probe from the
101 GST_PAD_PROBE_PASS is relevant for blocking probes and will temporarily unblock the
102 pad and let the item trough, it will then block again on the next item.
108 Blocking probes are probes with BLOCK or IDLE flags set. They will always
109 block the dataflow and trigger the callback according to the following rules:
111 When the IDLE flag is set, the probe callback is called as soon as no data is
112 flowing over the pad. If at the time of probe registration, the pad is idle,
113 the callback will be called immediately from the current thread. Otherwise,
114 the callback will be called as soon as the pad becomes idle in the streaming
117 The IDLE probe is useful to perform dynamic linking, it allows to wait for for
118 a safe moment when an unlink/link operation can be done. Since the probe is a
119 blocking probe, it will also make sure that the pad stays idle until the probe
122 When the BLOCK flag is set, the probe callback will be called when new data
123 arrives on the pad and right before the pad goes into the blocking state. This
124 callback is thus only called when there is new data on the pad.
126 The blocking probe is removed with gst_pad_remove_probe() or when the probe
127 callback return GST_PAD_PROBE_REMOVE. In both cases, and if this was the last
128 blocking probe on the pad, the pad is unblocked and dataflow can continue.
134 Non-blocking probes or DATA probes are probes triggered when data is flowing
135 over the pad. The are called after the blocking probes are run and always with
142 Push probes have the GST_PAD_PROBE_TYPE_PUSH flag set in the callbacks.
144 In push based scheduling, the blocking probe is called first with the data item.
145 Then the data probes are called before the peer pad chain or event function is
148 The data probes are called before the peer pad is checked. This allows for
149 linking the pad in either the BLOCK or DATA probes on the pad.
151 Before the peerpad chain or event function is called, the peer pad block and
152 data probes are called.
154 Finally, the IDLE probe is called on the pad after the data was sent to the
157 The push dataflow probe behavior is the same for buffers and bidirectional events.
163 gst_pad_push_event() | |
164 -------------------->O |
169 O-> do BLOCK probes |
175 O gst_pad_chain() / |
176 O gst_pad_send_event() |
177 O------------------------------>O
180 O< - - - - - - - - - - - - - - -O
181 O O-> do BLOCK probes
187 O< - - - - - - - - - - - - - - -O
198 Pull probes have the GST_PAD_PROBE_TYPE_PULL flag set in the callbacks.
200 The gst_pad_pull_range() call will first trigger the BLOCK probes without a DATA
201 item. This allows the pad to be linked before the peer pad is resolved. It also
202 allows the callback to set a data item in the probe info.
204 After the blocking probe and the getrange function is called on the peer pad
205 and there is a data item, the DATA probes are called.
207 When control returns to the sinkpad, the IDLE callbacks are called. The IDLE
208 callback is called without a data item so that it will also be called when there
211 If there is a valid DATA item, the DATA probes are called for the item.
216 | | gst_pad_pull_range()
217 | O<---------------------
221 | O - - - - - - - - - - >
222 | do BLOCK probes <-O
225 | O - - - - - - - - - - >
226 | gst_pad_get_range() O
227 O<------------------------------O
231 O- - - - - - - - - - - - - - - >O
232 do BLOCK probes <-O O
236 O- - - - - - - - - - - - - - - >O
239 O- - - - - - - - - - - - - - - >O
243 | O - - - - - - - - - - >
246 | O - - - - - - - - - - >
253 Query probes have the GST_PAD_PROBE_TYPE_QUERY_* flag set in the callbacks.
258 gst_pad_peer_query() | |
259 -------------------->O |
261 O-> do BLOCK probes |
263 O-> do QUERY | PUSH probes |
268 O------------------------------>O
269 O O-> do BLOCK probes
271 O O-> do QUERY | PUSH probes
275 <- - - - - - - - - - - - - - - - - - - - - - -O
277 O O-> do QUERY | PULL probes
278 O< - - - - - - - - - - - - - - -O
280 O-> do QUERY | PULL probes |
285 For queries, the PUSH ProbeType is set when the query is traveling to the object
286 that will answer the query and the PULL type is set when the query contains the