yes,always the same test code from the topic,just
modify the pipeline element,it will occure crash and memory leak problem[Camera liveview cannot show up again after repeated open/close the liveview for several times - #23 by DaneLLL]
libv4l2_nvargus have renamed;
huilian@huilian-desktop:~/xxw/rtp-send$ head -n 1 /etc/nv_tegra_release
R32 (release), REVISION: 5.0, GCID: 25531747, BOARD: t186ref, EABI: aarch64, DATE: Fri Jan 15 23:21:05 UTC 2021
huilian@huilian-desktop:~/xxw/rtp-send$ sudo find / -name libv4l2_nvargus*
[sudo] password for huilian:
find: ‘/run/user/1000/gvfs’: Permission denied
/usr/lib/aarch64-linux-gnu/tegra/libv4l2_nvargusbak.so
/usr/lib/aarch64-linux-gnu/libv4l/plugins/nv/libv4l2_nvargusbak1.so
find: ‘/proc/7481/task/7481/net’: Invalid argument
find: ‘/proc/7481/net’: Invalid argument
huilian@huilian-desktop:~/xxw/rtp-send$
test code & gcc
huilian@huilian-desktop:~/xxw/test1$ ls
a.out test.cpp
huilian@huilian-desktop:~/xxw/test1$ cat test.cpp
#include
#include
#include
#include <gst/gst.h>
using namespace std;
#define USE(x) ((void)(x))
static GstPipeline *gst_pipeline = nullptr;
static string launch_string;
GstClockTime usec = 1000000;
int main(int argc, char** argv) {
USE(argc);
USE(argv);
gst_init (&argc, &argv);
GMainLoop *main_loop;
main_loop = g_main_loop_new (NULL, FALSE);
ostringstream launch_stream;
GstBus* bus=NULL;
gboolean res;
//mem leak test1
#if 1
launch_stream
<< "videotestsrc is-live=1 ! "
<< "video/x-raw,width=1280,height=960,format=YUY2,framerate=30/1 ! "
<< "nvvidconv ! video/x-raw(memory:NVMM),format=I420,width=1280,height=960,framerate=30/1 ! "
<< “nvv4l2h265enc ! fakesink sync=false async=false”;
#endif
//mem leak test2
#if 0
launch_stream
<< "videotestsrc is-live=1 ! "
<< "video/x-raw,width=1280,height=960,format=YUY2,framerate=30/1 ! "
<< "nvvidconv ! video/x-raw(memory:NVMM),format=I420,width=1280,height=960,framerate=30/1 ! "
<< “omxh265enc ! fakesink sync=false async=false”;
#endif
//mem leak test3
#if 0
launch_stream
<< "videotestsrc is-live=1 ! "
<< "video/x-raw,width=1280,height=960,format=YUY2,framerate=30/1 ! "
<< "nvvidconv ! video/x-raw(memory:NVMM),format=I420,width=1280,height=960,framerate=30/1 ! "
<< “fakesink sync=false async=false”;
#endif
launch_string = launch_stream.str();
g_print("Using launch string: %s\n", launch_string.c_str());
GError *error = nullptr;
for(guint i=0; i<20000; i++) {
printf("loop= %d\n", i);
gst_pipeline = (GstPipeline*) gst_parse_launch(launch_string.c_str(), &error);
if (gst_pipeline == nullptr) {
printf("Failed to parse launch: %s\n", error->message);
return -1;
}
if(error)
{
printf("Parse error[%d]\n",i);
g_error_free(error);
}
printf("Set playing[%d]\n",i);
gst_element_set_state((GstElement*)gst_pipeline, GST_STATE_PLAYING);
g_usleep(3*usec);
printf("Send Eos[%d]\n",i);
res=gst_element_send_event ((GstElement*)gst_pipeline, gst_event_new_eos ());
if(!res)
{
printf("eos signal send failed\n");
}
else
{
printf("eos signal send success\n");
}
printf("get bus[%d]\n",i);
bus = gst_pipeline_get_bus(GST_PIPELINE(gst_pipeline));
printf("bus poll start[%d]\n",i);
gst_bus_poll(bus, GST_MESSAGE_EOS, GST_CLOCK_TIME_NONE);
printf("bus poll end &Set NULL[%d]\n",i);
gst_element_set_state((GstElement*)gst_pipeline, GST_STATE_NULL);
printf("Set unref[%d]\n",i);
gst_object_unref(GST_OBJECT(gst_pipeline));
gst_object_unref (bus);
gst_pipeline=NULL;
bus=NULL;
g_usleep(1*usec);
fflush(stdout);
}
g_main_loop_unref(main_loop);
g_print("going to exit \n");
return 0;
}
huilian@huilian-desktop:~/xxw/test1$ g++ -g test.cpp pkg-config --cflags --libs gstreamer-1.0
huilian@huilian-desktop:~/xxw/test1$