summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorBenny Prijono <bennylp@teluu.com>2011-12-27 12:50:17 +0000
committerBenny Prijono <bennylp@teluu.com>2011-12-27 12:50:17 +0000
commitda99d7b15e81dd5e3cca93c1dfa702a3bb41f379 (patch)
tree231d17029b2d6274221ecf0e31be18a342cc0f73
parent8522626d02647b2996d7dc62d0486422286a62f6 (diff)
Re #1393: added checkbox to enable/disable video in vidgui sample app
git-svn-id: http://svn.pjsip.org/repos/pjproject/trunk@3926 74dad513-b988-da41-8d7b-12977e46ad98
-rw-r--r--pjsip-apps/src/vidgui/vidgui.cpp38
-rw-r--r--pjsip-apps/src/vidgui/vidgui.h3
2 files changed, 38 insertions, 3 deletions
diff --git a/pjsip-apps/src/vidgui/vidgui.cpp b/pjsip-apps/src/vidgui/vidgui.cpp
index 1b7334b0..823ec8bf 100644
--- a/pjsip-apps/src/vidgui/vidgui.cpp
+++ b/pjsip-apps/src/vidgui/vidgui.cpp
@@ -42,7 +42,7 @@
#define SIP_DOMAIN "pjsip.org"
#define SIP_USERNAME "vidgui"
#define SIP_PASSWORD "secret"
-#define SIP_PORT 5084
+#define SIP_PORT 5080
#define SIP_TCP 1
//
@@ -108,11 +108,19 @@ void MainWin::initLayout()
/* Right pane */
vbox_right->addWidget((localUri_ = new QLabel));
+ vbox_right->addWidget((vidEnabled_ = new QCheckBox(tr("Enable &video"))));
vbox_right->addWidget((previewButton_=new QPushButton(tr("Start &Preview"))));
vbox_right->addWidget((callButton_=new QPushButton(tr("Call"))));
vbox_right->addWidget((hangupButton_=new QPushButton(tr("Hangup"))));
vbox_right->addWidget((quitButton_=new QPushButton(tr("Quit"))));
+#if PJMEDIA_HAS_VIDEO
+ vidEnabled_->setCheckState(Qt::Checked);
+#else
+ vidEnabled_->setCheckState(Qt::Unchecked);
+ vidEnabled_->setEnabled(false);
+#endif
+
/* Outest layout */
QVBoxLayout *vbox_outest = new QVBoxLayout;
vbox_outest->addLayout(hbox_main);
@@ -125,6 +133,7 @@ void MainWin::initLayout()
connect(hangupButton_, SIGNAL(clicked()), this, SLOT(hangup()));
connect(quitButton_, SIGNAL(clicked()), this, SLOT(quit()));
//connect(this, SIGNAL(close()), this, SLOT(quit()));
+ connect(vidEnabled_, SIGNAL(stateChanged(int)), this, SLOT(onVidEnabledChanged(int)));
// UI updates must be done in the UI thread!
connect(this, SIGNAL(signalNewCall(int, bool)),
@@ -172,6 +181,19 @@ void MainWin::showError(const char *title, pj_status_t status)
showStatus(errline);
}
+void MainWin::onVidEnabledChanged(int state)
+{
+ pjsua_call_setting call_setting;
+
+ if (currentCall_ == -1)
+ return;
+
+ pjsua_call_setting_default(&call_setting);
+ call_setting.vid_cnt = (state == Qt::Checked);
+
+ pjsua_call_reinvite2(currentCall_, &call_setting, NULL);
+}
+
void MainWin::onNewCall(int cid, bool incoming)
{
pjsua_call_info ci;
@@ -256,20 +278,30 @@ void MainWin::preview()
void MainWin::call()
{
if (callButton_->text() == "Answer") {
+ pjsua_call_setting call_setting;
+
pj_assert(currentCall_ != -1);
- pjsua_call_answer(currentCall_, 200, NULL, NULL);
+
+ pjsua_call_setting_default(&call_setting);
+ call_setting.vid_cnt = (vidEnabled_->checkState()==Qt::Checked);
+
+ pjsua_call_answer2(currentCall_, &call_setting, 200, NULL, NULL);
callButton_->setEnabled(false);
} else {
pj_status_t status;
QString dst = url_->text();
char uri[256];
+ pjsua_call_setting call_setting;
pj_ansi_strncpy(uri, dst.toAscii().data(), sizeof(uri));
pj_str_t uri2 = pj_str((char*)uri);
pj_assert(currentCall_ == -1);
- status = pjsua_call_make_call(accountId_, &uri2, 0,
+ pjsua_call_setting_default(&call_setting);
+ call_setting.vid_cnt = (vidEnabled_->checkState()==Qt::Checked);
+
+ status = pjsua_call_make_call(accountId_, &uri2, &call_setting,
NULL, NULL, &currentCall_);
if (status != PJ_SUCCESS) {
showError("make call", status);
diff --git a/pjsip-apps/src/vidgui/vidgui.h b/pjsip-apps/src/vidgui/vidgui.h
index a7c2a507..1cc27462 100644
--- a/pjsip-apps/src/vidgui/vidgui.h
+++ b/pjsip-apps/src/vidgui/vidgui.h
@@ -20,6 +20,7 @@
#define VIDGUI_H_
#include <QApplication>
+#include <QCheckBox>
#include <QFont>
#include <QLabel>
#include <QLineEdit>
@@ -65,6 +66,7 @@ public slots:
void call();
void hangup();
void quit();
+ void onVidEnabledChanged(int state);
void onNewCall(int cid, bool incoming);
void onCallReleased();
@@ -82,6 +84,7 @@ private:
*hangupButton_,
*quitButton_,
*previewButton_;
+ QCheckBox *vidEnabled_;
QLineEdit *url_;
VidWin *video_;
VidWin *video_prev_;