多进程确保视频流畅度

This commit is contained in:
邓智航
2026-01-26 22:06:52 +08:00
parent 3282d4d77e
commit 1875072f5b
3 changed files with 194 additions and 55 deletions

View File

@@ -17,7 +17,7 @@ from aiortc.mediastreams import VIDEO_CLOCK_RATE, VIDEO_TIME_BASE
class WebRTCServer:
def __init__(self, fps):
def __init__(self, fps, seat, server="ws://localhost:5000"):
self.pcs = set()
self.fps = fps
self.frameContainer = [None]
@@ -31,7 +31,8 @@ class WebRTCServer:
)
self._rtc_thread.start()
self.server = "ws://10.128.50.6:5000"
self.server = server
self.seat = seat
def _start_background_loop(self, loop):
asyncio.set_event_loop(loop)
@@ -43,8 +44,7 @@ class WebRTCServer:
@sio.event
async def connect():
print("已连接到中心信令服务器")
# TODO 注册自己为设备
await sio.emit("checkin", {"device_id": "cam_001"})
await sio.emit("checkin", {"seat_id": self.seat})
@sio.event
async def offer(data):