Ejemplo n.º 1
0
        /// <summary>
        /// 发送FECC
        /// </summary>
        /// <param name="key">FECC Key</param>
        public void StartSendFECC(FECCKey key)
        {
            var errno = PlcmProxy.SendFECCKey(this.CallHandle, key, FECCAction.START);

            if (errno != ErrorNumber.OK)
            {
                var errMsg = string.Format("发送FECC({0}) Start失败,errno={1}", key, errno);
                log.Error(errMsg);
                throw new Exception(errMsg);
            }
            log.Info(string.Format("发送FECC({0}) Start成功.", key));

            feccKey = key;

            feccTimer?.Dispose();
            feccTimer = new Timer()
            {
                Interval = 200
            };
            feccTimer.Tick += (sender, args) =>
            {
                errno = PlcmProxy.SendFECCKey(this.CallHandle, feccKey, FECCAction.CONTINUE);
                if (errno != ErrorNumber.OK)
                {
                    var errMsg = string.Format("发送FECC({0}) Continue失败,errno={1}", key, errno);
                    log.Error(errMsg);
                    throw new Exception(errMsg);
                }
                log.Info(string.Format("发送FECC({0}) Continue成功", key));
            };
            feccTimer.Start();
        }
Ejemplo n.º 2
0
        private void diallCallDiret(string dialUri, CallMode callMode = CallMode.VIDEO)
        {
            int callHandle = -1;

            qlConfig.SetProperty(PropertyKey.CalleeAddr, dialUri, true);
            var errno = PlcmProxy.PlaceCall(dialUri, ref callHandle, callMode);

            if (ErrorNumber.OK == errno)
            {
                var call = new QLCall(callHandle)
                {
                    CallHandle      = callHandle,
                    CallName        = dialUri,
                    CallMode        = callMode,
                    ActiveSpeakerId = 0,
                    CallState       = CallState.SIP_UNKNOWN,
                    CallType        = CallType.UNKNOWN,
                    StartTime       = DateTime.Now,
                };
                this.AddCall(call);
                this.CurrentCall = call;
                log.Info("呼叫成功!");
            }
            else
            {
                var msg = "呼叫失败,ErrorNo=" + errno;
                callView.ShowMessage(false, msg, MessageBoxButtonsType.OK, MessageBoxIcon.Error);
                throw new Exception(msg);
            }
        }
Ejemplo n.º 3
0
 /// <summary>
 /// 释放资源
 /// </summary>
 private void Release()
 {
     if (IsRegisted)
     {
         PlcmProxy.UnregisterClient();
     }
     callManager.Dispose();
     log.Info("关闭释放资源");
 }
Ejemplo n.º 4
0
        /// <summary>
        /// 恢复保持的呼叫
        /// </summary>
        public void ResumeCall()
        {
            var errno = PlcmProxy.ResumeCall(this.CallHandle);

            if (ErrorNumber.OK != errno)
            {
                throw new Exception("恢复呼叫失败,ErrorNo=" + errno);
            }
            log.Info(string.Format("呼叫{0}恢复", CallName));
        }
Ejemplo n.º 5
0
        /// <summary>
        /// 挂断呼叫
        /// </summary>
        public void HangUpCall()
        {
            var errno = PlcmProxy.TerminateCall(this.CallHandle);

            if (ErrorNumber.OK != errno)
            {
                throw new Exception("挂断呼叫失败,ErrorNo=" + errno);
            }
            log.Info(string.Format("挂断呼叫{0}", CallName));
        }
Ejemplo n.º 6
0
        /// <summary>
        /// 切换音频视频模式
        /// </summary>
        /// <param name="call">呼叫处理器,为空时为当前呼叫</param>
        /// <param name="callMode">呼叫类型</param>
        public void ChangeCallType(CallMode callMode)
        {
            var errno = PlcmProxy.ChangeCallMode(this.CallHandle, callMode);

            if (ErrorNumber.OK != errno)
            {
                throw new Exception("切换音频视频模式失败,ErrorNo=" + errno);
            }
            log.Info(string.Format("呼叫{0}改变模式{1}", CallName, callMode));
        }
