Esempio n. 1
0
        public IVideoSource Open(IVideoSourceConfig config, IVideoSourceType type, IntPtr hWnd)
        {
            if (config != null && config.Enabled)
            {
                IVideoSource vs = GetVideoSource(config.Name);
                if (vs == null)
                {
                    IVideoSourceFactory vsFactory = GetVideoSourceFactory(type);
                    if (vsFactory != null)
                    {
                        vs = vsFactory.CreateVideoSource(config, hWnd);
                        if (vs != null)
                        {
                            lock (mVideoSources.SyncRoot)
                            {
                                if (vs.Open(null))
                                {
                                    vs.OnPlayStatusChanged += new PLAYSTATUS_CHANGED(DoPlayStausChanged);
                                    vs.OnRecordProgress    += new RECORD_PROGRESS(DoRecordProgress);
                                    (vs as IKernelVideoSource).OnKernelStatus += new KERNELSTATUS_CHANGED(DoKernelStatus);

                                    mVideoSources.Add(vs.Name, vs);

                                    vs.RefreshState();
                                }
                                else
                                {
                                    return(null);
                                }
                            }
                        }
                    }
                }
                else
                {
                    if (hWnd != IntPtr.Zero)
                    {
                        vs.HWnd = hWnd;
                    }

                    if (!vs.IsOpen)
                    {
                        vs.Open(null);
                    }
                }
                return(vs);
            }
            return(null);
        }