diff --git a/src/accountadapter.cpp b/src/accountadapter.cpp index 7ac854291a7d14e83489523e5a32c1dcfd2f519b..bb1bb7cfa62084d97a2b7c2d29850b0121b76be1 100644 --- a/src/accountadapter.cpp +++ b/src/accountadapter.cpp @@ -231,16 +231,16 @@ AccountAdapter::savePassword(const QString& accountId, } void -AccountAdapter::startPreviewing(bool force, bool async) +AccountAdapter::startPreviewing(bool force) { - LRCInstance::renderer()->startPreviewing(force, async); + LRCInstance::renderer()->startPreviewing(force); } void -AccountAdapter::stopPreviewing(bool async) +AccountAdapter::stopPreviewing() { if (!LRCInstance::hasVideoCall() && LRCInstance::renderer()->isPreviewing()) { - LRCInstance::renderer()->stopPreviewing(async); + LRCInstance::renderer()->stopPreviewing(); } } diff --git a/src/accountadapter.h b/src/accountadapter.h index cdcc7561709e3bfdf7b1b61ccb1799c24550636b..a6e55df427e1c0dc000505896a67ca3c78b50154 100644 --- a/src/accountadapter.h +++ b/src/accountadapter.h @@ -93,8 +93,8 @@ public: const QString& oldPassword, const QString& newPassword); - Q_INVOKABLE void startPreviewing(bool force = false, bool async = true); - Q_INVOKABLE void stopPreviewing(bool async = true); + Q_INVOKABLE void startPreviewing(bool force = false); + Q_INVOKABLE void stopPreviewing(); Q_INVOKABLE bool hasVideoCall(); Q_INVOKABLE bool isPreviewing(); Q_INVOKABLE void setCurrAccDisplayName(const QString& text); diff --git a/src/avadapter.cpp b/src/avadapter.cpp index b1cfb98838668f1ee966910d641b478fc66dffa2..d22aa1c8731a03e171e332f176abd9785e995588 100644 --- a/src/avadapter.cpp +++ b/src/avadapter.cpp @@ -1,4 +1,4 @@ -/* +/* * Copyright (C) 2020 by Savoir-faire Linux * Author : Edric Ladent Milaret<edric.ladent - milaret @savoirfairelinux.com> * Author : Andreas Traczyk<andreas.traczyk @savoirfairelinux.com> @@ -21,25 +21,25 @@ #include "avadapter.h" #include "lrcinstance.h" +#include "qtutils.h" +#include <QtConcurrent/QtConcurrent> #include <QApplication> #include <QScreen> AvAdapter::AvAdapter(QObject* parent) : QmlAdapterBase(parent) -{} +{ + auto& avModel = LRCInstance::avModel(); + + deviceListSize_ = avModel.getDevices().size(); + connect(&avModel, &lrc::api::AVModel::deviceEvent, this, &AvAdapter::slotDeviceEvent); +} QVariantMap AvAdapter::populateVideoDeviceContextMenuItem() { - auto* convModel = LRCInstance::getCurrentConversationModel(); - const auto conversation = convModel->getConversationForUID(LRCInstance::getCurrentConvUid()); - auto call = LRCInstance::getCallInfoForConversation(conversation); - if (!call) { - return QVariantMap(); - } - - auto activeDevice = LRCInstance::avModel().getCurrentRenderedDevice(call->id); + auto activeDevice = LRCInstance::avModel().getCurrentVideoCaptureDevice(); /* * Create a list of video input devices. @@ -49,7 +49,7 @@ AvAdapter::populateVideoDeviceContextMenuItem() for (int i = 0; i < devices.size(); i++) { try { auto settings = LRCInstance::avModel().getDeviceSettings(devices[i]); - deciveContextMenuNeededInfo[settings.name] = QVariant(devices[i] == activeDevice.name); + deciveContextMenuNeededInfo[settings.name] = QVariant(settings.id == activeDevice); } catch (...) { qDebug().noquote() << "Error in getting device settings"; } @@ -138,3 +138,66 @@ AvAdapter::stopAudioMeter(bool async) { LRCInstance::stopAudioMeter(async); } + +void +AvAdapter::slotDeviceEvent() +{ + auto& avModel = LRCInstance::avModel(); + auto defaultDevice = avModel.getDefaultDevice(); + auto currentCaptureDevice = avModel.getCurrentVideoCaptureDevice(); + QString callId {}; + + auto* convModel = LRCInstance::getCurrentConversationModel(); + const auto conversation = convModel->getConversationForUID(LRCInstance::getCurrentConvUid()); + auto call = LRCInstance::getCallInfoForConversation(conversation); + if (call) + callId = call->id; + + /* + * Decide whether a device has plugged, unplugged, or nothing has changed. + */ + auto deviceList = avModel.getDevices(); + auto currentDeviceListSize = deviceList.size(); + + DeviceEvent deviceEvent {DeviceEvent::None}; + if (currentDeviceListSize > deviceListSize_) { + deviceEvent = DeviceEvent::Added; + } else if (currentDeviceListSize < deviceListSize_) { + /* + * Check if the currentCaptureDevice is still in the device list. + */ + if (std::find(std::begin(deviceList), std::end(deviceList), currentCaptureDevice) + == std::end(deviceList)) { + deviceEvent = DeviceEvent::RemovedCurrent; + } + } + + auto cb = [this, currentDeviceListSize, deviceEvent, defaultDevice, callId] { + auto& avModel = LRCInstance::avModel(); + if (currentDeviceListSize == 0) { + avModel.clearCurrentVideoCaptureDevice(); + avModel.switchInputTo({}, callId); + avModel.stopPreview(); + } else if (deviceEvent == DeviceEvent::RemovedCurrent && currentDeviceListSize > 0) { + avModel.switchInputTo(defaultDevice, callId); + avModel.setCurrentVideoCaptureDevice(defaultDevice); + } + }; + + if (LRCInstance::renderer()->isPreviewing()) { + Utils::oneShotConnect(LRCInstance::renderer(), + &RenderManager::previewRenderingStopped, + [cb] { QtConcurrent::run([cb]() { cb(); }); }); + } else { + if (deviceEvent == DeviceEvent::Added && currentDeviceListSize == 1) { + avModel.switchInputTo(defaultDevice, callId); + avModel.setCurrentVideoCaptureDevice(defaultDevice); + } else { + cb(); + } + } + + emit videoDeviceListChanged(); + + deviceListSize_ = currentDeviceListSize; +} \ No newline at end of file diff --git a/src/avadapter.h b/src/avadapter.h index cd30f7a7443915443f0ed55b7ebd3d81fa011b0e..8c2c98a31e1df23d1830d3b4099803e04472ff77 100644 --- a/src/avadapter.h +++ b/src/avadapter.h @@ -32,6 +32,13 @@ public: explicit AvAdapter(QObject* parent = nullptr); ~AvAdapter() = default; +signals: + + /* + * Emitted when the size of the video capture device list changes. + */ + void videoDeviceListChanged(); + protected: void safeInit() override {}; @@ -67,4 +74,20 @@ protected: Q_INVOKABLE void startAudioMeter(bool async); Q_INVOKABLE void stopAudioMeter(bool async); + +private: + /* + * Used to classify capture device events. + */ + enum class DeviceEvent { Added, RemovedCurrent, None }; + + /* + * Used to track the capture device count. + */ + int deviceListSize_; + + /* + * Device changed slot. + */ + void slotDeviceEvent(); }; diff --git a/src/commoncomponents/PhotoboothView.qml b/src/commoncomponents/PhotoboothView.qml index 78b3d9c1fcf8eca80e7a950b7829cd589e0f71f5..1cff7b6feb38f56600d5c7a0524c54fb2adbfc2e 100644 --- a/src/commoncomponents/PhotoboothView.qml +++ b/src/commoncomponents/PhotoboothView.qml @@ -34,8 +34,8 @@ ColumnLayout { setAvatarImage(AvatarImage.Mode.Default, "") } - function startBooth(force = false) { - AccountAdapter.startPreviewing(force) + function startBooth() { + AccountAdapter.startPreviewing(false) photoState = PhotoboothView.PhotoState.CameraRendering } diff --git a/src/distantrenderer.cpp b/src/distantrenderer.cpp index 7e5b37519786ec3837a77919a5a7bf568c3a213a..14b7f6db4a9669292454b44f82f552a2f9488785 100644 --- a/src/distantrenderer.cpp +++ b/src/distantrenderer.cpp @@ -33,13 +33,6 @@ DistantRenderer::DistantRenderer(QQuickItem* parent) if (distantRenderId_ == id) update(QRect(0, 0, width(), height())); }); - - connect(LRCInstance::renderer(), - &RenderManager::distantRenderingStopped, - [this](const QString& id) { - if (distantRenderId_ == id) - update(QRect(0, 0, width(), height())); - }); } DistantRenderer::~DistantRenderer() {} @@ -48,7 +41,6 @@ void DistantRenderer::setRendererId(const QString& id) { distantRenderId_ = id; - update(QRect(0, 0, width(), height())); } int @@ -99,4 +91,4 @@ DistantRenderer::paint(QPainter* painter) painter->drawImage(QRect(xOffset_, yOffset_, scaledDistant.width(), scaledDistant.height()), scaledDistant); } -} \ No newline at end of file +} diff --git a/src/mainview/components/VideoCallPage.qml b/src/mainview/components/VideoCallPage.qml index a834c29ba56e6fe9a0b37c7bc05623545441dee4..4befacc2fb058f14269cb16a8f5fc88fc53257c4 100644 --- a/src/mainview/components/VideoCallPage.qml +++ b/src/mainview/components/VideoCallPage.qml @@ -235,12 +235,6 @@ Rectangle { VideoCallPreviewRenderer { id: previewRenderer - // Property is used in the {} expression for height (extra dependency), - // it will not affect the true height expression, since expression - // at last will be taken only, but it will force the height to update - // and reevaluate getPreviewImageScalingFactor(). - property int previewImageScalingFactorUpdated: 0 - Connections { target: CallAdapter @@ -250,10 +244,6 @@ Rectangle { } width: Math.max(videoCallPageMainRect.width / 5, JamiTheme.minimumPreviewWidth) - height: { - previewImageScalingFactorUpdated - return previewRenderer.width * previewRenderer.getPreviewImageScalingFactor() - } x: videoCallPageMainRect.width - previewRenderer.width - previewMargin y: videoCallPageMainRect.height - previewRenderer.height - previewMargin - 56 // Avoid overlay z: -1 @@ -313,9 +303,11 @@ Rectangle { } } - onPreviewImageAvailable: { - previewImageScalingFactorUpdated++ - previewImageScalingFactorUpdated-- + onWidthChanged: { + previewRenderer.height = previewRenderer.width * previewImageScalingFactor + } + onPreviewImageScalingFactorChanged: { + previewRenderer.height = previewRenderer.width * previewImageScalingFactor } } } diff --git a/src/previewrenderer.cpp b/src/previewrenderer.cpp index e966a20eeea4578f87874a84741218360f27222d..d935dcfc70863c05f43ca399c06bd2215815da55 100644 --- a/src/previewrenderer.cpp +++ b/src/previewrenderer.cpp @@ -32,15 +32,11 @@ PreviewRenderer::PreviewRenderer(QQuickItem* parent) previewFrameUpdatedConnection_ = connect(LRCInstance::renderer(), &RenderManager::previewFrameUpdated, [this]() { update(QRect(0, 0, width(), height())); }); - previewRenderingStopped_ = connect(LRCInstance::renderer(), - &RenderManager::previewRenderingStopped, - [this]() { update(QRect(0, 0, width(), height())); }); } PreviewRenderer::~PreviewRenderer() { disconnect(previewFrameUpdatedConnection_); - disconnect(previewRenderingStopped_); } void @@ -71,30 +67,20 @@ PreviewRenderer::paint(QPainter* painter) } VideoCallPreviewRenderer::VideoCallPreviewRenderer(QQuickItem* parent) - : PreviewRenderer(parent) -{} + : PreviewRenderer(parent) { + setProperty("previewImageScalingFactor", 1.0); +} VideoCallPreviewRenderer::~VideoCallPreviewRenderer() {} -qreal -VideoCallPreviewRenderer::getPreviewImageScalingFactor() -{ - auto previewImage = LRCInstance::renderer()->getPreviewFrame(); - if (previewImage) { - return static_cast<qreal>(previewImage->height()) - / static_cast<qreal>(previewImage->width()); - } - return 1.0; -} - void VideoCallPreviewRenderer::paint(QPainter* painter) { auto previewImage = LRCInstance::renderer()->getPreviewFrame(); - if (previewImage) { - emit previewImageAvailable(); - + auto scalingFactor = static_cast<qreal>(previewImage->height()) + / static_cast<qreal>(previewImage->width()); + setProperty("previewImageScalingFactor", scalingFactor); QImage scaledPreview; scaledPreview = previewImage->scaled(size().toSize(), Qt::KeepAspectRatio); painter->drawImage(QRect(0, 0, scaledPreview.width(), scaledPreview.height()), diff --git a/src/previewrenderer.h b/src/previewrenderer.h index 715121c3b1e308c7b95981241c9327c70993f2ea..1da8a38fdf48b93768520b2777faf927b16db0c7 100644 --- a/src/previewrenderer.h +++ b/src/previewrenderer.h @@ -37,23 +37,23 @@ protected: private: QMetaObject::Connection previewFrameUpdatedConnection_; - QMetaObject::Connection previewRenderingStopped_; }; class VideoCallPreviewRenderer : public PreviewRenderer { Q_OBJECT + Q_PROPERTY(qreal previewImageScalingFactor MEMBER previewImageScalingFactor_ + NOTIFY previewImageScalingFactorChanged) public: explicit VideoCallPreviewRenderer(QQuickItem* parent = 0); virtual ~VideoCallPreviewRenderer(); - Q_INVOKABLE qreal getPreviewImageScalingFactor(); - signals: - void previewImageAvailable(); + void previewImageScalingFactorChanged(); private: void paint(QPainter* painter) override final; + qreal previewImageScalingFactor_; }; class PhotoboothPreviewRender : public PreviewRenderer diff --git a/src/qmlregister.cpp b/src/qmlregister.cpp index 416bdc251821ced84c1e9941b781f968cc961f54..e1bea27c4bce762c8ab03dd14e091838b7d41176 100644 --- a/src/qmlregister.cpp +++ b/src/qmlregister.cpp @@ -137,7 +137,6 @@ registerTypes() QML_REGISTERSINGLETONTYPE_CUSTOM("net.jami.Models", AVModel, 1, 0, &LRCInstance::avModel()) QML_REGISTERSINGLETONTYPE_CUSTOM("net.jami.Models", PluginModel, 1, 0, &LRCInstance::pluginModel()) - QML_REGISTERSINGLETONTYPE_CUSTOM("net.jami.Models", RenderManager, 1, 0, LRCInstance::renderer()) QML_REGISTERSINGLETONTYPE_CUSTOM("net.jami.Helpers", UpdateManager, 1, 0, LRCInstance::getUpdateManager()) diff --git a/src/rendermanager.cpp b/src/rendermanager.cpp index 15fd25ed9f5a4a6bc997025fec49ffd0dd25c528..f29f9ae21bea7face6e65efd0e0818e71635d28d 100644 --- a/src/rendermanager.cpp +++ b/src/rendermanager.cpp @@ -19,8 +19,6 @@ #include "rendermanager.h" -#include <QtConcurrent/QtConcurrent> - #include <stdexcept> using namespace lrc::api; @@ -51,6 +49,9 @@ FrameWrapper::connectStartRendering() bool FrameWrapper::startRendering() { + if (isRendering()) + return true; + try { renderer_ = const_cast<video::Renderer*>(&avModel_.getRenderer(id_)); } catch (std::out_of_range& e) { @@ -69,15 +70,22 @@ FrameWrapper::startRendering() renderConnections_.stopped = QObject::connect(&avModel_, &AVModel::rendererStopped, this, - &FrameWrapper::slotRenderingStopped); + &FrameWrapper::slotRenderingStopped, + Qt::DirectConnection); return true; } +void +FrameWrapper::stopRendering() +{ + isRendering_ = false; +} + QImage* FrameWrapper::getFrame() { - return image_.get(); + return isRendering_ ? image_.get() : nullptr; } bool @@ -99,8 +107,6 @@ FrameWrapper::slotRenderingStarted(const QString& id) } isRendering_ = true; - - emit renderingStarted(id); } void @@ -140,7 +146,6 @@ FrameWrapper::slotFrameUpdated(const QString& id) #endif } } - emit frameUpdated(id); } @@ -150,37 +155,22 @@ FrameWrapper::slotRenderingStopped(const QString& id) if (id != id_) { return; } + isRendering_ = false; QObject::disconnect(renderConnections_.updated); - QObject::disconnect(renderConnections_.stopped); + renderer_ = nullptr; - /* - * The object's QImage pointer is reset before renderingStopped - * is emitted, allowing the listener to invoke specific behavior - * like clearing the widget or changing the UI entirely. - */ image_.reset(); - isRendering_ = false; - emit renderingStopped(id); } RenderManager::RenderManager(AVModel& avModel) : avModel_(avModel) { - deviceListSize_ = avModel_.getDevices().size(); - connect(&avModel_, &lrc::api::AVModel::deviceEvent, this, &RenderManager::slotDeviceEvent); - previewFrameWrapper_ = std::make_unique<FrameWrapper>(avModel_); - QObject::connect(previewFrameWrapper_.get(), - &FrameWrapper::renderingStarted, - [this](const QString& id) { - Q_UNUSED(id); - emit previewRenderingStarted(); - }); QObject::connect(previewFrameWrapper_.get(), &FrameWrapper::frameUpdated, [this](const QString& id) { @@ -219,37 +209,27 @@ RenderManager::getPreviewFrame() } void -RenderManager::stopPreviewing(bool async) +RenderManager::stopPreviewing() { if (!previewFrameWrapper_->isRendering()) { return; } - if (async) { - QtConcurrent::run([this] { avModel_.stopPreview(); }); - } else { - avModel_.stopPreview(); - } + previewFrameWrapper_->stopRendering(); + avModel_.stopPreview(); } void -RenderManager::startPreviewing(bool force, bool async) +RenderManager::startPreviewing(bool force) { if (previewFrameWrapper_->isRendering() && !force) { return; } - auto restart = [this] { - if (previewFrameWrapper_->isRendering()) { - avModel_.stopPreview(); - } - avModel_.startPreview(); - }; - if (async) { - QtConcurrent::run(restart); - } else { - restart(); + if (previewFrameWrapper_->isRendering()) { + avModel_.stopPreview(); } + avModel_.startPreview(); } QImage* @@ -279,21 +259,11 @@ RenderManager::addDistantRenderer(const QString& id) /* * Connect this to the FrameWrapper. */ - distantConnectionMap_[id].started = QObject::connect(dfw.get(), - &FrameWrapper::renderingStarted, - [this](const QString& id) { - emit distantRenderingStarted(id); - }); distantConnectionMap_[id].updated = QObject::connect(dfw.get(), &FrameWrapper::frameUpdated, [this](const QString& id) { emit distantFrameUpdated(id); }); - distantConnectionMap_[id].stopped = QObject::connect(dfw.get(), - &FrameWrapper::renderingStopped, - [this](const QString& id) { - emit distantRenderingStopped(id); - }); /* * Connect FrameWrapper to avmodel. @@ -319,7 +289,6 @@ RenderManager::removeDistantRenderer(const QString& id) if (dcIt != distantConnectionMap_.end()) { QObject::disconnect(dcIt->second.started); QObject::disconnect(dcIt->second.updated); - QObject::disconnect(dcIt->second.stopped); } /* @@ -327,48 +296,4 @@ RenderManager::removeDistantRenderer(const QString& id) */ distantFrameWrapperMap_.erase(dfwIt); } -} - -void -RenderManager::slotDeviceEvent() -{ - auto defaultDevice = avModel_.getDefaultDevice(); - auto currentCaptureDevice = avModel_.getCurrentVideoCaptureDevice(); - /* - * Decide whether a device has plugged, unplugged, or nothing has changed. - */ - auto deviceList = avModel_.getDevices(); - auto currentDeviceListSize = deviceList.size(); - - DeviceEvent deviceEvent {DeviceEvent::None}; - if (currentDeviceListSize > deviceListSize_) { - deviceEvent = DeviceEvent::Added; - } else if (currentDeviceListSize < deviceListSize_) { - /* - * Check if the currentCaptureDevice is still in the device list. - */ - if (std::find(std::begin(deviceList), std::end(deviceList), currentCaptureDevice) - == std::end(deviceList)) { - deviceEvent = DeviceEvent::RemovedCurrent; - } - } - - if (previewFrameWrapper_->isRendering()) { - if (currentDeviceListSize == 0) { - avModel_.clearCurrentVideoCaptureDevice(); - avModel_.switchInputTo({}); - stopPreviewing(); - } else if (deviceEvent == DeviceEvent::RemovedCurrent && currentDeviceListSize > 0) { - avModel_.setCurrentVideoCaptureDevice(defaultDevice); - startPreviewing(true); - } else { - startPreviewing(); - } - } else if (deviceEvent == DeviceEvent::Added && currentDeviceListSize == 1) { - avModel_.setCurrentVideoCaptureDevice(defaultDevice); - } - - emit videoDeviceListChanged(); - - deviceListSize_ = currentDeviceListSize; -} +} \ No newline at end of file diff --git a/src/rendermanager.h b/src/rendermanager.h index 6ea24cb5d9b3b3499fb19fa74bf5d9a74c53472c..b9ce21634aab5cf7b73389931351b32f1b0b5b75 100644 --- a/src/rendermanager.h +++ b/src/rendermanager.h @@ -61,6 +61,11 @@ public: */ bool startRendering(); + /* + * Locally disable frame access to this FrameWrapper + */ + void stopRendering(); + /* * Get the most recently rendered frame as a QImage. * @return the rendered image of this object's id @@ -73,11 +78,6 @@ public: bool isRendering(); signals: - /* - * Emitted once in slotRenderingStarted. - * @param id of the renderer - */ - void renderingStarted(const QString& id); /* * Emitted each time a frame is ready to be displayed. * @param id of the renderer @@ -180,14 +180,12 @@ public: /* * Start capturing and rendering preview frames. * @param force if the capture device should be started - * @param async */ - void startPreviewing(bool force = false, bool async = true); + void startPreviewing(bool force = false); /* * Stop capturing. - * @param async */ - void stopPreviewing(bool async = true); + void stopPreviewing(); /* * Get the most recently rendered distant frame for a given id @@ -209,15 +207,6 @@ public: void removeDistantRenderer(const QString& id); signals: - /* - * Emitted when the size of the video capture device list changes. - */ - void videoDeviceListChanged(); - - /* - * Emitted when the preview is started. - */ - void previewRenderingStarted(); /* * Emitted when the preview has a new frame ready. @@ -229,11 +218,6 @@ signals: */ void previewRenderingStopped(); - /* - * Emitted when a distant renderer is started for a given id. - */ - void distantRenderingStarted(const QString& id); - /* * Emitted when a distant renderer has a new frame ready for a given id. */ @@ -244,23 +228,7 @@ signals: */ void distantRenderingStopped(const QString& id); -private slots: - /* - * Used to listen to AVModel::deviceEvent. - */ - void slotDeviceEvent(); - private: - /* - * Used to classify capture device events. - */ - enum class DeviceEvent { Added, RemovedCurrent, None }; - - /* - * Used to track the capture device count. - */ - int deviceListSize_; - /* * One preview frame. */ @@ -277,4 +245,3 @@ private: */ AVModel& avModel_; }; -Q_DECLARE_METATYPE(RenderManager*) diff --git a/src/settingsview/SettingsView.qml b/src/settingsview/SettingsView.qml index 8b74653d29f33396c7f3324271fd2948e3b1ba49..e013f27b5dedcdd801216ace243ec78a7c0a1bda 100644 --- a/src/settingsview/SettingsView.qml +++ b/src/settingsview/SettingsView.qml @@ -41,6 +41,8 @@ Rectangle { onVisibleChanged: { if(visible){ setSelected(selectedMenu,true) + } else { + AccountAdapter.stopPreviewing() } } @@ -51,21 +53,20 @@ Rectangle { switch(sel) { case SettingsView.Account: pageIdCurrentAccountSettings.connectCurrentAccount() - settingsViewRect.stopPreviewing() + AccountAdapter.stopPreviewing() selectedMenu = sel pageIdCurrentAccountSettings.updateAccountInfoDisplayed() break case SettingsView.General: - settingsViewRect.stopPreviewing() + AccountAdapter.stopPreviewing() selectedMenu = sel break case SettingsView.Media: selectedMenu = sel - settingsViewRect.stopPreviewing() avSettings.populateAVSettings() break case SettingsView.Plugin: - settingsViewRect.stopPreviewing() + AccountAdapter.stopPreviewing() selectedMenu = sel pluginSettings.populatePluginSettings() break @@ -83,7 +84,7 @@ Rectangle { // slots function leaveSettingsSlot(showMainView) { - settingsViewRect.stopPreviewing() + AccountAdapter.stopPreviewing() settingsViewRect.stopBooth() if (showMainView) settingsViewWindowNeedToShowMainViewWindow() @@ -118,7 +119,6 @@ Rectangle { anchors.fill: root color: JamiTheme.secondaryBackgroundColor - signal stopPreviewing signal stopBooth property bool isSIP: { diff --git a/src/settingsview/components/AvSettingPage.qml b/src/settingsview/components/AvSettingPage.qml index fcddecbdf1e9e692c8ff594e5505f711881450d7..fa5e692c47dcd108c7c64ea6db6562b0b4bf76fa 100644 --- a/src/settingsview/components/AvSettingPage.qml +++ b/src/settingsview/components/AvSettingPage.qml @@ -35,12 +35,6 @@ Rectangle { property int contentWidth: avSettingsColumnLayout.width property int preferredHeight: avSettingsColumnLayout.implicitHeight - onVisibleChanged: { - if (!visible) { - videoSettings.stopPreviewing() - } - } - function populateAVSettings() { audioSettings.populateAudioSettings() videoSettings.populateVideoSettings() diff --git a/src/settingsview/components/SettingsComboBox.qml b/src/settingsview/components/SettingsComboBox.qml index bfc37e1d0569f1fbe829b0217090d6c25d956c57..5fc1a1a6a433925e007660da76a6ef6e3f44b4d7 100644 --- a/src/settingsview/components/SettingsComboBox.qml +++ b/src/settingsview/components/SettingsComboBox.qml @@ -41,9 +41,11 @@ RowLayout { signal indexChanged - function setCurrentIndex(index) { + function setCurrentIndex(index, emitIndexChanged = false) { comboBoxOfLayout.currentIndex = index modelIndex = index + if (emitIndexChanged) + indexChanged() } function setEnabled(status) { diff --git a/src/settingsview/components/VideoSettings.qml b/src/settingsview/components/VideoSettings.qml index 1840d1adbb4b5174a0b98272d1a821797228856e..16f43360a0b128d3aa3d6cb6e4f2735481087e00 100644 --- a/src/settingsview/components/VideoSettings.qml +++ b/src/settingsview/components/VideoSettings.qml @@ -38,7 +38,7 @@ ColumnLayout { property int itemWidth Connections { - target: RenderManager + target: AvAdapter enabled: root.visible function onVideoDeviceListChanged() { @@ -54,13 +54,9 @@ ColumnLayout { resolutionComboBoxSetting.setEnabled(count) fpsComboBoxSetting.setEnabled(count) - deviceComboBoxSetting.setCurrentIndex(deviceComboBoxSetting.comboModel.getCurrentSettingIndex()) - slotDeviceBoxCurrentIndexChanged(deviceComboBoxSetting.modelIndex) + deviceComboBoxSetting.setCurrentIndex( + deviceComboBoxSetting.comboModel.getCurrentSettingIndex(), true) hardwareAccelControl.checked = AVModel.getHardwareAcceleration() - - try { - startPreviewing(false) - } catch (err2){ console.log("Start preview fail when populate video settings, exception: "+ err2.message) } } function slotDeviceBoxCurrentIndexChanged(index) { @@ -78,12 +74,12 @@ ColumnLayout { AVModel.setCurrentVideoCaptureDevice(deviceId) AVModel.setDefaultDevice(deviceId) setFormatListForCurrentDevice() - startPreviewing(true) + startPreviewing() } catch(err){ console.warn(err.message) } } - function startPreviewing(force = false, async = true) { - AccountAdapter.startPreviewing(force, async) + function startPreviewing(force = false) { + AccountAdapter.startPreviewing(force) previewAvailable = true } @@ -94,15 +90,11 @@ ColumnLayout { try { resolutionComboBoxSetting.comboModel.reset() - resolutionComboBoxSetting.setCurrentIndex(resolutionComboBoxSetting.comboModel.getCurrentSettingIndex()) - slotFormatCurrentIndexChanged(resolutionComboBoxSetting.modelIndex, true) + resolutionComboBoxSetting.setCurrentIndex( + resolutionComboBoxSetting.comboModel.getCurrentSettingIndex(), true) } catch(err){ console.warn("Exception: " + err.message) } } - function stopPreviewing(async = true) { - AccountAdapter.stopPreviewing(async) - } - function slotFormatCurrentIndexChanged(index, isResolutionIndex) { var resolution var rate @@ -111,7 +103,8 @@ ColumnLayout { resolutionComboBoxSetting.comboModel.index(index, 0), VideoFormatResolutionModel.Resolution) fpsComboBoxSetting.comboModel.currentResolution = resolution - fpsComboBoxSetting.setCurrentIndex(fpsComboBoxSetting.comboModel.getCurrentSettingIndex()) + fpsComboBoxSetting.setCurrentIndex( + fpsComboBoxSetting.comboModel.getCurrentSettingIndex(), true) rate = fpsComboBoxSetting.comboModel.data( fpsComboBoxSetting.comboModel.index(0, 0), VideoFormatFpsModel.FPS) @@ -221,7 +214,7 @@ ColumnLayout { onSwitchToggled: { AVModel.setHardwareAcceleration(checked) - videoSettings.startPreviewing(true) + startPreviewing(true) } } diff --git a/src/utilsadapter.cpp b/src/utilsadapter.cpp index c0f7e9887c57bfa44d36abb1a06629a592c879bb..b25130e082bb728512c4118e63dcffca20f8480f 100644 --- a/src/utilsadapter.cpp +++ b/src/utilsadapter.cpp @@ -201,26 +201,6 @@ UtilsAdapter::setCurrentCall(const QString& accountId, const QString& convUid) accInfo.callModel->setCurrentCall(convInfo.callId); } -void -UtilsAdapter::startPreviewing(bool force) -{ - LRCInstance::renderer()->startPreviewing(force); -} - -void -UtilsAdapter::stopPreviewing() -{ - if (!LRCInstance::hasVideoCall()) { - LRCInstance::renderer()->stopPreviewing(); - } -} - -bool -UtilsAdapter::hasVideoCall() -{ - return LRCInstance::hasVideoCall(); -} - bool UtilsAdapter::hasCall(const QString& accountId) { diff --git a/src/utilsadapter.h b/src/utilsadapter.h index 764cc4f6dde5166ee76f367741fe38c58fd8c1a6..a0442204ce7ceef66a9108c1481861cacccabddc 100644 --- a/src/utilsadapter.h +++ b/src/utilsadapter.h @@ -58,9 +58,6 @@ public: Q_INVOKABLE const QStringList getCurrAccList(); Q_INVOKABLE int getAccountListSize(); Q_INVOKABLE void setCurrentCall(const QString& accountId, const QString& convUid); - Q_INVOKABLE void startPreviewing(bool force); - Q_INVOKABLE void stopPreviewing(); - Q_INVOKABLE bool hasVideoCall(); Q_INVOKABLE bool hasCall(const QString& accountId); Q_INVOKABLE const QString getCallConvForAccount(const QString& accountId); Q_INVOKABLE const QString getCallId(const QString& accountId, const QString& convUid);