Skip to content
Snippets Groups Projects
Select Git revision
  • 00bab087b2e7afc7735ff1beb1463331f47ce7dc
  • master default protected
  • release/202005
  • release/202001
  • release/201912
  • release/201911
  • release/releaseWindowsTestOne
  • release/windowsReleaseTest
  • release/releaseTest
  • release/releaseWindowsTest
  • release/201910
  • release/qt/201910
  • release/windows-test/201910
  • release/201908
  • release/201906
  • release/201905
  • release/201904
  • release/201903
  • release/201902
  • release/201901
  • release/201812
  • 4.0.0
  • 2.2.0
  • 2.1.0
  • 2.0.1
  • 2.0.0
  • 1.4.1
  • 1.4.0
  • 1.3.0
  • 1.2.0
  • 1.1.0
31 results

call.cpp

Blame
    • Adrien Béraud's avatar
      00bab087
      call: wait for CONNECTED state to send messages · 00bab087
      Adrien Béraud authored
      In multi-device, we buffer outgoing messages and send them to subcalls
      when their SIP session become available.
      For this purpose we waited for CallState::ACTIVE which is not enough,
      since ConnectionState should be CONNECTED to ensure the SIp session to
      be availble.
      
      Change-Id: I2d84fdd4b4340e9ba198f75530212e83be575920
      Tuleap: #1154
      00bab087
      History
      call: wait for CONNECTED state to send messages
      Adrien Béraud authored
      In multi-device, we buffer outgoing messages and send them to subcalls
      when their SIP session become available.
      For this purpose we waited for CallState::ACTIVE which is not enough,
      since ConnectionState should be CONNECTED to ensure the SIp session to
      be availble.
      
      Change-Id: I2d84fdd4b4340e9ba198f75530212e83be575920
      Tuleap: #1154
    Code owners
    Assign users and groups as approvers for specific file changes. Learn more.
    videooverlay.cpp 5.94 KiB
    /***************************************************************************
     * Copyright (C) 2015-2017 by Savoir-faire Linux                           *
     * Author: Edric Ladent Milaret <edric.ladent-milaret@savoirfairelinux.com>*
     * Author: Andreas Traczyk <andreas.traczyk@savoirfairelinux.com>          *
     *                                                                         *
     * This program is free software; you can redistribute it and/or modify    *
     * it under the terms of the GNU General Public License as published by    *
     * the Free Software Foundation; either version 3 of the License, or       *
     * (at your option) any later version.                                     *
     *                                                                         *
     * This program is distributed in the hope that it will be useful,         *
     * but WITHOUT ANY WARRANTY; without even the implied warranty of          *
     * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the           *
     * GNU General Public License for more details.                            *
     *                                                                         *
     * You should have received a copy of the GNU General Public License       *
     * along with this program.  If not, see <http://www.gnu.org/licenses/>.   *
     **************************************************************************/
    
    #include "videooverlay.h"
    #include "ui_videooverlay.h"
    
    #include <QTime>
    
    // LRC
    #include "callmodel.h"
    #include "person.h"
    #include "account.h"
    
    #include "lrcinstance.h"
    #include "utils.h"
    
    VideoOverlay::VideoOverlay(QWidget* parent) :
        QWidget(parent),
        ui(new Ui::VideoOverlay),
        oneSecondTimer_(new QTimer(this))
    {
        ui->setupUi(this);
    
        ui->bottomButtons->setMouseTracking(true);
    
        ui->chatButton->setCheckable(true);
    
        setAttribute(Qt::WA_NoSystemBackground);
    
        ui->noMicButton->setCheckable(true);
    
        ui->onHoldLabel->setVisible(false);
    }
    
    VideoOverlay::~VideoOverlay()
    {
        delete ui;
    }
    
    void
    VideoOverlay::callStarted(const std::string& callId)
    {
        ui->timerLabel->setText("00:00");
        callId_ = callId;
        connect(oneSecondTimer_, &QTimer::timeout, this, &VideoOverlay::setTime);
        oneSecondTimer_->start(1000);
    }
    
    void
    VideoOverlay::setName(const QString& name)
    {
        ui->nameLabel->setText(name);
    }
    
    void
    VideoOverlay::setTime()
    {
        if (callId_.empty()) {
            return;
        }
        try {
            auto callInfo = LRCInstance::getCurrentCallModel()->getCall(callId_);
            if (callInfo.status == lrc::api::call::Status::IN_PROGRESS ||
                callInfo.status == lrc::api::call::Status::PAUSED) {
                int numSeconds = std::chrono::duration_cast<std::chrono::seconds>(
                    std::chrono::steady_clock::now() - callInfo.startTime).count();
                QTime t(0, 0, numSeconds);
                ui->timerLabel->setText(t.toString(numSeconds > 3600 ? "hh:mm:ss" : "mm:ss"));
            }
        } catch (...) { }
    }
    
    void
    VideoOverlay::setVideoMuteVisibility(bool visible)
    {
        ui->noVideoButton->setVisible(visible);
    }
    
    bool
    VideoOverlay::shouldShowOverlay()
    {
        auto callInfo = LRCInstance::getCurrentCallModel()->getCall(callId_);
        auto callPaused = callInfo.status == lrc::api::call::Status::PAUSED;
        return ui->bottomButtons->underMouse() || ui->topInfoBar->underMouse() || callPaused;
    }
    
    void
    VideoOverlay::simulateShowChatview(bool checked)
    {
        ui->chatButton->setChecked(checked);
    }
    
    bool
    VideoOverlay::getShowChatView()
    {
        return ui->chatButton->isChecked();
    }
    
    void
    VideoOverlay::on_hangupButton_clicked()
    {
        auto convInfo = Utils::getSelectedConversation();
        if (!convInfo.uid.empty()) {
            auto& callId = convInfo.callId;
            auto callModel = LRCInstance::getCurrentCallModel();
            if (callModel->hasCall(callId)) {
                callModel->hangUp(callId);
            }
        }
        ui->chatButton->setChecked(false);
    }
    
    void
    VideoOverlay::on_chatButton_toggled(bool checked)
    {
        emit setChatVisibility(checked);
    }
    
    void
    VideoOverlay::on_holdButton_clicked()
    {
        auto selectedConvUid = LRCInstance::getSelectedConvUid();
        auto conversation = Utils::getConversationFromUid(selectedConvUid,
            *LRCInstance::getCurrentConversationModel());
        auto& callId = conversation->callId;
        auto callModel = LRCInstance::getCurrentCallModel();
        if (callModel->hasCall(callId)) {
            auto onHold = callModel->getCall(callId).status == lrc::api::call::Status::PAUSED;
            ui->holdButton->setChecked(!onHold);
            ui->onHoldLabel->setVisible(!onHold);
            callModel->togglePause(callId);
        }
    }
    
    void
    VideoOverlay::on_noMicButton_clicked()
    {
        auto selectedConvUid = LRCInstance::getSelectedConvUid();
        auto conversation = Utils::getConversationFromUid(selectedConvUid,
            *LRCInstance::getCurrentConversationModel());
        auto& callId = conversation->callId;
        auto callModel = LRCInstance::getCurrentCallModel();
        if (callModel->hasCall(callId)) {
            ui->noMicButton->setChecked(callModel->getCall(callId).audioMuted);
            callModel->toggleMedia(callId, lrc::api::NewCallModel::Media::AUDIO);
        }
    }
    
    void
    VideoOverlay::on_noVideoButton_clicked()
    {
        auto selectedConvUid = LRCInstance::getSelectedConvUid();
        auto conversation = Utils::getConversationFromUid(selectedConvUid,
            *LRCInstance::getCurrentConversationModel());
        auto& callId = conversation->callId;
        auto callModel = LRCInstance::getCurrentCallModel();
        if (callModel->hasCall(callId)) {
            ui->noVideoButton->setChecked(callModel->getCall(callId).videoMuted);
            callModel->toggleMedia(callId, lrc::api::NewCallModel::Media::VIDEO);
        }
    }
    
    void
    VideoOverlay::on_recButton_clicked()
    {
        auto selectedConvUid = LRCInstance::getSelectedConvUid();
        auto conversation = Utils::getConversationFromUid(selectedConvUid,
            *LRCInstance::getCurrentConversationModel());
        auto& callId = conversation->callId;
        auto callModel = LRCInstance::getCurrentCallModel();
        if (callModel->hasCall(callId)) {
            callModel->toggleAudioRecord(callId);
        }
    }