QXmpp  Version: 1.15.1
QXmppCallStream_p.h
1 // SPDX-FileCopyrightText: 2019 Niels Ole Salscheider <ole@salscheider.org>
2 // SPDX-FileCopyrightText: 2025 Linus Jahn <lnj@kaidan.im>
3 //
4 // SPDX-License-Identifier: LGPL-2.1-or-later
5 
6 #ifndef QXMPPCALLSTREAM_P_H
7 #define QXMPPCALLSTREAM_P_H
8 
9 #include "QXmppCall_p.h"
10 #include "QXmppJingleIq.h"
11 
12 #include <gst/gst.h>
13 
14 #include <QList>
15 #include <QObject>
16 #include <QString>
17 
18 class QXmppIceConnection;
19 
20 //
21 // W A R N I N G
22 // -------------
23 //
24 // This file is not part of the QXmpp API.
25 // This header file may change from version to version without notice,
26 // or even be removed.
27 //
28 // We mean it.
29 //
30 
31 static const int RTP_COMPONENT = 1;
32 static const int RTCP_COMPONENT = 2;
33 
34 constexpr QStringView AUDIO_MEDIA = u"audio";
35 constexpr QStringView VIDEO_MEDIA = u"video";
36 
37 namespace QXmpp::Private {
38 
39 enum DtlsClientSetup {
40  Actpass,
41  Active,
42  Passive,
43 };
44 }
45 
46 class QXmppCallStreamPrivate : public QObject
47 {
48  Q_OBJECT
49 
50 public:
51  QXmppCallStreamPrivate(QXmppCallStream *parent, GstElement *pipeline_, GstElement *rtpBin_,
52  QString media_, QString creator_, QString name_, int id_, bool useDtls_);
53  ~QXmppCallStreamPrivate();
54 
55  GstFlowReturn sendDatagram(GstElement *appsink, int component);
56  void datagramReceived(const QByteArray &datagram, GstElement *appsrc);
57 
58  void addEncoder(QXmppCallPrivate::GstCodec &codec);
59  void addDecoder(GstPad *pad, QXmppCallPrivate::GstCodec &codec);
60  bool isDtlsClient() const;
61  void enableDtlsClientMode();
62  void onDtlsConnectionStateChanged(QXmpp::Private::GstDtlsConnectionState);
63  void onPeerCertificateReceived(QXmpp::Private::GCharPtr pem);
64 
65  Q_SIGNAL void peerCertificateReceived(bool fingerprintMatches);
66 
67  bool sendPadCbReady() const { return sendPadCB && sendPad && (dtlsHandshakeComplete || !useDtls); }
68  bool receivePadCbReady() const { return receivePadCB && receivePad && (dtlsHandshakeComplete || !useDtls); }
69 
70  QXmppCallStream *q;
71 
72  quint32 localSsrc;
73 
74  GstElement *pipeline = nullptr;
75  GstElement *rtpBin = nullptr;
76  GstPad *sendPad = nullptr;
77  GstPad *receivePad = nullptr;
78  GstElement *encoderBin = nullptr;
79  GstElement *decoderBin = nullptr;
80  GstElement *iceReceiveBin = nullptr;
81  GstElement *iceSendBin = nullptr;
82  GstElement *receiveRtp = nullptr;
83  GstElement *receiveRtcp = nullptr;
84  GstElement *sendRtp = nullptr;
85  GstElement *sendRtcp = nullptr;
86  // DTLS-SRTP
87  GstElement *dtlsSrtpEncoder = nullptr;
88  GstElement *dtlsSrtcpEncoder = nullptr;
89  GstElement *dtlsSrtpDecoder = nullptr;
90  GstElement *dtlsSrtcpDecoder = nullptr;
91 
92  std::function<void(GstPad *)> sendPadCB;
93  std::function<void(GstPad *)> receivePadCB;
94 
95  QXmppIceConnection *connection;
96  QString media;
97  QString creator;
98  QString name;
99  int id;
100 
101  bool useDtls;
102  // DTLS setup mode received from the other peer
103  std::optional<QXmpp::Private::DtlsClientSetup> dtlsPeerSetup;
104  QByteArray ownCertificateDigest;
105  QByteArray peerCertificateDigest;
106  QByteArray expectedPeerCertificateDigest;
107  bool dtlsHandshakeComplete = false;
108 
109  QList<QXmppJinglePayloadType> payloadTypes;
110 };
111 
112 #endif
The QXmppIceConnection class represents a set of UDP sockets capable of performing Interactive Connec...
Definition: QXmppStun.h:227
Definition: Algorithms.h:14
Definition: QXmppCallStream.h:21