private CallState GetNewCallState(IntPtr call, LinphoneCallState callState, ref CallType newCallType, ref string from, ref string to, bool recordEnable) { CallState newCallState; switch (callState) { case LinphoneCallState.LinphoneCallIncomingReceived: case LinphoneCallState.LinphoneCallIncomingEarlyMedia: newCallState = CallState.Loading; newCallType = CallType.Incoming; MarshalingExtensions.TryConvert(CallModule.linphone_call_get_remote_address_as_string(call), out from); to = Identity; break; case LinphoneCallState.LinphoneCallConnected: case LinphoneCallState.LinphoneCallResuming: case LinphoneCallState.LinphoneCallStreamsRunning: case LinphoneCallState.LinphoneCallPausedByRemote: case LinphoneCallState.LinphoneCallUpdatedByRemote: newCallState = CallState.Active; break; case LinphoneCallState.LinphoneCallPaused: case LinphoneCallState.LinphoneCallPausing: newCallState = CallState.Hold; break; case LinphoneCallState.LinphoneCallOutgoingInit: case LinphoneCallState.LinphoneCallOutgoingProgress: case LinphoneCallState.LinphoneCallOutgoingRinging: case LinphoneCallState.LinphoneCallOutgoingEarlyMedia: newCallState = CallState.Loading; newCallType = CallType.Outcoming; from = Identity; MarshalingExtensions.TryConvert(CallModule.linphone_call_get_remote_address_as_string(call), out to); break; case LinphoneCallState.LinphoneCallError: newCallState = CallState.Error; break; case LinphoneCallState.LinphoneCallReleased: case LinphoneCallState.LinphoneCallEnd: newCallState = CallState.Completed; if (recordEnable) { GenericModules.linphone_call_stop_recording(call); } break; default: throw new NotImplementedException("Sorry, that feature not implemented!"); break; } return(newCallState); }
public void OnMessageReceived(IntPtr lc, IntPtr room, IntPtr message) { var peer_address = ChatModule.linphone_chat_room_get_peer_address(room); if (peer_address.IsNonZero()) { var addressStringPtr = CallModule.linphone_address_as_string(peer_address); var chatMessagePtr = ChatModule.linphone_chat_message_get_text(message); string addressString, chatMessage; if (MarshalingExtensions.TryConvert(addressStringPtr, out addressString) && MarshalingExtensions.TryConvert(chatMessagePtr, out chatMessage)) { MessageReceivedEvent?.Invoke(addressString, chatMessage); } } }
public void OnCallStateChanged(IntPtr lc, IntPtr call, LinphoneCallState callState, string message) { if (LinphoneCore.IsNonZero() && IsRunning) { var newCallState = CallState.None; var newCallType = CallType.None; string from, to, recordFile; from = to = recordFile = null; IntPtr callParams = CallModule.linphone_call_get_params(call); bool recordEnable = MarshalingExtensions.TryConvert(CallModule.linphone_call_params_get_record_file(callParams), out recordFile); newCallState = GetNewCallState(call, callState, ref newCallType, ref from, ref to, recordEnable); UpdateCallReferences(call, newCallState, newCallType, callState, from, to, recordFile); } }