예제 #1
0
        public bool OpenVideoChannel(LibMWCapture.MWCAP_CHANNEL_INFO channelInfo, UInt32 dwFourcc, int cx, int cy, UInt32 nFrameDuration, IntPtr hWnd)
        {
            // open video device
            ushort[] wpath  = new ushort[512];
            IntPtr   pwpath = GCHandle.Alloc(wpath, GCHandleType.Pinned).AddrOfPinnedObject();

            LibMWCapture.MWGetDevicePath(channelInfo.byChannelIndex, pwpath);

            Board        = channelInfo.byBoardIndex;
            ChannelIndex = channelInfo.byChannelIndex;

            VideoChannel = LibMWCapture.MWOpenChannelByPath(pwpath);
            if (VideoChannel == IntPtr.Zero)
            {
                return(false);
            }

            video_callback = new LibMWCapture.VIDEO_CAPTURE_STDCALLBACK(video_callback_sub);
            // create video renderer

            bool reverse = dwFourcc == MWCap_FOURCC.MWCAP_FOURCC_BGR24 || dwFourcc == MWCap_FOURCC.MWCAP_FOURCC_BGRA;

            D3DRenderer = LibMWMedia.MWCreateD3DRenderer(cx, cy, dwFourcc, reverse, hWnd);

            if (D3DRenderer == IntPtr.Zero)
            {
                return(false);
            }
            llCount     = 0;
            CurrentTime = RefTime = Libkernel32.GetTickCount();
            uint fourcc        = (uint)dwFourcc;
            int  frameduration = (int)nFrameDuration;

            Video = LibMWCapture.MWCreateVideoCaptureWithStdCallBack(VideoChannel, cx, cy, fourcc, frameduration, video_callback, D3DRenderer);

            if (Video == IntPtr.Zero)
            {
                return(false);
            }

            if (!InitAudioCapture())
            {
                // может быть без аудио если этот источник уже открыт
                //return false;
            }
            return(true);
        }
예제 #2
0
        public static LibMWCapture.MWCAP_CHANNEL_INFO?GetChannelInfoByIndex(int channelIndex)
        {
            RefreshDevices();
            var videoChannelCount = GetChannelCount();

            if (videoChannelCount == 0)
            {
                return(null);
            }

            for (int i = 0; i < videoChannelCount; i++)
            {
                LibMWCapture.MWCAP_CHANNEL_INFO channelInfo = new LibMWCapture.MWCAP_CHANNEL_INFO();
                GetChannelInfobyIndex(i, ref channelInfo);
                if (channelInfo.byChannelIndex == channelIndex)
                {
                    return(channelInfo);
                }
            }
            return(null);
        }
예제 #3
0
 public static void GetChannelInfobyIndex(int nChannelIndex, ref LibMWCapture.MWCAP_CHANNEL_INFO channelInfo)
 {
     channelInfo = PInvokeTools.ReadStruct <LibMWCapture.MWCAP_CHANNEL_INFO>(ptr =>
                                                                             LibMWCapture.MWGetChannelInfoByIndex(nChannelIndex, ptr));
 }