Skip to content

Commit

Permalink
- Fix bug couldn't reallocate ports.
Browse files Browse the repository at this point in the history
  • Loading branch information
hanatyan128 committed Nov 22, 2024
1 parent 9d3c0fb commit a576bb3
Showing 1 changed file with 10 additions and 16 deletions.
26 changes: 10 additions & 16 deletions src/sources/ingress-link-source.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,7 @@ IngressLinkSource::IngressLinkSource(
{
name = obs_source_get_name(_source);
obs_log(LOG_DEBUG, "%s: Source creating", qUtf8Printable(name));
connRequest.setPort(0);

if (!strcmp(obs_data_get_json(settings), "{}")) {
// Initial creation -> Load recently settings from file
Expand All @@ -55,13 +56,6 @@ IngressLinkSource::IngressLinkSource(
// Capture source's settings first
captureSettings(settings);

// Allocate port (non-relay only)
if (!connRequest.getRelay()) {
connRequest.setPort(apiClient->getFreePort());
} else {
connRequest.setPort(0);
}

// Create decoder private source (SRT, RIST, etc.)
OBSDataAutoRelease decoderSettings = createDecoderSettings();
QString decoderName = QString("%1 (decoder)").arg(obs_source_get_name(_source));
Expand Down Expand Up @@ -234,6 +228,15 @@ void IngressLinkSource::captureSettings(obs_data_t *settings)
newRequest.setRevision(revision);

connRequest = newRequest;

// Re-allocate port
if (connRequest.getPort()) {
apiClient->releasePort(connRequest.getPort());
connRequest.setPort(0);
}
if (!connRequest.getRelay()) {
connRequest.setPort(apiClient->getFreePort());
}
}

obs_data_t *IngressLinkSource::createDecoderSettings()
Expand Down Expand Up @@ -642,15 +645,6 @@ void IngressLinkSource::reactivate()
OBSSourceAutoRelease source = obs_weak_source_get_source(weakSource);
OBSDataAutoRelease settings = obs_source_get_settings(source);

// Re-allocate port
if (connRequest.getPort()) {
apiClient->releasePort(connRequest.getPort());
connRequest.setPort(0);
}
if (!connRequest.getRelay()) {
connRequest.setPort(apiClient->getFreePort());
}

onSettingsUpdate(settings);
obs_log(LOG_DEBUG, "%s: Source reactivated with rev.%d", qUtf8Printable(name), revision);
}
Expand Down

0 comments on commit a576bb3

Please sign in to comment.