|
有关本地视频摄像头的枚举,请参考如下的代码:- int iDeviceCount = -1;
- IntPtr[] lpDevicePtrs;
- // 枚举系统所有的视频设备
- int ret = AnyChatCoreSDK.EnumVideoCapture(null, ref iDeviceCount);
- if(ret != 0 || iDeviceCount == 0)
- return;
- lpDevicePtrs = new IntPtr[iDeviceCount];
- ret = AnyChatCoreSDK.EnumVideoCapture(lpDevicePtrs, ref iDeviceCount);
- cbxCamera.Items.Clear();
- foreach (IntPtr p in lpDevicePtrs)
- {
- string device = Marshal.PtrToStringAnsi(p); // 如果是Unicode版本,需要使用:Marshal.PtrToStringUni(p);
- if (string.IsNullOrEmpty(device) == false)
- {
- cbxCamera.Text = device;
- cbxCamera.Items.Add(device);
- }
- }
- // 获取当前视频采集设备
- StringBuilder sb = new StringBuilder(1024);
- AnyChatCoreSDK.GetCurVideoCapture(sb, sb.Capacity);
- if (string.IsNullOrEmpty(sb.ToString()) == false)
- cbxCamera.Text = sb.ToString();
- else if (cbxCamera.Items.Count > 0)
- cbxCamera.Text = cbxCamera.Items[0].ToString();
复制代码 |
|