diff --git a/src/avadapter.cpp b/src/avadapter.cpp index ef3f8b096984098113ab306075479ce965c8a50c..cf8737d5d96c6c1d800b9ef9559d9e64c269d096 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 6f4236cd0188856fcd74755d37d8dd0a6c216b44..42b2cc4aaca9843f3063ff996e9611c2b47abadf 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 00b7355c1f8e2a198c96ccc72eb1688d2bbe0204..1187ef6c8af8a86615bbfd5d452a91ad8438db31 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 0eae57dcaecf090cff9e4e0ecb0a3e0f54fd3e55..4d3e565350aaee1ce643ba35cd21c910882b54e7 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 bee08de2b6ba7a31238c85307ef851f26f72aabd..d3449b110856b0c6cd2e987113fde3fdb28c6ee5 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: {