mirror of
https://github.com/moonlight-stream/moonlight-common-c.git
synced 2026-04-02 22:06:10 +00:00
Minor cleanups to RTSP URL parsing
This commit is contained in:
@@ -701,8 +701,10 @@ static bool parseUrlAddrFromRtspUrlString(const char* rtspUrlString, char* desti
|
|||||||
*urlPathSeparator = 0;
|
*urlPathSeparator = 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
PltSafeStrcpy(destination, destinationLength, rtspUrlScratchBuffer + prefixLen);
|
if (!PltSafeStrcpy(destination, destinationLength, rtspUrlScratchBuffer + prefixLen)) {
|
||||||
destination[destinationLength - 1] = '\0';
|
free(rtspUrlScratchBuffer);
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
free(rtspUrlScratchBuffer);
|
free(rtspUrlScratchBuffer);
|
||||||
return true;
|
return true;
|
||||||
@@ -774,24 +776,22 @@ int performRtspHandshake(PSERVER_INFORMATION serverInfo) {
|
|||||||
if (OriginalVideoBitrate >= HIGH_AUDIO_BITRATE_THRESHOLD &&
|
if (OriginalVideoBitrate >= HIGH_AUDIO_BITRATE_THRESHOLD &&
|
||||||
(AudioCallbacks.capabilities & CAPABILITY_SLOW_OPUS_DECODER) == 0 &&
|
(AudioCallbacks.capabilities & CAPABILITY_SLOW_OPUS_DECODER) == 0 &&
|
||||||
(StreamConfig.streamingRemotely != STREAM_CFG_REMOTE || CHANNEL_COUNT_FROM_AUDIO_CONFIGURATION(StreamConfig.audioConfiguration) <= 2)) {
|
(StreamConfig.streamingRemotely != STREAM_CFG_REMOTE || CHANNEL_COUNT_FROM_AUDIO_CONFIGURATION(StreamConfig.audioConfiguration) <= 2)) {
|
||||||
// If we have an RTSP URL string and it was successfully parsed, use that string
|
// If we have an RTSP URL string and it was successfully parsed and copied, use that string
|
||||||
if (serverInfo->rtspSessionUrl != NULL && parseUrlAddrFromRtspUrlString(serverInfo->rtspSessionUrl, urlAddr, sizeof(urlAddr))) {
|
if (serverInfo->rtspSessionUrl == NULL ||
|
||||||
PltSafeStrcpy(rtspTargetUrl, sizeof(rtspTargetUrl), serverInfo->rtspSessionUrl);
|
!parseUrlAddrFromRtspUrlString(serverInfo->rtspSessionUrl, urlAddr, sizeof(urlAddr)) ||
|
||||||
rtspTargetUrl[sizeof(rtspTargetUrl) - 1] = '\0';
|
!PltSafeStrcpy(rtspTargetUrl, sizeof(rtspTargetUrl), serverInfo->rtspSessionUrl)) {
|
||||||
}
|
|
||||||
else {
|
|
||||||
// If an RTSP URL string was not provided or failed to parse, we will construct one now as best we can.
|
// If an RTSP URL string was not provided or failed to parse, we will construct one now as best we can.
|
||||||
//
|
//
|
||||||
// NB: If the remote address is not a LAN address, the host will likely not enable high quality
|
// NB: If the remote address is not a LAN address, the host will likely not enable high quality
|
||||||
// audio since it only does that for local streaming normally. We can avoid this limitation,
|
// audio since it only does that for local streaming normally. We can avoid this limitation,
|
||||||
// but only if the caller gave us the RTSP session URL that it received from the host during launch.
|
// but only if the caller gave us the RTSP session URL that it received from the host during launch.
|
||||||
addrToUrlSafeString(&RemoteAddr, urlAddr, sizeof(urlAddr));
|
addrToUrlSafeString(&RemoteAddr, urlAddr, sizeof(urlAddr));
|
||||||
snprintf(rtspTargetUrl, sizeof(rtspTargetUrl), "rtsp%s://%s:%u", useEnet ? "ru" : "", urlAddr, RtspPortNumber);
|
snprintf(rtspTargetUrl, sizeof(rtspTargetUrl), "rtsp%s://%s:%u", useEnet ? "ru" : "", urlAddr, RtspPortNumber);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
PltSafeStrcpy(urlAddr, sizeof(urlAddr), "0.0.0.0");
|
PltSafeStrcpy(urlAddr, sizeof(urlAddr), "0.0.0.0");
|
||||||
snprintf(rtspTargetUrl, sizeof(rtspTargetUrl), "rtsp%s://%s:%u", useEnet ? "ru" : "", urlAddr, RtspPortNumber);
|
snprintf(rtspTargetUrl, sizeof(rtspTargetUrl), "rtsp%s://%s:%u", useEnet ? "ru" : "", urlAddr, RtspPortNumber);
|
||||||
}
|
}
|
||||||
|
|
||||||
switch (AppVersionQuad[0]) {
|
switch (AppVersionQuad[0]) {
|
||||||
|
|||||||
Reference in New Issue
Block a user