Ejemplo n.º 7
0
        /// <summary>
        /// 拒绝接听
        /// </summary>
        public void RejectCall()
        {
            var errno = PlcmProxy.RejectCall(this.CallHandle);

            if (ErrorNumber.OK != errno)
            {
                var errMsg = "拒绝接听失败,errNo=" + errno;
                log.Error(errMsg);
                throw new Exception(errMsg);
            }
            log.Info(string.Format("拒绝接听{0}", CallName));
        }
Ejemplo n.º 8
0
        /// <summary>
        /// 接听/应答呼叫
        /// </summary>
        /// <param name="callMode">响应呼叫类型  默认 VIDEO</param>
        public void AnswerCall(CallMode callMode = CallMode.VIDEO)
        {
            var errno = PlcmProxy.AnswerCall(this, callMode);

            if (ErrorNumber.OK != errno)
            {
                var errMsg = "接听应答呼叫失败,ErrorNo=" + errno;
                log.Error(errMsg);
                throw new Exception(errMsg);
            }
            log.Info(string.Format("呼叫{0}接听成功。{1}", CallName, callMode));
        }
Ejemplo n.º 9
0
        /// <summary>
        /// 获取应该程序列表
        /// </summary>
        /// <param name="callback">获取结果回调函数</param>
        public void GetApps(Action <ObservableCollection <QLApp> > callback)
        {
            apps.Clear();

            appCallBack = callback;
            var errno = PlcmProxy.GetApplicationInfo();

            if (ErrorNumber.OK != errno)
            {
                throw new Exception("获取信号流信息失败,errno=" + errno);
            }
        }
Ejemplo n.º 10
0
        /// <summary>
        /// 发送DTMF key
        /// </summary>
        /// <param name="key">DTMFkey</param>
        public void SendDTMFKey(DTMFKey key)
        {
            var errno = PlcmProxy.SendDTMFKey(this.CallHandle, key);

            if (errno != ErrorNumber.OK)
            {
                var errMsg = string.Format("发送DTMF Key({0})失败,errno={1}", key, errno);
                log.Error(errMsg);
                throw new Exception(errMsg);
            }
            log.Info(string.Format("发送DTMF Key({0})成功.", key));
        }
Ejemplo n.º 11
0
        /// <summary>
        /// 静音扬声器
        /// </summary>
        /// <param name="isMute">是否静音</param>
        public void MuteSpeaker(bool isMute)
        {
            var errno = PlcmProxy.MuteSpeaker(isMute);

            if (ErrorNumber.OK != errno)
            {
                var errMsg = "扬声器静音设置失败,errno=" + errno;
                log.Error(errMsg);
                throw new Exception(errMsg);
            }
            log.Info("扬声器静音设置成功");
        }
Ejemplo n.º 12
0
        /// <summary>
        /// 设置扬声器音量值
        /// </summary>
        /// <param name="volume">音量值</param>
        public void SetSpeakerVolume(int volume)
        {
            var errno = PlcmProxy.SetSpeakerVolume(volume);

            if (ErrorNumber.OK != errno)
            {
                var errMsg = "扬声器音量设置失败,errno=" + errno;
                log.Error(errMsg);
                throw new Exception(errMsg);
            }
            log.Info("扬声器音量设置成功");
        }
Ejemplo n.º 13
0
        /// <summary>
        /// 设置扬声器音量值
        /// </summary>
        /// <param name="volume">音量值</param>
        public void SetMicVolume(int volume)
        {
            var errno = PlcmProxy.SetMicVolume(volume);

            if (ErrorNumber.OK != errno)
            {
                var errMag = "麦克风音量设置失败,errno=" + errno;
                log.Error(errMag);
                throw new Exception(errMag);
            }
            log.Info("麦克风音量设置成功");
        }
Ejemplo n.º 14
0
        /// <summary>
        /// 关闭摄像头
        /// </summary>
        public void StopCamera()
        {
            var errno = PlcmProxy.StopCamera();

            if (ErrorNumber.OK != errno)
            {
                var errMag = "关闭摄像头失败,errno=" + errno;
                log.Error(errMag);
                throw new Exception(errMag);
            }
            log.Info("关闭摄像头成功");
        }
