Ejemplo n.º 1
0
 /// <summary>
 /// 设备回调
 /// </summary>
 private static void AddDeviceCallbackF(int deviceType, IntPtr deviceHandlePtr, IntPtr deviceNamePtr)
 {
     if (deviceType <= (int)DeviceType.MONITOR)
     {
         var deviceHandle = IntPtrHelper.IntPtrToUTF8string(deviceHandlePtr);
         var deviceName   = IntPtrHelper.IntPtrToUTF8string(deviceNamePtr);
         log.Info("AddDeviceCallback: deviceType:" + deviceType + "  deviceHandle:" + deviceHandle + "  deviceName:" + deviceName);
         var device = new QLDevice((DeviceType)deviceType, deviceHandle, deviceName);
         deviceManager.AddDevice(device);
     }
     else
     {
         throw new Exception(string.Format("DeviceType:{0} 设备不支持", deviceType));
     }
 }
Ejemplo n.º 2
0
        /// <summary>
        /// 添加设备
        /// </summary>
        /// <param name="device">设备</param>
        internal void AddDevice(QLDevice device)
        {
            if (device.DeviceName.Contains("none"))
            {
                return;
            }
            if (!ContainDevice(device.DeviceHandle))
            {
                devices.Add(device);
                switch (device.DeviceType)
                {
                case DeviceType.AUDIOINPUT:
                case DeviceType.AUDIOOUTPUT:
                {
                    var audioInput   = GetDevicesByType(DeviceType.AUDIOINPUT).FirstOrDefault();
                    var audioOutput  = GetDevicesByType(DeviceType.AUDIOOUTPUT).FirstOrDefault();
                    var inputHandle  = audioInput?.DeviceHandle;
                    var outputHandle = audioOutput?.DeviceHandle;
                    if (null == CurrentAudioInputDevice && null != audioInput)
                    {
                        CurrentAudioInputDevice = audioInput;
                    }
                    if (null == CurrentAudioOutputDevice && null != outputHandle)
                    {
                        CurrentAudioOutputDevice = audioOutput;
                    }
                }
                break;

                case DeviceType.VIDEOINPUT:
                {
                    if (null == CurrentAudioOutputDevice)
                    {
                        var video       = GetDevicesByType(DeviceType.VIDEOINPUT).FirstOrDefault();
                        var videoHandle = video?.DeviceHandle;
                        if (null != videoHandle)
                        {
                            CurrentVideoInputDevice = video;
                        }
                    }
                }
                break;
                }
            }
        }
Ejemplo n.º 3
0
        /// <summary>
        /// 移除设备
        /// </summary>
        /// <param name="device">设备</param>
        internal void RemoveDevice(QLDevice device)
        {
            if (null != device)
            {
                devices.Remove(device);
                switch (device.DeviceType)
                {
                case DeviceType.AUDIOINPUT:
                    CurrentAudioInputDevice = GetDevicesByType(DeviceType.AUDIOINPUT).FirstOrDefault();
                    break;

                case DeviceType.AUDIOOUTPUT:
                    CurrentAudioInputDevice = GetDevicesByType(DeviceType.AUDIOOUTPUT).FirstOrDefault();
                    break;

                case DeviceType.VIDEOINPUT:
                    CurrentAudioInputDevice = GetDevicesByType(DeviceType.VIDEOINPUT).FirstOrDefault();
                    break;
                }
            }
        }
