transports: allow base transports to be reused

This commit is contained in:
Aleix Conchillo Flaqué
2024-05-14 00:28:43 -07:00
parent a344101cff
commit 20c679988c
2 changed files with 15 additions and 3 deletions

View File

@@ -30,7 +30,7 @@ class BaseInputTransport(FrameProcessor):
self._params = params
self._running = True
self._running = False
# Start media threads.
if self._params.audio_in_enabled or self._params.vad_enabled:
@@ -41,6 +41,11 @@ class BaseInputTransport(FrameProcessor):
self._stopped_event = asyncio.Event()
async def start(self):
if self._running:
return
self._running = True
if self._params.audio_in_enabled or self._params.vad_enabled:
self._audio_in_thread.start()
self._audio_out_thread.start()

View File

@@ -35,7 +35,7 @@ class BaseOutputTransport(FrameProcessor):
self._params = params
self._running = True
self._running = False
# These are the images that we should send to the camera at our desired
# framerate.
@@ -45,7 +45,6 @@ class BaseOutputTransport(FrameProcessor):
if self._params.camera_out_enabled:
self._camera_out_queue = queue.Queue()
self._camera_out_thread = threading.Thread(target=self._camera_out_thread_handler)
self._camera_out_thread.start()
self._sink_queue = queue.Queue()
self._sink_thread = threading.Thread(target=self._sink_thread_handler)
@@ -53,6 +52,14 @@ class BaseOutputTransport(FrameProcessor):
self._stopped_event = asyncio.Event()
async def start(self):
if self._running:
return
self._running = True
if self._params.camera_out_enabled:
self._camera_out_thread.start()
self._sink_thread.start()
async def stop(self):