116 lines
3.6 KiB
Python
116 lines
3.6 KiB
Python
from __future__ import unicode_literals
|
|
|
|
|
|
class AgentSettings(object):
|
|
"""
|
|
Agent port configuration.
|
|
|
|
:ivar actuating_receiver_port: Port for receiving actuation commands.
|
|
:vartype actuating_receiver_port: int
|
|
:ivar main_receiver_port: Port for receiving main messages.
|
|
:vartype main_receiver_port: int
|
|
:ivar video_sender_port: Port used for sending video frames.
|
|
:vartype video_sender_port: int
|
|
:ivar audio_sender_port: Port used for sending audio data.
|
|
:vartype audio_sender_port: int
|
|
"""
|
|
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.
|
|
|
|
:ivar camera_index: Index of the camera used.
|
|
:vartype camera_index: int
|
|
:ivar resolution: Video resolution mode.
|
|
:vartype resolution: int
|
|
:ivar color_space: Color space identifier.
|
|
:vartype color_space: int
|
|
:ivar fps: Frames per second of the video stream.
|
|
:vartype fps: int
|
|
:ivar stream_name: Name of the video stream.
|
|
:vartype stream_name: str
|
|
:ivar image_buffer: Internal buffer size for video frames.
|
|
:vartype image_buffer: int
|
|
"""
|
|
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.
|
|
|
|
:ivar sample_rate: Audio sampling rate in Hz.
|
|
:vartype sample_rate: int
|
|
:ivar chunk_size: Size of audio chunks to capture/process.
|
|
:vartype chunk_size: int
|
|
:ivar channels: Number of audio channels.
|
|
:vartype channels: int
|
|
"""
|
|
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 system configuration.
|
|
|
|
:ivar poll_timeout_ms: Timeout for polling events, in milliseconds.
|
|
:vartype poll_timeout_ms: int
|
|
:ivar max_handler_time_ms: Maximum allowed handler time, in milliseconds.
|
|
:vartype max_handler_time_ms: int
|
|
"""
|
|
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.
|
|
|
|
:ivar agent_settings: Agent-related port configuration.
|
|
:vartype agent_settings: AgentSettings
|
|
:ivar video_config: Video stream configuration.
|
|
:vartype video_config: VideoConfig
|
|
:ivar audio_config: Audio stream configuration.
|
|
:vartype audio_config: AudioConfig
|
|
:ivar main_config: Main system-level configuration.
|
|
:vartype main_config: MainConfig
|
|
"""
|
|
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()
|