diff options
author | Joe Donofry <rubberduckie3554@gmail.com> | 2022-01-02 21:15:10 +0000 |
---|---|---|
committer | Joe Donofry <rubberduckie3554@gmail.com> | 2022-01-02 21:15:10 +0000 |
commit | d2af490202888f836606d6f4a7b46ead32b0f5a7 (patch) | |
tree | 76106e16b12ba35e5de177e370b1280ffd4d19f9 /src | |
parent | Port image overlay to qml (diff) | |
parent | Gstreamer glib event loop for macos and windows (diff) | |
download | nheko-d2af490202888f836606d6f4a7b46ead32b0f5a7.tar.xz |
Merge branch 'gstreamer_windows_macos' into 'master'
Gstreamer glib event loop for macos and windows See merge request nheko-reborn/nheko!19
Diffstat (limited to 'src')
-rw-r--r-- | src/main.cpp | 32 | ||||
-rw-r--r-- | src/voip/CallDevices.cpp | 7 | ||||
-rw-r--r-- | src/voip/CallManager.cpp | 6 |
3 files changed, 38 insertions, 7 deletions
diff --git a/src/main.cpp b/src/main.cpp index 4ecc18d2..2ae631cf 100644 --- a/src/main.cpp +++ b/src/main.cpp @@ -34,6 +34,11 @@ #include "emoji/MacHelper.h" #endif +#if defined(GSTREAMER_AVAILABLE) && (defined(Q_OS_MAC) || defined(Q_OS_WINDOWS)) +#include <QAbstractEventDispatcher> +#include <gst/gst.h> +#endif + #ifdef QML_DEBUGGING #include <QQmlDebuggingEnabler> QQmlDebuggingEnabler enabler; @@ -100,6 +105,23 @@ registerSignalHandlers() #endif +#if defined(GSTREAMER_AVAILABLE) && (defined(Q_OS_MAC) || defined(Q_OS_WINDOWS)) +GMainLoop *gloop = 0; +GThread *gthread = 0; + +extern "C" +{ + static gpointer glibMainLoopThreadFunc(gpointer) + { + gloop = g_main_loop_new(0, false); + g_main_loop_run(gloop); + g_main_loop_unref(gloop); + gloop = 0; + return 0; + } +} // extern "C" +#endif + QPoint screenCenter(int width, int height) { @@ -220,6 +242,16 @@ main(int argc, char *argv[]) registerSignalHandlers(); +#if defined(GSTREAMER_AVAILABLE) && (defined(Q_OS_MAC) || defined(Q_OS_WINDOWS)) + // If the version of Qt we're running in does not use GLib, we need to + // start a GMainLoop so that gstreamer can dispatch events. + const QMetaObject *mo = QAbstractEventDispatcher::instance(qApp->thread())->metaObject(); + if (gloop == 0 && strcmp(mo->className(), "QEventDispatcherGlib") != 0 && + strcmp(mo->superClass()->className(), "QEventDispatcherGlib") != 0) { + gthread = g_thread_new(0, glibMainLoopThreadFunc, 0); + } +#endif + if (parser.isSet(debugOption)) nhlog::enable_debug_log_from_commandline = true; diff --git a/src/voip/CallDevices.cpp b/src/voip/CallDevices.cpp index 353fc4a5..b0c90d84 100644 --- a/src/voip/CallDevices.cpp +++ b/src/voip/CallDevices.cpp @@ -8,7 +8,6 @@ #include <string_view> #include "CallDevices.h" -#include "ChatPage.h" #include "Logging.h" #include "UserSettingsPage.h" @@ -70,7 +69,7 @@ addFrameRate(std::vector<std::string> &rates, const FrameRate &rate) void setDefaultDevice(bool isVideo) { - auto settings = ChatPage::instance()->userSettings(); + auto settings = UserSettings::instance(); if (isVideo && settings->camera().isEmpty()) { const VideoSource &camera = videoSources_.front(); settings->setCamera(QString::fromStdString(camera.name)); @@ -320,7 +319,7 @@ CallDevices::frameRates(const std::string &cameraName, const std::string &resolu GstDevice * CallDevices::audioDevice() const { - std::string name = ChatPage::instance()->userSettings()->microphone().toStdString(); + std::string name = UserSettings::instance()->microphone().toStdString(); if (auto it = std::find_if(audioSources_.cbegin(), audioSources_.cend(), [&name](const auto &s) { return s.name == name; }); @@ -336,7 +335,7 @@ CallDevices::audioDevice() const GstDevice * CallDevices::videoDevice(std::pair<int, int> &resolution, std::pair<int, int> &frameRate) const { - auto settings = ChatPage::instance()->userSettings(); + auto settings = UserSettings::instance(); std::string name = settings->camera().toStdString(); if (auto s = getVideoSource(name); s) { nhlog::ui()->debug("WebRTC: camera: {}", name); diff --git a/src/voip/CallManager.cpp b/src/voip/CallManager.cpp index f184b622..54d86620 100644 --- a/src/voip/CallManager.cpp +++ b/src/voip/CallManager.cpp @@ -292,7 +292,7 @@ CallManager::handleEvent(const RoomEvent<CallInvite> &callInviteEvent) return; } - const QString &ringtone = ChatPage::instance()->userSettings()->ringtone(); + const QString &ringtone = UserSettings::instance()->ringtone(); if (ringtone != QLatin1String("Mute")) playRingtone(ringtone == QLatin1String("Default") ? QUrl(QStringLiteral("qrc:/media/media/ring.ogg")) @@ -431,8 +431,8 @@ QStringList CallManager::devices(bool isVideo) const { QStringList ret; - const QString &defaultDevice = isVideo ? ChatPage::instance()->userSettings()->camera() - : ChatPage::instance()->userSettings()->microphone(); + const QString &defaultDevice = + isVideo ? UserSettings::instance()->camera() : UserSettings::instance()->microphone(); std::vector<std::string> devices = CallDevices::instance().names(isVideo, defaultDevice.toStdString()); ret.reserve(devices.size()); |