Skip to content
Snippets Groups Projects
Commit f238b9d8 authored by Aline Gondim Santos's avatar Aline Gondim Santos Committed by Sébastien Blin
Browse files

x11: window sharing

GitLab: jami-project#1294

Change-Id: I6dfaea6c65323d072536518f3ac7abc426d33efd
parent 3fe379ca
No related branches found
No related tags found
No related merge requests found
......@@ -239,6 +239,60 @@ AvAdapter::shareScreenArea(unsigned x, unsigned y, unsigned width, unsigned heig
#endif
}
void
AvAdapter::shareWindow(const QString& windowId)
{
auto resource = lrcInstance_->getCurrentCallModel()->getDisplay(windowId);
auto callId = lrcInstance_->getCurrentCallId();
lrcInstance_->getCurrentCallModel()
->requestMediaChange(callId,
"video_0",
resource,
lrc::api::NewCallModel::MediaRequestType::SCREENSHARING,
false);
set_currentRenderingDeviceType(
lrcInstance_->getCurrentCallModel()->getCurrentRenderedDevice(callId).type);
}
QString
AvAdapter::getSharingResource(int screenId = -2, const QString& windowId = "")
{
if (screenId == -1) {
const auto arrangementRect = getAllScreensBoundingRect();
return lrcInstance_->getCurrentCallModel()->getDisplay(getScreenNumber(),
arrangementRect.x(),
arrangementRect.y(),
arrangementRect.width(),
arrangementRect.height());
} else if (screenId > -1) {
QScreen* screen = QGuiApplication::screens().at(screenId);
if (!screen)
return "";
QRect rect = screen->geometry();
return lrcInstance_->getCurrentCallModel()->getDisplay(getScreenNumber(),
rect.x(),
rect.y(),
rect.width()
* screen->devicePixelRatio(),
rect.height()
* screen->devicePixelRatio());
} else if (!windowId.isEmpty()) {
return lrcInstance_->getCurrentCallModel()->getDisplay(windowId);
}
return "";
}
void
AvAdapter::getListWindows()
{
auto map = lrcInstance_->avModel().getListWindows();
set_windowsNames(map.keys());
set_windowsIds(map.values());
}
void
AvAdapter::stopSharing()
{
......
......@@ -31,6 +31,8 @@ class AvAdapter final : public QmlAdapterBase
Q_OBJECT
QML_RO_PROPERTY(lrc::api::video::DeviceType, currentRenderingDeviceType)
QML_PROPERTY(bool, muteCamera)
QML_RO_PROPERTY(QStringList, windowsNames)
QML_RO_PROPERTY(QList<QVariant>, windowsIds)
public:
explicit AvAdapter(LRCInstance* instance, QObject* parent = nullptr);
......@@ -62,6 +64,14 @@ protected:
// Select screen area to display (from all screens).
Q_INVOKABLE void shareScreenArea(unsigned x, unsigned y, unsigned width, unsigned height);
// Select window to display.
Q_INVOKABLE void shareWindow(const QString& windowId);
// Returns the screensharing resource
Q_INVOKABLE QString getSharingResource(int screenId, const QString& key);
Q_INVOKABLE void getListWindows();
// Stop sharing the screen or file
Q_INVOKABLE void stopSharing();
......
......@@ -495,6 +495,9 @@ Item {
// SelectScreen
property string selectScreen: qsTr("Select a screen to share")
property string allScreens: qsTr("All Screens")
property string screens: qsTr("Screens")
property string windows: qsTr("Windows")
// UserProfile
property string qrCode: qsTr("QR code")
......
......@@ -132,7 +132,7 @@ Item {
property color recordIconColor: "#dc2719"
property color successLabelColor: "#2b5084"
property color rubberBandSelectionBlue: "steelblue"
property color screenSelectionBorderGreen: "green"
property color screenSelectionBorderColor: raiseHandColor
property color separationLine: darkTheme ? selectedColor : backgroundColor
// Plugin Preferences View
......
......@@ -184,12 +184,7 @@ Control {
},
Action {
id: muteVideoAction
onTriggered: {
if (AvAdapter.currentRenderingDeviceType === Video.DeviceType.DISPLAY || AvAdapter.currentRenderingDeviceType === Video.DeviceType.FILE) {
AvAdapter.stopSharing()
} else
CallAdapter.videoPauseThisCallToggle(!isVideoMuted)
}
onTriggered: CallAdapter.videoPauseThisCallToggle(!isVideoMuted)
checkable: true
icon.source: checked ?
JamiResources.videocam_off_24dp_svg :
......
......@@ -169,11 +169,12 @@ Item {
if (AvAdapter.currentRenderingDeviceType !== Video.DeviceType.DISPLAY && AvAdapter.currentRenderingDeviceType !== Video.DeviceType.FILE) {
AvAdapter.muteCamera = root.isVideoMuted
}
if (Qt.application.screens.length === 1) {
AvAdapter.getListWindows()
if (Qt.application.screens.length + AvAdapter.windowsNames.length === 1) {
AvAdapter.shareEntireScreen(0)
} else {
SelectScreenWindowCreation.createSelectScreenWindowObject()
SelectScreenWindowCreation.showSelectScreenWindow()
SelectScreenWindowCreation.showSelectScreenWindow(callPreviewId)
}
}
......
......@@ -119,11 +119,12 @@ ContextMenuAutoLoader {
if (AvAdapter.currentRenderingDeviceType !== Video.DeviceType.DISPLAY && AvAdapter.currentRenderingDeviceType !== Video.DeviceType.FILE) {
AvAdapter.muteCamera = root.isVideoMuted
}
if (Qt.application.screens.length === 1) {
AvAdapter.getListWindows()
if (Qt.application.screens.length + AvAdapter.windowsNames().length === 1) {
AvAdapter.shareEntireScreen(0)
} else {
SelectScreenWindowCreation.createSelectScreenWindowObject()
SelectScreenWindowCreation.showSelectScreenWindow()
SelectScreenWindowCreation.showSelectScreenWindow(callPreviewId)
}
}
},
......
This diff is collapsed.
......@@ -43,7 +43,9 @@ function finishCreation() {
selectScreenWindowObject.onClosing.connect(destroySelectScreenWindow)
}
function showSelectScreenWindow() {
function showSelectScreenWindow(previewId) {
console.log("previewId", previewId)
selectScreenWindowObject.currentPreview = previewId
selectScreenWindowObject.show()
var screen = selectScreenWindowObject.screen
......
......@@ -290,7 +290,6 @@ VideoDevices::getDefaultDevice()
return rendererId;
}
#pragma optimize("", off)
QString
VideoDevices::startDevice(const QString& deviceId, bool force)
{
......@@ -310,7 +309,6 @@ VideoDevices::stopDevice(const QString& deviceId, bool force)
deviceOpen_ = false;
}
}
#pragma optimize("", on)
void
VideoDevices::setDefaultDeviceRes(int index)
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment