QXmpp Version: 1.5.6
Loading...
Searching...
No Matches
QXmppJingleIq.h
1// SPDX-FileCopyrightText: 2010 Jeremy Lainé <jeremy.laine@m4x.org>
2// SPDX-FileCopyrightText: 2022 Melvin Keskin <melvo@olomono.de>
3//
4// SPDX-License-Identifier: LGPL-2.1-or-later
5
6#ifndef QXMPPJINGLEIQ_H
7#define QXMPPJINGLEIQ_H
8
9#include "QXmppIq.h"
10
11#include <variant>
12
13#include <QHostAddress>
14
15class QXmppJingleCandidatePrivate;
16class QXmppJingleIqContentPrivate;
17class QXmppJingleIqPrivate;
18class QXmppJinglePayloadTypePrivate;
19class QXmppJingleRtpCryptoElementPrivate;
20class QXmppJingleRtpEncryptionPrivate;
21class QXmppJingleRtpFeedbackPropertyPrivate;
22class QXmppJingleRtpHeaderExtensionPropertyPrivate;
23class QXmppSdpParameterPrivate;
24
25class QXMPP_EXPORT QXmppSdpParameter
26{
27public:
29
30 QXMPP_PRIVATE_DECLARE_RULE_OF_SIX(QXmppSdpParameter)
31
32 QString name() const;
33 void setName(const QString &name);
34
35 QString value() const;
36 void setValue(const QString &value);
37
39 void parse(const QDomElement &element);
40 void toXml(QXmlStreamWriter *writer) const;
42
43 static bool isSdpParameter(const QDomElement &element);
44
45private:
46 QSharedDataPointer<QXmppSdpParameterPrivate> d;
47};
48
50{
51public:
53
54 QXMPP_PRIVATE_DECLARE_RULE_OF_SIX(QXmppJingleRtpCryptoElement)
55
56 uint32_t tag() const;
57 void setTag(uint32_t tag);
58
59 QString cryptoSuite() const;
60 void setCryptoSuite(const QString &cryptoSuite);
61
62 QString keyParams() const;
63 void setKeyParams(const QString &keyParams);
64
65 QString sessionParams() const;
66 void setSessionParams(const QString &sessionParams);
67
69 void parse(const QDomElement &element);
70 void toXml(QXmlStreamWriter *writer) const;
72
73 static bool isJingleRtpCryptoElement(const QDomElement &element);
74
75private:
76 QSharedDataPointer<QXmppJingleRtpCryptoElementPrivate> d;
77};
78
79class QXMPP_EXPORT QXmppJingleRtpEncryption
80{
81public:
83
84 QXMPP_PRIVATE_DECLARE_RULE_OF_SIX(QXmppJingleRtpEncryption)
85
86 bool isRequired() const;
87 void setRequired(bool isRequired);
88
89 QVector<QXmppJingleRtpCryptoElement> cryptoElements() const;
90 void setCryptoElements(const QVector<QXmppJingleRtpCryptoElement> &cryptoElements);
91
93 void parse(const QDomElement &element);
94 void toXml(QXmlStreamWriter *writer) const;
96
97 static bool isJingleRtpEncryption(const QDomElement &element);
98
99private:
100 QSharedDataPointer<QXmppJingleRtpEncryptionPrivate> d;
101};
102
104{
105public:
107
108 QXMPP_PRIVATE_DECLARE_RULE_OF_SIX(QXmppJingleRtpFeedbackProperty)
109
110 QString type() const;
111 void setType(const QString &type);
112
113 QString subtype() const;
114 void setSubtype(const QString &subtype);
115
116 QVector<QXmppSdpParameter> parameters() const;
117 void setParameters(const QVector<QXmppSdpParameter> &parameters);
118
120 void parse(const QDomElement &element);
121 void toXml(QXmlStreamWriter *writer) const;
123
124 static bool isJingleRtpFeedbackProperty(const QDomElement &element);
125
126private:
127 QSharedDataPointer<QXmppJingleRtpFeedbackPropertyPrivate> d;
128};
129
131{
132public:
134
135 QXMPP_PRIVATE_DECLARE_RULE_OF_SIX(QXmppJingleRtpFeedbackInterval)
136
137 uint64_t value() const;
138 void setValue(uint64_t value);
139
141 void parse(const QDomElement &element);
142 void toXml(QXmlStreamWriter *writer) const;
144
145 static bool isJingleRtpFeedbackInterval(const QDomElement &element);
146
147private:
148 uint64_t m_value;
149};
150
152{
153public:
154 enum Senders {
160 Responder
161 };
162
164
165 QXMPP_PRIVATE_DECLARE_RULE_OF_SIX(QXmppJingleRtpHeaderExtensionProperty)
166
167 uint32_t id() const;
168 void setId(uint32_t id);
169
170 QString uri() const;
171 void setUri(const QString &uri);
172
173 Senders senders() const;
174 void setSenders(Senders senders);
175
176 QVector<QXmppSdpParameter> parameters() const;
177 void setParameters(const QVector<QXmppSdpParameter> &parameters);
178
180 void parse(const QDomElement &element);
181 void toXml(QXmlStreamWriter *writer) const;
183
184 static bool isJingleRtpHeaderExtensionProperty(const QDomElement &element);
185
186private:
187 QSharedDataPointer<QXmppJingleRtpHeaderExtensionPropertyPrivate> d;
188};
189
194class QXMPP_EXPORT QXmppJinglePayloadType
195{
196public:
200
201 unsigned char channels() const;
202 void setChannels(unsigned char channels);
203
204 unsigned int clockrate() const;
205 void setClockrate(unsigned int clockrate);
206
207 unsigned char id() const;
208 void setId(unsigned char id);
209
210 unsigned int maxptime() const;
211 void setMaxptime(unsigned int maxptime);
212
213 QString name() const;
214 void setName(const QString &name);
215
216 QMap<QString, QString> parameters() const;
217 void setParameters(const QMap<QString, QString> &parameters);
218
219 unsigned int ptime() const;
220 void setPtime(unsigned int ptime);
221
222 QVector<QXmppJingleRtpFeedbackProperty> rtpFeedbackProperties() const;
223 void setRtpFeedbackProperties(const QVector<QXmppJingleRtpFeedbackProperty> &rtpFeedbackProperties);
224
225 QVector<QXmppJingleRtpFeedbackInterval> rtpFeedbackIntervals() const;
226 void setRtpFeedbackIntervals(const QVector<QXmppJingleRtpFeedbackInterval> &rtpFeedbackIntervals);
227
229 void parse(const QDomElement &element);
230 void toXml(QXmlStreamWriter *writer) const;
232
233 QXmppJinglePayloadType &operator=(const QXmppJinglePayloadType &other);
234 bool operator==(const QXmppJinglePayloadType &other) const;
235
236private:
237 QSharedDataPointer<QXmppJinglePayloadTypePrivate> d;
238};
239
244class QXMPP_EXPORT QXmppJingleCandidate
245{
246public:
248 enum Type {
250 PeerReflexiveType,
252 ServerReflexiveType,
254 RelayedType
256 };
257
262
265
266 int component() const;
267 void setComponent(int component);
268
269 QString foundation() const;
270 void setFoundation(const QString &foundation);
271
272 int generation() const;
273 void setGeneration(int generation);
274
275 QHostAddress host() const;
276 void setHost(const QHostAddress &host);
277
278 QString id() const;
279 void setId(const QString &id);
280
281 int network() const;
282 void setNetwork(int network);
283
284 quint16 port() const;
285 void setPort(quint16 port);
286
287 int priority() const;
288 void setPriority(int priority);
289
290 QString protocol() const;
291 void setProtocol(const QString &protocol);
292
293 QXmppJingleCandidate::Type type() const;
294 void setType(QXmppJingleCandidate::Type);
295
296 bool isNull() const;
297
299 void parse(const QDomElement &element);
300 void toXml(QXmlStreamWriter *writer) const;
301
302 static QXmppJingleCandidate::Type typeFromString(const QString &typeStr, bool *ok = nullptr);
303 static QString typeToString(QXmppJingleCandidate::Type type);
305
306private:
307 QSharedDataPointer<QXmppJingleCandidatePrivate> d;
308};
309
316class QXMPP_EXPORT QXmppJingleIq : public QXmppIq
317{
318public:
320 enum Action {
321 ContentAccept,
322 ContentAdd,
323 ContentModify,
324 ContentReject,
325 ContentRemove,
326 DescriptionInfo,
327 SecurityInfo,
328 SessionAccept,
329 SessionInfo,
330 SessionInitiate,
331 SessionTerminate,
332 TransportAccept,
333 TransportInfo,
334 TransportReject,
335 TransportReplace
336 };
337
338 enum Creator {
342 Responder
343 };
344
346 {
347 };
348
350 {
351 };
352
354 {
355 };
356
358 {
361 bool isMute = true;
365 QString name;
366 };
367
369 {
370 };
371
372 using RtpSessionState = std::variant<RtpSessionStateActive, RtpSessionStateHold, RtpSessionStateUnhold, RtpSessionStateMuting, RtpSessionStateRinging>;
373
379 class QXMPP_EXPORT Content
380 {
381 public:
382 Content();
383 Content(const QXmppJingleIq::Content &other);
384 Content(QXmppJingleIq::Content &&);
385 ~Content();
386
387 Content &operator=(const Content &other);
388 Content &operator=(Content &&);
389
390 QString creator() const;
391 void setCreator(const QString &creator);
392
393 QString name() const;
394 void setName(const QString &name);
395
396 QString senders() const;
397 void setSenders(const QString &senders);
398
399 // XEP-0167: Jingle RTP Sessions
400 QString descriptionMedia() const;
401 void setDescriptionMedia(const QString &media);
402
403 quint32 descriptionSsrc() const;
404 void setDescriptionSsrc(quint32 ssrc);
405
406 bool isRtpMultiplexingSupported() const;
407 void setRtpMultiplexingSupported(bool isRtpMultiplexingSupported);
408
409 std::optional<QXmppJingleRtpEncryption> rtpEncryption() const;
410 void setRtpEncryption(const std::optional<QXmppJingleRtpEncryption> &rtpEncryption);
411
412 void addPayloadType(const QXmppJinglePayloadType &payload);
413 QList<QXmppJinglePayloadType> payloadTypes() const;
414 void setPayloadTypes(const QList<QXmppJinglePayloadType> &payloadTypes);
415
416 void addTransportCandidate(const QXmppJingleCandidate &candidate);
417 QList<QXmppJingleCandidate> transportCandidates() const;
418 void setTransportCandidates(const QList<QXmppJingleCandidate> &candidates);
419
420 QString transportUser() const;
421 void setTransportUser(const QString &user);
422
423 QString transportPassword() const;
424 void setTransportPassword(const QString &password);
425
426 QVector<QXmppJingleRtpFeedbackProperty> rtpFeedbackProperties() const;
427 void setRtpFeedbackProperties(const QVector<QXmppJingleRtpFeedbackProperty> &rtpFeedbackProperties);
428
429 QVector<QXmppJingleRtpFeedbackInterval> rtpFeedbackIntervals() const;
430 void setRtpFeedbackIntervals(const QVector<QXmppJingleRtpFeedbackInterval> &rtpFeedbackIntervals);
431
432 QVector<QXmppJingleRtpHeaderExtensionProperty> rtpHeaderExtensionProperties() const;
433 void setRtpHeaderExtensionProperties(const QVector<QXmppJingleRtpHeaderExtensionProperty> &rtpHeaderExtensionProperties);
434
435 bool isRtpHeaderExtensionMixingAllowed() const;
436 void setRtpHeaderExtensionMixingAllowed(bool isRtpHeaderExtensionMixingAllowed);
437
438 // XEP-0320: Use of DTLS-SRTP in Jingle Sessions
439 QByteArray transportFingerprint() const;
440 void setTransportFingerprint(const QByteArray &fingerprint);
441
442 QString transportFingerprintHash() const;
443 void setTransportFingerprintHash(const QString &hash);
444
445 QString transportFingerprintSetup() const;
446 void setTransportFingerprintSetup(const QString &setup);
447
449 void parse(const QDomElement &element);
450 void toXml(QXmlStreamWriter *writer) const;
451
452 bool parseSdp(const QString &sdp);
453 QString toSdp() const;
455
456 private:
457 QSharedDataPointer<QXmppJingleIqContentPrivate> d;
458 };
459
465 class QXMPP_EXPORT Reason
466 {
467 public:
469 enum Type {
470 None,
471 AlternativeSession,
472 Busy,
473 Cancel,
474 ConnectivityError,
475 Decline,
476 Expired,
477 FailedApplication,
478 FailedTransport,
479 GeneralError,
480 Gone,
481 IncompatibleParameters,
482 MediaError,
483 SecurityError,
484 Success,
485 Timeout,
486 UnsupportedApplications,
487 UnsupportedTransports
488 };
489
490 enum RtpErrorCondition {
492 NoErrorCondition,
494 InvalidCrypto,
496 CryptoRequired
497 };
498
499 Reason();
500
501 QString text() const;
502 void setText(const QString &text);
503
504 Type type() const;
505 void setType(Type type);
506
507 RtpErrorCondition rtpErrorCondition() const;
508 void setRtpErrorCondition(RtpErrorCondition rtpErrorCondition);
509
511 void parse(const QDomElement &element);
512 void toXml(QXmlStreamWriter *writer) const;
514
515 private:
516 QString m_text;
517 Type m_type;
518 RtpErrorCondition m_rtpErrorCondition = NoErrorCondition;
519 };
520
524 ~QXmppJingleIq() override;
525
528
529 Action action() const;
530 void setAction(Action action);
531
532 void addContent(const Content &content);
533 QList<Content> contents() const;
534 void setContents(const QList<Content> &contents);
535
536 QString initiator() const;
537 void setInitiator(const QString &initiator);
538
539 Reason &reason();
540 const Reason &reason() const;
541
542 QString responder() const;
543 void setResponder(const QString &responder);
544
545#if QXMPP_DEPRECATED_SINCE(1, 5)
546 QT_DEPRECATED_X("Use QXmpp::rtpSessionState() instead")
547 bool ringing() const;
548 QT_DEPRECATED_X("Use QXmpp::setRtpSessionState() instead")
549 void setRinging(bool ringing);
550#endif
551
552 QString sid() const;
553 void setSid(const QString &sid);
554
555 QString mujiGroupChatJid() const;
556 void setMujiGroupChatJid(const QString &mujiGroupChatJid);
557
558 std::optional<RtpSessionState> rtpSessionState() const;
559 void setRtpSessionState(const std::optional<RtpSessionState> &rtpSessionState);
560
562 static bool isJingleIq(const QDomElement &element);
564
565protected:
567 void parseElementFromChild(const QDomElement &element) override;
568 void toXmlElementFromChild(QXmlStreamWriter *writer) const override;
570
571private:
572 QSharedDataPointer<QXmppJingleIqPrivate> d;
573};
574
575Q_DECLARE_METATYPE(QXmppJingleIq::Reason::RtpErrorCondition)
576
577#endif
The QXmppIq class is the base class for all IQs.
Definition QXmppIq.h:23
The QXmppJingleCandidate class represents a transport candidate as specified by XEP-0176: Jingle ICE-...
Definition QXmppJingleIq.h:245
QXmppJingleCandidate(QXmppJingleCandidate &&)
Move-constructor.
QXmppJingleCandidate & operator=(const QXmppJingleCandidate &other)
Assignment operator.
QXmppJingleCandidate & operator=(QXmppJingleCandidate &&)
Move-assignment operator.
QXmppJingleCandidate(const QXmppJingleCandidate &other)
Copy-constructor.
Type
This enum is used to describe a candidate's type.
Definition QXmppJingleIq.h:248
@ HostType
Host candidate, a local address/port.
Definition QXmppJingleIq.h:249
The QXmppJingleIq class represents an IQ used for initiating media sessions as specified by XEP-0166:...
Definition QXmppJingleIq.h:317
QXmppJingleIq & operator=(const QXmppJingleIq &other)
Assignment operator.
QXmppJingleIq & operator=(QXmppJingleIq &&)
Move-assignment operator.
QXmppJingleIq(QXmppJingleIq &&)
Move-constructor.
Action
This enum is used to describe a Jingle action.
Definition QXmppJingleIq.h:320
Creator
Definition QXmppJingleIq.h:338
@ Initiator
The initiator generated the content type.
Definition QXmppJingleIq.h:340
QXmppJingleIq(const QXmppJingleIq &other)
Copy-constructor.
std::variant< RtpSessionStateActive, RtpSessionStateHold, RtpSessionStateUnhold, RtpSessionStateMuting, RtpSessionStateRinging > RtpSessionState
Definition QXmppJingleIq.h:372
The QXmppJinglePayloadType class represents a payload type as specified by XEP-0167: Jingle RTP Sessi...
Definition QXmppJingleIq.h:195
The QXmppJingleRtpCryptoElement class represents the XEP-0167: Jingle RTP Sessions "crypto" element u...
Definition QXmppJingleIq.h:50
The QXmppJingleRtpEncryption class represents the XEP-0167: Jingle RTP Sessions "encryption" element ...
Definition QXmppJingleIq.h:80
The QXmppJingleRtpFeedbackInterval class represents the XEP-0293: Jingle RTP Feedback Negotiation "rt...
Definition QXmppJingleIq.h:131
The QXmppJingleRtpFeedbackProperty class represents the XEP-0293: Jingle RTP Feedback Negotiation "rt...
Definition QXmppJingleIq.h:104
The QXmppJingleRtpHeaderExtensionProperty class represents the XEP-0294: Jingle RTP Header Extensions...
Definition QXmppJingleIq.h:152
Senders
Definition QXmppJingleIq.h:154
@ Initiator
Only the initiator is allowed.
Definition QXmppJingleIq.h:158
@ Both
The initiator and the sender are allowed.
Definition QXmppJingleIq.h:156
The QXmppSdpParameter class represents a Session Description Protocol (SDP) parameter specified by RF...
Definition QXmppJingleIq.h:26
Definition QXmppJingleIq.h:346
Definition QXmppJingleIq.h:350
Definition QXmppJingleIq.h:358
QString name
Session to be muted (e.g., only audio or video)
Definition QXmppJingleIq.h:365
Creator creator
Creator of the corresponding session.
Definition QXmppJingleIq.h:363
Definition QXmppJingleIq.h:369
Definition QXmppJingleIq.h:354