| 1 |
*/ |
| 2 |
|
| 3 |
|
| 4 |
|
| 5 |
|
| 6 |
|
| 7 |
|
| 8 |
|
| 9 |
|
| 10 |
|
| 11 |
|
| 12 |
|
| 13 |
|
| 14 |
|
| 15 |
|
| 16 |
|
| 17 |
|
| 18 |
|
| 19 |
|
| 20 |
using System; |
| 21 |
using System.Diagnostics; |
| 22 |
using System.Threading.Tasks; |
| 23 |
using VoipTasks.BackgroundOperations; |
| 24 |
using Windows.ApplicationModel.Calls; |
| 25 |
using Windows.Foundation.Collections; |
| 26 |
using VoipBackEnd; |
| 27 |
|
| 28 |
namespace VoipTasks.Helpers |
| 29 |
{ |
| 30 |
class EndpointHelper : IntAccount, IntCall |
| 31 |
{ |
| 32 |
private async void sendCallState(String state) |
| 33 |
{ |
| 34 |
ValueSet message = new ValueSet(); |
| 35 |
|
| 36 |
message[UpdateCallStateArguments.CallState.ToString()] = state; |
| 37 |
message[ForegroundOperation.NewForegroundRequest] = (int)ForegroundReguest.UpdateCallState; |
| 38 |
|
| 39 |
ValueSet response = await Current.SendMessageAsync(message); |
| 40 |
} |
| 41 |
|
| 42 |
private async void sendRegState(String state) |
| 43 |
{ |
| 44 |
ValueSet message = new ValueSet(); |
| 45 |
|
| 46 |
message[UpdateRegStateArguments.RegState.ToString()] = state; |
| 47 |
message[ForegroundOperation.NewForegroundRequest] = (int)ForegroundReguest.UpdateRegState; |
| 48 |
|
| 49 |
ValueSet response = await Current.SendMessageAsync(message); |
| 50 |
} |
| 51 |
|
| 52 |
|
| 53 |
public void onIncomingCall(CallInfoRT info) |
| 54 |
{ |
| 55 |
if (Current.VoipCall != null) |
| 56 |
{ |
| 57 |
|
| 58 |
return; |
| 59 |
} |
| 60 |
|
| 61 |
Current.RequestNewIncomingCall(info.remoteContact, |
| 62 |
info.remoteUri, |
| 63 |
"Pjsua"); |
| 64 |
} |
| 65 |
|
| 66 |
public void onRegState(OnRegStateParamRT prm) |
| 67 |
{ |
| 68 |
sendRegState(prm.reason); |
| 69 |
} |
| 70 |
|
| 71 |
|
| 72 |
public void onCallState(CallInfoRT info) |
| 73 |
{ |
| 74 |
switch (info.state) { |
| 75 |
case INV_STATE.PJSIP_INV_STATE_CALLING: |
| 76 |
sendCallState("Calling"); |
| 77 |
break; |
| 78 |
case INV_STATE.PJSIP_INV_STATE_INCOMING: |
| 79 |
sendCallState("Incoming"); |
| 80 |
break; |
| 81 |
case INV_STATE.PJSIP_INV_STATE_CONNECTING: |
| 82 |
sendCallState("Connecting"); |
| 83 |
break; |
| 84 |
case INV_STATE.PJSIP_INV_STATE_CONFIRMED: |
| 85 |
sendCallState("Connected"); |
| 86 |
break; |
| 87 |
case INV_STATE.PJSIP_INV_STATE_DISCONNECTED: |
| 88 |
sendCallState("Disconnected"); |
| 89 |
Current.EndCall(); |
| 90 |
break; |
| 91 |
} |
| 92 |
} |
| 93 |
} |
| 94 |
} |