blob: a6fde1a7aedc725adb8c7f449daa50bb3811b3ab (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
|
// Copyright (C) 2023 The Qt Company Ltd.
// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only
#ifndef SERVER_H
#define SERVER_H
#include <private/qglobal_p.h>
#ifdef QT_FEATURE_network
#include <qstring.h>
#include <qtcpserver.h>
#include <qtest.h>
#include <qurl.h>
QT_USE_NAMESPACE
class UnResponsiveRtspServer : public QObject
{
Q_OBJECT
public:
UnResponsiveRtspServer() : m_server{ new QTcpServer{ this } }
{
connect(m_server, &QTcpServer::newConnection, this, [&] { m_connected = true; });
}
bool listen() { return m_server->listen(QHostAddress::LocalHost); }
bool waitForConnection()
{
return QTest::qWaitFor([this] { return m_connected; });
}
QUrl address() const
{
return QUrl{ QString{ "rtsp://%1:%2" }
.arg(m_server->serverAddress().toString())
.arg(m_server->serverPort()) };
}
private:
QTcpServer *m_server;
bool m_connected = false;
};
#endif // QT_FEATURE_network
#endif // SERVER_H
|