# STEP 2 : Create the Gstreamer element on template

## STEP 2.1 : Build the Gstreamer template and testing

This process will build gstreamer template plugin for create your gstreamer template for get data from gstreaamer on step 3&#x20;

1. Build gstreamer on devcontainer

```bash
$ meson build
```

<figure><img src="https://paper-attachments.dropbox.com/s_8D12BA9D3ACC276FE6456B192705A16DC9CD19AC9DCDCFFA08371C99F10A1BD1_1645014929595_image.png" alt=""><figcaption></figcaption></figure>

2\. Linking library from build file&#x20;

```bash
$ ninja -C build
```

<figure><img src="https://paper-attachments.dropbox.com/s_8D12BA9D3ACC276FE6456B192705A16DC9CD19AC9DCDCFFA08371C99F10A1BD1_1645014949994_image.png" alt=""><figcaption></figcaption></figure>

3\. Set environment to built gstreamer template

```bash
$ export GST_PLUGIN_PATH=/workspaces/gst-template/build/gst-plugin
```

4\. Check gst-plugin[ *gst-inspect-1.0*](https://gstreamer.freedesktop.org/documentation/tools/gst-inspect.html?gi-language=c)[ ](https://gstreamer.freedesktop.org/documentation/tools/gst-inspect.html?gi-language=c)is a tool that prints out information on availabl *GStreamer* plugins, information about a particular plugin, or information about a particular element.&#x20;

```bash
$ gst-inspect-1.0 /workspaces/gst-template/build/gst-plugin/libgstplugin.so
```

<figure><img src="https://paper-attachments.dropbox.com/s_8D12BA9D3ACC276FE6456B192705A16DC9CD19AC9DCDCFFA08371C99F10A1BD1_1645015371091_image.png" alt=""><figcaption></figcaption></figure>

From the inspection, we found version of gst-plugin from we build is version 1.19.0.1 and it’s gstreamer element, The name of element is **plugin\_template**

5\. Test run gst-template working&#x20;

```bash
$ gst-launch-1.0 videotestsrc ! plugin_template ! fakesink
```

<figure><img src="https://paper-attachments.dropbox.com/s_8D12BA9D3ACC276FE6456B192705A16DC9CD19AC9DCDCFFA08371C99F10A1BD1_1645016516068_image.png" alt=""><figcaption></figcaption></figure>

## STEP 2.2 : Create the gstreamer template&#x20;

In this state, we will create our gstreamer template for get data from mockup data and application gstreamer code for get more data.&#x20;

1\. First we will create the gstreamer element

```bash
$ cd gst-plugin/src
$ ../tools/make_element videodatagst 
# video_data_gst just a name of your element, Don't worry to create your element name like lnwza007.
```

<figure><img src="https://paper-attachments.dropbox.com/s_8D12BA9D3ACC276FE6456B192705A16DC9CD19AC9DCDCFFA08371C99F10A1BD1_1645016317462_image.png" alt=""><figcaption></figcaption></figure>

2\. Go to line 247 : gst videodatagst\_chain. This function using for adjust working process inside the element. What is gst elemnet please folow this [link](https://gstreamer.freedesktop.org/documentation/application-development/basics/elements.html?gi-language=c)

* The Gstreamer element is black box of video process, it’s can recive input process from sink and put throughtput to src

<figure><img src="https://paper-attachments.dropbox.com/s_8D12BA9D3ACC276FE6456B192705A16DC9CD19AC9DCDCFFA08371C99F10A1BD1_1645016720311_image.png" alt=""><figcaption></figcaption></figure>

From the function, we saw the parameter is&#x20;

* [pad](https://gstreamer.freedesktop.org/documentation/application-development/basics/pads.html?gi-language=c) are the element's interface to the outside world. Data streams from one element's source pad to another element's sink pad.
* [parent](https://gstreamer.freedesktop.org/documentation/additional/design/relations.html?gi-language=c#object-relation-types) are the element’s relation on sink or src pad between element for reference data with the group of parent element.
* [buf](https://gstreamer.freedesktop.org/documentation/gstreamer/gstbuffer.html?gi-language=c#gstbuffer-page) are the basic unit of data transfer in GStreamer. They contain the timing and offset along with other arbitrary metadata that is associated with the [GstMemory](https://gstreamer.freedesktop.org/documentation/gstreamer/gstmemory.html#GstMemory) blocks that the buffer contains.

So from this function is chain. it’s mean working process on element pad, we can debug code or define element process on this fucntion.&#x20;


---

# Agent Instructions: Querying This Documentation

If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://docs.aic-eec.com/general/docker-os/application-gstreamer-on-devcontainer/step-2-create-the-gstreamer-element-on-template.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
