mpromonet / v4l2rtspserver

RTSP Server for V4L2 device capture supporting HEVC/H264/JPEG/VP8/VP9
The Unlicense
1.82k stars 423 forks source link

release resource problem #289

Closed peteeU closed 1 year ago

peteeU commented 1 year ago

Hi, thanks for your greate project, it is really help for me.

Here is your part of codes:

        V4L2DeviceParameters inParam(videoDev.c_str(), videoformatList, width, height, fps, ioTypeIn, verbose, openflags);
        StreamReplicator* videoReplicator = rtspServer.CreateVideoReplicator( inParam, queueSize, captureMode, repeatConfig,
                    output, ioTypeOut, out);
...
            StreamReplicator* audioReplicator = NULL;
#ifdef HAVE_ALSA
            audioReplicator = rtspServer.CreateAudioReplicator(audioDev, audioFmtList, audioFreq, audioNbChannels, verbose,
                    queueSize, captureMode);        
#endif

If i want to restart this process, and I found sometime the video is busy, I think I should do something when the process before quit. And I found that when did you release videoReplicator and audioReplicator ? I search all of project and not found. because I think this resource should be released when process stop. Thanks!

mpromonet commented 1 year ago

Hi @maohai

I made some modifications, and maybe this code may helps you https://github.com/mpromonet/v4l2camera/blob/master/src/v4l2web.cpp#L127, keeping v4l2 connection and recreate replicators (with updated format).

Best Regards, Michel.