Blame view

LiveChat/FeiTalk/gui/italkingwidget.cpp 27.9 KB
9f17d59e   陈明泉   no message
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
  #include "italkingwidget.h"
  #include "../JusCall/JusCallPch.h"
  #include "ui_talking.h"
  #include "ivideoitemteach.h"
  #include "../mainapp.h"
  #include <QGraphicsView>
  #include <QGraphicsProxyWidget>
  #include <QMessageBox>
  #include <QListWidget>
  #include <QtWebKitWidgets>
  #include "qwebpage.h"
  #include "iwebrequest.h"
  #include "JusDoodle/DoodleManager.h"
  #include "downloadfile.h"
  #include <QVBoxLayout>
  
  #include "GlobalSetting.h"
  #include "gotyecpp/gotyemsg.h"
  #include "gotye/GotyeMessage.h"
  #include "gotye/GotyeAPI.h"
  USING_NS_GOTYEAPI;
  
  
  const QSize SIZEHVIDEO = QSize(640 + VIDEOSHADOW_WIDTH, 480 + VIDEOSHADOW_HEIGHT);
  const QSize SIZEVVIDEO = QSize(480 + VIDEOSHADOW_WIDTH, 640 + VIDEOSHADOW_HEIGHT);
  
  
  ITalkingWidget::ITalkingWidget(QWidget *parent) :
      QWidget(parent),ui(new Ui::TalkingWidget())
  {
      ui->setupUi(this);
  
  //    videoItemTeacher = new IVideoItemTeach(ui->widgetCenter);//教师视频窗口
      videoItemTeacher = new QWidget(ui->label_left);//教师视频窗口
d6ba1152   陈明泉   1.3.1PC老师端正式上线发布版;
35
      videoItemTeacher->setStyleSheet("border-image: url(:/Images/VideoCall/img_video_close_01.png);");
6e10e93e   陈明泉   no message
36
37
      videoItemTeacher->resize(290, 320);
      videoItemTeacher->move(5, 0);
9f17d59e   陈明泉   no message
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
      videoItemTeacher->show();
  
      volSlider = new ISlider(ui->widgetCenter);//这个初始值,是让这个控件竖向布局
      volSlider->setOrientation(Qt::Vertical);
  //    volSlider->setGeometry(603,510,20,106);
      volSlider->setRange(0,20);
      volSlider->setPageStep(1);
      volSlider->hide();
  
      QFile qss(":qss/QSlider.qss");
      if(qss.open(QFile::ReadOnly))
      {
          QString text= qss.readAll();
          volSlider->setStyleSheet(text);
          qss.close();
      }
      setMouseTracking(true);
  
      setFocus(Qt::MouseFocusReason);
  
d6ba1152   陈明泉   1.3.1PC老师端正式上线发布版;
58
59
  //    connect((MainApp *)qApp, SIGNAL(videoEvent(int, const Notification&)),
  //        SLOT(onVideoEvent(int, const Notification&)));
9f17d59e   陈明泉   no message
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
  
  //    initShowUI();
      MyTimer.setSingleShot(true);
      trayHideTimer.setSingleShot(true);
      m_hanging_up_timer = new QTimer();
      m_hanging_up_timer->setSingleShot(true);
  
      //最小化
      connect(ui->pushButtonMin, SIGNAL(clicked()), this, SIGNAL(hideMain()));
      //悬浮框各控件控制
      connect(ui->pushButtonMic, SIGNAL(mouseIn()), this, SLOT(MicLabelShow()));
      connect(&MyTimer, SIGNAL(timeout()), volSlider, SLOT(hide()));
      connect(m_hanging_up_timer, SIGNAL(timeout()), this, SLOT(on_pushButtonCloseVideo_clicked()));
      connect(ui->pushButtonCameraChange, SIGNAL(mouseIn()), this, SLOT(CameraLabelShow()));
      connect(volSlider, SIGNAL(mouseOut()), this, SLOT(volSliderHide()));
      connect(volSlider, SIGNAL(mouseIn()), &MyTimer, SLOT(stop()));
      connect(ui->pushButtonVol, SIGNAL(mouseIn()), this, SLOT(volSliderShow()));
      connect(ui->pushButtonVol, SIGNAL(mouseOut()), this, SLOT(volSliderHide()));
      connect(volSlider, SIGNAL(valueChanged(int)), this, SLOT(SetSpkVol(int)));
  
  //    connect(ui->labelVideoShow, SIGNAL(mouseIn()), this, SLOT(widgettrayShow()));
  //    connect(ui->labelVideoShow, SIGNAL(mouseOut()), this, SLOT(widgettrayHide()));
  //    connect(&trayHideTimer,SIGNAL(timeout()),ui->widgettray, SLOT(hide()));
      connect(ui->widgettray, SIGNAL(mouseIn()), this, SLOT(widgettrayShow()));
      connect(ui->widgettray, SIGNAL(mouseOut()), this, SLOT(widgettrayHide()));
  
      connect(IWebRequest::Instance(), SIGNAL(response(int,int,QString,QString)), this, SLOT(doResponse(int,int,QString,QString)));
  
      ui->splitter->setStretchFactor(0,70);
      ui->splitter->setStretchFactor(1,30);
      ui->textEdit->installEventFilter(this);
      ui->pushButtonMessage->hide();
  
      QFile source(":Images/style/style.html");
      source.open(QIODevice::ReadOnly);
      ui->webView->setHtml(QString::fromUtf8(source.readAll().constData()));
      source.close();
  
      m_timer = new QTimer();
      connect( m_timer,SIGNAL(timeout()),this,SLOT(displayTime()));
  
      m_courseTimer = new QTimer();
      m_courseTimer->setSingleShot(true);
      connect(m_courseTimer,SIGNAL(timeout()),this,SLOT(upCourseUi()));
  
      hint_label = new QLabel(this);
      hint_label->setAlignment(Qt::AlignCenter);
      hint_label->setStyleSheet("border-image: url(:/Images/VideoCall/transparent50.png);background-color:rgba(120,120,120,255);color:rgb(255,0,0);");
      hint_label->hide();
  
      ui_msgMemo = new msgMemo();
  
      receiverUid = 0;
      pptNmu = 0;
6e10e93e   陈明泉   no message
114
115
116
117
118
119
120
      callTimeSec = 0;
      ui->pushButton_expression->hide();
  
      //接收消息
      apiist-> addListener(*this);
  
  }
