Skip to content

Commit 07fec79

Browse files
committed
feat: add new _on_stream_info_cleared / _on_credentials_cleared FrameProcessor methods, and use them when moving a track out of a room
1 parent 2dbe350 commit 07fec79

3 files changed

Lines changed: 14 additions & 31 deletions

File tree

livekit-rtc/livekit/rtc/audio_stream.py

Lines changed: 0 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -245,26 +245,6 @@ def from_track(
245245
noise_cancellation_leave_open=noise_cancellation_leave_open,
246246
)
247247

248-
def _on_processor_stream_info_updated(
249-
self,
250-
*,
251-
room_name: str,
252-
participant_identity: str,
253-
publication_sid: str,
254-
) -> None:
255-
if self._processor is None:
256-
return
257-
self._processor._on_stream_info_updated(
258-
room_name=room_name,
259-
participant_identity=participant_identity,
260-
publication_sid=publication_sid,
261-
)
262-
263-
def _on_processor_credentials_updated(self, *, token: str, url: str) -> None:
264-
if self._processor is None:
265-
return
266-
self._processor._on_credentials_updated(token=token, url=url)
267-
268248
def __del__(self) -> None:
269249
FfiClient.instance.queue.unsubscribe(self._ffi_queue)
270250

livekit-rtc/livekit/rtc/frame_processor.py

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,8 +24,12 @@ def _on_stream_info_updated(
2424
publication_sid: str,
2525
) -> None: ...
2626

27+
def _on_stream_info_cleared(self) -> None: ...
28+
2729
def _on_credentials_updated(self, *, token: str, url: str) -> None: ...
2830

31+
def _on_credentials_cleared(self) -> None: ...
32+
2933
@abstractmethod
3034
def _process(self, frame: T) -> T: ...
3135

livekit-rtc/livekit/rtc/track.py

Lines changed: 10 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -56,19 +56,18 @@ def _on_room_token_refreshed(self) -> None:
5656
if room is None or room._token is None or room._server_url is None:
5757
return
5858
for stream in self._audio_streams:
59-
stream._on_processor_credentials_updated(token=room._token, url=room._server_url)
59+
if not stream._processor:
60+
continue
61+
stream._processor._on_credentials_updated(token=room._token, url=room._server_url)
6062

6163
def _push_processor_metadata_to_stream(self, stream: AudioStream, room: Optional[Room]) -> None:
64+
if not stream._processor:
65+
return
66+
6267
if room is None:
6368
# track left a room — clear processor's room context
64-
# FIXME: This isn't really good, and I can't figure out what should happen here
65-
# Closing the processor doesn't work (the track could get added to another room later)
66-
# Empty values like this don't work, because it causes a drm::Error in the plugin
67-
# Talk to lukas about this in a 1:1 and see if he can think of anything better
68-
stream._on_processor_stream_info_updated(
69-
room_name="", participant_identity="", publication_sid=""
70-
)
71-
# stream._on_processor_credentials_updated(token="", url="")
69+
stream._processor._on_stream_info_cleared()
70+
stream._processor._on_credentials_cleared()
7271
return
7372

7473
identity = ""
@@ -88,13 +87,13 @@ def _push_processor_metadata_to_stream(self, stream: AudioStream, room: Optional
8887
identity, pub_sid = local.identity, local_publication.sid
8988
break
9089

91-
stream._on_processor_stream_info_updated(
90+
stream._processor._on_stream_info_updated(
9291
room_name=room.name,
9392
participant_identity=identity,
9493
publication_sid=pub_sid,
9594
)
9695
if room._token is not None and room._server_url is not None:
97-
stream._on_processor_credentials_updated(token=room._token, url=room._server_url)
96+
stream._processor._on_credentials_updated(token=room._token, url=room._server_url)
9897

9998
def _register_audio_stream(self, stream: AudioStream) -> None:
10099
self._audio_streams.add(stream)

0 commit comments

Comments
 (0)