1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
|
/*
Copyright (C) 2009 Ricardo Pescuma Domenecci
This is free software; you can redistribute it and/or
modify it under the terms of the GNU Library General Public
License as published by the Free Software Foundation; either
version 2 of the License, or (at your option) any later version.
This is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
Library General Public License for more details.
You should have received a copy of the GNU Library General Public
License along with this file; see the file license.txt. If
not, write to the Free Software Foundation, Inc., 59 Temple Place - Suite 330,
Boston, MA 02111-1307, USA.
*/
#ifndef __SIPCLIENT_H__
#define __SIPCLIENT_H__
class SIPClient
{
private:
HANDLE hNetlibUser;
bool hasToDestroy;
public:
struct ta {
pjsua_transport_id transport_id;
pjsua_acc_id acc_id;
TCHAR host[256];
int port;
};
ta udp;
ta tcp;
ta tls;
SIPClientCallback callback;
void *callback_param;
char name[512];
CRITICAL_SECTION cs;
std::vector<SIPEvent> events;
SIPClient(SIP_REGISTRATION *reg);
virtual ~SIPClient();
void on_incoming_call(pjsua_call_id call_id);
void on_call_state(pjsua_call_id call_id, const pjsua_call_info &info);
bool on_call_media_state_sync(pjsua_call_id call_id, const pjsua_call_info &info);
void on_call_media_state(pjsua_call_id call_id);
pjsua_call_id Call(const TCHAR *host, int port, int protocol);
int DropCall(pjsua_call_id call_id);
int HoldCall(pjsua_call_id call_id);
int AnswerCall(pjsua_call_id call_id);
int SendDTMF(pjsua_call_id call_id, TCHAR dtmf);
int Connect(SIP_REGISTRATION *reg);
void Disconnect();
private:
void Trace(TCHAR *fmt, ...);
void Info(TCHAR *fmt, ...);
void Error(TCHAR *fmt, ...);
void Error(pj_status_t status, TCHAR *fmt, ...);
void ShowMessage(int type, TCHAR *fmt, va_list args);
void RegisterTransport(pjsip_transport_type_e type, int port, ta *ta);
void ConfigureDevices();
void BuildURI(TCHAR *out, int outSize, const TCHAR *host, int port, pjsip_transport_type_e transport);
void CleanupURI(TCHAR *out, int outSize, const TCHAR *url);
void NotifyCall(pjsua_call_id call_id, int state, const TCHAR *host_port = NULL);
};
#endif // __SIPCLIENT_H__
|