24 #ifndef __NVDSCUSTOMLIB_BASE_HPP__
25 #define __NVDSCUSTOMLIB_BASE_HPP__
27 #include <gst/base/gstbasetransform.h>
28 #include <gst/video/video.h>
61 GstCaps* in_caps, GstCaps* othercaps);
127 GstCaps* in_caps, GstCaps* othercaps)
129 GstCaps* result = NULL;
130 GstStructure *s1, *s2;
131 gint width = 0, height = 0;
132 gint num = 0, denom = 0;
133 const gchar *inputFmt = NULL;
135 GST_INFO_OBJECT (
m_element,
"\n----------\ndirection = %d (1=Src, 2=Sink) -> %s:\nCAPS = %s\n",
136 direction, __func__, gst_caps_to_string(in_caps));
137 GST_INFO_OBJECT (
m_element,
"%s : OTHERCAPS = %s\n", __func__, gst_caps_to_string(othercaps));
140 GST_INFO_OBJECT (nvdsvideotemplate,
"%s : CAPS = %" GST_PTR_FORMAT
"\n\n", __func__, in_caps);
141 GST_INFO_OBJECT (nvdsvideotemplate,
"%s : OTHER CAPS = %" GST_PTR_FORMAT
"\n\n", __func__, othercaps);
144 othercaps = gst_caps_truncate(othercaps);
145 othercaps = gst_caps_make_writable(othercaps);
150 s1 = gst_caps_get_structure(in_caps, 0);
151 s2 = gst_caps_get_structure(othercaps, 0);
153 inputFmt = gst_structure_get_string (s1,
"format");
154 gst_structure_get_int (s1,
"width", &width);
155 gst_structure_get_int (s1,
"height", &height);
158 g_print (
"InputFMT = %s \n\n", inputFmt);
164 gst_structure_fixate_field_nearest_int(s2,
"width", width);
165 gst_structure_fixate_field_nearest_int(s2,
"height", height);
166 if (gst_structure_get_fraction(s1,
"framerate", &num, &denom))
168 gst_structure_fixate_field_nearest_fraction(s2,
"framerate", num, denom);
171 gst_structure_remove_fields (s2,
"width",
"height",
"format", NULL);
175 gst_structure_set (s2,
"width", G_TYPE_INT, width,
176 "height", G_TYPE_INT, height,
177 "format", G_TYPE_STRING,
"NV12",
180 result = gst_caps_ref(othercaps);
183 gst_caps_unref(othercaps);
185 GST_INFO_OBJECT (
m_element,
"%s : Updated OTHERCAPS = %s \n\n", __func__, gst_caps_to_string(othercaps));
187 GST_INFO_OBJECT (nvdsvideotemplate,
"%s : CAPS = %" GST_PTR_FORMAT
"\n\n", __func__, othercaps);
188 GST_INFO_OBJECT(nvdsvideotemplate,
"CAPS fixate: %" GST_PTR_FORMAT
", direction %d",
197 GstBufferPool *m_buf_pool= NULL;
198 GstStructure *config = NULL;
202 config = gst_buffer_pool_get_config (m_buf_pool);
204 GST_INFO_OBJECT (m_element,
"in videoconvert caps = %" GST_PTR_FORMAT
"\n", outcaps);
207 gst_structure_set (config,
209 "gpu-id", G_TYPE_UINT, pool_config->
gpu_id,
210 "batch-size", G_TYPE_UINT, pool_config->
batch_size, NULL);
212 GST_INFO_OBJECT (m_element,
" %s Allocating Buffers in NVM Buffer Pool for Max_Views=%d\n",
216 if (!gst_buffer_pool_set_config (m_buf_pool, config)) {
217 GST_WARNING (
"bufferpool configuration failed");
221 gboolean is_active = gst_buffer_pool_set_active (m_buf_pool, TRUE);
223 GST_WARNING (
" Failed to allocate the buffers inside the output pool");
226 GST_DEBUG (
" Output buffer pool (%p) successfully created with %d buffers",
235 GstMapInfo in_map_info;
239 if (!gst_buffer_map (inbuf, &in_map_info, GST_MAP_READ)) {
240 GST_ELEMENT_ERROR (
m_element, STREAM, FAILED,
241 (
"%s:gst buffer map to get pointer to NvBufSurface failed", __func__), (NULL));
248 gst_buffer_unmap(inbuf, &in_map_info);
249 return nvbuf_surface;