Debian Codegraph @

Xpjproject/pjsip-apps/src/pjsua/winrt/gui/uwp/VoipTasks/Helpers/EndpointHelper.cs

raw symbols SCIP
1 /* $Id*/
2 /*
3 * Copyright (C) 2016 Teluu Inc. (http://www.teluu.com)
4 *
5 * This program is free software; you can redistribute it and/or modify
6 * it under the terms of the GNU General Public License as published by
7 * the Free Software Foundation; either version 2 of the License, or
8 * (at your option) any later version.
9 *
10 * This program is distributed in the hope that it will be useful,
11 * but WITHOUT ANY WARRANTY; without even the implied warranty of
12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 * GNU General Public License for more details.
14 *
15 * You should have received a copy of the GNU General Public License
16 * along with this program; if not, write to the Free Software
17 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
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 /* Implement IntAccount. */
53 public void onIncomingCall(CallInfoRT info)
54 {
55 if (Current.VoipCall != null)
56 {
57 /* Only one active call */
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 /* Implement IntCall. */
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 }