mirror of
https://github.com/Nheko-Reborn/nheko.git
synced 2024-11-22 11:00:48 +03:00
Merge branch 'gstreamer_windows_macos' into 'master'
Gstreamer glib event loop for macos and windows See merge request nheko-reborn/nheko!19
This commit is contained in:
commit
d2af490202
4 changed files with 39 additions and 8 deletions
|
@ -503,7 +503,7 @@ endif()
|
||||||
if (VOIP)
|
if (VOIP)
|
||||||
include(FindPkgConfig)
|
include(FindPkgConfig)
|
||||||
pkg_check_modules(GSTREAMER REQUIRED IMPORTED_TARGET gstreamer-sdp-1.0>=1.18 gstreamer-webrtc-1.0>=1.18)
|
pkg_check_modules(GSTREAMER REQUIRED IMPORTED_TARGET gstreamer-sdp-1.0>=1.18 gstreamer-webrtc-1.0>=1.18)
|
||||||
if (SCREENSHARE_X11)
|
if (SCREENSHARE_X11 AND NOT WIN32 AND NOT APPLE)
|
||||||
pkg_check_modules(XCB REQUIRED IMPORTED_TARGET xcb xcb-ewmh)
|
pkg_check_modules(XCB REQUIRED IMPORTED_TARGET xcb xcb-ewmh)
|
||||||
endif()
|
endif()
|
||||||
endif()
|
endif()
|
||||||
|
|
32
src/main.cpp
32
src/main.cpp
|
@ -34,6 +34,11 @@
|
||||||
#include "emoji/MacHelper.h"
|
#include "emoji/MacHelper.h"
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
#if defined(GSTREAMER_AVAILABLE) && (defined(Q_OS_MAC) || defined(Q_OS_WINDOWS))
|
||||||
|
#include <QAbstractEventDispatcher>
|
||||||
|
#include <gst/gst.h>
|
||||||
|
#endif
|
||||||
|
|
||||||
#ifdef QML_DEBUGGING
|
#ifdef QML_DEBUGGING
|
||||||
#include <QQmlDebuggingEnabler>
|
#include <QQmlDebuggingEnabler>
|
||||||
QQmlDebuggingEnabler enabler;
|
QQmlDebuggingEnabler enabler;
|
||||||
|
@ -100,6 +105,23 @@ registerSignalHandlers()
|
||||||
|
|
||||||
#endif
|
#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
|
QPoint
|
||||||
screenCenter(int width, int height)
|
screenCenter(int width, int height)
|
||||||
{
|
{
|
||||||
|
@ -220,6 +242,16 @@ main(int argc, char *argv[])
|
||||||
|
|
||||||
registerSignalHandlers();
|
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))
|
if (parser.isSet(debugOption))
|
||||||
nhlog::enable_debug_log_from_commandline = true;
|
nhlog::enable_debug_log_from_commandline = true;
|
||||||
|
|
||||||
|
|
|
@ -8,7 +8,6 @@
|
||||||
#include <string_view>
|
#include <string_view>
|
||||||
|
|
||||||
#include "CallDevices.h"
|
#include "CallDevices.h"
|
||||||
#include "ChatPage.h"
|
|
||||||
#include "Logging.h"
|
#include "Logging.h"
|
||||||
#include "UserSettingsPage.h"
|
#include "UserSettingsPage.h"
|
||||||
|
|
||||||
|
@ -70,7 +69,7 @@ addFrameRate(std::vector<std::string> &rates, const FrameRate &rate)
|
||||||
void
|
void
|
||||||
setDefaultDevice(bool isVideo)
|
setDefaultDevice(bool isVideo)
|
||||||
{
|
{
|
||||||
auto settings = ChatPage::instance()->userSettings();
|
auto settings = UserSettings::instance();
|
||||||
if (isVideo && settings->camera().isEmpty()) {
|
if (isVideo && settings->camera().isEmpty()) {
|
||||||
const VideoSource &camera = videoSources_.front();
|
const VideoSource &camera = videoSources_.front();
|
||||||
settings->setCamera(QString::fromStdString(camera.name));
|
settings->setCamera(QString::fromStdString(camera.name));
|
||||||
|
@ -320,7 +319,7 @@ CallDevices::frameRates(const std::string &cameraName, const std::string &resolu
|
||||||
GstDevice *
|
GstDevice *
|
||||||
CallDevices::audioDevice() const
|
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(),
|
if (auto it = std::find_if(audioSources_.cbegin(),
|
||||||
audioSources_.cend(),
|
audioSources_.cend(),
|
||||||
[&name](const auto &s) { return s.name == name; });
|
[&name](const auto &s) { return s.name == name; });
|
||||||
|
@ -336,7 +335,7 @@ CallDevices::audioDevice() const
|
||||||
GstDevice *
|
GstDevice *
|
||||||
CallDevices::videoDevice(std::pair<int, int> &resolution, std::pair<int, int> &frameRate) const
|
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();
|
std::string name = settings->camera().toStdString();
|
||||||
if (auto s = getVideoSource(name); s) {
|
if (auto s = getVideoSource(name); s) {
|
||||||
nhlog::ui()->debug("WebRTC: camera: {}", name);
|
nhlog::ui()->debug("WebRTC: camera: {}", name);
|
||||||
|
|
|
@ -292,7 +292,7 @@ CallManager::handleEvent(const RoomEvent<CallInvite> &callInviteEvent)
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
const QString &ringtone = ChatPage::instance()->userSettings()->ringtone();
|
const QString &ringtone = UserSettings::instance()->ringtone();
|
||||||
if (ringtone != QLatin1String("Mute"))
|
if (ringtone != QLatin1String("Mute"))
|
||||||
playRingtone(ringtone == QLatin1String("Default")
|
playRingtone(ringtone == QLatin1String("Default")
|
||||||
? QUrl(QStringLiteral("qrc:/media/media/ring.ogg"))
|
? QUrl(QStringLiteral("qrc:/media/media/ring.ogg"))
|
||||||
|
@ -431,8 +431,8 @@ QStringList
|
||||||
CallManager::devices(bool isVideo) const
|
CallManager::devices(bool isVideo) const
|
||||||
{
|
{
|
||||||
QStringList ret;
|
QStringList ret;
|
||||||
const QString &defaultDevice = isVideo ? ChatPage::instance()->userSettings()->camera()
|
const QString &defaultDevice =
|
||||||
: ChatPage::instance()->userSettings()->microphone();
|
isVideo ? UserSettings::instance()->camera() : UserSettings::instance()->microphone();
|
||||||
std::vector<std::string> devices =
|
std::vector<std::string> devices =
|
||||||
CallDevices::instance().names(isVideo, defaultDevice.toStdString());
|
CallDevices::instance().names(isVideo, defaultDevice.toStdString());
|
||||||
ret.reserve(devices.size());
|
ret.reserve(devices.size());
|
||||||
|
|
Loading…
Reference in a new issue