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
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
|
/*
* Copyright (C) 2009 Mamadou Diop.
*
* Contact: Mamadou Diop <diopmamadou(at)yahoo.fr>
*
* This file is part of Open Source Doubango Framework.
*
* DOUBANGO is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* DOUBANGO 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 General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with DOUBANGO.
*
*/
#ifndef _TEST_QOS_H_
#define _TEST_QOS_H_
char* test_qos_tostring(const tmedia_qos_tline_t* tline)
{
char* ret = tsk_null;
tsdp_header_M_t* M;
if(!tline){
TSK_DEBUG_ERROR("Invalid parameter");
return tsk_null;
}
M = tsdp_header_M_create("audio", 20000, "RTP/AVP");
tmedia_qos_tline_to_sdp(tline, M);
ret = tsdp_header_tostring(TSDP_HEADER(M));
TSK_OBJECT_SAFE_FREE(M);
return ret;
}
void test_qos_parser()
{
tsdp_header_M_t* M;
tmedia_qos_tline_e2e_t* e2e;
tmedia_qos_tline_segmented_t* segmented;
char* temp = tsk_null;
tmedia_qos_stype_t type;
tsk_bool_t canresume;
/* test E2E */
M = tsdp_header_M_create("audio", 20000, "RTP/AVP");
e2e = tmedia_qos_tline_e2e_create(tmedia_qos_strength_mandatory);
// to_sdp
tmedia_qos_tline_e2e_to_sdp(e2e, M);
if((type = tmedia_qos_get_type(M)) != tmedia_qos_stype_e2e){
TSK_DEBUG_ERROR("Invalid type");
}
if((temp = tsdp_header_tostring(TSDP_HEADER(M)))){
TSK_DEBUG_INFO("E2E to_sdp: %s", temp);
TSK_FREE(temp);
}
// from_sdp
TSK_OBJECT_SAFE_FREE(e2e);
e2e = tmedia_qos_tline_e2e_from_sdp(M);
canresume = tmedia_qos_tline_e2e_canresume(e2e);
tmedia_qos_tline_e2e_to_sdp(e2e, M);
if((temp = tsdp_header_tostring(TSDP_HEADER(M)))){
TSK_DEBUG_INFO("e2e from_sdp: %s", temp);
TSK_FREE(temp);
}
TSK_OBJECT_SAFE_FREE(e2e);
TSK_OBJECT_SAFE_FREE(M);
/* test Segmented */
M = tsdp_header_M_create("video", 20002, "RTP/AVP");
segmented = tmedia_qos_tline_segmented_create(tmedia_qos_strength_none);
segmented->remote_send.strength = tmedia_qos_strength_optional;
// to_sdp
tmedia_qos_tline_segmented_to_sdp(segmented, M);
if((type = tmedia_qos_get_type(M)) != tmedia_qos_stype_segmented){
TSK_DEBUG_ERROR("Invalid type");
}
if((temp = tsdp_header_tostring(TSDP_HEADER(M)))){
TSK_DEBUG_INFO("Segmented to_sdp: %s", temp);
TSK_FREE(temp);
}
// from_sdp
TSK_OBJECT_SAFE_FREE(segmented);
segmented = tmedia_qos_tline_segmented_from_sdp(M);
canresume = tmedia_qos_tline_segmented_canresume(segmented);
tmedia_qos_tline_segmented_to_sdp(segmented, M);
if((temp = tsdp_header_tostring(TSDP_HEADER(M)))){
TSK_DEBUG_INFO("Segmented from_sdp: %s", temp);
TSK_FREE(temp);
}
TSK_OBJECT_SAFE_FREE(segmented);
TSK_OBJECT_SAFE_FREE(M);
}
void test_qos_e2e_neg()
{
tmedia_qos_tline_e2e_t *e2eA = tsk_null, *e2eB = tsk_null;
char* temp = tsk_null;
/* SDP1: A includes end-to-end quality of service preconditions in the
initial offer.
m=audio 20000 RTP/AVP 0
c=IN IP4 192.0.2.1
a=curr:qos e2e none
a=des:qos mandatory e2e sendrecv
*/
e2eA = tmedia_qos_tline_e2e_create(tmedia_qos_strength_mandatory);
if((temp = test_qos_tostring((const tmedia_qos_tline_t*)e2eA))){
TSK_DEBUG_INFO("SDP1=\n%s", temp);
TSK_FREE(temp);
}
/* SDP2: Since B uses RSVP, it can know when resources in its "send"
direction are available, because it will receive RESV messages from
the network. However, it does not know the status of the
reservations in the other direction. B requests confirmation for
resource reservations in its "recv" direction to the peer user agent
A in its answer.
m=audio 30000 RTP/AVP 0
c=IN IP4 192.0.2.4
a=curr:qos e2e none
a=des:qos mandatory e2e sendrecv
a=conf:qos e2e recv
*/
e2eB = tmedia_qos_tline_e2e_create(tmedia_qos_strength_mandatory);
tmedia_qos_tline_e2e_set_ro(e2eB, e2eA);
if((temp = test_qos_tostring((const tmedia_qos_tline_t*)e2eB))){
TSK_DEBUG_INFO("SDP2=\n%s", temp);
TSK_FREE(temp);
}
/* SDP3: When A receives RESV messages, it sends an updated offer (5) to B:
m=audio 20000 RTP/AVP 0
c=IN IP4 192.0.2.1
a=curr:qos e2e send
a=des:qos mandatory e2e sendrecv
*/
tmedia_qos_tline_e2e_set_ro(e2eA, e2eB);
if((temp = test_qos_tostring((const tmedia_qos_tline_t*)e2eA))){
TSK_DEBUG_INFO("SDP3=\n%s", temp);
TSK_FREE(temp);
}
/* SDP4: B responds with an answer (6) which contains the current status
of the resource reservation (i.e., sendrecv):
m=audio 30000 RTP/AVP 0
c=IN IP4 192.0.2.4
a=curr:qos e2e sendrecv
a=des:qos mandatory e2e sendrecv
*/
tmedia_qos_tline_e2e_set_ro(e2eB, e2eA);
if((temp = test_qos_tostring((const tmedia_qos_tline_t*)e2eB))){
TSK_DEBUG_INFO("SDP4=\n%s", temp);
TSK_FREE(temp);
}
/* A receive B's response */
tmedia_qos_tline_e2e_set_ro(e2eA, e2eB);
if((temp = test_qos_tostring((const tmedia_qos_tline_t*)e2eA))){
TSK_DEBUG_INFO("SDP5=\n%s", temp);
TSK_FREE(temp);
}
if(tmedia_qos_tline_e2e_canresume(e2eA)){
TSK_DEBUG_INFO("A can resume");
}
else{
TSK_DEBUG_ERROR("A can't resume");
}
if(tmedia_qos_tline_e2e_canresume(e2eB)){
TSK_DEBUG_INFO("B can resume");
}
else{
TSK_DEBUG_ERROR("B can't resume");
}
TSK_OBJECT_SAFE_FREE(e2eB);
TSK_OBJECT_SAFE_FREE(e2eA);
}
void test_qos_segmented_neg()
{
tmedia_qos_tline_segmented_t *segA = tsk_null, *segB = tsk_null;
char* temp = tsk_null;
/* INVITE
a=curr:qos local none
a=curr:qos remote none
a=des:qos mandatory local sendrecv
a=des:qos mandatory remote sendrecv
*/
segA = tmedia_qos_tline_segmented_create(tmedia_qos_strength_mandatory);
if((temp = test_qos_tostring((const tmedia_qos_tline_t*)segA))){
TSK_DEBUG_INFO("INVITE=\n%s", temp);
TSK_FREE(temp);
}
/* 183 Sesson progress
a=curr:qos local none
a=curr:qos remote none
a=des:qos mandatory local sendrecv
a=des:qos mandatory remote sendrecv
a=conf:qos remote sendrecv
*/
segB = tmedia_qos_tline_segmented_create(tmedia_qos_strength_mandatory);
tmedia_qos_tline_segmented_set_ro(segB, segA);
if((temp = test_qos_tostring((const tmedia_qos_tline_t*)segB))){
TSK_DEBUG_INFO("183=\n%s", temp);
TSK_FREE(temp);
}
/* UPDATE
a=curr:qos local sendrecv
a=curr:qos remote none
a=des:qos mandatory local sendrecv
a=des:qos mandatory remote sendrecv
*/
tmedia_qos_tline_segmented_set_ro(segA, segB);
if((temp = test_qos_tostring((const tmedia_qos_tline_t*)segA))){
TSK_DEBUG_INFO("UPDATE=\n%s", temp);
TSK_FREE(temp);
}
/* 200 OK
a=curr:qos local sendrecv
a=curr:qos remote sendrecv
a=des:qos mandatory local sendrecv
a=des:qos mandatory remote sendrecv
*/
tmedia_qos_tline_segmented_set_ro(segB, segA);
if((temp = test_qos_tostring((const tmedia_qos_tline_t*)segB))){
TSK_DEBUG_INFO("200OK=\n%s", temp);
TSK_FREE(temp);
}
TSK_OBJECT_SAFE_FREE(segA);
TSK_OBJECT_SAFE_FREE(segB);
}
void test_qos()
{
//test_qos_parser();
//test_qos_e2e_neg();
test_qos_segmented_neg();
}
#endif /* _TEST_QOS_H_ */
|