Skip to content
Snippets Groups Projects
Commit ad49fc70 authored by Olivier Gregoire's avatar Olivier Gregoire Committed by Guillaume Roguez
Browse files

add SmartInfo


This feature provides relevant advanced information during a call.

The public API has:
- start() and stop()
- setRefreshTime(<timeMS>)
- changed() -- signal
- getters

[Guillaume Roguez <guillaume.roguez@savoirfairelinux.com>: edit for daemon API sync]
[Guillaume Roguez <guillaume.roguez@savoirfairelinux.com>: better code writting]

Change-Id: I5eb464cdfacfbf2eda318c6945c128f8b64860fc
Reviewed-by: default avatarGuillaume Roguez <guillaume.roguez@savoirfairelinux.com>
parent 17ca5194
No related branches found
No related tags found
No related merge requests found
......@@ -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)
......
/****************************************************************************
* 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);
};
......@@ -173,6 +173,13 @@ 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 {
......
/****************************************************************************
* 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;
}
/****************************************************************************
* 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;
};
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment