2020-09-04 17:53:24 -04:00
|
|
|
/*!
|
2023-02-06 01:47:15 -05:00
|
|
|
* Copyright (C) 2020-2023 Savoir-faire Linux Inc.
|
2020-08-03 13:27:42 -04:00
|
|
|
* Author: Mingrui Zhang <mingrui.zhang@savoirfairelinux.com>
|
|
|
|
*
|
|
|
|
* This program is free software; you can redistribute it and/or modify
|
|
|
|
* it under the terms of the GNU General Public License as published by
|
|
|
|
* the Free Software Foundation; either version 3 of the License, or
|
|
|
|
* (at your option) any later version.
|
|
|
|
*
|
|
|
|
* This program is distributed in the hope that it will be useful,
|
|
|
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
|
|
* GNU General Public License for more details.
|
|
|
|
*
|
|
|
|
* You should have received a copy of the GNU General Public License
|
|
|
|
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
|
|
|
*/
|
|
|
|
|
|
|
|
#pragma once
|
|
|
|
|
|
|
|
#include "qmladapterbase.h"
|
2021-05-26 17:58:50 -04:00
|
|
|
#include "lrcinstance.h"
|
2020-08-03 13:27:42 -04:00
|
|
|
|
|
|
|
#include <QObject>
|
|
|
|
#include <QVariant>
|
|
|
|
#include <QString>
|
2021-05-26 17:58:50 -04:00
|
|
|
#include <qtutils.h>
|
2020-08-03 13:27:42 -04:00
|
|
|
|
2022-11-21 17:46:41 -05:00
|
|
|
#include "rendererinformationlistmodel.h"
|
|
|
|
|
2020-09-03 09:24:49 -04:00
|
|
|
class AvAdapter final : public QmlAdapterBase
|
2020-08-03 13:27:42 -04:00
|
|
|
{
|
|
|
|
Q_OBJECT
|
2022-02-11 09:25:33 -05:00
|
|
|
// TODO: currentRenderingDeviceType is only used in QML to check if
|
|
|
|
// we're sharing or not, so it should maybe just be a boolean.
|
2021-08-31 10:37:11 -04:00
|
|
|
QML_RO_PROPERTY(lrc::api::video::DeviceType, currentRenderingDeviceType)
|
2022-02-11 09:25:33 -05:00
|
|
|
QML_RO_PROPERTY(QString, currentRenderingDeviceId)
|
2021-11-03 14:41:55 -04:00
|
|
|
QML_PROPERTY(bool, muteCamera)
|
2021-11-17 19:11:18 -05:00
|
|
|
QML_RO_PROPERTY(QStringList, windowsNames)
|
|
|
|
QML_RO_PROPERTY(QList<QVariant>, windowsIds)
|
2022-11-21 17:46:41 -05:00
|
|
|
QML_RO_PROPERTY(QVariant, renderersInfoList)
|
2020-08-03 13:27:42 -04:00
|
|
|
|
|
|
|
public:
|
2021-03-30 14:22:39 -04:00
|
|
|
explicit AvAdapter(LRCInstance* instance, QObject* parent = nullptr);
|
2020-09-03 09:24:49 -04:00
|
|
|
~AvAdapter() = default;
|
|
|
|
|
2021-03-29 16:51:53 -04:00
|
|
|
Q_SIGNALS:
|
2020-11-26 15:05:01 +01:00
|
|
|
void screenCaptured(int screenNumber, QString source);
|
2021-08-31 10:37:11 -04:00
|
|
|
// TODO: move to future audio device class
|
|
|
|
void audioDeviceListChanged(int inputs, int outputs);
|
2020-11-26 15:05:01 +01:00
|
|
|
|
2020-09-03 09:24:49 -04:00
|
|
|
protected:
|
|
|
|
void safeInit() override {};
|
2020-08-03 13:27:42 -04:00
|
|
|
|
2022-06-09 11:20:24 -04:00
|
|
|
/**
|
|
|
|
* Check if user is sharing a media
|
|
|
|
*/
|
|
|
|
Q_INVOKABLE bool isSharing() const;
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Check if user is showing a camera
|
|
|
|
*/
|
|
|
|
Q_INVOKABLE bool isCapturing() const;
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Check if user has a camera (even muted)
|
|
|
|
*/
|
|
|
|
Q_INVOKABLE bool hasCamera() const;
|
|
|
|
|
2021-03-11 13:30:45 -05:00
|
|
|
// Share the screen specificed by screen number.
|
2020-08-03 13:27:42 -04:00
|
|
|
Q_INVOKABLE void shareEntireScreen(int screenNumber);
|
|
|
|
|
2021-03-11 13:30:45 -05:00
|
|
|
// Share the all screens connected.
|
2020-11-26 15:05:01 +01:00
|
|
|
Q_INVOKABLE void shareAllScreens();
|
|
|
|
|
2021-03-11 13:30:45 -05:00
|
|
|
// Take snap shot of the screen and return emitting signal.
|
2020-11-26 15:05:01 +01:00
|
|
|
Q_INVOKABLE void captureScreen(int screenNumber);
|
|
|
|
|
2021-03-11 13:30:45 -05:00
|
|
|
// Take snap shot of the all screens and return by emitting signal.
|
2020-11-26 15:05:01 +01:00
|
|
|
Q_INVOKABLE void captureAllScreens();
|
2020-08-03 13:27:42 -04:00
|
|
|
|
2021-03-11 13:30:45 -05:00
|
|
|
// Share a media file.
|
2020-09-10 17:40:51 -04:00
|
|
|
Q_INVOKABLE void shareFile(const QString& filePath);
|
2020-08-03 13:27:42 -04:00
|
|
|
|
2021-03-11 13:30:45 -05:00
|
|
|
// Select screen area to display (from all screens).
|
2020-11-26 15:05:01 +01:00
|
|
|
Q_INVOKABLE void shareScreenArea(unsigned x, unsigned y, unsigned width, unsigned height);
|
2020-09-30 14:54:25 -04:00
|
|
|
|
2021-11-17 19:11:18 -05:00
|
|
|
// Select window to display.
|
2023-01-10 15:52:36 -03:00
|
|
|
Q_INVOKABLE void shareWindow(const QString& windowProcessId, const QString& windowId);
|
2021-11-17 19:11:18 -05:00
|
|
|
|
|
|
|
// Returns the screensharing resource
|
2023-01-10 15:52:36 -03:00
|
|
|
Q_INVOKABLE QString getSharingResource(int screenId = -2, const QString& windowProcessId = "", const QString& key = "");
|
2021-11-17 19:11:18 -05:00
|
|
|
|
|
|
|
Q_INVOKABLE void getListWindows();
|
|
|
|
|
2021-05-31 14:04:38 -04:00
|
|
|
// Stop sharing the screen or file
|
2023-02-07 14:21:35 -03:00
|
|
|
Q_INVOKABLE void stopSharing(const QString& source = {});
|
2021-05-26 17:58:50 -04:00
|
|
|
|
2021-09-13 11:00:18 -04:00
|
|
|
Q_INVOKABLE void startAudioMeter();
|
|
|
|
Q_INVOKABLE void stopAudioMeter();
|
2020-11-03 17:28:25 -05:00
|
|
|
|
2021-08-26 14:57:24 -04:00
|
|
|
Q_INVOKABLE void setDeviceName(const QString& deviceName);
|
|
|
|
|
|
|
|
Q_INVOKABLE void enableCodec(unsigned int id, bool isToEnable);
|
|
|
|
Q_INVOKABLE void increaseCodecPriority(unsigned int id, bool isVideo);
|
|
|
|
Q_INVOKABLE void decreaseCodecPriority(unsigned int id, bool isVideo);
|
|
|
|
|
2022-11-21 17:46:41 -05:00
|
|
|
Q_INVOKABLE void resetRendererInfo();
|
|
|
|
Q_INVOKABLE void setRendererInfo();
|
|
|
|
|
2021-08-31 10:37:11 -04:00
|
|
|
// TODO: to be removed
|
|
|
|
Q_INVOKABLE bool getHardwareAcceleration();
|
|
|
|
Q_INVOKABLE void setHardwareAcceleration(bool accelerate);
|
|
|
|
|
2021-06-02 12:11:49 -04:00
|
|
|
private Q_SLOTS:
|
2022-11-21 17:46:41 -05:00
|
|
|
void updateRenderersFPSInfo(QPair<QString, QString> fpsInfo);
|
2021-06-02 12:11:49 -04:00
|
|
|
void onAudioDeviceEvent();
|
2022-09-26 21:01:45 -04:00
|
|
|
void onRendererStarted(const QString& id, const QSize& size);
|
2022-11-21 17:46:41 -05:00
|
|
|
void onRendererStopped(const QString& id);
|
2021-06-02 12:11:49 -04:00
|
|
|
|
2020-11-03 17:28:25 -05:00
|
|
|
private:
|
2021-05-03 15:16:03 -04:00
|
|
|
// Get screens arrangement rect relative to primary screen.
|
|
|
|
const QRect getAllScreensBoundingRect();
|
|
|
|
|
2021-03-11 13:30:45 -05:00
|
|
|
// Get the screen number
|
2022-09-02 09:31:55 -03:00
|
|
|
int getScreenNumber(int screenId = 0) const;
|
2022-11-21 17:46:41 -05:00
|
|
|
|
|
|
|
std::unique_ptr<RendererInformationListModel> rendererInformationListModel_;
|
2020-08-03 13:27:42 -04:00
|
|
|
};
|