mirror of
https://github.com/Nheko-Reborn/nheko.git
synced 2024-11-25 04:28:49 +03:00
Improve choosing screen share type
This commit is contained in:
parent
562a71a5f3
commit
2aadc7c2c4
3 changed files with 53 additions and 58 deletions
|
@ -14,10 +14,6 @@ Popup {
|
||||||
anchors.centerIn: parent;
|
anchors.centerIn: parent;
|
||||||
|
|
||||||
Component.onCompleted: {
|
Component.onCompleted: {
|
||||||
if (CallManager.screenShareX11Available)
|
|
||||||
CallManager.setScreenShareType(ScreenShareType.X11);
|
|
||||||
else
|
|
||||||
CallManager.setScreenShareType(ScreenShareType.XDP);
|
|
||||||
frameRateCombo.currentIndex = frameRateCombo.find(Settings.screenShareFrameRate);
|
frameRateCombo.currentIndex = frameRateCombo.find(Settings.screenShareFrameRate);
|
||||||
}
|
}
|
||||||
Component.onDestruction: {
|
Component.onDestruction: {
|
||||||
|
@ -47,29 +43,13 @@ Popup {
|
||||||
color: Nheko.colors.windowText
|
color: Nheko.colors.windowText
|
||||||
}
|
}
|
||||||
|
|
||||||
RadioButton {
|
ComboBox {
|
||||||
id: screenshare_X11
|
id: screenshareType
|
||||||
text: qsTr("X11");
|
|
||||||
visible: CallManager.screenShareX11Available
|
Layout.fillWidth: true
|
||||||
checked: CallManager.screenShareX11Available
|
model: CallManager.screenShareTypeList()
|
||||||
onToggled: {
|
onCurrentIndexChanged: CallManager.setScreenShareType(currentIndex);
|
||||||
if (screenshare_X11.checked)
|
}
|
||||||
CallManager.setScreenShareType(ScreenShareType.X11);
|
|
||||||
else
|
|
||||||
CallManager.setScreenShareType(ScreenShareType.XDP);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
RadioButton {
|
|
||||||
id: screenshare_XDP
|
|
||||||
text: qsTr("xdg-desktop-portal");
|
|
||||||
checked: !CallManager.screenShareX11Available
|
|
||||||
onToggled: {
|
|
||||||
if (screenshare_XDP.checked)
|
|
||||||
CallManager.setScreenShareType(ScreenShareType.XDP);
|
|
||||||
else
|
|
||||||
CallManager.setScreenShareType(ScreenShareType.X11);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
RowLayout {
|
RowLayout {
|
||||||
|
@ -84,7 +64,7 @@ Popup {
|
||||||
}
|
}
|
||||||
|
|
||||||
ComboBox {
|
ComboBox {
|
||||||
visible: screenshare_X11.checked
|
visible: CallManager.screenShareType == ScreenShareType.X11
|
||||||
id: windowCombo
|
id: windowCombo
|
||||||
|
|
||||||
Layout.fillWidth: true
|
Layout.fillWidth: true
|
||||||
|
@ -92,7 +72,7 @@ Popup {
|
||||||
}
|
}
|
||||||
|
|
||||||
Button {
|
Button {
|
||||||
visible: screenshare_XDP.checked
|
visible: CallManager.screenShareType == ScreenShareType.XDP
|
||||||
highlighted: !CallManager.screenShareReady
|
highlighted: !CallManager.screenShareReady
|
||||||
text: qsTr("Request screencast")
|
text: qsTr("Request screencast")
|
||||||
onClicked: {
|
onClicked: {
|
||||||
|
|
|
@ -68,12 +68,23 @@ CallManager::CallManager(QObject *parent)
|
||||||
qRegisterMetaType<mtx::events::voip::CallCandidates::Candidate>();
|
qRegisterMetaType<mtx::events::voip::CallCandidates::Candidate>();
|
||||||
qRegisterMetaType<mtx::responses::TurnServer>();
|
qRegisterMetaType<mtx::responses::TurnServer>();
|
||||||
|
|
||||||
if (screenShareX11Available()) {
|
#ifdef GSTREAMER_AVAILABLE
|
||||||
screenShareType_ = ScreenShareType::X11;
|
std::string errorMessage;
|
||||||
} else {
|
if (session_.havePlugins(true, true, ScreenShareType::XDP, &errorMessage)) {
|
||||||
|
screenShareTypes_.push_back(ScreenShareType::XDP);
|
||||||
screenShareType_ = ScreenShareType::XDP;
|
screenShareType_ = ScreenShareType::XDP;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (std::getenv("DISPLAY")) {
|
||||||
|
screenShareTypes_.push_back(ScreenShareType::X11);
|
||||||
|
if (QGuiApplication::platformName() != QStringLiteral("wayland")) {
|
||||||
|
// Selected by default
|
||||||
|
screenShareType_ = ScreenShareType::X11;
|
||||||
|
std::swap(screenShareTypes_[0], screenShareTypes_[1]);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
connect(
|
connect(
|
||||||
&session_,
|
&session_,
|
||||||
&WebRTCSession::offerCreated,
|
&WebRTCSession::offerCreated,
|
||||||
|
@ -208,13 +219,6 @@ CallManager::sendInvite(const QString &roomid, CallType callType, unsigned int w
|
||||||
auto roomInfo = cache::singleRoomInfo(roomid.toStdString());
|
auto roomInfo = cache::singleRoomInfo(roomid.toStdString());
|
||||||
|
|
||||||
std::string errorMessage;
|
std::string errorMessage;
|
||||||
if (!session_.havePlugins(callType != CallType::VOICE,
|
|
||||||
callType == CallType::SCREEN,
|
|
||||||
screenShareType_,
|
|
||||||
&errorMessage)) {
|
|
||||||
emit ChatPage::instance()->showNotification(QString::fromStdString(errorMessage));
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
callType_ = callType;
|
callType_ = callType;
|
||||||
roomid_ = roomid;
|
roomid_ = roomid;
|
||||||
|
@ -745,16 +749,6 @@ CallManager::callsSupported()
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
bool
|
|
||||||
CallManager::screenShareX11Available()
|
|
||||||
{
|
|
||||||
#ifdef GSTREAMER_AVAILABLE
|
|
||||||
return std::getenv("DISPLAY");
|
|
||||||
#else
|
|
||||||
return false;
|
|
||||||
#endif
|
|
||||||
}
|
|
||||||
|
|
||||||
QStringList
|
QStringList
|
||||||
CallManager::devices(bool isVideo) const
|
CallManager::devices(bool isVideo) const
|
||||||
{
|
{
|
||||||
|
@ -862,10 +856,30 @@ CallManager::screenShareReady() const
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
|
QStringList
|
||||||
|
CallManager::screenShareTypeList()
|
||||||
|
{
|
||||||
|
QStringList ret;
|
||||||
|
ret.reserve(2);
|
||||||
|
for (ScreenShareType type : screenShareTypes_) {
|
||||||
|
switch (type) {
|
||||||
|
case ScreenShareType::X11:
|
||||||
|
ret.append(tr("X11"));
|
||||||
|
break;
|
||||||
|
case ScreenShareType::XDP:
|
||||||
|
ret.append(tr("Stream from xdg-desktop-portal"));
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return ret;
|
||||||
|
}
|
||||||
|
|
||||||
QStringList
|
QStringList
|
||||||
CallManager::windowList()
|
CallManager::windowList()
|
||||||
{
|
{
|
||||||
if (!screenShareX11Available()) {
|
if (!(std::find(screenShareTypes_.begin(), screenShareTypes_.end(), ScreenShareType::X11) !=
|
||||||
|
screenShareTypes_.end())) {
|
||||||
return {};
|
return {};
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -998,7 +1012,7 @@ CallManager::previewWindow(unsigned int index) const
|
||||||
}
|
}
|
||||||
|
|
||||||
if (screenShareType_ == ScreenShareType::X11 &&
|
if (screenShareType_ == ScreenShareType::X11 &&
|
||||||
(!screenShareX11Available() || windows_.empty() || index >= windows_.size())) {
|
(windows_.empty() || index >= windows_.size())) {
|
||||||
nhlog::ui()->error("X11 screencast not available");
|
nhlog::ui()->error("X11 screencast not available");
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
@ -1085,19 +1099,20 @@ CallManager::setupScreenShareXDP()
|
||||||
#ifdef GSTREAMER_AVAILABLE
|
#ifdef GSTREAMER_AVAILABLE
|
||||||
ScreenCastPortal &sc_portal = ScreenCastPortal::instance();
|
ScreenCastPortal &sc_portal = ScreenCastPortal::instance();
|
||||||
sc_portal.init();
|
sc_portal.init();
|
||||||
screenShareType_ = ScreenShareType::XDP;
|
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
CallManager::setScreenShareType(webrtc::ScreenShareType screenShareType)
|
CallManager::setScreenShareType(unsigned int index)
|
||||||
{
|
{
|
||||||
#ifdef GSTREAMER_AVAILABLE
|
#ifdef GSTREAMER_AVAILABLE
|
||||||
closeScreenShare();
|
closeScreenShare();
|
||||||
screenShareType_ = screenShareType;
|
if (index >= screenShareTypes_.size())
|
||||||
|
nhlog::ui()->error("WebRTC: Screen share type index out of range");
|
||||||
|
screenShareType_ = screenShareTypes_[index];
|
||||||
emit screenShareChanged();
|
emit screenShareChanged();
|
||||||
#else
|
#else
|
||||||
(void)screenShareType;
|
(void)index;
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -44,7 +44,6 @@ class CallManager final : public QObject
|
||||||
Q_PROPERTY(QStringList mics READ mics NOTIFY devicesChanged)
|
Q_PROPERTY(QStringList mics READ mics NOTIFY devicesChanged)
|
||||||
Q_PROPERTY(QStringList cameras READ cameras NOTIFY devicesChanged)
|
Q_PROPERTY(QStringList cameras READ cameras NOTIFY devicesChanged)
|
||||||
Q_PROPERTY(bool callsSupported READ callsSupported CONSTANT)
|
Q_PROPERTY(bool callsSupported READ callsSupported CONSTANT)
|
||||||
Q_PROPERTY(bool screenShareX11Available READ screenShareX11Available CONSTANT)
|
|
||||||
Q_PROPERTY(bool screenShareReady READ screenShareReady NOTIFY screenShareChanged)
|
Q_PROPERTY(bool screenShareReady READ screenShareReady NOTIFY screenShareChanged)
|
||||||
|
|
||||||
public:
|
public:
|
||||||
|
@ -68,7 +67,6 @@ public:
|
||||||
bool screenShareReady() const;
|
bool screenShareReady() const;
|
||||||
|
|
||||||
static bool callsSupported();
|
static bool callsSupported();
|
||||||
static bool screenShareX11Available();
|
|
||||||
|
|
||||||
public slots:
|
public slots:
|
||||||
void sendInvite(const QString &roomid, webrtc::CallType, unsigned int windowIndex = 0);
|
void sendInvite(const QString &roomid, webrtc::CallType, unsigned int windowIndex = 0);
|
||||||
|
@ -80,8 +78,9 @@ public slots:
|
||||||
mtx::events::voip::CallHangUp::Reason = mtx::events::voip::CallHangUp::Reason::UserHangUp);
|
mtx::events::voip::CallHangUp::Reason = mtx::events::voip::CallHangUp::Reason::UserHangUp);
|
||||||
void rejectInvite();
|
void rejectInvite();
|
||||||
void setupScreenShareXDP();
|
void setupScreenShareXDP();
|
||||||
void setScreenShareType(webrtc::ScreenShareType);
|
void setScreenShareType(unsigned int index);
|
||||||
void closeScreenShare();
|
void closeScreenShare();
|
||||||
|
QStringList screenShareTypeList();
|
||||||
QStringList windowList();
|
QStringList windowList();
|
||||||
void previewWindow(unsigned int windowIndex) const;
|
void previewWindow(unsigned int windowIndex) const;
|
||||||
|
|
||||||
|
@ -126,6 +125,7 @@ private:
|
||||||
std::vector<std::string> turnURIs_;
|
std::vector<std::string> turnURIs_;
|
||||||
QTimer turnServerTimer_;
|
QTimer turnServerTimer_;
|
||||||
QMediaPlayer player_;
|
QMediaPlayer player_;
|
||||||
|
std::vector<webrtc::ScreenShareType> screenShareTypes_;
|
||||||
std::vector<std::pair<QString, uint32_t>> windows_;
|
std::vector<std::pair<QString, uint32_t>> windows_;
|
||||||
std::vector<std::string> rejectCallPartyIDs_;
|
std::vector<std::string> rejectCallPartyIDs_;
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue