[vlc-devel] libvlc_media_player_stop pending when try to stop one in two directshow instances

cong fu fc4976 at gmail.com
Tue Apr 16 11:30:05 CEST 2013


Hi:

I am a newbee for vlc developing, now I want to do such thing in my corrent
project:

a windows application, which can:
1. Show living show from an directshow usb device on screen forever
2. click a button to start to record the video into a mp4 file
3. click another button to stop recording the video, but the living show
should always there

to make it work, I created two VLC media player instances, one if for
living show on screen, the other is for recording into file, copy some code
here:

MyVLCPlayer.cs

        public MyVLCPlayer()
        {
            string[] arguments = { "-I", "dummy", "--ignore-config",
"--no-video-title", @"--plugin-path=C:\Program Files
(x86)\VideoLAN\VLC\plugins" };
            libvlc_instance_ = LibVlc.libvlc_new(arguments.Length,
arguments);
            if (libvlc_instance_ != IntPtr.Zero)
            {
                libvlc_media_player_ =
LibVlc.libvlc_media_player_new(libvlc_instance_);
            }
        }

        public void PlayDirectShow()
        {
            if (libvlc_instance_ != IntPtr.Zero)
            {
                IntPtr libvlc_media =
LibVlc.libvlc_media_new_path(libvlc_instance_, @"dshow://");
                if (libvlc_media != IntPtr.Zero)
                {
                        string[] options = new string[]
                        {
                    ":dshow-vdev=USB 2861 Device",
                            ":dshow-size=640*480",

                        };
                        foreach (string option in options)
                        {
                            LibVlc.libvlc_media_add_option(libvlc_media,
option);
                        }
                        if (libvlc_media_player_ != IntPtr.Zero)
                        {

LibVlc.libvlc_media_player_set_media(libvlc_media_player_, libvlc_media);
                        }
                        LibVlc.libvlc_media_release(libvlc_media);

LibVlc.libvlc_media_player_play(libvlc_media_player_);

//LibVlc.libvlc_media_player_pause(libvlc_media_player_);
                }
            }
        }
        public void RecordDirectShow(string filePath)
        {
            if (libvlc_instance_ != IntPtr.Zero)
            {
                IntPtr libvlc_media =
LibVlc.libvlc_media_new_path(libvlc_instance_, @"dshow://");
                if (libvlc_media != IntPtr.Zero)
                {
                    string[] options = new string[]
                        {
                    ":dshow-vdev=USB 2861 Device",
                            ":dshow-size=640*480",


":sout=#duplicate{dst=\'transcode{venc=x264{keyint=15,bframes=0},vcodec=h264,vb=400,scale=1,fps=25,acodec=mp3,ab=128,channels=2,samplerate=44100}:std{access=file,mux=mp4,dst="
+ filePath + "}\'}"
                        };
                    foreach (string option in options)
                    {
                        LibVlc.libvlc_media_add_option(libvlc_media,
option);
                    }
                    if (libvlc_media_player_ != IntPtr.Zero)
                    {

LibVlc.libvlc_media_player_set_media(libvlc_media_player_, libvlc_media);
                    }
                    LibVlc.libvlc_media_release(libvlc_media);
                    LibVlc.libvlc_media_player_play(libvlc_media_player_);

//LibVlc.libvlc_media_player_pause(libvlc_media_player_);
                }
            }
        }

MainWindow.xaml.cs

private MyVLCPlayer player;
        private MyVLCPlayer recorder;

        public MainWindow()
        {
            InitializeComponent();
....
player = new MyVLCPlayer();
            recorder = new MyVLCPlayer();
....

        }

 Then,

1. player. PlayDirectShow();
2. recorder.RecordDirectShow(filepath);
3. recorder.Stop();

the stop will never return!!

can someone tell me why?
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mailman.videolan.org/pipermail/vlc-devel/attachments/20130416/6dc065e0/attachment.html>


More information about the vlc-devel mailing list