s/ffmpegcolorspace/videoconvert/ in a few places
[platform/upstream/gstreamer.git] / pwg-building-pads.md
1 ---
2 title: Specifying the pads
3 ...
4
5 # Specifying the pads
6
7 As explained before, pads are the port through which data goes in and
8 out of your element, and that makes them a very important item in the
9 process of element creation. In the boilerplate code, we have seen how
10 static pad templates take care of registering pad templates with the
11 element class. Here, we will see how to create actual elements, use an
12 `_event
13 ()`-function to configure for a particular format and how to register
14 functions to let data flow through the element.
15
16 In the element `_init ()` function, you create the pad from the pad
17 template that has been registered with the element class in the
18 `_class_init ()` function. After creating the pad, you have to set a
19 `_chain ()` function pointer that will receive and process the input
20 data on the sinkpad. You can optionally also set an `_event ()` function
21 pointer and a `_query ()` function pointer. Alternatively, pads can also
22 operate in looping mode, which means that they can pull data themselves.
23 More on this topic later. After that, you have to register the pad with
24 the element. This happens like this:
25
26 ``` c
27
28
29
30 static void
31 gst_my_filter_init (GstMyFilter *filter)
32 {
33   /* pad through which data comes in to the element */
34   filter->sinkpad = gst_pad_new_from_static_template (
35     &sink_template, "sink");
36   /* pads are configured here with gst_pad_set_*_function () */
37
38
39
40   gst_element_add_pad (GST_ELEMENT (filter), filter->sinkpad);
41
42   /* pad through which data goes out of the element */
43   filter->srcpad = gst_pad_new_from_static_template (
44     &src_template, "src");
45   /* pads are configured here with gst_pad_set_*_function () */
46
47
48
49   gst_element_add_pad (GST_ELEMENT (filter), filter->srcpad);
50
51   /* properties initial value */
52   filter->silent = FALSE;
53 }
54   
55 ```
56