Ejemplo n.º 15
0
        /// <summary>
        /// 停止发送共享内容
        /// </summary>
        public void StopSendContent()
        {
            var errno = PlcmProxy.StopShareContent(this.CallHandle);

            if (ErrorNumber.OK != errno)
            {
                throw new Exception("停止内容共享失败,ErrorNo=" + errno);
            }
            log.Info(string.Format("呼叫{0}结束发送共享内容", CallName));

            RemoveChannel(-1);
        }
Ejemplo n.º 16
0
        /// <summary>
        /// 打开/关闭本地视频
        /// </summary>
        /// <param name="isMute">关闭:true, 打开:false</param>
        public void MuteLocalVideo(bool isMute)
        {
            var errno = PlcmProxy.MuteLocalVideo(isMute);

            if (errno != ErrorNumber.OK)
            {
                var errMsg = string.Format("打开/关闭本地视频设置{0}失败,errno={1}", isMute, errno);
                log.Error(errMsg);
                throw new Exception(errMsg);
            }
            MuteVideo = isMute;
            log.Info(string.Format("打开/关闭本地视频设置{0}成功", isMute));
        }
Ejemplo n.º 17
0
        /// <summary>
        /// 打开/关闭麦克风
        /// </summary>
        /// <param name="isMute">关闭:true, 打开:false</param>
        public void MuteLocalMic(bool isMute)
        {
            var errno = PlcmProxy.MuteMic(this.CallHandle, isMute);

            if (ErrorNumber.OK != errno)
            {
                var errMsg = string.Format("麦克风静音设置{0}失败,errno={1}", isMute, errno);
                log.Error(errMsg);
                throw new Exception(errMsg);
            }
            MuteMic = isMute;
            log.Info(string.Format("麦克风静音设置{0}成功", isMute));
        }
Ejemplo n.º 18
0
        /// <summary>
        /// 结束FECC发送
        /// </summary>
        public void StopSendFECC()
        {
            feccTimer?.Stop();
            var errno = PlcmProxy.SendFECCKey(this.CallHandle, feccKey, FECCAction.STOP);

            if (errno != ErrorNumber.OK)
            {
                var errMsg = string.Format("发送FECC({0}) Stop,errno={1}", feccKey, errno);
                log.Error(errMsg);
                throw new Exception(errMsg);
            }
            log.Info(string.Format("发送FECC({0}) Stop失败", feccKey));
        }
Ejemplo n.º 19
0
        /// <summary>
        /// 开启发送共享内容
        /// </summary>
        /// <param name="imageFormat">图像格式</param>
        /// <param name="contentType">共享内容类型</param>
        /// <param name="contentHandle">句柄</param>
        public void StartSendContent(ImageFormat imageFormat, ContentType contentType, object contentHandle)
        {
            var errno = PlcmProxy.StartBFCPContent(this.CallHandle);

            if (ErrorNumber.OK != errno)
            {
                throw new Exception("内容共享失败,ErrorNo=" + errno);
            }
            log.Info(string.Format("呼叫{0}开始发送BFCP共享内容", CallName));
            this.ContentImageFormat = imageFormat;
            this.ContentType        = contentType;
            this.ContentHandle      = contentHandle;
        }
Ejemplo n.º 20
0
 /// <summary>
 /// 停止播放声音
 /// </summary>
 public void StopSound()
 {
     if (null != CurrentAudioOutputDevice)
     {
         var errno = PlcmProxy.StopPlayAlert();
         if (ErrorNumber.OK != errno)
         {
             var errMsg = "关闭铃声播放失败,ErrorNo=" + errno;
             log.Error(errMsg);
             throw new Exception(errMsg);
         }
         log.Info("关闭铃声播放成功");
     }
 }
