mirror of
https://github.com/Dispatcharr/Dispatcharr.git
synced 2026-07-18 09:06:06 +00:00
Some checks are pending
CI Pipeline / prepare (push) Waiting to run
CI Pipeline / docker (amd64, ubuntu-24.04) (push) Blocked by required conditions
CI Pipeline / docker (arm64, ubuntu-24.04-arm) (push) Blocked by required conditions
CI Pipeline / create-manifest (push) Blocked by required conditions
Build and Push Multi-Arch Docker Image / build-and-push (push) Waiting to run
Frontend Tests / test (push) Waiting to run
- Write channel_name (and stream_name fallback) into Redis metadata at channel init time; read directly from Redis in get_basic_channel_info, removing Stream and M3UAccountProfile DB queries on every stats tick - Pass channel.name from views.py into ChannelService.initialize_channel via new optional channel_name param, skipping the redundant Channel DB lookup on the normal streaming path - Pass stream_name from get_stream_info_for_switch through change_stream_url into _update_channel_metadata, skipping the Stream DB lookup on switches - Resolve m3u_profile_name on the frontend from the playlists store instead of querying the DB per tick; StreamConnectionCard builds an id→profile map - Fix channel start notification showing no name and stop notification showing UUID: both now use channel_name from the stats WebSocket payload
119 lines
3.2 KiB
Python
119 lines
3.2 KiB
Python
"""
|
|
Constants used throughout the TS Proxy application.
|
|
Centralizing constants makes it easier to maintain and modify them.
|
|
"""
|
|
|
|
# Redis related constants
|
|
REDIS_KEY_PREFIX = "ts_proxy"
|
|
REDIS_TTL_DEFAULT = 3600 # 1 hour
|
|
REDIS_TTL_SHORT = 60 # 1 minute
|
|
REDIS_TTL_MEDIUM = 300 # 5 minutes
|
|
|
|
# Channel states
|
|
class ChannelState:
|
|
INITIALIZING = "initializing"
|
|
CONNECTING = "connecting"
|
|
WAITING_FOR_CLIENTS = "waiting_for_clients"
|
|
ACTIVE = "active"
|
|
ERROR = "error"
|
|
STOPPING = "stopping"
|
|
STOPPED = "stopped"
|
|
BUFFERING = "buffering"
|
|
|
|
# States before a channel is fully active. Used by the stream manager
|
|
# finally block to decide whether a failed stream can write ERROR.
|
|
PRE_ACTIVE = frozenset([INITIALIZING, CONNECTING, BUFFERING, WAITING_FOR_CLIENTS])
|
|
|
|
# Event types
|
|
class EventType:
|
|
STREAM_SWITCH = "stream_switch"
|
|
STREAM_SWITCHED = "stream_switched"
|
|
CHANNEL_STOP = "channel_stop"
|
|
CHANNEL_STOPPED = "channel_stopped"
|
|
CLIENT_CONNECTED = "client_connected"
|
|
CLIENT_DISCONNECTED = "client_disconnected"
|
|
CLIENT_STOP = "client_stop"
|
|
|
|
# Stream types
|
|
class StreamType:
|
|
HLS = "hls"
|
|
RTSP = "rtsp"
|
|
UDP = "udp"
|
|
TS = "ts"
|
|
UNKNOWN = "unknown"
|
|
|
|
# Channel metadata field names stored in Redis
|
|
class ChannelMetadataField:
|
|
# Basic fields
|
|
URL = "url"
|
|
USER_AGENT = "user_agent"
|
|
STATE = "state"
|
|
OWNER = "owner"
|
|
STREAM_ID = "stream_id"
|
|
CHANNEL_NAME = "channel_name"
|
|
STREAM_NAME = "stream_name"
|
|
|
|
# Profile fields
|
|
STREAM_PROFILE = "stream_profile"
|
|
M3U_PROFILE = "m3u_profile"
|
|
|
|
# Status and error fields
|
|
ERROR_MESSAGE = "error_message"
|
|
ERROR_TIME = "error_time"
|
|
STATE_CHANGED_AT = "state_changed_at"
|
|
INIT_TIME = "init_time"
|
|
CONNECTION_READY_TIME = "connection_ready_time"
|
|
|
|
# Buffer and data tracking
|
|
BUFFER_CHUNKS = "buffer_chunks"
|
|
TOTAL_BYTES = "total_bytes"
|
|
|
|
# Stream switching
|
|
STREAM_SWITCH_TIME = "stream_switch_time"
|
|
STREAM_SWITCH_REASON = "stream_switch_reason"
|
|
|
|
# FFmpeg performance metrics
|
|
FFMPEG_SPEED = "ffmpeg_speed"
|
|
FFMPEG_FPS = "ffmpeg_fps"
|
|
ACTUAL_FPS = "actual_fps"
|
|
FFMPEG_OUTPUT_BITRATE = "ffmpeg_output_bitrate"
|
|
FFMPEG_BITRATE = "ffmpeg_bitrate"
|
|
FFMPEG_STATS_UPDATED = "ffmpeg_stats_updated"
|
|
|
|
# Video stream info
|
|
VIDEO_CODEC = "video_codec"
|
|
RESOLUTION = "resolution"
|
|
WIDTH = "width"
|
|
HEIGHT = "height"
|
|
SOURCE_FPS = "source_fps"
|
|
PIXEL_FORMAT = "pixel_format"
|
|
VIDEO_BITRATE = "video_bitrate"
|
|
SOURCE_BITRATE = "source_bitrate"
|
|
|
|
# Audio stream info
|
|
AUDIO_CODEC = "audio_codec"
|
|
SAMPLE_RATE = "sample_rate"
|
|
AUDIO_CHANNELS = "audio_channels"
|
|
AUDIO_BITRATE = "audio_bitrate"
|
|
|
|
# Stream format info
|
|
STREAM_TYPE = "stream_type"
|
|
# Stream info timestamp
|
|
STREAM_INFO_UPDATED = "stream_info_updated"
|
|
|
|
# Client metadata fields
|
|
CONNECTED_AT = "connected_at"
|
|
LAST_ACTIVE = "last_active"
|
|
BYTES_SENT = "bytes_sent"
|
|
AVG_RATE_KBPS = "avg_rate_KBps"
|
|
CURRENT_RATE_KBPS = "current_rate_KBps"
|
|
IP_ADDRESS = "ip_address"
|
|
WORKER_ID = "worker_id"
|
|
CHUNKS_SENT = "chunks_sent"
|
|
STATS_UPDATED_AT = "stats_updated_at"
|
|
|
|
# TS packet constants
|
|
TS_PACKET_SIZE = 188
|
|
TS_SYNC_BYTE = 0x47
|
|
NULL_PID_HIGH = 0x1F
|
|
NULL_PID_LOW = 0xFF
|