Пример #1
0
        internal void UpdateCallInfo(VATRPCall call)
        {
            //*********************************************************************************************************************************
            // When anything related to call is changed or when call is running then this method is called.
            //*********************************************************************************************************************************
            if (call == null || call.CallState != VATRPCallState.StreamsRunning)
            {
                LogCallData(call); // cjm-aug17
                ResetCallInfoView();
                return;
            }

            ServiceManager.Instance.LinphoneService.LockCalls();
            ServiceManager.Instance.LinphoneService.GetCallAudioStats(call.NativeCallPtr, ref _audioStats);
            ServiceManager.Instance.LinphoneService.GetCallVideoStats(call.NativeCallPtr, ref _videoStats);

            IntPtr curparams = ServiceManager.Instance.LinphoneService.GetCallParams(call.NativeCallPtr);

            if (curparams != IntPtr.Zero)
            {
                int sipPort, rtpPort;
                ServiceManager.Instance.LinphoneService.GetUsedPorts(out sipPort, out rtpPort);

                SipPort = sipPort;
                RtpPort = rtpPort;
                bool has_video = LinphoneAPI.linphone_call_params_video_enabled(curparams) == 1;

                MSVideoSizeDef size_received = LinphoneAPI.linphone_call_params_get_received_video_size(curparams);
                MSVideoSizeDef size_sent     = LinphoneAPI.linphone_call_params_get_sent_video_size(curparams);
                IntPtr         rtp_profile   = LinphoneAPI.linphone_call_params_get_rtp_profile(curparams);

                if (rtp_profile != IntPtr.Zero)
                {
                    RtpProfile = Marshal.PtrToStringAnsi(rtp_profile);
                }
                AudioCodec = ServiceManager.Instance.LinphoneService.GetUsedAudioCodec(curparams);

                int avpf_mode = ServiceManager.Instance.LinphoneService.GetAVPFMode();

                if (avpf_mode == 0)
                {
                    AVPFEnabled = false;
                }
                else if (avpf_mode == 1)
                {
                    AVPFEnabled = true;
                }


                var videoCodecName = ServiceManager.Instance.LinphoneService.GetUsedVideoCodec(curparams);

                //Console.WriteLine("videoCodecName " + videoCodecName);
                if (has_video && !string.IsNullOrWhiteSpace(videoCodecName))
                {
                    VideoCodec      = videoCodecName;
                    UploadBandwidth = string.Format("{0:0.##} kbit/s a {1:0.##} kbit/s v {2:0.##} kbit/s",
                                                    _audioStats.upload_bandwidth + _videoStats.upload_bandwidth, _audioStats.upload_bandwidth,
                                                    _videoStats.upload_bandwidth);

                    DownloadBandwidth = string.Format("{0:0.##} kbit/s a {1:0.##} kbit/s v {2:0.##} kbit/s",
                                                      _audioStats.download_bandwidth + _videoStats.download_bandwidth, _audioStats.download_bandwidth,
                                                      _videoStats.download_bandwidth);
                    ReceivingFPS = ServiceManager.Instance.LinphoneService.GetFrameRate(curparams, false);
                    SendingFPS   = ServiceManager.Instance.LinphoneService.GetFrameRate(curparams, true);

                    // System.Diagnostics.Debug.WriteLine(ReceivingFPS.ToString(), SendingFPS.ToString());
                    var vs = ServiceManager.Instance.LinphoneService.GetVideoSize(curparams, false);
                    ReceivingVideoResolution = string.Format("{0}({1}x{2})", "", vs.width, vs.height);

                    vs = ServiceManager.Instance.LinphoneService.GetVideoSize(curparams, true);
                    SendingVideoResolution = string.Format("{0}({1}x{2})", "", vs.width, vs.height);
                }
                else
                {
                    VideoCodec               = "Not used";
                    ReceivingFPS             = 0;
                    SendingFPS               = 0;
                    UploadBandwidth          = string.Format("a {0:0.##} kbit/s", _audioStats.upload_bandwidth);
                    DownloadBandwidth        = string.Format("a {0:0.##} kbit/s", _audioStats.download_bandwidth);
                    ReceivingVideoResolution = "N/A";
                    SendingVideoResolution   = "N/A";
                }
                switch ((LinphoneIceState)_audioStats.ice_state)
                {
                case LinphoneIceState.LinphoneIceStateNotActivated:
                    IceSetup = "Not Activated";
                    break;

                case LinphoneIceState.LinphoneIceStateFailed:
                    IceSetup = "Failed";
                    break;

                case LinphoneIceState.LinphoneIceStateInProgress:
                    IceSetup = "In Progress";
                    break;

                case LinphoneIceState.LinphoneIceStateHostConnection:
                    IceSetup = "Connected directly";
                    break;

                case LinphoneIceState.LinphoneIceStateReflexiveConnection:
                    IceSetup = "Connected through NAT";
                    break;

                case LinphoneIceState.LinphoneIceStateRelayConnection:
                    IceSetup = "Connected through a relay";
                    break;
                }

                switch (ServiceManager.Instance.LinphoneService.GetMediaEncryption(curparams))
                {
                case LinphoneMediaEncryption.LinphoneMediaEncryptionNone:
                    MediaEncryption = "None";
                    break;

                case LinphoneMediaEncryption.LinphoneMediaEncryptionSRTP:
                    MediaEncryption = "SRTP";
                    break;

                case LinphoneMediaEncryption.LinphoneMediaEncryptionZRTP:
                    MediaEncryption = "ZRTP";
                    break;

                case LinphoneMediaEncryption.LinphoneMediaEncryptionDTLS:
                    MediaEncryption = "DTLS";
                    break;
                }

                var curQuality = ConvertToNamedQuality(call);
                if (CallQuality != curQuality)
                {
                    CallQuality = curQuality;
                    if (CallQualityChangedEvent != null)
                    {
                        CallQualityChangedEvent(curQuality);
                    }
                }

                AudioPacketLossSending           = "Sending " + _audioStats.sender_loss_rate;
                AudioPacketLossReceiving         = "Receiving " + _audioStats.receiver_loss_rate;
                AudioPacketLate                  = _audioStats.total_late_packets.ToString();
                AudioInterarrivalJitterSending   = "Sending " + _audioStats.sender_interarrival_jitter;
                AudioInterarrivalJitterReceiving = "Receiving " + _audioStats.receiver_interarrival_jitter;

                VideoPacketLossSending           = "Sending " + _videoStats.sender_loss_rate;
                VideoPacketLossReceiving         = "Receiving " + _audioStats.receiver_loss_rate;
                VideoPacketLate                  = _videoStats.total_late_packets.ToString();
                VideoInterarrivalJitterSending   = "Sending " + _audioStats.sender_interarrival_jitter;
                VideoInterarrivalJitterReceiving = "Receiving " + _audioStats.receiver_interarrival_jitter;
            }
            ServiceManager.Instance.LinphoneService.UnlockCalls();
            LogCallData(call); // cjm-aug17
        }