1 | // SPDX-FileCopyrightText: 2022 Kitsune Ral <Kitsune-Ral@users.sf.net> |
2 | // SPDX-License-Identifier: LGPL-2.1-or-later |
3 | |
4 | #include "callevents.h" |
5 | |
6 | #include "../logging_categories_p.h" |
7 | |
8 | using namespace Quotient; |
9 | |
10 | QJsonObject CallEvent::basicJson(const QString& matrixType, |
11 | const QString& callId, int version, |
12 | QJsonObject contentJson) |
13 | { |
14 | contentJson.insert(QStringLiteral("call_id" ), value: callId); |
15 | contentJson.insert(QStringLiteral("version" ), value: version); |
16 | return RoomEvent::basicJson(matrixType, content: contentJson); |
17 | } |
18 | |
19 | CallEvent::CallEvent(const QJsonObject& json) |
20 | : RoomEvent(json) |
21 | { |
22 | if (callId().isEmpty()) |
23 | qCWarning(EVENTS) << id() << "is a call event with an empty call id" ; |
24 | } |
25 | |
26 | /* |
27 | m.call.invite |
28 | { |
29 | "age": 242352, |
30 | "content": { |
31 | "call_id": "12345", |
32 | "lifetime": 60000, |
33 | "offer": { |
34 | "sdp": "v=0\r\no=- 6584580628695956864 2 IN IP4 127.0.0.1[...]", |
35 | "type": "offer" |
36 | }, |
37 | "version": 0 |
38 | }, |
39 | "event_id": "$WLGTSEFSEF:localhost", |
40 | "origin_server_ts": 1431961217939, |
41 | "room_id": "!Cuyf34gef24t:localhost", |
42 | "sender": "@example:localhost", |
43 | "type": "m.call.invite" |
44 | } |
45 | */ |
46 | |
47 | CallInviteEvent::CallInviteEvent(const QString& callId, int lifetime, |
48 | const QString& sdp) |
49 | : EventTemplate( |
50 | callId, |
51 | { { QStringLiteral("lifetime" ), lifetime }, |
52 | { QStringLiteral("offer" ), |
53 | QJsonObject{ { QStringLiteral("type" ), QStringLiteral("offer" ) }, |
54 | { QStringLiteral("sdp" ), sdp } } } }) |
55 | {} |
56 | |
57 | /* |
58 | m.call.answer |
59 | { |
60 | "age": 242352, |
61 | "content": { |
62 | "answer": { |
63 | "sdp": "v=0\r\no=- 6584580628695956864 2 IN IP4 127.0.0.1[...]", |
64 | "type": "answer" |
65 | }, |
66 | "call_id": "12345", |
67 | "version": 0 |
68 | }, |
69 | "event_id": "$WLGTSEFSEF:localhost", |
70 | "origin_server_ts": 1431961217939, |
71 | "room_id": "!Cuyf34gef24t:localhost", |
72 | "sender": "@example:localhost", |
73 | "type": "m.call.answer" |
74 | } |
75 | */ |
76 | |
77 | CallAnswerEvent::CallAnswerEvent(const QString& callId, const QString& sdp) |
78 | : EventTemplate(callId, { { QStringLiteral("answer" ), |
79 | QJsonObject { { QStringLiteral("type" ), |
80 | QStringLiteral("answer" ) }, |
81 | { QStringLiteral("sdp" ), sdp } } } }) |
82 | {} |
83 | |