How to use Gstreamer to encode and decode data using C language, and output the data?

I expect to use gstreamer to achieve two functions:

  1. Decode the obtained RTSP stream into YUV data and output the data to the queue.
  2. Encode yuv data into h264 data and encapsulate h264 data into rtsp data.
    I can easily implement these functions using commands, but now I need to implement them in C language and retrieve the data. Whether it is decoded or encoded data, I need to use C language to send it to a third party for use. I don’t know how to implement it?