Permalink
Browse files

Add voice and video call support

This implements matrix voice and video call support using oxide to
handle WebRTC.
  • Loading branch information...
1 parent 6414a69 commit a1f2cfff5d090c97d2481c8af26c81defdf61530 @mariogrip committed Nov 8, 2017
@@ -31,6 +31,10 @@
#include "libqmatrixclient/events/roommessageevent.h"
#include "libqmatrixclient/events/roommemberevent.h"
#include "libqmatrixclient/events/simplestateevents.h"
+#include "libqmatrixclient/events/callinviteevent.h"
+#include "libqmatrixclient/events/callcandidatesevent.h"
+#include "libqmatrixclient/events/callanswerevent.h"
+#include "libqmatrixclient/events/callhangupevent.h"
using namespace QMatrixClient;
@@ -163,6 +167,10 @@ QVariant MessageEventModel::data(const QModelIndex& index, int role) const
case EventType::RoomTopic:
case EventType::Typing:
case EventType::Receipt:
+ case EventType::CallInvite:
+ case EventType::CallCandidates:
+ case EventType::CallAnswer:
+ case EventType::CallHangup:
return "state";
default:
return "unknown";
@@ -254,6 +262,22 @@ QVariant MessageEventModel::data(const QModelIndex& index, int role) const
RoomAliasesEvent* e = static_cast<RoomAliasesEvent*>(event);
return QString("Current aliases: %1").arg(e->aliases().join(", "));
}
+ if( event->type() == EventType::CallInvite )
+ {
+ return "CallInvite";
+ }
+ if( event->type() == EventType::CallCandidates )
+ {
+ return "CallCandidates";
+ }
+ if( event->type() == EventType::CallAnswer )
+ {
+ return "CallAnswer";
+ }
+ if( event->type() == EventType::CallHangup )
+ {
+ return "CallHangup";
+ }
if( event->type() == EventType::Unknown )
{
return "Unknown Event: " + event->originalJsonObject()["type"].toString();
@@ -22,8 +22,17 @@
#include <QtGui/QColor>
#include <QtCore/QDebug>
+#include "libqmatrixclient/events/event.h"
+#include "libqmatrixclient/events/callinviteevent.h"
+#include "libqmatrixclient/events/callcandidatesevent.h"
+#include "libqmatrixclient/events/callanswerevent.h"
+#include "libqmatrixclient/events/callhangupevent.h"
#include "libqmatrixclient/connection.h"
#include "libqmatrixclient/room.h"
+#include "libqmatrixclient/logging.h"
+
+
+using namespace QMatrixClient;
const int RoomEventStateRole = Qt::UserRole + 1;
@@ -48,6 +57,7 @@ void RoomListModel::setConnection(QMatrixClient::Connection* connection)
for( QMatrixClient::Room* room: connection->roomMap().values() ) {
connect( room, &QMatrixClient::Room::namesChanged, this, &RoomListModel::namesChanged );
+ connect( room, &QMatrixClient::Room::callEvent, this, &RoomListModel::callEventChanged );
m_rooms.append(room);
}
endResetModel();
@@ -72,6 +82,8 @@ void RoomListModel::addRoom(QMatrixClient::Room* room)
connect( room, &QMatrixClient::Room::namesChanged, this, &RoomListModel::namesChanged );
connect( room, &QMatrixClient::Room::unreadMessagesChanged, this, &RoomListModel::unreadMessagesChanged );
connect( room, &QMatrixClient::Room::highlightCountChanged, this, &RoomListModel::highlightCountChanged );
+
+ connect( room, &QMatrixClient::Room::callEvent, this, &RoomListModel::callEventChanged );
m_rooms.append(room);
endInsertRows();
}
@@ -135,3 +147,31 @@ void RoomListModel::highlightCountChanged(QMatrixClient::Room* room)
int row = m_rooms.indexOf(room);
emit dataChanged(index(row), index(row));
}
+
+void RoomListModel::callEventChanged(QMatrixClient::Room* room, QMatrixClient::RoomEvent* event) {
+ switch (event->type())
+ {
+ case EventType::CallInvite: {
+ auto callInviteEvent = static_cast<CallInviteEvent*>(event);
+ emit callEvent("invite", room, callInviteEvent->toJson());
+ break;
+ }
+ case EventType::CallCandidates: {
+ auto callCandidatesEvent = static_cast<CallCandidatesEvent*>(event);
+ emit callEvent("candidates", room, callCandidatesEvent->toJson());
+ break;
+ }
+ case EventType::CallAnswer: {
+ auto callAnswerEvent = static_cast<CallAnswerEvent*>(event);
+ qCDebug(MAIN) << callAnswerEvent->toJson();
+ emit callEvent("answer", room, callAnswerEvent->toJson());
+ break;
+ }
+ case EventType::CallHangup: {
+ auto callHangupEvent = static_cast<CallHangupEvent*>(event);
+ emit callEvent("hangup", room, callHangupEvent->toJson());
+ break;
+ }
+ default: /* Ignore events of other types */;
+ }
+}
@@ -21,6 +21,9 @@
#include <QtCore/QAbstractListModel>
+#include "events/event.h"
+#include "libqmatrixclient/events/event.h"
+
namespace QMatrixClient
{
class Connection;
@@ -42,12 +45,17 @@ class RoomListModel: public QAbstractListModel
QHash<int, QByteArray> roleNames() const override;
+ signals:
+ void callEvent(const QString& type, QMatrixClient::Room* room, const QJsonObject& event);
+
private slots:
void namesChanged(QMatrixClient::Room* room);
void unreadMessagesChanged(QMatrixClient::Room* room);
void addRoom(QMatrixClient::Room* room);
void highlightCountChanged(QMatrixClient::Room* room);
+ void callEventChanged(QMatrixClient::Room* room, QMatrixClient::RoomEvent* event);
+
private:
QMatrixClient::Connection* m_connection;
QList<QMatrixClient::Room*> m_rooms;
Oops, something went wrong.

0 comments on commit a1f2cff

Please sign in to comment.