Ejemplo n.º 21
0
 /// <summary>
 /// 播放声音
 /// </summary>
 /// <param name="filePath">声音文件路径</param>
 /// <param name="isLoop">是否循环播放</param>
 /// <param name="interval">播放间隔</param>
 public void PlaySound(string filePath, bool isLoop, int interval)
 {
     if (null != CurrentAudioOutputDevice)
     {
         var errno = PlcmProxy.StartPlayAlert(filePath, isLoop, interval);
         if (ErrorNumber.OK != errno)
         {
             var errMsg = "开启铃声播放失败,ErrorNo=" + errno;
             log.Error(errMsg);
             throw new Exception(errMsg);
         }
         log.Info("开启铃声播放成功 filePath:" + filePath);
     }
 }
Ejemplo n.º 22
0
        private static void StartEventMonitor()
        {
            autoEvent = new AutoResetEvent(false);
            isRunning = true;
            var thread = new Thread(() =>
            {
                while (isRunning)
                {
                    log.Debug("handle the evt");
                    if (queue.Count <= 0)
                    {
                        lock (synObject)
                        {
                            log.Info("No evt, wait..");
                            autoEvent.WaitOne();
                        }
                    }
                    while (queue.Count > 0)
                    {
                        QLEvent evt = null;
                        lock (synObject)
                        {
                            evt = queue.Dequeue();
                        }
                        // dispatch QLEvent to proper modules
                        if (evt == null)
                        {
                            log.Error("QLEvent is null!");
                            continue;
                        }
                        try
                        {
                            callView.Invoke(new Action(() =>
                            {
                                DoEvent(evt);
                            }));
                        }
                        catch (Exception ex)
                        {
                            log.Error(ex.Message);
                        }
                        PlcmProxy.FreeEvent(evt.EventHandle);
                    }
                }
            });

            thread.Start();
        }
Ejemplo n.º 23
0
 /// <summary>
 /// 获取呼叫信号统计信息
 /// </summary>
 /// <param name="callBack">获取结果回调函数</param>
 public void GetMediaStatistics(Action <ObservableCollection <QLMediaStatistics> > callBack)
 {
     mediaStatistics.Clear();
     if (null != callManager.CurrentCall)
     {
         mediaStatisticsCallBack = callBack;
         var errno = PlcmProxy.GetMediaStatistics(callManager.CurrentCall.CallHandle);
         if (ErrorNumber.OK != errno)
         {
             throw new Exception("获取信号流信息失败,errno=" + errno);
         }
     }
     else
     {
         throw new Exception("当前呼叫为空,获取信号流信息");
     }
 }
Ejemplo n.º 24
0
        private void OnDisposed(object sender, EventArgs e)
        {
            try
            {
                switch (_channel.MediaType)
                {
                case MediaType.LOCAL:
                {
                    var errno = PlcmProxy.DetachStreamWnd(MediaType.LOCAL, _channel.ChannelID, _channel.Call.CallHandle);
                    if (ErrorNumber.OK != errno)
                    {
                        log.Error("本地视频卸载失败");
                    }
                    PlcmProxy.StopCamera();
                }
                break;

                case MediaType.REMOTE:
                {
                    var errno = PlcmProxy.DetachStreamWnd(MediaType.REMOTE, _channel.ChannelID, _channel.Call.CallHandle);
                    if (ErrorNumber.OK != errno)
                    {
                        log.Error("远程视频卸载失败");
                    }
                }
                break;

                case MediaType.CONTENT:
                {
                    var errno = PlcmProxy.DetachStreamWnd(MediaType.CONTENT, _channel.ChannelID, _channel.Call.CallHandle);
                    if (ErrorNumber.OK != errno)
                    {
                        log.Error("共享视频卸载失败");
                    }
                }
                break;

                case MediaType.LOCALCONTENT: {} break;
                }
            }
            catch (Exception ex)
            {
                log.Error(ex.Message);
            }
        }
