refactor: added config file and moved constants

- Moved hardcoded configuration constants to a dedicated config.py file.
- Created VideoConfig, AudioConfig, MainConfig, and Settings classes in config.py

ref: N25B-236
This commit is contained in:
Pim Hutting
2025-11-09 15:43:22 +01:00
parent c037eb7ec2
commit 4402b21a73
8 changed files with 74 additions and 21 deletions

View File

@@ -0,0 +1,46 @@
from __future__ import unicode_literals
import os
class AgentSettings(object):
"""Agent port configuration."""
def __init__(self, actuating_receiver_port=5557, main_receiver_port=5555,video_sender_port=5556, audio_sender_port=5558):
self.actuating_receiver_port = actuating_receiver_port
self.main_receiver_port = main_receiver_port
self.video_sender_port = video_sender_port
self.audio_sender_port = audio_sender_port
class VideoConfig(object):
"""Video configuration constants."""
def __init__(self, camera_index=0, resolution=2, color_space=11, fps=15, stream_name="Pepper Video", image_buffer=6):
self.camera_index = camera_index
self.resolution = resolution
self.color_space = color_space
self.fps = fps
self.stream_name = stream_name
self.image_buffer = image_buffer
class AudioConfig(object):
"""Audio configuration constants."""
def __init__(self, sample_rate=16000, chunk_size=512, channels=1):
self.sample_rate = sample_rate
self.chunk_size = chunk_size
self.channels = channels
class MainConfig(object):
"""Main configuration"""
def __init__(self, poll_timeout_ms=100, max_handler_time_ms=50):
self.poll_timeout_ms = poll_timeout_ms
self.max_handler_time_ms = max_handler_time_ms
class Settings(object):
"""Global settings container."""
def __init__(self, agent_settings=None, video_config=None, audio_config=None, main_config=None):
self.agent_settings = agent_settings or AgentSettings()
self.video_config = video_config or VideoConfig()
self.audio_config = audio_config or AudioConfig()
self.main_config = main_config or MainConfig()
settings = Settings()