73ef4ff3
Hu Chunming
提交三方库
|
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
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
|
/**
* @ingroup libeXosip2 The eXtented eXosip stack
* @defgroup howto_registration How-To send or update registrations.
<H2>Initiate a registration</H2>
To start a registration, you need to build a default REGISTER request
by providing several mandatory headers.
You can start as many registration you want even in one eXosip_t context.
~~~~~~~{.c}
osip_message_t *reg = NULL;
int rid;
int i;
eXosip_lock (ctx);
rid = eXosip_register_build_initial_register (ctx, "sip:me@sip.antisip.com", "sip.antisip.com", NULL, 1800, ®);
if (rid < 0)
{
eXosip_unlock (ctx);
return -1;
}
osip_message_set_supported (reg, "100rel");
osip_message_set_supported (reg, "path");
i = eXosip_register_send_register (ctx, rid, reg);
eXosip_unlock (ctx);
return i;
~~~~~~~
The returned element of eXosip_register_build_initial_register is the
registration identifier that you can use to update your registration.
In future events about this registration, you'll see that registration
identifier when applicable.
<H2>Contact headers in REGISTER</H2>
You should let eXosip2 manage contact headers alone. The setup you
have provided will generate various behavior, all being controlled
by eXosip2. See the "NAT and Contact header" section in setup
documentation.
<H2>Set password(s)!</H2>
Usually, you will need a login/password to access a service!
eXosip can be used to access several service at the same time and thus
the realm (identify the service) needs to be provided if you are
using several services in the same instance.
The simple way when you use one service with username being the same
as the login:
~~~~~~~{.c}
eXosip_lock (ctx);
eXosip_add_authentication_info (ctx, login, login, passwd, NULL, NULL);
eXosip_unlock (ctx);
~~~~~~~
OR the complete way:
~~~~~~~{.c}
eXosip_lock (ctx);
eXosip_add_authentication_info (ctx, login, login, passwd, NULL, "sip.antisip.com");
eXosip_add_authentication_info (ctx, from_username, login, passwd, NULL, "otherservice.com");
eXosip_unlock (ctx);
~~~~~~~
<H2>Delete all registration</H2>
This feature is not advised by sip specification, but it exists for some
purpose & reasons! You can send "*" in Contact header of a REGISTER to
ask for immediate removal of all active registrations for a particular
SIP agent:
~~~~~~~{.c}
rid = eXosip_register_build_initial_register (ctx, "sip:me@sip.antisip.com", "sip.antisip.com", "*", 1800, ®);
~~~~~~~
<H2>Update a registration</H2>
You just need to reuse the registration identifier:
~~~~~~~{.c}
int i;
eXosip_lock (ctx);
i = eXosip_register_build_register (ctx, rid, 1800, ®);
if (i < 0)
{
eXosip_unlock (ctx);
return -1;
}
eXosip_register_send_register (ctx, rid, reg);
eXosip_unlock (ctx);
~~~~~~~
<b>Note</b>: The above code also shows that the stack is sometimes able to
build and send a default SIP messages with only one API call
<H2>Closing the registration</H2>
A softphone should delete its registration on the SIP server when terminating.
To do so, you have to send a REGISTER request with the expires header set to
value "0".
The same code as for updating a registration is used with 0 instead of 1800
for the expiration delay.
~~~~~~~{.c}
int i;
eXosip_lock (ctx);
i = eXosip_register_build_register (ctx, rid, 0, ®);
if (i < 0)
{
eXosip_unlock (ctx);
return -1;
}
eXosip_register_send_register (ctx, rid, reg);
eXosip_unlock (ctx);
~~~~~~~
<H2>Discard registration context</H2>
If you need to delete a context without sending a REGISTER with expires 0,
you can use eXosip_register_remove to release memory.
~~~~~~~{.c}
int i;
eXosip_lock (ctx);
i = eXosip_register_remove (ctx, rid);
if (i == 0) {
}
eXosip_unlock (ctx);
~~~~~~~
*/
|