Ejemplo n.º 25
0
 /// <summary>
 /// 批量设置属性
 /// </summary>
 /// <param name="properties">属性集合</param>
 /// <param name="isPersistence">是否持久化保存</param>
 public void SetProperties(IDictionary <PropertyKey, string> properties, bool isPersistence)
 {
     if (null != properties && properties.Count > 0)
     {
         foreach (var propertyKV in properties)
         {
             SetProperty(propertyKV.Key, propertyKV.Value, false);
         }
         if (isPersistence)
         {
             var errno = PlcmProxy.UpdateConfig();
             if (errno != ErrorNumber.OK)
             {
                 var errMsg = string.Format("更新配置失败,err={0}", errno);
                 log.Error(errMsg);
                 throw new Exception(errMsg);
             }
         }
     }
 }
Ejemplo n.º 26
0
 public void Dispose()
 {
     if (_callList.Count > 0)
     {
         #region 结束呼叫
         //保存通话记录
         foreach (var call in _callList)
         {
             if (!call.IsActive())
             {
                 PlcmProxy.TerminateCall(call.CallHandle);
                 call.StopTime  = DateTime.Now;
                 call.CallState = CallState.SIP_CALL_CLOSED;
                 call.Reason    = "关闭程序,结束通话";
             }
         }
         #endregion
         #region 保存呼叫
         GetHistoryCalls((calls) =>
         {
             var dicPath = Path.Combine(Application.StartupPath, "History");
             if (!Directory.Exists(dicPath))
             {
                 Directory.CreateDirectory(dicPath);
             }
             var filePath = Path.Combine(dicPath, string.Format("history_{0}.log", qlConfig.GetProperty(PropertyKey.PLCM_MFW_KVLIST_KEY_SIP_UserName)));
             using (var fs = new FileStream(filePath, FileMode.Create, FileAccess.Write))
             {
                 using (var sw = new StreamWriter(fs))
                 {
                     var str = SerializerUtil.SerializeJson(calls);
                     sw.Write(str);
                 }
             }
         });
         #endregion
     }
 }
Ejemplo n.º 27
0
        private void RenderVedio()
        {
            try
            {
                var hwnd = pnlVideo.Handle;
                if (_channel.IsVideo)
                {
                    switch (_channel.MediaType)
                    {
                    case MediaType.LOCAL:
                    {
                        var errno = PlcmProxy.AttachStreamWnd(MediaType.LOCAL, _channel.ChannelID, _channel.Call.CallHandle, hwnd, 0, 0, this.pnlVideo.Width, this.pnlVideo.Height - 40);
                        if (ErrorNumber.OK != errno)
                        {
                            log.Error("本地视频附加失败");
                        }
                        PlcmProxy.StartCamera();
                    }
                    break;

                    case MediaType.REMOTE:
                    {
                        var errno = PlcmProxy.AttachStreamWnd(MediaType.REMOTE, _channel.ChannelID, _channel.Call.CallHandle, hwnd, 0, 0, this.pnlVideo.Width, this.pnlVideo.Height - 40);
                        if (ErrorNumber.OK != errno)
                        {
                            log.Error("远程视频附加失败");
                        }
                    }
                    break;

                    case MediaType.CONTENT:
                    {
                        var errno = PlcmProxy.AttachStreamWnd(MediaType.CONTENT, _channel.ChannelID, _channel.Call.CallHandle, hwnd, 0, 0, this.pnlVideo.Width, this.pnlVideo.Height - 40);
                        if (ErrorNumber.OK != errno)
                        {
                            log.Error("共享视频附加失败");
                        }
                    }
                    break;

                    case MediaType.LOCALCONTENT: { } break;
                    }
                }
                else  //音频
                {
                    switch (_channel.MediaType)
                    {
                    case MediaType.LOCAL:
                    {
                        var errno = PlcmProxy.DetachStreamWnd(MediaType.LOCAL, _channel.ChannelID, _channel.Call.CallHandle);
                        if (ErrorNumber.OK != errno)
                        {
                            log.Error("本地视频卸载失败");
                        }
                        PlcmProxy.StopCamera();
                    }
                    break;

                    case MediaType.REMOTE:
                    {
                        var errno = PlcmProxy.DetachStreamWnd(MediaType.REMOTE, _channel.ChannelID, _channel.Call.CallHandle);
                        if (ErrorNumber.OK != errno)
                        {
                            log.Error("远程视频卸载失败");
                        }
                    }
                    break;

                    case MediaType.CONTENT:
                    {
                        var errno = PlcmProxy.DetachStreamWnd(MediaType.CONTENT, _channel.ChannelID, _channel.Call.CallHandle);
                        if (ErrorNumber.OK != errno)
                        {
                            log.Error("共享视频卸载失败");
                        }
                    }
                    break;

                    case MediaType.LOCALCONTENT: { } break;
                    }
                }
            }
            catch (Exception ex)
            {
                log.Error(ex.Message);
            }
        }