9f17d59e   陈明泉   no message
121
  
6e10e93e   陈明泉   no message
122
123
124
125
126
127
128
  void ITalkingWidget::onReceiveMessage(const GotyeMessage& message, bool* downloadMediaIfNeed)
  {
      if(receiverUid == atoi(message.sender.name.data()))
      {
          if(pptNmu > 1 && ui_msgMemo->isHidden())
              pSess->_doodleWindow->ui->btnMessage->setStyleSheet("QPushButton{border-image: url(:/Images/VideoCall/icon__v_message_hover.png);}");
      }
9f17d59e   陈明泉   no message
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
  }
  
  void ITalkingWidget::MicLabelShow()
  {
      if (MyTimer.isActive())
      {
          MyTimer.stop();
          volSlider->hide();
      }
  
      if(isClictMic)
          ui->pushButtonMic->setToolTip("Click to Mute");
      else
          ui->pushButtonMic->setToolTip("Click to Unmute");
      qDebug("CMQ MicLabelShow...\n");
  }
  
  void ITalkingWidget::CameraLabelShow()
  {
      if (MyTimer.isActive())
      {
          MyTimer.stop();
          volSlider->hide();
      }
      if(isClictCamera)
          ui->pushButtonCameraChange->setToolTip("Unable Webcam");
      else
          ui->pushButtonCameraChange->setToolTip("Enable  Webcam");
      qDebug("CMQ CameraLabelShow...\n");
  }
  
  void ITalkingWidget::volSliderShow()
  {
      int num_x = ui->labelVideoShowBK->x()+ui->pushButtonVol->x()+ui->pushButtonVol->width()/4;
      if (MyTimer.isActive())
          MyTimer.stop();
      if(isClictVol)
          ui->pushButtonVol->setToolTip("Click to Mute");
      else
          ui->pushButtonVol->setToolTip("Click to Unmute");
      volSlider->setValue(Mtc_CallGetSpkVol(RCallManager::Instance()->m_pRSession->sessId()));
      volSlider->setGeometry(num_x,510,20,106);
6e10e93e   陈明泉   no message
171
      volSlider->raise();
9f17d59e   陈明泉   no message
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
      volSlider->show();
      qDebug("CMQ volSliderShow..%d..\n",Mtc_CallGetSpkVol(RCallManager::Instance()->m_pRSession->sessId()));
  }
  
  void ITalkingWidget::displayTime()
  {
      QString strtime = QString("");
      callTimeSec++;
      QDateTime dt = QDateTime::fromTime_t(callTimeSec);
      if(callTimeSec >= 3600)
          strtime = dt.toString("hh:mm:ss");//日期格式自定义
      else
          strtime = dt.toString("mm:ss");//日期格式自定义
      ui->label_time->setText(strtime);
  }
  
  void ITalkingWidget::SetSpkVol(int value)
  {
      Mtc_CallSetSpkVol(RCallManager::Instance()->m_pRSession->sessId(),value);
      qDebug("CMQ SetSpkVol..%d..\n",volSlider->value());
  }
  
  void ITalkingWidget::widgettrayShow()
  {
      //volSlider->hide();
      if (trayHideTimer.isActive())
          trayHideTimer.stop();
      ui->widgettray->show();
  }
  
  void ITalkingWidget::widgettrayHide()
  {
      //volSlider->hide();
      if (trayHideTimer.isActive())
          trayHideTimer.stop();
      trayHideTimer.start(3*1000);
  }
  
  void ITalkingWidget::volSliderHide()
  {
      //volSlider->hide();
      if (MyTimer.isActive())
          MyTimer.stop();
      MyTimer.start(2*1000);
  }
  
  int ITalkingWidget::getSendUid()
  {
  
      QString s_uid = QString::fromLatin1(Mtc_CallGetPeerName(RCallManager::Instance()->m_pRSession->sessId()));
      receiverUid = s_uid.remove(0,2).toInt();
      if(receiverUid > 0)
      {
          GotyeUser userInfo;
          QString user(QString("%1").arg(receiverUid));
          GotyeChatTarget getSender(user.toLatin1().data());
          userInfo = apiist->getUserDetail(getSender);
          if(strlen(userInfo.icon.path.data()) > 1)
          {
              apiist->downloadMedia(userInfo.icon);
              otherhead = QString::fromStdString(userInfo.icon.path);
              otherhead.replace("\\","/");
          }
          else
              userInfo = apiist->getUserDetail(getSender,true);
          apiist->activeSession(getSender); // < 激活与target的会话
          qDebug("CMQ getSendUid otherhead = %s.....\n",userInfo.icon.path.data());
      }
      return receiverUid;
  }
  
  void ITalkingWidget::initShowUI()
  {
      videoFlag = true;
      isClictMic = true;
      isClictVol = true;
      isClictCamera = true;
      ui->pushButtonMic->setStyleSheet("QPushButton{background:transparent;border-image: url(:Images/VideoCall/icon_mic_nor.png);}"
                                       "QPushButton:hover{border-image: url(:Images/VideoCall/icon_mic_hov.png);}"
                                       "QPushButton:pressed{border-image: url(:Images/VideoCall/icon_mic_pre.png);}");
      ui->pushButtonCameraChange->setStyleSheet("QPushButton{background:transparent;border-image: url(:Images/VideoCall/img_video_off_nor.png);}"
                                       "QPushButton:hover{border-image: url(:Images/VideoCall/img_video_off_hov.png);}"
                                       "QPushButton:pressed{border-image: url(:Images/VideoCall/img_video_off_pre.png);}");
      ui->pushButtonVol->setStyleSheet("QPushButton{background:transparent;border-image: url(:Images/VideoCall/icon_vol_nor.png);}"
                                       "QPushButton:hover{border-image: url(:Images/VideoCall/icon_vol_hov.png);}"
                                       "QPushButton:pressed{border-image: url(:Images/VideoCall/icon_vol_pre.png);}");
      ui->textEdit->setFocus();
  
  
      if(_GlobalSetting.userHeadImg.file_name.length() > 2)
          Myhead = QCoreApplication::applicationDirPath()+"/img/"+_GlobalSetting.userHeadImg.file_name +_GlobalSetting.userHeadImg.ext;
  
      hint_label->hide();;
      callTimeSec = 0;
      m_timer->start(1000);
  
      GotyeMsg::Instance()->setShowUserName(ui->label_name);
d6ba1152   陈明泉   1.3.1PC老师端正式上线发布版;
269
270
  
      qDebug()<<"initShowUI";
9f17d59e   陈明泉   no message
271
272
273
274
275
      GotyeMsg::Instance()->setIsUpdata(true);
      if(receiverUid < 1)
          getSendUid();
      showCourseUi();
      GotyeMsg::Instance()->uidGetChatLog(receiverUid);
d6ba1152   陈明泉   1.3.1PC老师端正式上线发布版;
276
      qDebug("CMQ initShowUI OK...");
9f17d59e   陈明泉   no message
277
278
279
280
281
282
283
284
285
286
287
288
289
  }
  
  //刷新课程PPT
  void ITalkingWidget::upCourseUi()
  {
      QStringList imagePaths = QStringList();
  //    pptNmu = pptarray.size();
      for(int i = 0;i < pptarray.size();i++)
      {
          QString couresFile = QCoreApplication::applicationDirPath()+"/couresImg/"+pptarray.at(i).toObject().\
                  find("pic").value().toObject().find("file_name").value().toString();
          imagePaths << couresFile;
      }
d6ba1152   陈明泉   1.3.1PC老师端正式上线发布版;
290
291
      if(pSess)
          pSess->setBackgroundImages(imagePaths);
9f17d59e   陈明泉   no message
292
  }
d6ba1152   陈明泉   1.3.1PC老师端正式上线发布版;
293
294
295
296
  /**
    判断是否有课程 显示不同排版界面
   * @brief ITalkingWidget::showCourseUi
   */
9f17d59e   陈明泉   no message
297
298
299
300
301
302
303
304
305
  void ITalkingWidget::showCourseUi()
  {
      if(pptNmu > 1)
      {
          GotyeMsg::Instance()->setShowMsgWebviwe(ui_msgMemo->getMsgView());
          QVBoxLayout *vLayout = (QVBoxLayout *)ui->label_left->layout();
          if(vLayout)
              delete vLayout;
          vLayout = new QVBoxLayout();
6e10e93e   陈明泉   no message
306
307
          vLayout->addWidget(videoItemTeacher,18);
          vLayout->addWidget(ui->labelVideoShowBK,22);
9f17d59e   陈明泉   no message
308
          vLayout->setSpacing(0);
6e10e93e   陈明泉   no message
309
          vLayout->setContentsMargins(0,0,0,0);
9f17d59e   陈明泉   no message
310
311
312
313
314
315
316
317
318
          ui->label_left->setLayout(vLayout);
          ui->widget_meg->hide();
          pSess = JusDoodle::DoodleManager::Instance()->findSess(RCallManager::Instance()->m_pRSession->sessId());
          if(!pSess)
              return;
          if (!pSess->_doodleWindow)
              pSess->initWindow(pptarray.size());
          pSess->_doodleWindow->show();
          ui->horizontalLayoutCenter->addWidget(pSess->_doodleWindow);
d6ba1152   陈明泉   1.3.1PC老师端正式上线发布版;
319
320
  //        ui->labelVideoShow->setStyleSheet("border-image: url(:/Images/VideoCall/img_video_close_02.png);");
          ui->labelVideoShow->setPixmap(QPixmap(QString(":/Images/VideoCall/img_video_close_02.png")).scaled(300,300));
9f17d59e   陈明泉   no message
321
322
          m_courseTimer->start(8*1000);
          upCourseUi();
6e10e93e   陈明泉   no message
323
324
          connect(pSess->_doodleWindow->ui->btnMessage,SIGNAL(clicked()),this,SLOT(ui_msgmemo_ishow()));
          connect(pSess->_doodleWindow->ui->btnNote,SIGNAL(clicked()),this,SLOT(ui_msgmemo_ishow()));
9f17d59e   陈明泉   no message
325
326
327
328
329
330
      }
      else
      {
          GotyeMsg::Instance()->setShowMsgWebviwe(ui->webView);
  
          QVBoxLayout *vLayout = (QVBoxLayout *)ui->label_left->layout();
d6ba1152   陈明泉   1.3.1PC老师端正式上线发布版;
331
          ui->labelVideoShow->setStyleSheet("border-image: url(:/Images/VideoCall/img_video_close_03.png);");
9f17d59e   陈明泉   no message
332
333
334
          if(vLayout)
              delete vLayout;
          videoItemTeacher->resize(290, 320);
d6ba1152   陈明泉   1.3.1PC老师端正式上线发布版;
335
          videoItemTeacher->move(5, 5);
9f17d59e   陈明泉   no message
336
337
338
339
340
  //        ui->horizontalLayoutCenter->setSpacing(5);
          ui->horizontalLayoutCenter->addWidget(ui->label_left);
          ui->horizontalLayoutCenter->addWidget(ui->labelVideoShowBK);
          ui->horizontalLayoutCenter->addWidget(ui->widget_meg);
          ui->widget_meg->show();
6e10e93e   陈明泉   no message
341
342
343
344
345
346
347
          ui->widget_meg->raise();
      }
  }
  
  void ITalkingWidget::ui_msgmemo_ishow()
  {
      if(ui_msgMemo->isVisible())
d6ba1152   陈明泉   1.3.1PC老师端正式上线发布版;
348
      {
6e10e93e   陈明泉   no message
349
          ui_msgMemo->hide();
d6ba1152   陈明泉   1.3.1PC老师端正式上线发布版;
350
351
          ui_msgMemo->show();
      }
6e10e93e   陈明泉   no message
352
353
354
355
      else
      {
          ui_msgMemo->show();
          pSess->_doodleWindow->ui->btnMessage->setStyleSheet("QPushButton{border-image: url(:/Images/VideoCall/icon_message_nomal.png);}");
9f17d59e   陈明泉   no message
356
      }
6e10e93e   陈明泉   no message
357
  
9f17d59e   陈明泉   no message
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
  }
  
  void ITalkingWidget::doResponse(int cmd,int,QString,QString result)
  {
      switch(cmd)
      {
          //通话课程
          case REQ_USER_COURSE_CALL_GET:
          {
              QJsonParseError jsonErr;
              QJsonDocument myjsonDoc1 = QJsonDocument::fromJson(result.toLatin1(),&jsonErr);
              pptarray = myjsonDoc1.object().find("result").value().toObject().find("ppt").value().toArray();
              QJsonObject courseInfo = myjsonDoc1.object().find("result").value().toObject().find("courseInfo").value().toObject();
  //            qDebug()<<"course: "<<courseInfo.find("course").value().toString()<<courseInfo.find("content").value().toString();
  //            qDebug()<<"pptarray: "<<pptarray;
  
              pptNmu = pptarray.size();
              IDownloadFile *downfile = IDownloadFile::Instance();
6e10e93e   陈明泉   no message
376
              for(int i = pptarray.size()-1;i >= 0;i--)
9f17d59e   陈明泉   no message
377
378
379
380
381
382
383
384
              {
                  QString couresFile = QCoreApplication::applicationDirPath()+"/couresImg/"+pptarray.at(i).toObject().\
                          find("pic").value().toObject().find("file_name").value().toString();
                  QString url = pptarray.at(i).toObject().\
                          find("pic").value().toObject().find("url").value().toString();
                  int fileId = pptarray.at(i).toObject().\
                          find("pic").value().toObject().find("file_id").value().toDouble();
                  QFile file(couresFile);
d6ba1152   陈明泉   1.3.1PC老师端正式上线发布版;
385
                  if(!file.exists() || file.size() < 1024)
9f17d59e   陈明泉   no message
386
                  {
d6ba1152   陈明泉   1.3.1PC老师端正式上线发布版;
387
388
                      if(file.exists())
                          file.remove();
9f17d59e   陈明泉   no message
389
390
391
392
                      downfile->addDownloadFile(url,couresFile,fileId);
                  }
              }
              downfile->startDownloadFile();
6e10e93e   陈明泉   no message
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
  //            connect(downfile,SIGNAL(downloadFileEnd()),this,SLOT(upCourseUi()));
              break;
          }
  
          case REQ_USER_REMARK_GET:
          {
              QJsonParseError jsonErr;
              QJsonDocument myjsonDoc1 = QJsonDocument::fromJson(result.toLatin1(),&jsonErr);
              QJsonObject remark = myjsonDoc1.object().find("result").value().toObject().find("remark").value().toObject();
              QString name = QString("");
              if(remark.size())
                  name = myjsonDoc1.object().find("result").value().toObject().find("remark").value().\
                          toObject().find("remark_name").value().toString();
              else
                  name = myjsonDoc1.object().find("result").value().toObject().find("userInfo").value().\
                          toObject().find("user_name").value().toString();
              qDebug()<<"result: "<<result<<"\n";
              ui->label_name->setText(name);
9f17d59e   陈明泉   no message
411
412
413
              break;
          }
      }
6e10e93e   陈明泉   no message
414
415
416
417
418
419
420
421
  
  }
  
  void ITalkingWidget::CallNetChanged(int num)
  {
      QString netStr = QString(":/Images/VideoCall/icon_wifi_0%1.png").arg(num);
  //    qDebug()<<netStr<<"\n";
      ui->label_net->setPixmap(QPixmap(netStr));
9f17d59e   陈明泉   no message
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
  }
  
  void ITalkingWidget::onVideoEvent(int eventType, const Notification &_info)
  {
      Notification info = (Notification &)_info;
      switch (eventType)
      {
      case ZmfVideoRenderDidReceive:
          ;//if (info.getIntValue(ZmfWindow) == (int)m_pVideoRemote->winId())
          {
             // showSessVideoSize(info.getIntValue(ZmfWidth), info.getIntValue(ZmfHeight));
          }
          break;
      }
      qDebug("CMQ onVideoEvent..eventType = %d..\n",eventType);
  }
  //void ITalkingWidget::on_pushButtonMin_clicked()
  //{
  //    this->showMinimized();
  //}
  
  void ITalkingWidget::slotClickedBtnAnswer()
  {
      Mtc_CallAnswer(RCallManager::Instance()->m_pRSession->sessId(), 0, ZTRUE, ZTRUE);
  }
  
  void ITalkingWidget::slotClickedBtnDecline()
  {
      Mtc_CallTerm(RCallManager::Instance()->m_pRSession->sessId(), EN_MTC_CALL_TERM_STATUS_DECLINE, ZNULL);
      //showSessTermed();
  }
  
  void ITalkingWidget::slotClickedBtnEnd()
  {
      Mtc_CallTerm(RCallManager::Instance()->m_pRSession->sessId(), EN_MTC_CALL_TERM_STATUS_NORMAL, ZNULL);
      //showSessTermed();
  }
  void ITalkingWidget::showSessTermed()
  {
      stopLocalVideo();
      stopRemoteVideo();
  }
  
  void ITalkingWidget::stopLocalVideo()
  {
      Zmf_VideoRenderRemoveAll((void *)videoItemTeacher->winId());
      Zmf_VideoRenderStop((void *)videoItemTeacher->winId());
  
      Zmf_VideoCaptureStopAll();
  }
  
  
  void ITalkingWidget::startLocalVideo()
  {
  
      qDebug("%s %d %d", __FUNCTION__, m_nRemoteWidth, m_nRemoteHeight);
  
      ZUINT dwWidth, dwHeight, dwFramerate;
      QString cameraId = RCallManager::Instance()->getCamera();
  
      // adjust size according to peer video resolution
      Mtc_CallGetVideoRemoteSize(RCallManager::Instance()->m_pRSession->sessId(), &dwWidth, &dwHeight);
      if (dwHeight == 720)
      {
          //slotShowFullSreen();
          m_nRemoteWidth = dwWidth;
          m_nRemoteHeight = dwHeight;
          videoItemTeacher->resize(dwWidth, dwHeight);
      }
  
      // start capture
      Mtc_MdmGetCaptureParms(&dwWidth, &dwHeight, &dwFramerate);
6e10e93e   陈明泉   no message
494
      qDebug()<<"dwWidth2 = "<<dwWidth;
9f17d59e   陈明泉   no message
495
496
      dwWidth = videoItemTeacher->width();
      dwHeight = videoItemTeacher->height();
6e10e93e   陈明泉   no message
497
      dwFramerate = 30;
d6ba1152   陈明泉   1.3.1PC老师端正式上线发布版;
498
      qDebug("CMQ startLocalVideo 1...");
6e10e93e   陈明泉   no message
499
  //    videoItemTeacher->resize(dwWidth, dwHeight);
9f17d59e   陈明泉   no message
500
501
502
503
504
505
506
      if (Zmf_VideoCaptureStart(cameraId.toUtf8().data(),
          dwWidth, dwHeight, dwFramerate) != 0)
      {
          qDebug("Failed to start capture.");
          return;
      }
  
d6ba1152   陈明泉   1.3.1PC老师端正式上线发布版;
507
      qDebug("CMQ startLocalVideo 2...");
9f17d59e   陈明泉   no message
508
509
510
511
512
513
514
515
      // start render
      if (Zmf_VideoRenderStart((void *)videoItemTeacher->winId(), ZmfRenderView) != 0)
      {
          qDebug("Failed to start render for capture.");
          Zmf_VideoCaptureStopAll();
          return;
      }
  
d6ba1152   陈明泉   1.3.1PC老师端正式上线发布版;
516
      qDebug("CMQ startLocalVideo 3...");
9f17d59e   陈明泉   no message
517
518
519
520
521
522
523
524
525
      // add render
      if (Zmf_VideoRenderAdd((void *)videoItemTeacher->winId(), cameraId.toUtf8().data(),
              0, ZmfRenderFullScreen) != 0)
      {
          qDebug("Failed to add render for capture.");
          Zmf_VideoRenderStop((void *)videoItemTeacher->winId());
          Zmf_VideoCaptureStopAll();
          return;
      }
d6ba1152   陈明泉   1.3.1PC老师端正式上线发布版;
526
      qDebug("CMQ startLocalVideo 4...");
9f17d59e   陈明泉   no message
527
528
529
  
      //resizeVideoWidgets();
      raise();
d6ba1152   陈明泉   1.3.1PC老师端正式上线发布版;
530
      qDebug("CMQ startLocalVideo OK...");
9f17d59e   陈明泉   no message
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
  }
  
  void ITalkingWidget::startRemoteVideo()
  {
      qDebug(__FUNCTION__);
  
      m_dwSessId = RCallManager::Instance()->m_pRSession->sessId();
  
      // start render
      if (Zmf_VideoRenderStart((void *)ui->labelVideoShow->winId(), ZmfRenderView) != 0)
      {
          qDebug("Failed to start render for peer.");
          return;
      }
  
      // add render
      ZCONST ZCHAR *pcCallName = Mtc_CallGetName(m_dwSessId);
      if (Zmf_VideoRenderAdd((void *)ui->labelVideoShow->winId(), pcCallName,
              0, ZmfRenderFullScreen) != 0)
      {
          qDebug("Failed to add render for peer.");
          Zmf_VideoRenderStop((void *)ui->labelVideoShow->winId());
          return;
      }
  
      // attach camera
      Mtc_CallCameraAttach(m_dwSessId,
          RCallManager::Instance()->getCamera().toUtf8().data());
      qDebug("CMQ startRemoteVideo OK...");
  }
  
  void ITalkingWidget::stopRemoteVideo()
  {
      Zmf_VideoRenderRemoveAll((void *)ui->labelVideoShow->winId());
      Zmf_VideoRenderStop((void *)ui->labelVideoShow->winId());
  }
  
  void ITalkingWidget::on_pushButtonClose_clicked()
  {
6e10e93e   陈明泉   no message
570
      QMessageBox::StandardButton rb = QMessageBox::question(NULL, "Close", "Are you sure to hang up?", QMessageBox::Yes | QMessageBox::No, QMessageBox::Yes);
9f17d59e   陈明泉   no message
571
572
573
574
575
576
577
578
579
580
581
      if(rb == QMessageBox::Yes)
      {
          on_pushButtonCloseVideo_clicked();
      }
  }
  
  void ITalkingWidget::otherVideoReceive(bool flag)
  {
  
      if(!flag)
      {
d6ba1152   陈明泉   1.3.1PC老师端正式上线发布版;
582
583
584
585
  //        QFont font;
  //        font.setPointSize(15);
  //        hint_label->setGeometry(290,300,420,50);
  //        hint_label->setFont(font);
9f17d59e   陈明泉   no message
586
          stopRemoteVideo();
d6ba1152   陈明泉   1.3.1PC老师端正式上线发布版;
587
588
589
590
  //        hint_label->setText(QString("The contact has turned off the webcam."));
  //        hint_label->show();
          videoFlag = false;
          ui->labelVideoShow->update();
9f17d59e   陈明泉   no message
591
592
593
594
      }
      else
      {
          startRemoteVideo();
d6ba1152   陈明泉   1.3.1PC老师端正式上线发布版;
595
596
597
          videoFlag = true;
  //        hint_label->setText(QString("The contact has turned on the webcam."));
  //        QTimer::singleShot(3*1000,hint_label,SLOT(hide()));
9f17d59e   陈明泉   no message
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
  //        hint_label->hide();
      }
  
  }
  /*
  对方挂断了通话
  */
  void ITalkingWidget::closeTheCurrentCall(QString)
  {
      QFont font;
      font.setPointSize(18);
      hint_label->setGeometry(260,300,500,50);
      hint_label->setFont(font);
      stopRemoteVideo();
      hint_label->setText(QString("The other has stopped the video chat."));
      hint_label->show();
      if(!m_hanging_up_timer->isActive())
          m_hanging_up_timer->start(3*1000);
6e10e93e   陈明泉   no message
616
617
      if(callTimeSec > 10)
          emit send_callTimeSec(callTimeSec);//通话时长
9f17d59e   陈明泉   no message
618
619
620
621
622
623
624
625
626
627
628
629
630
631
  }
  /*
  未接提醒
  */
  void ITalkingWidget::repulseCurrentCall()
  {
      if (!RCallManager::Instance()->m_pRSession)
          return;
      if(receiverUid < 1)
      {
          getSendUid();
          GotyeMsg::Instance()->sendMessage(QString("%1").arg(receiverUid), "Sorry! I am not available now. Please try again later.",GotyeMessageTypeText);
  //        qDebug("CMQ on_pushButtonCloseVideo_clicked %d...111\n",receiverUid);
      }
6e10e93e   陈明泉   no message
632
      slotClickedBtnEnd();
9f17d59e   陈明泉   no message
633
634
635
636
637
638
639
640
641
  }
  /*
  主动挂断了通话
  */
  void ITalkingWidget::on_pushButtonCloseVideo_clicked()
  {
      if (!RCallManager::Instance()->m_pRSession)
          return;
  
6e10e93e   陈明泉   no message
642
643
644
645
      emit send_callTimeSec(callTimeSec);//通话时长
      ui_msgMemo->hide();
      if(pptNmu > 1)
          JusDoodle::DoodleManager::Instance()->stopSess(RCallManager::Instance()->m_pRSession->sessId());
9f17d59e   陈明泉   no message
646
647
648
649
650
651
652
653
      QString user(QString("%1").arg(receiverUid));
      GotyeChatTarget getSender(user.toLatin1().data());
      apiist->deactiveSession(getSender); // < 隐藏与target的会话
      slotClickedBtnEnd();
      receiverUid = 0;
      callTimeSec = 0;
      m_timer->stop();
      stopCalling();
9f17d59e   陈明泉   no message
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
      pptNmu = 0;
  }
  
  void ITalkingWidget::on_pushButtonMic_clicked()
  {
  
      if(isClictMic)
      {
          Mtc_CallSetMicMute(RCallManager::Instance()->m_pRSession->sessId(),isClictMic);
          isClictMic = false;
          ui->pushButtonMic->setStyleSheet("QPushButton{background:transparent;border-image: url(:Images/VideoCall/icon_closemic_nor.png);}"
                                           "QPushButton:hover{border-image: url(:Images/VideoCall/icon_closemic_hov.png);}"
                                           "QPushButton:pressed{border-image: url(:Images/VideoCall/icon_closemic_pre.png);}");
      }
      else
      {
          Mtc_CallSetMicMute(RCallManager::Instance()->m_pRSession->sessId(),isClictMic);
          isClictMic = true;
          ui->pushButtonMic->setStyleSheet("QPushButton{background:transparent;border-image: url(:Images/VideoCall/icon_mic_nor.png);}"
                                           "QPushButton:hover{border-image: url(:Images/VideoCall/icon_mic_hov.png);}"
                                           "QPushButton:pressed{border-image: url(:Images/VideoCall/icon_mic_pre.png);}");
      }
      qDebug("CMQ on_pushButtonMic_clicked...\n");
  
  }
  
  void ITalkingWidget::on_pushButtonCameraChange_clicked()
  {
  
      if(isClictCamera)
      {
          isClictCamera = false;
          stopLocalVideo();
          Mtc_CallVideoSetSend(RCallManager::Instance()->m_pRSession->sessId(),EN_MTC_CALL_TRANSMISSION_CAMOFF);
          ui->pushButtonCameraChange->setStyleSheet("QPushButton{background:transparent;border-image: url(:Images/VideoCall/img_video_on_nor.png);}"
                                           "QPushButton:hover{border-image: url(:Images/VideoCall/img_video_on_hov.png);}"
                                           "QPushButton:pressed{border-image: url(:Images/VideoCall/img_video_on_pre.png);}");
6e10e93e   陈明泉   no message
691
692
  //    "border-image: url(:/Images/VideoCall/teacher_default.png);"
          videoItemTeacher->update();
9f17d59e   陈明泉   no message
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
      }
      else
      {
          isClictCamera = true;
          Mtc_CallVideoSetSend(RCallManager::Instance()->m_pRSession->sessId(),EN_MTC_CALL_TRANSMISSION_NORMAL);
          startLocalVideo();
          showCourseUi();
          ui->pushButtonCameraChange->setStyleSheet("QPushButton{background:transparent;border-image: url(:Images/VideoCall/img_video_off_nor.png);}"
                                           "QPushButton:hover{border-image: url(:Images/VideoCall/img_video_off_hov.png);}"
                                           "QPushButton:pressed{border-image: url(:Images/VideoCall/img_video_off_pre.png);}");
      }
      qDebug("CMQ on_pushButtonCameraChange_clicked...\n");
  }
  
  void ITalkingWidget::on_pushButtonVol_clicked()
  {
      if(isClictVol)
      {
          Mtc_CallSetSpkMute(RCallManager::Instance()->m_pRSession->sessId(),isClictVol);
          isClictVol = false;
          ui->pushButtonVol->setStyleSheet("QPushButton{background:transparent;border-image: url(:Images/VideoCall/icon_closevol_nor.png);}"
                                           "QPushButton:hover{border-image: url(:Images/VideoCall/icon_closevol_hov.png);}"
                                           "QPushButton:pressed{border-image: url(:Images/VideoCall/icon_closevol_pre.png);}");
  //        this->resize(QSize(1200,700));
  
      }
      else
      {
  //        this->resize(QSize(1000,700));
          Mtc_CallSetSpkMute(RCallManager::Instance()->m_pRSession->sessId(),isClictVol);
          isClictVol = true;
          ui->pushButtonVol->setStyleSheet("QPushButton{background:transparent;border-image: url(:Images/VideoCall/icon_vol_nor.png);}"
                                           "QPushButton:hover{border-image: url(:Images/VideoCall/icon_vol_hov.png);}"
                                           "QPushButton:pressed{border-image: url(:Images/VideoCall/icon_vol_pre.png);}");
      }
      qDebug("CMQ on_pushButtonVol_clicked...\n");
  }
  
  void ITalkingWidget::on_pushButton_clicked()
  {
  
      if( ui->textEdit->toPlainText() == NULL )
      {
          QMessageBox::warning( this , "warning","Message to be sent cannot be empty!" );
          return;
      }
      /**自己发送的消息*/
      if(receiverUid < 1)
          getSendUid();
  //    SendMsgShow( ui->textEdit->toPlainText(),Myhead);
      GotyeMsg::Instance()->sendMessage(QString("%1").arg(receiverUid), ui->textEdit->toPlainText(),GotyeMessageTypeText);
  
      ui->textEdit->clear();
      ui->textEdit->activateWindow();
      ui->textEdit->setFocus();
  }
  
  void ITalkingWidget::on_pushButton_picture_clicked()
  {
      if(receiverUid < 1)
          getSendUid();
      QFileDialog::Options options;
      //if (!native->isChecked())
          options |= QFileDialog::DontUseNativeDialog;
      QString selectedFilter,openFilesPath;
      QStringList files = QFileDialog::getOpenFileNames(
                                  this, tr("QFileDialog::getOpenFileNames()"),
                                  openFilesPath,
                                  tr("Images (*.png *.bmp *.jpg)"),
                                  &selectedFilter,
                                  options);
      if (files.count()) {
          for(int i = 0;i < files.count();i++)
          {
              GotyeMsg::Instance()->sendMessage(QString("%1").arg(receiverUid), files[i],GotyeMessageTypeImage);
  //            SendImageShow( files[i],Myhead);
          }
      }
  }
  
  bool ITalkingWidget::eventFilter(QObject *obj, QEvent *e)
  {
  //    Q_ASSERT(obj == inputTextEdit);
      if (e->type() == QEvent::KeyPress)
      {
          QKeyEvent *event = static_cast<QKeyEvent*>(e);
          if ((event->key() == Qt::Key_Enter || event->key() == Qt::Key_Return) && (event->modifiers() & Qt::ControlModifier))
          {
              ui->textEdit->append("");//换行
  //            on_pushButton_clicked(); //发送消息的槽
              return true;
          }
          else if (event->key() == Qt::Key_Enter || event->key() == Qt::Key_Return)
          {
              on_pushButton_clicked(); //发送消息的槽
              return true;
          }
      }
      return false;
  }
  
  
  void ITalkingWidget::on_pushButtonMessage_clicked()
  {
      static bool clickeMsg = false;
  
  //    if(clickeMsg)
  //    {
  //        ui->widget->hide();
  //        clickeMsg = false;
  //    }
  //    else
  //    {
  //        ui->widget->show();
  //        clickeMsg = true;
  //    }
  }