Commit 0ef04d6d authored by Ming Rui Zhang's avatar Ming Rui Zhang

video: enable to show preview/change video device when in a call

- make video decive changing in context menu sync with video decive in media setting
- During a call, context menu media device = setting media decive
- Out of a call, setting media decive = default device

Change-Id: I42c3858e3d90143cbf31cc52e9587e62b75f90da
parent 720a11a6
......@@ -5,6 +5,7 @@
* Author: Olivier Soldano <olivier.soldano@savoirfairelinux.com> *
* Author: Andreas Traczyk <andreas.traczyk@savoirfairelinux.com> *
* Author: Isa Nanic <isa.nanic@savoirfairelinux.com> *
* Author: Mingrui Zhang <mingrui.zhang@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 *
......@@ -729,8 +730,6 @@ void CallWidget::slotShowIncomingCallView(const std::string& accountId,
ui->messagesWidget->show();
}
ui->videoWidget->pushRenderer(convInfo.callId, LRCInstance::accountModel().getAccountInfo(accountId).profileInfo.type == lrc::api::profile::Type::SIP);
QFontMetrics primaryCallLabelFontMetrics(ui->callingBestNameLabel->font());
QFontMetrics sencondaryCallLabelFontMetrics(ui->callingBestIdLabel->font());
......@@ -1380,3 +1379,15 @@ CallWidget::Copy()
{
ui->messageView->copySelectedText(clipboard_);
}
void
CallWidget::disconnectRendering()
{
ui->videoWidget->disconnectRendering();
}
void
CallWidget::connectRendering(bool started)
{
ui->videoWidget->connectRendering(started);
}
......@@ -58,6 +58,10 @@ public:
~CallWidget();
int getLeftPanelWidth();
void disconnectRendering();
// if started is true, only update, stop signals are connected
void connectRendering(bool started = false);
// NavWidget
virtual void navigated(bool to);
......
/***************************************************************************
* Copyright (C) 2015-2017 by Savoir-faire Linux *
* Copyright (C) 2015-2019 by Savoir-faire Linux *
* Author: Edric Ladent Milaret <edric.ladent-milaret@savoirfairelinux.com>*
* Author: Andreas Traczyk <andreas.traczyk@savoirfairelinux.com> *
* Author: Mingrui Zhang <mingrui.zhang@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 *
......@@ -20,6 +21,7 @@
#include "mainwindow.h"
#include "ui_mainwindow.h"
#include <QtConcurrent/QtConcurrent>
#include <QDesktopWidget>
#include <QDir>
#include <QScreen>
......@@ -187,6 +189,16 @@ MainWindow::MainWindow(QWidget* parent)
});
timer->start(1000);
#endif
connect(ui->settingswidget, &SettingsWidget::switchCallWidgetToSettingsWidgetPreview,
this, &MainWindow::slotSwitchVideoWidget);
connect(ui->settingswidget, &SettingsWidget::switchSettingsWidgetPreviewToCallWidget,
this, &MainWindow::slotSwitchVideoWidget);
connect(ui->settingswidget, &SettingsWidget::switchCallWidgetToSettingsWidgetPhotoBooth,
this, &MainWindow::slotSwitchVideoWidget);
connect(ui->settingswidget, &SettingsWidget::switchSettingsWidgetPhotoBoothToCallWidget,
this, &MainWindow::slotSwitchVideoWidget);
connect(ui->settingswidget, &SettingsWidget::videoInputDeviceConnectionLost,
this, &MainWindow::slotSwitchVideoWidget);
}
MainWindow::~MainWindow()
......@@ -405,3 +417,70 @@ void MainWindow::slotAccountListChanged()
systrayMenu->addAction(exitAction_);
}
}
void MainWindow::slotSwitchVideoWidget(Utils::VideoWidgetSwapType type)
{
auto convInfo = Utils::getCurrentConvInfo();
bool isAudioOnly = LRCInstance::getCurrentCallModel()->getCall(convInfo.callId).isAudioOnly;
switch (type)
{
case Utils::VideoWidgetSwapType::CallWidgetToSettingsWidgetPreview: {
// switch local rendering from call to setting preview
ui->callwidget->disconnectRendering();
ui->settingswidget->connectStartedRenderingToPreview();
if (isAudioOnly) {
QtConcurrent::run(
[this] {
LRCInstance::avModel().stopPreview();
LRCInstance::avModel().startPreview();
});
break;
}
break;
}
case Utils::VideoWidgetSwapType::CallWidgetToSettingsWidgetPhotoBooth: {
// switch local rendering from call to setting photo booth
ui->callwidget->disconnectRendering();
ui->settingswidget->connectStartedRenderingToPhotoBooth();
if (isAudioOnly) {
QtConcurrent::run(
[this] {
LRCInstance::avModel().stopPreview();
LRCInstance::avModel().startPreview();
});
break;
}
break;
}
case Utils::VideoWidgetSwapType::SettingsWidgetPreviewToCallWidget: {
// switch local rendering from setting preview to call
ui->settingswidget->disconnectPreviewRendering();
if (isAudioOnly) {
QtConcurrent::run([this] { LRCInstance::avModel().stopPreview(); });
break;
}
ui->callwidget->connectRendering(true);
break;
}
case Utils::VideoWidgetSwapType::SettingsWidgetPhotoBoothToCallWidget: {
// switch local rendering from setting photo booth to call
ui->settingswidget->disconnectPhotoBoothRendering();
if (isAudioOnly) {
QtConcurrent::run([this] { LRCInstance::avModel().stopPreview(); });
break;
}
ui->callwidget->connectRendering(true);
break;
}
case Utils::VideoWidgetSwapType::VideoInputDeviceConnectionLost: {
if (isAudioOnly) {
break;
}
ui->callwidget->connectRendering(false);
break;
}
default: {
break;
}
}
}
/***************************************************************************
* Copyright (C) 2015-2017 by Savoir-faire Linux *
* Copyright (C) 2015-2019 by Savoir-faire Linux *
* Author: Edric Ladent Milaret <edric.ladent-milaret@savoirfairelinux.com>*
* *
* This program is free software; you can redistribute it and/or modify *
......@@ -26,6 +26,7 @@
#include "navwidget.h"
#include "settingswidget.h"
#include "utils.h"
static constexpr char IDM_ABOUTBOX = 0x0010;
......@@ -54,6 +55,10 @@ public:
float getCurrentScalingRatio();
void showWindow();
public slots:
// A slot where covers all cases of video rendering switch between widgets
void slotSwitchVideoWidget(Utils::VideoWidgetSwapType Type);
protected:
bool nativeEvent(const QByteArray& eventType, void* message, long* result);
void closeEvent(QCloseEvent* event);
......
......@@ -2,6 +2,7 @@
* Copyright (C) 2015-2019 by Savoir-faire Linux *
* Author: Olivier Soldano <olivier.soldano@savoirfairelinux.com> *
* Author: Andreas Traczyk <andreas.traczyk@savoirfairelinux.com> *
* Author: Mingrui Zhang <mingrui.zhang@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 *
......@@ -19,6 +20,7 @@
#include "photoboothwidget.h"
#include "ui_photoboothwidget.h"
#include "settingswidget.h"
#include <QFileDialog>
#include <QStandardPaths>
......@@ -51,7 +53,6 @@ PhotoboothWidget::PhotoboothWidget(QWidget *parent) :
flashAnimation_->setEndValue(0);
flashAnimation_->setEasingCurve(QEasingCurve::OutCubic);
takePhotoState_ = true;
ui->takePhotoButton->setIcon(QIcon(":/images/icons/baseline-camera_alt-24px.svg"));
}
......@@ -61,28 +62,47 @@ PhotoboothWidget::~PhotoboothWidget()
delete ui;
}
void PhotoboothWidget::startBooth()
void PhotoboothWidget::startBooth(bool isDeviceChanged)
{
hasAvatar_ = false;
ui->videoFeed->setResetPreview(true);
ui->videoFeed->connectRendering();
LRCInstance::avModel().stopPreview();
LRCInstance::avModel().startPreview();
if (!LRCInstance::getActiveCalls().size() || isDeviceChanged) {
// if no active calls
ui->videoFeed->connectPreviewOnlyRendering();
QtConcurrent::run(
[this] {
LRCInstance::avModel().stopPreview();
LRCInstance::avModel().startPreview();
});
} else if (settingsPreviewed_) {
// if setting preview is viewed
emit leaveSettingsWidgetPreviewToSettingsWidgetPhotoBooth(
Utils::VideoWidgetSwapType::SettingsWidgetPreviewToSettingsWidgetPhotoBooth);
hasConnection_ = true;
} else {
// call video rendering direct to photo booth
emit enterSettingsWidgetPhotoBoothFromCallWidget(
Utils::VideoWidgetSwapType::CallWidgetToSettingsWidgetPhotoBooth);
hasConnection_ = true;
}
takePhotoState_ = true;
ui->videoFeed->show();
ui->avatarLabel->hide();
takePhotoState_ = true;
ui->takePhotoButton->setIcon(QIcon(":/images/icons/baseline-camera_alt-24px.svg"));
}
void PhotoboothWidget::stopBooth()
{
if (!LRCInstance::getActiveCalls().size()) {
// if no active calls
LRCInstance::avModel().stopPreview();
} else if(hasConnection_){
// if video connection is still on photo booth (now stopBooth will onlt be called once leaving the setting widget)
emit enterCallWidgetFromSettingsWidgetPhotoBooth(
Utils::VideoWidgetSwapType::SettingsWidgetPhotoBoothToCallWidget);
hasConnection_ = false;
}
ui->videoFeed->hide();
ui->avatarLabel->show();
takePhotoState_ = false;
ui->takePhotoButton->setIcon(QIcon(":/images/icons/baseline-refresh-24px.svg"));
resetToAvatarLabel();
}
void
......@@ -106,7 +126,11 @@ PhotoboothWidget::on_importButton_clicked()
ui->avatarLabel->setPixmap(QPixmap::fromImage(Utils::getCirclePhoto(avatar, ui->avatarLabel->width())));
hasAvatar_ = true;
emit photoTaken();
stopBooth();
if (!LRCInstance::getActiveCalls().size()) {
stopBooth();
} else {
resetToAvatarLabel();
}
}
void
......@@ -130,24 +154,39 @@ PhotoboothWidget::on_takePhotoButton_clicked()
QtConcurrent::run(
[this] {
LRCInstance::avModel().stopPreview();
auto photo = Utils::cropImage(ui->videoFeed->takePhoto());
auto avatar = photo.scaled(224, 224, Qt::KeepAspectRatioByExpanding, Qt::SmoothTransformation);
avatarPixmap_ = QPixmap::fromImage(avatar);
ui->avatarLabel->setPixmap(QPixmap::fromImage(Utils::getCirclePhoto(avatar, ui->avatarLabel->width())));
hasAvatar_ = true;
emit photoTaken();
stopBooth();
if (!LRCInstance::getActiveCalls().size()) {
stopBooth();
} else {
resetToAvatarLabel();
}
});
}
}
void
PhotoboothWidget::setAvatarPixmap(const QPixmap& avatarPixmap, bool _default)
PhotoboothWidget::setAvatarPixmap(const QPixmap& avatarPixmap, bool default, bool stopPhotoboothPreview)
{
// function will be called when entering the setting widget
// or when settings change from one to another if previously the photo booth
// is opened and not stopped
// this is to ensure that when we are in a call,
// entering the setting, changing from settings to settings,
// video rendering will be used efficiently
// see resetPhotoBoothStateWhenSettingChanged in settingswidget.cpp
ui->avatarLabel->setPixmap(avatarPixmap);
stopBooth();
if (_default) {
if (!LRCInstance::getActiveCalls().size() && stopPhotoboothPreview) {
LRCInstance::avModel().stopPreview();
}
resetToAvatarLabel();
if (default) {
ui->takePhotoButton->setIcon(QIcon(":/images/icons/round-add_a_photo-24px.svg"));
}
}
......@@ -162,4 +201,30 @@ bool
PhotoboothWidget::hasAvatar()
{
return hasAvatar_;
}
\ No newline at end of file
}
void
PhotoboothWidget::connectRendering()
{
// connect only local preview
ui->videoFeed->rendererStartedWithoutDistantRender();
}
void
PhotoboothWidget::disconnectRendering()
{
ui->videoFeed->disconnectRendering();
}
void
PhotoboothWidget::resetToAvatarLabel()
{
ui->videoFeed->hide();
ui->avatarLabel->show();
takePhotoState_ = false;
if (!hasAvatar_) {
ui->takePhotoButton->setIcon(QIcon(":/images/icons/round-add_a_photo-24px.svg"));
} else {
ui->takePhotoButton->setIcon(QIcon(":/images/icons/baseline-refresh-24px.svg"));
}
}
......@@ -19,6 +19,8 @@
#pragma once
#include "utils.h"
#include <QWidget>
#include <QLabel>
#include <QPropertyAnimation>
......@@ -35,17 +37,34 @@ public:
explicit PhotoboothWidget(QWidget *parent = 0);
~PhotoboothWidget();
void startBooth();
void startBooth(bool isDeviceChanged = false);
void stopBooth();
void setAvatarPixmap(const QPixmap& avatarPixmap, bool _default = false);
void setAvatarPixmap(const QPixmap& avatarPixmap, bool default = false, bool stopPhotoboothPreview = false);
const QPixmap& getAvatarPixmap();
bool hasAvatar();
void connectRendering();
void disconnectRendering();
// hasConnection_ decides whether the video rendering connection is still in photobooth
// (connection transmitted from other video widget)
bool isPhotoBoothOpened() { return takePhotoState_; }
bool isPhotoBoothConnected() { return hasConnection_; }
void resetTakePhotoState(bool state) { takePhotoState_ = state; }
// settingsPreviewed_ changed once the setting's preview is previewed
void setIsSettingsPreviewed(bool state) { settingsPreviewed_ = state; }
signals:
void enterSettingsWidgetPhotoBoothFromCallWidget(Utils::VideoWidgetSwapType type);
void enterCallWidgetFromSettingsWidgetPhotoBooth(Utils::VideoWidgetSwapType type);
void leaveSettingsWidgetPreviewToSettingsWidgetPhotoBooth(Utils::VideoWidgetSwapType type);
private slots:
void on_importButton_clicked();
void on_takePhotoButton_clicked();
private:
void resetToAvatarLabel();
QString fileName_;
Ui::PhotoboothWidget *ui;
......@@ -54,7 +73,9 @@ private:
QPixmap avatarPixmap_;
bool hasAvatar_;
bool takePhotoState_;
bool takePhotoState_ { false };
bool hasConnection_ { false };
bool settingsPreviewed_ { false };
signals:
void photoTaken();
......
This diff is collapsed.
......@@ -23,6 +23,7 @@
#include "lrcinstance.h"
#include "navwidget.h"
#include "utils.h"
#include "advancedsettingswidget.h"
#include "advancedsipsettingwidget.h"
......@@ -45,12 +46,29 @@ public:
explicit SettingsWidget(QWidget* parent = nullptr);
~SettingsWidget();
void connectStartedRenderingToPreview();
void connectStartedRenderingToPhotoBooth();
void disconnectPreviewRendering();
void disconnectPhotoBoothRendering();
// NavWidget
virtual void navigated(bool to);
virtual void updateCustomUI();
public slots:
virtual void slotAccountListChanged();
void photoBoothEnterReceived(Utils::VideoWidgetSwapType Type);
void photoBoothLeaveReceived(Utils::VideoWidgetSwapType Type);
signals:
void switchCallWidgetToSettingsWidgetPreview(Utils::VideoWidgetSwapType type);
void switchCallWidgetToSettingsWidgetPhotoBooth(Utils::VideoWidgetSwapType type);
void switchSettingsWidgetPreviewToCallWidget(Utils::VideoWidgetSwapType type);
void switchSettingsWidgetPhotoBoothToCallWidget(Utils::VideoWidgetSwapType type);
void settingWidgetPhotoBoothTosettingWidgetPreviewSignal(Utils::VideoWidgetSwapType type);
void settingWidgetPreviewTosettingWidgetPhotoBoothSignal(Utils::VideoWidgetSwapType type);
void videoInputDeviceConnectionLost(Utils::VideoWidgetSwapType type);
private:
Ui::SettingsWidget* ui;
......@@ -67,7 +85,7 @@ private:
SEARCHING
};
void setAvatar(PhotoboothWidget* avatarWidget);
void setAvatar(PhotoboothWidget* avatarWidget, bool stopPhotoboothPreview);
void setSelected(Button sel);
void updateAccountInfoDisplayed();
void resizeEvent(QResizeEvent* event);
......@@ -83,12 +101,13 @@ private:
void populateGeneralSettings();
void populateAVSettings();
void setFormatListForDevice(const std::string& device);
void startPreviewing();
void startPreviewing(bool isDeviceChanged = false);
void stopPreviewing();
void toggleVideoSettings(bool enabled);
void toggleVideoPreview(bool enabled);
void startAudioMeter(bool blocking = false);
void stopAudioMeter(bool blocking = false);
void resetPhotoBoothStateWhenSettingChanged(Button type);
QList<QMetaObject::Connection> accountConnections_;
QString registeredName_;
......@@ -99,7 +118,6 @@ private:
lrc::api::profile::Type pastAccount_ = lrc::api::profile::Type::INVALID;
bool advancedSettingsDropped_ = false;
QList<QPair<std::string, float>> formatIndexList_;
std::string currentDisplayedVideoDevice_;
AdvancedSIPSettingsWidget* advancedSIPSettingsWidget_;
QScrollArea* scrollSIPArea_;
bool advancedSIPSettingsDropped_ = false;
......@@ -107,6 +125,9 @@ private:
int avatarSIPSize_;
bool regNameBtn_ = false;
const int itemHeight_ = 55;
bool previewed_ {false};
int previousDeviceSize_ { static_cast<int>(LRCInstance::avModel().getDevices().size()) };
bool deviceWasEmpty_ { false };
QMovie* lookupSpinnerMovie_;
QPixmap statusSuccessPixmap_;
......@@ -144,4 +165,10 @@ private slots:
void slotDeviceBoxCurrentIndexChanged(int index);
void slotFormatBoxCurrentIndexChanged(int index);
void slotSetHardwareAccel(bool state);
void videoDeviceEventHandlerAndMediaSettingSetUp();
public:
bool getIsPreviewed() { return previewed_; }
Button getPreviousButton() { return pastButton_; }
};
......@@ -755,6 +755,13 @@ Utils::getConversationFromUid(const std::string & convUid, bool filtered)
return lrc::api::conversation::Info();
}
const lrc::api::conversation::Info&
Utils::getCurrentConvInfo()
{
auto convModel = LRCInstance::getCurrentConversationModel();
return *Utils::getConversationFromUid(LRCInstance::getSelectedConvUid(), *convModel);
}
void
Utils::swapQListWidgetItems(QListWidget* list, bool down)
{
......
......@@ -107,6 +107,7 @@ QImage cropImage(const QImage& img);
lrc::api::conversation::Info getConversationFromCallId(const std::string& callId);
lrc::api::conversation::Info getSelectedConversation();
lrc::api::conversation::Info getConversationFromUid(const std::string & convUid, bool filtered = true);
const lrc::api::conversation::Info& getCurrentConvInfo();
// misc helpers
void swapQListWidgetItems(QListWidget* list, bool down = true);
......@@ -114,6 +115,26 @@ void swapQListWidgetItems(QListWidget* list, bool down = true);
// Byte to human readable size
QString humanFileSize(qint64 fileSize);
// Video widget change enum
enum class VideoWidgetSwapType
{
CallWidgetToSettingsWidgetPreview,
CallWidgetToSettingsWidgetPhotoBooth,
SettingsWidgetPreviewToCallWidget,
SettingsWidgetPhotoBoothToCallWidget,
SettingsWidgetPhotoBoothToSettingsWidgetPreview,
SettingsWidgetPreviewToSettingsWidgetPhotoBooth,
VideoInputDeviceConnectionLost
};
// device plug or unplug enum
enum class DevicePlugStatus
{
Plugged,
Unplugged,
Unchanged
};
template <typename Func1, typename Func2>
void
oneShotConnect(const typename QtPrivate::FunctionPointer<Func1>::Object* sender, Func1 signal, Func2 slot)
......
......@@ -133,6 +133,7 @@ VideoOverlay::on_hangupButton_clicked()
}
}
ui->chatButton->setChecked(false);
LRCInstance::avModel().switchInputTo("");
}
void
......
......@@ -271,7 +271,10 @@ VideoView::showContextMenu(const QPoint& pos)
}
connect(deviceAction, &QAction::triggered,
[this, deviceName, thisCallId]() {
LRCInstance::avModel().switchInputTo(deviceName.toStdString());
auto decive = deviceName.toStdString();
LRCInstance::avModel().switchInputTo(decive);
LRCInstance::avModel().setCurrentVideoCaptureDevice(decive);
ui->videoWidget->connectRendering();
});
}
......@@ -353,10 +356,6 @@ VideoView::pushRenderer(const std::string& callId, bool isSIP) {
auto call = callModel->getCall(callId);
if (call.isAudioOnly) {
return;
}
// transfer call will only happen in SIP calls
this->overlay_->setTransferCallAvailability(isSIP);
this->overlay_->callStarted(callId);
......@@ -449,3 +448,19 @@ VideoView::resetVideoOverlay(bool isAudioMuted, bool isVideoMuted, bool isRecord
emit overlay_->setChatVisibility(false);
overlay_->resetOverlay(isAudioMuted, isVideoMuted, isRecording, isHolding);
}
void
VideoView::disconnectRendering()
{
ui->videoWidget->disconnectRendering();
}
void
VideoView::connectRendering(bool started)
{
if (started) {
ui->videoWidget->slotRendererStarted();
} else {
ui->videoWidget->connectRendering();
}
}
......@@ -41,6 +41,8 @@ public:
void simulateShowChatview(bool checked);
void setCurrentCalleeName(const QString& CalleeDisplayName);
void resetVideoOverlay(bool isAudioMuted, bool isVideoMuted, bool isRecording, bool isHolding);
void disconnectRendering();
void connectRendering(bool started = false);
protected:
void resizeEvent(QResizeEvent* event);
......
......@@ -2,6 +2,7 @@
* Copyright (C) 2015-2019 by Savoir-faire Linux *
* Author: Edric Ladent Milaret <edric.ladent-milaret@savoirfairelinux.com>*
* Author: Andreas Traczyk <andreas.traczyk@savoirfairelinux.com> *
* Author: Mingrui Zhang <mingrui.zhang@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 *
......@@ -42,10 +43,6 @@ VideoWidget::slotRendererStarted(const std::string& id)
QObject::disconnect(rendererConnections_.started);
// only one videowidget will be used at the same time
if (not isVisible())
return;
this->show();
resetPreview_ = true;
......@@ -54,36 +51,15 @@ VideoWidget::slotRendererStarted(const std::string& id)
rendererConnections_.updated = connect(
&LRCInstance::avModel(),
&lrc::api::AVModel::frameUpdated,
[this](const std::string& id) {
auto avModel = &LRCInstance::avModel();
auto renderer = &avModel->getRenderer(id);
if (!renderer->isRendering()) {
return;
}
using namespace lrc::api::video;
if (id == PREVIEW_RENDERER_ID) {
previewRenderer_ = const_cast<Renderer*>(renderer);
} else {
distantRenderer_ = const_cast<Renderer*>(renderer);
}
renderFrame(id);
});
this,
&VideoWidget::slotUpdateFullView);
QObject::disconnect(rendererConnections_.stopped);
rendererConnections_.stopped = connect(
&LRCInstance::avModel(),
&lrc::api::AVModel::rendererStopped,
[this](const std::string& id) {
QObject::disconnect(rendererConnections_.updated);
QObject::disconnect(rendererConnections_.stopped);
using namespace lrc::api::video;
if (id == PREVIEW_RENDERER_ID) {
previewRenderer_ = nullptr;
} else {
distantRenderer_ = nullptr;
}
repaint();
});
this,
&VideoWidget::slotStopFullView);
}
void
......@@ -217,6 +193,17 @@ VideoWidget::connectRendering()
);
}
void
VideoWidget::connectPreviewOnlyRendering()
{
rendererConnections_.started = connect(
&LRCInstance::avModel(),
&lrc::api::AVModel::rendererStarted,
[this]() {
this->rendererStartedWithoutDistantRender();
});
}
void
VideoWidget::setPreviewDisplay(bool display)
{
......@@ -250,3 +237,82 @@ VideoWidget::setPhotoMode(bool isPhotoMode)
setAutoFillBackground(true);
setPalette(pal);
}
void
VideoWidget::disconnectRendering()
{
QObject::disconnect(rendererConnections_.started);
QObject::disconnect(rendererConnections_.stopped);
QObject::disconnect(rendererConnections_.updated);
}
void
VideoWidget::rendererStartedWithoutDistantRender()
{
// connect only local preview rendering
QObject::disconnect(rendererConnections_.started);
this->show();
resetPreview_ = true;
QObject::disconnect(rendererConnections_.updated);
rendererConnections_.updated = connect(
&LRCInstance::avModel(),
&lrc::api::AVModel::frameUpdated,
this,
&VideoWidget::slotUpdatePreview);
QObject::disconnect(rendererConnections_.stopped);
rendererConnections_.stopped = connect(
&LRCInstance::avModel(),
&lrc::api::AVModel::rendererStopped,
this,
&VideoWidget::slotStopFullView);
}
void
VideoWidget::slotUpdatePreview(const std::string& id)
{
auto avModel = &LRCInstance::avModel();
auto renderer = &avModel->getRenderer(id);
if (!renderer->isRendering()) {
return;
}
using namespace lrc::api::video;
if (id == PREVIEW_RENDERER_ID) {
previewRenderer_ = const_cast<Renderer*>(renderer);
renderFrame(id);
}
}
void
VideoWidget::slotUpdateFullView(const std::string& id)
{
auto avModel = &LRCInstance::avModel();
auto renderer = &avModel->getRenderer(id);
if (!renderer->isRendering()) {
return;
}
using namespace lrc::api::video;
if (id == PREVIEW_RENDERER_ID) {
previewRenderer_ = const_cast<Renderer*>(renderer);
} else {
distantRenderer_ = const_cast<Renderer*>(renderer);
}
renderFrame(id);
}
void
VideoWidget::slotStopFullView(const std::string& id)
{
QObject::disconnect(rendererConnections_.updated);
QObject::disconnect(rendererConnections_.stopped);