/************************************************************************ Copyright (c) 2005-2012 by Juphoon System Software Co., Ltd. All rights reserved. This software is confidential and proprietary to Juphoon System Software Co., Ltd.. No part of this software may be reproduced, stored, transmitted, disclosed or used in any form or by any means other than as expressly provided by the written license agreement between JusTel and its licensee. THIS SOFTWARE IS PROVIDED BY JusTel "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL JusTel BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. Juphoon System Software Co., Ltd. ************************************************************************/ /************************************************* File name : rsessvideo.cpp Module : UI Dialog Author : vic.ren Created on : 2012-11-05 Description : The session dialog Modify History: 1. Date: Author: Modification: 2012-11-05 Vic Ren Create *************************************************/ #include "JusCallPch.h" #include "../mainapp.h" #include #include const QSize SIZEHVIDEO = QSize(640 + VIDEOSHADOW_WIDTH, 480 + VIDEOSHADOW_HEIGHT); const QSize SIZEVVIDEO = QSize(480 + VIDEOSHADOW_WIDTH, 640 + VIDEOSHADOW_HEIGHT); RSessVideo::RSessVideo(RSession *pSession, QWidget *parent) : RMetroDlg(parent) , m_pSession(pSession) , m_nSessTime(0) , m_nRemoteWidth(VGA_X) , m_nRemoteHeight(VGA_Y) , m_pStatistics(ZNULL) , m_bIsTerming(false) , m_pAnimationWidget(ZNULL) , m_pOpacityWidget(ZNULL) , sizeRemoteVideo(VGA_X, VGA_Y) , sizeLocalVideo(140, 105) , m_pWidgetBackground(ZNULL) , m_bIsMouseDown(false) , m_bIsMouseIncontrol(false) , m_bIsAnimation(false) , m_bIsVideoShowing(false) , m_nLocalWidth(VGA_X) , m_nLocalHeight(VGA_Y) { setWindowFlags(Qt::FramelessWindowHint | Qt::WindowMinimizeButtonHint); setFocusPolicy(Qt::StrongFocus); setMouseTracking(true); initDlg(); updateContact(); setFocus(Qt::MouseFocusReason); connect((MainApp *)qApp, SIGNAL(videoEvent(int, const Notification&)), SLOT(onVideoEvent(int, const Notification&))); } RSessVideo::~RSessVideo() { delete m_pWidgetBackground; } void RSessVideo::showEvent(QShowEvent * event) { if (!event) return; RMetroDlg::showEvent(event); if (m_pSession->isTalking() && !isFullScreen()) resizeVideoWidgets(false); m_pWidgetBackground->raise(); raise(); } void RSessVideo::closeEvent(QCloseEvent * event) { RClient::Instance()->widgetClosed(this); if (m_pSession->sessId() != ZINVALIDID) Mtc_CallTerm(m_pSession->sessId(), EN_MTC_CALL_TERM_STATUS_NORMAL, ZNULL); showSessTermed(); emit signalVideoEnded(); if (m_pStatistics) m_pStatistics->close(); hideControl(); if (m_pAnimationWidget) { m_pAnimationWidget->hide(); m_pAnimationWidget->deleteLater(); m_pAnimationWidget = ZNULL; } if (m_pOpacityWidget) { m_pOpacityWidget->hide(); m_pOpacityWidget->deleteLater(); m_pOpacityWidget = ZNULL; } if (m_pWidgetBackground) { m_pWidgetBackground->hide(); m_pWidgetBackground->deleteLater(); m_pWidgetBackground = ZNULL; } RMetroDlg::closeEvent(event); } void RSessVideo::mousePressEvent(QMouseEvent * event) { if (!event) return; RMetroDlg::mousePressEvent(event); m_pControlPad->hideVolumeControl(); m_bIsMouseDown = true; m_pWidgetBackground->hide(); } void RSessVideo::mouseReleaseEvent(QMouseEvent * event) { if (!event) return; QWidget::mouseReleaseEvent(event); m_bIsMouseDown = false; m_pWidgetBackground->show(); raise(); } void RSessVideo::mouseMoveEvent(QMouseEvent * event) { if (!event) return; if (!isFullScreen()) RMetroDlg::mouseMoveEvent(event); else QWidget::mouseMoveEvent(event); if (!m_bIsTerming && !m_bIsAnimation && hasFocus()) showControl(); m_pWidgetBackground->move(pos()); } void RSessVideo::enterEvent(QEvent * event) { QWidget::enterEvent(event); if (!hasFocus()) return; if (!m_bIsTerming) showControl(); } void RSessVideo::leaveEvent(QEvent * event) { QWidget::leaveEvent(event); if (isFullScreen() && m_pTimerMouseMove->isActive()) m_pTimerMouseMove->stop(); QTimer::singleShot(100, this, SLOT(slotMouseTimer())); } void RSessVideo::focusInEvent(QFocusEvent * event) { QWidget::focusInEvent(event); //if (event->reason() == Qt::MouseFocusReason) showControl(); } void RSessVideo::focusOutEvent(QFocusEvent * event) { QWidget::focusOutEvent(event); hideControl(); setCursor(Qt::ArrowCursor); } void RSessVideo::keyPressEvent(QKeyEvent * event) { QWidget::keyPressEvent(event); if (event->key() == Qt::Key_Escape || isFullScreen()) slotShowFullSreen(); } void RSessVideo::initDlg() { connect(this, SIGNAL(signalClickedBtnClose()), SLOT(close())); connect(this, SIGNAL(signalClickedBtnMin()), SLOT(showMinimized())); resize(SIZEHVIDEO); /* no boder */ //addBoder(); setDragEnabled(true); m_pWidgetBackground = new RWidget; m_pWidgetBackground->setWindowFlags(Qt::FramelessWindowHint | Qt::Tool); m_pWidgetBackground->resize(SIZEHVIDEO); m_pVideoRemote = new RVideoWidget(this); m_pVideoRemote->resize(VGA_X, VGA_Y); m_pVideoRemote->hide(); connect(m_pVideoRemote, SIGNAL(signalDoubleClicked()), SLOT(slotShowFullSreen())); m_pLabelVideoRemote = new QLabel(this); m_pLabelVideoRemote->setStyleSheet("QLabel {background: black}"); m_pLabelVideoRemote->resize(VGA_X, VGA_Y); m_pLabelVideoRemote->hide(); m_pVideoLocal = new RVideoWidget(this); m_pVideoLocal->resize(VGA_X, VGA_Y); m_pVideoLocal->hide(); m_pVideoLocal->move(VIDEOBORDER_LEFT, VIDEOBORDER_TOP); connect(m_pVideoLocal, SIGNAL(signalDoubleClicked()), SLOT(slotShowFullSreen())); drawRect(QRect(VIDEOBORDER_LEFT, VIDEOBORDER_TOP, width() - VIDEOSHADOW_WIDTH, height() - VIDEOSHADOW_HEIGHT), Qt::black); m_pTiltePad = new RTitlePad(m_pSession); connect(m_pTiltePad, SIGNAL(signalClickedBtnClose()), SLOT(close())); connect(m_pTiltePad, SIGNAL(signalClickedBtnMin()), SLOT(showMinimized())); connect(m_pTiltePad, SIGNAL(signalClickedBtnInfo()), SLOT(slotClickedBtnInfo())); connect(m_pTiltePad, SIGNAL(signalMouseInControl(bool)), SLOT(slotMouseInControl(bool))); m_pTiltePad->setFixedSize(width() - VIDEOSHADOW_WIDTH, 40); m_pControlPad = new RControlPad(m_pSession, true); connect(m_pControlPad, SIGNAL(signalClickedBtnAnswer()), SLOT(slotClickedBtnAnswer())); connect(m_pControlPad, SIGNAL(signalClickedBtnDecline()), SLOT(slotClickedBtnDecline())); connect(m_pControlPad, SIGNAL(signalClickedBtnEnd()), SLOT(slotClickedBtnEnd())); connect(m_pControlPad, SIGNAL(signalMouseInControl(bool)), SLOT(slotMouseInControl(bool))); m_pTimerMouseMove = new QTimer(this); m_pTimerMouseMove->setSingleShot(true); connect(m_pTimerMouseMove, SIGNAL(timeout()), SLOT(slotMouseTimer())); } void RSessVideo::moveToPositon() { RClient::Instance()->moveToPositon(this); move(x(), RClient::mediaY()); showControl(true); } void RSessVideo::updateContact() { QString qsName = m_pSession->name(); if (qsName.isEmpty()) { qsName = m_pSession->currentPhone(); } setWindowTitle(QString(tr("Video-")) + qsName); m_pTiltePad->updateContact(); } void RSessVideo::showSessFailed() { QTimer::singleShot(2000, this, SLOT(close())); } void RSessVideo::showSessOut() { m_pControlPad->showSessOut(); } void RSessVideo::showSessOutgoing() { m_pTiltePad->setTime(tr("Calling...")); m_pWidgetBackground->move(pos()); m_pWidgetBackground->show(); emit signalStartLocalVideo(); } void RSessVideo::showSessIncoming() { m_pTiltePad->setTime(tr("")); m_pControlPad->showSessIncoming(); moveToPositon(); m_pWidgetBackground->move(pos()); m_pWidgetBackground->show(); emit signalStartLocalVideo(); slotClickedBtnAnswer(); } void RSessVideo::showSessAlerted() { m_pTiltePad->setTime(tr("Ringing...")); } void RSessVideo::showSessConnecting() { m_pTiltePad->setTime(tr("Connecting...")); m_pWidgetBackground->show(); if (Mtc_CallHasVideo(m_pSession->sessId())) { startRemoteVideo(); } } void RSessVideo::showSessTalking() { m_pTiltePad->setTime("00:00"); disconnect(&m_TimerSess, SIGNAL(timeout()), 0, 0); connect(&m_TimerSess, SIGNAL(timeout()), this, SLOT(slotSessTimer())); m_TimerSess.start(1000); m_pControlPad->showSessTalking(); } void RSessVideo::showSessTermed() { m_TimerSess.stop(); m_bIsTerming = true; m_pControlPad->hide(); m_pTiltePad->hide(); if (m_pTimerMouseMove->isActive()) m_pTimerMouseMove->stop(); m_pTiltePad->setTime(tr("Ending...")); m_nSessTime = 0; stopLocalVideo(); stopRemoteVideo(); QTimer::singleShot(2000, this, SLOT(close())); } void RSessVideo::showSessVideoSize(ZUINT dwWidth, ZUINT dwHeight) { RClient::printLog("%s %d %d", __FUNCTION__, dwWidth, dwHeight); if (!m_bIsVideoShowing) { m_nRemoteWidth = dwWidth; m_nRemoteHeight = dwHeight; Mtc_CallGetVideoLocalSize(m_pSession->sessId(), &m_nLocalWidth, &m_nLocalHeight); m_pVideoRemote->show(); m_bIsVideoShowing = true; } else { if ((m_nRemoteHeight >= m_nRemoteWidth) && (dwHeight >= dwWidth)) return; if ((m_nRemoteHeight < m_nRemoteWidth) && (dwHeight < dwWidth)) return; ZUINT nTmp = m_nRemoteWidth; m_nRemoteWidth = m_nRemoteHeight; m_nRemoteHeight = nTmp; } if (isFullScreen()) { //m_pLabelVideoRemote->show(); m_pVideoLocal->raise(); } if (isMinimized()) return; resizeVideoWidgets(); } void RSessVideo::startLocalVideo() { RClient::printLog("%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(m_pSession->sessId(), &dwWidth, &dwHeight); if (dwHeight == 720) { slotShowFullSreen(); m_nRemoteWidth = dwWidth; m_nRemoteHeight = dwHeight; m_pVideoLocal->resize(dwWidth, dwHeight); } // start capture Mtc_MdmGetCaptureParms(&dwWidth, &dwHeight, &dwFramerate); dwWidth = 640; dwHeight = 480; dwFramerate = 30; m_pVideoLocal->resize(dwWidth, dwHeight); m_pVideoLocal->show(); if (Zmf_VideoCaptureStart(cameraId.toUtf8().data(), dwWidth, dwHeight, dwFramerate) != 0) { RClient::printLog("Failed to start capture."); return; } // start render if (Zmf_VideoRenderStart((void *)m_pVideoLocal->winId(), ZmfRenderView) != 0) { RClient::printLog("Failed to start render for capture."); Zmf_VideoCaptureStopAll(); return; } // add render if (Zmf_VideoRenderAdd((void *)m_pVideoLocal->winId(), cameraId.toUtf8().data(), 0, ZmfRenderFullScreen) != 0) { RClient::printLog("Failed to add render for capture."); Zmf_VideoRenderStop((void *)m_pVideoLocal->winId()); Zmf_VideoCaptureStopAll(); return; } resizeVideoWidgets(); raise(); } void RSessVideo::stopLocalVideo() { Zmf_VideoRenderRemoveAll((void *)m_pVideoLocal->winId()); Zmf_VideoRenderStop((void *)m_pVideoLocal->winId()); Zmf_VideoCaptureStopAll(); } void RSessVideo::startRemoteVideo() { RClient::printLog(__FUNCTION__); // start render if (Zmf_VideoRenderStart((void *)m_pVideoRemote->winId(), ZmfRenderView) != 0) { RClient::printLog("Failed to start render for peer."); return; } // add render ZCONST ZCHAR *pcCallName = Mtc_CallGetName(m_pSession->sessId()); if (Zmf_VideoRenderAdd((void *)m_pVideoRemote->winId(), pcCallName, 0, ZmfRenderFullContent) != 0) { RClient::printLog("Failed to add render for peer."); Zmf_VideoRenderStop((void *)m_pVideoRemote->winId()); return; } // attach camera Mtc_CallCameraAttach(m_pSession->sessId(), RCallManager::Instance()->getCamera().toUtf8().data()); } void RSessVideo::stopRemoteVideo() { Zmf_VideoRenderRemoveAll((void *)m_pVideoRemote->winId()); Zmf_VideoRenderStop((void *)m_pVideoRemote->winId()); } void RSessVideo::resizeVideoWidgets(bool bNeedAnimation) { RClient::printLog("%s remoteSize %d %d", __FUNCTION__, m_nRemoteWidth, m_nRemoteHeight); if (m_nRemoteWidth == 0 || (m_nRemoteHeight == 0)) { m_nRemoteWidth = VGA_X; m_nRemoteHeight = VGA_Y; } if (isFullScreen()) { resizeVideoWidgetsFull(); return; } /* resize remote video widget */ int nRemoteWidth = m_nRemoteWidth; int nRemoteHeight = m_nRemoteHeight; QSize sizeWidget = (m_nRemoteWidth > m_nRemoteHeight) ? SIZEHVIDEO : SIZEVVIDEO; calScaleSize(VGA_X, VGA_Y, nRemoteWidth, nRemoteHeight); RClient::printLog("%s calRemoteSize %d %d", __FUNCTION__, nRemoteWidth, nRemoteHeight); sizeRemoteVideo.setWidth(nRemoteWidth); sizeRemoteVideo.setHeight(nRemoteHeight); /* resize local video widget */ if (m_bIsVideoShowing) { ZUINT nW, nH; if (m_nLocalWidth != 0 && (m_nLocalHeight != 0)) { ZUINT nTmp = VGA_X * VGA_Y / 24; nW = (ZUINT)qSqrt((qreal)(nTmp * m_nLocalWidth / m_nLocalHeight)); nH = m_nLocalHeight * nW / m_nLocalWidth; } else { nW = 140; nH = 105; } RClient::printLog("%s LocalSize %d %d", __FUNCTION__, nW, nH); sizeLocalVideo.setWidth(nW); sizeLocalVideo.setHeight(nH); if (size() != sizeWidget && bNeedAnimation) rotateAnimation(); //opacityAnimation(); else { resize(sizeWidget); m_pVideoLocal->setGeometry(VIDEOBORDER_LEFT + 10, VIDEOBORDER_TOP + 10, nW, nH); m_pVideoRemote->setGeometry((sizeWidget.width() - nRemoteWidth)/2, (sizeWidget.height() - nRemoteHeight)/2, nRemoteWidth, nRemoteHeight); } } else { int nLocalWidth = m_nLocalWidth; int nLocalHeight = m_nLocalHeight; calScaleSize(VGA_X, VGA_Y, nLocalWidth, nLocalHeight); int nX = sizeWidget.width() - nLocalWidth; int nY = sizeWidget.height() - nLocalHeight; if (nX == 0) nX = 0; else nX = nX/2; if (nY == 0) nY = 0; else nY = nY/2; m_pVideoLocal->setGeometry(nX, nY, nLocalWidth, nLocalHeight); } /* draw background */ drawRect(QRect(VIDEOBORDER_LEFT, VIDEOBORDER_TOP, width() - 2, height() - 2), Qt::black); m_pVideoRemote->raise(); //m_pLabelVideoRemote->raise(); m_pVideoLocal->raise(); } void RSessVideo::resizeVideoWidgetsFull() { /* draw background */ drawRect(rect(), Qt::black); int nRemoteWidth = m_nRemoteWidth; int nRemoteHeight = m_nRemoteHeight; calScalSizeFull(nRemoteWidth, nRemoteHeight); RClient::printLog("%s %d %d", __FUNCTION__, nRemoteWidth, nRemoteHeight); m_pLabelVideoRemote->setGeometry((RClient::screenWidth() - nRemoteWidth)/2, (RClient::screenHeight() - nRemoteHeight)/2, nRemoteWidth, nRemoteHeight); m_pVideoRemote->setGeometry((RClient::screenWidth() - nRemoteWidth)/2, (RClient::screenHeight() - nRemoteHeight)/2, nRemoteWidth, nRemoteHeight); //QTimer::singleShot(300, this, SLOT(slotFullRotateDone())); if (m_bIsVideoShowing) { ZUINT nW, nH; ZUINT nTmp = RClient::screenWidth() * RClient::screenHeight() / 24; if (m_nLocalWidth != 0 && (m_nLocalHeight != 0)) { nW = (ZUINT)qSqrt((qreal)(nTmp * m_nLocalWidth / m_nLocalHeight)); nH = m_nLocalHeight * nW / m_nLocalWidth; } else { nW = 140; nH = 105; } RClient::printLog("%s %s %d %d", __FUNCTION__, "LocalSize", nW, nH); m_pVideoLocal->setGeometry(10, height() - nH - 10, nW, nH); } else { int nLocalWidth = m_nLocalWidth; int nLocalHeight = m_nLocalHeight; calScalSizeFull(nLocalWidth, nLocalHeight); m_pVideoLocal->setGeometry((RClient::screenWidth() - nLocalWidth)/2, (RClient::screenHeight() - nLocalHeight)/2, nLocalWidth, nLocalHeight); } } void RSessVideo::calScalSizeFull(int & width, int & height) { int w, h, nWidth, nHeight; int winWidth = RClient::screenWidth(); int winHeight = RClient::screenHeight(); if (width > height) { w = winWidth * height; h = winHeight * width; if (w > h) { nHeight = winHeight; nWidth = width * nHeight / height; } else { nWidth = winWidth; nHeight = height * nWidth / width; } } else { nHeight = winHeight; nWidth = width * nHeight / height; } width = nWidth; height = nHeight; } void RSessVideo::calScaleSize(int winWidth, int winHeight, int & width, int & height) { int w, h, nWidth, nHeight; #ifdef _DEBUG if (width > height) { w = winWidth * height; h = winHeight * width; if (w > h) { nHeight = winHeight; nWidth = width * nHeight / height; } else { nWidth = winWidth; nHeight = height * nWidth / width; } } else { w = winHeight * height; h = winWidth * width; if (w > h) { nHeight = winWidth; nWidth = width * nHeight / height; } else { nWidth = winHeight; nHeight = height * nWidth / width; } } #else if (width > height) { w = winWidth * height; h = winHeight * width; if (w > h) { nWidth = winWidth; nHeight = height * nWidth / width; } else { nHeight = winHeight; nWidth = width * nHeight / height; } } else { w = winHeight * height; h = winWidth * width; if (w > h) { nWidth = winHeight; nHeight = height * nWidth / width; } else { nHeight = winWidth; nWidth = width * nHeight / height; } } #endif width = nWidth; height = nHeight; } void RSessVideo::opacityAnimation() { RClient::printLog(__FUNCTION__); hideControl(); m_pWidgetBackground->hide(); if (m_pOpacityWidget) { m_pOpacityWidget->hide(); m_pOpacityWidget->deleteLater(); m_pOpacityWidget = ZNULL; } m_pOpacityWidget = new QWidget; m_pOpacityWidget->resize(width(), height()); m_pOpacityWidget->setWindowFlags(Qt::FramelessWindowHint | Qt::Tool); m_pOpacityWidget->setAttribute(Qt::WA_TranslucentBackground); m_pOpacityWidget->move(x(), y()); QLabel *pLabel = new QLabel; pLabel->setStyleSheet("QLabel {background: black}"); pLabel->resize(m_pOpacityWidget->size()); QGraphicsView *view = new QGraphicsView(m_pOpacityWidget); view->resize(m_pOpacityWidget->size()); view->setStyleSheet("background: transparent;border:0px"); view->setWindowFlags(Qt::FramelessWindowHint); view->setScene(new QGraphicsScene(0, 0, m_pOpacityWidget->width(), m_pOpacityWidget->height())); view->setHorizontalScrollBarPolicy(Qt::ScrollBarAlwaysOff); view->setVerticalScrollBarPolicy(Qt::ScrollBarAlwaysOff); QGraphicsProxyWidget *pW = view->scene()->addWidget(pLabel); QPropertyAnimation *animationOpacity = new QPropertyAnimation((QObject*)pW, "opacity"); animationOpacity->setDuration(350); animationOpacity->setStartValue(qreal(0)); animationOpacity->setEndValue(qreal(1)); animationOpacity->start(); QObject::connect(animationOpacity, SIGNAL(finished()), SLOT(slotOpacityAnimationFinished())); m_pOpacityWidget->show(); } void RSessVideo::rotateAnimation() { RClient::printLog(__FUNCTION__); const int nAnimation = 1200; hideControl(); hide(); m_pWidgetBackground->raise(); m_bIsAnimation = true; int nCenterX = x() + width()/2; int nCenterY = y() + height()/2; if (m_nRemoteWidth > m_nRemoteHeight) resize(SIZEHVIDEO); else resize(SIZEVVIDEO); int nX = width() - sizeRemoteVideo.width(); int nY = height() - sizeRemoteVideo.height(); if (nX == 0) nX = 0; else nX = nX/2; if (nY == 0) nY = 0; else nY = nY/2; m_pVideoRemote->setGeometry(nX, nY, sizeRemoteVideo.width(), sizeRemoteVideo.height()); m_pVideoLocal->setGeometry(VIDEOBORDER_LEFT + 10, VIDEOBORDER_TOP + 40, sizeLocalVideo.width(), sizeLocalVideo.height()); move(nCenterX - width()/2, nCenterY - height()/2); if (m_pAnimationWidget) { m_pAnimationWidget->hide(); m_pAnimationWidget->deleteLater(); m_pAnimationWidget = ZNULL; } m_pAnimationWidget = new QWidget; m_pAnimationWidget->resize(nAnimation, nAnimation); m_pAnimationWidget->setWindowFlags(Qt::FramelessWindowHint | Qt::Tool); m_pAnimationWidget->setAttribute(Qt::WA_TranslucentBackground); qreal qrRotateAng; QPoint ptEndValue; QLabel *pLabel = new QLabel; pLabel->setStyleSheet("QLabel {background: black}"); if ((m_nRemoteWidth > m_nRemoteHeight)) { qrRotateAng = -90; pLabel->resize(VGA_Y + VIDEOSHADOW_HEIGHT, VGA_X + VIDEOSHADOW_WIDTH); ptEndValue = QPoint((nAnimation - pLabel->height())/2, (nAnimation - pLabel->width())/2 + pLabel->width()); } else { qrRotateAng = 90; pLabel->resize(VGA_X + VIDEOSHADOW_WIDTH, VGA_Y + VIDEOSHADOW_HEIGHT); ptEndValue = QPoint((nAnimation - pLabel->height())/2 + pLabel->height(), (nAnimation - pLabel->width())/2); } nX = pos().x() - (nAnimation - pLabel->height())/2; nY = pos().y() - (nAnimation - pLabel->width())/2; m_pAnimationWidget->move(nX, nY); QGraphicsView *view = new QGraphicsView(m_pAnimationWidget); view->resize(nAnimation, nAnimation); view->setStyleSheet("background: transparent;border:0px"); view->setWindowFlags(Qt::FramelessWindowHint); view->setScene(new QGraphicsScene(0, 0, nAnimation, nAnimation)); view->setHorizontalScrollBarPolicy(Qt::ScrollBarAlwaysOff); view->setVerticalScrollBarPolicy(Qt::ScrollBarAlwaysOff); QGraphicsProxyWidget *pW = view->scene()->addWidget(pLabel); pW->setTransformOriginPoint(QPoint(pLabel->width()/2, pLabel->height()/2)); pW->setGeometry(QRect((nAnimation - pLabel->width())/2, (nAnimation - pLabel->height())/2, pLabel->width(), pLabel->height())); QPropertyAnimation *animationRotate = new QPropertyAnimation(pW, "rotation"); animationRotate->setDuration(350); animationRotate->setStartValue(qreal(0)); animationRotate->setEndValue(qreal(qrRotateAng)); QPropertyAnimation *animationOpacity = new QPropertyAnimation(pW, "opacity"); animationOpacity->setDuration(350); animationOpacity->setStartValue(qreal(1)); animationOpacity->setEndValue(qreal(0)); QSequentialAnimationGroup *animationGroup = new QSequentialAnimationGroup; animationGroup->addAnimation(animationRotate); animationGroup->addAnimation(animationOpacity); QObject::connect(animationRotate, SIGNAL(finished()), SLOT(slotAnimationFinished())); QObject::connect(animationGroup, SIGNAL(finished()), SLOT(slotHideVideoLabel())); m_pAnimationWidget->show(); m_pAnimationWidget->raise(); animationGroup->start(); m_pWidgetBackground->hide(); m_pWidgetBackground->resize(size()); m_pWidgetBackground->move(nCenterX - width()/2, nCenterY - height()/2); } void RSessVideo::hideControl() { if (m_pTiltePad->isHidden()) { m_pTimerMouseMove->stop(); return; } m_pControlPad->hideVolumeControl(); m_pTiltePad->hide(); m_pControlPad->hide(); setCursor(Qt::BlankCursor); if (m_pTimerMouseMove->isActive()) m_pTimerMouseMove->stop(); } void RSessVideo::showControl(bool bMustShow) { setCursor(Qt::ArrowCursor); if (m_pTimerMouseMove->isActive()) m_pTimerMouseMove->stop(); m_pTimerMouseMove->start(5000); if (m_bIsAnimation) return; if (!bMustShow &&!m_bIsMouseDown && !m_pControlPad->isHidden() && !m_bIsMouseIncontrol) return; int nX, nY; nX = width()/2 - 190; if (isFullScreen()) { m_pTiltePad->setFixedWidth(width()); m_pTiltePad->move(x(), y()); nY = height() - m_pControlPad->height() - 10; } else { m_pTiltePad->setFixedWidth(width() - VIDEOSHADOW_WIDTH); m_pTiltePad->move(x() + VIDEOBORDER_LEFT, y() + VIDEOBORDER_TOP); nY = height() - m_pControlPad->height() - VIDEOBORDER_BOTTOM; } m_pControlPad->move(x() + nX, y() + nY); m_pControlPad->show(); m_pTiltePad->show(); setFocus(); show(); } void RSessVideo::moveVideo(const QPoint & point) { move(mapToParent(point)); showControl(); m_pWidgetBackground->move(pos()); } void RSessVideo::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; } } void RSessVideo::slotClickedBtnInfo() { if (m_pStatistics) { m_pStatistics->hide(); m_pStatistics->deleteLater(); m_pStatistics = ZNULL; return; } m_pStatistics = new RStatistics(m_pSession->sessId()); connect(m_pStatistics, SIGNAL(signalClosed()), SLOT(slotStatisticsClosed())); m_pStatistics->show(); m_pStatistics->move(x() + 40, y() + 40); } void RSessVideo::slotClickedBtnAnswer() { Mtc_CallAnswer(m_pSession->sessId(), 0, ZTRUE, ZTRUE); } void RSessVideo::slotClickedBtnDecline() { Mtc_CallTerm(m_pSession->sessId(), EN_MTC_CALL_TERM_STATUS_DECLINE, ZNULL); showSessTermed(); } void RSessVideo::slotClickedBtnEnd() { Mtc_CallTerm(m_pSession->sessId(), EN_MTC_CALL_TERM_STATUS_NORMAL, ZNULL); showSessTermed(); } void RSessVideo::slotShowFullSreen() { if (m_bIsTerming) return; m_pWidgetBackground->hide(); hideControl(); if (isFullScreen()) showNormal(); else showFullScreen(); resizeVideoWidgets(false); m_pWidgetBackground->resize(size()); m_pWidgetBackground->move(pos()); m_pWidgetBackground->show(); raise(); } void RSessVideo::slotOpacityAnimationFinished() { rotateAnimation(); if (!m_pOpacityWidget) return; m_pOpacityWidget->hide(); m_pOpacityWidget->deleteLater(); m_pOpacityWidget = ZNULL; } void RSessVideo::slotAnimationFinished() { //QTimer::singleShot(100, this, SLOT(slotHideVideoLabel())); m_pWidgetBackground->show(); show(); if (!m_pAnimationWidget) return; m_pAnimationWidget->raise(); } void RSessVideo::slotHideVideoLabel() { if (!m_pAnimationWidget) return; m_pAnimationWidget->hide(); m_pAnimationWidget->deleteLater(); m_pAnimationWidget = ZNULL; int nX = x(); int nY = y(); if (nX < 0) nX = 0; else if (nX > RClient::screenWidth() - width()) nX = RClient::screenWidth() - width(); if (nY < 0) nY = 0; else if (nY > RClient::screenHeight() - height()) nY = RClient::screenHeight() - height(); if (nX != x() || nY != y()) { hideControl(); QPropertyAnimation *animationPosition = new QPropertyAnimation(this, "geometry"); animationPosition->setDuration(350); animationPosition->setStartValue(QRect(x(), y(), width(), height())); animationPosition->setEndValue(QRect(nX, nY, width(), height())); QPropertyAnimation *animationPosition1 = new QPropertyAnimation(m_pWidgetBackground, "geometry"); animationPosition1->setDuration(350); animationPosition1->setStartValue(QRect(x(), y(), width(), height())); animationPosition1->setEndValue(QRect(nX, nY, width(), height())); QParallelAnimationGroup *animationGroup = new QParallelAnimationGroup; animationGroup->addAnimation(animationPosition); animationGroup->addAnimation(animationPosition1); animationGroup->start(); connect(animationGroup, SIGNAL(finished()), SLOT(slotAnimationPositionFinished())); return; } m_bIsAnimation = false; } void RSessVideo::slotAnimationPositionFinished() { m_bIsAnimation = false; } void RSessVideo::slotStatisticsClosed() { m_pStatistics = ZNULL; } void RSessVideo::slotSessTimer() { m_nSessTime ++; char strTimer[100] = {0}; sprintf(strTimer, "%02d:%02d", m_nSessTime/60, m_nSessTime%60); m_pTiltePad->setTime(QString(strTimer)); } void RSessVideo::slotMouseTimer() { if (m_pTimerMouseMove->isActive()) m_pTimerMouseMove->stop(); if (m_bIsMouseIncontrol || !m_bIsVideoShowing) m_pTimerMouseMove->start(5000); else hideControl(); } void RSessVideo::slotMouseInControl(bool bIsInControl) { m_bIsMouseIncontrol = bIsInControl; } void RSessVideo::slotFullRotateDone() { m_pLabelVideoRemote->hide(); }