diff --git a/CMakeLists.txt b/CMakeLists.txt index 66b9f513aa8898d90c57ab07d0e1302e3b862ccf..80b6719b623347c0969d5a7979dd308252455049 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -330,6 +330,7 @@ SET( libringclient_LIB_SRCS src/private/sortproxies.cpp src/private/threadworker.cpp src/mime.cpp + src/smartinfohub.cpp #Extension src/extensions/presencecollectionextension.cpp @@ -430,6 +431,7 @@ SET( libringclient_LIB_HDRS src/shortcutcreatordefault.h src/dbuserrorhandlerdefault.h src/itemdataroles.h + src/smartinfohub.h ) SET(libringclient_video_LIB_HDRS @@ -593,6 +595,7 @@ SET(libringclient_PRIVATE_HDRS src/private/securityevaluationmodel_p.h src/collectionconfigurationinterface.h src/private/imconversationmanagerprivate.h + src/private/smartInfoHub_p.h ) IF(${ENABLE_LIBWRAP} MATCHES true) diff --git a/src/private/smartInfoHub_p.h b/src/private/smartInfoHub_p.h new file mode 100644 index 0000000000000000000000000000000000000000..2525f7df6d7318ad3262e62cb9ac1ea79d11580e --- /dev/null +++ b/src/private/smartInfoHub_p.h @@ -0,0 +1,54 @@ +/**************************************************************************** + * Copyright (C) 2016 by Savoir-faire Linux * + * Author: Olivier Grégoire <olivier.gregoire@savoirfairelinux.com> * + * * + * This library is free software; you can redistribute it and/or * + * modify it under the terms of the GNU Lesser General Public * + * License as published by the Free Software Foundation; either * + * version 2.1 of the License, or (at your option) any later version. * + * * + * This library 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 * + * Lesser 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/>. * + ***************************************************************************/ + +/* widget_p.h (_p means private) */ +#include <QObject> +#include "../smartinfohub.h" +#include "typedefs.h" + +#pragma once + +//variables contain in the map information +static QString LOCAL_FPS = QStringLiteral("local FPS"); +static QString LOCAL_AUDIO_CODEC = QStringLiteral("local audio codec"); +static QString LOCAL_VIDEO_CODEC = QStringLiteral("local video codec"); +static QString LOCAL_WIDTH = QStringLiteral("local width"); +static QString LOCAL_HEIGHT = QStringLiteral("local height"); +static QString REMOTE_FPS = QStringLiteral("remote FPS"); +static QString REMOTE_WIDTH = QStringLiteral("remote width"); +static QString REMOTE_HEIGHT = QStringLiteral("remote height"); +static QString REMOTE_VIDEO_CODEC = QStringLiteral("remote video codec"); +static QString REMOTE_AUDIO_CODEC = QStringLiteral("remote audio codec"); +static QString CALL_ID = QStringLiteral("callID"); + +class SmartInfoHubPrivate; +class SmartInfoHubPrivate final : public QObject +{ + Q_OBJECT + +public: + constexpr static const char* DEFAULT_RETURN_VALUE_QSTRING = "void"; + + uint32_t m_refreshTimeInformationMS = 500; + QMap<QString, QString> m_information; + + void setMapInfo(const MapStringString& info); + +public slots: + void slotSmartInfo(const MapStringString& info); +}; diff --git a/src/qtwrapper/callmanager_wrap.h b/src/qtwrapper/callmanager_wrap.h index a61e060ede026a1a92311ca14a347de26f5a7913..7dedbbca00d7a40a15e84a02542d976fe06ca7ba 100644 --- a/src/qtwrapper/callmanager_wrap.h +++ b/src/qtwrapper/callmanager_wrap.h @@ -173,7 +173,14 @@ public: LOG_DRING_SIGNAL2("videoMuted",QString(callID.c_str()), state); Q_EMIT videoMuted(QString(callID.c_str()), state); }); - }) + }), + exportable_callback<CallSignal::SmartInfo>( + [this] (const std::map<std::string, std::string>& info) { + QTimer::singleShot(0, [this,info] { + LOG_DRING_SIGNAL("smartInfo",""); + Q_EMIT smartInfo(convertMap(info)); + }); + }) }; } @@ -379,6 +386,16 @@ public Q_SLOTS: // METHODS return DRing::muteLocalMedia(callid.toStdString(), mediaType.toStdString(), mute); } + void startSmartInfo(int refresh) + { + DRing::startSmartInfo(refresh); + } + + void stopSmartInfo() + { + DRing::stopSmartInfo(); + } + Q_SIGNALS: // SIGNALS void callStateChanged(const QString &callID, const QString &state, int code); void transferFailed(); @@ -398,6 +415,7 @@ Q_SIGNALS: // SIGNALS void audioMuted(const QString &callID, bool state); void videoMuted(const QString &callID, bool state); void peerHold(const QString &callID, bool state); + void smartInfo(const MapStringString& info); }; namespace org { diff --git a/src/smartinfohub.cpp b/src/smartinfohub.cpp new file mode 100644 index 0000000000000000000000000000000000000000..290fa3e4f4762f164a86dec398a83f778953b87f --- /dev/null +++ b/src/smartinfohub.cpp @@ -0,0 +1,162 @@ +/**************************************************************************** + * Copyright (C) 2016 by Savoir-faire Linux * + * Author: Olivier Grégoire <olivier.gregoire@savoirfairelinux.com> * + * * + * This library is free software; you can redistribute it and/or * + * modify it under the terms of the GNU Lesser General Public * + * License as published by the Free Software Foundation; either * + * version 2.1 of the License, or (at your option) any later version. * + * * + * This library 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 * + * Lesser 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/>. * + ***************************************************************************/ + +#include "smartinfohub.h" +#include "private/smartInfoHub_p.h" +#include "callmodel.h" +#include "typedefs.h" + +#include <dbus/videomanager.h> +#include <dbus/callmanager.h> +#include <dbus/callmanager.h> + +SmartInfoHub::SmartInfoHub() +{ + d_ptr = new SmartInfoHubPrivate; + connect(&CallManager::instance(), SIGNAL(SmartInfo(MapStringString)), d_ptr , SLOT(slotSmartInfo(MapStringString))); +} + +SmartInfoHub::~SmartInfoHub() +{} + +void SmartInfoHub::start() +{ + CallManager::instance().startSmartInfo(d_ptr->m_refreshTimeInformationMS); +} + +void SmartInfoHub::stop() +{ + CallManager::instance().stopSmartInfo(); +} + +SmartInfoHub& SmartInfoHub::instance() +{ + //Singleton + static SmartInfoHub instance_; + return instance_; +} + +void SmartInfoHub::setRefreshTime(uint32_t timeMS) +{ + d_ptr->m_refreshTimeInformationMS = timeMS; +} + +//Retrieve information from the map and implement all the variables +void SmartInfoHubPrivate::slotSmartInfo(const MapStringString& map) +{ + for(int i = 0; i < map.size(); i++){ + SmartInfoHubPrivate::m_information[map.keys().at(i)]=map[map.keys().at(i)]; + } + + emit SmartInfoHub::instance().changed(); +} +//Getter + +bool SmartInfoHub::isConference() const +{ + return (d_ptr->m_information["type"] == "conference"); +} + + +float SmartInfoHub::localFps() const +{ + if(d_ptr->m_information[LOCAL_FPS] != NULL) + return d_ptr->m_information[LOCAL_FPS].toFloat(); + + return 0.0; +} + +float SmartInfoHub::remoteFps() const +{ + if(d_ptr->m_information[REMOTE_FPS] != NULL) + return d_ptr->m_information[REMOTE_FPS].toFloat(); + + return 0.0; +} + +int SmartInfoHub::remoteWidth() const +{ + if(d_ptr->m_information[REMOTE_WIDTH] != NULL) + return d_ptr->m_information[REMOTE_WIDTH].toInt(); + else + return 0; +} + +int SmartInfoHub::remoteHeight() const +{ + if(d_ptr->m_information[REMOTE_HEIGHT] != NULL) + return d_ptr->m_information[REMOTE_HEIGHT].toInt(); + else + return 0; +} + +int SmartInfoHub::localWidth() const +{ + if(d_ptr->m_information[LOCAL_WIDTH] != NULL) + return d_ptr->m_information[LOCAL_WIDTH].toInt(); + else + return 0; +} + +int SmartInfoHub::localHeight() const +{ + if(d_ptr->m_information[LOCAL_HEIGHT] != NULL) + return d_ptr->m_information[LOCAL_HEIGHT].toInt(); + else + return 0; +} + +QString SmartInfoHub::callID() const +{ + if(d_ptr->m_information[CALL_ID] != NULL) + return d_ptr->m_information[CALL_ID]; + else + return SmartInfoHubPrivate::DEFAULT_RETURN_VALUE_QSTRING; +} + +QString SmartInfoHub::localVideoCodec() const +{ + if(d_ptr->m_information[LOCAL_VIDEO_CODEC] != NULL) + return d_ptr->m_information[LOCAL_VIDEO_CODEC]; + else + return SmartInfoHubPrivate::DEFAULT_RETURN_VALUE_QSTRING; +} + +QString SmartInfoHub::localAudioCodec() const +{ + if(d_ptr->m_information[LOCAL_AUDIO_CODEC] != NULL) + return d_ptr->m_information[LOCAL_AUDIO_CODEC]; + else + return SmartInfoHubPrivate::DEFAULT_RETURN_VALUE_QSTRING; +} + +QString SmartInfoHub::remoteVideoCodec() const +{ + if(d_ptr->m_information[REMOTE_VIDEO_CODEC] != NULL) + return d_ptr->m_information[REMOTE_VIDEO_CODEC]; + else + return SmartInfoHubPrivate::DEFAULT_RETURN_VALUE_QSTRING; +} + +QString SmartInfoHub::remoteAudioCodec() const +{ + if(d_ptr->m_information[REMOTE_AUDIO_CODEC] != NULL) + return d_ptr->m_information[REMOTE_AUDIO_CODEC]; + else + return SmartInfoHubPrivate::DEFAULT_RETURN_VALUE_QSTRING; +} diff --git a/src/smartinfohub.h b/src/smartinfohub.h new file mode 100644 index 0000000000000000000000000000000000000000..8b55dd9037ca2af8b5f278aa3c6140d2e1f75a79 --- /dev/null +++ b/src/smartinfohub.h @@ -0,0 +1,61 @@ +/**************************************************************************** + * Copyright (C) 2016 by Savoir-faire Linux * + * Author: Olivier Grégoire <olivier.gregoire@savoirfairelinux.com> * + * * + * This library is free software; you can redistribute it and/or * + * modify it under the terms of the GNU Lesser General Public * + * License as published by the Free Software Foundation; either * + * version 2.1 of the License, or (at your option) any later version. * + * * + * This library 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 * + * Lesser 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 <QObject> + +class SmartInfoHubPrivate; + +class SmartInfoHub final : public QObject +{ + Q_OBJECT + public: + // Singleton + static SmartInfoHub& instance(); + + void start(); + void stop(); + + void setRefreshTime(uint32_t timeMS); + + //Getter + float localFps() const; + float remoteFps() const; + int remoteWidth() const; + int remoteHeight() const; + int localWidth() const; + int localHeight() const; + QString callID() const; + QString localVideoCodec() const; + QString localAudioCodec() const; + QString remoteVideoCodec() const; + QString remoteAudioCodec() const; + bool isConference() const; + + Q_SIGNALS: + ///Emitted when informations have changed + void changed(); + + private: + //use to initialise the connection between the Qsignal and the lambda function + SmartInfoHub(); + virtual ~SmartInfoHub(); + + SmartInfoHubPrivate* d_ptr; +};