diff --git a/apps/sample_apps/deepstream-test5/Makefile b/apps/sample_apps/deepstream-test5/Makefile index 5ca07ab..4af0d7a 100644 --- a/apps/sample_apps/deepstream-test5/Makefile +++ b/apps/sample_apps/deepstream-test5/Makefile @@ -46,7 +46,7 @@ OBJS:= $(SRCS:.c=.o) CFLAGS+= -I../../apps-common/includes -I../../../includes -I../deepstream-app/ -DDS_VERSION_MINOR=0 -DDS_VERSION_MAJOR=5 LIBS+= -L$(LIB_INSTALL_DIR) -lnvdsgst_meta -lnvds_meta -lnvdsgst_helper -lnvdsgst_smartrecord -lnvds_utils -lm \ - -lgstrtspserver-1.0 -ldl -Wl,-rpath,$(LIB_INSTALL_DIR) + -lgstrtspserver-1.0 -ldl -lnvbufsurface -Wl,-rpath,$(LIB_INSTALL_DIR) CFLAGS+= `pkg-config --cflags $(PKGS)` diff --git a/apps/sample_apps/deepstream-test5/deepstream_test5_app_main.c b/apps/sample_apps/deepstream-test5/deepstream_test5_app_main.c index 1e0c024..071431a 100644 --- a/apps/sample_apps/deepstream-test5/deepstream_test5_app_main.c +++ b/apps/sample_apps/deepstream-test5/deepstream_test5_app_main.c @@ -1047,6 +1047,47 @@ nvds_x_event_thread (gpointer data) return NULL; } +#include "nvbufsurface.h" + +void map_buffer_with_memleak(AppCtx* ctx, GstBuffer* buf) +{ + GstMapInfo in_map_info; + NvBufSurface *surface = NULL; + + if (buf == NULL) { + return; + } + + memset(&in_map_info, 0, sizeof(in_map_info)); + + if (gst_buffer_map(buf, &in_map_info, GST_MAP_READWRITE)) { + surface = (NvBufSurface *)in_map_info.data; + + if(NvBufSurfaceMap(surface, -1, -1, NVBUF_MAP_READ_WRITE)) { + g_print("Warning - Can't Map NvBufSurface.\n"); + gst_buffer_unmap(buf, &in_map_info); + return; + } + if(NvBufSurfaceSyncForCpu(surface, -1, -1)) { + g_print("Warning - Can't sync NvBufSurface for CPU.\n"); + NvBufSurfaceUnMap(surface, -1, -1); + gst_buffer_unmap(buf, &in_map_info); + return; + } + + //TODO: Draw something on surface + + NvBufSurfaceSyncForDevice(surface, -1, -1); + NvBufSurfaceUnMap(surface, -1, -1); + } else { + g_print("Could not map gst_buffer to opencv.\n"); + return; + } + + gst_buffer_unmap(buf, &in_map_info); + +} + /** * callback function to add application specific metadata. * Here it demonstrates how to display the URI of source in addition to @@ -1056,6 +1097,7 @@ static gboolean overlay_graphics (AppCtx * appCtx, GstBuffer * buf, NvDsBatchMeta * batch_meta, guint index) { + map_buffer_with_memleak(appCtx, buf); return TRUE; }