Skip to content

Commit cfa04b2

Browse files
Hormoldclaude
andcommitted
feat(rtc): add restart_publisher method stub to Room
Add `restart_publisher()` method stub to the Room class. This method will perform an ICE restart on the publisher PeerConnection when implemented. Use case: When sending data (stream_text/publish_data) times out but receiving audio/video continues to work, the publisher PeerConnection may be stuck. Currently there's no way to recover without disconnecting the entire room. This is a placeholder that raises NotImplementedError until the corresponding FFI bindings are added to livekit/rust-sdks. Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
1 parent 2744c66 commit cfa04b2

1 file changed

Lines changed: 28 additions & 0 deletions

File tree

livekit-rtc/livekit/rtc/room.py

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -541,6 +541,34 @@ async def get_rtc_stats(self) -> RtcStats:
541541

542542
return RtcStats(publisher_stats=publisher_stats, subscriber_stats=subscriber_stats)
543543

544+
async def restart_publisher(self) -> None:
545+
"""Restart the publisher PeerConnection with an ICE restart.
546+
547+
This is useful when the publisher connection fails while the subscriber still works.
548+
For example, when sending data (stream_text/publish_data) times out but receiving
549+
audio/video still works.
550+
551+
Raises:
552+
NotImplementedError: This method requires FFI bindings in rust-sdks.
553+
See: https://github.com/livekit/rust-sdks/issues/XXX
554+
555+
Example:
556+
```python
557+
try:
558+
await room.local_participant.publish_data(data)
559+
except TimeoutError:
560+
# Publisher might be stuck, try to restart it
561+
await room.restart_publisher()
562+
# Retry the operation
563+
await room.local_participant.publish_data(data)
564+
```
565+
"""
566+
raise NotImplementedError(
567+
"restart_publisher() requires FFI bindings in livekit/rust-sdks. "
568+
"This is a placeholder for future implementation. "
569+
"See: https://github.com/livekit/python-sdks/pull/571"
570+
)
571+
544572
def register_byte_stream_handler(self, topic: str, handler: ByteStreamHandler):
545573
existing_handler = self._byte_stream_handlers.get(topic)
546574
if existing_handler is None:

0 commit comments

Comments
 (0)