Ejemplo n.º 4
0
        private static void DoEvent(object state)
        {
            var evt = state as QLEvent;

            if (null == evt)
            {
                return;
            }
            log.Info(string.Format("EventType:{0},CallHandle:{1}", evt.EventType, evt.CallHandle));
            switch (evt.EventType)
            {
                #region QLDevice
            case EventType.DEVICE_VIDEOINPUTCHANGED:
            {
                string deviceName   = evt.PlugDeviceName;
                string deviceHandle = evt.DeviceHandle;
                if (string.IsNullOrWhiteSpace(deviceName) ||
                    string.IsNullOrWhiteSpace(deviceHandle))
                {
                    return;
                }
                if (true == evt.PlugDeviceStatus)
                {           /*plug in a device*/
                    var device = new QLDevice(DeviceType.VIDEOINPUT, deviceHandle, deviceName);
                    deviceManager.AddDevice(device);
                }
                else
                {
                    deviceManager.RemoveDevice(deviceHandle);
                }
            }
            break;           /* from MP */

            case EventType.DEVICE_AUDIOINPUTCHANGED:
            {
                string deviceName   = evt.PlugDeviceName;
                string deviceHandle = evt.DeviceHandle;
                if (string.IsNullOrWhiteSpace(deviceName) ||
                    string.IsNullOrWhiteSpace(deviceHandle))
                {
                    return;
                }
                if (true == evt.PlugDeviceStatus)
                {           /*plug in a device*/
                    var device = new QLDevice(DeviceType.AUDIOINPUT, deviceHandle, deviceName);
                    deviceManager.AddDevice(device);
                }
                else
                {
                    deviceManager.RemoveDevice(deviceHandle);
                }
            }
            break;          /* from MP */

            case EventType.DEVICE_AUDIOOUTPUTCHANGED:
            {
                string deviceName   = evt.PlugDeviceName;
                string deviceHandle = evt.DeviceHandle;
                if (string.IsNullOrWhiteSpace(deviceName) ||
                    string.IsNullOrWhiteSpace(deviceHandle))
                {
                    return;
                }
                if (true == evt.PlugDeviceStatus)
                {           /*plug in a device*/
                    var device = new QLDevice(DeviceType.AUDIOOUTPUT, deviceHandle, deviceName);
                    deviceManager.AddDevice(device);
                }
                else
                {
                    deviceManager.RemoveDevice(deviceHandle);
                }
            }
            break;                                      /* from MP */

            case EventType.DEVICE_VOLUMECHANGED: break; /* from MP */

            case EventType.DEVICE_MONITORINPUTSCHANGED:
            {
                string deviceName   = evt.PlugDeviceName;
                string deviceHandle = evt.DeviceHandle;
                if (string.IsNullOrWhiteSpace(deviceName) ||
                    string.IsNullOrWhiteSpace(deviceHandle))
                {
                    return;
                }
                if (true == evt.PlugDeviceStatus)
                {           /*plug in a device*/
                    var device = new QLDevice(DeviceType.MONITOR, deviceHandle, deviceName);
                    deviceManager.AddDevice(device);
                }
                else
                {
                    deviceManager.RemoveDevice(deviceHandle);
                }
            }
            break;          /* from MP */
                #endregion

                #region Register
            case EventType.UNKNOWN: break;

            case EventType.SIP_REGISTER_SUCCESS:
            {
                QLManager.GetInstance().isRegisted = true;
            }
            break;

            case EventType.SIP_REGISTER_FAILURE:
            {
                QLManager.GetInstance().isRegisted = false;
            }
            break;

            case EventType.SIP_REGISTER_UNREGISTERED: break;
                #endregion
                #region  处理

                /*
                 #region Call
                 * case EventType.SIP_CALL_INCOMING: break;
                 * case EventType.SIP_CALL_TRYING:break;
                 * case EventType.SIP_CALL_RINGING:break;
                 * case EventType.SIP_CALL_FAILURE:break;
                 * case EventType.SIP_CALL_CLOSED:break;
                 * case EventType.SIP_CALL_HOLD:break;
                 * case EventType.SIP_CALL_HELD:break;
                 * case EventType.SIP_CALL_DOUBLE_HOLD:break;
                 * case EventType.SIP_CALL_UAS_CONNECTED:break;
                 * case EventType.SIP_CALL_UAC_CONNECTED:break;
                 #endregion
                 #region Content
                 * case EventType.SIP_CONTENT_INCOMING:break;
                 * case EventType.SIP_CONTENT_CLOSED:break;
                 * case EventType.SIP_CONTENT_SENDING:break;
                 * case EventType.SIP_CONTENT_IDLE:break;
                 * case EventType.SIP_CONTENT_UNSUPPORTED:break;
                 #endregion
                 *
                 *
                 *
                 #region Stream
                 * case EventType.STREAM_VIDEO_LOCAL_RESOLUTIONCHANGED:break;
                 * case EventType.STREAM_VIDEO_REMOTE_RESOLUTIONCHANGED:break;
                 #endregion
                 *
                 * case EventType.NETWORK_CHANGED: break;
                 * case EventType.MFW_INTERNAL_TIME_OUT: break;
                 *
                 * case EventType.REFRESH_ACTIVE_SPEAKER:break;
                 * case EventType.REMOTE_VIDEO_REFRESH:break;
                 * case EventType.REMOTE_VIDEO_CHANNELSTATUS_CHANGED:break;
                 * case EventType.REMOTE_VIDEO_DISPLAYNAME_UPDATE:break;
                 * case EventType.SIP_CALL_MODE_CHANGED:break;
                 *
                 * case EventType.SIP_CALL_MODE_UPGRADE_REQ:break;
                 * case EventType.IS_TALKING_STATUS_CHANGED:break;
                 * case EventType.CERTIFICATE_VERIFY:break;
                 * case EventType.TRANSCODER_FINISH:break;
                 * case EventType.ICE_STATUS_CHANGED:break;
                 * case EventType.SUTLITE_INCOMING_CALL:break;
                 * case EventType.SUTLITE_TERMINATE_CALL:break;
                 * case EventType.NOT_SUPPORT_VIDEOCODEC:break;
                 *
                 * case EventType.BANDWIDTH_LIMITATION:break;
                 * case EventType.MEDIA_ADDRESS_UPDATED:break;
                 * case EventType.AUTODISCOVERY_STATUS_CHANGED:break;
                 */
                #endregion
            }
            QLManager.GetInstance().InternalQLEvent?.Invoke(evt);
            QLManager.GetInstance().QLEvent?.Invoke(evt);
        }