QXmpp  Version: 1.6.0
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,
284  ServerReflexiveType,
286  RelayedType
288  };
290 
295 
296  QXmppJingleCandidate &operator=(const QXmppJingleCandidate &other);
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 
438  {
439  };
440 
442  {
443  };
444 
446  {
447  };
448 
450  {
453  bool isMute = true;
457  QString name;
458  };
459 
461  {
462  };
463 
464  using RtpSessionState = std::variant<RtpSessionStateActive, RtpSessionStateHold, RtpSessionStateUnhold, RtpSessionStateMuting, RtpSessionStateRinging>;
465 
468 
474  class QXMPP_EXPORT Content
475  {
476  public:
477  Content();
478  Content(const QXmppJingleIq::Content &other);
479  Content(QXmppJingleIq::Content &&);
480  ~Content();
481 
482  Content &operator=(const Content &other);
483  Content &operator=(Content &&);
484 
485  QString creator() const;
486  void setCreator(const QString &creator);
487 
488  QString name() const;
489  void setName(const QString &name);
490 
491  QString senders() const;
492  void setSenders(const QString &senders);
493 
494  // XEP-0167: Jingle RTP Sessions
495  QXmppJingleDescription description() const;
496  void setDescription(const QXmppJingleDescription &description);
497 
498 #if QXMPP_DEPRECATED_SINCE(1, 6)
499  QString descriptionMedia() const;
500  void setDescriptionMedia(const QString &media);
501 
502  quint32 descriptionSsrc() const;
503  void setDescriptionSsrc(quint32 ssrc);
504 
505  void addPayloadType(const QXmppJinglePayloadType &payload);
506  QList<QXmppJinglePayloadType> payloadTypes() const;
507  void setPayloadTypes(const QList<QXmppJinglePayloadType> &payloadTypes);
508 #endif
509 
510  bool isRtpMultiplexingSupported() const;
511  void setRtpMultiplexingSupported(bool isRtpMultiplexingSupported);
512 
513  std::optional<QXmppJingleRtpEncryption> rtpEncryption() const;
514  void setRtpEncryption(const std::optional<QXmppJingleRtpEncryption> &rtpEncryption);
515 
516  void addTransportCandidate(const QXmppJingleCandidate &candidate);
517  QList<QXmppJingleCandidate> transportCandidates() const;
518  void setTransportCandidates(const QList<QXmppJingleCandidate> &candidates);
519 
520  QString transportUser() const;
521  void setTransportUser(const QString &user);
522 
523  QString transportPassword() const;
524  void setTransportPassword(const QString &password);
525 
526  QVector<QXmppJingleRtpFeedbackProperty> rtpFeedbackProperties() const;
527  void setRtpFeedbackProperties(const QVector<QXmppJingleRtpFeedbackProperty> &rtpFeedbackProperties);
528 
529  QVector<QXmppJingleRtpFeedbackInterval> rtpFeedbackIntervals() const;
530  void setRtpFeedbackIntervals(const QVector<QXmppJingleRtpFeedbackInterval> &rtpFeedbackIntervals);
531 
532  QVector<QXmppJingleRtpHeaderExtensionProperty> rtpHeaderExtensionProperties() const;
533  void setRtpHeaderExtensionProperties(const QVector<QXmppJingleRtpHeaderExtensionProperty> &rtpHeaderExtensionProperties);
534 
535  bool isRtpHeaderExtensionMixingAllowed() const;
536  void setRtpHeaderExtensionMixingAllowed(bool isRtpHeaderExtensionMixingAllowed);
537 
538  // XEP-0320: Use of DTLS-SRTP in Jingle Sessions
539  QByteArray transportFingerprint() const;
540  void setTransportFingerprint(const QByteArray &fingerprint);
541 
542  QString transportFingerprintHash() const;
543  void setTransportFingerprintHash(const QString &hash);
544 
545  QString transportFingerprintSetup() const;
546  void setTransportFingerprintSetup(const QString &setup);
547 
549  void parse(const QDomElement &element);
550  void toXml(QXmlStreamWriter *writer) const;
551 
552  bool parseSdp(const QString &sdp);
553  QString toSdp() const;
555 
556  private:
557  QSharedDataPointer<QXmppJingleIqContentPrivate> d;
558  };
559 
560  QXmppJingleIq();
561  QXmppJingleIq(const QXmppJingleIq &other);
563  ~QXmppJingleIq() override;
564 
565  QXmppJingleIq &operator=(const QXmppJingleIq &other);
566  QXmppJingleIq &operator=(QXmppJingleIq &&);
567 
568  Action action() const;
569  void setAction(Action action);
570 
571  void addContent(const Content &content);
572  QList<Content> contents() const;
573  void setContents(const QList<Content> &contents);
574 
575  QString initiator() const;
576  void setInitiator(const QString &initiator);
577 
578  QXmppJingleReason &reason();
579  const QXmppJingleReason &reason() const;
580 
581  QString responder() const;
582  void setResponder(const QString &responder);
583 
584 #if QXMPP_DEPRECATED_SINCE(1, 5)
585  QT_DEPRECATED_X("Use QXmpp::rtpSessionState() instead")
586  bool ringing() const;
587  QT_DEPRECATED_X("Use QXmpp::setRtpSessionState() instead")
588  void setRinging(bool ringing);
589 #endif
590 
591  QString sid() const;
592  void setSid(const QString &sid);
593 
594  QString mujiGroupChatJid() const;
595  void setMujiGroupChatJid(const QString &mujiGroupChatJid);
596 
597  std::optional<RtpSessionState> rtpSessionState() const;
598  void setRtpSessionState(const std::optional<RtpSessionState> &rtpSessionState);
599 
601  static bool isJingleIq(const QDomElement &element);
603 
604 protected:
606  void parseElementFromChild(const QDomElement &element) override;
607  void toXmlElementFromChild(QXmlStreamWriter *writer) const override;
609 
610 private:
611  QSharedDataPointer<QXmppJingleIqPrivate> d;
612 };
613 
615 {
616 public:
617  enum class Type {
618  None,
619  Propose,
620  Ringing,
621  Proceed,
622  Reject,
623  Retract,
624  Finish
625  };
626 
628  QXMPP_PRIVATE_DECLARE_RULE_OF_SIX(QXmppJingleMessageInitiationElement)
629 
630  Type type() const;
631  void setType(Type type);
632 
633  QString id() const;
634  void setId(const QString &id);
635 
636  std::optional<QXmppJingleDescription> description() const;
637  void setDescription(std::optional<QXmppJingleDescription> description);
638 
639  std::optional<QXmppJingleReason> reason() const;
640  void setReason(std::optional<QXmppJingleReason> reason);
641 
642  bool containsTieBreak() const;
643  void setContainsTieBreak(bool containsTieBreak);
644 
645  QString migratedTo() const;
646  void setMigratedTo(const QString &migratedTo);
647 
649  void parse(const QDomElement &element);
650  void toXml(QXmlStreamWriter *writer) const;
652 
653  static bool isJingleMessageInitiationElement(const QDomElement &);
654  static QString jmiElementTypeToString(Type type);
655  static std::optional<Type> stringToJmiElementType(const QString &typeStr);
656 
657 private:
658  QSharedDataPointer<QXmppJingleMessageInitiationElementPrivate> d;
659 };
660 
661 class QXMPP_EXPORT QXmppCallInviteElement
662 {
663 public:
664  enum class Type {
665  None,
666  Invite,
667  Retract,
668  Accept,
669  Reject,
670  Left
671  };
672 
673  struct Jingle
674  {
675  QString sid;
676  std::optional<QString> jid;
677 
678  bool operator==(const Jingle &other) const { return other.sid == sid && other.jid == jid; }
679 
680  void parse(const QDomElement &element);
681  void toXml(QXmlStreamWriter *writer) const;
682  };
683 
684  struct External
685  {
686  QString uri;
687 
688  bool operator==(const External &other) const { return other.uri == uri; }
689 
690  void toXml(QXmlStreamWriter *writer) const;
691  };
692 
694  QXMPP_PRIVATE_DECLARE_RULE_OF_SIX(QXmppCallInviteElement)
695 
696  Type type() const;
697  void setType(Type type);
698 
699  QString id() const;
700  void setId(const QString &id);
701 
702  bool audio() const;
703  void setAudio(bool audio);
704 
705  bool video() const;
706  void setVideo(bool video);
707 
708  std::optional<Jingle> jingle() const;
709  void setJingle(std::optional<Jingle> jingle);
710 
711  std::optional<QVector<External>> external() const;
712  void setExternal(std::optional<QVector<External>> external);
713 
715  void parse(const QDomElement &element);
716  void toXml(QXmlStreamWriter *writer) const;
718 
719  static bool isCallInviteElement(const QDomElement &);
720 
721 private:
722  static QString callInviteElementTypeToString(Type type);
723  static std::optional<Type> stringToCallInviteElementType(const QString &typeStr);
724 
725  QSharedDataPointer<QXmppCallInviteElementPrivate> d;
726 };
727 
728 Q_DECLARE_METATYPE(QXmppJingleReason::RtpErrorCondition)
729 
730 #endif
Definition: QXmppJingleData.h:441
The QXmppJingleIq class represents an IQ used for initiating media sessions as specified by XEP-0166:...
Definition: QXmppJingleData.h:408
The QXmppJingleRtpEncryption class represents the XEP-0167: Jingle RTP Sessions "encryption" element ...
Definition: QXmppJingleData.h:84
The QXmppJingleRtpHeaderExtensionProperty class represents the XEP-0294: Jingle RTP Header Extensions...
Definition: QXmppJingleData.h:156
Action
This enum is used to describe a Jingle action.
Definition: QXmppJingleData.h:412
The QXmppCallInviteElement class represents a Call Invite element as specified by XEP-0482: Call Invi...
Definition: QXmppJingleData.h:661
The QXmppJinglePayloadType class represents a payload type as specified by XEP-0167: Jingle RTP Sessi...
Definition: QXmppJingleData.h:199
Creator
Definition: QXmppJingleData.h:430
The initiator and the sender are allowed.
Definition: QXmppJingleData.h:161
Type
This enum is used to describe a reason&#39;s type.
Definition: QXmppJingleData.h:347
The QXmppJingleRtpFeedbackInterval class represents the XEP-0293: Jingle RTP Feedback Negotiation "rt...
Definition: QXmppJingleData.h:135
Definition: QXmppJingleData.h:437
Host candidate, a local address/port.
Definition: QXmppJingleData.h:282
Definition: QXmppJingleData.h:343
Definition: QXmppJingleData.h:449
The QXmppJingleDescription class represents descriptions for Jingle elements including media type...
Definition: QXmppJingleData.h:245
The QXmppJingleRtpCryptoElement class represents the XEP-0167: Jingle RTP Sessions "crypto" element u...
Definition: QXmppJingleData.h:54
QString name
Session to be muted (e.g., only audio or video)
Definition: QXmppJingleData.h:457
Definition: QXmppJingleData.h:460
Type
Definition: QXmppJingleData.h:664
Type
This enum is used to describe a candidate&#39;s type.
Definition: QXmppJingleData.h:281
There is no error condition.
Definition: QXmppJingleData.h:372
The QXmppIq class is the base class for all IQs.
Definition: QXmppIq.h:22
The initiator generated the content type.
Definition: QXmppJingleData.h:432
std::variant< RtpSessionStateActive, RtpSessionStateHold, RtpSessionStateUnhold, RtpSessionStateMuting, RtpSessionStateRinging > RtpSessionState
Definition: QXmppJingleData.h:464
The QXmppJingleCandidate class represents a transport candidate as specified by XEP-0176: Jingle ICE-...
Definition: QXmppJingleData.h:277
Creator creator
Creator of the corresponding session.
Definition: QXmppJingleData.h:455
The encryption offer is rejected.
Definition: QXmppJingleData.h:374
The QXmppJingleMessageInitiationElement class represents a Jingle Message Initiation element as speci...
Definition: QXmppJingleData.h:614
Only the initiator is allowed.
Definition: QXmppJingleData.h:163
Definition: QXmppJingleData.h:445
Senders
Definition: QXmppJingleData.h:159
Action
Definition: QXmppExternalService.h:27
The QXmppJingleRtpFeedbackProperty class represents the XEP-0293: Jingle RTP Feedback Negotiation "rt...
Definition: QXmppJingleData.h:108
RtpErrorCondition
Definition: QXmppJingleData.h:370
Type
Definition: QXmppJingleData.h:617
The QXmppSdpParameter class represents a Session Description Protocol (SDP) parameter specified by RF...
Definition: QXmppJingleData.h:30