QXmpp Version: 1.10.0
QXmppCall_p.h
1// SPDX-FileCopyrightText: 2019 Jeremy Lainé <jeremy.laine@m4x.org>
2//
3// SPDX-License-Identifier: LGPL-2.1-or-later
4
5#ifndef QXMPPCALL_P_H
6#define QXMPPCALL_P_H
7
8#include "QXmppCall.h"
9#include "QXmppJingleIq.h"
10
11#include <gst/gst.h>
12
13#include <QList>
14
15//
16// W A R N I N G
17// -------------
18//
19// This file is not part of the QXmpp API.
20// This header file may change from version to version without notice,
21// or even be removed.
22//
23// We mean it.
24//
25
26class QXmppCallStream;
27
28class QXmppCallPrivate : public QObject
29{
30 Q_OBJECT
31public:
32 struct GstCodec {
33 int pt;
34 QString name;
35 int channels;
36 uint clockrate;
37 QString gstPay;
38 QString gstDepay;
39 QString gstEnc;
40 QString gstDec;
41 struct Property {
42 QString name;
43 int value;
44 };
45 // Use e.g. gst-inspect-1.0 x264enc to find good encoder settings for live streaming
46 QList<Property> encProps;
47 };
48
49 QXmppCallPrivate(QXmppCall *qq);
50 ~QXmppCallPrivate();
51
52 void ssrcActive(uint sessionId, uint ssrc);
53 void padAdded(GstPad *pad);
54 GstCaps *ptMap(uint sessionId, uint pt);
55 bool isFormatSupported(const QString &codecName) const;
56 void filterGStreamerFormats(QList<GstCodec> &formats);
57
58 QXmppCallStream *createStream(const QString &media, const QString &creator, const QString &name);
59 QXmppCallStream *findStreamByMedia(const QString &media);
60 QXmppCallStream *findStreamByName(const QString &name);
61 QXmppCallStream *findStreamById(const int id);
62 QXmppJingleIq::Content localContent(QXmppCallStream *stream) const;
63
64 void handleAck(const QXmppIq &iq);
65 bool handleDescription(QXmppCallStream *stream, const QXmppJingleIq::Content &content);
66 void handleRequest(const QXmppJingleIq &iq);
67 bool handleTransport(QXmppCallStream *stream, const QXmppJingleIq::Content &content);
68 void setState(QXmppCall::State state);
69 bool sendAck(const QXmppJingleIq &iq);
70 bool sendInvite();
71 bool sendRequest(const QXmppJingleIq &iq);
72 void terminate(QXmppJingleIq::Reason::Type reasonType);
73
74 QXmppCall::Direction direction;
75 QString jid;
76 QString ownJid;
77 QXmppCallManager *manager;
78 QList<QXmppJingleIq> requests;
79 QString sid;
80 QXmppCall::State state;
81
82 GstElement *pipeline;
83 GstElement *rtpbin;
84
85 // Media streams
86 QList<QXmppCallStream *> streams;
87 int nextId;
88
89 // Supported codecs
90 QList<GstCodec> videoCodecs = {
91 { .pt = 100, .name = QStringLiteral("H264"), .channels = 1, .clockrate = 90000, .gstPay = QStringLiteral("rtph264pay"), .gstDepay = QStringLiteral("rtph264depay"), .gstEnc = QStringLiteral("x264enc"), .gstDec = QStringLiteral("avdec_h264"), .encProps = { { QStringLiteral("tune"), 4 }, { QStringLiteral("speed-preset"), 3 }, { QStringLiteral("byte-stream"), true }, { QStringLiteral("bitrate"), 512 } } },
92 { .pt = 99, .name = QStringLiteral("VP8"), .channels = 1, .clockrate = 90000, .gstPay = QStringLiteral("rtpvp8pay"), .gstDepay = QStringLiteral("rtpvp8depay"), .gstEnc = QStringLiteral("vp8enc"), .gstDec = QStringLiteral("vp8dec"), .encProps = { { QStringLiteral("deadline"), 20000 }, { QStringLiteral("target-bitrate"), 512000 } } },
93 // vp9enc and x265enc seem to be very slow. Give them a lower priority for now.
94 { .pt = 102, .name = QStringLiteral("H265"), .channels = 1, .clockrate = 90000, .gstPay = QStringLiteral("rtph265pay"), .gstDepay = QStringLiteral("rtph265depay"), .gstEnc = QStringLiteral("x265enc"), .gstDec = QStringLiteral("avdec_h265"), .encProps = { { QStringLiteral("tune"), 4 }, { QStringLiteral("speed-preset"), 3 }, { QStringLiteral("bitrate"), 512 } } },
95 { .pt = 101, .name = QStringLiteral("VP9"), .channels = 1, .clockrate = 90000, .gstPay = QStringLiteral("rtpvp9pay"), .gstDepay = QStringLiteral("rtpvp9depay"), .gstEnc = QStringLiteral("vp9enc"), .gstDec = QStringLiteral("vp9dec"), .encProps = { { QStringLiteral("deadline"), 20000 }, { QStringLiteral("target-bitrate"), 512000 } } }
96 };
97
98 QList<GstCodec> audioCodecs = {
99 { .pt = 98, .name = QStringLiteral("OPUS"), .channels = 2, .clockrate = 48000, .gstPay = QStringLiteral("rtpopuspay"), .gstDepay = QStringLiteral("rtpopusdepay"), .gstEnc = QStringLiteral("opusenc"), .gstDec = QStringLiteral("opusdec") },
100 { .pt = 98, .name = QStringLiteral("OPUS"), .channels = 1, .clockrate = 48000, .gstPay = QStringLiteral("rtpopuspay"), .gstDepay = QStringLiteral("rtpopusdepay"), .gstEnc = QStringLiteral("opusenc"), .gstDec = QStringLiteral("opusdec") },
101 { .pt = 97, .name = QStringLiteral("SPEEX"), .channels = 1, .clockrate = 48000, .gstPay = QStringLiteral("rtpspeexpay"), .gstDepay = QStringLiteral("rtpspeexdepay"), .gstEnc = QStringLiteral("speexenc"), .gstDec = QStringLiteral("speexdec") },
102 { .pt = 97, .name = QStringLiteral("SPEEX"), .channels = 1, .clockrate = 44100, .gstPay = QStringLiteral("rtpspeexpay"), .gstDepay = QStringLiteral("rtpspeexdepay"), .gstEnc = QStringLiteral("speexenc"), .gstDec = QStringLiteral("speexdec") },
103 { .pt = 96, .name = QStringLiteral("AAC"), .channels = 2, .clockrate = 48000, .gstPay = QStringLiteral("rtpmp4apay"), .gstDepay = QStringLiteral("rtpmp4adepay"), .gstEnc = QStringLiteral("avenc_aac"), .gstDec = QStringLiteral("avdec_aac") },
104 { .pt = 96, .name = QStringLiteral("AAC"), .channels = 2, .clockrate = 44100, .gstPay = QStringLiteral("rtpmp4apay"), .gstDepay = QStringLiteral("rtpmp4adepay"), .gstEnc = QStringLiteral("avenc_aac"), .gstDec = QStringLiteral("avdec_aac") },
105 { .pt = 96, .name = QStringLiteral("AAC"), .channels = 1, .clockrate = 48000, .gstPay = QStringLiteral("rtpmp4apay"), .gstDepay = QStringLiteral("rtpmp4adepay"), .gstEnc = QStringLiteral("avenc_aac"), .gstDec = QStringLiteral("avdec_aac") },
106 { .pt = 96, .name = QStringLiteral("AAC"), .channels = 1, .clockrate = 44100, .gstPay = QStringLiteral("rtpmp4apay"), .gstDepay = QStringLiteral("rtpmp4adepay"), .gstEnc = QStringLiteral("avenc_aac"), .gstDec = QStringLiteral("avdec_aac") },
107 { .pt = 8, .name = QStringLiteral("PCMA"), .channels = 1, .clockrate = 8000, .gstPay = QStringLiteral("rtppcmapay"), .gstDepay = QStringLiteral("rtppcmadepay"), .gstEnc = QStringLiteral("alawenc"), .gstDec = QStringLiteral("alawdec") },
108 { .pt = 0, .name = QStringLiteral("PCMU"), .channels = 1, .clockrate = 8000, .gstPay = QStringLiteral("rtppcmupay"), .gstDepay = QStringLiteral("rtppcmudepay"), .gstEnc = QStringLiteral("mulawenc"), .gstDec = QStringLiteral("mulawdec") }
109 };
110
111private:
112 QXmppCall *q;
113};
114
115#endif
The QXmppCallManager class provides support for making and receiving voice calls.
Definition: QXmppCallManager.h:46
Definition: QXmppCallStream.h:23
Definition: QXmppCall.h:21
Direction
This enum is used to describe the direction of a call.
Definition: QXmppCall.h:32
State
This enum is used to describe the state of a call.
Definition: QXmppCall.h:39
The QXmppIq class is the base class for all IQs.
Definition: QXmppIq.h:23
The QXmppJingleIq class represents an IQ used for initiating media sessions as specified by XEP-0166:...
Definition: QXmppJingleData.h:409
Type
This enum is used to describe a reason's type.
Definition: QXmppJingleData.h:347