mirror of
https://github.com/infiniteCable2/openpilot.git
synced 2026-08-05 08:16:03 +08:00
webrtc: signal shutdown over datachannel (#38185)
signal shut down, fix enabled bug
This commit is contained in:
@@ -262,7 +262,7 @@ class StreamSession:
|
||||
self.params = Params()
|
||||
builder = WebRTCAnswerBuilder(sdp)
|
||||
|
||||
self.enabled = enabled if enabled else True # default to enabled
|
||||
self.enabled = enabled if enabled is not None else True # default to enabled
|
||||
self.video_track = LiveStreamVideoStreamTrack(init_camera, self.enabled) if not debug_mode else VideoStreamTrack()
|
||||
builder.add_video_stream(init_camera, self.video_track)
|
||||
self.stream = builder.stream()
|
||||
@@ -381,7 +381,7 @@ async def get_stream(request: 'web.Request'):
|
||||
if s.run_task and not s.run_task.done():
|
||||
try:
|
||||
ch = s.stream.get_messaging_channel()
|
||||
ch.send(json.dumps({"type": "connectionReplaced", "data": "Another device has connected, closing this session."}))
|
||||
ch.send(json.dumps({"type": "disconnect", "data": "Another device has connected, closing this session."}))
|
||||
except Exception:
|
||||
pass
|
||||
await s.stop()
|
||||
@@ -431,6 +431,11 @@ async def post_notify(request: 'web.Request'):
|
||||
|
||||
async def on_shutdown(app: 'web.Application'):
|
||||
for session in app['streams'].values():
|
||||
try:
|
||||
ch = session.stream.get_messaging_channel()
|
||||
ch.send(json.dumps({"type": "disconnect", "data": "device stream has been stopped."}))
|
||||
except Exception:
|
||||
pass
|
||||
await session.stop()
|
||||
del app['streams']
|
||||
|
||||
|
||||
Reference in New Issue
Block a user