55 lines
1.3 KiB
Python
55 lines
1.3 KiB
Python
"""
|
|
RTSP 服务模块 - 简洁版本,直接使用原始服务
|
|
"""
|
|
|
|
import threading
|
|
from rtsp_service_ws_1217 import RTSPService
|
|
|
|
|
|
class SimpleRTSPServer:
|
|
"""RTSP 服务管理器 - 简洁包装器"""
|
|
|
|
def __init__(self):
|
|
self.is_running = False
|
|
self.service = None
|
|
self.thread = None
|
|
|
|
def start(self):
|
|
"""启动 RTSP 服务"""
|
|
if self.is_running:
|
|
return
|
|
|
|
print("🚀 启动 RTSP 服务...")
|
|
|
|
# 创建原始服务实例
|
|
self.service = RTSPService(config_path="config.yaml")
|
|
|
|
# 在新线程中启动服务
|
|
self.thread = threading.Thread(
|
|
target=self.service.start,
|
|
daemon=True
|
|
)
|
|
self.thread.start()
|
|
|
|
self.is_running = True
|
|
print("✅ RTSP 服务启动完成")
|
|
|
|
def stop(self):
|
|
"""停止 RTSP 服务"""
|
|
if not self.is_running:
|
|
return
|
|
|
|
print("🛑 停止 RTSP 服务...")
|
|
|
|
if self.service:
|
|
self.service.stop()
|
|
|
|
if self.thread:
|
|
self.thread.join(timeout=5.0)
|
|
|
|
self.is_running = False
|
|
print("✅ RTSP 服务已停止")
|
|
|
|
|
|
# 创建全局实例
|
|
rtsp_server = SimpleRTSPServer() |