Debian Codegraph @

Xpjproject/pjsip-apps/src/vidgui/vidgui.cpp

raw symbols SCIP
1 /*
2 * Copyright (C) 2011-2011 Teluu Inc. (http://www.teluu.com)
3 *
4 * This program is free software; you can redistribute it and/or modify
5 * it under the terms of the GNU General Public License as published by
6 * the Free Software Foundation; either version 2 of the License, or
7 * (at your option) any later version.
8 *
9 * This program is distributed in the hope that it will be useful,
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 * GNU General Public License for more details.
13 *
14 * You should have received a copy of the GNU General Public License
15 * along with this program; if not, write to the Free Software
16 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
17 */
18 #include "vidgui.h"
19 #include "vidwin.h"
20
21 #if defined(PJ_WIN32)
22 # define SDL_MAIN_HANDLED
23 #endif
24
25 #include <SDL.h>
26 #include <assert.h>
27 #include <QMessageBox>
28
29 #define LOG_FILE "vidgui.log"
30 #define THIS_FILE "vidgui.cpp"
31
32 ///////////////////////////////////////////////////////////////////////////
33 //
34 // SETTINGS
35 //
36
37 //
38 // These configure SIP registration
39 //
40 #define USE_REGISTRATION 0
41 #define SIP_DOMAIN "pjsip.org"
42 #define SIP_USERNAME "vidgui"
43 #define SIP_PASSWORD "secret"
44 #define SIP_PORT 5080
45 #define SIP_TCP 1
46
47 //
48 // NAT helper settings
49 //
50 #define USE_ICE 1
51 #define USE_STUN 0
52 #define STUN_SRV "stun.pjsip.org"
53
54 //
55 // Devices settings
56 //
57 #define DEFAULT_CAP_DEV PJMEDIA_VID_DEFAULT_CAPTURE_DEV
58 //#define DEFAULT_CAP_DEV 1
59 #define DEFAULT_REND_DEV PJMEDIA_VID_DEFAULT_RENDER_DEV
60
61
62 //
63 // End of Settings
64 ///////////////////////////////////////////////////////////////////////////
65
66
67 MainWin *MainWin::theInstance_;
68
69 MainWin::MainWin(QWidget *parent)
70 : QWidget(parent), accountId_(-1), currentCall_(-1),
71 preview_on(false), video_(NULL), video_prev_(NULL)
72 {
73 theInstance_ = this;
74
75 initLayout();
76 emit signalCallReleased();
77 }
78
79 MainWin::~MainWin()
80 {
81 quit();
82 theInstance_ = NULL;
83 }
84
85 MainWin *MainWin::instance()
86 {
87 return theInstance_;
88 }
89
90 void MainWin::initLayout()
91 {
92 //statusBar_ = new QStatusBar(this);
93
94 /* main layout */
95 QHBoxLayout *hbox_main = new QHBoxLayout;
96 //QVBoxLayout *vbox_left = new QVBoxLayout;
97 vbox_left = new QVBoxLayout;
98 QVBoxLayout *vbox_right = new QVBoxLayout;
99 hbox_main->addLayout(vbox_left);
100 hbox_main->addLayout(vbox_right);
101
102 /* Left pane */
103 QHBoxLayout *hbox_url = new QHBoxLayout;
104 hbox_url->addWidget(new QLabel(tr("Url:")));
105 hbox_url->addWidget(url_=new QLineEdit(tr("sip:")), 1);
106 vbox_left->addLayout(hbox_url);
107
108 /* Right pane */
109 vbox_right->addWidget((localUri_ = new QLabel));
110 vbox_right->addWidget((vidEnabled_ = new QCheckBox(tr("Enable &video"))));
111 vbox_right->addWidget((previewButton_=new QPushButton(tr("Start &Preview"))));
112 vbox_right->addWidget((callButton_=new QPushButton(tr("Call"))));
113 vbox_right->addWidget((hangupButton_=new QPushButton(tr("Hangup"))));
114 vbox_right->addWidget((quitButton_=new QPushButton(tr("Quit"))));
115
116 #if PJMEDIA_HAS_VIDEO
117 vidEnabled_->setCheckState(Qt::Checked);
118 #else
119 vidEnabled_->setCheckState(Qt::Unchecked);
120 vidEnabled_->setEnabled(false);
121 #endif
122
123 /* Outest layout */
124 QVBoxLayout *vbox_outest = new QVBoxLayout;
125 vbox_outest->addLayout(hbox_main);
126 vbox_outest->addWidget((statusBar_ = new QLabel));
127
128 setLayout(vbox_outest);
129
130 connect(previewButton_, SIGNAL(clicked()), this, SLOT(preview()));
131 connect(callButton_, SIGNAL(clicked()), this, SLOT(call()));
132 connect(hangupButton_, SIGNAL(clicked()), this, SLOT(hangup()));
133 connect(quitButton_, SIGNAL(clicked()), this, SLOT(quit()));
134 //connect(this, SIGNAL(close()), this, SLOT(quit()));
135 connect(vidEnabled_, SIGNAL(stateChanged(int)), this, SLOT(onVidEnabledChanged(int)));
136
137 // UI updates must be done in the UI thread!
138 connect(this, SIGNAL(signalNewCall(int, bool)),
139 this, SLOT(onNewCall(int, bool)));
140 connect(this, SIGNAL(signalCallReleased()),
141 this, SLOT(onCallReleased()));
142 connect(this, SIGNAL(signalInitVideoWindow()),
143 this, SLOT(initVideoWindow()));
144 connect(this, SIGNAL(signalShowStatus(const QString&)),
145 this, SLOT(doShowStatus(const QString&)));
146 }
147
148 void MainWin::quit()
149 {
150 delete video_prev_;
151 video_prev_ = NULL;
152 delete video_;
153 video_ = NULL;
154
155 pjsua_destroy();
156 qApp->quit();
157 }
158
159 void MainWin::showStatus(const char *msg)
160 {
161 PJ_LOG(3,(THIS_FILE, "%s", msg));
162
163 QString msg_ = QString::fromUtf8(msg);
164 emit signalShowStatus(msg_);
165 }
166
167 void MainWin::doShowStatus(const QString& msg)
168 {
169 //statusBar_->showMessage(msg);
170 statusBar_->setText(msg);
171 }
172
173 void MainWin::showError(const char *title, pj_status_t status)
174 {
175 char errmsg[PJ_ERR_MSG_SIZE];
176 char errline[120];
177
178 pj_strerror(status, errmsg, sizeof(errmsg));
179 snprintf(errline, sizeof(errline), "%s error: %s", title, errmsg);
180 showStatus(errline);
181 }
182
183 void MainWin::onVidEnabledChanged(int state)
184 {
185 pjsua_call_setting call_setting;
186
187 if (currentCall_ == -1)
188 return;
189
190 pjsua_call_setting_default(&call_setting);
191 call_setting.vid_cnt = (state == Qt::Checked);
192
193 pjsua_call_reinvite2(currentCall_, &call_setting, NULL);
194 }
195
196 void MainWin::onNewCall(int cid, bool incoming)
197 {
198 pjsua_call_info ci;
199
200 pj_assert(currentCall_ == -1);
201 currentCall_ = cid;
202
203 pjsua_call_get_info(cid, &ci);
204 url_->setText(ci.remote_info.ptr);
205 url_->setEnabled(false);
206 hangupButton_->setEnabled(true);
207
208 if (incoming) {
209 callButton_->setText(tr("Answer"));
210 callButton_->setEnabled(true);
211 } else {
212 callButton_->setEnabled(false);
213 }
214
215 //video_->setText(ci.remote_contact.ptr);
216 //video_->setWindowTitle(ci.remote_contact.ptr);
217 }
218
219 void MainWin::onCallReleased()
220 {
221 url_->setEnabled(true);
222 callButton_->setEnabled(true);
223 callButton_->setText(tr("Call"));
224 hangupButton_->setEnabled(false);
225 currentCall_ = -1;
226
227 delete video_;
228 video_ = NULL;
229 }
230
231 void MainWin::preview()
232 {
233 if (preview_on) {
234 delete video_prev_;
235 video_prev_ = NULL;
236
237 pjsua_vid_preview_stop(DEFAULT_CAP_DEV);
238
239 showStatus("Preview stopped");
240 previewButton_->setText(tr("Start &Preview"));
241 } else {
242 pjsua_vid_win_id wid;
243 pjsua_vid_win_info wi;
244 pjsua_vid_preview_param pre_param;
245 pj_status_t status;
246
247 pjsua_vid_preview_param_default(&pre_param);
248 pre_param.rend_id = DEFAULT_REND_DEV;
249 pre_param.show = PJ_FALSE;
250
251 status = pjsua_vid_preview_start(DEFAULT_CAP_DEV, &pre_param);
252 if (status != PJ_SUCCESS) {
253 char errmsg[PJ_ERR_MSG_SIZE];
254 pj_strerror(status, errmsg, sizeof(errmsg));
255 QMessageBox::critical(0, "Error creating preview", errmsg);
256 return;
257 }
258 wid = pjsua_vid_preview_get_win(DEFAULT_CAP_DEV);
259 pjsua_vid_win_get_info(wid, &wi);
260
261 video_prev_ = new VidWin(&wi.hwnd);
262 video_prev_->putIntoLayout(vbox_left);
263 //Using this will cause SDL window to display blank
264 //screen sometimes, probably because it's using different
265 //X11 Display
266 //status = pjsua_vid_win_set_show(wid, PJ_TRUE);
267 //This is handled by VidWin now
268 //video_prev_->show_sdl();
269 showStatus("Preview started");
270
271 previewButton_->setText(tr("Stop &Preview"));
272 }
273 preview_on = !preview_on;
274 }
275
276
277 void MainWin::call()
278 {
279 if (callButton_->text() == "Answer") {
280 pjsua_call_setting call_setting;
281
282 pj_assert(currentCall_ != -1);
283
284 pjsua_call_setting_default(&call_setting);
285 call_setting.vid_cnt = (vidEnabled_->checkState()==Qt::Checked);
286
287 pjsua_call_answer2(currentCall_, &call_setting, 200, NULL, NULL);
288 callButton_->setEnabled(false);
289 } else {
290 pj_status_t status;
291 QString dst = url_->text();
292 char uri[256];
293 pjsua_call_setting call_setting;
294
295 pj_ansi_strxcpy(uri, dst.toUtf8().data(), sizeof(uri));
296 pj_str_t uri2 = pj_str((char*)uri);
297
298 pj_assert(currentCall_ == -1);
299
300 pjsua_call_setting_default(&call_setting);
301 call_setting.vid_cnt = (vidEnabled_->checkState()==Qt::Checked);
302
303 status = pjsua_call_make_call(accountId_, &uri2, &call_setting,
304 NULL, NULL, &currentCall_);
305 if (status != PJ_SUCCESS) {
306 showError("make call", status);
307 return;
308 }
309 }
310 }
311
312 void MainWin::hangup()
313 {
314 pj_assert(currentCall_ != -1);
315 //pjsua_call_hangup(currentCall_, PJSIP_SC_BUSY_HERE, NULL, NULL);
316 pjsua_call_hangup_all();
317 emit signalCallReleased();
318 }
319
320
321 void MainWin::initVideoWindow()
322 {
323 pjsua_call_info ci;
324 unsigned i;
325
326 if (currentCall_ == -1)
327 return;
328
329 delete video_;
330 video_ = NULL;
331
332 pjsua_call_get_info(currentCall_, &ci);
333 for (i = 0; i < ci.media_cnt; ++i) {
334 if ((ci.media[i].type == PJMEDIA_TYPE_VIDEO) &&
335 (ci.media[i].dir & PJMEDIA_DIR_DECODING))
336 {
337 pjsua_vid_win_info wi;
338 pjsua_vid_win_get_info(ci.media[i].stream.vid.win_in, &wi);
339
340 video_= new VidWin(&wi.hwnd);
341 video_->putIntoLayout(vbox_left);
342
343 break;
344 }
345 }
346 }
347
348 void MainWin::on_reg_state(pjsua_acc_id acc_id)
349 {
350 pjsua_acc_info info;
351
352 pjsua_acc_get_info(acc_id, &info);
353
354 char reg_status[80];
355 char status[120];
356
357 if (!info.has_registration) {
358 pj_ansi_snprintf(reg_status, sizeof(reg_status), "%.*s",
359 (int)info.status_text.slen,
360 info.status_text.ptr);
361
362 } else {
363 pj_ansi_snprintf(reg_status, sizeof(reg_status),
364 "%d/%.*s (expires=%d)",
365 info.status,
366 (int)info.status_text.slen,
367 info.status_text.ptr,
368 info.expires);
369
370 }
371
372 snprintf(status, sizeof(status),
373 "%.*s: %s\n",
374 (int)info.acc_uri.slen, info.acc_uri.ptr,
375 reg_status);
376 showStatus(status);
377 }
378
379 void MainWin::on_call_state(pjsua_call_id call_id, pjsip_event *e)
380 {
381 pjsua_call_info ci;
382
383 PJ_UNUSED_ARG(e);
384
385 pjsua_call_get_info(call_id, &ci);
386
387 if (currentCall_ == -1 && ci.state < PJSIP_INV_STATE_DISCONNECTED &&
388 ci.role == PJSIP_ROLE_UAC)
389 {
390 emit signalNewCall(call_id, false);
391 }
392
393 char status[80];
394 if (ci.state == PJSIP_INV_STATE_DISCONNECTED) {
395 snprintf(status, sizeof(status), "Call is %s (%s)",
396 ci.state_text.ptr,
397 ci.last_status_text.ptr);
398 showStatus(status);
399 emit signalCallReleased();
400 } else {
401 snprintf(status, sizeof(status), "Call is %s", pjsip_inv_state_name(ci.state));
402 showStatus(status);
403 }
404 }
405
406 void MainWin::on_incoming_call(pjsua_acc_id acc_id, pjsua_call_id call_id,
407 pjsip_rx_data *rdata)
408 {
409 PJ_UNUSED_ARG(acc_id);
410 PJ_UNUSED_ARG(rdata);
411
412 if (currentCall_ != -1) {
413 pjsua_call_answer(call_id, PJSIP_SC_BUSY_HERE, NULL, NULL);
414 return;
415 }
416
417 emit signalNewCall(call_id, true);
418
419 pjsua_call_info ci;
420 char status[80];
421
422 pjsua_call_get_info(call_id, &ci);
423 snprintf(status, sizeof(status), "Incoming call from %.*s",
424 (int)ci.remote_info.slen, ci.remote_info.ptr);
425 showStatus(status);
426 }
427
428 void MainWin::on_call_media_state(pjsua_call_id call_id)
429 {
430 pjsua_call_info ci;
431
432 pjsua_call_get_info(call_id, &ci);
433
434 for (unsigned i=0; i<ci.media_cnt; ++i) {
435 if (ci.media[i].type == PJMEDIA_TYPE_AUDIO) {
436 switch (ci.media[i].status) {
437 case PJSUA_CALL_MEDIA_ACTIVE:
438 pjsua_conf_connect(ci.media[i].stream.aud.conf_slot, 0);
439 pjsua_conf_connect(0, ci.media[i].stream.aud.conf_slot);
440 break;
441 default:
442 break;
443 }
444 } else if (ci.media[i].type == PJMEDIA_TYPE_VIDEO) {
445 emit signalInitVideoWindow();
446 }
447 }
448 }
449
450 //
451 // pjsua callbacks
452 //
453 static void on_reg_state(pjsua_acc_id acc_id)
454 {
455 MainWin::instance()->on_reg_state(acc_id);
456 }
457
458 static void on_call_state(pjsua_call_id call_id, pjsip_event *e)
459 {
460 MainWin::instance()->on_call_state(call_id, e);
461 }
462
463 static void on_incoming_call(pjsua_acc_id acc_id, pjsua_call_id call_id,
464 pjsip_rx_data *rdata)
465 {
466 MainWin::instance()->on_incoming_call(acc_id, call_id, rdata);
467 }
468
469 static void on_call_media_state(pjsua_call_id call_id)
470 {
471 MainWin::instance()->on_call_media_state(call_id);
472 }
473
474 //
475 // initStack()
476 //
477 bool MainWin::initStack()
478 {
479 pj_status_t status;
480
481 //showStatus("Creating stack..");
482 status = pjsua_create();
483 if (status != PJ_SUCCESS) {
484 showError("pjsua_create", status);
485 return false;
486 }
487
488 showStatus("Initializing stack..");
489
490 pjsua_config ua_cfg;
491 pjsua_config_default(&ua_cfg);
492 pjsua_callback ua_cb;
493 pj_bzero(&ua_cb, sizeof(ua_cb));
494 ua_cfg.cb.on_reg_state = &::on_reg_state;
495 ua_cfg.cb.on_call_state = &::on_call_state;
496 ua_cfg.cb.on_incoming_call = &::on_incoming_call;
497 ua_cfg.cb.on_call_media_state = &::on_call_media_state;
498 #if USE_STUN
499 ua_cfg.stun_srv_cnt = 1;
500 ua_cfg.stun_srv[0] = pj_str((char*)STUN_SRV);
501 #endif
502
503 pjsua_logging_config log_cfg;
504 pjsua_logging_config_default(&log_cfg);
505 log_cfg.log_filename = pj_str((char*)LOG_FILE);
506
507 pjsua_media_config med_cfg;
508 pjsua_media_config_default(&med_cfg);
509 med_cfg.enable_ice = USE_ICE;
510
511 status = pjsua_init(&ua_cfg, &log_cfg, &med_cfg);
512 if (status != PJ_SUCCESS) {
513 showError("pjsua_init", status);
514 goto on_error;
515 }
516
517 //
518 // Create UDP and TCP transports
519 //
520 pjsua_transport_config udp_cfg;
521 pjsua_transport_id udp_id;
522 pjsua_transport_config_default(&udp_cfg);
523 udp_cfg.port = SIP_PORT;
524
525 status = pjsua_transport_create(PJSIP_TRANSPORT_UDP,
526 &udp_cfg, &udp_id);
527 if (status != PJ_SUCCESS) {
528 showError("UDP transport creation", status);
529 goto on_error;
530 }
531
532 pjsua_transport_info udp_info;
533 status = pjsua_transport_get_info(udp_id, &udp_info);
534 if (status != PJ_SUCCESS) {
535 showError("UDP transport info", status);
536 goto on_error;
537 }
538
539 #if SIP_TCP
540 pjsua_transport_config tcp_cfg;
541 pjsua_transport_config_default(&tcp_cfg);
542 tcp_cfg.port = 0;
543
544 status = pjsua_transport_create(PJSIP_TRANSPORT_TCP,
545 &tcp_cfg, NULL);
546 if (status != PJ_SUCCESS) {
547 showError("TCP transport creation", status);
548 goto on_error;
549 }
550 #endif
551
552 //
553 // Create account
554 //
555 pjsua_acc_config acc_cfg;
556 pjsua_acc_config_default(&acc_cfg);
557 #if USE_REGISTRATION
558 acc_cfg.id = pj_str( (char*)"<sip:" SIP_USERNAME "@" SIP_DOMAIN ">");
559 acc_cfg.reg_uri = pj_str((char*) ("sip:" SIP_DOMAIN));
560 acc_cfg.cred_count = 1;
561 acc_cfg.cred_info[0].realm = pj_str((char*)"*");
562 acc_cfg.cred_info[0].scheme = pj_str((char*)"digest");
563 acc_cfg.cred_info[0].username = pj_str((char*)SIP_USERNAME);
564 acc_cfg.cred_info[0].data = pj_str((char*)SIP_PASSWORD);
565
566 # if SIP_TCP
567 acc_cfg.proxy[acc_cfg.proxy_cnt++] = pj_str((char*) "<sip:" SIP_DOMAIN ";transport=tcp>");
568 # endif
569
570 #else
571 char sip_id[80];
572 snprintf(sip_id, sizeof(sip_id),
573 "sip:%s@%.*s:%u", SIP_USERNAME,
574 (int)udp_info.local_name.host.slen,
575 udp_info.local_name.host.ptr,
576 udp_info.local_name.port);
577 acc_cfg.id = pj_str(sip_id);
578 #endif
579
580 acc_cfg.vid_cap_dev = DEFAULT_CAP_DEV;
581 acc_cfg.vid_rend_dev = DEFAULT_REND_DEV;
582 acc_cfg.vid_in_auto_show = PJ_TRUE;
583 acc_cfg.vid_out_auto_transmit = PJ_TRUE;
584
585 status = pjsua_acc_add(&acc_cfg, PJ_TRUE, &accountId_);
586 if (status != PJ_SUCCESS) {
587 showError("Account creation", status);
588 goto on_error;
589 }
590
591 localUri_->setText(acc_cfg.id.ptr);
592
593 //
594 // Start pjsua!
595 //
596 showStatus("Starting stack..");
597 status = pjsua_start();
598 if (status != PJ_SUCCESS) {
599 showError("pjsua_start", status);
600 goto on_error;
601 }
602
603 showStatus("Ready");
604
605 return true;
606
607 on_error:
608 pjsua_destroy();
609 return false;
610 }
611
612 /*
613 * A simple registrar, invoked by default_mod_on_rx_request()
614 */
615 static void simple_registrar(pjsip_rx_data *rdata)
616 {
617 pjsip_tx_data *tdata;
618 const pjsip_expires_hdr *exp;
619 const pjsip_hdr *h;
620 unsigned cnt = 0;
621 pjsip_generic_string_hdr *srv;
622 pj_status_t status;
623
624 status = pjsip_endpt_create_response(pjsua_get_pjsip_endpt(),
625 rdata, 200, NULL, &tdata);
626 if (status != PJ_SUCCESS)
627 return;
628
629 exp = (pjsip_expires_hdr*)
630 pjsip_msg_find_hdr(rdata->msg_info.msg, PJSIP_H_EXPIRES, NULL);
631
632 h = rdata->msg_info.msg->hdr.next;
633 while (h != &rdata->msg_info.msg->hdr) {
634 if (h->type == PJSIP_H_CONTACT) {
635 const pjsip_contact_hdr *c = (const pjsip_contact_hdr*)h;
636 int e = c->expires;
637
638 if (e < 0) {
639 if (exp)
640 e = exp->ivalue;
641 else
642 e = 3600;
643 }
644
645 if (e > 0) {
646 pjsip_contact_hdr *nc = (pjsip_contact_hdr*)
647 pjsip_hdr_clone(tdata->pool, h);
648 nc->expires = e;
649 pjsip_msg_add_hdr(tdata->msg, (pjsip_hdr*)nc);
650 ++cnt;
651 }
652 }
653 h = h->next;
654 }
655
656 srv = pjsip_generic_string_hdr_create(tdata->pool, NULL, NULL);
657 srv->name = pj_str((char*)"Server");
658 srv->hvalue = pj_str((char*)"pjsua simple registrar");
659 pjsip_msg_add_hdr(tdata->msg, (pjsip_hdr*)srv);
660
661 status = pjsip_endpt_send_response2(pjsua_get_pjsip_endpt(),
662 rdata, tdata, NULL, NULL);
663 if (status != PJ_SUCCESS) pjsip_tx_data_dec_ref(tdata);
664 }
665
666 /* Notification on incoming request */
667 static pj_bool_t default_mod_on_rx_request(pjsip_rx_data *rdata)
668 {
669 /* Simple registrar */
670 if (pjsip_method_cmp(&rdata->msg_info.msg->line.req.method,
671 &pjsip_register_method) == 0)
672 {
673 simple_registrar(rdata);
674 return PJ_TRUE;
675 }
676
677 return PJ_FALSE;
678 }
679
680 /* The module instance. */
681 static pjsip_module mod_default_handler =
682 {
683 NULL, NULL, /* prev, next. */
684 { (char*)"mod-default-handler", 19 }, /* Name. */
685 -1, /* Id */
686 PJSIP_MOD_PRIORITY_APPLICATION+99, /* Priority */
687 NULL, /* load() */
688 NULL, /* start() */
689 NULL, /* stop() */
690 NULL, /* unload() */
691 &default_mod_on_rx_request, /* on_rx_request() */
692 NULL, /* on_rx_response() */
693 NULL, /* on_tx_request. */
694 NULL, /* on_tx_response() */
695 NULL, /* on_tsx_state() */
696
697 };
698
699 int main(int argc, char *argv[])
700 {
701 /* At least on Linux, we have to initialize SDL video subsystem prior to
702 * creating/initializing QApplication, otherwise we'll segfault miserably
703 * in SDL_CreateWindow(). Here's a stack trace if you're interested:
704
705 Thread [7] (Suspended: Signal 'SIGSEGV' received. Description: Segmentation fault.)
706 13 XCreateIC()
707 12 SetupWindowData()
708 11 X11_CreateWindow()
709 10 SDL_CreateWindow()
710 ..
711 */
712 if ( SDL_InitSubSystem(SDL_INIT_VIDEO) < 0 ) {
713 printf("Unable to init SDL: %s\n", SDL_GetError());
714 return 1;
715 }
716
717 QApplication app(argc, argv);
718
719 MainWin win;
720 win.show();
721
722 if (!win.initStack()) {
723 win.quit();
724 return 1;
725 }
726
727 /* We want to be registrar too! */
728 if (pjsua_get_pjsip_endpt()) {
729 pjsip_endpt_register_module(pjsua_get_pjsip_endpt(),
730 &mod_default_handler);
731 }
732
733 return app.exec();
734 }
735