Fix Connectiojn Limit Bug

This commit is contained in:
Exil Productions
2025-12-26 23:37:04 +01:00
parent ea52870ca5
commit fad6425f44
5 changed files with 21 additions and 15 deletions

View File

@@ -1,5 +1,5 @@
#include "../include/rtmp_capi.h"
#include "../include/rtmp_server.h"
#include "../include/rtmp_capi.hpp"
#include "../include/rtmp_server.hpp"
#include <string>
#include <vector>
@@ -109,12 +109,15 @@ void rtmp_server_destroy(RtmpServerHandle handle) {
delete impl->server;
delete impl;
}
bool rtmp_server_start(RtmpServerHandle handle) {
if (!handle)
bool rtmp_server_start(RtmpServerHandle handle, bool *isRunning) {
if (!handle || !isRunning)
return false;
Impl *impl = static_cast<Impl *>(handle);
return impl->server->start();
bool result = impl->server->start(*isRunning);
return result;
}
void rtmp_server_stop(RtmpServerHandle handle) {
if (!handle)
return;

View File

@@ -1,4 +1,4 @@
#include "../include/rtmp_server.h"
#include "../include/rtmp_server.hpp"
#include <algorithm>
#include <cstring>
#include <ctime>
@@ -1007,7 +1007,7 @@ RTMPServer::RTMPServer(int port) : port(port), server_fd(-1), running(false) {}
RTMPServer::~RTMPServer() { stop(); }
bool RTMPServer::start() {
bool RTMPServer::start(bool& isRunning) {
server_fd = socket(AF_INET, SOCK_STREAM, 0);
if (server_fd < 0) {
LOG_ERROR("Failed to create socket");
@@ -1040,6 +1040,7 @@ bool RTMPServer::start() {
}
timeout_thread = std::thread(&RTMPServer::timeoutCheckRoutine, this);
LOG_INFO("RTMP Server started on port " + std::to_string(port));
isRunning = true;
return true;
}
@@ -1436,10 +1437,10 @@ bool RTMPServer::checkConnectionLimits(const std::string &app,
bool is_publisher) const {
if (is_publisher) {
int current = countPublishers(app, stream_key);
return current < max_publishers_per_stream;
return current >= max_publishers_per_stream;
} else {
int current = countPlayers(app, stream_key);
return current < max_players_per_stream;
return current >= max_players_per_stream;
}
}