private int GetCamera() { try { UserConfigBusiness conf = new UserConfigBusiness(); int iSizeSTDeviceParam = Marshal.SizeOf(typeof(STDeviceParam)); byte[] pSTDeviceParam = new byte[iSizeSTDeviceParam]; UCServiceRetvCode iRet = (UCServiceRetvCode)conf.GetCurrentVideoDev(pSTDeviceParam); if (iRet == UCServiceRetvCode.UC_SDK_Success) { IntPtr tempInfoIntPtr = Marshal.AllocHGlobal(iSizeSTDeviceParam); Marshal.Copy(pSTDeviceParam, 0, tempInfoIntPtr, (int)iSizeSTDeviceParam); STDeviceParam head = (STDeviceParam)Marshal.PtrToStructure(tempInfoIntPtr, typeof(STDeviceParam)); if (head.index < 0) { return(0); } else { return(head.index); } } else { return(0); } } catch (Exception ex) { LogManager.SystemLog.Error(ex.ToString()); return(0); } }
/// <summary> /// 加载系统设备 /// </summary> void LoadSystDve() { UserConfigBusiness conf = new UserConfigBusiness(); int iSizeSTDeviceListParam = Marshal.SizeOf(typeof(STDeviceListParam)); int iSizeSTDeviceParam = Marshal.SizeOf(typeof(STDeviceParam)); int iBufSize = (iSizeSTDeviceListParam + iSizeSTDeviceParam * (count - 1)); byte[] pSTDeviceList = new byte[iBufSize]; UCServiceRetvCode iRet = (UCServiceRetvCode)conf.GetMicDevList(0, 9, iBufSize, pSTDeviceList); Dictionary <int, string> dicMicrophone = new Dictionary <int, string>(); if (iRet == UCServiceRetvCode.UC_SDK_Success) { IntPtr tempInfoIntPtr = Marshal.AllocHGlobal((int)iSizeSTDeviceListParam); byte[] tempInfoByte = new byte[iSizeSTDeviceListParam]; Marshal.Copy(pSTDeviceList, 0, tempInfoIntPtr, (int)iSizeSTDeviceListParam); STDeviceListParam head = (STDeviceListParam)Marshal.PtrToStructure(tempInfoIntPtr, typeof(STDeviceListParam)); for (int i = -1; i < head.iTotal - 1 && i < count - 1; i++) { Marshal.Copy(pSTDeviceList, iSizeSTDeviceListParam + iSizeSTDeviceParam * i, tempInfoIntPtr, (int)iSizeSTDeviceParam); STDeviceParam item = (STDeviceParam)Marshal.PtrToStructure(tempInfoIntPtr, typeof(STDeviceParam)); dicMicrophone.Add(item.index, item.name); } Marshal.Release(tempInfoIntPtr); } winOptionSetting.comMicrophone.ItemsSource = dicMicrophone; winOptionSetting.comMicrophone.SelectedValuePath = "Key"; winOptionSetting.comMicrophone.DisplayMemberPath = "Value"; winOptionSetting.comMicrophone.SelectedIndex = 0; pSTDeviceList = new byte[iBufSize]; iRet = (UCServiceRetvCode)conf.GetSpeakerDevList(0, 9, iBufSize, pSTDeviceList); Dictionary <int, string> dicSpeakerDev = new Dictionary <int, string>(); if (iRet == UCServiceRetvCode.UC_SDK_Success) { IntPtr tempInfoIntPtr = Marshal.AllocHGlobal((int)iSizeSTDeviceListParam); byte[] tempInfoByte = new byte[iSizeSTDeviceListParam]; Marshal.Copy(pSTDeviceList, 0, tempInfoIntPtr, (int)iSizeSTDeviceListParam); STDeviceListParam head = (STDeviceListParam)Marshal.PtrToStructure(tempInfoIntPtr, typeof(STDeviceListParam)); for (int i = -1; i < head.iTotal - 1 && i < count - 1; i++) { Marshal.Copy(pSTDeviceList, iSizeSTDeviceListParam + iSizeSTDeviceParam * i, tempInfoIntPtr, (int)iSizeSTDeviceParam); STDeviceParam item = (STDeviceParam)Marshal.PtrToStructure(tempInfoIntPtr, typeof(STDeviceParam)); dicSpeakerDev.Add(item.index, item.name); } Marshal.Release(tempInfoIntPtr); } winOptionSetting.comSpeaker.ItemsSource = dicSpeakerDev; winOptionSetting.comSpeaker.SelectedValuePath = "Key"; winOptionSetting.comSpeaker.DisplayMemberPath = "Value"; winOptionSetting.comSpeaker.SelectedIndex = 0; pSTDeviceList = new byte[iBufSize]; iRet = (UCServiceRetvCode)conf.GetVideoDevList(0, 9, iBufSize, pSTDeviceList); Dictionary <int, string> dicVideoDev = new Dictionary <int, string>(); if (iRet == UCServiceRetvCode.UC_SDK_Success) { IntPtr tempInfoIntPtr = Marshal.AllocHGlobal((int)iSizeSTDeviceListParam); byte[] tempInfoByte = new byte[iSizeSTDeviceListParam]; Marshal.Copy(pSTDeviceList, 0, tempInfoIntPtr, (int)iSizeSTDeviceListParam); STDeviceListParam head = (STDeviceListParam)Marshal.PtrToStructure(tempInfoIntPtr, typeof(STDeviceListParam)); for (int i = -1; i < head.iTotal - 1 && i < count - 1; i++) { Marshal.Copy(pSTDeviceList, iSizeSTDeviceListParam + iSizeSTDeviceParam * i, tempInfoIntPtr, (int)iSizeSTDeviceParam); STDeviceParam item = (STDeviceParam)Marshal.PtrToStructure(tempInfoIntPtr, typeof(STDeviceParam)); dicVideoDev.Add(item.index, item.name); } Marshal.Release(tempInfoIntPtr); } winOptionSetting.comCamera.ItemsSource = dicVideoDev; winOptionSetting.comCamera.SelectedValuePath = "Key"; winOptionSetting.comCamera.DisplayMemberPath = "Value"; winOptionSetting.comCamera.SelectedIndex = 0; }