16QString addressWithScheme(QLatin1StringView scheme,
const QString& address)
18 return address.isEmpty() ? QString() : (scheme + address);
24QString listenUri(QLatin1StringView scheme,
const QString& advertised)
26 bool isNumber =
false;
27 const int port = advertised.toInt(&isNumber);
37 url.setScheme(scheme);
38 if (url.host().isEmpty()) {
39 url.setHost(QStringLiteral(
"0.0.0.0"));
41 return url.toString();
48 const bool namedH265 = (streamInfo.
encoding() == VIDEO_STREAM_ENCODING_UNKNOWN) &&
49 streamInfo.
uri().startsWith(QLatin1StringView(
"udp265://"), Qt::CaseInsensitive);
50 return ((streamInfo.
encoding() == VIDEO_STREAM_ENCODING_H265) || namedH265) ? QLatin1StringView(
"udp265")
51 : QLatin1StringView(
"udp");
56 const QString uri = streamInfo.
uri();
57 switch (streamInfo.
type()) {
58 case VIDEO_STREAM_TYPE_RTPUDP:
59 return listenUri(rtpUdpScheme(streamInfo), uri);
60 case VIDEO_STREAM_TYPE_MPEG_TS:
61 return listenUri(QLatin1StringView(
"mpegts"), uri);
62 case VIDEO_STREAM_TYPE_RTSP:
63 case VIDEO_STREAM_TYPE_TCP_MPEG:
72 const char* videoSource;
75 QString VideoStreamResolver::Settings::* url;
78constexpr ManualSource kManualSources[] = {
91const ManualSource* findManualSource(
const QString& videoSource)
93 for (
const ManualSource& source : kManualSources) {
94 if (videoSource == QLatin1StringView(source.videoSource)) {
103 const ManualSource*
const source = findManualSource(settings.
videoSource);
107 const QLatin1StringView uri(source->uri);
108 return source->url ? addressWithScheme(uri, settings.*(source->url)) : QString(uri);
116 settings.
videoSource = videoSettings->videoSource()->rawValue().toString();
117 settings.
udpUrl = videoSettings->udpUrl()->rawValue().toString();
118 settings.
tcpUrl = videoSettings->tcpUrl()->rawValue().toString();
119 settings.
rtspUrl = videoSettings->rtspUrl()->rawValue().toString();
120 settings.
rtspTimeoutSec = videoSettings->rtspTimeout()->rawValue().toUInt();
121 settings.
lowLatency = videoSettings->lowLatencyMode()->rawValue().toBool();
123 std::min(videoSettings->rtpJitterLatencyMs()->rawValue().toUInt(),
static_cast<uint
>(INT_MAX)));
124 settings.
autoReconnect = videoSettings->rtspAutoReconnect()->rawValue().toBool();
125 settings.
conversionElement = videoSettings->videoConversionElement()->rawValue().toString().toUtf8();
127 settings.
forceCpuVideoPath = videoSettings->forceCpuVideoPath()->rawValue().toBool();
146 uri = autoStreamUri(*streamInfo);
148 uri = manualUri(settings);
168 return streamInfo && !streamInfo->
uri().isEmpty();
173 return findManualSource(videoSource) !=
nullptr;
183 return url.scheme().toUpper();
185 switch (*transport) {
186 case Transport::Rtsp:
187 return QStringLiteral(
"RTSP");
188 case Transport::RtpUdpH264:
189 return QStringLiteral(
"RTP/UDP (H.264)");
190 case Transport::RtpUdpH265:
191 return QStringLiteral(
"RTP/UDP (H.265)");
192 case Transport::MpegTsUdp:
193 return QStringLiteral(
"MPEG-TS/UDP");
194 case Transport::MpegTsTcp:
195 return QStringLiteral(
"MPEG-TS/TCP");
constexpr VideoDecoderOption videoDecoderOptionFromSetting(int value)
The option a stored forceVideoDecoder value names: the default for a value that names none.
Encapsulates the contents of a VIDEO_STREAM_INFORMATION message.
static constexpr const char * videoSource3DRSolo
static constexpr const char * videoSourceParrotDiscovery
static constexpr const char * videoSourceTCP
static constexpr const char * videoSourceUDPH264
static constexpr const char * videoSourceHerelinkHotspot
static constexpr const char * videoSourceRTSP
static constexpr const char * videoSourceYuneecMantisG
static constexpr const char * videoSourceUDPH265
static constexpr const char * videoSourceMPEGTS
static constexpr const char * videoSourceHerelinkAirUnit
GPSCommandSequence port(QByteArrayView port, unsigned baud)
Clears the SBF output of port, keeps a serial port at the link's baud, and selects SBF and the WGS84 ...
Settings snapshot(VideoSettings *videoSettings)
bool isNetworkSource(const QString &videoSource)
True for the manual sources that are network streams (not "disabled", not a local camera).
VideoReceiver::DisplayConfig displayConfig(const Settings &settings)
The display sink settings: GPU zero-copy unless the CPU path or a software decoder is forced.
Role
What a video source, each with a VideoStreamController, is. VideoSourceRole.Primary,...
@ Primary
The stream to display: a vehicle's current camera's current one, else the one the settings configure.
QString transportName(const QString &uri)
bool isAutoStream(const QGCVideoStreamInfo *streamInfo)
True when streamInfo advertises a URI, which then takes precedence over the manual settings.
std::optional< VideoReceiver::Config > resolve(const Settings &settings, const QGCVideoStreamInfo *streamInfo, Role role)
@ Rtsp
Any rtsp* scheme: rtsp://, rtsps://, rtspt://, ...
constexpr bool isValidPort(int port)
A TCP or UDP port a source can name: 1 to 65535.
constexpr bool listens(Transport transport)
The receiver listens on a local UDP port for transport, rather than connect to a server.
std::optional< Transport > transportFor(const QUrl &url)
The transport url's scheme selects, case-insensitively; nullopt for any other scheme.
std::chrono::seconds timeout
bool autoReconnect
Reconnect with backoff after a failure. Applies at once; changing any other field restarts the stream...
How the display sink presents frames. Construct-only: a change applies when restart() rebuilds the si...
The video settings resolve() reads, and what they depend on.
QByteArray conversionElement
VideoDecoderOption forceVideoDecoder
bool disablePixelAspectRatio