QXmpp Version: 1.11.3
Loading...
Searching...
No Matches
QXmppJingleData.h
1// SPDX-FileCopyrightText: 2010 Jeremy Lainé <jeremy.laine@m4x.org>
2// SPDX-FileCopyrightText: 2022 Melvin Keskin <melvo@olomono.de>
3// SPDX-FileCopyrightText: 2023 Tibor Csötönyi <work@taibsu.de>
4//
5// SPDX-License-Identifier: LGPL-2.1-or-later
6
7#ifndef QXMPPJINGLEIQ_H
8#define QXMPPJINGLEIQ_H
9
10#include "QXmppConstants_p.h"
11#include "QXmppIq.h"
12
13#include <variant>
14
15#include <QHostAddress>
16
17class QXmppJingleCandidatePrivate;
18class QXmppJingleDescriptionPrivate;
19class QXmppJingleIqContentPrivate;
20class QXmppJingleIqReasonPrivate;
21class QXmppJingleIqPrivate;
22class QXmppJinglePayloadTypePrivate;
23class QXmppJingleRtpCryptoElementPrivate;
24class QXmppJingleRtpEncryptionPrivate;
25class QXmppJingleRtpFeedbackPropertyPrivate;
26class QXmppJingleRtpHeaderExtensionPropertyPrivate;
27class QXmppSdpParameterPrivate;
28class QXmppJingleMessageInitiationElementPrivate;
29class QXmppCallInviteElementPrivate;
30
31class QXMPP_EXPORT QXmppSdpParameter
32{
33public:
35
36 QXMPP_PRIVATE_DECLARE_RULE_OF_SIX(QXmppSdpParameter)
37
38 QString name() const;
39 void setName(const QString &name);
40
41 QString value() const;
42 void setValue(const QString &value);
43
45 void parse(const QDomElement &element);
46 void toXml(QXmlStreamWriter *writer) const;
48
49 static bool isSdpParameter(const QDomElement &element);
50
51private:
52 QSharedDataPointer<QXmppSdpParameterPrivate> d;
53};
54
56{
57public:
59
60 QXMPP_PRIVATE_DECLARE_RULE_OF_SIX(QXmppJingleRtpCryptoElement)
61
62 uint32_t tag() const;
63 void setTag(uint32_t tag);
64
65 QString cryptoSuite() const;
66 void setCryptoSuite(const QString &cryptoSuite);
67
68 QString keyParams() const;
69 void setKeyParams(const QString &keyParams);
70
71 QString sessionParams() const;
72 void setSessionParams(const QString &sessionParams);
73
75 static constexpr std::tuple XmlTag = { u"crypto", QXmpp::Private::ns_jingle_rtp };
76 void parse(const QDomElement &element);
77 void toXml(QXmlStreamWriter *writer) const;
79
80 static bool isJingleRtpCryptoElement(const QDomElement &element);
81
82private:
83 QSharedDataPointer<QXmppJingleRtpCryptoElementPrivate> d;
84};
85
86class QXMPP_EXPORT QXmppJingleRtpEncryption
87{
88public:
90
91 QXMPP_PRIVATE_DECLARE_RULE_OF_SIX(QXmppJingleRtpEncryption)
92
93 bool isRequired() const;
94 void setRequired(bool isRequired);
95
96 QVector<QXmppJingleRtpCryptoElement> cryptoElements() const;
97 void setCryptoElements(const QVector<QXmppJingleRtpCryptoElement> &cryptoElements);
98
100 static constexpr std::tuple XmlTag = { u"encryption", QXmpp::Private::ns_jingle_rtp };
101 void parse(const QDomElement &element);
102 void toXml(QXmlStreamWriter *writer) const;
104
105 static bool isJingleRtpEncryption(const QDomElement &element);
106
107private:
108 QSharedDataPointer<QXmppJingleRtpEncryptionPrivate> d;
109};
110
112{
113public:
115
116 QXMPP_PRIVATE_DECLARE_RULE_OF_SIX(QXmppJingleRtpFeedbackProperty)
117
118 QString type() const;
119 void setType(const QString &type);
120
121 QString subtype() const;
122 void setSubtype(const QString &subtype);
123
124 QVector<QXmppSdpParameter> parameters() const;
125 void setParameters(const QVector<QXmppSdpParameter> &parameters);
126
128 static constexpr std::tuple XmlTag = { u"rtcp-fb", QXmpp::Private::ns_jingle_rtcp_fb };
129 void parse(const QDomElement &element);
130 void toXml(QXmlStreamWriter *writer) const;
132
133 static bool isJingleRtpFeedbackProperty(const QDomElement &element);
134
135private:
136 QSharedDataPointer<QXmppJingleRtpFeedbackPropertyPrivate> d;
137};
138
140{
141public:
143
144 QXMPP_PRIVATE_DECLARE_RULE_OF_SIX(QXmppJingleRtpFeedbackInterval)
145
146 uint64_t value() const;
147 void setValue(uint64_t value);
148
150 static constexpr std::tuple XmlTag = { u"rtcp-fb-trr-int", QXmpp::Private::ns_jingle_rtcp_fb };
151 void parse(const QDomElement &element);
152 void toXml(QXmlStreamWriter *writer) const;
154
155 static bool isJingleRtpFeedbackInterval(const QDomElement &element);
156
157private:
158 uint64_t m_value;
159};
160
162{
163public:
164 enum Senders {
170 Responder
171 };
172
174
175 QXMPP_PRIVATE_DECLARE_RULE_OF_SIX(QXmppJingleRtpHeaderExtensionProperty)
176
177 uint32_t id() const;
178 void setId(uint32_t id);
179
180 QString uri() const;
181 void setUri(const QString &uri);
182
183 Senders senders() const;
184 void setSenders(Senders senders);
185
186 QVector<QXmppSdpParameter> parameters() const;
187 void setParameters(const QVector<QXmppSdpParameter> &parameters);
188
190 static constexpr std::tuple XmlTag = { u"rtp-hdrext", QXmpp::Private::ns_jingle_rtp_hdrext };
191 void parse(const QDomElement &element);
192 void toXml(QXmlStreamWriter *writer) const;
194
195 static bool isJingleRtpHeaderExtensionProperty(const QDomElement &element);
196
197private:
198 QSharedDataPointer<QXmppJingleRtpHeaderExtensionPropertyPrivate> d;
199};
200
205class QXMPP_EXPORT QXmppJinglePayloadType
206{
207public:
211
212 unsigned char channels() const;
213 void setChannels(unsigned char channels);
214
215 unsigned int clockrate() const;
216 void setClockrate(unsigned int clockrate);
217
218 unsigned char id() const;
219 void setId(unsigned char id);
220
221 unsigned int maxptime() const;
222 void setMaxptime(unsigned int maxptime);
223
224 QString name() const;
225 void setName(const QString &name);
226
227 QMap<QString, QString> parameters() const;
228 void setParameters(const QMap<QString, QString> &parameters);
229
230 unsigned int ptime() const;
231 void setPtime(unsigned int ptime);
232
233 QVector<QXmppJingleRtpFeedbackProperty> rtpFeedbackProperties() const;
234 void setRtpFeedbackProperties(const QVector<QXmppJingleRtpFeedbackProperty> &rtpFeedbackProperties);
235
236 QVector<QXmppJingleRtpFeedbackInterval> rtpFeedbackIntervals() const;
237 void setRtpFeedbackIntervals(const QVector<QXmppJingleRtpFeedbackInterval> &rtpFeedbackIntervals);
238
240 static constexpr std::tuple XmlTag = { u"payload-type", QXmpp::Private::ns_jingle_rtp };
241 void parse(const QDomElement &element);
242 void toXml(QXmlStreamWriter *writer) const;
244
245 QXmppJinglePayloadType &operator=(const QXmppJinglePayloadType &other);
246 bool operator==(const QXmppJinglePayloadType &other) const;
247
248private:
249 QSharedDataPointer<QXmppJinglePayloadTypePrivate> d;
250};
251
252class QXMPP_EXPORT QXmppJingleDescription
253{
254public:
256 QXMPP_PRIVATE_DECLARE_RULE_OF_SIX(QXmppJingleDescription)
257
258 QString media() const;
259 void setMedia(const QString &media);
260
261 quint32 ssrc() const;
262 void setSsrc(quint32 ssrc);
263
264 QString type() const;
265 void setType(const QString &type);
266
267 void addPayloadType(const QXmppJinglePayloadType &payload);
268 const QList<QXmppJinglePayloadType> &payloadTypes() const;
269 void setPayloadTypes(const QList<QXmppJinglePayloadType> &payloadTypes);
270
272 static constexpr std::tuple XmlTag = { u"description", QXmpp::Private::ns_jingle_rtp };
273 void parse(const QDomElement &element);
274 void toXml(QXmlStreamWriter *writer) const;
276
277private:
278 QSharedDataPointer<QXmppJingleDescriptionPrivate> d;
279};
280
285class QXMPP_EXPORT QXmppJingleCandidate
286{
287public:
289 enum Type {
291 PeerReflexiveType,
293 ServerReflexiveType,
295 RelayedType
297 };
298
303
306
307 int component() const;
308 void setComponent(int component);
309
310 QString foundation() const;
311 void setFoundation(const QString &foundation);
312
313 int generation() const;
314 void setGeneration(int generation);
315
316 QHostAddress host() const;
317 void setHost(const QHostAddress &host);
318
319 QString id() const;
320 void setId(const QString &id);
321
322 int network() const;
323 void setNetwork(int network);
324
325 quint16 port() const;
326 void setPort(quint16 port);
327
328 int priority() const;
329 void setPriority(int priority);
330
331 QString protocol() const;
332 void setProtocol(const QString &protocol);
333
334 QXmppJingleCandidate::Type type() const;
335 void setType(QXmppJingleCandidate::Type);
336
337 bool isNull() const;
338
340 static constexpr std::tuple XmlTag = { u"candidate", QXmpp::Private::ns_jingle_ice_udp };
341 void parse(const QDomElement &element);
342 void toXml(QXmlStreamWriter *writer) const;
344
345private:
346 QSharedDataPointer<QXmppJingleCandidatePrivate> d;
347};
348
349class QXMPP_EXPORT QXmppJingleReason
350{
351public:
353 enum Type {
354 None,
355 AlternativeSession,
356 Busy,
357 Cancel,
358 ConnectivityError,
359 Decline,
360 Expired,
361 FailedApplication,
362 FailedTransport,
363 GeneralError,
364 Gone,
365 IncompatibleParameters,
366 MediaError,
367 SecurityError,
368 Success,
369 Timeout,
370 UnsupportedApplications,
371 UnsupportedTransports
372 };
373
384
386 QXmppJingleReason(Type, const QString &, std::optional<RtpErrorCondition>);
387 QXMPP_PRIVATE_DECLARE_RULE_OF_SIX(QXmppJingleReason)
388
389 QString text() const;
390 void setText(const QString &text);
391
392 Type type() const;
393 void setType(Type type);
394
395 RtpErrorCondition rtpErrorCondition() const;
396 void setRtpErrorCondition(RtpErrorCondition rtpErrorCondition);
397
399 static constexpr std::tuple XmlTag = { u"reason", QXmpp::Private::ns_jingle };
400 void parse(const QDomElement &element);
401 void toXml(QXmlStreamWriter *writer) const;
403
404private:
405 QSharedDataPointer<QXmppJingleIqReasonPrivate> d;
406};
407
414class QXMPP_EXPORT QXmppJingleIq : public QXmppIq
415{
416public:
418 enum Action {
419 ContentAccept,
420 ContentAdd,
421 ContentModify,
422 ContentReject,
423 ContentRemove,
424 DescriptionInfo,
425 SecurityInfo,
426 SessionAccept,
427 SessionInfo,
428 SessionInitiate,
429 SessionTerminate,
430 TransportAccept,
431 TransportInfo,
432 TransportReject,
433 TransportReplace
434 };
435
436 enum Creator {
440 Responder
441 };
442
456
457 using RtpSessionState = std::variant<RtpSessionStateActive, RtpSessionStateHold, RtpSessionStateUnhold, RtpSessionStateMuting, RtpSessionStateRinging>;
458
461
467 class QXMPP_EXPORT Content
468 {
469 public:
470 Content();
471 Content(const QXmppJingleIq::Content &other);
472 Content(QXmppJingleIq::Content &&);
473 ~Content();
474
475 Content &operator=(const Content &other);
476 Content &operator=(Content &&);
477
478 QString creator() const;
479 void setCreator(const QString &creator);
480
481 QString name() const;
482 void setName(const QString &name);
483
484 QString senders() const;
485 void setSenders(const QString &senders);
486
487 // XEP-0167: Jingle RTP Sessions
488 QXmppJingleDescription description() const;
489 void setDescription(const QXmppJingleDescription &description);
490
491#if QXMPP_DEPRECATED_SINCE(1, 6)
492 QString descriptionMedia() const;
493 void setDescriptionMedia(const QString &media);
494
495 quint32 descriptionSsrc() const;
496 void setDescriptionSsrc(quint32 ssrc);
497
498 void addPayloadType(const QXmppJinglePayloadType &payload);
499 QList<QXmppJinglePayloadType> payloadTypes() const;
500 void setPayloadTypes(const QList<QXmppJinglePayloadType> &payloadTypes);
501#endif
502
503 bool isRtpMultiplexingSupported() const;
504 void setRtpMultiplexingSupported(bool isRtpMultiplexingSupported);
505
506 std::optional<QXmppJingleRtpEncryption> rtpEncryption() const;
507 void setRtpEncryption(const std::optional<QXmppJingleRtpEncryption> &rtpEncryption);
508
509 void addTransportCandidate(const QXmppJingleCandidate &candidate);
510 QList<QXmppJingleCandidate> transportCandidates() const;
511 void setTransportCandidates(const QList<QXmppJingleCandidate> &candidates);
512
513 QString transportUser() const;
514 void setTransportUser(const QString &user);
515
516 QString transportPassword() const;
517 void setTransportPassword(const QString &password);
518
519 QVector<QXmppJingleRtpFeedbackProperty> rtpFeedbackProperties() const;
520 void setRtpFeedbackProperties(const QVector<QXmppJingleRtpFeedbackProperty> &rtpFeedbackProperties);
521
522 QVector<QXmppJingleRtpFeedbackInterval> rtpFeedbackIntervals() const;
523 void setRtpFeedbackIntervals(const QVector<QXmppJingleRtpFeedbackInterval> &rtpFeedbackIntervals);
524
525 QVector<QXmppJingleRtpHeaderExtensionProperty> rtpHeaderExtensionProperties() const;
526 void setRtpHeaderExtensionProperties(const QVector<QXmppJingleRtpHeaderExtensionProperty> &rtpHeaderExtensionProperties);
527
528 bool isRtpHeaderExtensionMixingAllowed() const;
529 void setRtpHeaderExtensionMixingAllowed(bool isRtpHeaderExtensionMixingAllowed);
530
531 // XEP-0320: Use of DTLS-SRTP in Jingle Sessions
532 QByteArray transportFingerprint() const;
533 void setTransportFingerprint(const QByteArray &fingerprint);
534
535 QString transportFingerprintHash() const;
536 void setTransportFingerprintHash(const QString &hash);
537
538 QString transportFingerprintSetup() const;
539 void setTransportFingerprintSetup(const QString &setup);
540
542 static constexpr std::tuple XmlTag = { u"content", QXmpp::Private::ns_jingle };
543 void parse(const QDomElement &element);
544 void toXml(QXmlStreamWriter *writer) const;
545
546 bool parseSdp(const QString &sdp);
547 QString toSdp() const;
549
550 private:
551 QSharedDataPointer<QXmppJingleIqContentPrivate> d;
552 };
553
557 ~QXmppJingleIq() override;
558
561
562 Action action() const;
563 void setAction(Action action);
564
565 void addContent(const Content &content);
566 QList<Content> contents() const;
567 void setContents(const QList<Content> &contents);
568
569 QString initiator() const;
570 void setInitiator(const QString &initiator);
571
572 std::optional<QXmppJingleReason> actionReason() const;
573 void setActionReason(const std::optional<QXmppJingleReason> &);
574
575#if QXMPP_DEPRECATED_SINCE(1, 11)
576 [[deprecated("Use actionReason() instead.")]]
577 QXmppJingleReason &reason();
578 [[deprecated("Use actionReason() instead.")]]
579 const QXmppJingleReason &reason() const;
580#endif
581
582 QString responder() const;
583 void setResponder(const QString &responder);
584
585#if QXMPP_DEPRECATED_SINCE(1, 5)
586 QT_DEPRECATED_X("Use QXmpp::rtpSessionState() instead")
587 bool ringing() const;
588 QT_DEPRECATED_X("Use QXmpp::setRtpSessionState() instead")
589 void setRinging(bool ringing);
590#endif
591
592 QString sid() const;
593 void setSid(const QString &sid);
594
595 QString mujiGroupChatJid() const;
596 void setMujiGroupChatJid(const QString &mujiGroupChatJid);
597
598 std::optional<RtpSessionState> rtpSessionState() const;
599 void setRtpSessionState(const std::optional<RtpSessionState> &rtpSessionState);
600
602 static bool isJingleIq(const QDomElement &element);
604
605protected:
607 void parseElementFromChild(const QDomElement &element) override;
608 void toXmlElementFromChild(QXmlStreamWriter *writer) const override;
610
611private:
612 QSharedDataPointer<QXmppJingleIqPrivate> d;
613};
614
616{
617public:
618 enum class Type {
619 None,
620 Propose,
621 Ringing,
622 Proceed,
623 Reject,
624 Retract,
625 Finish
626 };
627
629 QXMPP_PRIVATE_DECLARE_RULE_OF_SIX(QXmppJingleMessageInitiationElement)
630
631 Type type() const;
632 void setType(Type type);
633
634 QString id() const;
635 void setId(const QString &id);
636
637 std::optional<QXmppJingleDescription> description() const;
638 void setDescription(std::optional<QXmppJingleDescription> description);
639
640 std::optional<QXmppJingleReason> reason() const;
641 void setReason(std::optional<QXmppJingleReason> reason);
642
643 bool containsTieBreak() const;
644 void setContainsTieBreak(bool containsTieBreak);
645
646 QString migratedTo() const;
647 void setMigratedTo(const QString &migratedTo);
648
650 void parse(const QDomElement &element);
651 void toXml(QXmlStreamWriter *writer) const;
653
654 static bool isJingleMessageInitiationElement(const QDomElement &);
655
656private:
657 QSharedDataPointer<QXmppJingleMessageInitiationElementPrivate> d;
658};
659
660class QXMPP_EXPORT QXmppCallInviteElement
661{
662public:
663 enum class Type {
664 None,
665 Invite,
666 Retract,
667 Accept,
668 Reject,
669 Left
670 };
671
672 struct Jingle {
673 QString sid;
674 std::optional<QString> jid;
675
676 bool operator==(const Jingle &other) const { return other.sid == sid && other.jid == jid; }
677
678 void parse(const QDomElement &element);
679 void toXml(QXmlStreamWriter *writer) const;
680 };
681
682 struct External {
683 QString uri;
684
685 bool operator==(const External &other) const { return other.uri == uri; }
686
687 static constexpr std::tuple XmlTag = { u"external", QXmpp::Private::ns_call_invites };
688 void parse(const QDomElement &el);
689 void toXml(QXmlStreamWriter *writer) const;
690 };
691
693 QXMPP_PRIVATE_DECLARE_RULE_OF_SIX(QXmppCallInviteElement)
694
695 Type type() const;
696 void setType(Type type);
697
698 QString id() const;
699 void setId(const QString &id);
700
701 bool audio() const;
702 void setAudio(bool audio);
703
704 bool video() const;
705 void setVideo(bool video);
706
707 std::optional<Jingle> jingle() const;
708 void setJingle(std::optional<Jingle> jingle);
709
710 std::optional<QVector<External>> external() const;
711 void setExternal(std::optional<QVector<External>> external);
712
714 void parse(const QDomElement &element);
715 void toXml(QXmlStreamWriter *writer) const;
717
718 static bool isCallInviteElement(const QDomElement &);
719
720private:
721 QSharedDataPointer<QXmppCallInviteElementPrivate> d;
722};
723
724Q_DECLARE_METATYPE(QXmppJingleReason::RtpErrorCondition)
725
726#endif
The QXmppCallInviteElement class represents a Call Invite element as specified by XEP-0482: Call Invi...
Definition QXmppJingleData.h:661
Type
Definition QXmppJingleData.h:663
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 QXmppJingleData.h:286
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 QXmppJingleData.h:289
@ HostType
Host candidate, a local address/port.
Definition QXmppJingleData.h:290
The QXmppJingleDescription class represents descriptions for Jingle elements including media type,...
Definition QXmppJingleData.h:253
The QXmppJingleIq class represents an IQ used for initiating media sessions as specified by XEP-0166:...
Definition QXmppJingleData.h:415
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 QXmppJingleData.h:418
Creator
Definition QXmppJingleData.h:436
@ Initiator
The initiator generated the content type.
Definition QXmppJingleData.h:438
QXmppJingleIq(const QXmppJingleIq &other)
Copy-constructor.
std::variant< RtpSessionStateActive, RtpSessionStateHold, RtpSessionStateUnhold, RtpSessionStateMuting, RtpSessionStateRinging > RtpSessionState
Definition QXmppJingleData.h:457
The QXmppJingleMessageInitiationElement class represents a Jingle Message Initiation element as speci...
Definition QXmppJingleData.h:616
Type
Definition QXmppJingleData.h:618
The QXmppJinglePayloadType class represents a payload type as specified by XEP-0167: Jingle RTP Sessi...
Definition QXmppJingleData.h:206
Definition QXmppJingleData.h:350
Type
This enum is used to describe a reason's type.
Definition QXmppJingleData.h:353
RtpErrorCondition
Definition QXmppJingleData.h:376
@ InvalidCrypto
The encryption offer is rejected.
Definition QXmppJingleData.h:380
@ NoErrorCondition
There is no error condition.
Definition QXmppJingleData.h:378
The QXmppJingleRtpCryptoElement class represents the XEP-0167: Jingle RTP Sessions "crypto" element u...
Definition QXmppJingleData.h:56
The QXmppJingleRtpEncryption class represents the XEP-0167: Jingle RTP Sessions "encryption" element ...
Definition QXmppJingleData.h:87
The QXmppJingleRtpFeedbackInterval class represents the XEP-0293: Jingle RTP Feedback Negotiation "rt...
Definition QXmppJingleData.h:140
The QXmppJingleRtpFeedbackProperty class represents the XEP-0293: Jingle RTP Feedback Negotiation "rt...
Definition QXmppJingleData.h:112
The QXmppJingleRtpHeaderExtensionProperty class represents the XEP-0294: Jingle RTP Header Extensions...
Definition QXmppJingleData.h:162
Senders
Definition QXmppJingleData.h:164
@ Initiator
Only the initiator is allowed.
Definition QXmppJingleData.h:168
@ Both
The initiator and the sender are allowed.
Definition QXmppJingleData.h:166
The QXmppSdpParameter class represents a Session Description Protocol (SDP) parameter specified by RF...
Definition QXmppJingleData.h:32
Definition Algorithms.h:14
Definition QXmppJingleData.h:443
Definition QXmppJingleData.h:444
Definition QXmppJingleData.h:446
QString name
Session to be muted (e.g., only audio or video)
Definition QXmppJingleData.h:453
bool isMute
Definition QXmppJingleData.h:449
Creator creator
Creator of the corresponding session.
Definition QXmppJingleData.h:451
Definition QXmppJingleData.h:455
Definition QXmppJingleData.h:445