public static LibMWCapture.MWCAP_VIDEO_SIGNAL_STATUS?GetSignalStatus(int channelIndex, out LibMWCapture.MWCAP_AUDIO_VOLUME? audioStatus) { audioStatus = null; ushort[] wpath = new ushort[512]; IntPtr pwpath = GCHandle.Alloc(wpath, GCHandleType.Pinned).AddrOfPinnedObject(); LibMWCapture.MWGetDevicePath(channelIndex, pwpath); var videoChannel = LibMWCapture.MWOpenChannelByPath(pwpath); if (videoChannel == IntPtr.Zero) { return(null); } try { audioStatus = PInvokeTools.ReadStruct <LibMWCapture.MWCAP_AUDIO_VOLUME>(ptr => LibMWCapture.MWGetAudioVolume(videoChannel, LibMWCapture.MWCAP_AUDIO_NODE.MWCAP_AUDIO_EMBEDDED_CAPTURE, ptr)); return(PInvokeTools.ReadStruct <LibMWCapture.MWCAP_VIDEO_SIGNAL_STATUS>( ptr => LibMWCapture.MWGetVideoSignalStatus(videoChannel, ptr))); } finally { LibMWCapture.MWCloseChannel(videoChannel); } }
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); }