23 #ifndef __NVDSCUSTOMLIB_BASE_HPP__
24 #define __NVDSCUSTOMLIB_BASE_HPP__
26 #include <gst/base/gstbasetransform.h>
27 #include <gst/video/video.h>
60 GstCaps* in_caps, GstCaps* othercaps);
126 GstCaps* in_caps, GstCaps* othercaps)
128 GstCaps* result = NULL;
129 GstStructure *s1, *s2;
130 gint width = 0, height = 0;
131 gint num = 0, denom = 0;
132 const gchar *inputFmt = NULL;
134 GST_INFO_OBJECT (
m_element,
"\n----------\ndirection = %d (1=Src, 2=Sink) -> %s:\nCAPS = %s\n",
135 direction, __func__, gst_caps_to_string(in_caps));
136 GST_INFO_OBJECT (
m_element,
"%s : OTHERCAPS = %s\n", __func__, gst_caps_to_string(othercaps));
139 GST_INFO_OBJECT (nvdsvideotemplate,
"%s : CAPS = %" GST_PTR_FORMAT
"\n\n", __func__, in_caps);
140 GST_INFO_OBJECT (nvdsvideotemplate,
"%s : OTHER CAPS = %" GST_PTR_FORMAT
"\n\n", __func__, othercaps);
143 othercaps = gst_caps_truncate(othercaps);
144 othercaps = gst_caps_make_writable(othercaps);
149 s1 = gst_caps_get_structure(in_caps, 0);
150 s2 = gst_caps_get_structure(othercaps, 0);
152 inputFmt = gst_structure_get_string (s1,
"format");
153 gst_structure_get_int (s1,
"width", &width);
154 gst_structure_get_int (s1,
"height", &height);
157 g_print (
"InputFMT = %s \n\n", inputFmt);
163 gst_structure_fixate_field_nearest_int(s2,
"width", width);
164 gst_structure_fixate_field_nearest_int(s2,
"height", height);
165 if (gst_structure_get_fraction(s1,
"framerate", &num, &denom))
167 gst_structure_fixate_field_nearest_fraction(s2,
"framerate", num, denom);
170 gst_structure_remove_fields (s2,
"width",
"height",
"format", NULL);
174 gst_structure_set (s2,
"width", G_TYPE_INT, width,
175 "height", G_TYPE_INT, height,
176 "format", G_TYPE_STRING,
"NV12",
179 result = gst_caps_ref(othercaps);
182 gst_caps_unref(othercaps);
184 GST_INFO_OBJECT (
m_element,
"%s : Updated OTHERCAPS = %s \n\n", __func__, gst_caps_to_string(othercaps));
186 GST_INFO_OBJECT (nvdsvideotemplate,
"%s : CAPS = %" GST_PTR_FORMAT
"\n\n", __func__, othercaps);
187 GST_INFO_OBJECT(nvdsvideotemplate,
"CAPS fixate: %" GST_PTR_FORMAT
", direction %d",
196 GstBufferPool *m_buf_pool= NULL;
197 GstStructure *config = NULL;
201 config = gst_buffer_pool_get_config (m_buf_pool);
203 GST_INFO_OBJECT (m_element,
"in videoconvert caps = %" GST_PTR_FORMAT
"\n", outcaps);
206 gst_structure_set (config,
208 "gpu-id", G_TYPE_UINT, pool_config->
gpu_id,
209 "batch-size", G_TYPE_UINT, pool_config->
batch_size, NULL);
211 GST_INFO_OBJECT (m_element,
" %s Allocating Buffers in NVM Buffer Pool for Max_Views=%d\n",
215 if (!gst_buffer_pool_set_config (m_buf_pool, config)) {
216 GST_WARNING (
"bufferpool configuration failed");
220 gboolean is_active = gst_buffer_pool_set_active (m_buf_pool, TRUE);
222 GST_WARNING (
" Failed to allocate the buffers inside the output pool");
225 GST_DEBUG (
" Output buffer pool (%p) successfully created with %d buffers",
234 GstMapInfo in_map_info;
238 if (!gst_buffer_map (inbuf, &in_map_info, GST_MAP_READ)) {
239 GST_ELEMENT_ERROR (
m_element, STREAM, FAILED,
240 (
"%s:gst buffer map to get pointer to NvBufSurface failed", __func__), (NULL));
247 gst_buffer_unmap(inbuf, &in_map_info);
248 return nvbuf_surface;