From d4139fddd10a270cf5150b7507dedc12281df8de Mon Sep 17 00:00:00 2001 From: Julien Wadel Date: Wed, 17 Apr 2024 11:30:18 +0200 Subject: [PATCH] fix preview/cameras. CameraEnabled => localVideoEnabled. Meeting invitations. --- Linphone/core/App.cpp | 2 - Linphone/core/call/CallCore.cpp | 31 +-- Linphone/core/call/CallCore.hpp | 15 +- .../core/conference/ConferenceInfoCore.cpp | 16 +- .../core/conference/ConferenceInfoCore.hpp | 14 +- Linphone/model/call/CallModel.cpp | 34 +-- Linphone/model/call/CallModel.hpp | 8 +- .../model/conference/ConferenceInfoModel.cpp | 23 +- .../model/conference/ConferenceInfoModel.hpp | 6 +- Linphone/model/conference/ConferenceModel.hpp | 2 +- .../conference/ConferenceSchedulerModel.cpp | 2 +- Linphone/model/tool/ToolModel.cpp | 6 +- Linphone/view/App/CallsWindow.qml | 6 +- Linphone/view/App/Layout/MainLayout.qml | 2 +- Linphone/view/Item/Call/WaitingRoom.qml | 4 +- Linphone/view/Item/Contact/ContactsList.qml | 2 +- Linphone/view/Item/Contact/Sticker.qml | 6 +- Linphone/view/Item/Meeting/MeetingSetUp.qml | 6 +- .../view/Layout/Call/ActiveSpeakerLayout.qml | 6 +- Linphone/view/Layout/Call/CallLayout.qml | 238 +----------------- Linphone/view/Layout/Call/GridLayout.qml | 2 +- .../view/Layout/Conference/IncallGrid.qml | 4 +- .../view/Layout/Contact/ContactLayout.qml | 3 +- 23 files changed, 121 insertions(+), 317 deletions(-) diff --git a/Linphone/core/App.cpp b/Linphone/core/App.cpp index 1b5715f9..ba1cb0a7 100644 --- a/Linphone/core/App.cpp +++ b/Linphone/core/App.cpp @@ -111,8 +111,6 @@ void App::setSelf(QSharedPointer(me)) { auto win = getCallsWindow(QVariant::fromValue(callGui)); Utils::smartShowWindow(win); qDebug() << "App : call created" << callGui; - // callGui.value ()->getCore()->lSetCameraEnabled(true); }); }); } diff --git a/Linphone/core/call/CallCore.cpp b/Linphone/core/call/CallCore.cpp index cf5541fc..34e23d8b 100644 --- a/Linphone/core/call/CallCore.cpp +++ b/Linphone/core/call/CallCore.cpp @@ -53,9 +53,12 @@ CallCore::CallCore(const std::shared_ptr &call) : QObject(nullpt mDuration = call->getDuration(); mMicrophoneMuted = call->getMicrophoneMuted(); mSpeakerMuted = call->getSpeakerMuted(); - // mCameraEnabled = call->cameraEnabled(); auto videoDirection = call->getCurrentParams()->getVideoDirection(); - mCameraEnabled = + mLocalVideoEnabled = + videoDirection == linphone::MediaDirection::SendOnly || videoDirection == linphone::MediaDirection::SendRecv; + auto remoteParams = call->getRemoteParams(); + videoDirection = remoteParams ? remoteParams->getVideoDirection() : linphone::MediaDirection::Inactive; + mRemoteVideoEnabled = videoDirection == linphone::MediaDirection::SendOnly || videoDirection == linphone::MediaDirection::SendRecv; mState = LinphoneEnums::fromLinphone(call->getState()); mPeerAddress = Utils::coreStringToAppString(call->getRemoteAddress()->asStringUriOnly()); @@ -79,7 +82,7 @@ CallCore::CallCore(const std::shared_ptr &call) : QObject(nullpt } mPaused = mState == LinphoneEnums::CallState::Pausing || mState == LinphoneEnums::CallState::Paused || mState == LinphoneEnums::CallState::PausedByRemote; - mRemoteVideoEnabled = call->getRemoteParams() && call->getRemoteParams()->videoEnabled(); + mRecording = call->getParams() && call->getParams()->isRecording(); mRemoteRecording = call->getRemoteParams() && call->getRemoteParams()->isRecording(); mSpeakerVolumeGain = mCallModel->getSpeakerVolumeGain(); @@ -123,8 +126,8 @@ void CallCore::setSelf(QSharedPointer me) { mCallModelConnection->makeConnectToModel(&CallModel::speakerMutedChanged, [this](bool isMuted) { mCallModelConnection->invokeToCore([this, isMuted]() { setSpeakerMuted(isMuted); }); }); - mCallModelConnection->makeConnectToCore(&CallCore::lSetCameraEnabled, [this](bool enabled) { - mCallModelConnection->invokeToModel([this, enabled]() { mCallModel->setCameraEnabled(enabled); }); + mCallModelConnection->makeConnectToCore(&CallCore::lSetLocalVideoEnabled, [this](bool enabled) { + mCallModelConnection->invokeToModel([this, enabled]() { mCallModel->setLocalVideoEnabled(enabled); }); }); mCallModelConnection->makeConnectToCore(&CallCore::lStartRecording, [this]() { mCallModelConnection->invokeToModel([this]() { mCallModel->startRecording(); }); @@ -146,8 +149,8 @@ void CallCore::setSelf(QSharedPointer me) { &CallModel::remoteRecording, [this](const std::shared_ptr &call, bool recording) { mCallModelConnection->invokeToCore([this, recording]() { setRemoteRecording(recording); }); }); - mCallModelConnection->makeConnectToModel(&CallModel::cameraEnabledChanged, [this](bool enabled) { - mCallModelConnection->invokeToCore([this, enabled]() { setCameraEnabled(enabled); }); + mCallModelConnection->makeConnectToModel(&CallModel::localVideoEnabledChanged, [this](bool enabled) { + mCallModelConnection->invokeToCore([this, enabled]() { setLocalVideoEnabled(enabled); }); }); mCallModelConnection->makeConnectToModel(&CallModel::durationChanged, [this](int duration) { mCallModelConnection->invokeToCore([this, duration]() { setDuration(duration); }); @@ -356,15 +359,15 @@ void CallCore::setMicrophoneMuted(bool isMuted) { } } -bool CallCore::getCameraEnabled() const { - return mCameraEnabled; +bool CallCore::getLocalVideoEnabled() const { + return mLocalVideoEnabled; } -void CallCore::setCameraEnabled(bool enabled) { - if (mCameraEnabled != enabled) { - mCameraEnabled = enabled; - qWarning() << "CameraEnabled: " << mCameraEnabled; - emit cameraEnabledChanged(); +void CallCore::setLocalVideoEnabled(bool enabled) { + if (mLocalVideoEnabled != enabled) { + mLocalVideoEnabled = enabled; + qWarning() << "LocalVideoEnabled: " << mLocalVideoEnabled; + emit localVideoEnabledChanged(); } } diff --git a/Linphone/core/call/CallCore.hpp b/Linphone/core/call/CallCore.hpp index a5d1d366..ddd64f2d 100644 --- a/Linphone/core/call/CallCore.hpp +++ b/Linphone/core/call/CallCore.hpp @@ -41,7 +41,6 @@ class CallCore : public QObject, public AbstractObject { Q_PROPERTY(int duration READ getDuration NOTIFY durationChanged) Q_PROPERTY(bool speakerMuted READ getSpeakerMuted WRITE lSetSpeakerMuted NOTIFY speakerMutedChanged) Q_PROPERTY(bool microphoneMuted READ getMicrophoneMuted WRITE lSetMicrophoneMuted NOTIFY microphoneMutedChanged) - Q_PROPERTY(bool cameraEnabled READ getCameraEnabled WRITE lSetCameraEnabled NOTIFY cameraEnabledChanged) Q_PROPERTY(bool paused READ getPaused WRITE lSetPaused NOTIFY pausedChanged) Q_PROPERTY(QString peerAddress READ getPeerAddress CONSTANT) Q_PROPERTY(QString localAddress READ getLocalAddress CONSTANT) @@ -52,6 +51,8 @@ class CallCore : public QObject, public AbstractObject { Q_PROPERTY(QString remoteSas WRITE setRemoteSas MEMBER mRemoteSas NOTIFY remoteSasChanged) Q_PROPERTY( bool remoteVideoEnabled READ getRemoteVideoEnabled WRITE setRemoteVideoEnabled NOTIFY remoteVideoEnabledChanged) + Q_PROPERTY( + bool localVideoEnabled READ getLocalVideoEnabled WRITE lSetLocalVideoEnabled NOTIFY localVideoEnabledChanged) Q_PROPERTY(bool recording READ getRecording WRITE setRecording NOTIFY recordingChanged) Q_PROPERTY(bool remoteRecording READ getRemoteRecording WRITE setRemoteRecording NOTIFY remoteRecordingChanged) Q_PROPERTY(bool recordable READ getRecordable WRITE setRecordable NOTIFY recordableChanged) @@ -96,9 +97,6 @@ public: bool getMicrophoneMuted() const; void setMicrophoneMuted(bool isMuted); - bool getCameraEnabled() const; - void setCameraEnabled(bool enabled); - bool getPaused() const; void setPaused(bool paused); @@ -121,6 +119,9 @@ public: bool getRemoteVideoEnabled() const; void setRemoteVideoEnabled(bool enabled); + bool getLocalVideoEnabled() const; + void setLocalVideoEnabled(bool enabled); + bool getRecording() const; void setRecording(bool recording); @@ -158,13 +159,13 @@ signals: void durationChanged(int duration); void speakerMutedChanged(); void microphoneMutedChanged(); - void cameraEnabledChanged(); void pausedChanged(); void transferStateChanged(); void securityUpdated(); void localSasChanged(); void remoteSasChanged(); void remoteVideoEnabledChanged(bool remoteVideoEnabled); + void localVideoEnabledChanged(); void recordingChanged(); void remoteRecordingChanged(); void recordableChanged(); @@ -181,7 +182,7 @@ signals: void lTerminateAllCalls(); // Hangup all calls void lSetSpeakerMuted(bool muted); void lSetMicrophoneMuted(bool isMuted); - void lSetCameraEnabled(bool enabled); + void lSetLocalVideoEnabled(bool enabled); void lSetVideoEnabled(bool enabled); void lSetPaused(bool paused); void lTransferCall(QString &est); @@ -230,7 +231,7 @@ private: int mDuration = 0; bool mSpeakerMuted; bool mMicrophoneMuted; - bool mCameraEnabled = false; + bool mLocalVideoEnabled = false; bool mVideoEnabled = false; bool mPaused = false; bool mRemoteVideoEnabled = false; diff --git a/Linphone/core/conference/ConferenceInfoCore.cpp b/Linphone/core/conference/ConferenceInfoCore.cpp index 02115f86..f1455c3e 100644 --- a/Linphone/core/conference/ConferenceInfoCore.cpp +++ b/Linphone/core/conference/ConferenceInfoCore.cpp @@ -129,7 +129,7 @@ ConferenceInfoCore::ConferenceInfoCore(const ConferenceInfoCore &conferenceInfoC mHaveModel = conferenceInfoCore.mHaveModel; mIsScheduled = conferenceInfoCore.mIsScheduled; mIsEnded = conferenceInfoCore.mIsEnded; - mInviteMode = conferenceInfoCore.mInviteMode; + mInviteEnabled = conferenceInfoCore.mInviteEnabled; mConferenceInfoState = conferenceInfoCore.mConferenceInfoState; } @@ -150,7 +150,7 @@ void ConferenceInfoCore::reset(const ConferenceInfoCore &conf) { setTimeZoneModel(conf.getTimeZoneModel()); setIsScheduled(conf.isScheduled()); setIsEnded(conf.isEnded()); - setInviteMode(conf.getInviteMode()); + enableInvite(conf.inviteEnabled()); setConferenceInfoState(conf.getConferenceInfoState()); } @@ -367,8 +367,8 @@ bool ConferenceInfoCore::isEnded() const { return mIsEnded; } -int ConferenceInfoCore::getInviteMode() const { - return mInviteMode; +bool ConferenceInfoCore::inviteEnabled() const { + return mInviteEnabled; } QVariantList ConferenceInfoCore::getParticipants() const { @@ -503,10 +503,10 @@ void ConferenceInfoCore::setIsEnded(bool ended) { } } -void ConferenceInfoCore::setInviteMode(const int &mode) { - if (mode != mInviteMode) { - mInviteMode = mode; - emit inviteModeChanged(); +void ConferenceInfoCore::enableInvite(const bool &enable) { + if (enable != mInviteEnabled) { + mInviteEnabled = enable; + emit inviteEnabledChanged(); } } diff --git a/Linphone/core/conference/ConferenceInfoCore.hpp b/Linphone/core/conference/ConferenceInfoCore.hpp index dcc5609e..84151c67 100644 --- a/Linphone/core/conference/ConferenceInfoCore.hpp +++ b/Linphone/core/conference/ConferenceInfoCore.hpp @@ -51,13 +51,13 @@ public: Q_PROPERTY(QString subject READ getSubject WRITE setSubject NOTIFY subjectChanged) Q_PROPERTY(QString description READ getDescription WRITE setDescription NOTIFY descriptionChanged) Q_PROPERTY(QString uri READ getUri NOTIFY uriChanged) - + Q_PROPERTY(bool haveModel READ getHaveModel NOTIFY haveModelChanged) Q_PROPERTY(bool isScheduled READ isScheduled WRITE setIsScheduled NOTIFY isScheduledChanged) Q_PROPERTY(bool isEnded READ isEnded WRITE setIsEnded NOTIFY isEndedChanged) - Q_PROPERTY(int inviteMode READ getInviteMode WRITE setInviteMode NOTIFY inviteModeChanged) + Q_PROPERTY(bool inviteEnabled READ inviteEnabled WRITE enableInvite NOTIFY inviteEnabledChanged) Q_PROPERTY(int participantCount READ getParticipantCount NOTIFY participantsChanged) - + Q_PROPERTY(QVariantList participants READ getParticipants NOTIFY participantsChanged) Q_PROPERTY(LinphoneEnums::ConferenceInfoState state READ getConferenceInfoState NOTIFY conferenceInfoStateChanged) Q_PROPERTY(LinphoneEnums::ConferenceSchedulerState schedulerState READ getConferenceSchedulerState NOTIFY @@ -92,7 +92,7 @@ public: bool computeIsEnded() const; bool isEnded() const; void setIsEnded(bool ended); - int getInviteMode() const; + bool inviteEnabled() const; QVariantList getParticipants() const; // Q_INVOKABLE QVariantList getAllParticipants() const; int getParticipantCount() const; @@ -112,7 +112,7 @@ public: void setUri(const QString &uri); void setTimeZoneModel(TimeZoneModel *model); void setDescription(const QString &description); - void setInviteMode(const int &mode); + void enableInvite(const bool &enable); void setConferenceInfoState(LinphoneEnums::ConferenceInfoState state); void setConferenceSchedulerState(LinphoneEnums::ConferenceSchedulerState state); @@ -156,7 +156,7 @@ signals: void haveModelChanged(); void isScheduledChanged(); void isEndedChanged(); - void inviteModeChanged(); + void inviteEnabledChanged(); void conferenceInfoStateChanged(); void conferenceSchedulerStateChanged(); void timeZoneModelChanged(); @@ -192,7 +192,7 @@ private: bool mIsScheduled; bool mIsEnded = false; QTimer mCheckEndTimer; - int mInviteMode = 0; + bool mInviteEnabled = true; // bool mRemoveRequested = false; // true if user has request its deletion from DB // linphone::ConferenceScheduler::State mLastConferenceSchedulerState = // linphone::ConferenceScheduler::State::Idle; // Workaround for missing getter in scheduler. diff --git a/Linphone/model/call/CallModel.cpp b/Linphone/model/call/CallModel.cpp index 0c5445d8..91770ca1 100644 --- a/Linphone/model/call/CallModel.cpp +++ b/Linphone/model/call/CallModel.cpp @@ -57,13 +57,11 @@ void CallModel::accept(bool withVideo) { mustBeInLinphoneThread(log().arg(Q_FUNC_INFO)); auto core = CoreModel::getInstance()->getCore(); auto params = core->createCallParams(mMonitor); - params->enableVideo(withVideo); params->setRecordFile( Paths::getCapturesDirPath() .append(Utils::generateSavedFilename(QString::fromStdString(mMonitor->getToAddress()->getUsername()), "")) .append(".mkv") .toStdString()); - mMonitor->enableCamera(withVideo); // Answer with local call address. auto localAddress = mMonitor->getCallLog()->getLocalAddress(); for (auto account : core->getAccountList()) { @@ -72,8 +70,9 @@ void CallModel::accept(bool withVideo) { break; } } + activateLocalVideo(params, mMonitor->getCurrentParams(), withVideo); mMonitor->acceptWithParams(params); - emit cameraEnabledChanged(withVideo); + emit localVideoEnabledChanged(withVideo); } void CallModel::decline() { @@ -122,14 +121,13 @@ void CallModel::setSpeakerMuted(bool isMuted) { emit speakerMutedChanged(isMuted); } -void CallModel::setCameraEnabled(bool enabled) { - mustBeInLinphoneThread(log().arg(Q_FUNC_INFO)); - // mMonitor->enableCamera(enabled); - auto params = CoreModel::getInstance()->getCore()->createCallParams(mMonitor); +void CallModel::activateLocalVideo(std::shared_ptr ¶ms, + const std::shared_ptr ¤tParams, + bool enable) { params->enableVideo(true); - auto direction = mMonitor->getCurrentParams()->getVideoDirection(); + auto direction = currentParams ? currentParams->getVideoDirection() : params->getVideoDirection(); auto videoDirection = linphone::MediaDirection::RecvOnly; - if (enabled) { // +Send + if (enable) { // +Send switch (direction) { case linphone::MediaDirection::RecvOnly: videoDirection = linphone::MediaDirection::SendRecv; @@ -168,6 +166,12 @@ void CallModel::setCameraEnabled(bool enabled) { : linphone::MediaDirection::SendOnly; */ params->setVideoDirection(videoDirection); +} + +void CallModel::setLocalVideoEnabled(bool enabled) { + mustBeInLinphoneThread(log().arg(Q_FUNC_INFO)); + auto params = CoreModel::getInstance()->getCore()->createCallParams(mMonitor); + activateLocalVideo(params, mMonitor->getCurrentParams(), enabled); mMonitor->update(params); } @@ -359,12 +363,12 @@ void CallModel::onStateChanged(const std::shared_ptr &call, if (state == linphone::Call::State::StreamsRunning) { // After UpdatedByRemote, video direction could be changed. auto params = call->getRemoteParams(); - emit remoteVideoEnabledChanged(params && params->videoEnabled()); - qDebug() << "CallCameraEnabled:" << call->cameraEnabled(); - auto videoDirection = call->getCurrentParams()->getVideoDirection(); - emit cameraEnabledChanged(videoDirection == linphone::MediaDirection::SendOnly || - videoDirection == linphone::MediaDirection::SendRecv); - // emit cameraEnabledChanged(call->cameraEnabled()); + auto videoDirection = params ? params->getVideoDirection() : linphone::MediaDirection::Inactive; + emit remoteVideoEnabledChanged(videoDirection == linphone::MediaDirection::SendOnly || + videoDirection == linphone::MediaDirection::SendRecv); + videoDirection = call->getCurrentParams()->getVideoDirection(); + emit localVideoEnabledChanged(videoDirection == linphone::MediaDirection::SendOnly || + videoDirection == linphone::MediaDirection::SendRecv); setConference(call->getConference()); updateConferenceVideoLayout(); } diff --git a/Linphone/model/call/CallModel.hpp b/Linphone/model/call/CallModel.hpp index feb11fed..57d5e5a8 100644 --- a/Linphone/model/call/CallModel.hpp +++ b/Linphone/model/call/CallModel.hpp @@ -43,7 +43,7 @@ public: void setMicrophoneMuted(bool isMuted); void setSpeakerMuted(bool isMuted); - void setCameraEnabled(bool enabled); + void setLocalVideoEnabled(bool enabled); void startRecording(); void stopRecording(); void setRecordFile(const std::string &path); @@ -72,14 +72,18 @@ public: void changeConferenceVideoLayout(LinphoneEnums::ConferenceLayout layout); // Make a call request void updateConferenceVideoLayout(); // Called from call state changed ater the new layout has been set. + static void activateLocalVideo(std::shared_ptr ¶ms, + const std::shared_ptr ¤tParams, + bool enable); + signals: void microphoneMutedChanged(bool isMuted); void speakerMutedChanged(bool isMuted); - void cameraEnabledChanged(bool enabled); void durationChanged(int); void microphoneVolumeChanged(float); void pausedChanged(bool paused); void remoteVideoEnabledChanged(bool remoteVideoEnabled); + void localVideoEnabledChanged(bool enabled); void recordingChanged(bool recording); void authenticationTokenVerifiedChanged(bool verified); void speakerVolumeGainChanged(float volume); diff --git a/Linphone/model/conference/ConferenceInfoModel.cpp b/Linphone/model/conference/ConferenceInfoModel.cpp index d160c739..40f01ed6 100644 --- a/Linphone/model/conference/ConferenceInfoModel.cpp +++ b/Linphone/model/conference/ConferenceInfoModel.cpp @@ -57,8 +57,14 @@ void ConferenceInfoModel::setConferenceScheduler(const std::shared_ptrremoveListener(); } mConferenceSchedulerModel = model; - connect(mConferenceSchedulerModel.get(), &ConferenceSchedulerModel::stateChanged, this, - &ConferenceInfoModel::schedulerStateChanged); + connect(mConferenceSchedulerModel.get(), &ConferenceSchedulerModel::stateChanged, + [this](linphone::ConferenceScheduler::State state) { + if (state == linphone::ConferenceScheduler::State::Ready && mInviteEnabled) { + auto params = CoreModel::getInstance()->getCore()->createDefaultChatRoomParams(); + mConferenceSchedulerModel->getMonitor()->sendInvitations(params); + } + emit schedulerStateChanged(state); + }); connect(mConferenceSchedulerModel.get(), &ConferenceSchedulerModel::invitationsSent, this, &ConferenceInfoModel::invitationsSent); mConferenceSchedulerModel->setSelf(mConferenceSchedulerModel); @@ -110,6 +116,10 @@ std::list> ConferenceInfoModel::getPa return mConferenceInfo->getParticipantInfos(); } +bool ConferenceInfoModel::inviteEnabled() const { + return mInviteEnabled; +} + void ConferenceInfoModel::setDateTime(const QDateTime &date) { mConferenceInfo->setDateTime(date.isValid() ? date.toMSecsSinceEpoch() / 1000 : -1); // toMSecsSinceEpoch() is UTC emit dateTimeChanged(date); @@ -157,4 +167,11 @@ void ConferenceInfoModel::cancelConference() { void ConferenceInfoModel::updateConferenceInfo() { mConferenceSchedulerModel->setInfo(mConferenceInfo); -} \ No newline at end of file +} + +void ConferenceInfoModel::enableInvite(bool enable) { + if (mInviteEnabled != enable) { + mInviteEnabled = enable; + emit inviteEnabledChanged(mInviteEnabled); + } +} diff --git a/Linphone/model/conference/ConferenceInfoModel.hpp b/Linphone/model/conference/ConferenceInfoModel.hpp index ab8670e0..9fe34c13 100644 --- a/Linphone/model/conference/ConferenceInfoModel.hpp +++ b/Linphone/model/conference/ConferenceInfoModel.hpp @@ -48,6 +48,7 @@ public: QString getDescription() const; QString getUri() const; std::list> getParticipantInfos() const; + bool inviteEnabled() const; void setDateTime(const QDateTime &date); void setDuration(int duration); @@ -58,6 +59,7 @@ public: void deleteConferenceInfo(); void cancelConference(); void updateConferenceInfo(); + void enableInvite(bool enable); signals: void dateTimeChanged(const QDateTime &date); @@ -71,14 +73,16 @@ signals: void schedulerStateChanged(linphone::ConferenceScheduler::State state); void infoStateChanged(linphone::ConferenceInfo::State state); void invitationsSent(const std::list> &failedInvitations); + void inviteEnabledChanged(bool enable); private: std::shared_ptr mConferenceInfo; std::shared_ptr mConferenceSchedulerModel = nullptr; + bool mInviteEnabled = true; DECLARE_ABSTRACT_OBJECT // LINPHONE //-------------------------------------------------------------------------------- }; -#endif \ No newline at end of file +#endif diff --git a/Linphone/model/conference/ConferenceModel.hpp b/Linphone/model/conference/ConferenceModel.hpp index 4863b98f..b8b02786 100644 --- a/Linphone/model/conference/ConferenceModel.hpp +++ b/Linphone/model/conference/ConferenceModel.hpp @@ -58,11 +58,11 @@ public: signals: void microphoneMutedChanged(bool isMuted); void speakerMutedChanged(bool isMuted); - void cameraEnabledChanged(bool enabled); void durationChanged(int); void microphoneVolumeChanged(float); void pausedChanged(bool paused); void remoteVideoEnabledChanged(bool remoteVideoEnabled); + void localVideoEnabledChanged(bool enabled); void recordingChanged(bool recording); void speakerVolumeGainChanged(float volume); void microphoneVolumeGainChanged(float volume); diff --git a/Linphone/model/conference/ConferenceSchedulerModel.cpp b/Linphone/model/conference/ConferenceSchedulerModel.cpp index 1ca2cdd4..1f6c6021 100644 --- a/Linphone/model/conference/ConferenceSchedulerModel.cpp +++ b/Linphone/model/conference/ConferenceSchedulerModel.cpp @@ -64,4 +64,4 @@ void ConferenceSchedulerModel::onInvitationsSent( const std::shared_ptr &conferenceScheduler, const std::list> &failedInvitations) { emit invitationsSent(failedInvitations); -} \ No newline at end of file +} diff --git a/Linphone/model/tool/ToolModel.cpp b/Linphone/model/tool/ToolModel.cpp index 0c9976a8..02424615 100644 --- a/Linphone/model/tool/ToolModel.cpp +++ b/Linphone/model/tool/ToolModel.cpp @@ -101,7 +101,7 @@ bool ToolModel::createCall(const QString &sipAddress, QString *errorMessage) { bool waitRegistrationForCall = true; // getSettingsModel()->getWaitRegistrationForCall() std::shared_ptr core = CoreModel::getInstance()->getCore(); - bool cameraEnabled = options.contains("cameraEnabled") ? options["cameraEnabled"].toBool() : false; + bool localVideoEnabled = options.contains("localVideoEnabled") ? options["localVideoEnabled"].toBool() : false; std::shared_ptr address = interpretUrl(sipAddress); if (!address) { @@ -115,8 +115,7 @@ bool ToolModel::createCall(const QString &sipAddress, } std::shared_ptr params = core->createCallParams(nullptr); - params->enableVideo(true); - params->setVideoDirection(cameraEnabled ? linphone::MediaDirection::SendRecv : linphone::MediaDirection::Inactive); + CallModel::activateLocalVideo(params, nullptr, localVideoEnabled); params->setMediaEncryption(mediaEncryption); if (Utils::coreStringToAppString(params->getRecordFile()).isEmpty()) { @@ -137,7 +136,6 @@ bool ToolModel::createCall(const QString &sipAddress, if (core->getDefaultAccount()) params->setAccount(core->getDefaultAccount()); auto call = core->inviteAddressWithParams(address, params); - call->enableCamera(cameraEnabled); return call != nullptr; /* TODO transfer diff --git a/Linphone/view/App/CallsWindow.qml b/Linphone/view/App/CallsWindow.qml index 14427996..c23a4e91 100644 --- a/Linphone/view/App/CallsWindow.qml +++ b/Linphone/view/App/CallsWindow.qml @@ -788,7 +788,7 @@ Window { target: rightPanel onVisibleChanged: if (!visible) waitingRoomIn.settingsButtonChecked = false } - onJoinConfRequested: mainWindow.joinConference({'microEnabled':microEnabled, 'cameraEnabled':cameraEnabled}) + onJoinConfRequested: mainWindow.joinConference({'microEnabled':microEnabled, 'localVideoEnabled':localVideoEnabled}) } } Component { @@ -948,12 +948,12 @@ Window { enabled: mainWindow.conferenceInfo || (mainWindow.callState === LinphoneEnums.CallState.Connected || mainWindow.callState === LinphoneEnums.CallState.StreamsRunning) iconUrl: AppIcons.videoCamera checkedIconUrl: AppIcons.videoCameraSlash - checked: mainWindow.call && !mainWindow.call.core.cameraEnabled + checked: mainWindow.call && !mainWindow.call.core.localVideoEnabled Layout.preferredWidth: 55 * DefaultStyle.dp Layout.preferredHeight: 55 * DefaultStyle.dp icon.width: 32 * DefaultStyle.dp icon.height: 32 * DefaultStyle.dp - onClicked: mainWindow.call.core.lSetCameraEnabled(!mainWindow.call.core.cameraEnabled) + onClicked: mainWindow.call.core.lSetLocalVideoEnabled(!mainWindow.call.core.localVideoEnabled) } CheckableButton { iconUrl: AppIcons.microphone diff --git a/Linphone/view/App/Layout/MainLayout.qml b/Linphone/view/App/Layout/MainLayout.qml index fe31ebcd..1b402760 100644 --- a/Linphone/view/App/Layout/MainLayout.qml +++ b/Linphone/view/App/Layout/MainLayout.qml @@ -245,7 +245,7 @@ Item { height: 24 * DefaultStyle.dp source: AppIcons.videoCamera } - onClicked: UtilsCpp.createCall(sipAddr.text, {'cameraEnabled':true}) + onClicked: UtilsCpp.createCall(sipAddr.text, {'localVideoEnabled':true}) } } Button { diff --git a/Linphone/view/Item/Call/WaitingRoom.qml b/Linphone/view/Item/Call/WaitingRoom.qml index e5b04e6e..a0e56b2a 100644 --- a/Linphone/view/Item/Call/WaitingRoom.qml +++ b/Linphone/view/Item/Call/WaitingRoom.qml @@ -7,7 +7,7 @@ import UtilsCpp 1.0 RowLayout { id: mainItem - property alias cameraEnabled: preview.cameraEnabled + property alias localVideoEnabled: preview.videoEnabled property bool microEnabled: true property bool settingsButtonChecked: settingsButton.checked property ConferenceInfoGui conferenceInfo @@ -43,7 +43,7 @@ RowLayout { Layout.preferredHeight: 55 * DefaultStyle.dp icon.width: 32 * DefaultStyle.dp icon.height: 32 * DefaultStyle.dp - onCheckedChanged: mainItem.cameraEnabled = !mainItem.cameraEnabled + onCheckedChanged: mainItem.localVideoEnabled = !mainItem.localVideoEnabled } CheckableButton { id: microButton diff --git a/Linphone/view/Item/Contact/ContactsList.qml b/Linphone/view/Item/Contact/ContactsList.qml index 710a4b85..bf928cbb 100644 --- a/Linphone/view/Item/Contact/ContactsList.qml +++ b/Linphone/view/Item/Contact/ContactsList.qml @@ -177,7 +177,7 @@ ListView { height: 24 * DefaultStyle.dp source: AppIcons.videoCamera } - onClicked: UtilsCpp.createCall(modelData.core.defaultAddress, {'cameraEnabled':true}) + onClicked: UtilsCpp.createCall(modelData.core.defaultAddress, {'localVideoEnabled':true}) } } PopupButton { diff --git a/Linphone/view/Item/Contact/Sticker.qml b/Linphone/view/Item/Contact/Sticker.qml index 3cf3e4f1..dc3b4410 100644 --- a/Linphone/view/Item/Contact/Sticker.qml +++ b/Linphone/view/Item/Contact/Sticker.qml @@ -31,8 +31,8 @@ Item { property string peerAddress:peerAddressObj ? peerAddressObj.value : "" property var identityAddress: account ? UtilsCpp.getDisplayName(account.core.identityAddress) : null - property bool cameraEnabled: (previewEnabled && call && call.core.cameraEnabled) - || (!previewEnabled && participantDevice && participantDevice.core.videoEnabled) + property bool videoEnabled: (previewEnabled && call && call.core.localVideoEnabled) + || (participantDevice && participantDevice.core.videoEnabled) property string qmlName Rectangle { @@ -86,7 +86,7 @@ Item { triggeredOnStart: true onTriggered: {cameraLoader.reset = !cameraLoader.reset} } - active: mainItem.visible && mainItem.cameraEnabled && !mainItem.reset + active: mainItem.visible && mainItem.videoEnabled && !mainItem.reset onActiveChanged: console.log("("+mainItem.qmlName+") Camera active " + active) sourceComponent: cameraComponent } diff --git a/Linphone/view/Item/Meeting/MeetingSetUp.qml b/Linphone/view/Item/Meeting/MeetingSetUp.qml index 03d10130..86583fa9 100644 --- a/Linphone/view/Item/Meeting/MeetingSetUp.qml +++ b/Linphone/view/Item/Meeting/MeetingSetUp.qml @@ -446,10 +446,8 @@ ColumnLayout { } Switch { text: qsTr("Send invitation to participants") - Component.onCompleted: { - console.log("TODO : handle send invitation to participants") - toggle() - } + checked: mainItem.conferenceInfoGui.core.inviteEnabled + onToggled: mainItem.conferenceInfoGui.core.inviteEnabled = checked } Item { Layout.fillHeight: true diff --git a/Linphone/view/Layout/Call/ActiveSpeakerLayout.qml b/Linphone/view/Layout/Call/ActiveSpeakerLayout.qml index cb5f2f25..977bfd7a 100644 --- a/Linphone/view/Layout/Call/ActiveSpeakerLayout.qml +++ b/Linphone/view/Layout/Call/ActiveSpeakerLayout.qml @@ -37,7 +37,7 @@ Item{ call: mainItem.call participantDevice: mainItem.conference && mainItem.conference.core.activeSpeaker property var address: participantDevice && participantDevice.core.address - cameraEnabled: call && call.core.remoteVideoEnabled + videoEnabled: (participantDevice && participantDevice.core.videoEnabled) || (!participantDevice && call && call.core.remoteVideoEnabled) qmlName: 'AS' Timer { @@ -113,8 +113,8 @@ Item{ anchors.rightMargin: 10 * DefaultStyle.dp anchors.bottomMargin: 10 * DefaultStyle.dp //participantDevice: allDevices.me - cameraEnabled: preview.visible && mainItem.call && mainItem.call.core.cameraEnabled - onCameraEnabledChanged: console.log("P : " +cameraEnabled + " / " +visible +" / " +mainItem.call) + videoEnabled: preview.visible && mainItem.call && mainItem.call.core.localVideoEnabled + onVideoEnabledChanged: console.log("P : " +videoEnabled + " / " +visible +" / " +mainItem.call) property AccountProxy accounts: AccountProxy{id: accountProxy} account: accountProxy.defaultAccount call: mainItem.call diff --git a/Linphone/view/Layout/Call/CallLayout.qml b/Linphone/view/Layout/Call/CallLayout.qml index 18e3b1d8..bafd1574 100644 --- a/Linphone/view/Layout/Call/CallLayout.qml +++ b/Linphone/view/Layout/Call/CallLayout.qml @@ -17,7 +17,13 @@ Item { property bool callTerminatedByUser: false readonly property var callState: call && call.core.state || undefined property int conferenceLayout: call && call.core.conferenceVideoLayout || 0 - onConferenceLayoutChanged:console.log("CallLayout change : " +conferenceLayout) + onConferenceLayoutChanged: { + console.log("CallLayout change : " +conferenceLayout) + callLayout.sourceComponent = undefined // unload old view before opening the new view to avoid conflicts in Video UI. + callLayout.sourceComponent = mainItem.conferenceLayout == LinphoneEnums.ConferenceLayout.ActiveSpeaker + ? activeSpeakerComponent + : gridComponent + } onCallStateChanged: if (callState === LinphoneEnums.CallState.End) { callTerminatedText.visible = true }else if( callState === LinphoneEnums.CallState.Error) { @@ -46,9 +52,7 @@ Item { id: callLayout Layout.Layout.fillWidth: true Layout.Layout.fillHeight: true - sourceComponent: mainItem.conferenceLayout == LinphoneEnums.ConferenceLayout.ActiveSpeaker - ? activeSpeakerComponent - : gridComponent + sourceComponent: gridComponent } Layout.ColumnLayout { id: userNotFoundLayout @@ -100,230 +104,4 @@ Item { // Layout.preferredHeight: 47 * DefaultStyle.dp // } // } - /* - Sticker { - id: preview - visible: mainItem.callState != LinphoneEnums.CallState.End - && mainItem.callState != LinphoneEnums.CallState.Released - height: 180 * DefaultStyle.dp - width: 300 * DefaultStyle.dp - anchors.right: mainItem.right - anchors.bottom: mainItem.bottom - anchors.rightMargin: 10 * DefaultStyle.dp - anchors.bottomMargin: 10 * DefaultStyle.dp - AccountProxy{ - id: accounts - } - account: accounts.defaultAccount - previewEnabled: mainItem.call.core.cameraEnabled - - MovableMouseArea { - id: previewMouseArea - anchors.fill: parent - // visible: mainItem.participantCount <= 2 - movableArea: mainItem - margin: 10 * DefaultStyle.dp - function resetPosition(){ - preview.anchors.right = mainItem.right - preview.anchors.bottom = mainItem.bottom - preview.anchors.rightMargin = previewMouseArea.margin - preview.anchors.bottomMargin = previewMouseArea.margin - } - onVisibleChanged: if(!visible){ - resetPosition() - } - drag.target: preview - onDraggingChanged: if(dragging) { - preview.anchors.right = undefined - preview.anchors.bottom = undefined - } - onRequestResetPosition: resetPosition() - } - } - - property int previousWidth - Component.onCompleted: { - previousWidth = width - } - onWidthChanged: { - if (width < previousWidth) { - previewMouseArea.updatePosition(0, 0) - } else { - previewMouseArea.updatePosition(width - previousWidth, 0) - } - previousWidth = width - }*/ - -/* - -Item { - id: mainItem - property CallModel callModel - property bool isRightReducedLayout: false - property bool isLeftReducedLayout: false - property bool cameraEnabled: true - property bool isConference: callModel && callModel.isConference - property bool isConferenceReady: isConference && callModel.conferenceModel && callModel.conferenceModel.isReady - - property int participantCount: isConference ? allDevices.count + 1 : 2 // +me. allDevices==0 if !conference - - property ParticipantDeviceProxyModel participantDevices : ParticipantDeviceProxyModel { - id: allDevices - callModel: mainItem.callModel - showMe: false - - onConferenceCreated: cameraView.resetCamera() - } - - Sticker{ - id: cameraView - anchors.fill: parent - anchors.leftMargin: isRightReducedLayout || isLeftReducedLayout? 30 : 140 - anchors.rightMargin: isRightReducedLayout ? 10 : 140 - cameraQmlName: 'AS' - callModel: mainItem.callModel - currentDevice: isPreview - ? allDevices.me - : mainItem.isConference - ? allDevices.activeSpeaker - : null - deactivateCamera: !mainItem.cameraEnabled || (isPreview && callModel.pausedByUser) - ? true - : mainItem.isConference - ? (callModel && (callModel.pausedByUser || callModel.status === CallModel.CallStatusPaused) ) - || (!(callModel && callModel.cameraEnabled) && mainItem.participantCount == 1) - || (currentDevice && !currentDevice.videoEnabled)// && mainItem.participantCount == 2) - || !mainItem.isConferenceReady - : (callModel && (callModel.pausedByUser || callModel.status === CallModel.CallStatusPaused || !callModel.videoEnabled) ) - || currentDevice && !currentDevice.videoEnabled - isPreview: !preview.visible && mainItem.participantCount == 1 - onIsPreviewChanged: {cameraView.resetCamera() } - isCameraFromDevice: isPreview - isPaused: isPreview && callModel.pausedByUser - ? false - : mainItem.isConference - ? //callModel && callModel.pausedByUser && mainItem.participantCount != 2 || - (currentDevice && currentDevice.isPaused) - : callModel && !callModel.pausedByUser && (callModel.status === CallModel.CallStatusPaused) - - quickTransition: true - showCloseButton: false - showActiveSpeakerOverlay: false // This is an active speaker. We don't need to show the indicator. - showCustomButton: false - avatarStickerBackgroundColor: isPreview ? IncallStyle.container.avatar.stickerPreviewBackgroundColor.color : IncallStyle.container.avatar.stickerBackgroundColor.color - avatarBackgroundColor: IncallStyle.container.avatar.backgroundColor.color - } - Item{// Need an item to not override Sticker internal states. States are needed for changing anchors. - id: preview - anchors.right: parent.right - anchors.bottom: parent.bottom - anchors.rightMargin: 30 - anchors.bottomMargin: 15 - - height: visible ? miniViews.cellHeight : 0 - width: 16 * height / 9 - - visible: mainItem.isConferenceReady && allDevices.count >= 1 - || (!mainItem.isConference && mainItem.callModel && mainItem.callModel.cameraEnabled)// use videoEnabled if we want to show the preview sticker - - Loader{ - anchors.fill: parent - anchors.margins: 3 - sourceComponent: - Sticker{ - id: previewSticker - cameraQmlName: 'AS_Preview' - deactivateCamera: !mainItem.cameraEnabled || !mainItem.callModel || callModel.pausedByUser || !mainItem.callModel.cameraEnabled - currentDevice: allDevices.me - isPreview: true - callModel: mainItem.callModel - isCameraFromDevice: true - showCloseButton: false - showCustomButton: false - showAvatarBorder: true - avatarStickerBackgroundColor: IncallStyle.container.avatar.stickerPreviewBackgroundColor.color - avatarBackgroundColor: IncallStyle.container.avatar.backgroundColor.color - } - active: parent.visible - } - - MovableMouseArea{ - id: dragger - anchors.fill: parent - visible: mainItem.participantCount <= 2 - function resetPosition(){ - preview.anchors.right = mainItem.right - preview.anchors.bottom = mainItem.bottom - } - onVisibleChanged: if(!visible){ - resetPosition() - } - drag.target: preview - onDraggingChanged: if(dragging){ - preview.anchors.right = undefined - preview.anchors.bottom = undefined - } - onRequestResetPosition: resetPosition() - } - } - - Item{ - id: miniViewArea - anchors.right: parent.right - anchors.top: parent.top - anchors.bottom: preview.top - anchors.rightMargin: 30 - anchors.topMargin: 15 - anchors.bottomMargin: 0 -//--------------- - width: 16 * miniViews.cellHeight / 9 - visible: mainItem.isConferenceReady || !mainItem.isConference - property int heightLeft: parent.height - preview.height - onHeightLeftChanged: {Qt.callLater(miniViewArea.forceRefresh)} - function forceRefresh(){// Force a content refresh via margins. Qt is buggy when managing sizes in ListView. - ++miniViewArea.anchors.topMargin - --miniViewArea.anchors.topMargin - } - - ScrollableListView{ - id: miniViews - property int cellHeight: 150 - anchors.fill: parent - model : mainItem.isConference && mainItem.participantDevices.count > 1 ? mainItem.participantDevices : [] - spacing: 0 - verticalLayoutDirection: ListView.BottomToTop - fitCacheToContent: false - property int oldCount : 0// Count changed can be called without a change... (bug?). Use oldCount to avoid it. - onCountChanged: {if(oldCount != count){ oldCount = count ; Qt.callLater(miniViewArea.forceRefresh)}} - Component.onCompleted: {Qt.callLater(miniViewArea.forceRefresh)} - delegate:Item{ - height: visible ? miniViews.cellHeight + 15 : 0 - width: visible ? miniViews.width : 0 - visible: cameraView.currentDevice != modelData - clip:false - Sticker{ - id: miniView - anchors.fill: parent - anchors.topMargin: 3 - anchors.leftMargin: 3 - anchors.rightMargin: 3 - anchors.bottomMargin: 18 - cameraQmlName: 'S_'+index - deactivateCamera: (!mainItem.isConferenceReady || !mainItem.isConference) - && (index <0 || !mainItem.cameraEnabled || (!modelData.videoEnabled) || (callModel && callModel.pausedByUser) ) - currentDevice: modelData.isPreview ? null : modelData - callModel: modelData.isPreview ? null : mainItem.callModel - isCameraFromDevice: mainItem.isConference - isPaused: currentDevice && currentDevice.isPaused - showCloseButton: false - showCustomButton: false - showAvatarBorder: true - avatarStickerBackgroundColor: IncallStyle.container.avatar.stickerBackgroundColor.color - avatarBackgroundColor: IncallStyle.container.avatar.backgroundColor.color - } - } - } - } -} -*/ diff --git a/Linphone/view/Layout/Call/GridLayout.qml b/Linphone/view/Layout/Call/GridLayout.qml index f1e535ad..3aaf1f44 100644 --- a/Linphone/view/Layout/Call/GridLayout.qml +++ b/Linphone/view/Layout/Call/GridLayout.qml @@ -9,7 +9,7 @@ import Linphone Mosaic { id: grid property alias call: allDevices.currentCall - property bool cameraEnabled: true + property bool videoEnabled: true property int participantCount: gridModel.count // On grid view, we limit the quality if there are enough participants// The vga mode has been activated from the factory rc diff --git a/Linphone/view/Layout/Conference/IncallGrid.qml b/Linphone/view/Layout/Conference/IncallGrid.qml index 3b2cb19b..b2f5a1a4 100644 --- a/Linphone/view/Layout/Conference/IncallGrid.qml +++ b/Linphone/view/Layout/Conference/IncallGrid.qml @@ -22,7 +22,7 @@ import 'qrc:/ui/scripts/Utils/utils.js' as Utils Mosaic { id: grid property alias callModel: participantDevices.callModel - property bool cameraEnabled: true + property bool videoEnabled: true property int participantCount: gridModel.count // On grid view, we limit the quality if there are enough participants// The vga mode has been activated from the factory rc @@ -50,7 +50,7 @@ Mosaic { cameraQmlName: 'G_'+index callModel: index >= 0 ? participantDevices.callModel : null // do this before to prioritize changing call on remove - deactivateCamera: index <0 || !grid.cameraEnabled || grid.callModel.pausedByUser + deactivateCamera: index <0 || !grid.videoEnabled || grid.callModel.pausedByUser currentDevice: gridModel.participantDevices.getAt(index) isCameraFromDevice: true diff --git a/Linphone/view/Layout/Contact/ContactLayout.qml b/Linphone/view/Layout/Contact/ContactLayout.qml index f975f3d6..e212e68b 100644 --- a/Linphone/view/Layout/Contact/ContactLayout.qml +++ b/Linphone/view/Layout/Contact/ContactLayout.qml @@ -152,8 +152,7 @@ ColumnLayout { label: qsTr("Appel Video") button.onClicked: { var addr = UtilsCpp.generateLinphoneSipAddress(mainItem.contactAddress) - UtilsCpp.createCall(addr) - console.log("[CallPage.qml] TODO : enable video") + UtilsCpp.createCall(addr, {'localVideoEnabled':true}) } } }