init
This commit is contained in:
@@ -63,6 +63,32 @@ class Config
|
||||
get => $this->tcpServerPort;
|
||||
}
|
||||
|
||||
/**
|
||||
* 摄像头配置列表
|
||||
*/
|
||||
public array $cameraConfig {
|
||||
get => $this->cameraConfig;
|
||||
}
|
||||
|
||||
/**
|
||||
* ZLM配置
|
||||
*/
|
||||
public ZLMConfig $zlm {
|
||||
get => $this->zlm;
|
||||
}
|
||||
public string $httpIP{
|
||||
get => $this->httpIP;
|
||||
}
|
||||
public int $httpPort{
|
||||
get => $this->httpPort;
|
||||
}
|
||||
|
||||
/**
|
||||
* 人员检测回调函数
|
||||
* @var callable|null
|
||||
*/
|
||||
private $personDetectionCallback = null;
|
||||
|
||||
private function __construct()
|
||||
{
|
||||
$this->database = new DatabaseConfig();
|
||||
@@ -79,12 +105,56 @@ class Config
|
||||
default => \Monolog\Logger::DEBUG
|
||||
};
|
||||
$this->tcpServerPort = self::getIntEnv('TCP_SERVER_PORT', 50000);
|
||||
$this->logRotationTimeByDay = self::getIntEnv('LOG_ROTATION_TIME_BY_DAY', 14);
|
||||
$this->errorLogRotationTimeByDay = self::getIntEnv('ERROR_LOG_ROTATION_TIME_BY_DAY', 30);
|
||||
$this->cameraConfig = $this->loadCameraConfig();
|
||||
$this->httpIP = self::getStringEnv('HTTP_IP', '0.0.0.0');
|
||||
$this->httpPort = self::getIntEnv('HTTP_PORT', 8080);
|
||||
$this->zlm = new ZLMConfig();
|
||||
$this->personDetectionCallback = null;
|
||||
if (strtoupper(substr(PHP_OS, 0, 3)) === 'WIN' && $this->tcpServerProcessNum > 1) {
|
||||
$this->tcpServerProcessNum = 1;
|
||||
echo "Warning: TCP_SERVER_PROCESS_NUM set to 1 on Windows.\n";
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 加载摄像头配置
|
||||
*/
|
||||
private function loadCameraConfig(): array
|
||||
{
|
||||
// 从环境变量加载摄像头配置
|
||||
// 格式: CAMERA_CONFIG={"camera_01":{"rtsp_url":"rtsp://...","enabled":true}}
|
||||
$configJson = self::getStringEnv('CAMERA_CONFIG', '');
|
||||
if (!empty($configJson)) {
|
||||
$config = json_decode($configJson, true);
|
||||
if (is_array($config)) {
|
||||
return $config;
|
||||
}
|
||||
}
|
||||
|
||||
// 默认空配置
|
||||
return [];
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取人员检测回调函数
|
||||
* @return callable|null
|
||||
*/
|
||||
public function getPersonDetectionCallback(): ?callable
|
||||
{
|
||||
return $this->personDetectionCallback;
|
||||
}
|
||||
|
||||
/**
|
||||
* 设置人员检测回调函数
|
||||
* @param callable|null $callback
|
||||
*/
|
||||
public function setPersonDetectionCallback(?callable $callback): void
|
||||
{
|
||||
$this->personDetectionCallback = $callback;
|
||||
}
|
||||
|
||||
private function __clone()
|
||||
{
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user