예제 #1
0
        private async Task CallStatusUpdate(CallStatus callState)
        {
            switch (callState.State)
            {
            case Background.AppService.Dto.CallState.Idle:
                CallState = CallState.Idle;
                IsOtherConversationInCallMode = false;
                LocalSwapChainPanelHandle     = 0;
                RemoteSwapChainPanelHandle    = 0;
                _camera = null;
                break;

            case Background.AppService.Dto.CallState.LocalRinging:
                if (callState.PeerId == UserId)
                {
                    CallState = CallState.LocalRinging;
                    UnMuteCommandExecute();     //Start new calls with mic enabled
                    IsVideoEnabled        = callState.IsVideoEnabled;
                    IsAudioOnlyCall       = callState.Type == CallType.Audio;
                    LocalNativeVideoSize  = new Size(0, 0);
                    RemoteNativeVideoSize = new Size(0, 0);
                    LocalFrameRate        = "N/A";
                    RemoteFrameRate       = "N/A";
                }
                else
                {
                    IsOtherConversationInCallMode = true;
                }
                break;

            case Background.AppService.Dto.CallState.RemoteRinging:
                if (callState.PeerId == UserId)
                {
                    CallState = CallState.RemoteRinging;
                    UnMuteCommandExecute();     //Start new calls with mic enabled
                    IsVideoEnabled        = callState.IsVideoEnabled;
                    IsAudioOnlyCall       = callState.Type == CallType.Audio;
                    LocalNativeVideoSize  = new Size(0, 0);
                    RemoteNativeVideoSize = new Size(0, 0);
                    LocalFrameRate        = "N/A";
                    RemoteFrameRate       = "N/A";
                }
                else
                {
                    IsOtherConversationInCallMode = true;
                }
                break;

            case Background.AppService.Dto.CallState.EstablishOutgoing:
                if (callState.PeerId == UserId)
                {
                    CallState            = CallState.Connected;
                    IsVideoEnabled       = callState.IsVideoEnabled;
                    IsAudioOnlyCall      = callState.Type == CallType.Audio;
                    IsSelfVideoAvailable = IsVideoEnabled;
                    IsPeerVideoAvailable = callState.Type == CallType.AudioVideo;
                }
                else
                {
                    IsOtherConversationInCallMode = true;
                }
                break;

            case Background.AppService.Dto.CallState.EstablishIncoming:
                if (callState.PeerId == UserId)
                {
                    CallState            = CallState.Connected;
                    IsVideoEnabled       = callState.IsVideoEnabled;
                    IsAudioOnlyCall      = callState.Type == CallType.Audio;
                    IsSelfVideoAvailable = IsVideoEnabled;
                    IsPeerVideoAvailable = callState.Type == CallType.AudioVideo;
                }
                else
                {
                    IsOtherConversationInCallMode = true;
                }
                break;

            case Background.AppService.Dto.CallState.HangingUp:
                if (callState.PeerId == UserId)
                {
                    CallState = CallState.Connected;
                }
                else
                {
                    IsOtherConversationInCallMode = true;
                }
                break;

            case Background.AppService.Dto.CallState.Held:
                if (callState.PeerId == UserId)
                {
                    CallState = CallState.Held;
                }
                break;

            case Background.AppService.Dto.CallState.ActiveCall:
                IsVideoEnabled  = callState.IsVideoEnabled;
                IsAudioOnlyCall = callState.Type == CallType.Audio;
                if (callState.PeerId == UserId)
                {
                    CallState            = CallState.Connected;
                    IsSelfVideoAvailable = IsVideoEnabled;
                    IsPeerVideoAvailable = callState.Type == CallType.AudioVideo;

                    _camera = await _settingsChannel.GetVideoDeviceAsync();

                    IsCameraSwitchInProgress = false;
                    UpdateCameraSwitchButtonFlags();
                }
                else
                {
                    IsOtherConversationInCallMode = true;
                }
                break;

            default:
                throw new ArgumentOutOfRangeException();
            }
        }