Ejemplo n.º 28
0
 /// <summary>
 /// 获取麦克风音量
 /// </summary>
 /// <returns>音量值</returns>
 public int GetMicVolume()
 {
     log.Info("获取麦克风音量");
     return(PlcmProxy.GetMicVolume());
 }
Ejemplo n.º 29
0
        private void onShareTimerTickHandle(object sender, EventArgs e)
        {
            try
            {
                log.Info(string.Format("SetContentBuffer({0},{1},{2}) ", call.ContentImageFormat, call.ContentType, call.ContentHandle));
                #region Image
                Bitmap image = null;
                var    rect  = new Rectangle();
                if (null == call.ContentHandle)
                {
                    return;
                }
                if (call.ContentType == ContentType.Monitor)
                {
                    image = ImageHelper.CaptureScreen(call.ContentHandle, ref rect);
                }
                else
                {
                    image = ImageHelper.CaptureApplication(call.ContentHandle, ref rect);
                }
                #endregion
                if (null != image)
                {
                    log.Info(string.Format("SetContentBuffer({0},{1},{2})", call.ContentImageFormat, image.Width, image.Height));
                    this.Bounds = rect;

                    #region Resolution
                    Size size = new Size();
                    if (image.Width <= 320 && image.Height <= 240)
                    {
                        size = new Size(320, 240);
                    }
                    else if (image.Width <= 432 && image.Height <= 240)
                    {
                        size = new Size(432, 240);
                    }
                    else if (image.Width <= 640 && image.Height <= 480)
                    {
                        size = new Size(640, 480);
                    }
                    else if (image.Width <= 704 && image.Height <= 576)
                    {
                        size = new Size(704, 576);
                    }
                    else if (image.Width <= 800 && image.Height <= 600)
                    {
                        size = new Size(800, 600);
                    }
                    else if (image.Width <= 1024 && image.Height <= 576)
                    {
                        size = new Size(1024, 576);
                    }
                    else if (image.Width <= 1024 && image.Height <= 768)
                    {
                        size = new Size(1024, 768);
                    }
                    else
                    {
                        size = new Size(1280, 720);
                    }
                    #endregion
                    var scaledImage = ImageHelper.ScaleImage(image, size);

                    #region Bytes
                    byte[] buffer = null;
                    if (call.ContentImageFormat == ImageFormat.YV12)
                    {
                        buffer = ImageHelper.GetYUV(scaledImage);
                    }
                    else
                    {
                        buffer = ImageHelper.GetRGBA(scaledImage);
                    }
                    #endregion
                    var errno = PlcmProxy.SetContentBuffer(call.ContentImageFormat, buffer, scaledImage.Width, scaledImage.Height);
                    if (ErrorNumber.OK != errno)
                    {
                        log.Error("SetContentBuffer 失败, ex:" + errno);

                        this.Hide();
                    }
                    else
                    {
                        channel.LocalContentImage = scaledImage;
                        this.Show();
                    }
                }
                else
                {
                    throw new Exception("捕捉图像失败");
                }
            }
            catch (Exception ex)
            {
                log.Error(ex.Message);
            }
        }
Ejemplo n.º 30
0
 /// <summary>
 /// 获取扬声器音量
 /// </summary>
 /// <returns>音量值</returns>
 public int GetSpeakerVolume()
 {
     log.Info("获取扬声器音量");
     return(PlcmProxy.GetSpeakerVolume());
 }