private QualityIndicator ConvertToNamedQuality(VATRPCall call) { var rating = (float)LinphoneAPI.linphone_call_get_current_quality(call.NativeCallPtr); if (rating >= 4.0) { return(QualityIndicator.Good); } if (rating >= 3.0) { return(QualityIndicator.Medium); } if (rating >= 2.0) { return(QualityIndicator.Poor); } if (rating >= 1.0) { return(QualityIndicator.VeryPoor); } if (rating >= 0) { return(QualityIndicator.ToBad); } return(QualityIndicator.Unknown); }
public void ClearCallsItems() { if (manager.LinphoneService.LinphoneCore != IntPtr.Zero) { LinphoneAPI.linphone_core_clear_call_logs(manager.LinphoneService.LinphoneCore); if (OnCallHistoryEvent != null) { var eargs = new VATRPCallEventArgs(HistoryEventTypes.Reset); OnCallHistoryEvent(null, eargs); } } }
public void LoadLinphoneCallEvents() { if (manager.LinphoneService.LinphoneCore == IntPtr.Zero) { return; } AllCallsEvents.Clear(); isLoadingCalls = true; IntPtr callsListPtr = LinphoneAPI.linphone_core_get_call_logs(manager.LinphoneService.LinphoneCore); if (callsListPtr != IntPtr.Zero) { MSList curStruct; do { curStruct.next = IntPtr.Zero; curStruct.prev = IntPtr.Zero; curStruct.data = IntPtr.Zero; curStruct = (MSList)Marshal.PtrToStructure(callsListPtr, typeof(MSList)); if (curStruct.data != IntPtr.Zero) { var callevent = ParseLinphoneCallLog(curStruct.data); AllCallsEvents.Add(callevent); } callsListPtr = curStruct.next; } while (curStruct.next != IntPtr.Zero); } isLoadingCalls = false; if (OnCallHistoryEvent != null) { var eargs = new VATRPCallEventArgs(HistoryEventTypes.Load); OnCallHistoryEvent(null, eargs); } }
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 }
private VATRPCallEvent ParseLinphoneCallLog(IntPtr callLogPtr) { LinphoneCallDir direction = LinphoneAPI.linphone_call_log_get_dir(callLogPtr); IntPtr tmpPtr = LinphoneAPI.linphone_call_log_get_remote_address(callLogPtr); if (tmpPtr == IntPtr.Zero) { return(null); } // 4/11 MITRE-fjr Throws Exception, Added Catch try { tmpPtr = LinphoneAPI.linphone_address_as_string(tmpPtr); // 4/11 try ?? LinphoneAddress _linphoneAddress = LinphoneAPI.linphone_address_as_string(tmpPtr); if (tmpPtr == IntPtr.Zero) { return(null); } } catch (Exception ex) { Console.Write(ex.InnerException); return(null); } var remoteParty = Marshal.PtrToStringAnsi(tmpPtr); LinphoneAPI.ortp_free(tmpPtr); string dn = "", un = "", host = ""; int port = 0; VATRPCall.ParseSipAddressEx(remoteParty, out dn, out un, out host, out port); if (string.IsNullOrEmpty(un)) { return(null); } remoteParty = port == 0 ? string.Format("sip:{0}@{1}", un, host) : string.Format("sip:{0}@{1}:{2}", un, host, port); var callevent = new VATRPCallEvent("", remoteParty) { DisplayName = dn, Username = un }; tmpPtr = LinphoneAPI.linphone_call_log_get_call_id(callLogPtr); if (tmpPtr != IntPtr.Zero) { callevent.CallGuid = Marshal.PtrToStringAnsi(tmpPtr); } callevent.StartTime = new DateTime(1970, 1, 1).AddSeconds(LinphoneAPI.linphone_call_log_get_start_date(callLogPtr)); callevent.EndTime = callevent.StartTime.AddSeconds( Convert.ToInt32(LinphoneAPI.linphone_call_log_get_duration(callLogPtr))); switch (LinphoneAPI.linphone_call_log_get_status(callLogPtr)) { case LinphoneCallStatus.LinphoneCallSuccess: { callevent.Status = direction == LinphoneCallDir.LinphoneCallIncoming ? VATRPHistoryEvent.StatusType.Incoming : VATRPHistoryEvent.StatusType.Outgoing; } break; case LinphoneCallStatus.LinphoneCallAborted: callevent.Status = VATRPHistoryEvent.StatusType.Failed; break; case LinphoneCallStatus.LinphoneCallDeclined: callevent.Status = VATRPHistoryEvent.StatusType.Rejected; break; case LinphoneCallStatus.LinphoneCallMissed: callevent.Status = VATRPHistoryEvent.StatusType.Missed; break; } return(callevent); }