From 9f3115d3da2f9eba751af12096aed48d32dddcdc Mon Sep 17 00:00:00 2001 From: Julien Wadel Date: Fri, 1 Jul 2022 15:38:19 +0200 Subject: [PATCH] Add options to set camera modes for mosaic/gric/calls. Change waiting room design to fit camera preview size. Fix avatar sizes. Fix preview size to be 16/9 and below main view in call. --- linphone-app/assets/languages/da.ts | 25 ++++- linphone-app/assets/languages/de.ts | 25 ++++- linphone-app/assets/languages/en.ts | 25 ++++- linphone-app/assets/languages/es.ts | 25 ++++- linphone-app/assets/languages/fr_FR.ts | 25 ++++- linphone-app/assets/languages/hu.ts | 25 ++++- linphone-app/assets/languages/it.ts | 25 ++++- linphone-app/assets/languages/ja.ts | 25 ++++- linphone-app/assets/languages/lt.ts | 25 ++++- linphone-app/assets/languages/pt_BR.ts | 25 ++++- linphone-app/assets/languages/ru.ts | 25 ++++- linphone-app/assets/languages/sv.ts | 25 ++++- linphone-app/assets/languages/tr.ts | 25 ++++- linphone-app/assets/languages/uk.ts | 25 ++++- linphone-app/assets/languages/zh_CN.ts | 25 ++++- .../src/components/call/CallModel.cpp | 33 ++++++- linphone-app/src/components/camera/Camera.cpp | 19 ++++ linphone-app/src/components/camera/Camera.hpp | 6 ++ .../src/components/settings/SettingsModel.cpp | 52 +++++++++- .../src/components/settings/SettingsModel.hpp | 19 +++- .../Common/Form/Placements/FormGroup.qml | 3 + .../Common/Form/Placements/FormHGroup.qml | 6 +- .../Common/Form/Placements/FormLine.qml | 3 +- .../Common/Form/Placements/FormVGroup.qml | 1 + .../ui/modules/Linphone/Camera/CameraItem.qml | 3 + .../ui/modules/Linphone/Camera/CameraView.qml | 2 + linphone-app/ui/scripts/Utils/utils.js | 3 +- linphone-app/ui/views/App/Calls/Incall.qml | 4 +- .../ui/views/App/Calls/WaitingRoom.qml | 53 +++++----- .../ui/views/App/Settings/SettingsVideo.qml | 99 +++++++++++++++---- 30 files changed, 548 insertions(+), 133 deletions(-) diff --git a/linphone-app/assets/languages/da.ts b/linphone-app/assets/languages/da.ts index cf41d4eaa..796b11d4d 100644 --- a/linphone-app/assets/languages/da.ts +++ b/linphone-app/assets/languages/da.ts @@ -3035,11 +3035,6 @@ Klik her: <a href="%1">%1</a> 'Video display' : Title for display parameters - - videoModeLabel - 'Camera mode' : Label to choose a camera mode. - - videoHybrid 'Hybrid' : Hybrid mode for camera. @@ -3070,6 +3065,26 @@ Klik her: <a href="%1">%1</a> 'Mosaic' : Mosaic layout invideo conference. + + videoGridModeLabel + 'Mosaic' : Label to choose a camera mode. + + + + videoActiveSpeakerModeLabel + 'Active speaker' : Label to choose a camera mode. + + + + videoCallsModeLabel + 'Calls' : Label to choose a camera mode. + + + + videoModeLabel + 'Camera modes' : Label to choose a camera modes. + + SettingsVideoPreview diff --git a/linphone-app/assets/languages/de.ts b/linphone-app/assets/languages/de.ts index 93c4c827d..3e85adaa0 100644 --- a/linphone-app/assets/languages/de.ts +++ b/linphone-app/assets/languages/de.ts @@ -3035,11 +3035,6 @@ Klicken Sie hier: <a href="%1">%1</a> 'Video display' : Title for display parameters - - videoModeLabel - 'Camera mode' : Label to choose a camera mode. - - videoHybrid 'Hybrid' : Hybrid mode for camera. @@ -3070,6 +3065,26 @@ Klicken Sie hier: <a href="%1">%1</a> 'Mosaic' : Mosaic layout invideo conference. + + videoGridModeLabel + 'Mosaic' : Label to choose a camera mode. + + + + videoActiveSpeakerModeLabel + 'Active speaker' : Label to choose a camera mode. + + + + videoCallsModeLabel + 'Calls' : Label to choose a camera mode. + + + + videoModeLabel + 'Camera modes' : Label to choose a camera modes. + + SettingsVideoPreview diff --git a/linphone-app/assets/languages/en.ts b/linphone-app/assets/languages/en.ts index e86d74ed4..729dd55dc 100644 --- a/linphone-app/assets/languages/en.ts +++ b/linphone-app/assets/languages/en.ts @@ -3058,11 +3058,6 @@ Click here: <a href="%1">%1</a> 'Video display' : Title for display parameters Video display - - videoModeLabel - 'Camera mode' : Label to choose a camera mode. - Camera mode - videoHybrid 'Hybrid' : Hybrid mode for camera. @@ -3093,6 +3088,26 @@ Click here: <a href="%1">%1</a> 'Mosaic' : Mosaic layout invideo conference. Mosaic + + videoGridModeLabel + 'Mosaic' : Label to choose a camera mode. + Mosaic + + + videoActiveSpeakerModeLabel + 'Active speaker' : Label to choose a camera mode. + Active speaker + + + videoCallsModeLabel + 'Calls' : Label to choose a camera mode. + Calls + + + videoModeLabel + 'Camera modes' : Label to choose a camera modes. + Camera modes + SettingsVideoPreview diff --git a/linphone-app/assets/languages/es.ts b/linphone-app/assets/languages/es.ts index 186358154..a56c55431 100644 --- a/linphone-app/assets/languages/es.ts +++ b/linphone-app/assets/languages/es.ts @@ -3035,11 +3035,6 @@ Haga clic aquí: <a href="%1">%1 </a> 'Video display' : Title for display parameters - - videoModeLabel - 'Camera mode' : Label to choose a camera mode. - - videoHybrid 'Hybrid' : Hybrid mode for camera. @@ -3070,6 +3065,26 @@ Haga clic aquí: <a href="%1">%1 </a> 'Mosaic' : Mosaic layout invideo conference. + + videoGridModeLabel + 'Mosaic' : Label to choose a camera mode. + + + + videoActiveSpeakerModeLabel + 'Active speaker' : Label to choose a camera mode. + + + + videoCallsModeLabel + 'Calls' : Label to choose a camera mode. + + + + videoModeLabel + 'Camera modes' : Label to choose a camera modes. + + SettingsVideoPreview diff --git a/linphone-app/assets/languages/fr_FR.ts b/linphone-app/assets/languages/fr_FR.ts index 7c58bb4b2..71f32154c 100644 --- a/linphone-app/assets/languages/fr_FR.ts +++ b/linphone-app/assets/languages/fr_FR.ts @@ -3035,11 +3035,6 @@ Cliquez ici : <a href="%1">%1</a> 'Video display' : Title for display parameters - - videoModeLabel - 'Camera mode' : Label to choose a camera mode. - - videoHybrid 'Hybrid' : Hybrid mode for camera. @@ -3070,6 +3065,26 @@ Cliquez ici : <a href="%1">%1</a> 'Mosaic' : Mosaic layout invideo conference. + + videoGridModeLabel + 'Mosaic' : Label to choose a camera mode. + + + + videoActiveSpeakerModeLabel + 'Active speaker' : Label to choose a camera mode. + + + + videoCallsModeLabel + 'Calls' : Label to choose a camera mode. + + + + videoModeLabel + 'Camera modes' : Label to choose a camera modes. + + SettingsVideoPreview diff --git a/linphone-app/assets/languages/hu.ts b/linphone-app/assets/languages/hu.ts index c1a7cc6ec..8b29c78ca 100644 --- a/linphone-app/assets/languages/hu.ts +++ b/linphone-app/assets/languages/hu.ts @@ -3022,11 +3022,6 @@ Kattintson ide: <a href="%1">%1</a> 'Video display' : Title for display parameters - - videoModeLabel - 'Camera mode' : Label to choose a camera mode. - - videoHybrid 'Hybrid' : Hybrid mode for camera. @@ -3057,6 +3052,26 @@ Kattintson ide: <a href="%1">%1</a> 'Mosaic' : Mosaic layout invideo conference. + + videoGridModeLabel + 'Mosaic' : Label to choose a camera mode. + + + + videoActiveSpeakerModeLabel + 'Active speaker' : Label to choose a camera mode. + + + + videoCallsModeLabel + 'Calls' : Label to choose a camera mode. + + + + videoModeLabel + 'Camera modes' : Label to choose a camera modes. + + SettingsVideoPreview diff --git a/linphone-app/assets/languages/it.ts b/linphone-app/assets/languages/it.ts index 51a9fffba..2b690df55 100644 --- a/linphone-app/assets/languages/it.ts +++ b/linphone-app/assets/languages/it.ts @@ -3035,11 +3035,6 @@ Clicca: <a href="%1">%1</a> 'Video display' : Title for display parameters - - videoModeLabel - 'Camera mode' : Label to choose a camera mode. - - videoHybrid 'Hybrid' : Hybrid mode for camera. @@ -3070,6 +3065,26 @@ Clicca: <a href="%1">%1</a> 'Mosaic' : Mosaic layout invideo conference. + + videoGridModeLabel + 'Mosaic' : Label to choose a camera mode. + + + + videoActiveSpeakerModeLabel + 'Active speaker' : Label to choose a camera mode. + + + + videoCallsModeLabel + 'Calls' : Label to choose a camera mode. + + + + videoModeLabel + 'Camera modes' : Label to choose a camera modes. + + SettingsVideoPreview diff --git a/linphone-app/assets/languages/ja.ts b/linphone-app/assets/languages/ja.ts index ceeb02cc4..8ff96c59c 100644 --- a/linphone-app/assets/languages/ja.ts +++ b/linphone-app/assets/languages/ja.ts @@ -3022,11 +3022,6 @@ 'Video display' : Title for display parameters - - videoModeLabel - 'Camera mode' : Label to choose a camera mode. - - videoHybrid 'Hybrid' : Hybrid mode for camera. @@ -3057,6 +3052,26 @@ 'Mosaic' : Mosaic layout invideo conference. + + videoGridModeLabel + 'Mosaic' : Label to choose a camera mode. + + + + videoActiveSpeakerModeLabel + 'Active speaker' : Label to choose a camera mode. + + + + videoCallsModeLabel + 'Calls' : Label to choose a camera mode. + + + + videoModeLabel + 'Camera modes' : Label to choose a camera modes. + + SettingsVideoPreview diff --git a/linphone-app/assets/languages/lt.ts b/linphone-app/assets/languages/lt.ts index 0f5139afb..ae30684a2 100644 --- a/linphone-app/assets/languages/lt.ts +++ b/linphone-app/assets/languages/lt.ts @@ -3048,11 +3048,6 @@ Spustelėkite čia: <a href="%1">%1</a> 'Video display' : Title for display parameters - - videoModeLabel - 'Camera mode' : Label to choose a camera mode. - - videoHybrid 'Hybrid' : Hybrid mode for camera. @@ -3083,6 +3078,26 @@ Spustelėkite čia: <a href="%1">%1</a> 'Mosaic' : Mosaic layout invideo conference. + + videoGridModeLabel + 'Mosaic' : Label to choose a camera mode. + + + + videoActiveSpeakerModeLabel + 'Active speaker' : Label to choose a camera mode. + + + + videoCallsModeLabel + 'Calls' : Label to choose a camera mode. + + + + videoModeLabel + 'Camera modes' : Label to choose a camera modes. + + SettingsVideoPreview diff --git a/linphone-app/assets/languages/pt_BR.ts b/linphone-app/assets/languages/pt_BR.ts index 2d425b931..84b34e2b4 100644 --- a/linphone-app/assets/languages/pt_BR.ts +++ b/linphone-app/assets/languages/pt_BR.ts @@ -3035,11 +3035,6 @@ Clique aqui: <a href="%1">%1 </a> 'Video display' : Title for display parameters - - videoModeLabel - 'Camera mode' : Label to choose a camera mode. - - videoHybrid 'Hybrid' : Hybrid mode for camera. @@ -3070,6 +3065,26 @@ Clique aqui: <a href="%1">%1 </a> 'Mosaic' : Mosaic layout invideo conference. + + videoGridModeLabel + 'Mosaic' : Label to choose a camera mode. + + + + videoActiveSpeakerModeLabel + 'Active speaker' : Label to choose a camera mode. + + + + videoCallsModeLabel + 'Calls' : Label to choose a camera mode. + + + + videoModeLabel + 'Camera modes' : Label to choose a camera modes. + + SettingsVideoPreview diff --git a/linphone-app/assets/languages/ru.ts b/linphone-app/assets/languages/ru.ts index aad7e64bf..411beb73d 100644 --- a/linphone-app/assets/languages/ru.ts +++ b/linphone-app/assets/languages/ru.ts @@ -3048,11 +3048,6 @@ 'Video display' : Title for display parameters - - videoModeLabel - 'Camera mode' : Label to choose a camera mode. - - videoHybrid 'Hybrid' : Hybrid mode for camera. @@ -3083,6 +3078,26 @@ 'Mosaic' : Mosaic layout invideo conference. + + videoGridModeLabel + 'Mosaic' : Label to choose a camera mode. + + + + videoActiveSpeakerModeLabel + 'Active speaker' : Label to choose a camera mode. + + + + videoCallsModeLabel + 'Calls' : Label to choose a camera mode. + + + + videoModeLabel + 'Camera modes' : Label to choose a camera modes. + + SettingsVideoPreview diff --git a/linphone-app/assets/languages/sv.ts b/linphone-app/assets/languages/sv.ts index 39214bfef..b393dd527 100644 --- a/linphone-app/assets/languages/sv.ts +++ b/linphone-app/assets/languages/sv.ts @@ -3035,11 +3035,6 @@ Klicka här: <a href="%1">%1</a> 'Video display' : Title for display parameters - - videoModeLabel - 'Camera mode' : Label to choose a camera mode. - - videoHybrid 'Hybrid' : Hybrid mode for camera. @@ -3070,6 +3065,26 @@ Klicka här: <a href="%1">%1</a> 'Mosaic' : Mosaic layout invideo conference. + + videoGridModeLabel + 'Mosaic' : Label to choose a camera mode. + + + + videoActiveSpeakerModeLabel + 'Active speaker' : Label to choose a camera mode. + + + + videoCallsModeLabel + 'Calls' : Label to choose a camera mode. + + + + videoModeLabel + 'Camera modes' : Label to choose a camera modes. + + SettingsVideoPreview diff --git a/linphone-app/assets/languages/tr.ts b/linphone-app/assets/languages/tr.ts index 4dfee474a..7da41a04c 100644 --- a/linphone-app/assets/languages/tr.ts +++ b/linphone-app/assets/languages/tr.ts @@ -3022,11 +3022,6 @@ Buraya tıklayın: <a href="%1">%1</a> 'Video display' : Title for display parameters - - videoModeLabel - 'Camera mode' : Label to choose a camera mode. - - videoHybrid 'Hybrid' : Hybrid mode for camera. @@ -3057,6 +3052,26 @@ Buraya tıklayın: <a href="%1">%1</a> 'Mosaic' : Mosaic layout invideo conference. + + videoGridModeLabel + 'Mosaic' : Label to choose a camera mode. + + + + videoActiveSpeakerModeLabel + 'Active speaker' : Label to choose a camera mode. + + + + videoCallsModeLabel + 'Calls' : Label to choose a camera mode. + + + + videoModeLabel + 'Camera modes' : Label to choose a camera modes. + + SettingsVideoPreview diff --git a/linphone-app/assets/languages/uk.ts b/linphone-app/assets/languages/uk.ts index 0df39ecdd..2977671a3 100644 --- a/linphone-app/assets/languages/uk.ts +++ b/linphone-app/assets/languages/uk.ts @@ -3048,11 +3048,6 @@ 'Video display' : Title for display parameters - - videoModeLabel - 'Camera mode' : Label to choose a camera mode. - - videoHybrid 'Hybrid' : Hybrid mode for camera. @@ -3083,6 +3078,26 @@ 'Mosaic' : Mosaic layout invideo conference. + + videoGridModeLabel + 'Mosaic' : Label to choose a camera mode. + + + + videoActiveSpeakerModeLabel + 'Active speaker' : Label to choose a camera mode. + + + + videoCallsModeLabel + 'Calls' : Label to choose a camera mode. + + + + videoModeLabel + 'Camera modes' : Label to choose a camera modes. + + SettingsVideoPreview diff --git a/linphone-app/assets/languages/zh_CN.ts b/linphone-app/assets/languages/zh_CN.ts index 82a1dca38..c3f9f1be6 100644 --- a/linphone-app/assets/languages/zh_CN.ts +++ b/linphone-app/assets/languages/zh_CN.ts @@ -3022,11 +3022,6 @@ 'Video display' : Title for display parameters - - videoModeLabel - 'Camera mode' : Label to choose a camera mode. - - videoHybrid 'Hybrid' : Hybrid mode for camera. @@ -3057,6 +3052,26 @@ 'Mosaic' : Mosaic layout invideo conference. + + videoGridModeLabel + 'Mosaic' : Label to choose a camera mode. + + + + videoActiveSpeakerModeLabel + 'Active speaker' : Label to choose a camera mode. + + + + videoCallsModeLabel + 'Calls' : Label to choose a camera mode. + + + + videoModeLabel + 'Camera modes' : Label to choose a camera modes. + + SettingsVideoPreview diff --git a/linphone-app/src/components/call/CallModel.cpp b/linphone-app/src/components/call/CallModel.cpp index fcbc6f536..f6e7b79ef 100644 --- a/linphone-app/src/components/call/CallModel.cpp +++ b/linphone-app/src/components/call/CallModel.cpp @@ -51,18 +51,28 @@ constexpr char AutoAnswerObjectName[] = "auto-answer-timer"; } CallModel::CallModel (shared_ptr call){ + CoreManager *coreManager = CoreManager::getInstance(); + SettingsModel *settings = coreManager->getSettingsModel(); + connect(this, &CallModel::callIdChanged, this, &CallModel::chatRoomModelChanged);// When the call Id change, the chat room change. mCall = call; if(mCall) mCall->setData("call-model", *this); updateIsInConference(); - mConferenceVideoLayout = LinphoneEnums::fromLinphone(call->getParams()->getConferenceVideoLayout()); - - CoreManager *coreManager = CoreManager::getInstance(); + if(mCall) { + mConferenceVideoLayout = LinphoneEnums::fromLinphone(mCall->getParams()->getConferenceVideoLayout()); + if(mCall->getConference()){ + if( mConferenceVideoLayout == LinphoneEnums::ConferenceLayoutGrid) + settings->setCameraMode(settings->getGridCameraMode()); + else + settings->setCameraMode(settings->getActiveSpeakerCameraMode()); + }else + settings->setCameraMode(settings->getCallCameraMode()); + } // Deal with auto-answer. if (!isOutgoing()) { - SettingsModel *settings = coreManager->getSettingsModel(); + if (settings->getAutoAnswerStatus()) { QTimer *timer = new QTimer(this); @@ -922,13 +932,26 @@ LinphoneEnums::ConferenceLayout CallModel::getConferenceVideoLayout() const{ } void CallModel::changeConferenceVideoLayout(LinphoneEnums::ConferenceLayout layout){ - shared_ptr params = CoreManager::getInstance()->getCore()->createCallParams(mCall); + auto coreManager = CoreManager::getInstance(); + if( layout == LinphoneEnums::ConferenceLayoutGrid) + coreManager->getSettingsModel()->setCameraMode(coreManager->getSettingsModel()->getGridCameraMode()); + else + coreManager->getSettingsModel()->setCameraMode(coreManager->getSettingsModel()->getActiveSpeakerCameraMode()); + shared_ptr params = coreManager->getCore()->createCallParams(mCall); params->setConferenceVideoLayout(LinphoneEnums::toLinphone(layout)); params->enableVideo(true); mCall->update(params); } void CallModel::setConferenceVideoLayout(LinphoneEnums::ConferenceLayout layout){ + auto settings = CoreManager::getInstance()->getSettingsModel(); + if(mCall->getConference()){ + if( layout == LinphoneEnums::ConferenceLayoutGrid) + settings->setCameraMode(settings->getGridCameraMode()); + else + settings->setCameraMode(settings->getActiveSpeakerCameraMode()); + }else + settings->setCameraMode(settings->getCallCameraMode()); if( mConferenceVideoLayout != layout){ mConferenceVideoLayout = layout; emit conferenceVideoLayoutChanged(); diff --git a/linphone-app/src/components/camera/Camera.cpp b/linphone-app/src/components/camera/Camera.cpp index e8b580e0b..792664e3c 100644 --- a/linphone-app/src/components/camera/Camera.cpp +++ b/linphone-app/src/components/camera/Camera.cpp @@ -26,6 +26,7 @@ #include "components/call/CallModel.hpp" #include "components/core/CoreManager.hpp" #include "components/participant/ParticipantDeviceModel.hpp" +#include "components/settings/SettingsModel.hpp" #include "Camera.hpp" #include "CameraDummy.hpp" @@ -58,6 +59,9 @@ Camera::Camera (QQuickItem *parent) : QQuickFramebufferObject(parent) { ); mRefreshTimer->start(); + + mLastVideoDefinitionChecker.setInterval(500); + QObject::connect(&mLastVideoDefinitionChecker, &QTimer::timeout, this, &Camera::checkVideoDefinition, Qt::QueuedConnection); } Camera::~Camera(){ @@ -102,11 +106,26 @@ void Camera::resetWindowId() const{ mIsWindowIdSet = false; } } +void Camera::checkVideoDefinition(){ + if( mWindowIdLocation == WindowIdLocation::CorePreview){ + auto videoDefinition = CoreManager::getInstance()->getSettingsModel()->getCurrentPreviewVideoDefinition(); + if(videoDefinition["width"] != mLastVideoDefinition["width"] || videoDefinition["height"] != mLastVideoDefinition["height"]){ + mLastVideoDefinition = videoDefinition; + emit videoDefinitionChanged(); + } + } +} void Camera::setWindowIdLocation(const WindowIdLocation& location){ if( mWindowIdLocation != location){ resetWindowId();// Location change: Reset old window ID. mWindowIdLocation = location; + if( mWindowIdLocation == WindowIdLocation::CorePreview){ + mLastVideoDefinition = CoreManager::getInstance()->getSettingsModel()->getCurrentPreviewVideoDefinition(); + emit videoDefinitionChanged(); + mLastVideoDefinitionChecker.start(); + }else + mLastVideoDefinitionChecker.stop(); } } void Camera::updateWindowIdLocation(){ diff --git a/linphone-app/src/components/camera/Camera.hpp b/linphone-app/src/components/camera/Camera.hpp index ed5631ec6..58d20c9cf 100644 --- a/linphone-app/src/components/camera/Camera.hpp +++ b/linphone-app/src/components/camera/Camera.hpp @@ -26,6 +26,7 @@ #include #include #include +#include // ============================================================================= @@ -60,6 +61,7 @@ public: QQuickFramebufferObject::Renderer *createRenderer () const override; Q_INVOKABLE void resetWindowId() const; // const to be used from createRenderer() + void checkVideoDefinition(); static QMutex mPreviewCounterMutex; static int mPreviewCounter; @@ -73,6 +75,7 @@ signals: void isReadyChanged(); void participantDeviceModelChanged(ParticipantDeviceModel *participantDeviceModel); void requestNewRenderer(); + void videoDefinitionChanged(); private: CallModel *getCallModel () const; @@ -91,6 +94,9 @@ private: void updateWindowIdLocation(); void removeParticipantDeviceModel(); + QVariantMap mLastVideoDefinition; + QTimer mLastVideoDefinitionChecker; + bool mIsPreview = false; bool mIsReady = false; CallModel *mCallModel = nullptr; diff --git a/linphone-app/src/components/settings/SettingsModel.cpp b/linphone-app/src/components/settings/SettingsModel.cpp index ee5e77c1e..c9a31be43 100644 --- a/linphone-app/src/components/settings/SettingsModel.cpp +++ b/linphone-app/src/components/settings/SettingsModel.cpp @@ -560,6 +560,18 @@ QVariantMap SettingsModel::getVideoDefinition () const { return createMapFromVideoDefinition(CoreManager::getInstance()->getCore()->getPreferredVideoDefinition()); } +QVariantMap SettingsModel::getCurrentPreviewVideoDefinition () const { + auto definition = CoreManager::getInstance()->getCore()->getCurrentPreviewVideoDefinition(); + if(definition) + return createMapFromVideoDefinition(definition); + else { + QVariantMap map; + map["width"] = 0; + map["height"] = 0; + return map; + } +} + void SettingsModel::setVideoDefinition (const QVariantMap &definition) { CoreManager::getInstance()->getCore()->setPreferredVideoDefinition( definition.value("__definition").value>()->clone() @@ -590,8 +602,7 @@ void SettingsModel::updateCameraMode(){ mConfig->setString("video", "other_display_mode", mode); } -SettingsModel::CameraMode SettingsModel::getCameraMode() const{ - auto mode = mConfig->getString("video", "main_display_mode", "OccupyAllSpace"); +SettingsModel::CameraMode SettingsModel::cameraModefromString(const std::string& mode){ if( mode == "Hybrid") return CameraMode::CameraMode_Hybrid; else if( mode == "BlackBars") @@ -599,6 +610,18 @@ SettingsModel::CameraMode SettingsModel::getCameraMode() const{ else return CameraMode::CameraMode_OccupyAllSpace; } +std::string SettingsModel::toString(const CameraMode& mode){ + std::string modeStr; + switch(mode){ + case CameraMode::CameraMode_Hybrid : modeStr = "Hybrid";break; + case CameraMode::CameraMode_BlackBars: modeStr = "BlackBars";break; + default: modeStr = "OccupyAllSpace"; + } + return modeStr; +} +SettingsModel::CameraMode SettingsModel::getCameraMode() const{ + return cameraModefromString(mConfig->getString("video", "main_display_mode", "OccupyAllSpace")); +} void SettingsModel::setCameraMode(CameraMode mode){ std::string modeToSet; @@ -612,6 +635,31 @@ void SettingsModel::setCameraMode(CameraMode mode){ emit cameraModeChanged(); } +SettingsModel::CameraMode SettingsModel::getGridCameraMode() const{ + return cameraModefromString(mConfig->getString(UiSection, "main_grid_display_mode", "OccupyAllSpace")); +} +void SettingsModel::setGridCameraMode(CameraMode mode){ + auto modeStd = toString(mode); + mConfig->setString(UiSection, "main_grid_display_mode", modeStd); + emit gridCameraModeChanged(); +} +SettingsModel::CameraMode SettingsModel::getActiveSpeakerCameraMode() const{ + return cameraModefromString(mConfig->getString(UiSection, "main_active_speaker_display_mode", "Hybrid")); +} +void SettingsModel::setActiveSpeakerCameraMode(CameraMode mode){ + auto modeStd = toString(mode); + mConfig->setString(UiSection, "main_active_speaker_display_mode", modeStd); + emit activeSpeakerCameraModeChanged(); +} +SettingsModel::CameraMode SettingsModel::getCallCameraMode() const{ + return cameraModefromString(mConfig->getString(UiSection, "main_call_display_mode", "Hybrid")); +} +void SettingsModel::setCallCameraMode(CameraMode mode){ + auto modeStd = toString(mode); + mConfig->setString(UiSection, "main_call_display_mode", modeStd); + emit callCameraModeChanged(); +} + LinphoneEnums::ConferenceLayout SettingsModel::getVideoConferenceLayout() const{ return (LinphoneEnums::ConferenceLayout) mConfig->getInt(UiSection, "video_conference_layout", (int)LinphoneEnums::ConferenceLayoutActiveSpeaker); } diff --git a/linphone-app/src/components/settings/SettingsModel.hpp b/linphone-app/src/components/settings/SettingsModel.hpp index 1d8cd268d..e2e86b40b 100644 --- a/linphone-app/src/components/settings/SettingsModel.hpp +++ b/linphone-app/src/components/settings/SettingsModel.hpp @@ -96,7 +96,9 @@ class SettingsModel : public QObject { Q_PROPERTY(bool showVideoCodecs READ getShowVideoCodecs WRITE setShowVideoCodecs NOTIFY showVideoCodecsChanged) - Q_PROPERTY(CameraMode cameraMode READ getCameraMode WRITE setCameraMode NOTIFY cameraModeChanged) + Q_PROPERTY(CameraMode gridCameraMode READ getGridCameraMode WRITE setGridCameraMode NOTIFY gridCameraModeChanged) + Q_PROPERTY(CameraMode activeSpeakerCameraMode READ getActiveSpeakerCameraMode WRITE setActiveSpeakerCameraMode NOTIFY activeSpeakerCameraModeChanged) + Q_PROPERTY(CameraMode callCameraMode READ getCallCameraMode WRITE setCallCameraMode NOTIFY callCameraModeChanged) Q_PROPERTY(LinphoneEnums::ConferenceLayout videoConferenceLayout READ getVideoConferenceLayout WRITE setVideoConferenceLayout NOTIFY videoConferenceLayoutChanged) @@ -239,6 +241,8 @@ public: CameraMode_BlackBars = 2 }; Q_ENUM(CameraMode); + static SettingsModel::CameraMode cameraModefromString(const std::string& mode); + static std::string toString(const CameraMode& mode); SettingsModel (QObject *parent = Q_NULLPTR); @@ -350,6 +354,7 @@ public: QVariantList getSupportedVideoDefinitions () const; QVariantMap getVideoDefinition () const; + Q_INVOKABLE QVariantMap getCurrentPreviewVideoDefinition () const; void setVideoDefinition (const QVariantMap &definition); bool getVideoSupported () const; @@ -359,7 +364,14 @@ public: void updateCameraMode(); CameraMode getCameraMode() const; - void setCameraMode(CameraMode mode); + Q_INVOKABLE void setCameraMode(CameraMode mode); + // Custom modes to set default for setCameraMode + CameraMode getGridCameraMode() const; + void setGridCameraMode(CameraMode mode); + CameraMode getActiveSpeakerCameraMode() const; + void setActiveSpeakerCameraMode(CameraMode mode); + CameraMode getCallCameraMode() const; + void setCallCameraMode(CameraMode mode); LinphoneEnums::ConferenceLayout getVideoConferenceLayout() const; void setVideoConferenceLayout(LinphoneEnums::ConferenceLayout layout); @@ -658,6 +670,9 @@ signals: void showVideoCodecsChanged (bool status); void cameraModeChanged(); + void gridCameraModeChanged(); + void activeSpeakerCameraModeChanged(); + void callCameraModeChanged(); void videoConferenceLayoutChanged(); // Chat & calls. ------------------------------------------------------------- diff --git a/linphone-app/ui/modules/Common/Form/Placements/FormGroup.qml b/linphone-app/ui/modules/Common/Form/Placements/FormGroup.qml index cdc303347..742ec4c63 100644 --- a/linphone-app/ui/modules/Common/Form/Placements/FormGroup.qml +++ b/linphone-app/ui/modules/Common/Form/Placements/FormGroup.qml @@ -9,6 +9,8 @@ Loader { // --------------------------------------------------------------------------- property string label + property var labelFont: item ? item.labelFont : Application.font + property bool fitLabel: false readonly property int orientation: parent.orientation default property var _content: null @@ -27,6 +29,7 @@ Loader { _content: loader._content label: loader.label maxWidth: loader.maxWidth + fitLabel: loader.fitLabel } } diff --git a/linphone-app/ui/modules/Common/Form/Placements/FormHGroup.qml b/linphone-app/ui/modules/Common/Form/Placements/FormHGroup.qml index 8249e2839..47ed4bea0 100644 --- a/linphone-app/ui/modules/Common/Form/Placements/FormHGroup.qml +++ b/linphone-app/ui/modules/Common/Form/Placements/FormHGroup.qml @@ -8,9 +8,11 @@ import Common.Styles 1.0 RowLayout { property alias label: label.text + property alias labelFont: label.font default property var _content: null property int maxWidth: FormHGroupStyle.content.maxWidth + property bool fitLabel : false // --------------------------------------------------------------------------- spacing: FormHGroupStyle.spacing @@ -19,9 +21,9 @@ RowLayout { Text { id: label - + computeFitWidth: parent.fitLabel Layout.preferredHeight: FormHGroupStyle.legend.height - Layout.preferredWidth: FormHGroupStyle.legend.width + Layout.preferredWidth: fitLabel ? Math.min(label.fitWidth, FormHGroupStyle.legend.width) : FormHGroupStyle.legend.width color: FormHGroupStyle.legend.color elide: Text.ElideRight diff --git a/linphone-app/ui/modules/Common/Form/Placements/FormLine.qml b/linphone-app/ui/modules/Common/Form/Placements/FormLine.qml index 7651d3424..a1c207a2d 100644 --- a/linphone-app/ui/modules/Common/Form/Placements/FormLine.qml +++ b/linphone-app/ui/modules/Common/Form/Placements/FormLine.qml @@ -5,8 +5,9 @@ import Common.Styles 1.0 // ============================================================================= Row { + property int childrenCount: children.length property double maxItemWidth: { - var n = children.length + var n = childrenCount var curWidth = width / n - (n - 1) * spacing var maxWidth = orientation === Qt.Horizontal ? FormHGroupStyle.legend.width + FormHGroupStyle.content.maxWidth + FormHGroupStyle.spacing diff --git a/linphone-app/ui/modules/Common/Form/Placements/FormVGroup.qml b/linphone-app/ui/modules/Common/Form/Placements/FormVGroup.qml index a36861014..a33621d3a 100644 --- a/linphone-app/ui/modules/Common/Form/Placements/FormVGroup.qml +++ b/linphone-app/ui/modules/Common/Form/Placements/FormVGroup.qml @@ -8,6 +8,7 @@ import Common.Styles 1.0 ColumnLayout { property alias label: label.text + property alias labelFont: label.font default property var _content: null property int maxWidth: FormVGroupStyle.content.maxWidth diff --git a/linphone-app/ui/modules/Linphone/Camera/CameraItem.qml b/linphone-app/ui/modules/Linphone/Camera/CameraItem.qml index ee63106d9..adc186ecd 100644 --- a/linphone-app/ui/modules/Linphone/Camera/CameraItem.qml +++ b/linphone-app/ui/modules/Linphone/Camera/CameraItem.qml @@ -33,6 +33,8 @@ Item { property bool d : callModel && callModel.cameraEnabled property bool isReady: cameraLoader.item && cameraLoader.item.isReady + signal videoDefinitionChanged() + onCurrentDeviceChanged: {if(container.isCameraFromDevice) resetActive()} function resetActive(){ resetTimer.resetActive() @@ -71,6 +73,7 @@ Item { isPreview: container.isPreview onRequestNewRenderer: {resetTimer.resetActive()} + onVideoDefinitionChanged: container.videoDefinitionChanged() } } } diff --git a/linphone-app/ui/modules/Linphone/Camera/CameraView.qml b/linphone-app/ui/modules/Linphone/Camera/CameraView.qml index c35f713e9..5ea7ceccc 100644 --- a/linphone-app/ui/modules/Linphone/Camera/CameraView.qml +++ b/linphone-app/ui/modules/Linphone/Camera/CameraView.qml @@ -24,6 +24,7 @@ Item{ property bool showActiveSpeakerOverlay: true property color color : camera.isReady ? CameraViewStyle.cameraBackgroundColor : CameraViewStyle.outBackgroundColor signal closeRequested() + signal videoDefinitionChanged() MouseArea{ anchors.fill: parent @@ -74,6 +75,7 @@ Item{ anchors.centerIn: parent anchors.fill: parent visible: false + onVideoDefinitionChanged: mainItem.videoDefinitionChanged() } OpacityMask{ id: renderedCamera diff --git a/linphone-app/ui/scripts/Utils/utils.js b/linphone-app/ui/scripts/Utils/utils.js index 2eaf761d2..2e2c2341c 100644 --- a/linphone-app/ui/scripts/Utils/utils.js +++ b/linphone-app/ui/scripts/Utils/utils.js @@ -744,8 +744,7 @@ function write (fileName, text) { function computeAvatarSize (container, maxSize) { var height = 2*container.height/3 - var width = 2*container.width/3 - + var width = 2*container.width/3 var size = height < maxSize && height > 0 ? height : maxSize return size < width ? size : width } diff --git a/linphone-app/ui/views/App/Calls/Incall.qml b/linphone-app/ui/views/App/Calls/Incall.qml index 62fbf8aca..258947d34 100644 --- a/linphone-app/ui/views/App/Calls/Incall.qml +++ b/linphone-app/ui/views/App/Calls/Incall.qml @@ -396,8 +396,8 @@ Rectangle { id: cameraPreviewLoader anchors.centerIn: parent - height: CallStyle.actionArea.userVideo.height - width: CallStyle.actionArea.userVideo.width + height: CallStyle.actionArea.height + width: 16*height/9 active: incall.width >= CallStyle.actionArea.lowWidth && incall.call.videoEnabled && !isFullScreen sourceComponent: cameraPreview Component { diff --git a/linphone-app/ui/views/App/Calls/WaitingRoom.qml b/linphone-app/ui/views/App/Calls/WaitingRoom.qml index f8f561e4d..864620e31 100644 --- a/linphone-app/ui/views/App/Calls/WaitingRoom.qml +++ b/linphone-app/ui/views/App/Calls/WaitingRoom.qml @@ -10,7 +10,7 @@ import UtilsCpp 1.0 import Common.Styles 1.0 import App.Styles 1.0 - +import 'qrc:/ui/scripts/Utils/utils.js' as Utils // ============================================================================= @@ -39,11 +39,18 @@ Rectangle { ColumnLayout { anchors.fill: parent - RowLayout{ + ColumnLayout{ Layout.preferredHeight: 60 Layout.alignment: Qt.AlignCenter Layout.topMargin: 15 - spacing: 20 + spacing: 5 + BusyIndicator { + Layout.alignment: Qt.AlignCenter + Layout.preferredHeight: WaitingRoomStyle.header.busyIndicator.height + Layout.preferredWidth: WaitingRoomStyle.header.busyIndicator.width + color: WaitingRoomStyle.header.busyIndicator.color + visible: mainItem.callModel && mainItem.callModel.isOutgoing + } Text{ Layout.preferredHeight: 60 Layout.alignment: Qt.AlignCenter @@ -54,13 +61,6 @@ Rectangle { horizontalAlignment: Qt.AlignHCenter verticalAlignment: Qt.AlignVCenter } - BusyIndicator { - Layout.alignment: Qt.AlignCenter - Layout.preferredHeight: WaitingRoomStyle.header.busyIndicator.height - Layout.preferredWidth: WaitingRoomStyle.header.busyIndicator.width - color: WaitingRoomStyle.header.busyIndicator.color - visible: mainItem.callModel && mainItem.callModel.isOutgoing - } } Text { Layout.fillWidth: true @@ -77,7 +77,12 @@ Rectangle { id: loader Layout.fillWidth: true Layout.fillHeight: true + property var previewDefinition: SettingsModel.getCurrentPreviewVideoDefinition() + onPreviewDefinitionChanged: console.log(Utils.printObject(previewDefinition)) + property real cameraRatio: previewDefinition.height > 0 ? previewDefinition.width/previewDefinition.height : 1.0 property int minSize: Math.min( loader.height, loader.width) + property int cameraHeight: Math.min(Math.min(cameraRatio * minSize, loader.width) / cameraRatio, minSize) + property int cameraWidth: cameraRatio * cameraHeight Item{ Layout.fillHeight: true Layout.fillWidth: true @@ -85,8 +90,8 @@ Rectangle { Flipable{ id: contentsStack anchors.centerIn: parent - height: loader.minSize - width : height + height: loader.cameraHeight + width : loader.cameraWidth property bool flipped: false transform: Rotation { @@ -111,8 +116,9 @@ Rectangle { id: previewLoader showCloseButton: false enabled: mainItem.previewLoaderEnabled - height: loader.minSize - width : height + height: loader.cameraHeight + width : loader.cameraWidth + onVideoDefinitionChanged: loader.previewDefinition = SettingsModel.getCurrentPreviewVideoDefinition() ActionButton{ anchors.top: parent.top anchors.right: parent.right @@ -125,12 +131,13 @@ Rectangle { onClicked: mediaMenu.visible = !mediaMenu.visible } } - back: Avatar { + back: IncallAvatar { id: avatar - height: Math.min( loader.height, loader.width) - width : height + anchors.centerIn: parent + height: Utils.computeAvatarSize(loader, CallStyle.container.avatar.maxSize) + width: height backgroundColor: WaitingRoomStyle.avatar.backgroundColor - image: mainItem._sipAddressObserver && _sipAddressObserver.contact && mainItem._sipAddressObserver.contact.vcard.avatar + image: mainItem._sipAddressObserver && mainItem._sipAddressObserver.contact && mainItem._sipAddressObserver.contact.vcard.avatar username: mainItem.conferenceInfoModel ? mainItem.conferenceInfoModel.subject : (mainItem._sipAddressObserver ? UtilsCpp.getDisplayName(mainItem._sipAddressObserver.peerAddress) : '') } @@ -160,7 +167,6 @@ Rectangle { Layout.bottomMargin: 25 Layout.leftMargin: 25 Layout.rightMargin: 25 - enabled: !mainItem.callModel // Action buttons RowLayout{ anchors.centerIn: parent @@ -169,6 +175,7 @@ Rectangle { id: micro visible: SettingsModel.muteMicrophoneEnabled property bool microMuted: false + onMicroMutedChanged: if(mainItem.callModel) mainItem.callModel.microMuted = microMuted isCustom: true backgroundRadius: 90 colorSet: microMuted ? WaitingRoomStyle.buttons.microOff : WaitingRoomStyle.buttons.microOn @@ -187,6 +194,7 @@ Rectangle { ActionSwitch { id: speaker property bool speakerMuted: false + onSpeakerMutedChanged: if(mainItem.callModel) mainItem.callModel.speakerMuted = speakerMuted isCustom: true backgroundRadius: 90 colorSet: speakerMuted ? WaitingRoomStyle.buttons.speakerOff : WaitingRoomStyle.buttons.speakerOn @@ -195,6 +203,7 @@ Rectangle { ActionSwitch { id: camera property bool cameraEnabled: true + visible: !mainItem.callModel isCustom: true backgroundRadius: 90 colorSet: cameraEnabled ? WaitingRoomStyle.buttons.cameraOn : WaitingRoomStyle.buttons.cameraOff @@ -204,8 +213,8 @@ Rectangle { } RowLayout{ anchors.centerIn: parent - anchors.horizontalCenterOffset: loader.minSize/2 - modeChoice.width/2 - + anchors.horizontalCenterOffset: loader.cameraWidth/2 - modeChoice.width/2 + visible: !mainItem.callModel ActionButton{ id: modeChoice property int selectedMode: SettingsModel.videoConferenceLayout @@ -239,7 +248,7 @@ Rectangle { //: 'Start' : Button label for starting the conference. text: qsTr('startButton') capitalization: Font.AllUppercase - enabled: !mainItem.callModel + visible: !mainItem.callModel onClicked: {CallsListModel.launchVideoCall(conferenceInfoModel.uri, '', 0, { video: modeChoice.selectedMode != 2 diff --git a/linphone-app/ui/views/App/Settings/SettingsVideo.qml b/linphone-app/ui/views/App/Settings/SettingsVideo.qml index 3c973cc84..bf28782fa 100644 --- a/linphone-app/ui/views/App/Settings/SettingsVideo.qml +++ b/linphone-app/ui/views/App/Settings/SettingsVideo.qml @@ -189,31 +189,90 @@ TabContainer { // Diplay Video. // ------------------------------------------------------------------------- + Form { + id: videoDisplayForm //: 'Video display' : Title for display parameters title: qsTr('videoDisplayTitle') width: parent.width - FormLine { - FormGroup { - //: 'Camera mode' : Label to choose a camera mode. - label: qsTr('videoModeLabel') + property var cameraModel: + //: 'Hybrid' : Hybrid mode for camera. + [{displayText:qsTr('videoHybrid')} + //: 'Occupy all space' : Camera mode for a centered cropping view. + , {displayText:qsTr('videoOccupyAllSpace')} + //: 'Black bars' : Camera mode for a fit view with black bars to keep ratio. + , {displayText:qsTr('videoBlackBars')} + ] + function getId(index){ + if(index == 0 ) + return SettingsModel.CameraMode_Hybrid + else if(index == 1) + return SettingsModel.CameraMode_OccupyAllSpace + else + return SettingsModel.CameraMode_BlackBars + } + Row{ + property int orientation: Qt.Horizontal + width: parent.width + Text{ + id: videoModeLabel + height: parent.height + //: 'Camera modes' : Label to choose a camera modes. + text: qsTr('videoModeLabel') + font: videoGridMode.labelFont + horizontalAlignment: Text.AlignRight + verticalAlignment: Text.AlignVCenter - ComboBox { - //: 'Hybrid' : Hybrid mode for camera. - model:[{text:qsTr('videoHybrid'), value: SettingsModel.CameraMode_Hybrid} - //: 'Occupy all space' : Camera mode for a centered cropping view. - , {text:qsTr('videoOccupyAllSpace'), value:SettingsModel.CameraMode_OccupyAllSpace} - //: 'Black bars' : Camera mode for a fit view with black bars to keep ratio. - ,{text:qsTr('videoBlackBars'), value:SettingsModel.CameraMode_BlackBars} - ] - textRole: 'text' - currentIndex: SettingsModel.cameraMode == SettingsModel.CameraMode_Hybrid - ? 0 - : SettingsModel.cameraMode == SettingsModel.CameraMode_OccupyAllSpace - ? 1 - : 2 - onActivated: SettingsModel.cameraMode = model[index].value + } + FormLine { + spacing: 5 + width: parent.width-videoModeLabel.implicitWidth + FormGroup { + id: videoGridMode + //: 'Mosaic' : Label to choose a camera mode. + label: qsTr('videoGridModeLabel') + ':' + fitLabel: true + ComboBox { + model: videoDisplayForm.cameraModel + textRole: 'displayText' + currentIndex: SettingsModel.gridCameraMode == SettingsModel.CameraMode_Hybrid + ? 0 + : SettingsModel.gridCameraMode == SettingsModel.CameraMode_OccupyAllSpace + ? 1 + : 2 + onActivated: SettingsModel.gridCameraMode = videoDisplayForm.getId(index) + } + } + FormGroup { + //: 'Active speaker' : Label to choose a camera mode. + label: qsTr('videoActiveSpeakerModeLabel') + ':' + fitLabel: true + ComboBox { + model: videoDisplayForm.cameraModel + textRole: 'displayText' + currentIndex: SettingsModel.activeSpeakerCameraMode == SettingsModel.CameraMode_Hybrid + ? 0 + : SettingsModel.activeSpeakerCameraMode == SettingsModel.CameraMode_OccupyAllSpace + ? 1 + : 2 + onActivated: SettingsModel.activeSpeakerCameraMode = videoDisplayForm.getId(index) + } + } + FormGroup { + //: 'Calls' : Label to choose a camera mode. + label: qsTr('videoCallsModeLabel') + ':' + fitLabel: true + ComboBox { + model: videoDisplayForm.cameraModel + textRole: 'displayText' + currentIndex: SettingsModel.callCameraMode == SettingsModel.CameraMode_Hybrid + ? 0 + : SettingsModel.callCameraMode == SettingsModel.CameraMode_OccupyAllSpace + ? 1 + : 2 + onActivated: SettingsModel.callCameraMode = videoDisplayForm.getId(index) + } } } } @@ -221,7 +280,7 @@ TabContainer { FormGroup { //: 'Default video layout' : Label to choose the default layout in video conference. label: qsTr('videoLayout') - + fitLabel: true ComboBox { //: 'Mosaic' : Mosaic layout invideo conference. model:[{text:qsTr('videoMosaicLayout'), value:LinphoneEnums.ConferenceLayoutGrid}