QXmpp  Version: 1.7.1
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 "QXmppIq.h"
11 
12 #include <variant>
13 
14 #include <QHostAddress>
15 
16 class QXmppJingleCandidatePrivate;
17 class QXmppJingleDescriptionPrivate;
18 class QXmppJingleIqContentPrivate;
19 class QXmppJingleIqReasonPrivate;
20 class QXmppJingleIqPrivate;
21 class QXmppJinglePayloadTypePrivate;
22 class QXmppJingleRtpCryptoElementPrivate;
23 class QXmppJingleRtpEncryptionPrivate;
24 class QXmppJingleRtpFeedbackPropertyPrivate;
25 class QXmppJingleRtpHeaderExtensionPropertyPrivate;
26 class QXmppSdpParameterPrivate;
27 class QXmppJingleMessageInitiationElementPrivate;
28 class QXmppCallInviteElementPrivate;
29 
30 class QXMPP_EXPORT QXmppSdpParameter
31 {
32 public:
34 
35  QXMPP_PRIVATE_DECLARE_RULE_OF_SIX(QXmppSdpParameter)
36 
37  QString name() const;
38  void setName(const QString &name);
39 
40  QString value() const;
41  void setValue(const QString &value);
42 
44  void parse(const QDomElement &element);
45  void toXml(QXmlStreamWriter *writer) const;
47 
48  static bool isSdpParameter(const QDomElement &element);
49 
50 private:
51  QSharedDataPointer<QXmppSdpParameterPrivate> d;
52 };
53 
54 class QXMPP_EXPORT QXmppJingleRtpCryptoElement
55 {
56 public:
58 
59  QXMPP_PRIVATE_DECLARE_RULE_OF_SIX(QXmppJingleRtpCryptoElement)
60 
61  uint32_t tag() const;
62  void setTag(uint32_t tag);
63 
64  QString cryptoSuite() const;
65  void setCryptoSuite(const QString &cryptoSuite);
66 
67  QString keyParams() const;
68  void setKeyParams(const QString &keyParams);
69 
70  QString sessionParams() const;
71  void setSessionParams(const QString &sessionParams);
72 
74  void parse(const QDomElement &element);
75  void toXml(QXmlStreamWriter *writer) const;
77 
78  static bool isJingleRtpCryptoElement(const QDomElement &element);
79 
80 private:
81  QSharedDataPointer<QXmppJingleRtpCryptoElementPrivate> d;
82 };
83 
84 class QXMPP_EXPORT QXmppJingleRtpEncryption
85 {
86 public:
88 
89  QXMPP_PRIVATE_DECLARE_RULE_OF_SIX(QXmppJingleRtpEncryption)
90 
91  bool isRequired() const;
92  void setRequired(bool isRequired);
93 
94  QVector<QXmppJingleRtpCryptoElement> cryptoElements() const;
95  void setCryptoElements(const QVector<QXmppJingleRtpCryptoElement> &cryptoElements);
96 
98  void parse(const QDomElement &element);
99  void toXml(QXmlStreamWriter *writer) const;
101 
102  static bool isJingleRtpEncryption(const QDomElement &element);
103 
104 private:
105  QSharedDataPointer<QXmppJingleRtpEncryptionPrivate> d;
106 };
107 
109 {
110 public:
112 
113  QXMPP_PRIVATE_DECLARE_RULE_OF_SIX(QXmppJingleRtpFeedbackProperty)
114 
115  QString type() const;
116  void setType(const QString &type);
117 
118  QString subtype() const;
119  void setSubtype(const QString &subtype);
120 
121  QVector<QXmppSdpParameter> parameters() const;
122  void setParameters(const QVector<QXmppSdpParameter> &parameters);
123 
125  void parse(const QDomElement &element);
126  void toXml(QXmlStreamWriter *writer) const;
128 
129  static bool isJingleRtpFeedbackProperty(const QDomElement &element);
130 
131 private:
132  QSharedDataPointer<QXmppJingleRtpFeedbackPropertyPrivate> d;
133 };
134 
136 {
137 public:
139 
140  QXMPP_PRIVATE_DECLARE_RULE_OF_SIX(QXmppJingleRtpFeedbackInterval)
141 
142  uint64_t value() const;
143  void setValue(uint64_t value);
144 
146  void parse(const QDomElement &element);
147  void toXml(QXmlStreamWriter *writer) const;
149 
150  static bool isJingleRtpFeedbackInterval(const QDomElement &element);
151 
152 private:
153  uint64_t m_value;
154 };
155 
157 {
158 public:
159  enum Senders {
165  Responder
166  };
167 
169 
170  QXMPP_PRIVATE_DECLARE_RULE_OF_SIX(QXmppJingleRtpHeaderExtensionProperty)
171 
172  uint32_t id() const;
173  void setId(uint32_t id);
174 
175  QString uri() const;
176  void setUri(const QString &uri);
177 
178  Senders senders() const;
179  void setSenders(Senders senders);
180 
181  QVector<QXmppSdpParameter> parameters() const;
182  void setParameters(const QVector<QXmppSdpParameter> &parameters);
183 
185  void parse(const QDomElement &element);
186  void toXml(QXmlStreamWriter *writer) const;
188 
189  static bool isJingleRtpHeaderExtensionProperty(const QDomElement &element);
190 
191 private:
192  QSharedDataPointer<QXmppJingleRtpHeaderExtensionPropertyPrivate> d;
193 };
194 
199 class QXMPP_EXPORT QXmppJinglePayloadType
200 {
201 public:
205 
206  unsigned char channels() const;
207  void setChannels(unsigned char channels);
208 
209  unsigned int clockrate() const;
210  void setClockrate(unsigned int clockrate);
211 
212  unsigned char id() const;
213  void setId(unsigned char id);
214 
215  unsigned int maxptime() const;
216  void setMaxptime(unsigned int maxptime);
217 
218  QString name() const;
219  void setName(const QString &name);
220 
221  QMap<QString, QString> parameters() const;
222  void setParameters(const QMap<QString, QString> &parameters);
223 
224  unsigned int ptime() const;
225  void setPtime(unsigned int ptime);
226 
227  QVector<QXmppJingleRtpFeedbackProperty> rtpFeedbackProperties() const;
228  void setRtpFeedbackProperties(const QVector<QXmppJingleRtpFeedbackProperty> &rtpFeedbackProperties);
229 
230  QVector<QXmppJingleRtpFeedbackInterval> rtpFeedbackIntervals() const;
231  void setRtpFeedbackIntervals(const QVector<QXmppJingleRtpFeedbackInterval> &rtpFeedbackIntervals);
232 
234  void parse(const QDomElement &element);
235  void toXml(QXmlStreamWriter *writer) const;
237 
238  QXmppJinglePayloadType &operator=(const QXmppJinglePayloadType &other);
239  bool operator==(const QXmppJinglePayloadType &other) const;
240 
241 private:
242  QSharedDataPointer<QXmppJinglePayloadTypePrivate> d;
243 };
244 
245 class QXMPP_EXPORT QXmppJingleDescription
246 {
247 public:
249  QXMPP_PRIVATE_DECLARE_RULE_OF_SIX(QXmppJingleDescription)
250 
251  QString media() const;
252  void setMedia(const QString &media);
253 
254  quint32 ssrc() const;
255  void setSsrc(quint32 ssrc);
256 
257  QString type() const;
258  void setType(const QString &type);
259 
260  void addPayloadType(const QXmppJinglePayloadType &payload);
261  const QList<QXmppJinglePayloadType> &payloadTypes() const;
262  void setPayloadTypes(const QList<QXmppJinglePayloadType> &payloadTypes);
263 
265  void parse(const QDomElement &element);
266  void toXml(QXmlStreamWriter *writer) const;
268 
269 private:
270  QSharedDataPointer<QXmppJingleDescriptionPrivate> d;
271 };
272 
277 class QXMPP_EXPORT QXmppJingleCandidate
278 {
279 public:
281  enum Type {
283  PeerReflexiveType,
285  ServerReflexiveType,
287  RelayedType
289  };
290 
295 
298 
299  int component() const;
300  void setComponent(int component);
301 
302  QString foundation() const;
303  void setFoundation(const QString &foundation);
304 
305  int generation() const;
306  void setGeneration(int generation);
307 
308  QHostAddress host() const;
309  void setHost(const QHostAddress &host);
310 
311  QString id() const;
312  void setId(const QString &id);
313 
314  int network() const;
315  void setNetwork(int network);
316 
317  quint16 port() const;
318  void setPort(quint16 port);
319 
320  int priority() const;
321  void setPriority(int priority);
322 
323  QString protocol() const;
324  void setProtocol(const QString &protocol);
325 
326  QXmppJingleCandidate::Type type() const;
327  void setType(QXmppJingleCandidate::Type);
328 
329  bool isNull() const;
330 
332  void parse(const QDomElement &element);
333  void toXml(QXmlStreamWriter *writer) const;
334 
335  static QXmppJingleCandidate::Type typeFromString(const QString &typeStr, bool *ok = nullptr);
336  static QString typeToString(QXmppJingleCandidate::Type type);
338 
339 private:
340  QSharedDataPointer<QXmppJingleCandidatePrivate> d;
341 };
342 
343 class QXMPP_EXPORT QXmppJingleReason
344 {
345 public:
347  enum Type {
348  None,
349  AlternativeSession,
350  Busy,
351  Cancel,
352  ConnectivityError,
353  Decline,
354  Expired,
355  FailedApplication,
356  FailedTransport,
357  GeneralError,
358  Gone,
359  IncompatibleParameters,
360  MediaError,
361  SecurityError,
362  Success,
363  Timeout,
364  UnsupportedApplications,
365  UnsupportedTransports
366  };
367 
376  CryptoRequired
377  };
378 
380 
381  QString text() const;
382  void setText(const QString &text);
383 
384  Type type() const;
385  void setType(Type type);
386 
387  RtpErrorCondition rtpErrorCondition() const;
388  void setRtpErrorCondition(RtpErrorCondition rtpErrorCondition);
389 
391  void parse(const QDomElement &element);
392  void toXml(QXmlStreamWriter *writer) const;
393 
395 
396  QXMPP_PRIVATE_DECLARE_RULE_OF_SIX(QXmppJingleReason)
397 
398 private:
399  QSharedDataPointer<QXmppJingleIqReasonPrivate> d;
400 };
401 
408 class QXMPP_EXPORT QXmppJingleIq : public QXmppIq
409 {
410 public:
412  enum Action {
413  ContentAccept,
414  ContentAdd,
415  ContentModify,
416  ContentReject,
417  ContentRemove,
418  DescriptionInfo,
419  SecurityInfo,
420  SessionAccept,
421  SessionInfo,
422  SessionInitiate,
423  SessionTerminate,
424  TransportAccept,
425  TransportInfo,
426  TransportReject,
427  TransportReplace
428  };
429 
430  enum Creator {
434  Responder
435  };
436 
443  bool isMute = true;
447  QString name;
448  };
450 
451  using RtpSessionState = std::variant<RtpSessionStateActive, RtpSessionStateHold, RtpSessionStateUnhold, RtpSessionStateMuting, RtpSessionStateRinging>;
452 
455 
461  class QXMPP_EXPORT Content
462  {
463  public:
464  Content();
465  Content(const QXmppJingleIq::Content &other);
466  Content(QXmppJingleIq::Content &&);
467  ~Content();
468 
469  Content &operator=(const Content &other);
470  Content &operator=(Content &&);
471 
472  QString creator() const;
473  void setCreator(const QString &creator);
474 
475  QString name() const;
476  void setName(const QString &name);
477 
478  QString senders() const;
479  void setSenders(const QString &senders);
480 
481  // XEP-0167: Jingle RTP Sessions
482  QXmppJingleDescription description() const;
483  void setDescription(const QXmppJingleDescription &description);
484 
485 #if QXMPP_DEPRECATED_SINCE(1, 6)
486  QString descriptionMedia() const;
487  void setDescriptionMedia(const QString &media);
488 
489  quint32 descriptionSsrc() const;
490  void setDescriptionSsrc(quint32 ssrc);
491 
492  void addPayloadType(const QXmppJinglePayloadType &payload);
493  QList<QXmppJinglePayloadType> payloadTypes() const;
494  void setPayloadTypes(const QList<QXmppJinglePayloadType> &payloadTypes);
495 #endif
496 
497  bool isRtpMultiplexingSupported() const;
498  void setRtpMultiplexingSupported(bool isRtpMultiplexingSupported);
499 
500  std::optional<QXmppJingleRtpEncryption> rtpEncryption() const;
501  void setRtpEncryption(const std::optional<QXmppJingleRtpEncryption> &rtpEncryption);
502 
503  void addTransportCandidate(const QXmppJingleCandidate &candidate);
504  QList<QXmppJingleCandidate> transportCandidates() const;
505  void setTransportCandidates(const QList<QXmppJingleCandidate> &candidates);
506 
507  QString transportUser() const;
508  void setTransportUser(const QString &user);
509 
510  QString transportPassword() const;
511  void setTransportPassword(const QString &password);
512 
513  QVector<QXmppJingleRtpFeedbackProperty> rtpFeedbackProperties() const;
514  void setRtpFeedbackProperties(const QVector<QXmppJingleRtpFeedbackProperty> &rtpFeedbackProperties);
515 
516  QVector<QXmppJingleRtpFeedbackInterval> rtpFeedbackIntervals() const;
517  void setRtpFeedbackIntervals(const QVector<QXmppJingleRtpFeedbackInterval> &rtpFeedbackIntervals);
518 
519  QVector<QXmppJingleRtpHeaderExtensionProperty> rtpHeaderExtensionProperties() const;
520  void setRtpHeaderExtensionProperties(const QVector<QXmppJingleRtpHeaderExtensionProperty> &rtpHeaderExtensionProperties);
521 
522  bool isRtpHeaderExtensionMixingAllowed() const;
523  void setRtpHeaderExtensionMixingAllowed(bool isRtpHeaderExtensionMixingAllowed);
524 
525  // XEP-0320: Use of DTLS-SRTP in Jingle Sessions
526  QByteArray transportFingerprint() const;
527  void setTransportFingerprint(const QByteArray &fingerprint);
528 
529  QString transportFingerprintHash() const;
530  void setTransportFingerprintHash(const QString &hash);
531 
532  QString transportFingerprintSetup() const;
533  void setTransportFingerprintSetup(const QString &setup);
534 
536  void parse(const QDomElement &element);
537  void toXml(QXmlStreamWriter *writer) const;
538 
539  bool parseSdp(const QString &sdp);
540  QString toSdp() const;
542 
543  private:
544  QSharedDataPointer<QXmppJingleIqContentPrivate> d;
545  };
546 
547  QXmppJingleIq();
550  ~QXmppJingleIq() override;
551 
554 
555  Action action() const;
556  void setAction(Action action);
557 
558  void addContent(const Content &content);
559  QList<Content> contents() const;
560  void setContents(const QList<Content> &contents);
561 
562  QString initiator() const;
563  void setInitiator(const QString &initiator);
564 
565  QXmppJingleReason &reason();
566  const QXmppJingleReason &reason() const;
567 
568  QString responder() const;
569  void setResponder(const QString &responder);
570 
571 #if QXMPP_DEPRECATED_SINCE(1, 5)
572  QT_DEPRECATED_X("Use QXmpp::rtpSessionState() instead")
573  bool ringing() const;
574  QT_DEPRECATED_X("Use QXmpp::setRtpSessionState() instead")
575  void setRinging(bool ringing);
576 #endif
577 
578  QString sid() const;
579  void setSid(const QString &sid);
580 
581  QString mujiGroupChatJid() const;
582  void setMujiGroupChatJid(const QString &mujiGroupChatJid);
583 
584  std::optional<RtpSessionState> rtpSessionState() const;
585  void setRtpSessionState(const std::optional<RtpSessionState> &rtpSessionState);
586 
588  static bool isJingleIq(const QDomElement &element);
590 
591 protected:
593  void parseElementFromChild(const QDomElement &element) override;
594  void toXmlElementFromChild(QXmlStreamWriter *writer) const override;
596 
597 private:
598  QSharedDataPointer<QXmppJingleIqPrivate> d;
599 };
600 
602 {
603 public:
604  enum class Type {
605  None,
606  Propose,
607  Ringing,
608  Proceed,
609  Reject,
610  Retract,
611  Finish
612  };
613 
615  QXMPP_PRIVATE_DECLARE_RULE_OF_SIX(QXmppJingleMessageInitiationElement)
616 
617  Type type() const;
618  void setType(Type type);
619 
620  QString id() const;
621  void setId(const QString &id);
622 
623  std::optional<QXmppJingleDescription> description() const;
624  void setDescription(std::optional<QXmppJingleDescription> description);
625 
626  std::optional<QXmppJingleReason> reason() const;
627  void setReason(std::optional<QXmppJingleReason> reason);
628 
629  bool containsTieBreak() const;
630  void setContainsTieBreak(bool containsTieBreak);
631 
632  QString migratedTo() const;
633  void setMigratedTo(const QString &migratedTo);
634 
636  void parse(const QDomElement &element);
637  void toXml(QXmlStreamWriter *writer) const;
639 
640  static bool isJingleMessageInitiationElement(const QDomElement &);
641  static QString jmiElementTypeToString(Type type);
642  static std::optional<Type> stringToJmiElementType(const QString &typeStr);
643 
644 private:
645  QSharedDataPointer<QXmppJingleMessageInitiationElementPrivate> d;
646 };
647 
648 class QXMPP_EXPORT QXmppCallInviteElement
649 {
650 public:
651  enum class Type {
652  None,
653  Invite,
654  Retract,
655  Accept,
656  Reject,
657  Left
658  };
659 
660  struct Jingle {
661  QString sid;
662  std::optional<QString> jid;
663 
664  bool operator==(const Jingle &other) const { return other.sid == sid && other.jid == jid; }
665 
666  void parse(const QDomElement &element);
667  void toXml(QXmlStreamWriter *writer) const;
668  };
669 
670  struct External {
671  QString uri;
672 
673  bool operator==(const External &other) const { return other.uri == uri; }
674 
675  void toXml(QXmlStreamWriter *writer) const;
676  };
677 
679  QXMPP_PRIVATE_DECLARE_RULE_OF_SIX(QXmppCallInviteElement)
680 
681  Type type() const;
682  void setType(Type type);
683 
684  QString id() const;
685  void setId(const QString &id);
686 
687  bool audio() const;
688  void setAudio(bool audio);
689 
690  bool video() const;
691  void setVideo(bool video);
692 
693  std::optional<Jingle> jingle() const;
694  void setJingle(std::optional<Jingle> jingle);
695 
696  std::optional<QVector<External>> external() const;
697  void setExternal(std::optional<QVector<External>> external);
698 
700  void parse(const QDomElement &element);
701  void toXml(QXmlStreamWriter *writer) const;
703 
704  static bool isCallInviteElement(const QDomElement &);
705 
706 private:
707  static QString callInviteElementTypeToString(Type type);
708  static std::optional<Type> stringToCallInviteElementType(const QString &typeStr);
709 
710  QSharedDataPointer<QXmppCallInviteElementPrivate> d;
711 };
712 
713 Q_DECLARE_METATYPE(QXmppJingleReason::RtpErrorCondition)
714 
715 #endif
The QXmppCallInviteElement class represents a Call Invite element as specified by XEP-0482: Call Invi...
Definition: QXmppJingleData.h:649
Type
Definition: QXmppJingleData.h:651
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:278
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:281
@ HostType
Host candidate, a local address/port.
Definition: QXmppJingleData.h:282
The QXmppJingleDescription class represents descriptions for Jingle elements including media type,...
Definition: QXmppJingleData.h:246
The QXmppJingleIq class represents an IQ used for initiating media sessions as specified by XEP-0166:...
Definition: QXmppJingleData.h:409
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:412
Creator
Definition: QXmppJingleData.h:430
@ Initiator
The initiator generated the content type.
Definition: QXmppJingleData.h:432
QXmppJingleIq(const QXmppJingleIq &other)
Copy-constructor.
std::variant< RtpSessionStateActive, RtpSessionStateHold, RtpSessionStateUnhold, RtpSessionStateMuting, RtpSessionStateRinging > RtpSessionState
Definition: QXmppJingleData.h:451
The QXmppJingleMessageInitiationElement class represents a Jingle Message Initiation element as speci...
Definition: QXmppJingleData.h:602
Type
Definition: QXmppJingleData.h:604
The QXmppJinglePayloadType class represents a payload type as specified by XEP-0167: Jingle RTP Sessi...
Definition: QXmppJingleData.h:200
Definition: QXmppJingleData.h:344
Type
This enum is used to describe a reason's type.
Definition: QXmppJingleData.h:347
RtpErrorCondition
Definition: QXmppJingleData.h:370
@ InvalidCrypto
The encryption offer is rejected.
Definition: QXmppJingleData.h:374
@ NoErrorCondition
There is no error condition.
Definition: QXmppJingleData.h:372
The QXmppJingleRtpCryptoElement class represents the XEP-0167: Jingle RTP Sessions "crypto" element u...
Definition: QXmppJingleData.h:55
The QXmppJingleRtpEncryption class represents the XEP-0167: Jingle RTP Sessions "encryption" element ...
Definition: QXmppJingleData.h:85
The QXmppJingleRtpFeedbackInterval class represents the XEP-0293: Jingle RTP Feedback Negotiation "rt...
Definition: QXmppJingleData.h:136
The QXmppJingleRtpFeedbackProperty class represents the XEP-0293: Jingle RTP Feedback Negotiation "rt...
Definition: QXmppJingleData.h:109
The QXmppJingleRtpHeaderExtensionProperty class represents the XEP-0294: Jingle RTP Header Extensions...
Definition: QXmppJingleData.h:157
Senders
Definition: QXmppJingleData.h:159
@ Initiator
Only the initiator is allowed.
Definition: QXmppJingleData.h:163
@ Both
The initiator and the sender are allowed.
Definition: QXmppJingleData.h:161
The QXmppSdpParameter class represents a Session Description Protocol (SDP) parameter specified by RF...
Definition: QXmppJingleData.h:31
Definition: Algorithms.h:10
Definition: QXmppJingleData.h:437
Definition: QXmppJingleData.h:438
Definition: QXmppJingleData.h:440
QString name
Session to be muted (e.g., only audio or video)
Definition: QXmppJingleData.h:447
Creator creator
Creator of the corresponding session.
Definition: QXmppJingleData.h:445
Definition: QXmppJingleData.h:449
Definition: QXmppJingleData.h:439