blob: f769ba58fb8fb22c94020c812804ba67d26d3c9e [file] [log] [blame]
Alexandre Lision8af73cb2013-12-10 14:11:20 -05001import py_pjsua
2
3status = py_pjsua.create()
4print "py status " + `status`
5
6
7#
8# Create configuration objects
9#
10ua_cfg = py_pjsua.config_default()
11log_cfg = py_pjsua.logging_config_default()
12media_cfg = py_pjsua.media_config_default()
13
14#
15# Logging callback.
16#
17def logging_cb1(level, str, len):
18 print str,
19
20
21#
22# Configure logging
23#
24log_cfg.cb = logging_cb1
25log_cfg.console_level = 4
26
27#
28# Initialize pjsua!
29#
30status = py_pjsua.init(ua_cfg, log_cfg, media_cfg);
31print "py status after initialization :" + `status`
32
33
34#
35# Start pjsua!
36#
37status = py_pjsua.start()
38if status != 0:
39 exit(1)
40
41
42message = py_pjsua.msg_data_init()
43
44print "identitas object message data :" + `message`
45
46sipaddr = 'sip:167.205.34.99'
47print "checking sip address [%s] : %d" % (sipaddr, py_pjsua.verify_sip_url(sipaddr))
48
49sipaddr = '167.205.34.99'
50print "checking invalid sip address [%s] : %d" % (sipaddr, py_pjsua.verify_sip_url(sipaddr))
51
52object = py_pjsua.get_pjsip_endpt()
53print "identitas Endpoint :" + `object` + ""
54
55mediaend = py_pjsua.get_pjmedia_endpt()
56print "identitas Media Endpoint :" + `mediaend` + ""
57
58pool = py_pjsua.get_pool_factory()
59print "identitas pool factory :" + `pool` + ""
60
61status = py_pjsua.handle_events(3000)
62print "py status after 3 second of blocking wait :" + `status`
63
64
65
66# end of new testrun
67
68#
69
70# lib transport
71stunc = py_pjsua.stun_config_default();
72
73
74tc = py_pjsua.transport_config_default();
75
76
77py_pjsua.normalize_stun_config(stunc);
78
79
80status, id = py_pjsua.transport_create(1, tc);
81print "py transport create status " + `status`
82
83ti = py_pjsua.Transport_Info();
84ti = py_pjsua.transport_get_info(id)
85print "py transport get info status " + `status`
86
87status = py_pjsua.transport_set_enable(id,1)
88print "py transport set enable status " + `status`
89if status != 0 :
90 py_pjsua.perror("py_pjsua","set enable",status)
91
92
93status = py_pjsua.transport_close(id,1)
94print "py transport close status " + `status`
95if status != 0 :
96 py_pjsua.perror("py_pjsua","close",status)
97
98# end of lib transport
99
100# lib account
101
102accfg = py_pjsua.acc_config_default()
103status, accid = py_pjsua.acc_add(accfg, 1)
104print "py acc add status " + `status`
105if status != 0 :
106 py_pjsua.perror("py_pjsua","add acc",status)
107count = py_pjsua.acc_get_count()
108print "acc count " + `count`
109
110accid = py_pjsua.acc_get_default()
111
112print "acc id default " + `accid`
113
114# end of lib account
115
116#lib buddy
117
118bcfg = py_pjsua.Buddy_Config()
119status, id = py_pjsua.buddy_add(bcfg)
120acc_id = id
121print "py buddy add status " + `status` + " id " + `id`
122bool = py_pjsua.buddy_is_valid(id)
123print "py buddy is valid " + `bool`
124count = py_pjsua.get_buddy_count()
125print "buddy count " + `count`
126binfo = py_pjsua.buddy_get_info(id)
127ids = py_pjsua.enum_buddies()
128status = py_pjsua.buddy_del(id)
129print "py buddy del status " + `status`
130status = py_pjsua.buddy_subscribe_pres(id, 1)
131print "py buddy subscribe pres status " + `status`
132py_pjsua.pres_dump(1)
133status = py_pjsua.im_send(accid, "fahris@divusi.com", "", "hallo", message, 0)
134print "py im send status " + `status`
135status = py_pjsua.im_typing(accid, "fahris@divusi.com", 1, message)
136print "py im typing status " + `status`
137#print "binfo " + `binfo`
138
139#end of lib buddy
140
141#lib media
142count = py_pjsua.conf_get_max_ports()
143print "py media conf get max ports " + `count`
144count = py_pjsua.conf_get_active_ports()
145print "py media conf get active ports " + `count`
146ids = py_pjsua.enum_conf_ports()
147for id in ids:
148 print "py media conf ports " + `id`
149 cp_info = py_pjsua.conf_get_port_info(id)
150 print "port info name " + cp_info.name
151pool = py_pjsua.PJ_Pool()
152port = py_pjsua.PJMedia_Port()
153status, id = py_pjsua.conf_add_port(pool,port)
154print "py media conf add port status " + `status` + " id " + `id`
155if status != 0 :
156 py_pjsua.perror("py_pjsua","add port",status)
157status = py_pjsua.conf_remove_port(id)
158print "py media conf remove port status " + `status`
159if status != 0 :
160 py_pjsua.perror("py_pjsua","remove port",status)
161status = py_pjsua.conf_connect(id, id)
162print "py media conf connect status " + `status`
163if status != 0 :
164 py_pjsua.perror("py_pjsua","connect",status)
165status = py_pjsua.conf_disconnect(id, id)
166print "py media conf disconnect status " + `status`
167if status != 0 :
168 py_pjsua.perror("py_pjsua","disconnect",status)
169status, id = py_pjsua.player_create("test.wav", 0)
170print "py media player create status " + `status` + " id " + `id`
171if status != 0 :
172 py_pjsua.perror("py_pjsua","player create",status)
173c_id = py_pjsua.player_get_conf_port(id)
174print "py media player get conf port id " + `c_id`
175status = py_pjsua.player_set_pos(id, 10)
176if status != 0 :
177 py_pjsua.perror("py_pjsua","player set pos",status)
178status = py_pjsua.player_destroy(id)
179if status != 0 :
180 py_pjsua.perror("py_pjsua","player destroy",status)
181status, id = py_pjsua.recorder_create("rec.wav", 0, "None", 1000, 0)
182print "py media recorder create status " + `status` + " id " + `id`
183if status != 0 :
184 py_pjsua.perror("py_pjsua","recorder create",status)
185status = py_pjsua.recorder_get_conf_port(id)
186print "py media recorder get conf port status " + `status`
187if status != 0 :
188 py_pjsua.perror("py_pjsua","recorder get conf port",status)
189status = py_pjsua.recorder_destroy(id)
190print "py media recorder destroy status " + `status`
191if status != 0 :
192 py_pjsua.perror("py_pjsua","recorder destroy",status)
193#cdev, pdev = py_pjsua.get_snd_dev()
194#print "py media get snd dev capture dev " + `cdev` + " playback dev " + `pdev`
195status = py_pjsua.set_snd_dev(0,1)
196print "py media set snd dev status " + `status`
197if status != 0 :
198 py_pjsua.perror("py_pjsua","set snd dev",status)
199status = py_pjsua.set_null_snd_dev()
200print "py media set null snd dev status " + `status`
201if status != 0 :
202 py_pjsua.perror("py_pjsua","set null snd dev",status)
203port = py_pjsua.set_no_snd_dev()
204status = py_pjsua.set_ec(0,0)
205print "py media set ec status " + `status`
206if status != 0 :
207 py_pjsua.perror("py_pjsua","set ec",status)
208tail = py_pjsua.get_ec_tail()
209print "py media get ec tail " + `tail`
210infos = py_pjsua.enum_codecs()
211for info in infos:
212 print "py media enum codecs " + `info`
213status = py_pjsua.codec_set_priority("coba", 0)
214print "py media codec set priority " + `status`
215if status != 0 :
216 py_pjsua.perror("py_pjsua","codec set priority",status)
217c_param = py_pjsua.codec_get_param("coba")
218status = py_pjsua.codec_set_param("coba", c_param)
219print "py media codec set param " + `status`
220if status != 0 :
221 py_pjsua.perror("py_pjsua","codec set param",status)
222
223#end of lib media
224
225#lib call
226
227count = py_pjsua.call_get_max_count()
228print "py call get max count " + `count`
229count = py_pjsua.call_get_count()
230print "py call get count " + `count`
231ids = py_pjsua.enum_calls()
232for id in ids:
233 print "py enum calls id " + `id`
234msg_data = py_pjsua.Msg_Data()
235status, id = py_pjsua.call_make_call(-1, "sip:bulukucing1@iptel.org", 0, 0, msg_data)
236print "py call make call " + `status` + " id " + `id`
237if status != 0 :
238 py_pjsua.perror("py_pjsua","call make call",status)
239bool = py_pjsua.call_is_active(id)
240print "py call is active " + `bool`
241bool = py_pjsua.call_has_media(id)
242print "py call has media " + `bool`
243cp_id = py_pjsua.call_get_conf_port(id)
244print "py call get conf port " + `cp_id`
245info = py_pjsua.call_get_info(id)
246if info != None :
247 print "py info id " + `info.id`
248status = py_pjsua.call_set_user_data(id, 0)
249print "py call set user data status " + `status`
250if status != 0 :
251 py_pjsua.perror("py_pjsua","set user data",status)
252user_data = py_pjsua.call_get_user_data(id)
253print "py call get user data " + `user_data`
254
255
256
257#end of lib call
258
259py_pjsua.perror("saya","hallo",70006)
260
261status = py_pjsua.destroy()
262print "py status " + `status`
263
264