0

I'm using Stylet as MVVM framework and LibVLCSharp.WPF 3.6.5 + VideoLAN.LibVLC.Windows 3.0.16 in my project for streaming camera rtsp streams. VideoView is included in my VLCPLayer custom user control, and that control is exposed as a property in my view model. I don't know if this is a good thing, but in this way I managed to make some kind of custom full screen video with custom buttons. Everything works fine until I try to close player, or better to say try to dispose VideoView. I have something like this:

public void Dispose()
{
    //these are custom events in my user control
    VlcPlayer.ClosePlayer -= ClosePlayer;
    VlcPlayer.RestorePlayer -= RestorePlayer;
    VlcPlayer.MinimizePlayer -= MinimizePlayer;
    //here I try to dispose player and VideoView
    VlcPlayer.VideoView.MediaPlayer.Stop();
    VlcPlayer.VideoView.MediaPlayer.Media.Dispose();        
    VlcPlayer.VideoView.MediaPlayer.Dispose();
    //here I'm getting Access Violation Exception
    VlcPlayer.VideoView.Dispose();
}

If I don't dispose VideoView it remains in memory and every time I start new stream new VideoView is added to memory, so if I opened and closed one stream and then opened the same or whatever stream, I'll have in memory 2 VideoViews instead of one. I have to release memory of unused VideoViews and players since application will be used for some kind of surveillance, so it will have lot of streams at the same time opened, and lot of VideoViews opened. Here I found similar issue, but it was reportedly solved updating to newest version of LibVLCSharp, but my version is newer than from mentioned post and I still have similar problem. I'd appreciate any kind of help on this issue. Thanks.

  • is this related to this known issue? https://code.videolan.org/videolan/LibVLCSharp/-/issues/214 – cube45 Feb 22 '22 at 06:13
  • @cube45 - I wouldn't say, this is happening when I try to close window with video. Video is displayed in full screen with custom buttons for closing, minimizing and restoring the window, and button for sending video to surveillance window where I have random number of streaming videos. When I send video to surveillance window, I call above Dispose(), and then I'm opening new one in surveillance window. Every time when I try to close video I get this exception. Also, LibVLC is singleton, but I had to this - public class LibVLCSingleton : LibVLC { }, so Stylet's IOC can make it singleton – novikorisnik Feb 22 '22 at 13:37
  • Probably this root cause : https://code.videolan.org/videolan/vlc/-/issues/22648 – cube45 Feb 22 '22 at 15:55
  • hm, maybe, but I have the same issue when I open just one window with video stream and when I want to close it, without opening a new one...I'm short with time and it'll be quite tricky, but I'll try to make minimal example that will reproduce this exception – novikorisnik Feb 22 '22 at 16:19
  • the native lib that handles RTSP support in libvlc is not thread safe. That being said, feel free to open an issue on our gitlab so we can have a look (please fill in the template) – mfkl Feb 23 '22 at 05:42
  • @mfkl - I've opened the issue on gitlab with example code https://code.videolan.org/videolan/LibVLCSharp/-/issues/537 – novikorisnik Feb 23 '22 at 10:23

0 Answers0