Ignore:
Timestamp:
Aug 26, 2011 4:30:18 AM (13 years ago)
Author:
nanang
Message:

Re #1327:

  • Vidgui UI updates on Qt must be done in the UI thread, implemented this with Qt signal-slot mechanism.
  • VidWin::show() better be called internally by VidWin? class instead of MainWin?.
  • Fix QString to const char* issue, keeping the pointer returned by "QString::to*()::data()" won't work, the pointer actually points to a temporary data (lifetime issue).
  • Minor: cleaning up unused lines in vidgui.
File:
1 edited

Legend:

Unmodified
Added
Removed
  • pjproject/trunk/pjsip-apps/src/vidgui/vidgui.cpp

    r3724 r3726  
    5151 
    5252    initLayout(); 
    53     onCallReleased(); 
     53    emit signalCallReleased(); 
    5454} 
    5555 
     
    102102    connect(quitButton_, SIGNAL(clicked()), this, SLOT(quit())); 
    103103    //connect(this, SIGNAL(close()), this, SLOT(quit())); 
     104 
     105    // UI updates must be done in the UI thread! 
     106    connect(this, SIGNAL(signalNewCall(int, bool)), 
     107            this, SLOT(onNewCall(int, bool))); 
     108    connect(this, SIGNAL(signalCallReleased()), 
     109            this, SLOT(onCallReleased())); 
     110    connect(this, SIGNAL(signalInitVideoWindow()), 
     111            this, SLOT(initVideoWindow())); 
     112    connect(this, SIGNAL(signalShowStatus(const QString&)), 
     113            this, SLOT(doShowStatus(const QString&))); 
    104114} 
    105115 
    106116void MainWin::quit() 
    107117{ 
    108     //if (preview_on) 
    109         //preview(); 
    110  
    111118    delete video_prev_; 
    112119    video_prev_ = NULL; 
     
    120127void MainWin::showStatus(const char *msg) 
    121128{ 
     129    PJ_LOG(3,(THIS_FILE, "%s", msg)); 
     130 
     131    QString msg_ = QString::fromUtf8(msg); 
     132    emit signalShowStatus(msg_); 
     133} 
     134 
     135void MainWin::doShowStatus(const QString& msg) 
     136{ 
    122137    //statusBar_->showMessage(msg); 
    123138    statusBar_->setText(msg); 
    124     PJ_LOG(3,(THIS_FILE, "%s", msg)); 
    125139} 
    126140 
     
    135149} 
    136150 
    137 void MainWin::onNewCall(pjsua_call_id cid, bool incoming) 
     151void MainWin::onNewCall(int cid, bool incoming) 
    138152{ 
    139153    pjsua_call_info ci; 
     
    206220        //X11 Display 
    207221        //status = pjsua_vid_win_set_show(wid, PJ_TRUE); 
    208         video_prev_->show(); 
     222        //This is handled by VidWin now 
     223        //video_prev_->show(); 
    209224        showStatus("Preview started"); 
    210225 
     
    224239        pj_status_t status; 
    225240        QString dst = url_->text(); 
    226         const char *uri = dst.toAscii().data(); 
     241        char uri[256]; 
     242 
     243        pj_ansi_strncpy(uri, dst.toAscii().data(), sizeof(uri)); 
    227244        pj_str_t uri2 = pj_str((char*)uri); 
    228245 
     
    243260    //pjsua_call_hangup(currentCall_, PJSIP_SC_BUSY_HERE, NULL, NULL); 
    244261    pjsua_call_hangup_all(); 
    245     onCallReleased(); 
    246 } 
    247  
    248  
    249 void MainWin::init_video_window() 
     262    emit signalCallReleased(); 
     263} 
     264 
     265 
     266void MainWin::initVideoWindow() 
    250267{ 
    251268    pjsua_call_info ci; 
     
    311328 
    312329    if (currentCall_ == -1 && ci.state < PJSIP_INV_STATE_DISCONNECTED) { 
    313         onNewCall(call_id, false); 
     330        emit signalNewCall(call_id, false); 
    314331    } 
    315332 
     
    320337                 ci.last_status_text.ptr); 
    321338        showStatus(status); 
    322         onCallReleased(); 
     339        emit signalCallReleased(); 
    323340    } else { 
    324341        snprintf(status, sizeof(status), "Call is %s", pjsip_inv_state_name(ci.state)); 
     
    338355    } 
    339356 
    340     onNewCall(call_id, true); 
     357    emit signalNewCall(call_id, true); 
    341358 
    342359    pjsua_call_info ci; 
     
    366383            } 
    367384        } else if (ci.media[i].type == PJMEDIA_TYPE_VIDEO) { 
    368             init_video_window(); 
     385            emit signalInitVideoWindow(); 
    369386        } 
    370387    } 
Note: See TracChangeset for help on using the changeset viewer.