1
/* $Id: sdptest.c 3553 2011-05-05 06:14:19Z nanang $ */
3
* Copyright (C) 2008-2011 Teluu Inc. (http://www.teluu.com)
4
* Copyright (C) 2003-2008 Benny Prijono <benny@prijono.org>
6
* This program is free software; you can redistribute it and/or modify
7
* it under the terms of the GNU General Public License as published by
8
* the Free Software Foundation; either version 2 of the License, or
9
* (at your option) any later version.
11
* This program is distributed in the hope that it will be useful,
12
* but WITHOUT ANY WARRANTY; without even the implied warranty of
13
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14
* GNU General Public License for more details.
16
* You should have received a copy of the GNU General Public License
17
* along with this program; if not, write to the Free Software
18
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
20
#include <pjmedia/sdp.h>
26
static char *sdp[] = {
29
"o=mhandley 2890844526 2890842807 IN IP4 126.16.64.4\r\n"
31
"i=A Seminar on the session description protocol\r\n"
32
"u=http://www.cs.ucl.ac.uk/staff/M.Handley/sdp.03.ps\r\n"
33
"e=mjh@isi.edu (Mark Handley)\r\n"
34
"c=IN IP4 224.2.17.12/127\r\n"
35
"t=2873397496 2873404696\r\n"
37
"m=audio 49170 RTP/AVP 0\r\n"
38
"m=video 51372 RTP/AVP 31\r\n"
39
"m=application 32416 udp wb\r\n"
40
"a=orient:portrait\r\n"
41
"m=audio 49230 RTP/AVP 96 97 98\r\n"
42
"a=rtpmap:96 L8/8000\r\n"
43
"a=rtpmap:97 L16/8000\r\n"
44
"a=rtpmap:98 L16/11025/2\r\n",
47
"o=usera 2890844526 2890844527 IN IP4 alice.example.com\r\n"
49
"c=IN IP4 alice.example.com\r\n"
51
"m=message 7394 msrp/tcp *\r\n"
52
"a=accept-types: message/cpim text/plain text/html\r\n"
53
"a=path:msrp://alice.example.com:7394/2s93i9;tcp\r\n"
56
static int sdp_perform_test(pj_pool_factory *pf)
60
pjsdp_session_desc *ses;
62
enum { LOOP=1000000 };
64
pj_time_val start, end;
66
printf("Parsing and printing %d SDP messages..\n", LOOP);
68
pool = pj_pool_create(pf, "", 4096, 0, NULL);
69
inputlen = strlen(sdp[0]);
70
pj_gettimeofday(&start);
71
for (i=0; i<LOOP; ++i) {
72
ses = pjsdp_parse(sdp[0], inputlen, pool);
73
len = pjsdp_print(ses, buf, sizeof(buf));
77
pj_gettimeofday(&end);
79
printf("Original:\n%s\n", sdp[0]);
80
printf("Parsed:\n%s\n", buf);
82
PJ_TIME_VAL_SUB(end, start);
83
printf("Time: %ld:%03lds\n", end.sec, end.msec);
85
if (end.msec==0 && end.sec==0) end.msec=1;
86
printf("Performance: %ld msg/sec\n", LOOP*1000/PJ_TIME_VAL_MSEC(end));
89
pj_pool_release(pool);
93
static int sdp_conform_test(pj_pool_factory *pf)
96
pjsdp_session_desc *ses;
100
for (i=0; i<sizeof(sdp)/sizeof(sdp[0]); ++i) {
101
pool = pj_pool_create(pf, "sdp", 4096, 0, NULL);
102
ses = pjsdp_parse(sdp[i], strlen(sdp[i]), pool);
103
len = pjsdp_print(ses, buf, sizeof(buf));
106
pj_pool_release(pool);
112
pj_status_t sdp_test(pj_pool_factory *pf)
114
if (sdp_conform_test(pf) != 0)
117
if (sdp_perform_test(pf) != 0)