I am writing a gstreamer plugin to render the camera video(height=480, width=640 , format UYVY) on top of a HD video frame. In my chain function (gst_plugin_template_chain (GstPad * pad, GstObject * parent, GstBuffer * buf)) I can see the buf size as 480x640x2. I allocated a new buffer equivalent to Full HD and copied this UYVY data on top of the new buffer and replaced the existing buffer. But output video is still height=480, width=640.
Here are the code snippet.
gst_plugin_template_chain (GstPad * pad, GstObject * parent, GstBuffer * buf)
{
GstPluginTemplate *filter;
GstMapInfo map;
guchar *data;
gint width = 640, height = 480;
GstMemory *mem;
int row = 0;
filter = GST_PLUGIN_TEMPLATE (parent);
gst_buffer_map (buf, &map, GST_MAP_READWRITE);
mem = gst_allocator_alloc(NULL, 4147200, NULL); //1080*1920*2 (Full HD UYVY) = 4147200
GstMapInfo info_out;
gst_memory_map(mem, &info_out, GST_MAP_WRITE);
for(int i = 0; i < 480 ; i++) {
memcpy(info_out.data + row, map.data + row, 1280);
row += 1280; //640*2
}
gst_buffer_replace_all_memory(buf, mem);
gst_buffer_unmap (buf, &map);
gst_memory_unmap(mem, &info_out);
return gst_pad_push (filter->srcpad, buf);
}
You need to send a new CAPS event downstream. Probably you want gst_event_new_caps()
and push it through the source pad. But double check the documentation about what you want exactly.