From 021ab43dfef406b97fe86dc49c1973eea62db18f Mon Sep 17 00:00:00 2001 From: agsantos <aline.gondimsantos@savoirfairelinux.com> Date: Tue, 19 Oct 2021 15:24:19 -0400 Subject: [PATCH] calls: file/screen sharing in audio only calls GitLab: #499 Change-Id: I76754b4b32cde4cf8445c6058649aab912d7a0b4 --- src/avadapter.cpp | 94 ++++++++++++++----- src/calladapter.cpp | 18 +++- src/calladapter.h | 4 +- src/mainview/components/CallActionBar.qml | 14 +-- .../components/CallViewContextMenu.qml | 11 +-- 5 files changed, 96 insertions(+), 45 deletions(-) diff --git a/src/avadapter.cpp b/src/avadapter.cpp index ef3f8b096..cf8737d5d 100644 --- a/src/avadapter.cpp +++ b/src/avadapter.cpp @@ -91,12 +91,19 @@ AvAdapter::shareEntireScreen(int screenNumber) return; QRect rect = screen->geometry(); - lrcInstance_->avModel().setDisplay(getScreenNumber(), + auto resource = lrcInstance_->avModel().getDisplay(getScreenNumber(), rect.x(), rect.y(), rect.width() * screen->devicePixelRatio(), - rect.height() * screen->devicePixelRatio(), - lrcInstance_->getCurrentCallId()); + rect.height() * screen->devicePixelRatio()); + auto callId = lrcInstance_->getCurrentCallId(); + lrcInstance_->getCurrentCallModel()->requestMediaChange(callId, + "video_0", + resource, + lrc::api::NewCallModel::MediaRequestType::SCREENSHARING, + false); + set_currentRenderingDeviceType( + lrcInstance_->avModel().getCurrentRenderedDevice(callId).type); } void @@ -104,12 +111,19 @@ AvAdapter::shareAllScreens() { const auto arrangementRect = getAllScreensBoundingRect(); - lrcInstance_->avModel().setDisplay(getScreenNumber(), - arrangementRect.x(), - arrangementRect.y(), - arrangementRect.width(), - arrangementRect.height(), - lrcInstance_->getCurrentCallId()); + auto resource = lrcInstance_->avModel().getDisplay(getScreenNumber(), + arrangementRect.x(), + arrangementRect.y(), + arrangementRect.width(), + arrangementRect.height()); + auto callId = lrcInstance_->getCurrentCallId(); + lrcInstance_->getCurrentCallModel()->requestMediaChange(callId, + "video_0", + resource, + lrc::api::NewCallModel::MediaRequestType::SCREENSHARING, + false); + set_currentRenderingDeviceType( + lrcInstance_->avModel().getCurrentRenderedDevice(callId).type); } void @@ -169,7 +183,17 @@ AvAdapter::captureAllScreens() void AvAdapter::shareFile(const QString& filePath) { - lrcInstance_->avModel().setInputFile(filePath, lrcInstance_->getCurrentCallId()); + auto callId = lrcInstance_->getCurrentCallId(); + if (!callId.isEmpty()) { + lrcInstance_->getCurrentCallModel() + ->requestMediaChange(callId, + "video_0", + filePath, + lrc::api::NewCallModel::MediaRequestType::FILESHARING, + false); + set_currentRenderingDeviceType( + lrcInstance_->avModel().getCurrentRenderedDevice(callId).type); + } } void @@ -182,21 +206,34 @@ AvAdapter::shareScreenArea(unsigned x, unsigned y, unsigned width, unsigned heig QTimer::singleShot(100, [=]() mutable { x = y = width = height = 0; xrectsel(&x, &y, &width, &height); - - lrcInstance_->avModel().setDisplay(getScreenNumber(), - x, - y, - width < 128 ? 128 : width, - height < 128 ? 128 : height, - lrcInstance_->getCurrentCallId()); + auto resource = lrcInstance_->avModel().getDisplay(getScreenNumber(), + x, + y, + width < 128 ? 128 : width, + height < 128 ? 128 : height); + auto callId = lrcInstance_->getCurrentCallId(); + lrcInstance_->getCurrentCallModel()->requestMediaChange(callId, + "video_0", + resource, + lrc::api::NewCallModel::MediaRequestType::SCREENSHARING, + false); + set_currentRenderingDeviceType( + lrcInstance_->avModel().getCurrentRenderedDevice(callId).type); }); #else - lrcInstance_->avModel().setDisplay(getScreenNumber(), - x, - y, - width < 128 ? 128 : width, - height < 128 ? 128 : height, - lrcInstance_->getCurrentCallId()); + auto resource = lrcInstance_->avModel().getDisplay(getScreenNumber(), + x, + y, + width < 128 ? 128 : width, + height < 128 ? 128 : height); + auto callId = lrcInstance_->getCurrentCallId(); + lrcInstance_->getCurrentCallModel()->requestMediaChange(callId, + "video_0", + resource, + lrc::api::NewCallModel::MediaRequestType::SCREENSHARING, + false); + set_currentRenderingDeviceType( + lrcInstance_->avModel().getCurrentRenderedDevice(callId).type); #endif } @@ -204,9 +241,18 @@ void AvAdapter::stopSharing() { auto callId = lrcInstance_->getCurrentCallId(); - if (!callId.isEmpty()) + if (!callId.isEmpty()) { + lrcInstance_->getCurrentCallModel() + ->requestMediaChange(callId, + "video_0", + lrcInstance_->avModel().getCurrentVideoCaptureDevice(), + lrc::api::NewCallModel::MediaRequestType::CAMERA, + false); lrcInstance_->avModel().switchInputTo(lrcInstance_->avModel().getCurrentVideoCaptureDevice(), callId); + set_currentRenderingDeviceType( + lrcInstance_->avModel().getCurrentRenderedDevice(callId).type); + } } void diff --git a/src/calladapter.cpp b/src/calladapter.cpp index 6f4236cd0..42b2cc4aa 100644 --- a/src/calladapter.cpp +++ b/src/calladapter.cpp @@ -650,7 +650,7 @@ CallAdapter::updateCallOverlay(const lrc::api::conversation::Info& convInfo) bool isPaused = call->status == lrc::api::call::Status::PAUSED; bool isAudioOnly = call->isAudioOnly && !isPaused; bool isAudioMuted = call->audioMuted && (call->status != lrc::api::call::Status::PAUSED); - bool isVideoMuted = call->videoMuted && !isPaused && !call->isAudioOnly; + bool isVideoMuted = call->videoMuted && !isPaused; bool isRecording = isRecordingThisCall(); bool isConferenceCall = !convInfo.confId.isEmpty() || (convInfo.confId.isEmpty() && call->participantsInfos.size() != 0); @@ -959,7 +959,7 @@ CallAdapter::holdThisCallToggle() } void -CallAdapter::muteThisCallToggle() +CallAdapter::muteThisCallToggle(bool mute) { const auto callId = lrcInstance_->getCallIdForConversationUid(convUid_, accountId_); if (callId.isEmpty() || !lrcInstance_->getCurrentCallModel()->hasCall(callId)) { @@ -967,7 +967,11 @@ CallAdapter::muteThisCallToggle() } auto* callModel = lrcInstance_->getCurrentCallModel(); if (callModel->hasCall(callId)) { - callModel->requestMediaChange(callId, "audio_0"); + callModel->requestMediaChange(callId, + "audio_0", + lrcInstance_->avModel().getCurrentVideoCaptureDevice(), + lrc::api::NewCallModel::MediaRequestType::CAMERA, + mute); } } @@ -985,7 +989,7 @@ CallAdapter::recordThisCallToggle() } void -CallAdapter::videoPauseThisCallToggle() +CallAdapter::videoPauseThisCallToggle(bool mute) { const auto callId = lrcInstance_->getCallIdForConversationUid(convUid_, accountId_); if (callId.isEmpty() || !lrcInstance_->getCurrentCallModel()->hasCall(callId)) { @@ -993,7 +997,11 @@ CallAdapter::videoPauseThisCallToggle() } auto* callModel = lrcInstance_->getCurrentCallModel(); if (callModel->hasCall(callId)) { - callModel->requestMediaChange(callId, "video_0"); + callModel->requestMediaChange(callId, + "video_0", + lrcInstance_->avModel().getCurrentVideoCaptureDevice(), + lrc::api::NewCallModel::MediaRequestType::CAMERA, + mute); // media label should come from qml // also thi function can me emrged with "muteThisCallToggle" } diff --git a/src/calladapter.h b/src/calladapter.h index 00b7355c1..1187ef6c8 100644 --- a/src/calladapter.h +++ b/src/calladapter.h @@ -69,9 +69,9 @@ public: Q_INVOKABLE bool isModerator(const QString& uri = {}) const; Q_INVOKABLE bool isCurrentModerator() const; Q_INVOKABLE void holdThisCallToggle(); - Q_INVOKABLE void muteThisCallToggle(); + Q_INVOKABLE void muteThisCallToggle(bool mute); Q_INVOKABLE void recordThisCallToggle(); - Q_INVOKABLE void videoPauseThisCallToggle(); + Q_INVOKABLE void videoPauseThisCallToggle(bool mute); Q_INVOKABLE bool isRecordingThisCall(); Q_INVOKABLE QVariantList getConferencesInfos(); Q_INVOKABLE void muteParticipant(const QString& uri, const bool state); diff --git a/src/mainview/components/CallActionBar.qml b/src/mainview/components/CallActionBar.qml index 0eae57dca..4d3e56535 100644 --- a/src/mainview/components/CallActionBar.qml +++ b/src/mainview/components/CallActionBar.qml @@ -156,7 +156,7 @@ Control { property list<Action> primaryActions: [ Action { id: muteAudioAction - onTriggered: CallAdapter.muteThisCallToggle() + onTriggered: CallAdapter.muteThisCallToggle(!isAudioMuted) checkable: true icon.source: checked ? JamiResources.mic_off_24dp_svg : @@ -175,7 +175,7 @@ Control { }, Action { id: muteVideoAction - onTriggered: CallAdapter.videoPauseThisCallToggle() + onTriggered: CallAdapter.videoPauseThisCallToggle(!isVideoMuted) checkable: true icon.source: checked ? JamiResources.videocam_off_24dp_svg : @@ -237,17 +237,17 @@ Control { Action { id: shareAction onTriggered: { - if (AvAdapter.currentRenderingDeviceType === Video.DeviceType.DISPLAY) + if (AvAdapter.currentRenderingDeviceType === Video.DeviceType.DISPLAY || AvAdapter.currentRenderingDeviceType === Video.DeviceType.FILE) root.stopSharingClicked() else root.shareScreenClicked() } - icon.source: AvAdapter.currentRenderingDeviceType === Video.DeviceType.DISPLAY ? + icon.source: AvAdapter.currentRenderingDeviceType === Video.DeviceType.DISPLAY || AvAdapter.currentRenderingDeviceType === Video.DeviceType.FILE ? JamiResources.share_stop_black_24dp_svg : JamiResources.share_screen_black_24dp_svg - icon.color: AvAdapter.currentRenderingDeviceType === Video.DeviceType.DISPLAY ? + icon.color: AvAdapter.currentRenderingDeviceType === Video.DeviceType.DISPLAY || AvAdapter.currentRenderingDeviceType === Video.DeviceType.FILE ? "red" : "white" - text: AvAdapter.currentRenderingDeviceType === Video.DeviceType.DISPLAY ? + text: AvAdapter.currentRenderingDeviceType === Video.DeviceType.DISPLAY || AvAdapter.currentRenderingDeviceType === Video.DeviceType.FILE ? JamiStrings.stopSharing : JamiStrings.shareScreen property real size: 34 @@ -308,7 +308,7 @@ Control { CallOverlayModel.addSecondaryControl(callTransferAction) } CallOverlayModel.addSecondaryControl(chatAction) - if (!isAudioOnly && !isSIP) + if (!isSIP) CallOverlayModel.addSecondaryControl(shareAction) CallOverlayModel.addSecondaryControl(recordAction) CallOverlayModel.addSecondaryControl(pluginsAction) diff --git a/src/mainview/components/CallViewContextMenu.qml b/src/mainview/components/CallViewContextMenu.qml index bee08de2b..d3449b110 100644 --- a/src/mainview/components/CallViewContextMenu.qml +++ b/src/mainview/components/CallViewContextMenu.qml @@ -101,8 +101,7 @@ ContextMenuAutoLoader { GeneralMenuItem { id: stopSharing - canTrigger: !isAudioOnly - && AvAdapter.currentRenderingDeviceType === Video.DeviceType.DISPLAY + canTrigger: AvAdapter.currentRenderingDeviceType === Video.DeviceType.DISPLAY && !isSIP itemName: JamiStrings.stopSharing iconSource: JamiResources.share_stop_black_24dp_svg @@ -114,8 +113,7 @@ ContextMenuAutoLoader { GeneralMenuItem { id: shareScreen - canTrigger: !isAudioOnly - && AvAdapter.currentRenderingDeviceType !== Video.DeviceType.DISPLAY + canTrigger: AvAdapter.currentRenderingDeviceType !== Video.DeviceType.DISPLAY && !isSIP itemName: JamiStrings.shareScreen iconSource: JamiResources.share_screen_black_24dp_svg @@ -131,8 +129,7 @@ ContextMenuAutoLoader { GeneralMenuItem { id: shareScreenArea - canTrigger: !isAudioOnly - && AvAdapter.currentRenderingDeviceType !== Video.DeviceType.DISPLAY + canTrigger: AvAdapter.currentRenderingDeviceType !== Video.DeviceType.DISPLAY && !isSIP itemName: JamiStrings.shareScreenArea iconSource: JamiResources.share_screen_black_24dp_svg @@ -148,7 +145,7 @@ ContextMenuAutoLoader { GeneralMenuItem { id: shareFile - canTrigger: !isAudioOnly && !isSIP + canTrigger: !isSIP itemName: JamiStrings.shareFile iconSource: JamiResources.insert_photo_24dp_svg onClicked: { -- GitLab