Beispiel #1
0
        private void InitParticipant(ParticipantItem participant)
        {
            var partAVModality = (AVModality)participant.Participant.Modalities[ModalityTypes.AudioVideo];

            partAVModality.ActionAvailabilityChanged += OnParticipantActionAvailabilityChanged;
            partAVModality.ModalityStateChanged      += OnParticipantModalityStateChanged;

            var partVideoChannel = partAVModality.VideoChannel;

            partVideoChannel.StateChanged += OnParticipantVideoChannelStateChanged;


            if (participant.Participant.IsSelf)
            {
                var localpPartAVModality = (AVModality)participant.Participant.Modalities[ModalityTypes.AudioVideo];

                participant.AVModality   = partAVModality;
                participant.VideoChannel = partVideoChannel;


                LocalParticipantVideoModel = participant;
            }

            else
            {
                if (_avModality.CanInvoke(ModalityAction.Connect))
                {
                    Connect();
                }

                participant.AVModality   = partAVModality;
                participant.VideoChannel = partVideoChannel;
            }
        }
Beispiel #2
0
 public static void AvConnect(ConversationWindow conversationWindow)
 {
     try
     {
         AVModality avModality = (AVModality)conversationWindow.Conversation.Modalities[ModalityTypes.AudioVideo];
         if (avModality != null)
         {
             if (avModality.CanInvoke(ModalityAction.Connect))
             {
                 avModality.BeginConnect(null, null);
             }
         }
     }
     catch (Exception ex)
     {
         LogManage.WriteLog(typeof(LyncHelper), ex);
     }
     finally
     {
     }
 }
        private static void Modality_Response_Connect(ConversationWindow conversationWindow)
        {
            try
            {
                var modalities = conversationWindow.Conversation.Modalities;

                //视频通道
                VideoChannel videoChannel = null;

                //音频通道
                AudioChannel audioChannel = null;

                AVModality avModality = ((AVModality)modalities[ModalityTypes.AudioVideo]);
                if (avModality != null)
                {
                    //视频通道
                    videoChannel = avModality.VideoChannel;
                    //音频通道
                    audioChannel = avModality.AudioChannel;
                }

                //视频
                if (videoChannel != null && videoChannel.State == ChannelState.Connecting)
                {
                    Application.Current.Dispatcher.BeginInvoke(new Action(() =>
                    {
                        try
                        {
                            if (avModality.CanInvoke(ModalityAction.Accept))
                            {
                                //接受
                                avModality.Accept();

                                if (videoChannel.CanInvoke(ChannelAction.Start))
                                {
                                    videoChannel.BeginStart(null, null);
                                }
                            }
                        }
                        catch (Exception ex)
                        {
                            LogManage.WriteLog(typeof(LyncHelper), ex);
                        };
                    }));
                }
                //语音
                else if (audioChannel != null && audioChannel.State == ChannelState.Connecting)
                {
                    if (avModality.CanInvoke(ModalityAction.Accept))
                    {
                        //接受
                        avModality.Accept();
                    }
                }
            }
            catch (Exception ex)
            {
                LogManage.WriteLog(typeof(LyncHelper), ex);
            }
            finally
            {
            }
        }
        /// <summary>
        /// 通道响应(accept)
        /// </summary>
        /// <param name="conversationWindow">会话窗体</param>
        private static void Modality_Response_Accept(ConversationWindow conversationWindow)
        {
            try
            {
                var modalities = conversationWindow.Conversation.Modalities;

                //视频通道
                VideoChannel videoChannel = null;

                //音频通道
                AudioChannel audioChannel = null;

                AVModality avModality = ((AVModality)modalities[ModalityTypes.AudioVideo]);
                if (avModality != null)
                {
                    //视频通道
                    videoChannel = avModality.VideoChannel;
                    //音频通道
                    audioChannel = avModality.AudioChannel;
                }

                //内容共享
                ContentSharingModality shareContent = (ContentSharingModality)modalities[ModalityTypes.ContentSharing];
                //程序共享
                ApplicationSharingModality applicationSharing = (ApplicationSharingModality)modalities[ModalityTypes.ApplicationSharing];


                //视频
                if (videoChannel != null && videoChannel.State == ChannelState.Receive)
                {
                    Application.Current.Dispatcher.BeginInvoke(new Action(() =>
                    {
                        try
                        {
                            if (avModality.CanInvoke(ModalityAction.Accept))
                            {
                                //接受
                                avModality.Accept();

                                if (videoChannel.CanInvoke(ChannelAction.Start))
                                {
                                    videoChannel.BeginStart(null, null);
                                }
                            }
                        }
                        catch (Exception ex)
                        {
                            LogManage.WriteLog(typeof(LyncHelper), ex);
                        };
                    }));
                }
                //语音
                else if (audioChannel != null && audioChannel.State == ChannelState.Receive)
                {
                    if (avModality.CanInvoke(ModalityAction.Accept))
                    {
                        //接受
                        avModality.Accept();
                    }
                }
                //共享ppt、电子白板
                else if (shareContent != null && shareContent.State == ModalityState.Notified)
                {
                    shareContent.Accept();
                }
                //共享应用程序
                else if (applicationSharing != null && applicationSharing.State == ModalityState.Notified)
                {
                    applicationSharing.Accept();
                    if (AddContent_Type_CallBack != null)
                    {
                        AddContent_Type_CallBack(SharingType.Application);
                    }
                }
            }
            catch (Exception ex)
            {
                LogManage.WriteLog(typeof(LyncHelper), ex);
            }
            finally
            {
            }
        }