Changeset 3926


Ignore:
Timestamp:
Dec 27, 2011 12:50:17 PM (12 years ago)
Author:
bennylp
Message:

Re #1393: added checkbox to enable/disable video in vidgui sample app

Location:
pjproject/trunk/pjsip-apps/src/vidgui
Files:
2 edited

Legend:

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

    r3923 r3926  
    4343#define SIP_USERNAME            "vidgui" 
    4444#define SIP_PASSWORD            "secret" 
    45 #define SIP_PORT                5084 
     45#define SIP_PORT                5080 
    4646#define SIP_TCP                 1 
    4747 
     
    109109    /* Right pane */ 
    110110    vbox_right->addWidget((localUri_ = new QLabel)); 
     111    vbox_right->addWidget((vidEnabled_ = new QCheckBox(tr("Enable &video")))); 
    111112    vbox_right->addWidget((previewButton_=new QPushButton(tr("Start &Preview")))); 
    112113    vbox_right->addWidget((callButton_=new QPushButton(tr("Call")))); 
    113114    vbox_right->addWidget((hangupButton_=new QPushButton(tr("Hangup")))); 
    114115    vbox_right->addWidget((quitButton_=new QPushButton(tr("Quit")))); 
     116 
     117#if PJMEDIA_HAS_VIDEO 
     118    vidEnabled_->setCheckState(Qt::Checked); 
     119#else 
     120    vidEnabled_->setCheckState(Qt::Unchecked); 
     121    vidEnabled_->setEnabled(false); 
     122#endif 
    115123 
    116124    /* Outest layout */ 
     
    126134    connect(quitButton_, SIGNAL(clicked()), this, SLOT(quit())); 
    127135    //connect(this, SIGNAL(close()), this, SLOT(quit())); 
     136    connect(vidEnabled_, SIGNAL(stateChanged(int)), this, SLOT(onVidEnabledChanged(int))); 
    128137 
    129138    // UI updates must be done in the UI thread! 
     
    173182} 
    174183 
     184void MainWin::onVidEnabledChanged(int state) 
     185{ 
     186    pjsua_call_setting call_setting; 
     187 
     188    if (currentCall_ == -1) 
     189        return; 
     190 
     191    pjsua_call_setting_default(&call_setting); 
     192    call_setting.vid_cnt = (state == Qt::Checked); 
     193 
     194    pjsua_call_reinvite2(currentCall_, &call_setting, NULL); 
     195} 
     196 
    175197void MainWin::onNewCall(int cid, bool incoming) 
    176198{ 
     
    257279{ 
    258280    if (callButton_->text() == "Answer") { 
     281        pjsua_call_setting call_setting; 
     282 
    259283        pj_assert(currentCall_ != -1); 
    260         pjsua_call_answer(currentCall_, 200, NULL, NULL); 
     284 
     285        pjsua_call_setting_default(&call_setting); 
     286        call_setting.vid_cnt = (vidEnabled_->checkState()==Qt::Checked); 
     287 
     288        pjsua_call_answer2(currentCall_, &call_setting, 200, NULL, NULL); 
    261289        callButton_->setEnabled(false); 
    262290    } else { 
     
    264292        QString dst = url_->text(); 
    265293        char uri[256]; 
     294        pjsua_call_setting call_setting; 
    266295 
    267296        pj_ansi_strncpy(uri, dst.toAscii().data(), sizeof(uri)); 
     
    270299        pj_assert(currentCall_ == -1); 
    271300 
    272         status = pjsua_call_make_call(accountId_, &uri2, 0, 
     301        pjsua_call_setting_default(&call_setting); 
     302        call_setting.vid_cnt = (vidEnabled_->checkState()==Qt::Checked); 
     303 
     304        status = pjsua_call_make_call(accountId_, &uri2, &call_setting, 
    273305                                      NULL, NULL, &currentCall_); 
    274306        if (status != PJ_SUCCESS) { 
  • pjproject/trunk/pjsip-apps/src/vidgui/vidgui.h

    r3726 r3926  
    2121 
    2222#include <QApplication> 
     23#include <QCheckBox> 
    2324#include <QFont> 
    2425#include <QLabel> 
     
    6667    void hangup(); 
    6768    void quit(); 
     69    void onVidEnabledChanged(int state); 
    6870 
    6971    void onNewCall(int cid, bool incoming); 
     
    8385                *quitButton_, 
    8486                *previewButton_; 
     87    QCheckBox   *vidEnabled_; 
    8588    QLineEdit *url_; 
    8689    VidWin *video_; 
Note: See TracChangeset for help on using the changeset viewer.