Run time switch video decode type(h264, jpeg) gstreamer pipeline sometime crash

I first use gst_element_set_state NULL , then unlink eliment, make new element, link them, gst_element_set_state play.
my pipeline is appsrc->queue->h264parse/jpegparse->nvv4l2decoder.
I want to change h264 or jpeg type in runtime, but some wrong occurs sometimes, such as:

ERROR from element vdec-jpegparse: Can’t set caps to the src pad
Error details: gstjpegparse.c(836): gst_jpeg_parse_handle_frame (): /GstPipeline:media-pipeline/GstBin:vdec_subbin0/GstJpegParse:vdec-jpegparse:
Can’t set caps to the src pad

ERROR from element vdec-appsrc: Internal data stream error.
Error details: gstbasesrc.c(3055): gst_base_src_loop (): /GstPipeline:media-pipeline/GstBin:vdec_subbin3/GstAppSrc:vdec-appsrc:
streaming stopped, reason error (-5)
ERROR from element vdec-queue: Internal data stream error.
Error details: gstqueue.c(988): gst_queue_handle_sink_event (): /GstPipeline:media-pipeline/GstBin:vdec_subbin3/GstQueue:vdec-queue:
streaming stopped, reason error (-5)

We would suggest re-initialize the pipeline. Changing state to NULL and switching between H264/JPEG is not verified and may not work properly. If you would like to do further check on the case, you may download the source code of nvv4l2decoder(gst-nvvideo4linux2_src.tbz2) and rebuild with debug prints. The source code is in

run time switch between h264/h265/mjpeg is request for our product application. this is convenient for user in nvr application scene. so can nvidia support this request?

recently frequently switch h264/h265/mjpeg occur segmetation fault, such as

[Thread debugging using libthread_db enabled]
Using host libthread_db library “/lib/aarch64-linux-gnu/”.
Core was generated by `./build/apps/anfang_app/anfang_app’.
Program terminated with signal SIGSEGV, Segmentation fault.
#0 malloc_consolidate (av=av@entry=0x7f14000020) at malloc.c:4469
4469 malloc.c: No such file or directory.
[Current thread is 1 (Thread 0x7e2cfc9830 (LWP 12179))]
(gdb) bt
#0 0x0000007f89598ac0 in malloc_consolidate (av=av@entry=0x7f14000020) at malloc.c:4469
#1 0x0000007f8959ba70 in _int_malloc (av=av@entry=0x7f14000020, bytes=bytes@entry=32816) at malloc.c:3713
#2 0x0000007f8959d3a4 in __GI___libc_malloc (bytes=32816) at malloc.c:3075
#3 0x0000007f895c3314 in __alloc_dir (fd=164, close_fd=true, flags=, statp=0x7e2cfc74b8) at …/sysdeps/posix/opendir.c:216
#4 0x0000007f895c3410 in opendir_tail (fd=164) at …/sysdeps/posix/opendir.c:136
#5 0x0000007f895debe4 in glob_in_dir (pattern=pattern@entry=0x7f50412d4d “.so", directory=directory@entry=0x7e2cfc7880 “/usr/lib/aarch64-linux-gnu/libv4l/plugins/nv”, flags=flags@entry=0, errfunc=errfunc@entry=0x0, pglob=pglob@entry=0x7e2cfc7e58, alloca_used=541920622352, alloca_used@entry=45) at …/posix/glob.c:1313
#6 0x0000007f89632390 in __glob_lstat_compat (pattern=0x7f50412d20 "/usr/lib/aarch64-linux-gnu/libv4l/plugins/nv/
.so”, flags=0, errfunc=0x0, pglob=0x7e2cfc7e58)
at …/posix/glob.c:1097
#7 0x0000007f504119e8 in () at /usr/lib/aarch64-linux-gnu/tegra/
#8 0x0000007f5040d6c0 in v4l2_fd_open () at /usr/lib/aarch64-linux-gnu/tegra/
#9 0x0000007f5055e840 in () at /usr/lib/aarch64-linux-gnu/gstreamer-1.0/
#10 0x0000007f5054d494 in () at /usr/lib/aarch64-linux-gnu/gstreamer-1.0/
#11 0x0000007f50557178 in () at /usr/lib/aarch64-linux-gnu/gstreamer-1.0/
#12 0x0000007f8afa969c in () at /usr/lib/aarch64-linux-gnu/
#13 0x0000007f8ae94f48 in () at /usr/lib/aarch64-linux-gnu/

Currently we don’t have plan to support this usecase in default releases. Since it is open source, you can do customization and implement the usecase.

base on gstreamer operator, can give some constructive suggests,crediblely finish the operater of decode type switch ? thanks